Test Script

Name/FHIRSandbox/MedCom/CareCommunication/v400-send/Send/UseCases/CareCommunication_TestScripts_send-forward-changecategory
DescriptionForward CareCommunication with changed category
Version2Latest2
Content
{
  "resourceType" : "TestScript",
  "id" : "carecommunication-send-forward-changecategory",
  "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" : "Forward CareCommunication with changed category",
  "title" : "Forward CareCommunication with changed category",
  "url" : "http://medcomfhir.dk/ig/carecommunicationtestscript/carecommunication-send-forward-changecategory",
  "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.xml"
    }
  }, {
    "id" : "create-forward-message-02",
    "autocreate" : false,
    "autodelete" : false,
    "resource" : {
      "reference" : "../Fixtures/CareCommunication-fixture-empty.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" : "hospitalSOR-new-message-01",
    "expression" : "Bundle.entry[0].resource.sender.reference.resolve().identifier.where(system = 'urn:oid:1.2.208.176.1.1').value",
    "sourceId" : "create-message-new-message-01"
  }, {
    "name" : "messageHeaderid-forward-message-02",
    "expression" : "Bundle.entry[0].resource.id",
    "sourceId" : "create-message-forward-message-02"
  }, {
    "name" : "category-new-message-01",
    "expression" : "Bundle.entry.resource.ofType(Communication).category.coding.code",
    "sourceId" : "create-message-new-message-01"
  }, {
    "name" : "category-forward-message-02",
    "expression" : "Bundle.entry.resource.ofType(Communication).category.coding.code",
    "sourceId" : "create-message-forward-message-02"
  } ],
  "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-forward-message-02",
    "name" : "Create a CareCommunication forward-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-forward-message-02",
        "sourceId" : "create-forward-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 sender SOR number is different from the previous message.",
        "direction" : "request",
        "expression" : "Bundle.entry[0].resource.sender.reference.resolve().identifier.where(system = 'urn:oid:1.2.208.176.1.1').value != ${hospitalSOR-new-message})",
        "warningOnly" : false
      }
    }, {
      "assert" : {
        "description" : "Confirm that the content is different in the two messages",
        "direction" : "request",
        "expression" : "'${category-new-message-01}' != '${category-forward-message-02}'",
        "warningOnly" : false
      }
    } ]
  } ]
}