STU 3 Ballot

This page is part of the FHIR Specification (v1.6.0: STU 3 Ballot 4). The current version which supercedes this version is 5.0.0. For a full list of available versions, see the Directory of published versions

Testscript-example-rule.ttl

Raw Turtle, JSON-LD

Rule TestScript Example

@prefix fhir: <http://hl7.org/fhir/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

# - resource -------------------------------------------------------------------

<http://hl7.org/fhir/TestScript/example-rule> a fhir:TestScript;
  fhir:nodeRole fhir:treeRoot;
  fhir:Resource.id [ fhir:value "example-rule"];
  fhir:DomainResource.text [
     fhir:Narrative.status [ fhir:value "generated" ];
     fhir:Narrative.div "<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>"
  ];
  fhir:TestScript.url [ fhir:value "http://hl7.org/fhir/TestScript/example-rule"];
  fhir:TestScript.version [ fhir:value "1.0"];
  fhir:TestScript.name [ fhir:value "Test Script 1"];
  fhir:TestScript.status [ fhir:value "draft"];
  fhir:TestScript.identifier [
     fhir:Identifier.system [ fhir:value "urn:ietf:rfc:3986" ];
     fhir:Identifier.value [ fhir:value "urn:oid:1.3.6.1.4.1.21367.2005.3.7.9876" ]
  ];
  fhir:TestScript.experimental [ fhir:value "true"^^xsd:boolean];
  fhir:TestScript.publisher [ fhir:value "HL7"];
  fhir:TestScript.contact [
     fhir:index 0;
     fhir:TestScript.contact.name [ fhir:value "Support" ];
     fhir:TestScript.contact.telecom [
       fhir:index 0;
       fhir:ContactPoint.system [ fhir:value "email" ];
       fhir:ContactPoint.value [ fhir:value "support@gmail.com" ];
       fhir:ContactPoint.use [ fhir:value "temp" ]
     ]
  ];
  fhir:TestScript.date [ fhir:value "2015-08-31"^^xsd:date];
  fhir:TestScript.description [ fhir:value "Example Test Script"];
  fhir:TestScript.useContext [
     fhir:index 0;
     fhir:CodeableConcept.coding [
       fhir:index 0;
       fhir:Coding.system [ fhir:value "urn:iso:std:iso:3166" ];
       fhir:Coding.code [ fhir:value "US" ];
       fhir:Coding.display [ fhir:value "United States of America (the)" ]
     ]
  ];
  fhir:TestScript.requirements [ fhir:value "Patient Create, Read, and Update Operations"];
  fhir:TestScript.copyright [ fhir:value "© HL7.org 2011+"];
  fhir:TestScript.metadata [
     fhir:TestScript.metadata.capability [
       fhir:index 0;
       fhir:TestScript.metadata.capability.required [ fhir:value "true"^^xsd:boolean ];
       fhir:TestScript.metadata.capability.description [ fhir:value "Patient Create, Read, and Update Operations" ];
       fhir:TestScript.metadata.capability.destination [ fhir:value "1"^^xsd:int ];
       fhir:TestScript.metadata.capability.link [
         fhir:value "http://hl7.org/implement/standards/FHIR-Develop/http.html#create";
         fhir:index 0
       ], [
         fhir:value "http://hl7.org/implement/standards/FHIR-Develop/http.html#read";
         fhir:index 1
       ], [
         fhir:value "http://hl7.org/implement/standards/FHIR-Develop/http.html#update";
         fhir:index 2
       ];
       fhir:TestScript.metadata.capability.conformance [
         fhir:link <http://hl7.org/fhir/Conformance/example>;
         fhir:Reference.reference [ fhir:value "Conformance/example" ]
       ]
     ]
  ];
  fhir:TestScript.fixture [
     fhir:index 0;
     fhir:Element.id [ fhir:value "F1" ];
     fhir:TestScript.fixture.autocreate [ fhir:value "false"^^xsd:boolean ];
     fhir:TestScript.fixture.autodelete [ fhir:value "false"^^xsd:boolean ];
     fhir:TestScript.fixture.resource [
       fhir:link <http://hl7.org/fhir/Patient/example>;
       fhir:Reference.reference [ fhir:value "Patient/example" ];
       fhir:Reference.display [ fhir:value "Patient resource" ]
     ]
  ];
  fhir:TestScript.profile [
     fhir:index 0;
     fhir:link <http://hl7.org/fhir/StructureDefinition/Patient>;
     fhir:Element.id [ fhir:value "patient-profile" ];
     fhir:Reference.reference [ fhir:value "http://hl7.org/fhir/StructureDefinition/Patient" ]
  ];
  fhir:TestScript.rule [
     fhir:index 0;
     fhir:Element.id [ fhir:value "ruleResponseOkay" ];
     fhir:TestScript.rule.resource [
       fhir:link <http://hl7.org/fhir/TestScript/example>;
       fhir:Reference.reference [ fhir:value "TestScript/example" ]
     ];
     fhir:TestScript.rule.param [
       fhir:index 0;
       fhir:TestScript.rule.param.name [ fhir:value "expectedStatusCode" ];
       fhir:TestScript.rule.param.value [ fhir:value "200" ]
     ]
  ];
  fhir:TestScript.ruleset [
     fhir:index 0;
     fhir:Element.id [ fhir:value "ruleset-responseResourcePatient" ];
     fhir:TestScript.ruleset.resource [
       fhir:link <http://hl7.org/fhir/TestScript/example>;
       fhir:Reference.reference [ fhir:value "TestScript/example" ]
     ];
     fhir:TestScript.ruleset.rule [
       fhir:index 0;
       fhir:TestScript.ruleset.rule.ruleId [ fhir:value "RuleResponseContentType" ];
       fhir:TestScript.ruleset.rule.param [
         fhir:index 0;
         fhir:TestScript.ruleset.rule.param.name [ fhir:value "expectedContentType" ];
         fhir:TestScript.ruleset.rule.param.value [ fhir:value "JSON" ]
       ]
     ], [
       fhir:index 1;
       fhir:TestScript.ruleset.rule.ruleId [ fhir:value "RuleResponseStatusCode" ];
       fhir:TestScript.ruleset.rule.param [
         fhir:index 0;
         fhir:TestScript.ruleset.rule.param.name [ fhir:value "expectedStatusCode" ];
         fhir:TestScript.ruleset.rule.param.value [ fhir:value "200" ]
       ]
     ]
  ];
  fhir:TestScript.setup [
     fhir:TestScript.setup.action [
       fhir:index 0;
       fhir:TestScript.setup.action.operation [
         fhir:TestScript.setup.action.operation.type [
           fhir:Coding.code [ fhir:value "create" ]
         ];
         fhir:TestScript.setup.action.operation.label [ fhir:value "SetupPatient" ];
         fhir:TestScript.setup.action.operation.description [ fhir:value "Create patient resource on test server" ];
         fhir:TestScript.setup.action.operation.accept [ fhir:value "json" ];
         fhir:TestScript.setup.action.operation.responseId [ fhir:value "create-response" ];
         fhir:TestScript.setup.action.operation.sourceId [ fhir:value "F1" ]
       ]
     ], [
       fhir:index 1;
       fhir:TestScript.setup.action.assert [
         fhir:TestScript.setup.action.assert.label [ fhir:value "RuleReadOK" ];
         fhir:TestScript.setup.action.assert.direction [ fhir:value "request" ];
         fhir:TestScript.setup.action.assert.rule [
           fhir:TestScript.setup.action.assert.rule.ruleId [ fhir:value "ruleResponseOkay" ];
           fhir:TestScript.setup.action.assert.rule.param [
             fhir:index 0;
             fhir:TestScript.setup.action.assert.rule.param.name [ fhir:value "expectedStatusCode" ];
             fhir:TestScript.setup.action.assert.rule.param.value [ fhir:value "201" ]
           ]
         ]
       ]
     ]
  ];
  fhir:TestScript.test [
     fhir:index 0;
     fhir:Element.id [ fhir:value "READ01" ];
     fhir:TestScript.test.name [ fhir:value "Read Patient" ];
     fhir:TestScript.test.description [ fhir:value "Read a patient and validate response." ];
     fhir:TestScript.test.action [
       fhir:index 0;
       fhir:TestScript.test.action.operation [
         fhir:TestScript.setup.action.operation.type [
           fhir:Coding.code [ fhir:value "read" ]
         ];
         fhir:TestScript.setup.action.operation.encodeRequestUrl [ fhir:value "false"^^xsd:boolean ];
         fhir:TestScript.setup.action.operation.responseId [ fhir:value "F1-read" ];
         fhir:TestScript.setup.action.operation.targetId [ fhir:value "F1" ]
       ]
     ], [
       fhir:index 1;
       fhir:TestScript.test.action.assert [
         fhir:TestScript.setup.action.assert.label [ fhir:value "RuleReadOK" ];
         fhir:TestScript.setup.action.assert.rule [
           fhir:TestScript.setup.action.assert.rule.ruleId [ fhir:value "ruleResponseOkay" ]
         ]
       ]
     ], [
       fhir:index 2;
       fhir:TestScript.test.action.assert [
         fhir:TestScript.setup.action.assert.label [ fhir:value "RuleContentTypeResponse" ];
         fhir:TestScript.setup.action.assert.ruleset [
           fhir:TestScript.setup.action.assert.ruleset.rulesetId [ fhir:value "ruleset-responseResourcePatient" ];
           fhir:TestScript.setup.action.assert.ruleset.rule [
             fhir:index 0;
             fhir:TestScript.setup.action.assert.ruleset.rule.ruleId [ fhir:value "RuleResponseContentType" ];
             fhir:TestScript.setup.action.assert.ruleset.rule.param [
               fhir:index 0;
               fhir:TestScript.setup.action.assert.ruleset.rule.param.name [ fhir:value "expectedContentType" ];
               fhir:TestScript.setup.action.assert.ruleset.rule.param.value [ fhir:value "XML" ]
             ]
           ]
         ]
       ]
     ], [
       fhir:index 3;
       fhir:TestScript.test.action.assert [
         fhir:TestScript.setup.action.assert.headerField [ fhir:value "Last-Modified" ];
         fhir:TestScript.setup.action.assert.operator [ fhir:value "notEmpty" ];
         fhir:TestScript.setup.action.assert.warningOnly [ fhir:value "true"^^xsd:boolean ]
       ]
     ], [
       fhir:index 4;
       fhir:TestScript.test.action.assert [
         fhir:TestScript.setup.action.assert.resource [ fhir:value "Patient" ]
       ]
     ], [
       fhir:index 5;
       fhir:TestScript.test.action.assert [
         fhir:TestScript.setup.action.assert.validateProfileId [ fhir:value "patient-profile" ]
       ]
     ], [
       fhir:index 6;
       fhir:TestScript.test.action.assert [
         fhir:TestScript.setup.action.assert.operator [ fhir:value "equals" ];
         fhir:TestScript.setup.action.assert.path [ fhir:value "fhir:Patient/fhir:name/fhir:family/@value" ];
         fhir:TestScript.setup.action.assert.value [ fhir:value "Chalmers" ]
       ]
     ], [
       fhir:index 7;
       fhir:TestScript.test.action.assert [
         fhir:TestScript.setup.action.assert.operator [ fhir:value "equals" ];
         fhir:TestScript.setup.action.assert.path [ fhir:value "fhir:Patient/fhir:name/fhir:family/@value" ];
         fhir:TestScript.setup.action.assert.sourceId [ fhir:value "F1" ];
         fhir:TestScript.setup.action.assert.value [ fhir:value "Chalmers" ]
       ]
     ], [
       fhir:index 8;
       fhir:TestScript.test.action.assert [
         fhir:TestScript.setup.action.assert.compareToSourceId [ fhir:value "F1-read" ];
         fhir:TestScript.setup.action.assert.compareToSourcePath [ fhir:value "fhir:Patient/fhir:name/fhir:family/@value" ];
         fhir:TestScript.setup.action.assert.operator [ fhir:value "equals" ];
         fhir:TestScript.setup.action.assert.path [ fhir:value "fhir:Patient/fhir:name/fhir:family/@value" ]
       ]
     ], [
       fhir:index 9;
       fhir:TestScript.test.action.assert [
         fhir:TestScript.setup.action.assert.compareToSourceId [ fhir:value "F1-read" ];
         fhir:TestScript.setup.action.assert.compareToSourcePath [ fhir:value "fhir:Patient/fhir:name/fhir:family/@value" ];
         fhir:TestScript.setup.action.assert.path [ fhir:value "fhir:Patient/fhir:name/fhir:family/@value" ];
         fhir:TestScript.setup.action.assert.sourceId [ fhir:value "F1" ]
       ]
     ], [
       fhir:index 10;
       fhir:TestScript.test.action.assert [
         fhir:TestScript.setup.action.assert.minimumId [ fhir:value "F1-min" ]
       ]
     ]
  ] .

<http://hl7.org/fhir/StructureDefinition/Patient> a fhir:StructureDefinition .

# -------------------------------------------------------------------------------------


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.