{
"description": "Reply CareCommunication",
"_filename": "example/TestScript-carecommunication-send-reply-message.json",
"package_name": "medcom.fhir.dk.carecommunicationtestscripts",
"date": "2025-10-15",
"meta": {
"profile": [ "http://touchstone.aegis.net/touchstone/fhir/testing/StructureDefinition/testscript" ]
},
"variable": [ {
"name": "messageHeaderid-new-message-01",
"sourceId": "create-new-message-01",
"expression": "Bundle.entry[0].resource.id"
}, {
"name": "destinationUri-new-message-01",
"sourceId": "create-new-message-01",
"expression": "Bundle.entry.resource.ofType(MessageHeader).destination.endpoint"
}, {
"name": "bundleid-new-message-01",
"sourceId": "create-new-message-01",
"expression": "Bundle.id"
}, {
"name": "messageHeaderid-reply-message-02",
"sourceId": "create-reply-message-02",
"expression": "Bundle.entry[0].resource.id"
}, {
"name": "identifier-new-message-01",
"sourceId": "create-new-message-01",
"expression": "Bundle.entry.resource.ofType(Communication).identifier.value"
}, {
"name": "identifier-reply-message-02",
"sourceId": "create-reply-message-02",
"expression": "Bundle.entry.resource.ofType(Communication).identifier.value"
} ],
"publisher": null,
"jurisdiction": [ {
"coding": [ {
"code": "DK",
"system": "urn:iso:std:iso:3166",
"display": "Denmark"
} ]
} ],
"name": "CareCommunicationTestScript",
"copyright": "MedCom 2023",
"type": null,
"experimental": null,
"resourceType": "TestScript",
"title": "Reply CareCommunication",
"setup": {
"action": [ {
"operation": {
"type": {
"code": "delete",
"system": "http://terminology.hl7.org/CodeSystem/testscript-operation-codes"
},
"accept": "xml",
"params": "?message.destination-uri=$destinationUri-new-message",
"resource": "Bundle",
"description": "System-generated search, delete operations from conditional delete on Bundle MessageHeader.destination.endpoint",
"destination": 1,
"encodeRequestUrl": true
}
}, {
"operation": {
"description": "Create or Update the Bundle.id in XML format on the destination server, so it corresponds to $bundleid-new-message-01.",
"params": "/${bundleid-new-message-01}",
"type": {
"code": "updateCreate",
"system": "http://terminology.hl7.org/CodeSystem/testscript-operation-codes"
},
"encodeRequestUrl": true,
"resource": "Bundle",
"contentType": "xml",
"sourceId": "create-new-message-01",
"destination": 1,
"accept": "xml"
}
}, {
"assert": {
"operator": "in",
"direction": "response",
"description": "Confirm that the returned HTTP status is okay or created.",
"warningOnly": false,
"responseCode": "200,201"
}
} ]
},
"package_version": "5.0.0",
"status": "active",
"id": "046b4ef0-69a2-49f1-982c-8079d192684a",
"kind": null,
"url": "http://medcomfhir.dk/ig/carecommunicationtestscript/carecommunication-send-reply-message",
"origin": [ {
"index": 1,
"profile": {
"code": "FHIR-Client",
"system": "http://terminology.hl7.org/CodeSystem/testscript-profile-origin-types"
}
} ],
"fixture": [ {
"id": "create-new-message-01",
"resource": {
"reference": "../Fixtures/CareCommunication-fixture.xml"
},
"autocreate": false,
"autodelete": false
}, {
"id": "create-reply-message-02",
"resource": {
"reference": "../Fixtures/CareCommunication-fixture-empty.xml"
},
"autocreate": false,
"autodelete": false
} ],
"version": "5.0.0",
"contact": [ {
"name": "MedCom",
"telecom": [ {
"value": "mailto:fhir@medcom.dk",
"system": "email"
} ]
} ],
"destination": [ {
"index": 1,
"profile": {
"code": "FHIR-Server",
"system": "http://terminology.hl7.org/CodeSystem/testscript-profile-destination-types"
}
} ],
"test": [ {
"id": "message-read-new-message-01",
"name": "Get a new-message message 01",
"action": [ {
"operation": {
"type": {
"code": "read",
"system": "http://terminology.hl7.org/CodeSystem/testscript-operation-codes"
},
"accept": "xml",
"origin": 1,
"params": "/${bundleid-new-message-01}",
"resource": "Bundle",
"description": "Receive message",
"destination": 1,
"encodeRequestUrl": true
}
}, {
"assert": {
"operator": "in",
"direction": "response",
"description": "Confirm that the returned HTTP status is okay or created.",
"warningOnly": false,
"responseCode": "200,201"
}
} ],
"description": "GET a message. The expected response is a 200(OK) with a payload of the message resource in XML format."
}, {
"id": "carecommunication-create-reply-message-02",
"name": "Create a CareCommunication reply-message Message 02",
"action": [ {
"operation": {
"type": {
"code": "create",
"system": "http://terminology.hl7.org/CodeSystem/testscript-operation-codes"
},
"origin": 1,
"resource": "Bundle",
"sourceId": "create-reply-message-02",
"description": "Post a carecommunication",
"destination": 1,
"encodeRequestUrl": true
}
}, {
"assert": {
"direction": "request",
"description": "Validates the bundle against http://medcomfhir.dk/ig/carecommunication/ImplementationGuide/dk.fhir.ig.dk-medcom-carecommunication|5.0.1",
"warningOnly": false,
"validateProfileId": "carecommunication"
}
}, {
"assert": {
"operator": "in",
"direction": "response",
"description": "Confirm that the returned HTTP status is okay or created.",
"warningOnly": false,
"responseCode": "200,201"
}
}, {
"assert": {
"resource": "Bundle",
"direction": "request",
"description": "Confirm that the client request payload contains a Bundle resource type.",
"warningOnly": false
}
}, {
"assert": {
"direction": "request",
"expression": "Bundle.entry.resource.ofType(Provenance).where(entity.what.reference.contains('${messageHeaderid-new-message-01}')).exists()",
"description": "Confirm that the previous MessageHeader.id is referenced in Provenance.entity.what",
"warningOnly": false
}
}, {
"assert": {
"direction": "request",
"expression": "Bundle.entry.resource.ofType(MessageHeader).event.as(Coding).code = 'care-communication-message'",
"description": "Confirm that the request resource contains the expected eventCoding.code.",
"warningOnly": false
}
}, {
"assert": {
"direction": "request",
"expression": "Bundle.entry.resource.ofType(Provenance).entity.where(role = 'revision').exists()",
"description": "Confirm that the role is set to revision. Not used when testing the first message in a stream",
"warningOnly": false
}
}, {
"assert": {
"direction": "request",
"expression": "Bundle.entry.resource.ofType(Provenance).where(target.reference.contains(%resource.entry[0].resource.id)).exists()",
"description": "Confirm that the target reference in Provenance equals MessageHeader.id",
"warningOnly": false
}
}, {
"assert": {
"value": "2",
"operator": "equals",
"direction": "request",
"expression": "Bundle.entry.resource.ofType(Provenance).count()",
"description": "Confirm that the 2 Provenance instances exists.",
"warningOnly": false
}
}, {
"assert": {
"direction": "request",
"expression": "Bundle.entry.resource.ofType(Communication).payload.count() = '2'",
"description": "Confirm that number of payloads is '2'",
"warningOnly": false
}
}, {
"assert": {
"direction": "request",
"expression": "Bundle.entry.resource.ofType(Communication).identifier.value = '${identifier-new-message-01}'",
"description": "Confirm that the communication.identifier is held the same in the two messages",
"warningOnly": false
}
} ],
"description": "Post CareCommunication to the server."
} ],
"profile": [ {
"id": "carecommunication",
"reference": "http://medcomfhir.dk/ig/carecommunication/StructureDefinition/medcom-careCommunication-message|5.0.1"
} ]
}