This page is part of the FHIR Specification (v1.4.0: STU 3 Ballot 3). The current version which supercedes this version is 5.0.0. For a full list of available versions, see the Directory of published versions
Rule TestScript Example (id = "example-rule")
<TestScript xmlns="http://hl7.org/fhir"> <id value="example-rule"/> <text><status value="generated"/><div xmlns="http://www.w3.org/1999/xhtml"><p><b>Generated Narrative with Details</b></p><p><b>id</b>: example</p><p><b>name</b>: Test Script 1</p><p><b>description</b>: Example Test Script with rule and ruleset</p><h3>Fixtures</h3><table><tr><td>-</td><td><b>Resource</b></td></tr><tr><td>*</td><td><a>Patient resource</a></td></tr></table><blockquote><p><b>test</b></p><p><b>name</b>: Read Patient</p><p><b>description</b>: Read a patient and validate response.</p><blockquote><p><b>metadata</b></p><h3>Links</h3><table><tr><td>-</td><td><b>Url</b></td><td><b>Description</b></td></tr><tr><td>*</td><td><a>http://hl7.org/implement/standards/FHIR-Develop/patient.html</a></td><td>FHIR Patient</td></tr></table><h3>Operations</h3><table><tr><td>-</td><td><b>Type</b></td><td><b>Resource</b></td><td><b>Description</b></td><td><b>Link</b></td><td><b>Required</b></td></tr><tr><td>*</td><td>create</td><td>Patient</td><td>Patient Create Operation</td><td><a>http://hl7.org/implement/standards/FHIR-Develop/http.html#create</a></td><td>true</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Operations</h3><table><tr><td>-</td></tr><tr><td>*</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table><tr><td>-</td></tr><tr><td>*</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table><tr><td>-</td></tr><tr><td>*</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table><tr><td>-</td></tr><tr><td>*</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table><tr><td>-</td></tr><tr><td>*</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table><tr><td>-</td></tr><tr><td>*</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table><tr><td>-</td></tr><tr><td>*</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table><tr><td>-</td></tr><tr><td>*</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table><tr><td>-</td></tr><tr><td>*</td></tr></table></blockquote></blockquote></div></text> <url value="http://hl7.org/fhir/TestScript/example-rule"/> <version value="1.0"/> <name value="Test Script 1"/> <status value="draft"/> <identifier> <system value="urn:ietf:rfc:3986"/> <value value="urn:oid:1.3.6.1.4.1.21367.2005.3.7.9876"/> </identifier> <experimental value="true"/> <publisher value="HL7"/> <contact> <name value="Support"/> <telecom> <system value="email"/> <value value="support@gmail.com"/> <use value="temp"/> </telecom> </contact> <date value="2015-08-31"/> <description value="Example Test Script"/> <useContext> <coding> <system value="urn:iso:std:iso:3166"/> <code value="US"/> <display value="United States of America (the)"/> </coding> </useContext> <requirements value="Patient Create, Read, and Update Operations"/> <copyright value="© HL7.org 2011+"/> <metadata> <capability> <required value="true"/> <description value="Patient Create, Read, and Update Operations"/> <destination value="1"/> <link value="http://hl7.org/implement/standards/FHIR-Develop/http.html#create"/> <link value="http://hl7.org/implement/standards/FHIR-Develop/http.html#read"/> <link value="http://hl7.org/implement/standards/FHIR-Develop/http.html#update"/> <conformance> <reference value="Conformance/example"/> </conformance> </capability> </metadata> <fixture id="F1"> <autocreate value="false"/> <autodelete value="false"/> <resource> <reference value="Patient/example"/> <display value="Patient resource"/> </resource> </fixture> <profile id="patient-profile"> <reference value="http://hl7.org/fhir/StructureDefinition/Patient"/> </profile> <rule id="ruleResponseOkay"> <resource> <reference value="TestScript/example"/> </resource> <param> <name value="expectedStatusCode"/> <value value="200"/> </param> </rule> <ruleset id="ruleset-responseResourcePatient"> <resource> <reference value="TestScript/example"/> </resource> <rule id="RuleResponseContentType"> <param> <name value="expectedContentType"/> <value value="JSON"/> </param> </rule> <rule id="RuleResponseStatusCode"> <param> <name value="expectedStatusCode"/> <value value="200"/> </param> </rule> </ruleset> <setup> <!-- Create the patient using fixture --> <action> <operation> <type> <code value="create"/> </type> <label value="SetupPatient"/> <description value="Create patient resource on test server"/> <accept value="json"/> <responseId value="create-response"/> <sourceId value="F1"/> </operation> </action> <action> <assert> <direction value="request"/> <responseCode value="201"/> </assert> </action> </setup> <test id="READ01"> <name value="Read Patient"/> <description value="Read a patient and validate response."/> <action> <operation> <type> <code value="read"/> </type> <encodeRequestUrl value="false"/> <responseId value="F1-read"/> <targetId value="F1"/> </operation> </action> <action> <assert> <label value="RuleReadOK"/> <rule id="ruleResponseOkay"> <param> <name value="expectedStatusCode"/> <value value="200"/> </param> </rule> </assert> </action> <action> <assert> <label value="RuleContentTypeResponse"/> <ruleset id="ruleset-responseResourcePatient"> <!-- We only need to overwrite one param value in the ruleset --> <rule id="RuleResponseContentType"> <param> <name value="expectedContentType"/> <value value="XML"/> </param> </rule> </ruleset> </assert> </action> <action> <assert> <headerField value="Last-Modified"/> <operator value="notEmpty"/> <warningOnly value="true"/> </assert> </action> <action> <assert> <resource value="Patient"/> </assert> </action> <action> <assert> <validateProfileId value="patient-profile"/> </assert> </action> <action> <assert> <operator value="equals"/> <path value="fhir:Patient/fhir:name/fhir:family/@value"/> <value value="Chalmers"/> </assert> </action> <action> <assert> <operator value="equals"/> <path value="fhir:Patient/fhir:name/fhir:family/@value"/> <sourceId value="F1"/> <value value="Chalmers"/> </assert> </action> <action> <assert> <compareToSourceId value="F1-read"/> <compareToSourcePath value="fhir:Patient/fhir:name/fhir:family/@value"/> <operator value="equals"/> <path value="fhir:Patient/fhir:name/fhir:family/@value"/> </assert> </action> <action> <assert> <compareToSourceId value="F1-read"/> <compareToSourcePath value="fhir:Patient/fhir:name/fhir:family/@value"/> <path value="fhir:Patient/fhir:name/fhir:family/@value"/> <sourceId value="F1"/> </assert> </action> <action> <assert> <minimumId value="F1-min"/> </assert> </action> </test> </TestScript>
Usage note: every effort has been made to ensure that the examples are correct and useful, but they are not a normative part of the specification.