STU 3 Candidate

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 . Page versions: R5 R4B R4 R3

Testscript-example.ttl

Raw Turtle, JSON-LD

General 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 xs: <http://www.w3.org/2001/XMLSchema#> .

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

<http://hl7.org/fhir//TestScript/example> a fhir:TestScript;
  fhir:nodeRole fhir:treeRoot;
  fhir:Resource.id [ fhir:value "example"];
  fhir:DomainResource.text [
     fhir:Narrative.status [ fhir:value "generated" ]
  ];
  fhir:TestScript.url [ fhir:value "http://hl7.org/fhir/TestScript/example"];
  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"^^xs: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"^^xs: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"^^xs:boolean ];
       fhir:TestScript.metadata.capability.description [ fhir:value "Patient Create, Read, and Update Operations" ];
       fhir:TestScript.metadata.capability.destination [ fhir:value "1"^^xs:int ];
       fhir:TestScript.metadata.capability.link [
         fhir:value "http://hl7.org/implement/standards/FHIR-Develop/http.html#create";
         fhir:index 0       ];
       fhir:TestScript.metadata.capability.link [
         fhir:value "http://hl7.org/implement/standards/FHIR-Develop/http.html#read";
         fhir:index 1       ];
       fhir:TestScript.metadata.capability.link [
         fhir:value "http://hl7.org/implement/standards/FHIR-Develop/http.html#update";
         fhir:index 2       ];
       fhir:TestScript.metadata.capability.conformance [
         fhir:reference <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"^^xs:boolean ];
     fhir:TestScript.fixture.autodelete [ fhir:value "false"^^xs:boolean ];
     fhir:TestScript.fixture.resource [
       fhir:reference <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:reference <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.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:TestScript.setup.action [
       fhir:index 1;
       fhir:TestScript.setup.action.assert [
         fhir:TestScript.setup.action.assert.direction [ fhir:value "request" ];
         fhir:TestScript.setup.action.assert.responseCode [ 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"^^xs:boolean ];
         fhir:TestScript.setup.action.operation.responseId [ fhir:value "F1-read" ];
         fhir:TestScript.setup.action.operation.targetId [ fhir:value "F1" ]       ]     ];
     fhir:TestScript.test.action [
       fhir:index 1;
       fhir:TestScript.test.action.assert [
         fhir:TestScript.setup.action.assert.label [ fhir:value "ReadOK" ];
         fhir:TestScript.setup.action.assert.description [ fhir:value "Test for OK response" ];
         fhir:TestScript.setup.action.assert.direction [ fhir:value "request" ];
         fhir:TestScript.setup.action.assert.response [ fhir:value "okay" ]       ]     ];
     fhir:TestScript.test.action [
       fhir:index 2;
       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"^^xs:boolean ]       ]     ];
     fhir:TestScript.test.action [
       fhir:index 3;
       fhir:TestScript.test.action.assert [
         fhir:TestScript.setup.action.assert.resource [ fhir:value "Patient" ]       ]     ];
     fhir:TestScript.test.action [
       fhir:index 4;
       fhir:TestScript.test.action.assert [
         fhir:TestScript.setup.action.assert.validateProfileId [ fhir:value "patient-profile" ]       ]     ];
     fhir:TestScript.test.action [
       fhir:index 5;
       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:TestScript.test.action [
       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.sourceId [ fhir:value "F1" ];
         fhir:TestScript.setup.action.assert.value [ fhir:value "Chalmers" ]       ]     ];
     fhir:TestScript.test.action [
       fhir:index 7;
       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:TestScript.test.action [
       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.path [ fhir:value "fhir:Patient/fhir:name/fhir:family/@value" ];
         fhir:TestScript.setup.action.assert.sourceId [ fhir:value "F1" ]       ]     ];
     fhir:TestScript.test.action [
       fhir:index 9;
       fhir:TestScript.test.action.assert [
         fhir:TestScript.setup.action.assert.minimumId [ fhir:value "F1-min" ]       ]     ]
  ].

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


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.