{
  "resourceType" : "TestScript",
  "id" : "acknowledgement-send-transient-error-duplicate-hospitalnotificat",
  "meta" : {
    "profile" : ["http://touchstone.aegis.net/touchstone/fhir/testing/StructureDefinition/testscript"]
  },
  "text" : {
    "status" : "generated",
    "div" : "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p><b>Generated Narrative: TestScript</b><a name=\"acknowledgement-send-transient-error-duplicate-hospitalnotificat\"> </a></p><div style=\"display: inline-block; background-color: #d9e0e7; padding: 6px; margin: 4px; border: 1px solid #8da1b4; border-radius: 5px; line-height: 60%\"><p style=\"margin-bottom: 0px\">Resource TestScript &quot;acknowledgement-send-transient-error-duplicate-hospitalnotificat&quot; </p><p style=\"margin-bottom: 0px\">Profile: <a href=\"file://D:\\GitHub\\Touchstone\\testing-ig\\output/StructureDefinition-testscript.html\">AEGIS Touchstone Testing TestScript Profile</a></p></div><p><b>url</b>: <code>http://medcomfhir.dk/ig/acknowledgementtestscript/acknowledgement-send-transient-error-duplicate-hospitalnotificat</code></p><p><b>version</b>: 2.0.0</p><p><b>name</b>: AcknowledgementTestScript</p><p><b>title</b>: Send acknowledgements, as response to duplicate messages - Transient Error, followed by OK</p><p><b>status</b>: active</p><p><b>date</b>: 2023-05-25</p><p><b>publisher</b>: MedCom</p><p><b>contact</b>: MedCom: <a href=\"mailto:mailto:fhir@medcom.dk\">mailto:fhir@medcom.dk</a></p><p><b>description</b>: Send acknowledgements, as response to duplicate messages - Transient Error, followed by OK</p><p><b>copyright</b>: MedCom 2023</p><h3>Origins</h3><table class=\"grid\"><tr><td>-</td><td><b>Index</b></td><td><b>Profile</b></td></tr><tr><td>*</td><td>1</td><td>FHIR Client (Details: http://terminology.hl7.org/CodeSystem/testscript-profile-origin-types code FHIR-Client = 'FHIR Client', stated as 'null')</td></tr></table><h3>Destinations</h3><table class=\"grid\"><tr><td>-</td><td><b>Index</b></td><td><b>Profile</b></td></tr><tr><td>*</td><td>1</td><td>FHIR Server (Details: http://terminology.hl7.org/CodeSystem/testscript-profile-destination-types code FHIR-Server = 'FHIR Server', stated as 'null')</td></tr></table><blockquote><p><b>fixture</b></p><blockquote><p><b>id</b></p>create-STIN-01</blockquote><p><b>autocreate</b>: false</p><p><b>autodelete</b>: false</p><p><b>resource</b>: <a href=\"/FHIRSandbox/MedCom/Acknowledgement/draft/Send/Fixtures/HospitalNotification-fixture-STIN-transient-error.xml\">/FHIRSandbox/MedCom/Acknowledgement/draft/Send/Fixtures/HospitalNotification-fixture-STIN-transient-error.xml</a></p></blockquote><blockquote><p><b>fixture</b></p><blockquote><p><b>id</b></p>create-STIN2-03</blockquote><p><b>autocreate</b>: false</p><p><b>autodelete</b>: false</p><p><b>resource</b>: <a href=\"/FHIRSandbox/MedCom/Acknowledgement/draft/Send/Fixtures/HospitalNotification-fixture-STIN-ok.xml\">/FHIRSandbox/MedCom/Acknowledgement/draft/Send/Fixtures/HospitalNotification-fixture-STIN-ok.xml</a></p></blockquote><blockquote><p><b>fixture</b></p><blockquote><p><b>id</b></p>create-transient-error-02</blockquote><p><b>autocreate</b>: false</p><p><b>autodelete</b>: false</p><p><b>resource</b>: <a href=\"/FHIRSandbox/MedCom/Acknowledgement/draft/Send/Fixtures/Acknowledgement-fixture.xml\">/FHIRSandbox/MedCom/Acknowledgement/draft/Send/Fixtures/Acknowledgement-fixture.xml</a></p></blockquote><blockquote><p><b>fixture</b></p><blockquote><p><b>id</b></p>create-ok-04</blockquote><p><b>autocreate</b>: false</p><p><b>autodelete</b>: false</p><p><b>resource</b>: <a href=\"/FHIRSandbox/MedCom/Acknowledgement/draft/Send/Fixtures/Acknowledgement-fixture.xml\">/FHIRSandbox/MedCom/Acknowledgement/draft/Send/Fixtures/Acknowledgement-fixture.xml</a></p></blockquote><p><b>profile</b>: <a href=\"http://medcomfhir.dk/ig/acknowledgement/StructureDefinition/medcom-messaging-acknowledgement\">http://medcomfhir.dk/ig/acknowledgement/StructureDefinition/medcom-messaging-acknowledgement</a> &quot;MedComAcknowledgementMessage&quot;</p><blockquote><p><b>variable</b></p><p><b>name</b>: destinationUri-STIN</p><p><b>expression</b>: Bundle.entry.resource.ofType(MessageHeader).destination.endpoint</p><p><b>sourceId</b>: create-STIN-01</p></blockquote><blockquote><p><b>variable</b></p><p><b>name</b>: bundleid-STIN-01</p><p><b>expression</b>: Bundle.id</p><p><b>sourceId</b>: create-STIN-01</p></blockquote><blockquote><p><b>variable</b></p><p><b>name</b>: messageHeaderid-STIN</p><p><b>expression</b>: Bundle.entry[0].fullUrl</p><p><b>sourceId</b>: create-STIN-01</p></blockquote><blockquote><p><b>variable</b></p><p><b>name</b>: destinationUri-STIN2</p><p><b>expression</b>: Bundle.entry.resource.ofType(MessageHeader).destination.endpoint</p><p><b>sourceId</b>: create-STIN2-03</p></blockquote><blockquote><p><b>variable</b></p><p><b>name</b>: bundleid-STIN2-03</p><p><b>expression</b>: Bundle.id</p><p><b>sourceId</b>: create-STIN2-03</p></blockquote><blockquote><p><b>variable</b></p><p><b>name</b>: messageHeaderid-STIN2</p><p><b>expression</b>: Bundle.entry[0].fullUrl</p><p><b>sourceId</b>: create-STIN2-03</p></blockquote><blockquote><p><b>variable</b></p><p><b>name</b>: bundleid-transient-error-02</p><p><b>expression</b>: Bundle.id</p><p><b>sourceId</b>: create-message-transient-error-02</p></blockquote><blockquote><p><b>variable</b></p><p><b>name</b>: bundletimestamp-transient-error-02</p><p><b>expression</b>: Bundle.timestamp</p><p><b>sourceId</b>: create-message-transient-error-02</p></blockquote><blockquote><p><b>variable</b></p><p><b>name</b>: bundleid-ok-04</p><p><b>expression</b>: Bundle.id</p><p><b>sourceId</b>: create-message-ok-04</p></blockquote><blockquote><p><b>variable</b></p><p><b>name</b>: bundletimestamp-ok-04</p><p><b>expression</b>: Bundle.timestamp</p><p><b>sourceId</b>: create-message-ok-04</p></blockquote><blockquote><p><b>setup</b></p><blockquote><p><b>action</b></p><h3>Operations</h3><table class=\"grid\"><tr><td>-</td><td><b>Type</b></td><td><b>Resource</b></td><td><b>Description</b></td><td><b>Accept</b></td><td><b>EncodeRequestUrl</b></td><td><b>Params</b></td></tr><tr><td>*</td><td>Delete (Details: http://terminology.hl7.org/CodeSystem/testscript-operation-codes code delete = 'Delete', stated as 'null')</td><td>Bundle</td><td>System-generated search and delete operations from conditional delete on Bundle MessageHeader.destination.endpoint</td><td>xml</td><td>true</td><td>?message.destination-uri=${destinationUri-STIN}</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Operations</h3><table class=\"grid\"><tr><td>-</td><td><b>Type</b></td><td><b>Resource</b></td><td><b>Description</b></td><td><b>Accept</b></td><td><b>ContentType</b></td><td><b>EncodeRequestUrl</b></td><td><b>SourceId</b></td></tr><tr><td>*</td><td>Create (Details: http://terminology.hl7.org/CodeSystem/testscript-operation-codes code create = 'Create', stated as 'null')</td><td>Bundle</td><td>Create the Bundle resource in XML format on the destination server.</td><td>xml</td><td>xml</td><td>true</td><td>create-STIN-01</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Operations</h3><table class=\"grid\"><tr><td>-</td><td><b>Type</b></td><td><b>Resource</b></td><td><b>Description</b></td><td><b>Accept</b></td><td><b>ContentType</b></td><td><b>EncodeRequestUrl</b></td><td><b>Params</b></td><td><b>SourceId</b></td></tr><tr><td>*</td><td>Create using Update (Details: http://terminology.hl7.org/CodeSystem/testscript-operation-codes code updateCreate = 'Create using Update', stated as 'null')</td><td>Bundle</td><td>Update the Bundle.id in XML format on the destination server, so it corresponds to $bundleid-STIN-01.</td><td>xml</td><td>xml</td><td>true</td><td>/${bundleid-STIN-01}</td><td>create-STIN-01</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table class=\"grid\"><tr><td>-</td><td><b>Description</b></td><td><b>Direction</b></td><td><b>Operator</b></td><td><b>ResponseCode</b></td><td><b>WarningOnly</b></td></tr><tr><td>*</td><td>Confirm that the returned HTTP status is okay or created.</td><td>response</td><td>in</td><td>200,201</td><td>false</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Operations</h3><table class=\"grid\"><tr><td>-</td><td><b>Type</b></td><td><b>Resource</b></td><td><b>Description</b></td><td><b>Accept</b></td><td><b>ContentType</b></td><td><b>EncodeRequestUrl</b></td><td><b>SourceId</b></td></tr><tr><td>*</td><td>Create (Details: http://terminology.hl7.org/CodeSystem/testscript-operation-codes code create = 'Create', stated as 'null')</td><td>Bundle</td><td>Create the Bundle resource in XML format on the destination server.</td><td>xml</td><td>xml</td><td>true</td><td>create-STIN2-03</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Operations</h3><table class=\"grid\"><tr><td>-</td><td><b>Type</b></td><td><b>Resource</b></td><td><b>Description</b></td><td><b>Accept</b></td><td><b>ContentType</b></td><td><b>EncodeRequestUrl</b></td><td><b>Params</b></td><td><b>SourceId</b></td></tr><tr><td>*</td><td>Create using Update (Details: http://terminology.hl7.org/CodeSystem/testscript-operation-codes code updateCreate = 'Create using Update', stated as 'null')</td><td>Bundle</td><td>Update the Bundle.id in XML format on the destination server, so it corresponds to $bundleid-STIN2-03.</td><td>xml</td><td>xml</td><td>true</td><td>/${bundleid-STIN2-03}</td><td>create-STIN2-03</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table class=\"grid\"><tr><td>-</td><td><b>Description</b></td><td><b>Direction</b></td><td><b>Operator</b></td><td><b>ResponseCode</b></td><td><b>WarningOnly</b></td></tr><tr><td>*</td><td>Confirm that the returned HTTP status is okay or created.</td><td>response</td><td>in</td><td>200,201</td><td>false</td></tr></table></blockquote></blockquote><blockquote><p><b>test</b></p><blockquote><p><b>id</b></p>message-read-STIN-01</blockquote><p><b>name</b>: Get a STIN message 01</p><p><b>description</b>: GET a message. The expected response is a 200(OK) with a payload of the message resource in XML format.</p><blockquote><p><b>action</b></p><h3>Operations</h3><table class=\"grid\"><tr><td>-</td><td><b>Type</b></td><td><b>Resource</b></td><td><b>Description</b></td><td><b>Accept</b></td><td><b>Destination</b></td><td><b>EncodeRequestUrl</b></td><td><b>Origin</b></td><td><b>Params</b></td></tr><tr><td>*</td><td>Read (Details: http://terminology.hl7.org/CodeSystem/testscript-operation-codes code read = 'Read', stated as 'null')</td><td>Bundle</td><td>Receive message</td><td>xml</td><td>1</td><td>true</td><td>1</td><td>/${bundleid-STIN-01}</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table class=\"grid\"><tr><td>-</td><td><b>Description</b></td><td><b>Direction</b></td><td><b>Operator</b></td><td><b>ResponseCode</b></td><td><b>WarningOnly</b></td></tr><tr><td>*</td><td>Confirm that the returned HTTP status is okay or created.</td><td>response</td><td>in</td><td>200,201</td><td>false</td></tr></table></blockquote></blockquote><blockquote><p><b>test</b></p><blockquote><p><b>id</b></p>message-create-transient-error-02</blockquote><p><b>name</b>: Create an Acknowledegment transient-error Message 02</p><p><b>description</b>: Post Acknowledegment to the server.</p><blockquote><p><b>action</b></p><h3>Operations</h3><table class=\"grid\"><tr><td>-</td><td><b>Type</b></td><td><b>Resource</b></td><td><b>Description</b></td><td><b>Destination</b></td><td><b>EncodeRequestUrl</b></td><td><b>Origin</b></td><td><b>RequestId</b></td><td><b>SourceId</b></td></tr><tr><td>*</td><td>Create (Details: http://terminology.hl7.org/CodeSystem/testscript-operation-codes code create = 'Create', stated as 'null')</td><td>Bundle</td><td>Post an Acknowledegment</td><td>1</td><td>true</td><td>1</td><td>create-message-transient-error-02</td><td>create-transient-error-02</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table class=\"grid\"><tr><td>-</td><td><b>Description</b></td><td><b>Direction</b></td><td><b>Operator</b></td><td><b>ResponseCode</b></td><td><b>WarningOnly</b></td></tr><tr><td>*</td><td>Confirm that the returned HTTP status is okay or created.</td><td>response</td><td>in</td><td>200,201</td><td>false</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table class=\"grid\"><tr><td>-</td><td><b>Description</b></td><td><b>Direction</b></td><td><b>Resource</b></td><td><b>WarningOnly</b></td></tr><tr><td>*</td><td>Confirm that the client request payload contains a Bundle resource type.</td><td>request</td><td>Bundle</td><td>false</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table class=\"grid\"><tr><td>-</td><td><b>Description</b></td><td><b>Direction</b></td><td><b>ValidateProfileId</b></td><td><b>WarningOnly</b></td></tr><tr><td>*</td><td>Validates the bundle against http://medcomfhir.dk/ig/acknowledgement/StructureDefinition/medcom-messaging-acknowledgement</td><td>request</td><td>acknowledgement</td><td>false</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table class=\"grid\"><tr><td>-</td><td><b>Description</b></td><td><b>Direction</b></td><td><b>Expression</b></td><td><b>WarningOnly</b></td></tr><tr><td>*</td><td>Confirm that the previous MessageHeader fullURL is identical to Provenance.entity.what</td><td>request</td><td>Bundle.entry.resource.ofType(Provenance).where(entity.what.reference = '${messageHeaderid-STIN}').count() = 1</td><td>false</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table class=\"grid\"><tr><td>-</td><td><b>Description</b></td><td><b>Direction</b></td><td><b>Expression</b></td><td><b>WarningOnly</b></td></tr><tr><td>*</td><td>Confirm that the request resource contains the expected eventCoding.code.</td><td>request</td><td>Bundle.entry.resource.ofType(MessageHeader).event.as(Coding).select(code = 'acknowledgement-message').allTrue()</td><td>false</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table class=\"grid\"><tr><td>-</td><td><b>Description</b></td><td><b>Direction</b></td><td><b>Expression</b></td><td><b>WarningOnly</b></td></tr><tr><td>*</td><td>Confirm that MessageHeader.responseCode equals to transient-error</td><td>request</td><td>Bundle.entry.resource.ofType(MessageHeader).response.code = 'transient-error'</td><td>false</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table class=\"grid\"><tr><td>-</td><td><b>Description</b></td><td><b>Direction</b></td><td><b>Expression</b></td><td><b>WarningOnly</b></td></tr><tr><td>*</td><td>Confirm that a OperationOutcome instance is included, when the responseCode is 'transient-error' or 'fatal-error'</td><td>request</td><td>Bundle.entry.resource.ofType(MessageHeader).response.code = 'ok' or ((Bundle.entry.resource.ofType(MessageHeader).response.code = 'transient-error' or Bundle.entry.resource.ofType(MessageHeader).response.code = 'fatal-error') and Bundle.entry.resource.ofType(OperationOutcome).exists())</td><td>false</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table class=\"grid\"><tr><td>-</td><td><b>Description</b></td><td><b>Direction</b></td><td><b>Expression</b></td><td><b>Operator</b></td><td><b>Value</b></td><td><b>WarningOnly</b></td></tr><tr><td>*</td><td>Confirm that the role is set to revision. Not used when testing the first message in a stream</td><td>request</td><td>Bundle.entry.resource.ofType(Provenance).entity.role</td><td>equals</td><td>revision</td><td>false</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table class=\"grid\"><tr><td>-</td><td><b>Description</b></td><td><b>Direction</b></td><td><b>Expression</b></td><td><b>WarningOnly</b></td></tr><tr><td>*</td><td>Confirm that the target reference in Provenance equals MessageHeader.id</td><td>request</td><td>Bundle.entry.resource.ofType(Provenance).where(target.reference = %resource.entry[0].fullUrl).exists()</td><td>false</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table class=\"grid\"><tr><td>-</td><td><b>Description</b></td><td><b>Direction</b></td><td><b>Expression</b></td><td><b>WarningOnly</b></td></tr><tr><td>*</td><td>Confirm that 2 Provenance instances exists.</td><td>request</td><td>Bundle.entry.resource.ofType(Provenance).count() = 2</td><td>false</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table class=\"grid\"><tr><td>-</td><td><b>Description</b></td><td><b>Direction</b></td><td><b>Expression</b></td><td><b>WarningOnly</b></td></tr><tr><td>*</td><td>Confirm that the one Provenance instance contains the expected activity code.</td><td>request</td><td>Bundle.entry.resource.ofType(Provenance).where(activity.coding.code = 'acknowledgement').count() = 1</td><td>false</td></tr></table></blockquote></blockquote><blockquote><p><b>test</b></p><blockquote><p><b>id</b></p>message-read-STIN2-03</blockquote><p><b>name</b>: Get a STIN2 message 03</p><p><b>description</b>: GET a message. The expected response is a 200(OK) with a payload of the message resource in XML format.</p><blockquote><p><b>action</b></p><h3>Operations</h3><table class=\"grid\"><tr><td>-</td><td><b>Type</b></td><td><b>Resource</b></td><td><b>Description</b></td><td><b>Accept</b></td><td><b>Destination</b></td><td><b>EncodeRequestUrl</b></td><td><b>Origin</b></td><td><b>Params</b></td></tr><tr><td>*</td><td>Read (Details: http://terminology.hl7.org/CodeSystem/testscript-operation-codes code read = 'Read', stated as 'null')</td><td>Bundle</td><td>Receive message</td><td>xml</td><td>1</td><td>true</td><td>1</td><td>/${bundleid-STIN2-03}</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table class=\"grid\"><tr><td>-</td><td><b>Description</b></td><td><b>Direction</b></td><td><b>Operator</b></td><td><b>ResponseCode</b></td><td><b>WarningOnly</b></td></tr><tr><td>*</td><td>Confirm that the returned HTTP status is okay or created.</td><td>response</td><td>in</td><td>200,201</td><td>false</td></tr></table></blockquote></blockquote><blockquote><p><b>test</b></p><blockquote><p><b>id</b></p>message-create-ok-04</blockquote><p><b>name</b>: Create an Acknowledegment ok Message 04</p><p><b>description</b>: Post Acknowledegment to the server.</p><blockquote><p><b>action</b></p><h3>Operations</h3><table class=\"grid\"><tr><td>-</td><td><b>Type</b></td><td><b>Resource</b></td><td><b>Description</b></td><td><b>Destination</b></td><td><b>EncodeRequestUrl</b></td><td><b>Origin</b></td><td><b>RequestId</b></td><td><b>SourceId</b></td></tr><tr><td>*</td><td>Create (Details: http://terminology.hl7.org/CodeSystem/testscript-operation-codes code create = 'Create', stated as 'null')</td><td>Bundle</td><td>Post an Acknowledegment</td><td>1</td><td>true</td><td>1</td><td>create-message-ok-04</td><td>create-ok-04</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table class=\"grid\"><tr><td>-</td><td><b>Description</b></td><td><b>Direction</b></td><td><b>Operator</b></td><td><b>ResponseCode</b></td><td><b>WarningOnly</b></td></tr><tr><td>*</td><td>Confirm that the returned HTTP status is okay or created.</td><td>response</td><td>in</td><td>200,201</td><td>false</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table class=\"grid\"><tr><td>-</td><td><b>Description</b></td><td><b>Direction</b></td><td><b>Resource</b></td><td><b>WarningOnly</b></td></tr><tr><td>*</td><td>Confirm that the client request payload contains a Bundle resource type.</td><td>request</td><td>Bundle</td><td>false</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table class=\"grid\"><tr><td>-</td><td><b>Description</b></td><td><b>Direction</b></td><td><b>ValidateProfileId</b></td><td><b>WarningOnly</b></td></tr><tr><td>*</td><td>Validates the bundle against http://medcomfhir.dk/ig/acknowledgement/StructureDefinition/medcom-messaging-acknowledgement</td><td>request</td><td>acknowledgement</td><td>false</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table class=\"grid\"><tr><td>-</td><td><b>Description</b></td><td><b>Direction</b></td><td><b>Expression</b></td><td><b>WarningOnly</b></td></tr><tr><td>*</td><td>Confirm that the previous MessageHeader fullURL is identical to Provenance.entity.what</td><td>request</td><td>Bundle.entry.resource.ofType(Provenance).where(entity.what.reference = '${messageHeaderid-STIN2}').count() = 1</td><td>false</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table class=\"grid\"><tr><td>-</td><td><b>Description</b></td><td><b>Direction</b></td><td><b>Expression</b></td><td><b>WarningOnly</b></td></tr><tr><td>*</td><td>Confirm that the request resource contains the expected eventCoding.code.</td><td>request</td><td>Bundle.entry.resource.ofType(MessageHeader).event.as(Coding).select(code = 'acknowledgement-message').allTrue()</td><td>false</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table class=\"grid\"><tr><td>-</td><td><b>Description</b></td><td><b>Direction</b></td><td><b>Expression</b></td><td><b>WarningOnly</b></td></tr><tr><td>*</td><td>Confirm that MessageHeader.responseCode equals to ok</td><td>request</td><td>Bundle.entry.resource.ofType(MessageHeader).response.code = 'ok'</td><td>false</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table class=\"grid\"><tr><td>-</td><td><b>Description</b></td><td><b>Direction</b></td><td><b>Expression</b></td><td><b>WarningOnly</b></td></tr><tr><td>*</td><td>Confirm that a OperationOutcome instance is included, when the responseCode is 'transient-error' or 'fatal-error'</td><td>request</td><td>Bundle.entry.resource.ofType(MessageHeader).response.code = 'ok' or ((Bundle.entry.resource.ofType(MessageHeader).response.code = 'transient-error' or Bundle.entry.resource.ofType(MessageHeader).response.code = 'fatal-error') and Bundle.entry.resource.ofType(OperationOutcome).exists())</td><td>false</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table class=\"grid\"><tr><td>-</td><td><b>Description</b></td><td><b>Direction</b></td><td><b>Expression</b></td><td><b>Operator</b></td><td><b>Value</b></td><td><b>WarningOnly</b></td></tr><tr><td>*</td><td>Confirm that the role is set to revision. Not used when testing the first message in a stream</td><td>request</td><td>Bundle.entry.resource.ofType(Provenance).entity.role</td><td>equals</td><td>revision</td><td>false</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table class=\"grid\"><tr><td>-</td><td><b>Description</b></td><td><b>Direction</b></td><td><b>Expression</b></td><td><b>WarningOnly</b></td></tr><tr><td>*</td><td>Confirm that the target reference in Provenance equals MessageHeader.id</td><td>request</td><td>Bundle.entry.resource.ofType(Provenance).where(target.reference = %resource.entry[0].fullUrl).exists()</td><td>false</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table class=\"grid\"><tr><td>-</td><td><b>Description</b></td><td><b>Direction</b></td><td><b>Expression</b></td><td><b>WarningOnly</b></td></tr><tr><td>*</td><td>Confirm that 2 Provenance instances exists.</td><td>request</td><td>Bundle.entry.resource.ofType(Provenance).count() = 2</td><td>false</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table class=\"grid\"><tr><td>-</td><td><b>Description</b></td><td><b>Direction</b></td><td><b>Expression</b></td><td><b>WarningOnly</b></td></tr><tr><td>*</td><td>Confirm that the one Provenance instance contains the expected activity code.</td><td>request</td><td>Bundle.entry.resource.ofType(Provenance).where(activity.coding.code = 'acknowledgement').count() = 1</td><td>false</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table class=\"grid\"><tr><td>-</td><td><b>Description</b></td><td><b>Direction</b></td><td><b>Expression</b></td><td><b>WarningOnly</b></td></tr><tr><td>*</td><td>Confirm that the Bundle.timestamp of the two Acknowledgements are different.</td><td>request</td><td>'${bundletimestamp-transient-error-02}' != '${bundletimestamp-ok-04}'</td><td>false</td></tr></table></blockquote><blockquote><p><b>action</b></p><h3>Asserts</h3><table class=\"grid\"><tr><td>-</td><td><b>Description</b></td><td><b>Direction</b></td><td><b>Expression</b></td><td><b>WarningOnly</b></td></tr><tr><td>*</td><td>Confirm that the Bundle.id of the two Acknowledgements are different.</td><td>request</td><td>'${bundleid-transient-error-02}' != '${bundleid-ok-04}'</td><td>false</td></tr></table></blockquote></blockquote></div>"
  },
  "url" : "http://medcomfhir.dk/ig/acknowledgementtestscript/acknowledgement-send-transient-error-duplicate-hospitalnotificat",
  "version" : "2.0.0",
  "name" : "AcknowledgementTestScript",
  "title" : "Send acknowledgements, as response to duplicate messages - Transient Error, followed by OK",
  "status" : "active",
  "date" : "2023-05-25",
  "publisher" : "MedCom",
  "contact" : [{
    "name" : "MedCom",
    "telecom" : [{
      "system" : "email",
      "value" : "mailto:fhir@medcom.dk"
    }]
  }],
  "description" : "Send acknowledgements, as response to duplicate messages - Transient Error, followed by OK",
  "copyright" : "MedCom 2023",
  "origin" : [{
    "index" : 1,
    "profile" : {
      "system" : "http://terminology.hl7.org/CodeSystem/testscript-profile-origin-types",
      "code" : "FHIR-Client"
    }
  }],
  "destination" : [{
    "index" : 1,
    "profile" : {
      "system" : "http://terminology.hl7.org/CodeSystem/testscript-profile-destination-types",
      "code" : "FHIR-Server"
    }
  }],
  "fixture" : [{
    "id" : "create-STIN-01",
    "autocreate" : false,
    "autodelete" : false,
    "resource" : {
      "reference" : "/FHIRSandbox/MedCom/Acknowledgement/draft/Send/Fixtures/HospitalNotification-fixture-STIN-transient-error.xml"
    }
  },
  {
    "id" : "create-STIN2-03",
    "autocreate" : false,
    "autodelete" : false,
    "resource" : {
      "reference" : "/FHIRSandbox/MedCom/Acknowledgement/draft/Send/Fixtures/HospitalNotification-fixture-STIN-ok.xml"
    }
  },
  {
    "id" : "create-transient-error-02",
    "autocreate" : false,
    "autodelete" : false,
    "resource" : {
      "reference" : "/FHIRSandbox/MedCom/Acknowledgement/draft/Send/Fixtures/Acknowledgement-fixture.xml"
    }
  },
  {
    "id" : "create-ok-04",
    "autocreate" : false,
    "autodelete" : false,
    "resource" : {
      "reference" : "/FHIRSandbox/MedCom/Acknowledgement/draft/Send/Fixtures/Acknowledgement-fixture.xml"
    }
  }],
  "profile" : [{
    "id" : "acknowledgement",
    "reference" : "http://medcomfhir.dk/ig/acknowledgement/StructureDefinition/medcom-messaging-acknowledgement"
  }],
  "variable" : [{
    "name" : "destinationUri-STIN",
    "expression" : "Bundle.entry.resource.ofType(MessageHeader).destination.endpoint",
    "sourceId" : "create-STIN-01"
  },
  {
    "name" : "bundleid-STIN-01",
    "expression" : "Bundle.id",
    "sourceId" : "create-STIN-01"
  },
  {
    "name" : "messageHeaderid-STIN",
    "expression" : "Bundle.entry[0].fullUrl",
    "sourceId" : "create-STIN-01"
  },
  {
    "name" : "destinationUri-STIN2",
    "expression" : "Bundle.entry.resource.ofType(MessageHeader).destination.endpoint",
    "sourceId" : "create-STIN2-03"
  },
  {
    "name" : "bundleid-STIN2-03",
    "expression" : "Bundle.id",
    "sourceId" : "create-STIN2-03"
  },
  {
    "name" : "messageHeaderid-STIN2",
    "expression" : "Bundle.entry[0].fullUrl",
    "sourceId" : "create-STIN2-03"
  },
  {
    "name" : "bundleid-transient-error-02",
    "expression" : "Bundle.id",
    "sourceId" : "create-message-transient-error-02"
  },
  {
    "name" : "bundletimestamp-transient-error-02",
    "expression" : "Bundle.timestamp",
    "sourceId" : "create-message-transient-error-02"
  },
  {
    "name" : "bundleid-ok-04",
    "expression" : "Bundle.id",
    "sourceId" : "create-message-ok-04"
  },
  {
    "name" : "bundletimestamp-ok-04",
    "expression" : "Bundle.timestamp",
    "sourceId" : "create-message-ok-04"
  }],
  "setup" : {
    "action" : [{
      "operation" : {
        "type" : {
          "system" : "http://terminology.hl7.org/CodeSystem/testscript-operation-codes",
          "code" : "delete"
        },
        "resource" : "Bundle",
        "description" : "System-generated search and delete operations from conditional delete on Bundle MessageHeader.destination.endpoint",
        "accept" : "xml",
        "encodeRequestUrl" : true,
        "params" : "?message.destination-uri=${destinationUri-STIN}"
      }
    },
    {
      "operation" : {
        "type" : {
          "system" : "http://terminology.hl7.org/CodeSystem/testscript-operation-codes",
          "code" : "create"
        },
        "resource" : "Bundle",
        "description" : "Create the Bundle resource in XML format on the destination server.",
        "accept" : "xml",
        "contentType" : "xml",
        "encodeRequestUrl" : true,
        "sourceId" : "create-STIN-01"
      }
    },
    {
      "operation" : {
        "type" : {
          "system" : "http://terminology.hl7.org/CodeSystem/testscript-operation-codes",
          "code" : "updateCreate"
        },
        "resource" : "Bundle",
        "description" : "Update the Bundle.id in XML format on the destination server, so it corresponds to $bundleid-STIN-01.",
        "accept" : "xml",
        "contentType" : "xml",
        "encodeRequestUrl" : true,
        "params" : "/${bundleid-STIN-01}",
        "sourceId" : "create-STIN-01"
      }
    },
    {
      "assert" : {
        "description" : "Confirm that the returned HTTP status is okay or created.",
        "direction" : "response",
        "operator" : "in",
        "responseCode" : "200,201",
        "warningOnly" : false
      }
    },
    {
      "operation" : {
        "type" : {
          "system" : "http://terminology.hl7.org/CodeSystem/testscript-operation-codes",
          "code" : "create"
        },
        "resource" : "Bundle",
        "description" : "Create the Bundle resource in XML format on the destination server.",
        "accept" : "xml",
        "contentType" : "xml",
        "encodeRequestUrl" : true,
        "sourceId" : "create-STIN2-03"
      }
    },
    {
      "operation" : {
        "type" : {
          "system" : "http://terminology.hl7.org/CodeSystem/testscript-operation-codes",
          "code" : "updateCreate"
        },
        "resource" : "Bundle",
        "description" : "Update the Bundle.id in XML format on the destination server, so it corresponds to $bundleid-STIN2-03.",
        "accept" : "xml",
        "contentType" : "xml",
        "encodeRequestUrl" : true,
        "params" : "/${bundleid-STIN2-03}",
        "sourceId" : "create-STIN2-03"
      }
    },
    {
      "assert" : {
        "description" : "Confirm that the returned HTTP status is okay or created.",
        "direction" : "response",
        "operator" : "in",
        "responseCode" : "200,201",
        "warningOnly" : false
      }
    }]
  },
  "test" : [{
    "id" : "message-read-STIN-01",
    "name" : "Get a STIN message 01",
    "description" : "GET a message. The expected response is a 200(OK) with a payload of the message resource in XML format.",
    "action" : [{
      "operation" : {
        "type" : {
          "system" : "http://terminology.hl7.org/CodeSystem/testscript-operation-codes",
          "code" : "read"
        },
        "resource" : "Bundle",
        "description" : "Receive message",
        "accept" : "xml",
        "destination" : 1,
        "encodeRequestUrl" : true,
        "origin" : 1,
        "params" : "/${bundleid-STIN-01}"
      }
    },
    {
      "assert" : {
        "description" : "Confirm that the returned HTTP status is okay or created.",
        "direction" : "response",
        "operator" : "in",
        "responseCode" : "200,201",
        "warningOnly" : false
      }
    }]
  },
  {
    "id" : "message-create-transient-error-02",
    "name" : "Create an Acknowledegment transient-error Message 02",
    "description" : "Post Acknowledegment to the server.",
    "action" : [{
      "operation" : {
        "type" : {
          "system" : "http://terminology.hl7.org/CodeSystem/testscript-operation-codes",
          "code" : "create"
        },
        "resource" : "Bundle",
        "description" : "Post an Acknowledegment",
        "destination" : 1,
        "encodeRequestUrl" : true,
        "origin" : 1,
        "requestId" : "create-message-transient-error-02",
        "sourceId" : "create-transient-error-02"
      }
    },
    {
      "assert" : {
        "description" : "Confirm that the returned HTTP status is okay or created.",
        "direction" : "response",
        "operator" : "in",
        "responseCode" : "200,201",
        "warningOnly" : false
      }
    },
    {
      "assert" : {
        "description" : "Confirm that the client request payload contains a Bundle resource type.",
        "direction" : "request",
        "resource" : "Bundle",
        "warningOnly" : false
      }
    },
    {
      "assert" : {
        "description" : "Validates the bundle against http://medcomfhir.dk/ig/acknowledgement/StructureDefinition/medcom-messaging-acknowledgement",
        "direction" : "request",
        "validateProfileId" : "acknowledgement",
        "warningOnly" : false
      }
    },
    {
      "assert" : {
        "description" : "Confirm that the previous MessageHeader fullURL is identical to Provenance.entity.what",
        "direction" : "request",
        "expression" : "Bundle.entry.resource.ofType(Provenance).where(entity.what.reference = '${messageHeaderid-STIN}').count() = 1",
        "warningOnly" : false
      }
    },
    {
      "assert" : {
        "description" : "Confirm that the request resource contains the expected eventCoding.code.",
        "direction" : "request",
        "expression" : "Bundle.entry.resource.ofType(MessageHeader).event.as(Coding).select(code = 'acknowledgement-message').allTrue()",
        "warningOnly" : false
      }
    },
    {
      "assert" : {
        "description" : "Confirm that MessageHeader.responseCode equals to transient-error",
        "direction" : "request",
        "expression" : "Bundle.entry.resource.ofType(MessageHeader).response.code = 'transient-error'",
        "warningOnly" : false
      }
    },
    {
      "assert" : {
        "description" : "Confirm that a OperationOutcome instance is included, when the responseCode is 'transient-error' or 'fatal-error'",
        "direction" : "request",
        "expression" : "Bundle.entry.resource.ofType(MessageHeader).response.code = 'ok' or ((Bundle.entry.resource.ofType(MessageHeader).response.code = 'transient-error' or Bundle.entry.resource.ofType(MessageHeader).response.code = 'fatal-error') and Bundle.entry.resource.ofType(OperationOutcome).exists())",
        "warningOnly" : false
      }
    },
    {
      "assert" : {
        "description" : "Confirm that the role is set to revision. Not used when testing the first message in a stream",
        "direction" : "request",
        "expression" : "Bundle.entry.resource.ofType(Provenance).entity.role",
        "operator" : "equals",
        "value" : "revision",
        "warningOnly" : false
      }
    },
    {
      "assert" : {
        "description" : "Confirm that the target reference in Provenance equals MessageHeader.id",
        "direction" : "request",
        "expression" : "Bundle.entry.resource.ofType(Provenance).where(target.reference = %resource.entry[0].fullUrl).exists()",
        "warningOnly" : false
      }
    },
    {
      "assert" : {
        "description" : "Confirm that 2 Provenance instances exists.",
        "direction" : "request",
        "expression" : "Bundle.entry.resource.ofType(Provenance).count() = 2",
        "warningOnly" : false
      }
    },
    {
      "assert" : {
        "description" : "Confirm that the one Provenance instance contains the expected activity code.",
        "direction" : "request",
        "expression" : "Bundle.entry.resource.ofType(Provenance).where(activity.coding.code = 'acknowledgement').count() = 1",
        "warningOnly" : false
      }
    }]
  },
  {
    "id" : "message-read-STIN2-03",
    "name" : "Get a STIN2 message 03",
    "description" : "GET a message. The expected response is a 200(OK) with a payload of the message resource in XML format.",
    "action" : [{
      "operation" : {
        "type" : {
          "system" : "http://terminology.hl7.org/CodeSystem/testscript-operation-codes",
          "code" : "read"
        },
        "resource" : "Bundle",
        "description" : "Receive message",
        "accept" : "xml",
        "destination" : 1,
        "encodeRequestUrl" : true,
        "origin" : 1,
        "params" : "/${bundleid-STIN2-03}"
      }
    },
    {
      "assert" : {
        "description" : "Confirm that the returned HTTP status is okay or created.",
        "direction" : "response",
        "operator" : "in",
        "responseCode" : "200,201",
        "warningOnly" : false
      }
    }]
  },
  {
    "id" : "message-create-ok-04",
    "name" : "Create an Acknowledegment ok Message 04",
    "description" : "Post Acknowledegment to the server.",
    "action" : [{
      "operation" : {
        "type" : {
          "system" : "http://terminology.hl7.org/CodeSystem/testscript-operation-codes",
          "code" : "create"
        },
        "resource" : "Bundle",
        "description" : "Post an Acknowledegment",
        "destination" : 1,
        "encodeRequestUrl" : true,
        "origin" : 1,
        "requestId" : "create-message-ok-04",
        "sourceId" : "create-ok-04"
      }
    },
    {
      "assert" : {
        "description" : "Confirm that the returned HTTP status is okay or created.",
        "direction" : "response",
        "operator" : "in",
        "responseCode" : "200,201",
        "warningOnly" : false
      }
    },
    {
      "assert" : {
        "description" : "Confirm that the client request payload contains a Bundle resource type.",
        "direction" : "request",
        "resource" : "Bundle",
        "warningOnly" : false
      }
    },
    {
      "assert" : {
        "description" : "Validates the bundle against http://medcomfhir.dk/ig/acknowledgement/StructureDefinition/medcom-messaging-acknowledgement",
        "direction" : "request",
        "validateProfileId" : "acknowledgement",
        "warningOnly" : false
      }
    },
    {
      "assert" : {
        "description" : "Confirm that the previous MessageHeader fullURL is identical to Provenance.entity.what",
        "direction" : "request",
        "expression" : "Bundle.entry.resource.ofType(Provenance).where(entity.what.reference = '${messageHeaderid-STIN2}').count() = 1",
        "warningOnly" : false
      }
    },
    {
      "assert" : {
        "description" : "Confirm that the request resource contains the expected eventCoding.code.",
        "direction" : "request",
        "expression" : "Bundle.entry.resource.ofType(MessageHeader).event.as(Coding).select(code = 'acknowledgement-message').allTrue()",
        "warningOnly" : false
      }
    },
    {
      "assert" : {
        "description" : "Confirm that MessageHeader.responseCode equals to ok",
        "direction" : "request",
        "expression" : "Bundle.entry.resource.ofType(MessageHeader).response.code = 'ok'",
        "warningOnly" : false
      }
    },
    {
      "assert" : {
        "description" : "Confirm that a OperationOutcome instance is included, when the responseCode is 'transient-error' or 'fatal-error'",
        "direction" : "request",
        "expression" : "Bundle.entry.resource.ofType(MessageHeader).response.code = 'ok' or ((Bundle.entry.resource.ofType(MessageHeader).response.code = 'transient-error' or Bundle.entry.resource.ofType(MessageHeader).response.code = 'fatal-error') and Bundle.entry.resource.ofType(OperationOutcome).exists())",
        "warningOnly" : false
      }
    },
    {
      "assert" : {
        "description" : "Confirm that the role is set to revision. Not used when testing the first message in a stream",
        "direction" : "request",
        "expression" : "Bundle.entry.resource.ofType(Provenance).entity.role",
        "operator" : "equals",
        "value" : "revision",
        "warningOnly" : false
      }
    },
    {
      "assert" : {
        "description" : "Confirm that the target reference in Provenance equals MessageHeader.id",
        "direction" : "request",
        "expression" : "Bundle.entry.resource.ofType(Provenance).where(target.reference = %resource.entry[0].fullUrl).exists()",
        "warningOnly" : false
      }
    },
    {
      "assert" : {
        "description" : "Confirm that 2 Provenance instances exists.",
        "direction" : "request",
        "expression" : "Bundle.entry.resource.ofType(Provenance).count() = 2",
        "warningOnly" : false
      }
    },
    {
      "assert" : {
        "description" : "Confirm that the one Provenance instance contains the expected activity code.",
        "direction" : "request",
        "expression" : "Bundle.entry.resource.ofType(Provenance).where(activity.coding.code = 'acknowledgement').count() = 1",
        "warningOnly" : false
      }
    },
    {
      "assert" : {
        "description" : "Confirm that the Bundle.timestamp of the two Acknowledgements are different.",
        "direction" : "request",
        "expression" : "'${bundletimestamp-transient-error-02}' != '${bundletimestamp-ok-04}'",
        "warningOnly" : false
      }
    },
    {
      "assert" : {
        "description" : "Confirm that the Bundle.id of the two Acknowledgements are different.",
        "direction" : "request",
        "expression" : "'${bundleid-transient-error-02}' != '${bundleid-ok-04}'",
        "warningOnly" : false
      }
    }]
  }]
}