バリデーション
FRUCtoS サーバへの登録・更新を行う前に、基底仕様、及び指定されたプロファイルに対してリソースを検証します。
リソースが仕様に準拠していない場合は、処理を中断し、検証エラーの内容を含むレスポンスを返却します。
エラーメッセージ
検証結果がエラーの場合はエラーの内容を含む OperationOutcome リソースが返却されます。
(例)Bundle リソースの制約(bdl-8)に反していた場合
{
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "fatal",
"code": "invalid",
"details": {
"text": "Resource validation failed. Details: line:6, location:Bundle, message:bdl-8: fullUrl cannot be a version specific reference [fullUrl.contains('/_history/').not()], type:INVARIANT, level:ERROR"
},
"diagnostics": "Resource validation failed. Details: line:6, location:Bundle, message:bdl-8: fullUrl cannot be a version specific reference [fullUrl.contains('/_history/').not()], type:INVARIANT, level:ERROR"
}
]
}
検証実行中に予期しないエラーが発生し、検証を続行できなかった場合は以下のエラーメッセージを含む OperationOutcome リソースが返却されます。
{
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "fatal",
"code": "invalid",
"details": {
"text": "Resource validation failed."
},
"diagnostics": "Resource validation failed."
}
]
}
検証項目
FHIR 仕様に従って、以下の項目を検証します。
| # | 検証項目 | 詳細 |
|---|---|---|
| 1 | リソース構造の妥当性 | リソース内の全てのコンテンツが仕様で定義されており、余分な要素が出現していないことを検証する |
| 2 | 多重度 | 全ての要素の多重度が定義された多重度に反していないことを検証する |
| 3 | データ型 | 全ての要素の値が定義されたデータ型の仕様に準拠していることを検証する |
| 4 | バインディング | 用語バリデーションとも。Coding または CodeableConcept 型で指定されたコードが有効であることを検証する ※外部 TerminologyService の利用設定を「 ON 」に設定している場合のみ |
| 5 | 制約 | 定義された制約に準拠していることを検証する |
| 6 | プロファイル | プロファイルで定義された仕様に準拠していることを検証する |
| 7 | Questionnaires | Questionnaire リソースに対して、QuestionnaireResponse リソースが有効であることを検証する |
| 8 | Bundle | Document, Message のリファレンス要素を検証する |
リソース構造の妥当性
仕様で定義されていない要素を含む場合はエラーを返却します。
(例)リソース内に不正な要素が存在する場合
- リクエストボディ
- Patient リソースに仕様で定義されていない
test要素を指定
- Patient リソースに仕様で定義されていない
{
"resourceType": "Patient",
"id": "1",
"active": true,
"test": "example",
"gender": "male"
}
- レスポンスボディ
{
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "fatal",
"code": "invalid",
"details": {
"text": "Resource validation failed. Details: line:5, location:Patient, message:Unrecognised property '@test', type:STRUCTURE, level:ERROR"
},
"diagnostics": "Resource validation failed. Details: line:5, location:Patient, message:Unrecognised property '@test', type:STRUCTURE, level:ERROR"
}
]
}
多重度
多重度が仕様に準拠していない場合はエラーを返却します。
(例)必須要素が存在しない場合
- リクエストボディ
- Observation リソースに
status要素(1..1)を指定していない
- Observation リソースに
{
"resourceType": "Observation",
"id": "f001",
"identifier": [
{
"use": "official",
"system": "http://www.bmc.nl/zorgportal/identifiers/observations",
"value": "6323"
}
],
"code": {
"coding": [
{
"system": "http://loinc.org",
"code": "15074-8",
"display": "Glucose [Moles/volume] in Blood"
}
]
},
[etc]
}
- レスポンスボディ
{
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "fatal",
"code": "invalid",
"details": {
"text": "Resource validation failed. Details: line:1, location:Observation, message:Profile http://hl7.org/fhir/StructureDefinition/Observation, Element 'Observation.status': minimum required = 1, but only found 0, type:STRUCTURE, level:ERROR"
},
"diagnostics": "Resource validation failed. Details: line:1, location:Observation, message:Profile http://hl7.org/fhir/StructureDefinition/Observation, Element 'Observation.status': minimum required = 1, but only found 0, type:STRUCTURE, level:ERROR"
}
]
}
(例)複数指定不可の要素が1つ以上存在する場合
-
独自 Observation プロファイル
Observation.categoryのmax値を「 1 」と定義
-
リクエストボディ
- Observation リソースの
category要素(1..1)を複数指定
- Observation リソースの
{
"resourceType": "Observation",
"id": "f005",
"meta": {
"profile": [
"http://jpfhir.jp/fhir/StructureDefinition/JP_Observation_LabResult"
]
},
"identifier": [
{
"use": "official",
"system": "http://www.bmc.nl/zorgportal/identifiers/observations",
"value": "6327"
}
],
"status": "final",
"category": [
{
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/observation-category",
"code": "laboratory",
"display": "Laboratory"
}
],
"text": "Laboratory"
},
{
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/observation-category",
"code": "vital-signs",
"display": "Vital Signs"
}
],
"text": "Vital Signs"
}
],
[etc]
}
- レスポン スボディ
{
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "fatal",
"code": "invalid",
"details": {
"text": "Resource validation failed. Details: line:1, location:Observation, message:Profile http://jpfhir.jp/fhir/StructureDefinition/JP_Observation_LabResult, Element 'Observation.category': max allowed = 1, but found 2, type:STRUCTURE, level:ERROR"
},
"diagnostics": "Resource validation failed. Details: line:1, location:Observation, message:Profile http://jpfhir.jp/fhir/StructureDefinition/JP_Observation_LabResult, Element 'Observation.category': max allowed = 1, but found 2, type:STRUCTURE, level:ERROR"
}
]
}
データ型
要素の値がその要素が許可するデータ型の仕様に準拠していない場合はエラーを返却します。
(例)要素の値がデータ型の仕様に準拠していない場合
- リクエストボディ
- Patient リソースの
active要素( boolean 型)の値に文字列(「 example 」)を指定
- Patient リソースの
{
"resourceType": "Patient",
"id": "1",
"active": "example",
"gender": "male"
}
- レスポンスボディ
{
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "fatal",
"code": "invalid",
"details": {
"text": "Resource validation failed. Details: line:4, location:Patient.active, message:Error parsing JSON: the primitive value must be a boolean, type:INVALID, level:ERROR"
},
"diagnostics": "Resource validation failed. Details: line:4, location:Patient.active, message:Error parsing JSON: the primitive value must be a boolean, type:INVALID, level:ERROR"
}
]
}
(例)要素の型がその要素が許可するデータ型でない場合
- リクエストボディ
- EN-representation 拡張の
value( code 型)を string 型で指定
- EN-representation 拡張の
{
"resourceType": "Patient",
"id": "1",
"name": [
{
"extension": [
{
"url": "http://hl7.org/fhir/StructureDefinition/iso21090-EN-representation",
"valueString": "IDE"
}
],
"family": "山田",
"given": [
"太郎"
]
}
],
"gender": "male"
}
- レスポンスボディ
{
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "fatal",
"code": "invalid",
"details": {
"text": "Resource validation failed. Details: line:7, location:Patient.name[0].extension[0][url='http://hl7.org/fhir/StructureDefinition/iso21090-EN-representation'], message:The Extension 'http://hl7.org/fhir/StructureDefinition/iso21090-EN-representation' definition allows for the types [code] but found type string, type:STRUCTURE, level:ERROR"
},
"diagnostics": "Resource validation failed. Details: line:7, location:Patient.name[0].extension[0][url='http://hl7.org/fhir/StructureDefinition/iso21090-EN-representation'], message:The Extension 'http://hl7.org/fhir/StructureDefinition/iso21090-EN-representation' definition allows for the types [code] but found type string, type:STRUCTURE, level:ERROR"
}
]
}
要素のデータ型が仕様に準拠していないリソースは、検証を行う前にエラーとなる場合があり、以下のメッセージを含むエラーを返却します。
※ バリデーションの実行設定が「 OFF 」の場合もエラーになります。
(例)要素のデータ型が仕様に準拠していない場合
- リクエストボディ
- Patient リソースの
deceased要素( boolean / dateTime 型)を string 型で指定
- Patient リソースの
{
"resourceType": "Patient",
"id": "1",
"active": true,
"gender": "male",
"deceasedString": "example"
}
- レスポンスボディ
{
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "fatal",
"code": "invalid",
"details": {
"text": "The request body is incorrect. Please make sure the character encoding and FHIR format (including data types) are correct. Also, I/O excpetion error may cause this message to appear."
},
"diagnostics": "The request body is incorrect. Please make sure the character encoding and FHIR format (including data types) are correct. Also, I/O excpetion error may cause this message to appear."
}
]
}
バインディング
※外部 TerminologyService の利用有無が「 ON 」の場合のみ有効です。
バインディングでは「外部 TerminologyService のエンドポイント」に設定された外部 TerminologyService に対して以下のリクエストを実行し、用語の検証を行います(用語バリデーション)。
自サーバに登録されているTerminology関連リソースを参照して用語を検証したい場合は、エンドポイントに自サーバのベース URL([base])を設定してください。
-
GET [base]/CodeSystem?url=[url]&_format=application/fhir+json -
GET [base]/ValueSet?url=[url]&_format=application/fhir+json -
GET [base]/CodeSystem/$validate-code?url=[url]&code=[code]&_format=application/fhir+json -
GET [base]/ValueSet/$validate-code?url=[url]&system=[system]&code=[code]&_format=application/fhir+json
バインディングの動作
Coding または CodeableConcept 型で指定された値が有効でない場合にエラーを返却します。
(例)coding.system で指定した CodeSystem に存在しないコードを指定した場合
- リクエストボディ
- Patient リソースの
identifier.type.coding.code要素に存在しないコード(「 EXAMPLE 」)を指定
- Patient リソースの
{
"resourceType": "Patient",
"id": "example",
"identifier": [
{
"type": {
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/v2-0203",
"code": "EXAMPLE"
}
]
},
"system": "urn:oid:1.2.36.146.595.217.0.1",
"value": "12345"
}
],
"active": true
}
- レスポンスボディ
{
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "fatal",
"code": "invalid",
"details": {
"text": "The concept details supplied are invalid.Details: The specified code 'EXAMPLE' is not known to belong to the specified code system 'http://terminology.hl7.org/CodeSystem/v2-0203'"
},
"diagnostics": "The concept details supplied are invalid.Details: The specified code 'EXAMPLE' is not known to belong to the specified code system 'http://terminology.hl7.org/CodeSystem/v2-0203'"
}
]
}
制約
リソース毎に定義された制約に準拠していない場合はエラーを返却します。
(例)Patient リソースの制約( pat-1 )に準拠していない場合
- リクエストボディ
- Patient リソースの
contact要素内にname,telecom,address,organization要素をいずれも指定しない
- Patient リソースの
{
"resourceType": "Patient",
"id": "animal",
"contact": [
{
"relationship": [
{
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/v2-0131",
"code": "C"
}
]
}
]
}
]
}
- レスポンスボディ
{
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "fatal",
"code": "invalid",
"details": {
"text": "Resource validation failed. Details: line:5, location:Patient, message:pat-1: SHALL at least contain a contact's details or a reference to an organization [name.exists() or telecom.exists() or address.exists() or organization.exists()], type:INVARIANT, level:ERROR"
},
"diagnostics": "Resource validation failed. Details: line:5, location:Patient, message:pat-1: SHALL at least contain a contact's details or a reference to an organization [name.exists() or telecom.exists() or address.exists() or organization.exists()], type:INVARIANT, level:ERROR"
}
]
}
プロファイル
多重度・データ型・制約以外のプロファイルで定義された仕様に対して準拠していない場合はエラーを返却します。
以下の項目を検証します。
固定値
要素の値がプロファイルで定義された固定値に一致しない場合はエラーを返却します。
(例)MedicationRequest リソースの status 要素に定義された固定値と、実際の値が一致しない場合
-
独自 MedicationRequest プロファイル
MedicationRequest.statusに固定値「 active 」を定義
-
リクエストボディ
- MedicationRequest リソースの
status要素に「 unknown 」を指定
- MedicationRequest リソースの
{
"resourceType": "MedicationRequest",
"id": "example",
"meta": {
"profile": [
"http://jpfhir.jp/fhir/core/1.0/StructureDefinition/JP_MedicationRequest"
]
},
"status": "unknown",
[etc]
}
- レスポンスボディ
{
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "fatal",
"code": "invalid",
"details": {
"text": "Resource validation failed. Details: line:7, location:MedicationRequest.status, message:Value does not match fixed or pattern value, type:VALUE, level:ERROR"
},
"diagnostics": "Resource validation failed. Details: line:7, location:MedicationRequest.status, message:Value does not match fixed or pattern value, type:VALUE, level:ERROR"
}
]
}
拡張
パッケージに含まれる拡張定義に対してデータ型や多重度を検証します。
(例)必須要素が存在しない場合
- リクエストボディ
- animal 拡張の Extension.extension(species)(1..1)を指定しない
{
"resourceType": "Patient",
"id": "animal",
"extension": [
{
"url": "http://hl7.org/fhir/StructureDefinition/patient-animal",
"extension": [
{
"url": "breed",
"valueCodeableConcept": {
"coding": [
{
"system": "http://snomed.info/sct",
"code": "58108001",
"display": "Golden retriever"
},
{
"system": "http://example.org/fhir/CodeSystem/animal-breed",
"code": "gret",
"display": "Golden Retriever"
}
]
}
},
{
"url": "genderStatus",
"valueCodeableConcept": {
"coding": [
{
"system": "http://hl7.org/fhir/animal-genderstatus",
"code": "neutered"
}
]
}
}
]
}
],
[etc]
}