バリデーション
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": "Failed to parse request body as JSON resource."
},
"diagnostics": "Failed to parse request body as JSON resource."
}
]
}
バインディング
※外部 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]
}
- レスポンスボディ
{
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "fatal",
"code": "invalid",
"details": {
"text": "Resource validation failed. Details: line:5, location:Patient.extension[0], message:Profile http://hl7.org/fhir/StructureDefinition/patient-animal, Element 'Patient.extension[0].extension[species]': minimum required = 1, but only found 0, type:STRUCTURE, level:ERROR"
},
"diagnostics": "Resource validation failed. Details: line:5, location:Patient.extension[0], message:Profile http://hl7.org/fhir/StructureDefinition/patient-animal, Element 'Patient.extension[0].extension[species]': minimum required = 1, but only found 0, type:STRUCTURE, level:ERROR"
}
]
}
パッケージに定義が存在しない拡張を指定した場合はエラーを返却します。
(例)パッケージに定義が存在しない拡張を指定した場合
- リクエストボディ
- パッケージに存在しない拡張「 http://hl7.org/fhir/StructureDefinition/extension-example 」を指定
{
"resourceType": "Patient",
"id": "example",
"extension": [
{
"url": "http://hl7.org/fhir/StructureDefinition/extension-example",
"valueString": "example"
}
],
[etc]
}
- レスポンスボディ
{
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "fatal",
"code": "invalid",
"details": {
"text": "Resource validation failed. Details: line:5, location:Patient.extension[0], message:The extension http://hl7.org/fhir/StructureDefinition/extension-example is unknown, and not allowed here, type:STRUCTURE, level:ERROR"
},
"diagnostics": "Resource validation failed. Details: line:5, location:Patient.extension[0], message:The extension http://hl7.org/fhir/StructureDefinition/extension-example is unknown, and not allowed here, type:STRUCTURE, level:ERROR"
}
]
}
独自に定義したリソースプロファイルに対して検証する場合は、そのプロファイルで定義する独自の拡張定義が全てパッケージ内に存在している必要があります。
(例)リソースプロファイルで定義されている独自拡張( UsageDuration )の定義がパッケージに存在しない場合
-
独自 MedicationRequest プロファイル
MedicationRequest.extension
に、パッケージに存在しない独自拡張( UsageDuration )とパッケージに存在する独自拡張( PeriodOfUse )を定義
-
リクエストボディ
- MedicationRequest リソースの
extension
要素にパッケージに存在する独自拡張( PeriodOfUse )を指定
- MedicationRequest リソースの
{
"resourceType": "MedicationRequest",
"id": "example",
"meta": {
"profile": [
"http://jpfhir.jp/fhir/core/1.0/StructureDefinition/JP_MedicationRequest"
]
},
"extension": [
{
"url": "http://jpfhir.jp/fhir/core/1.0/StructureDefinition/JP_MedicationRequestPeriodOfUse",
"valuePeriod": {
"start": "2021-02-01"
}
}
],
"status": "active",
[etc]
}
- レスポンスボディ
{
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "fatal",
"code": "invalid",
"details": {
"text": "Resource validation failed. Details: line:10, location:MedicationRequest.extension[0], message:Problem with use of resolve() - profile '[CanonicalType[http://jpfhir.jp/fhir/core/1.0/StructureDefinition/JP_MedicationRequestUsageDuration]]' on MedicationRequest.extension:UsageDuration could not be resolved, type:PROCESSING, level:ERROR"
},
"diagnostics": "Resource validation failed. Details: line:10, location:MedicationRequest.extension[0], message:Problem with use of resolve() - profile '[CanonicalType[http://jpfhir.jp/fhir/core/1.0/StructureDefinition/JP_MedicationRequestUsageDuration]]' on MedicationRequest.extension:UsageDuration could not be resolved, type:PROCESSING, level:ERROR"
}
]
}
また、Context の整合性を検証し、 拡張の出現位置が定義に一致しない場合はエラーを返却します。
(例)Gene 拡張を Patient リソースに指定した場合
- リクエストボディ
- Patient リソースの
extension
要素に Gene 拡張を指定
- Patient リソースの
{
"resourceType": "Patient",
"id": "example",
"extension": [
{
"url": "http://hl7.org/fhir/StructureDefinition/observation-geneticsGene",
"valueCodeableConcept": {
"coding": [
{
"system": "http://www.genenames.org",
"code": "3236",
"display": "EGFR"
}
]
}
}
],
"active": true,
[etc]
}
- レスポンスボディ
{
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "fatal",
"code": "invalid",
"details": {
"text": "Resource validation failed. Details: line:5, location:Patient.extension[0], message:The extension http://hl7.org/fhir/StructureDefinition/observation-geneticsGene is not allowed to be used on the logical path set [Patient] (allowed: resource=element:Observation), type:STRUCTURE, level:ERROR"
},
"diagnostics": "Resource validation failed. Details: line:5, location:Patient.extension[0], message:The extension http://hl7.org/fhir/StructureDefinition/observation-geneticsGene is not allowed to be used on the logical path set [Patient] (allowed: resource=element:Observation), type:STRUCTURE, level:ERROR"
}
]
}
スライス
スライス要素に対して定義した順序での出現を求められている場合は、正しい順序でなければエラーを返却します。
(例)定義された順序と異なる順序で Patient リソースの name
要素を記述した場合
-
独自 Patient プロファイル
Patient.name
のslicing.ordered
を「 true 」と定義Patient.name
のスライス要素を「 IDE 」、「 SYL 」の順に定義
-
リクエストボディ
- Patient リソースの
name
要素を「 SYL 」、「 IDE 」の順に指定
- Patient リソースの
{
"resourceType": "Patient",
"id": "example",
"meta": {
"profile": [
"http://example.org/fhir/StructureDefinition/Patient-example"
]
},
"identifier": [
{
"use": "usual",
"system": "urn:oid:1.2.36.146.595.217.0.1",
"value": "12345"
}
],
"name": [
{
"extension": [
{
"url": "http://hl7.org/fhir/StructureDefinition/iso21090-EN-representation",
"valueCode": "SYL"
}
],
"family": "ヤマダ",
"given": [
"タロウ"
]
},
{
"extension": [
{
"url": "http://hl7.org/fhir/StructureDefinition/iso21090-EN-representation",
"valueCode": "IDE"
}
],
"family": "山田",
"given": [
"太郎"
]
}
]
}
- レスポンスボディ
{
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "fatal",
"code": "invalid",
"details": {
"text": "Resource validation failed. Details: line:26, location:Patient.name[1], message:As specified by profile http://example.org/fhir/StructureDefinition/Patient-example, Element 'name' is out of order in ordered slice, type:INVALID, level:ERROR"
},
"diagnostics": "Resource validation failed. Details: line:26, location:Patient.name[1], message:As specified by profile http://example.org/fhir/StructureDefinition/Patient-example, Element 'name' is out of order in ordered slice, type:INVALID, level:ERROR"
}
]
}
最小値 / 最大値
要素に対して最小値 / 最大値が定義されている場合は、その条件を満たしていることを検証します。
要素の値が定義された最小値 / 最大値に対して不正である場合は、エラーを返却します。
(例)Patient リソースの birthDate
要素に対して定義された最小値に反した値を指定した場合
-
独自 Patient プロファイル
Patient.birthDate
に最小値「1850-01-01」(1850年1月1日)を定義
-
リクエストボディ
birthDate
要素に最小値より値の小さい「1800-10-01」(1800年10月1日)を指定
{
"resourceType": "Patient",
"id": "example",
"meta": {
"profile": [
"http://example.org/fhir/StructureDefinition/Patient-example"
]
},
"identifier": [
{
"use": "usual",
"system": "urn:oid:1.2.36.146.595.217.0.1",
"value": "12345"
}
],
"gender": "male",
"birthDate": "1800-10-01",
[etc]
}
- レスポンスボディ
{
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "fatal",
"code": "invalid",
"details": {
"text": "Resource validation failed. Details: line:17, location:Patient.birthDate, message:value is less than permitted minimum value of DateType[1850-01-01], type:INVALID, level:ERROR"
},
"diagnostics": "Resource validation failed. Details: line:17, location:Patient.birthDate, message:value is less than permitted minimum value of DateType[1850-01-01], type:INVALID, level:ERROR"
}
]
}