工作组:FHIR Infrastructure ![]() | 成熟度: N | 标准状态 (from v4.0.0) | 隔间: N/A |
验证(validate)操作用于检查服务端是否支持对已有资源内容的创建、更新或者删除。服务器返回的内容取决于模式参数:
更新和删除模式仅在资源实例层级调用操作时适用。操作的返回是一个 操作结果资源(OperationOutcome)
请注意,此操作不是验证资源的唯一方法,理多详情请参阅。验证资源
此操作的官方定义URL是
http://hl7.org/fhir/OperationDefinition/Resource-validate (待修正)
此正式定义 是一个 操作定义资源(OperationDefinition)
URL: [base]/[Resource]/$validate
URL: [base]/[Resource]/[id]/$validate
这是一个等幂等操作
| 输入参数: | |||||
| 名称 | 基数 | 类型 | 绑定 | 说明 | |
| resource | 0..1 | Resource |
除非为“删除模式”,否则必需提供 |
||
| mode | 0..1 | code | ResourceValidationMode (必填) | 默认值为 'no action'; (如,一般验证) |
|
| profile | 0..1 | uri | 如果提供了此参数,则根据此特定配置验证资源。如果指定了一个配置,但服务器不能根据它来进行验证,那么必须返回一个错误。 | ||
| 输出参数: | |||||
| 名称 | 基数 | 类型 | 绑定 | 说明 | |
| return | 1..1 | OperationOutcome |
如果操作结果没有列出任何错误,并且指定了模式,则可视为该操作已成功(事务完整性问题除外,见下)。
注意:由于这是唯一的输出参数,它是一个资源,并且它的名称为'return',因此操作的结果直接作为一个资源返回。 | ||
此操作可在设计和开发期间用于验证应用程序的设计。它也可以在运行时使用。 例如,当用户编辑对话框时,客户端询问服务器提交的更新是否有效并向用户显示更新的错误。 该操作可以用作轻量级的两阶段提交协议(two phase commit protocol,2PC)的一部分,但在使用该操作后服务器将不会保留资源的内容,服务器也不保证在验证操作完成后就能成功执行实际的创建、更新或删除操作。
无论资源是否通过验证,此操作都是返回200 OK。 如果返回 4xx 或 5xx 错误意味着验证操作本身无法执行,并且不知道资源是否有效。
注:关于语言(尤其是Coding.display)的正确验证行为目前尚未定义,进一步的开发和测试可能导致后续版本中出现特定的要求或建议。
此规范的未来版本可能会添加其他验证参数。候选名单由
FHIR Validator Documentation
维护。
请求:请求验证提交的患者实例是否符合DAF患者配置。本例直接在POST的地址中使用参数。
POST /open/Patient/$validate?profile=http://hl7.org/fhir/StructureDefinition/daf-patient [other headers] <?xml version="1.0" encoding="UTF-8"?> <Patient xmlns="http://hl7.org/fhir"> <id value="us01"/> <text> <status value="generated"/> <div xmlns="http://www.w3.org/1999/xhtml"> <p> <b>Generated Narrative with Details</b> </p> <p> <b>id</b>: us01</p> <p> <b>active</b>: true</p> <p> <b>birthsex</b>: Male</p> <p> <b>name</b>: Peter James Chalmers (OFFICIAL)</p> <p> <b>telecom</b>: ph: (03) 5555 6473(WORK), person@example.org(WORK)</p> <p> <b>address</b>: 534 Erewhon St PleasantVille Vic 3999 (HOME)</p> <p> <b>race</b>: White, American Indian or Alaska Native, Asian, Shoshone, Filipino</p> <p> <b>ethnicity</b>: Hispanic or Latino, Dominican, Mexican</p> </div> </text> <extension url="http://hl7.org/fhir/StructureDefinition/us-core-race"> <extension url="ombCategory"> <valueCoding> <system value="http://terminology.hl7.org/CodeSystem/v3-Race"/> <code value="2106-3"/> <display value="White"/> </valueCoding> </extension> <extension url="ombCategory"> <valueCoding> <system value="http://terminology.hl7.org/CodeSystem/v3-Race"/> <code value="1002-5"/> <display value="American Indian or Alaska Native"/> </valueCoding> </extension> <extension url="ombCategory"> <valueCoding> <system value="http://terminology.hl7.org/CodeSystem/v3-Race"/> <code value="2028-9"/> <display value="Asian"/> </valueCoding> </extension> <extension url="detailed"> <valueCoding> <system value="http://terminology.hl7.org/CodeSystem/v3-Race"/> <code value="1586-7"/> <display value="Shoshone"/> </valueCoding> </extension> <extension url="detailed"> <valueCoding> <system value="http://terminology.hl7.org/CodeSystem/v3-Race"/> <code value="2036-2"/> <display value="Filipino"/> </valueCoding> </extension> </extension> <extension url="http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity"> <extension url="ombCategory"> <valueCoding> <system value="http://terminology.hl7.org/CodeSystem/v3-Ethnicity"/> <code value="2135-2"/> <display value="Hispanic or Latino"/> </valueCoding> </extension> <extension url="detailed"> <valueCoding> <system value="http://terminology.hl7.org/CodeSystem/v3-Ethnicity"/> <code value="2184-0"/> <display value="Dominican"/> </valueCoding> </extension> <extension url="detailed"> <valueCoding> <system value="http://terminology.hl7.org/CodeSystem/v3-Ethnicity"/> <code value="2148-5"/> <display value="Mexican"/> </valueCoding> </extension> </extension> <extension url="http://hl7.org/fhir/StructureDefinition/us-core-birthsex"> <valueCode value="M"/> </extension> <active value="true"/> <!-- Peter James Chalmers, but called "Jim" --> <name> <use value="official"/> <family value="Chalmers"/> <given value="Peter"/> <given value="James"/> </name> <telecom> <system value="phone"/> <value value="(03) 5555 6473"/> <use value="work"/> </telecom> <telecom> <extension url="http://hl7.org/fhir/StructureDefinition/us-core-direct"> <valueBoolean value="true"/> </extension> <system value="email"/> <value value="person@example.org"/> <use value="work"/> </telecom> <address> <use value="home"/> <line value="534 Erewhon St"/> <city value="PleasantVille"/> <district value="Orange County"/> <state value="Vic"/> <postalCode value="3999"/> </address> </Patient>
请求:对提交的患者更新进行验证。本例使用参数语法。
POST /open/Patient/example/$validate
[other headers]
<Parameters xmlns="http://hl7.org/fhir">
<parameter>
<name value="mode"/>
<valueCode value="update"/>
</parameter>
<parameter>
<name value="resource"/>
<resource>
<?xml version="1.0" encoding="UTF-8"?>
<Patient xmlns="http://hl7.org/fhir">
<id value="example"/>
<text>
<status value="generated"/>
<div xmlns="http://www.w3.org/1999/xhtml">
<table>
<tbody>
<tr>
<td>Name</td>
<td>Peter James
<b>Chalmers</b> ("Jim")
</td>
</tr>
<tr>
<td>Address</td>
<td>534 Erewhon, Pleasantville, Vic, 3999</td>
</tr>
<tr>
<td>Contacts</td>
<td>Home: unknown. Work: (03) 5555 6473</td>
</tr>
<tr>
<td>Id</td>
<td>MRN: 12345 (Acme Healthcare)</td>
</tr>
</tbody>
</table>
</div>
</text>
<!-- MRN assigned by ACME healthcare on 6-May 2001 -->
<identifier>
<use value="usual"/>
<type>
<coding>
<system value="http://terminology.hl7.org/CodeSystem/v2-0203"/>
<code value="MR"/>
</coding>
</type>
<system value="urn:oid:1.2.36.146.595.217.0.1"/>
<value value="12345"/>
<period>
<start value="2001-05-06"/>
</period>
<assigner>
<display value="Acme Healthcare"/>
</assigner>
</identifier>
<active value="true"/>
<!-- Peter James Chalmers, but called "Jim" -->
<name>
<use value="official"/>
<family value="Chalmers"/>
<given value="Peter"/>
<given value="James"/>
</name>
<name>
<use value="usual"/>
<given value="Jim"/>
</name>
<name>
<!-- Maiden names apply for anyone whose name changes as a result of marriage - irrespective of gender -->
<use value="maiden"/>
<family value="Windsor"/>
<given value="Peter"/>
<given value="James"/>
<period>
<end value="2002"/>
</period>
</name>
<telecom>
<use value="home"/>
<!-- home communication details aren't known -->
</telecom>
<telecom>
<system value="phone"/>
<value value="(03) 5555 6473"/>
<use value="work"/>
<rank value="1"/>
</telecom>
<telecom>
<system value="phone"/>
<value value="(03) 3410 5613"/>
<use value="mobile"/>
<rank value="2"/>
</telecom>
<telecom>
<system value="phone"/>
<value value="(03) 5555 8834"/>
<use value="old"/>
<period>
<end value="2014"/>
</period>
</telecom>
<!-- use FHIR code system for male / female -->
<gender value="male"/>
<birthDate value="1974-12-25">
<extension url="http://hl7.org/fhir/StructureDefinition/patient-birthTime">
<valueDateTime value="1974-12-25T14:35:45-05:00"/>
</extension>
</birthDate>
<deceasedBoolean value="false"/>
<address>
<use value="home"/>
<type value="both"/>
<text value="534 Erewhon St
PeasantVille, Rainbow, Vic 3999"/>
<line value="534 Erewhon St"/>
<city value="PleasantVille"/>
<district value="Rainbow"/>
<state value="Vic"/>
<postalCode value="3999"/>
<period>
<start value="1974-12-25"/>
</period>
</address>
<contact>
<relationship>
<coding>
<system value="http://terminology.hl7.org/CodeSystem/v2-0131"/>
<code value="N"/>
</coding>
</relationship>
<name>
<family value="du Marché">
<!-- the "du" part is a family name prefix (VV in iso 21090) -->
<extension url="http://hl7.org/fhir/StructureDefinition/humanname-own-prefix">
<valueString value="VV"/>
</extension>
</family>
<given value="Bénédicte"/>
</name>
<telecom>
<system value="phone"/>
<value value="+33 (237) 998327"/>
</telecom>
<address>
<use value="home"/>
<type value="both"/>
<line value="534 Erewhon St"/>
<city value="PleasantVille"/>
<district value="Rainbow"/>
<state value="Vic"/>
<postalCode value="3999"/>
<period>
<start value="1974-12-25"/>
</period>
</address>
<gender value="female"/>
<period>
<!-- The contact relationship started in 2012 -->
<start value="2012"/>
</period>
</contact>
<managingOrganization>
<reference value="Organization/1"/>
</managingOrganization>
</Patient>
</resource>
</parameter>
</Parameters>
响应:当资源通过验证时返回
HTTP/1.1 200 OK
[other headers]
<?xml version="1.0" encoding="UTF-8"?>
<OperationOutcome xmlns="http://hl7.org/fhir">
<id value="allok"/>
<text>
<status value="generated"/>
<div xmlns="http://www.w3.org/1999/xhtml">
<p>All OK</p>
</div>
</text>
<issue>
<severity value="information"/>
<code value="informational"/>
<details>
<text value="All OK"/>
</details>
</issue>
</OperationOutcome>
响应:当资源未通过验证时返回
HTTP/1.1 200 OK
[other headers]
<?xml version="1.0" encoding="UTF-8"?>
<OperationOutcome xmlns="http://hl7.org/fhir">
<id value="validationfail"/>
<text>
<status value="generated"/>
<div xmlns="http://www.w3.org/1999/xhtml">
<p>Error parsing resource XML (Unknown Content "label" @ /Patient/identifier/label) at Patient.identifier</p>
</div>
</text>
<issue>
<severity value="error"/>
<code value="structure"/>
<details>
<text value="Error parsing resource XML (Unknown Content "label""/>
</details>
<location value="/f:Patient/f:identifier"/>
<expression value="Patient.identifier"/>
</issue>
</OperationOutcome>
有关操作的更多信息,包括如何调用操作,请参阅Operations。