FHIR:V1.0 FHIR Error handling examples: verschil tussen versies
Naar navigatie springen
Naar zoeken springen
k (Switchting staging environment to live) |
k (Beveiligde "FHIR:V1.0 FHIR Error handling examples": Protect production page from accidental edits ([Bewerken=Alleen beheerders toestaan] (vervalt niet) [Hernoemen=Alleen beheerders toestaan] (vervalt niet))) |
||
(10 tussenliggende versies door 4 gebruikers niet weergegeven) | |||
Regel 1: | Regel 1: | ||
− | |||
__NUMBEREDHEADINGS__ | __NUMBEREDHEADINGS__ | ||
{{DISPLAYTITLE:FHIR IG Error handling examples}} | {{DISPLAYTITLE:FHIR IG Error handling examples}} | ||
− | |||
=Error handling examples= | =Error handling examples= | ||
This page provides guidance on how a server could handle errors. Examples are provided in XML format but could have been in JSON format as well. Please note: these examples are not considered to be part of the normative content of the implementation guide. | This page provides guidance on how a server could handle errors. Examples are provided in XML format but could have been in JSON format as well. Please note: these examples are not considered to be part of the normative content of the implementation guide. | ||
==All interactions== | ==All interactions== | ||
+ | ===Not authorized=== | ||
+ | {| class="wikitable" | ||
+ | |- | ||
+ | | '''Scenario''' | ||
+ | | Not authorized. | ||
+ | |- | ||
+ | | '''Request''' | ||
+ | | <pre> GET [base]/Practitioner/86475712701</pre> | ||
+ | |- | ||
+ | | '''Response''' | ||
+ | | | ||
+ | * HTTP 401 Unauthorized | ||
+ | * OperationOutcome with {{fhir|OperationOutcome.issue.code}} set to {{term|security}} or if applicable a more specific child code. | ||
+ | |} | ||
+ | {{Collapse top|XML contents - response}} | ||
+ | <syntaxhighlight lang="xml"> | ||
+ | <OperationOutcome xmlns="http://hl7.org/fhir"> | ||
+ | <id value="01464674-b4b6-11eb-8529-0242ac130003" /> | ||
+ | <text> | ||
+ | ... | ||
+ | </text> | ||
+ | <issue> | ||
+ | <severity value="error"/> | ||
+ | <code value="security"/> | ||
+ | <details> | ||
+ | <text value="Not authorized to access this resource"/> | ||
+ | </details> | ||
+ | </issue> | ||
+ | </OperationOutcome> | ||
+ | </syntaxhighlight> | ||
+ | {{Collapse bottom}} | ||
===Invalid authorization=== | ===Invalid authorization=== | ||
{| class="wikitable" | {| class="wikitable" | ||
Regel 18: | Regel 47: | ||
| '''Response''' | | '''Response''' | ||
| | | | ||
− | * HTTP | + | * HTTP 403 Forbidden |
− | * OperationOutcome with | + | * OperationOutcome with {{fhir|OperationOutcome.issue.code}} set to {{term|security}} or if applicable a more specific child code. |
|} | |} | ||
{{Collapse top|XML contents - response}} | {{Collapse top|XML contents - response}} | ||
Regel 32: | Regel 61: | ||
<code value="security"/> | <code value="security"/> | ||
<details> | <details> | ||
− | <text value=" | + | <text value="Read access forbidden"/> |
</details> | </details> | ||
</issue> | </issue> | ||
Regel 38: | Regel 67: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{Collapse bottom}} | {{Collapse bottom}} | ||
+ | |||
===Resource is not supported=== | ===Resource is not supported=== | ||
{| class="wikitable" | {| class="wikitable" | ||
Regel 50: | Regel 80: | ||
| | | | ||
* HTTP 404 Not Found | * HTTP 404 Not Found | ||
− | * OperationOutcome with | + | * OperationOutcome with {{fhir|OperationOutcome.issue.code}} set to {{term|not-supported}}. |
|} | |} | ||
Regel 70: | Regel 100: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{Collapse bottom}} | {{Collapse bottom}} | ||
+ | |||
==Search== | ==Search== | ||
===Unkown or unsupported search parameter value=== | ===Unkown or unsupported search parameter value=== | ||
Regel 84: | Regel 115: | ||
| | | | ||
* HTTP 200 OK | * HTTP 200 OK | ||
− | * Empty Bundle of | + | * Empty Bundle of {{fhir|.type}} {{term|searchset}}. |
− | * OperationOutcome in Bundle as an entry marked with | + | * OperationOutcome in Bundle as an entry marked with {{fhir|Bundle.entry.search.mode}} set to {{term|outcome}}. |
− | * OperationOutcome with | + | * OperationOutcome with {{fhir|OperationOutcome.issue.code}} set to {{term|not-found}} and {{fhir|OperationOutcome.severity}} not set to {{term|fatal}} or {{term|error}}. |
|} | |} | ||
{{Collapse top|XML contents - response}} | {{Collapse top|XML contents - response}} | ||
Regel 135: | Regel 166: | ||
|- | |- | ||
| '''Response''' | | '''Response''' | ||
− | | * HTTP | + | | |
+ | * HTTP 400 Bad Request | ||
+ | * OperationOutcome. There are various issue type codes that could be used, depending on the nature of the error. | ||
|} | |} | ||
+ | |||
{{Collapse top|XML contents - response}} | {{Collapse top|XML contents - response}} | ||
<syntaxhighlight lang="xml"> | <syntaxhighlight lang="xml"> | ||
Regel 160: | Regel 194: | ||
|- | |- | ||
| '''Scenario''' | | '''Scenario''' | ||
− | | The id is not known by the server | + | | The id is not known by the server. |
|- | |- | ||
| '''Request''' | | '''Request''' | ||
Regel 166: | Regel 200: | ||
|- | |- | ||
| '''Response''' | | '''Response''' | ||
− | | * HTTP | + | | |
+ | * HTTP 404 Not Found | ||
+ | * OperationOutcome with {{fhir|OperationOutcome.issue.code}} set to {{term|not-found}}. | ||
|} | |} | ||
+ | |||
{{Collapse top|XML contents - response}} | {{Collapse top|XML contents - response}} | ||
<syntaxhighlight lang="xml"> | <syntaxhighlight lang="xml"> | ||
Regel 197: | Regel 234: | ||
| | | | ||
* HTTP 400 Bad Request | * HTTP 400 Bad Request | ||
− | OperationOutcome with | + | * OperationOutcome with {{fhir|OperationOutcome.issue.code}} set to {{term|invalid}}. |
|} | |} | ||
Regel 232: | Regel 269: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{Collapse bottom}} | {{Collapse bottom}} | ||
− | ===Resource syntax or data is incorrect or | + | |
+ | ===Resource syntax or data is incorrect, invalid or unsupported=== | ||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
| '''Scenario''' | | '''Scenario''' | ||
− | | Resource syntax or data is incorrect or | + | | Resource syntax or data is incorrect, invalid or unsupported. |
|- | |- | ||
| '''Request''' | | '''Request''' | ||
Regel 243: | Regel 281: | ||
| '''Response''' | | '''Response''' | ||
| | | | ||
− | * HTTP 400 Bad Request or HTTP 422 | + | * HTTP 400 Bad Request or HTTP 422 Unprocessable Entity |
− | * OperationOutcome with | + | * OperationOutcome with {{fhir|OperationOutcome.issue.code}} set to {{term|invalid}} or a more specific child code. |
|} | |} | ||
{{Collapse top|XML contents - request}} | {{Collapse top|XML contents - request}} | ||
Regel 281: | Regel 319: | ||
<diagnostics value="value.empty() or system.exists()" /> | <diagnostics value="value.empty() or system.exists()" /> | ||
<location value="Patient.telecom[0]" /> | <location value="Patient.telecom[0]" /> | ||
+ | </issue> | ||
+ | </OperationOutcome> | ||
+ | </syntaxhighlight> | ||
+ | {{Collapse bottom}} | ||
+ | |||
+ | {| class="wikitable" | ||
+ | |- | ||
+ | | '''Scenario''' | ||
+ | | Resource syntax or data is incorrect, invalid or unsupported. | ||
+ | |- | ||
+ | | '''Request''' | ||
+ | | <pre> POST [base]/Observation</pre> | ||
+ | |- | ||
+ | | '''Response''' | ||
+ | | | ||
+ | * HTTP 400 Bad Request or HTTP 422 Unprocessable Entity | ||
+ | * OperationOutcome with {{fhir|OperationOutcome.issue.code}} set to {{term|invalid}} or a more specific child code. | ||
+ | |} | ||
+ | {{Collapse top|XML contents - request}} | ||
+ | <syntaxhighlight lang="xml"> | ||
+ | <?xml version="1.0" encoding="UTF-8"?> | ||
+ | |||
+ | <Observation xmlns="http://hl7.org/fhir"> | ||
+ | <id value="example"/> | ||
+ | ... | ||
+ | <category> | ||
+ | <coding> | ||
+ | <system value="http://hl7.org/fhir/observation-category"/> | ||
+ | <code value="vital-signs"/> | ||
+ | <display value="Vital Signs"/> | ||
+ | </coding> | ||
+ | </category> | ||
+ | <code> | ||
+ | <coding> | ||
+ | <system value="http://loinc.org"/> | ||
+ | <code value="39156-5"/> | ||
+ | <display value="Body mass index (BMI)"/> | ||
+ | </coding> | ||
+ | </code> | ||
+ | ... | ||
+ | </Observation> | ||
+ | </syntaxhighlight> | ||
+ | {{Collapse bottom}} | ||
+ | |||
+ | {{Collapse top|XML contents - response}} | ||
+ | <syntaxhighlight lang="xml"> | ||
+ | <OperationOutcome xmlns="http://hl7.org/fhir"> | ||
+ | <id value="c8bc9de0-5141-40dd-9a06-7134109d8ce0" /> | ||
+ | <text> | ||
+ | ... | ||
+ | </text> | ||
+ | <issue> | ||
+ | <severity value="error" /> | ||
+ | <code value="not-supported" /> | ||
+ | <details> | ||
+ | <text value="Unsupported code value" /> | ||
+ | </details> | ||
+ | <location value="Observation.code[0]" /> | ||
</issue> | </issue> | ||
</OperationOutcome> | </OperationOutcome> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{Collapse bottom}} | {{Collapse bottom}} |
Huidige versie van 25 okt 2022 om 09:36
1 Error handling examples
This page provides guidance on how a server could handle errors. Examples are provided in XML format but could have been in JSON format as well. Please note: these examples are not considered to be part of the normative content of the implementation guide.
1.1 All interactions
1.1.1 Not authorized
Scenario | Not authorized. |
Request | GET [base]/Practitioner/86475712701 |
Response |
|
XML contents - response |
---|
<OperationOutcome xmlns="http://hl7.org/fhir">
<id value="01464674-b4b6-11eb-8529-0242ac130003" />
<text>
...
</text>
<issue>
<severity value="error"/>
<code value="security"/>
<details>
<text value="Not authorized to access this resource"/>
</details>
</issue>
</OperationOutcome>
|
1.1.2 Invalid authorization
Scenario | Invalid authorization. |
Request | GET [base]/Patient/20118482245 |
Response |
|
XML contents - response |
---|
<OperationOutcome xmlns="http://hl7.org/fhir">
<id value="131sasdffa-ds32-2380-2343-131s12334234" />
<text>
...
</text>
<issue>
<severity value="error"/>
<code value="security"/>
<details>
<text value="Read access forbidden"/>
</details>
</issue>
</OperationOutcome>
|
1.1.3 Resource is not supported
Scenario | The Resource is not supported by the resource server. |
Request | GET [base]/Questionnaire |
Response |
|
XML contents - response |
---|
<OperationOutcome xmlns="http://hl7.org/fhir">
<id value="3f3f6d70-823f-4c6f-92e9-8693c50723ac" />
<text>
...
</text>
<issue>
<severity value="error" />
<code value="not-supported" />
<details>
<text value="Request for not-supported ResourceType(s) Questionnaire" />
</details>
</issue>
</OperationOutcome>
|
1.2 Search
1.2.1 Unkown or unsupported search parameter value
Scenario |
Unknown or unsupported search parameter value. In this example scenario, the Consent endpoint is supported. Although a system has implemented support for the HCIM TreatmentDirective ( |
Request | GET [base]/Consent?category=http://snomed.info/sct|11341000146107 |
Response |
|
XML contents - response |
---|
<Bundle xmlns="http://hl7.org/fhir">
<id value="bundle-search-warning"/>
<meta>
<lastUpdated value="2020-03-14T08:23:30+11:00"/>
</meta>
<type value="searchset"/>
<total value="0"/>
<link>
<relation value="self"/>
<url value="https://example.org/fhir/Consent?category=http://snomed.info/sct|11341000146107"/>
</link>
<entry>
<resource>
<OperationOutcome>
<id value="131sadfa-ds32-2380-2343-131sadfa34234" />
<text>
...
</text>
<issue>
<severity value="warning"/>
<code value="not-found"/>
<details>
<text value="Request for not-supported Consent of category HCIM AdvanceDirective" />
</details>
</issue>
</OperationOutcome>
</resource>
<search>
<mode value="outcome"/>
</search>
</entry>
</Bundle>
|
1.2.2 Syntactically incorrect parameter
Scenario | Syntactically incorrect parameter in the search request. |
Request | GET [base]/Procedure?patient:john |
Response |
|
XML contents - response |
---|
<OperationOutcome xmlns="http://hl7.org/fhir">
<id value="1317cae1-ds32-4e80-2343-4fe6sdfsaxzxfdfs" />
<text>
...
</text>
<issue>
<severity value="error" />
<code value="invalid" />
<details>
<text value="Argument lacks the name/value separator '=' or has no value" />
</details>
</issue>
</OperationOutcome>
|
1.3 Read
1.3.1 Request on an unknown id
Scenario | The id is not known by the server. |
Request | GET [base]/Patient/wrong-id |
Response |
|
XML contents - response |
---|
<OperationOutcome xmlns="http://hl7.org/fhir">
<id value="1317cae1-ds32-4e80-2340-4fe6sdfae321xf" />
<text>
...
</text>
<issue>
<severity value="error"/>
<code value="not-found"/>
<diagnostics value="Resource Id "Patient/wrong-id" does not exist"/>
</issue>
</OperationOutcome>
|
1.4 Create/Update
1.4.1 No or incorrect Resource id
Scenario | Update an existing Patient resource, using a wrong id in the Resource. |
Request | PUT [base]/Patient/34235234 |
Response |
|
XML contents - request |
---|
<?xml version="1.0" encoding="UTF-8"?>
<Patient xmlns="http://hl7.org/fhir">
<id value="wrong-id"/>
<name>
<use value="official"/>
<family value="Case"/>
<given value="Justin"/>
</name>
</Patient>
|
XML contents - response |
---|
<OperationOutcome xmlns="http://hl7.org/fhir">
<id value="1317cae1-ds32-4e80-aaf0-4fe687fsdfsdf" />
<text>
...
</text>
<issue>
<severity value="error" />
<code value="invalid" />
<details>
<text value="Id in request (34235234) and in resource (wrong-id) must match." />
</details>
</issue>
</OperationOutcome>
|
1.4.2 Resource syntax or data is incorrect, invalid or unsupported
Scenario | Resource syntax or data is incorrect, invalid or unsupported. |
Request | POST [base]/Patient |
Response |
|
XML contents - request |
---|
<?xml version="1.0" encoding="UTF-8"?>
<Patient xmlns="http://hl7.org/fhir">
<id value="example"/>
<name>
<use value="official"/>
<family value="Case"/>
<given value="Justin"/>
</name>
<telecom>
<value value="061234567"/>
<use value="mobile"/>
<rank value="2"/>
</telecom>
</Patient>
|
XML contents - response |
---|
<OperationOutcome xmlns="http://hl7.org/fhir">
<id value="1317cae1-2ee2-4e80-aaf0-4fe687ffd5f9" />
<text>
...
</text>
<issue>
<severity value="error" />
<code value="invariant" />
<details>
<text value="Instance failed constraint cpt-2 "A system is required if a value is provided."" />
</details>
<diagnostics value="value.empty() or system.exists()" />
<location value="Patient.telecom[0]" />
</issue>
</OperationOutcome>
|
Scenario | Resource syntax or data is incorrect, invalid or unsupported. |
Request | POST [base]/Observation |
Response |
|
XML contents - request |
---|
<?xml version="1.0" encoding="UTF-8"?>
<Observation xmlns="http://hl7.org/fhir">
<id value="example"/>
...
<category>
<coding>
<system value="http://hl7.org/fhir/observation-category"/>
<code value="vital-signs"/>
<display value="Vital Signs"/>
</coding>
</category>
<code>
<coding>
<system value="http://loinc.org"/>
<code value="39156-5"/>
<display value="Body mass index (BMI)"/>
</coding>
</code>
...
</Observation>
|
XML contents - response |
---|
<OperationOutcome xmlns="http://hl7.org/fhir">
<id value="c8bc9de0-5141-40dd-9a06-7134109d8ce0" />
<text>
...
</text>
<issue>
<severity value="error" />
<code value="not-supported" />
<details>
<text value="Unsupported code value" />
</details>
<location value="Observation.code[0]" />
</issue>
</OperationOutcome>
|