{
"resourceType" : "TestScript",
"id" : "carecommunication-send-tec-07",
"meta" : {
"profile" : [ "http://touchstone.aegis.net/touchstone/fhir/testing/StructureDefinition/testscript" ]
},
"status" : "active",
"date" : "2024-07-15",
"publisher" : "MedCom",
"contact" : [ {
"name" : "MedCom",
"telecom" : [ {
"system" : "email",
"value" : "mailto:fhir@medcom.dk"
}, {
"system" : "url",
"value" : "https://medcom.dk/"
} ]
} ],
"copyright" : "MedCom 2023",
"description" : "Reply to CareCommunication, that includes all content.",
"title" : "Reply to CareCommunication, that includes all content.",
"url" : "http://medcomfhir.dk/ig/carecommunicationtestscript/carecommunication-send-tec-07",
"name" : "CareCommunicationTestScript",
"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-new-message-01",
"autocreate" : false,
"autodelete" : false,
"resource" : {
"reference" : "../Fixtures/CareCommunication-fixture-new-message-all.xml"
}
}, {
"id" : "create-reply-message-02",
"autocreate" : false,
"autodelete" : false,
"resource" : {
"reference" : "../Fixtures/CareCommunication-fixture.xml"
}
} ],
"profile" : [ {
"id" : "carecommunication",
"reference" : "http://medcomfhir.dk/ig/carecommunication/StructureDefinition/medcom-careCommunication-message"
} ],
"variable" : [ {
"name" : "messageHeaderid-new-message-01",
"expression" : "Bundle.entry[0].resource.id",
"sourceId" : "create-message-new-message-01"
}, {
"name" : "destinationUri-new-message-01",
"expression" : "Bundle.entry.resource.ofType(MessageHeader).destination.endpoint",
"sourceId" : "create-message-new-message-01"
}, {
"name" : "bundleid-new-message-01",
"expression" : "Bundle.id",
"sourceId" : "create-message-new-message-01"
}, {
"name" : "messageHeaderid-reply-message-02",
"expression" : "Bundle.entry[0].resource.id",
"sourceId" : "create-message-reply-message-02"
}, {
"name" : "episodeOfCareID-new-message-01",
"expression" : "Bundle.entry.resource.ofType(Encounter).episodeOfCare.identifier.value",
"sourceId" : "create-message-new-message-01"
} ],
"setup" : {
"action" : [ {
"operation" : {
"type" : {
"system" : "http://terminology.hl7.org/CodeSystem/testscript-operation-codes",
"code" : "delete"
},
"resource" : "Bundle",
"description" : "System-generated search, delete operations from conditional delete on Bundle MessageHeader.destination.endpoint",
"accept" : "xml",
"encodeRequestUrl" : true,
"params" : "?message.destination-uri=${destinationUri-new-message}"
}
}, {
"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-new-message-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-new-message-01.",
"accept" : "xml",
"contentType" : "xml",
"encodeRequestUrl" : true,
"sourceId" : "create-new-message-01",
"params" : "/${bundleid-new-message-01}"
}
}, {
"assert" : {
"description" : "Confirm that the returned HTTP status is okay or created.",
"direction" : "response",
"responseCode" : "200,201",
"operator" : "in",
"warningOnly" : false
}
} ]
},
"test" : [ {
"id" : "message-read-new-message-01",
"name" : "Get a new-message 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-new-message-01}"
}
}, {
"assert" : {
"description" : "Confirm that the returned HTTP status is okay or created.",
"direction" : "response",
"responseCode" : "200,201",
"operator" : "in",
"warningOnly" : false
}
} ]
}, {
"id" : "carecommunication-create-reply-message-02",
"name" : "Create a CareCommunication reply-message Message 02",
"description" : "Post CareCommunication to the server.",
"action" : [ {
"operation" : {
"type" : {
"system" : "http://terminology.hl7.org/CodeSystem/testscript-operation-codes",
"code" : "create"
},
"resource" : "Bundle",
"description" : "Post a carecommunication",
"destination" : 1,
"encodeRequestUrl" : true,
"origin" : 1,
"requestId" : "create-message-reply-message-02",
"sourceId" : "create-reply-message-02"
}
}, {
"assert" : {
"description" : "Validates the bundle against http://medcomfhir.dk/ig/carecommunication/ImplementationGuide/dk.fhir.ig.dk-medcom-carecommunication",
"direction" : "request",
"validateProfileId" : "carecommunication",
"warningOnly" : false
}
}, {
"assert" : {
"description" : "Confirm that the returned HTTP status is okay or created.",
"direction" : "response",
"responseCode" : "200,201",
"operator" : "in",
"warningOnly" : false
}
}, {
"assert" : {
"description" : "Confirm that the client request payload contains a Bundle resource type.",
"direction" : "request",
"resource" : "Bundle",
"warningOnly" : false
}
}, {
"assert" : {
"description" : "Confirm that the previous MessageHeader.id is identical to Provenance.entity.what",
"direction" : "request",
"expression" : "Bundle.entry.resource.ofType(Provenance).where(entity.what.reference.contains('${messageHeaderid-new-message-01}')).exists()",
"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 = 'care-communication-message').allTrue()",
"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.where(role = 'revision').exists()",
"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.contains(%resource.entry[0].resource.id)).exists()",
"warningOnly" : false
}
}, {
"assert" : {
"description" : "Confirm that the 2 Provenance instances exists.",
"direction" : "request",
"expression" : "Bundle.entry.resource.ofType(Provenance).count()",
"operator" : "equals",
"value" : "2",
"warningOnly" : false
}
}, {
"assert" : {
"description" : "Confirm that number of payloads is '2'",
"direction" : "request",
"expression" : "Bundle.entry.resource.ofType(Communication).payload.count() = '2'",
"warningOnly" : false
}
}, {
"assert" : {
"description" : "Confirm that the episodeOfCare-identifier is episodeOfCareID-new-message-01",
"direction" : "request",
"expression" : "Bundle.entry.resource.ofType(Encounter).where(episodeOfCare.identifier.value = '${episodeOfCareID-new-message-01}').count() = 1",
"warningOnly" : false
}
} ]
} ]
}