メインコンテンツまでスキップ
Version: v2.2.0

参照整合性の検証

FRUCtoS サーバではリファレンス要素で指定されるリソースの参照整合性を検証する目的でリファレンス要素の値を変換する場合があります。
本章の参照整合性とは、リファレンス要素で指定されたリソースが FRUCtoS サーバに存在するかどうかを検証するための仕組みです。
※ 外部リソース参照は参照整合性の検証対象外です。

create, update, batch / transaction インタラクション実行時は、リクエストのリソース内に存在するリファレンス要素が後述の条件を満たす場合、絶対 URL の相対化( [type]/[id] 形式)、または相対 URL の絶対化を行います。
リファレンス要素の値は相対化または絶対化した形式でサーバに登録されます。

単一リソース

リファレンス要素が FRUCtoS サーバ URL の絶対参照である場合のみ相対化を行います。

リファレンス要素変換参照整合性
の検証
絶対参照(FRUCtoS サーバ)
(例)http://localhost:8080/fructos/Organization/1
相対化
(例)Organization/1
絶対参照(外部サーバ)
(例)http://example.org/fhir/Organization/1
-×
相対参照
(例)Organization/1
-

絶対参照(FRUCtoS サーバ)

単一リソース内に存在するリファレンス要素が絶対参照であり、そのベース URL が FRUCtoS サーバ URL の場合は相対化を行います。

(例)Patient リソースの managingOrganization.reference 要素が絶対参照(ベース URL が FRUCtoS サーバ URL)の場合

POST [base]/Patient
  • リクエストボディ
{
"resourceType": "Patient",
"active": true,
"name": [
{
"use": "official",
"family": "Donald",
"given": [
"Duck"
]
}
],
"gender": "male",
"managingOrganization": {
"reference": "http://localhost:8080/fructos/Organization/1",
"display": "ACME Healthcare, Inc"
}
}

managingOrganization.reference 要素の値「 http://localhost:8080/fructos/Organization/1 」を「 Organization/1 」に相対化します。
managingOrganization.reference 要素で指定された Organization リソースが FRUCtoS サーバに登録されている場合は以下のレスポンスを返却します。

  • レスポンスボディ
    201 Created
{
"resourceType": "Patient",
"id": "2",
"meta": {
"versionId": "1",
"lastUpdated": "2021-10-26T16:08:27.331+09:00"
},
"active": true,
"name": [
{
"use": "official",
"family": "Donald",
"given": [
"Duck"
]
}
],
"gender": "male",
"managingOrganization": {
"reference": "Organization/1",
"display": "ACME Healthcare, Inc"
}
}

managingOrganization.reference 要素で指定された Organization リソースが FRUCtoS サーバに登録されていない場合はエラーを返却します。

  • レスポンスボディ
    400 Bad Request
{
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "fatal",
"code": "invalid",
"details": {
"text": "The referenced resource \"Organization/1\" does not exist."
},
"diagnostics": "The referenced resource \"Organization/1\" does not exist."
}
]
}

絶対参照(外部サーバ)

単一リソース内に存在するリファレンス要素が絶対参照であり、そのベース URL が外部サーバ URL の場合は相対化を行いません。

(例)Patient リソースの managingOrganization.reference 要素が絶対参照(ベース URL が外部サーバ URL)の場合

POST [base]/Patient
  • リクエストボディ
{
"resourceType": "Patient",
"active": true,
"name": [
{
"use": "official",
"family": "Donald",
"given": [
"Duck"
]
}
],
"gender": "male",
"managingOrganization": {
"reference": "http://example.org/fhir/Organization/1",
"display": "ACME Healthcare, Inc"
}
}

外部リソースの参照整合性は検証しないため、Patient リソースが FHIR 仕様に準拠している場合は以下のレスポンスを返却します。

  • レスポンスボディ
    201 Created
{
"resourceType": "Patient",
"id": "2",
"meta": {
"versionId": "1",
"lastUpdated": "2021-10-26T15:39:42.927+09:00"
},
"active": true,
"name": [
{
"use": "official",
"family": "Donald",
"given": [
"Duck"
]
}
],
"gender": "male",
"managingOrganization": {
"reference": "http://example.org/fhir/Organization/1",
"display": "ACME Healthcare, Inc"
}
}

相対参照

単一リソース内に存在するリファレンス要素が相対参照の場合は絶対化を行いません。

(例)Patient リソースの managingOrganization.reference 要素が相対参照の場合

POST [base]/Patient
  • リクエストボディ
{
"resourceType": "Patient",
"active": true,
"name": [
{
"use": "official",
"family": "Donald",
"given": [
"Duck"
]
}
],
"gender": "male",
"managingOrganization": {
"reference": "Organization/1",
"display": "ACME Healthcare, Inc"
}
}

managingOrganization.reference 要素で指定された Organization リソースが FRUCtoS サーバに登録されている場合は以下のレスポンスを返却します。

  • レスポンスボディ
    201 Created
{
"resourceType": "Patient",
"id": "9",
"meta": {
"versionId": "1",
"lastUpdated": "2021-10-26T15:48:17.111+09:00"
},
"active": true,
"name": [
{
"use": "official",
"family": "Donald",
"given": [
"Duck"
]
}
],
"gender": "male",
"managingOrganization": {
"reference": "Organization/1",
"display": "ACME Healthcare, Inc"
}
}

managingOrganization.reference 要素で指定された Organization リソースが FRUCtoS サーバに登録されていない場合はエラーを返却します。

  • レスポンスボディ
    400 Bad Request
{
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "fatal",
"code": "invalid",
"details": {
"text": "The referenced resource \"Organization/1\" does not exist."
},
"diagnostics": "The referenced resource \"Organization/1\" does not exist."
}
]
}

Bundle リソース

単一リソースと同様に、リファレンス要素が絶対参照であり、ベース URL が FRUCtoS サーバの URL の場合は相対化を行います。
また、リファレンス要素が相対参照であり、Bundle.entry.fullUrl 要素の値が絶対 URL でベース URL が外部サーバ URL の場合は絶対化を行います。

Bundle.typedocument または message の場合は、Bundle リソース内の参照整合性の検証を行います。(詳細はバリデーションに記載)

リファレンス要素Bundle.entry.fullUrl変換参照整合性
の検証
絶対参照(FRUCtoS サーバ)
(例)http://localhost:8080/fructos/Organization/1
-相対化
(例)Organization/1
○     
絶対参照(外部サーバ)
(例)http://example.org/fhir/Organization/1
--×
相対参照(Bundle.entry.fullUrl:外部サーバ)
(例)Organization/1
絶対 URL(外部サーバ)
(例)http://example.org/fhir/Patient/1
絶対化
(例)http://example.org/fhir/Organization/1
×
相対参照(Bundle.entry.fullUrl:FRUCtoS サーバ)
(例)Organization/1
絶対 URL(FRUCtoS サーバ)
(例)http://localhost:8080/
fructos/Patient/1
-
相対参照(Bundle.entry.fullUrl:絶対 URL 以外)
(例)Organization/1
絶対 URL 以外
(例)urn:uuid:61ebe359-bfdc-4613-8bf2-c5e300945f0a
-×

相対参照(Bundle.entry.fullUrl:外部サーバ)

リファレンス要素が相対参照であり、Bundle.entry.fullUrl 要素の値が絶対 URL(ベース URL が外部サーバ URL)の場合は絶対化を行います。
ベース URL は Bundle.entry.fullUrl 要素と同一の外部サーバ URL となります。

(例)Patient リソースの managingOrganization.reference 要素が相対参照で、Patient リソースを含む Bundle.entryfullUrl 要素が絶対 URL(ベース URL が外部サーバ URL)の場合

POST [base]/Bundle
  • リクエストボディ
{
"resourceType": "Bundle",
"type": "message",
"timestamp": "2015-07-14T11:15:33+10:00",
"entry": [
{
"fullUrl": "urn:uuid:267b18ce-3d37-4581-9baa-6fada338038b",
"resource": {
"resourceType": "MessageHeader",
"id": "267b18ce-3d37-4581-9baa-6fada338038b",
"eventCoding": {
"system": "http://example.org/fhir/message-events",
"code": "patient-link"
},
"source": {
"endpoint": "http://example.org/clients/ehr-lite"
},
"focus": [
{
"reference": "http://acme.com/ehr/fhir/Patient/pat1"
}
]
}
},
{
"fullUrl": "http://acme.com/ehr/fhir/Patient/pat1",
"resource": {
"resourceType": "Patient",
"id": "pat1",
"active": true,
"name": [
{
"use": "official",
"family": "Donald",
"given": [
"Duck"
]
}
],
"gender": "male",
"managingOrganization": {
"reference": "Organization/1",
"display": "ACME Healthcare, Inc"
}
}
}
]
}

managingOrganization.reference 要素の値 「 Organization/1 」を「 http://acme.com/ehr/fhir/Organization/1 」に絶対化します。
外部リソースの参照整合性は検証しないため、Bundle リソースが FHIR 仕様に準拠している場合は以下のレスポンスを返却します。

  • レスポンスボディ
    201 Created
{
"resourceType": "Bundle",
"id": "4",
"meta": {
"versionId": "1",
"lastUpdated": "2021-10-26T15:34:59.228+09:00"
},
"type": "message",
"timestamp": "2015-07-14T11:15:33+10:00",
"entry": [
{
"fullUrl": "urn:uuid:267b18ce-3d37-4581-9baa-6fada338038b",
"resource": {
"resourceType": "MessageHeader",
"id": "4#urn:uuid:267b18ce-3d37-4581-9baa-6fada338038b",
"eventCoding": {
"system": "http://example.org/fhir/message-events",
"code": "patient-link"
},
"source": {
"endpoint": "http://example.org/clients/ehr-lite"
},
"focus": [
{
"reference": "http://acme.com/ehr/fhir/Patient/pat1"
}
]
}
},
{
"fullUrl": "http://acme.com/ehr/fhir/Patient/pat1",
"resource": {
"resourceType": "Patient",
"id": "4#http://acme.com/ehr/fhir/Patient/pat1",
"active": true,
"name": [
{
"use": "official",
"family": "Donald",
"given": [
"Duck"
]
}
],
"gender": "male",
"managingOrganization": {
"reference": "http://acme.com/ehr/fhir/Organization/1",
"display": "ACME Healthcare, Inc"
}
}
}
]
}

相対参照(Bundle.entry.fullUrl:FRUCtoS サーバ)

リファレンス要素が相対参照であり、Bundle.entry.fullUrl 要素の値が絶対 URL(ベース URL が FRUCtoS サーバ URL)の場合は絶対化を行いません。

(例)Patient リソースの managingOrganization.reference 要素が相対参照で、Patient リソースを含む Bundle.entryfullUrl 要素が絶対 URL(ベース URL が FRUCtoS サーバ URL)の場合

POST [base]
  • リクエストボディ
{
"resourceType": "Bundle",
"type": "transaction",
"entry": [
{
"fullUrl": "urn:uuid:61ebe359-bfdc-4613-8bf2-c5e300945f0a",
"resource": {
"resourceType": "Patient",
"active": true,
"name": [
{
"use": "official",
"family": "Chalmers",
"given": [
"Peter",
"James"
]
}
],
"gender": "male",
"birthDate": "1974-12-25"
},
"request": {
"method": "POST",
"url": "Patient"
}
},
{
"fullUrl": "http://localhost:8080/fructos/Patient/4",
"resource": {
"resourceType": "Patient",
"id": "4",
"active": true,
"name": [
{
"use": "official",
"family": "Donald",
"given": [
"Duck"
]
}
],
"gender": "male",
"birthDate": "1980-12-20",
"managingOrganization": {
"reference": "Organization/1"
}
},
"request": {
"method": "PUT",
"url": "Patient/4"
}
}
]
}

managingOrganization.reference 要素で指定された Organization リソースが FRUCtoS サーバに登録されている場合は以下のレスポンスを返却します。

  • レスポンスボディ
    201 Created
{
"resourceType": "Bundle",
"id": "8c6e67ca-493d-4fae-9c59-d7cfaad8c074",
"type": "transaction-response",
"entry": [
{
"fullUrl": "http://localhost:8080/fructos/Patient/7",
"resource": {
"resourceType": "Patient",
"id": "7",
"meta": {
"versionId": "1",
"lastUpdated": "2021-11-02T10:37:46.584+09:00"
},
"active": true,
"name": [
{
"use": "official",
"family": "Chalmers",
"given": [
"Peter",
"James"
]
}
],
"gender": "male",
"birthDate": "1974-12-25"
},
"response": {
"status": "201 CREATED",
"location": "Patient/7/_history/1",
"etag": "W/\"1\"",
"lastModified": "2021-11-02T10:37:46.584+09:00"
}
},
{
"fullUrl": "http://localhost:8080/fructos/Patient/4",
"resource": {
"resourceType": "Patient",
"id": "4",
"meta": {
"versionId": "2",
"lastUpdated": "2021-11-02T10:37:46.648+09:00"
},
"active": true,
"name": [
{
"use": "official",
"family": "Donald",
"given": [
"Duck"
]
}
],
"gender": "male",
"birthDate": "1980-12-20",
"managingOrganization": {
"reference": "Organization/1"
}
},
"response": {
"status": "200 OK",
"etag": "W/\"2\"",
"lastModified": "2021-11-02T10:37:46.648+09:00"
}
}
]
}

managingOrganization.reference 要素で指定された Organization リソースが FRUCtoS サーバに登録されていない場合は、エラーを返却します。

  • レスポンスボディ
    400 Bad Request
{
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "fatal",
"code": "invalid",
"details": {
"text": "The referenced resource \"Organization/1\" does not exist."
},
"diagnostics": "The referenced resource \"Organization/1\" does not exist."
}
]
}

相対参照(Bundle.entry.fullUrl:絶対 URL 以外)

リファレンス要素が相対参照であり、Bundle.entry.fullUrl 要素の値が絶対 URL 以外の場合は絶対化を行いません。

(例)Patient リソースの managingOrganization.reference 要素が相対参照で、Patient リソースを含む Bundle.entryfullUrl 要素が絶対 URL ではない場合

POST [base]/Bundle
  • リクエストボディ
{
"resourceType": "Bundle",
"type": "message",
"timestamp": "2015-07-14T11:15:33+10:00",
"entry": [
{
"fullUrl": "urn:uuid:267b18ce-3d37-4581-9baa-6fada338038b",
"resource": {
"resourceType": "MessageHeader",
"id": "267b18ce-3d37-4581-9baa-6fada338038b",
"eventCoding": {
"system": "http://example.org/fhir/message-events",
"code": "patient-link"
},
"source": {
"endpoint": "http://example.org/clients/ehr-lite"
},
"focus": [
{
"reference": "urn:uuid:541a72a8-df75-4484-ac89-ac4923f03b81"
}
]
}
},
{
"fullUrl": "urn:uuid:541a72a8-df75-4484-ac89-ac4923f03b81",
"resource": {
"resourceType": "Patient",
"id": "pat1",
"active": true,
"name": [
{
"use": "official",
"family": "Donald",
"given": [
"Duck"
]
}
],
"gender": "male",
"managingOrganization": {
"reference": "Organization/1",
"display": "ACME Healthcare, Inc"
}
}
}
]
}

managingOrganization.reference 要素で指定された Organization リソースが FRUCtoS サーバに登録されている場合は以下のレスポンスを返却します。

  • レスポンスボディ
    201 Created
{
"resourceType": "Bundle",
"id": "2",
"meta": {
"versionId": "1",
"lastUpdated": "2021-10-27T15:30:30.715+09:00"
},
"type": "message",
"timestamp": "2015-07-14T11:15:33+10:00",
"entry": [
{
"fullUrl": "urn:uuid:267b18ce-3d37-4581-9baa-6fada338038b",
"resource": {
"resourceType": "MessageHeader",
"id": "2#urn:uuid:267b18ce-3d37-4581-9baa-6fada338038b",
"eventCoding": {
"system": "http://example.org/fhir/message-events",
"code": "patient-link"
},
"source": {
"endpoint": "http://example.org/clients/ehr-lite"
},
"focus": [
{
"reference": "Patient/2#urn:uuid:541a72a8-df75-4484-ac89-ac4923f03b81"
}
]
}
},
{
"fullUrl": "urn:uuid:541a72a8-df75-4484-ac89-ac4923f03b81",
"resource": {
"resourceType": "Patient",
"id": "2#urn:uuid:541a72a8-df75-4484-ac89-ac4923f03b81",
"active": true,
"name": [
{
"use": "official",
"family": "Donald",
"given": [
"Duck"
]
}
],
"gender": "male",
"managingOrganization": {
"reference": "Organization/1",
"display": "ACME Healthcare, Inc"
}
}
}
]
}

managingOrganization.reference 要素で指定された Organization リソースが FRUCtoS サーバに登録されていない場合は、エラーを返却します。

  • レスポンスボディ
    400 Bad Request
{
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "fatal",
"code": "invalid",
"details": {
"text": "The referenced resource \"Organization/1\" does not exist."
},
"diagnostics": "The referenced resource \"Organization/1\" does not exist."
}
]
}

参照先のリソースのバージョンの新旧判定

Canonical参照においてバージョンの指定がない場合、参照先のリソースは最新バージョンになります。FRUCtoSではバージョン表記方法としてセマンティックバージョンをサポートしています。

  • セマンティックバージョン表記方法同士の比較
  • セマンティックバージョン表記方法以外同士の比較
    • 辞書順の比較を行います。新旧判定が期待通りにならない場合があることにご注意ください。
      • 辞書順の比較が期待通りとなる例(バージョンが十分に書式化されている場合)
        • 辞書順: 2014-03-26, 2018-08-12, 2018-12-25
        • 辞書順: 001, 002, 010
      • 辞書順の比較が期待通りにならない例(バージョンが十分に書式化されていない場合)
        • 辞書順: 2014-3-26, 2018-12-25, 2018-8-12
        • 辞書順: 1, 10, 2
  • セマンティックバージョン表記方法とそれ以外の表記方法の比較
    • エラーを返却します。参照値に参照先のリソースのバージョンを明記してください。
      • HTTPステータス
        • 400 Bad Request
      • レスポンスボディ
        •   {
          "resourceType": "OperationOutcome",
          "issue": [
          {
          "severity": "fatal",
          "code": "invalid",
          "details": {
          "text": "Unable to compare versions: 1.1.0, 2018-08-12"
          },
          "diagnostics": "Unable to compare versions: 1.1.0, 2018-08-12"
          }
          ]
          }