-
Notifications
You must be signed in to change notification settings - Fork 7
Description
Hey there,
I have a scriptlet pasted below. In it you can see that I have two params isPatientDeliveryStatus and isSBDHAckOrSBDhFhirAck, these are set so that I can reuse the same scriptlet in many testcases and also maintain orderering of my test steps. For example I would like to always do the step "Assert that the profile is EdsPatientDeliveryStatus" as the second step, straight after the first step.
But these if statements are kinda misused compared to their original intent, because this is not a runtime decision, this is a compile time decision, set to either true or false in the testcase.
So I was wondering if there is something I can do so that the user doesn't see this decision making, i.e. the if statement is hidden, but not the or steps. So that the user just sees the resulting step inside the relevant step?
Similarly I also have cases where I would like to dynamically change the desc of a test step, based on something that is compile-time sat by the testcase. It is kinda in the same vein.
<?xml version="1.0" encoding="UTF-8"?>
<scriptlet id="CommonMSHSBDHAsserts" xmlns="http://www.gitb.com/tdl/v1/">
<params>
<var name="providedEDSAuditEvent" type="string" />
<var name="subtypeCode" type="string"/>
<var name="matchingSBDH" type="string"/>
<var name="isPatientDeliveryStatus" type="boolean"/>
<var name="isSBDHAckOrSBDHFhirAck" type="boolean"/>
</params>
<steps>
<verify output="validationOutput" handler="$DOMAIN{validationServiceAddress}" desc="Validate against the profile">
<input name="fhirResource">$providedEDSAuditEvent</input>
<input name="ig">"dk.ehmi.eds#1.0.2"</input>
</verify>
<if title="Is expected PatientDeliveryStatus?" desc="$isPatientDeliveryStatus">
<cond>$isPatientDeliveryStatus</cond>
<then>
<call path="Scriptlets/FhirExpressionScriptletWithValidation.xml" from="utility-suite">
<input name="input">$userData{providedEDSAuditEvent}</input>
<input name="expression">"meta.profile[0]"</input>
<input name="expectedValue">"http://medcomehmi.dk/ig/eds/StructureDefinition/EdsPatientDeliveryStatus"</input>
<input name="stepDescription">"Assert that the profile is EdsPatientDeliveryStatus"</input>
</call>
</then>
<else>
<call path="Scriptlets/FhirExpressionScriptletWithValidation.xml" from="utility-suite">
<input name="input">$providedEDSAuditEvent</input>
<input name="expression" asTemplate="true">"meta.profile[0]"</input>
<input name="expectedValue">"http://medcomehmi.dk/ig/eds/StructureDefinition/EdsBasicDeliveryStatus"</input>
<input name="stepDescription">"Assert that the profile is EdsBasicDeliveryStatus"</input>
</call>
</else>
</if>
<call path="Scriptlets/FhirExpressionScriptletWithValidation.xml" from="utility-suite">
<input name="input">$providedEDSAuditEvent</input>
<input name="expression" asTemplate="true">"subtype.code"</input>
<input name="expectedValue">$subtypeCode</input>
<input name="stepDescription">"Assert the subtype"</input>
</call>
<call path="Scriptlets/FhirExpressionScriptletWithValidation.xml" from="utility-suite">
<input name="input">$providedEDSAuditEvent</input>
<input name="expression" asTemplate="true">"contained.where(type.coding.code = 'MSH').exists()"</input>
<input name="failureMsg">"A device has to be within the 'contained' array and have the type code 'MSH'"</input>
<input name="stepDescription">"Assert the device type is 'MSH'"</input>
</call>
<call id="getSBDHSenderGLN" path="Scriptlets/XPathExpressionScriptletWithResult.xml" from="utility-suite">
<input name="input">$matchingSBDH</input>
<input name="expression">"substring-after(/sbdhNS:StandardBusinessDocument/sbdhNS:StandardBusinessDocumentHeader/sbdhNS:Sender/sbdhNS:Identifier/string(), '0088:')"</input>
</call>
<call path="Scriptlets/FhirExpressionScriptletWithValidation.xml" from="utility-suite">
<input name="input">$providedEDSAuditEvent</input>
<input name="expression">"agent.where(type.coding.code = 'ehmiSender').extension.value.value"</input>
<input name="expectedValue">$getSBDHSenderGLN{output}</input>
<input name="stepDescription">"Assert ehmiSender corresponds to SBDH sender"</input>
</call>
<call id="getSBDHReceiverGLN" path="Scriptlets/XPathExpressionScriptletWithResult.xml" from="utility-suite">
<input name="input">$matchingSBDH</input>
<input name="expression">"substring-after(/sbdhNS:StandardBusinessDocument/sbdhNS:StandardBusinessDocumentHeader/sbdhNS:Receiver/sbdhNS:Identifier/string(), '0088:')"</input>
</call>
<call path="Scriptlets/FhirExpressionScriptletWithValidation.xml" from="utility-suite">
<input name="input">$providedEDSAuditEvent</input>
<input name="expression">"agent.where(type.coding.code = 'ehmiReceiver').extension.value.value"</input>
<input name="expectedValue">$getSBDHReceiverGLN{output}</input>
<input name="stepDescription">"Assert ehmiReceiver corresponds to SBDH receiver"</input>
</call>
<group title="Entity ehmiMessage">
<call id="getSBDHMessageIdentifier" path="Scriptlets/XPathExpressionScriptletWithResult.xml" from="utility-suite">
<input name="input">$matchingSBDH</input>
<input name="expression">"/sbdhNS:StandardBusinessDocument/sbdhNS:StandardBusinessDocumentHeader/sbdhNS:BusinessScope/sbdhNS:Scope[sbdhNS:Type = 'MESSAGEIDENTIFIER']/sbdhNS:InstanceIdentifier"</input>
</call>
<call path="Scriptlets/FhirExpressionScriptletWithValidation.xml" from="utility-suite">
<input name="input">$providedEDSAuditEvent</input>
<input name="expression">"entity.where(type.code = 'ehmiMessage').what.identifier.value"</input>
<input name="expectedValue">$getSBDHMessageIdentifier{output}</input>
<input name="stepDescription">"Assert that the ehmiMessage identifier matches the SBDH message identifier"</input>
</call>
<call id="getSBDHStandard" path="Scriptlets/XPathExpressionScriptletWithResult.xml" from="utility-suite">
<input name="input">$matchingSBDH</input>
<input name="expression">"/sbdhNS:StandardBusinessDocument/sbdhNS:StandardBusinessDocumentHeader/sbdhNS:DocumentIdentification/sbdhNS:Standard"</input>
</call>
<call path="Scriptlets/FhirExpressionScriptletWithValidation.xml" from="utility-suite">
<input name="input">$providedEDSAuditEvent</input>
<input name="expression">"entity.where(type.code = 'ehmiMessage').detail.where(type = 'ehmiMessageType').value"</input>
<input name="expectedValue">$getSBDHStandard{output}</input>
<input name="stepDescription">"Assert the ehmiMessageType"</input>
</call>
<call id="getSBDHTypeVersion" path="Scriptlets/XPathExpressionScriptletWithResult.xml" from="utility-suite">
<input name="input">$matchingSBDH</input>
<input name="expression">"/sbdhNS:StandardBusinessDocument/sbdhNS:StandardBusinessDocumentHeader/sbdhNS:DocumentIdentification/sbdhNS:TypeVersion"</input>
</call>
<call path="Scriptlets/FhirExpressionScriptletWithValidation.xml" from="utility-suite">
<input name="input">$providedEDSAuditEvent</input>
<input name="expression">"entity.where(type.code = 'ehmiMessage').detail.where(type = 'ehmiMessageVersion').value"</input>
<input name="expectedValue">$getSBDHTypeVersion{output}</input>
<input name="stepDescription">"Assert the ehmiMessageVersion"</input>
</call>
</group>
<group title="Entity ehmiMessageEnvelope">
<call path="Scriptlets/FhirExpressionScriptletWithValidation.xml" from="utility-suite" stopOnError="true">
<input name="input">$providedEDSAuditEvent</input>
<input name="expression">"entity.where(type.code = 'ehmiMessageEnvelope').exists()"</input>
<input name="stepDescription">"Assert that the ehmiMessageEnvelope entity exists"</input>
</call>
<call id="getSBDHMessageEnvelopeIdentifier" path="Scriptlets/XPathExpressionScriptletWithResult.xml" from="utility-suite">
<input name="input">$matchingSBDH</input>
<input name="expression">"/sbdhNS:StandardBusinessDocument/sbdhNS:StandardBusinessDocumentHeader/sbdhNS:BusinessScope/sbdhNS:Scope[sbdhNS:Type = 'MESSAGEENVELOPEIDENTIFIER']/sbdhNS:InstanceIdentifier"</input>
</call>
<call path="Scriptlets/FhirExpressionScriptletWithValidation.xml" from="utility-suite">
<input name="input">$userData{providedEDSAuditEvent}</input>
<input name="expression">"entity.where(type.code = 'ehmiMessageEnvelope').what.identifier.value"</input>
<input name="expectedValue">$getSBDHMessageEnvelopeIdentifier{output}</input>
<input name="stepDescription">"Assert that the ehmiMessageEnvelope identifier matches the SBDH message envelope identifier"</input>
</call>
<call id="getSBDHType" path="Scriptlets/XPathExpressionScriptletWithResult.xml" from="utility-suite">
<input name="input">$matchingSBDH</input>
<input name="expression">"/sbdhNS:StandardBusinessDocument/sbdhNS:StandardBusinessDocumentHeader/sbdhNS:DocumentIdentification/sbdhNS:Type"</input>
</call>
<call path="Scriptlets/FhirExpressionScriptletWithValidation.xml" from="utility-suite">
<input name="input">$providedEDSAuditEvent</input>
<input name="expression">"entity.where(type.code = 'ehmiMessageEnvelope').detail.where(type = 'ehmiMessageEnvelopeType').value"</input>
<input name="expectedValue">$getSBDHType{output}</input>
<input name="stepDescription">"Assert that the ehmiMessageEnvelopeType is the same as the SBDH Type"</input>
</call>
</group>
<group title="Entity ehmiTransportEnvelope">
<call path="Scriptlets/FhirExpressionScriptletWithValidation.xml" from="utility-suite" stopOnError="true">
<input name="input">$providedEDSAuditEvent</input>
<input name="expression">"entity.where(type.code = 'ehmiTransportEnvelope').exists()"</input>
<input name="stepDescription">"Assert that the ehmiTransportEnvelope entity exists"</input>
</call>
<call path="Scriptlets/FhirExpressionScriptletWithValidation.xml" from="utility-suite">
<input name="input">$providedEDSAuditEvent</input>
<input name="expression">"entity.where(type.code = 'ehmiTransportEnvelope').detail.where(type = 'ehmiTransportEnvelopeType').value"</input>
<input name="expectedValue">"SBDH"</input>
<input name="stepDescription">"Assert that the ehmiTransportEnvelopeType is SBDH"</input>
</call>
<call id="getSBDHHeaderVersion" path="Scriptlets/FhirExpressionScriptletWithResult.xml" from="utility-suite">
<input name="input">$matchingSBDH</input>
<input name="expression">"/sbdhNS:StandardBusinessDocument/sbdhNS:StandardBusinessDocumentHeader/sbdhNS:HeaderVersion"</input>
</call>
<call path="Scriptlets/FhirExpressionScriptletWithValidation.xml" from="utility-suite">
<input name="input">$providedEDSAuditEvent</input>
<input name="expression">"entity.where(type.code = 'ehmiTransportEnvelope').detail.where(type = 'ehmiTransportEnvelopeVersion').value"</input>
<input name="expectedValue">$getSBDHHeaderVersion{output}</input>
<input name="stepDescription">"Assert that the ehmiTransportEnvelopeVersion is the same as the provided SBDH HeaderVersion"</input>
</call>
</group>
<if title="Is expected PatientDeliveryStatus?" desc="$isPatientDeliveryStatus">
<cond>$isPatientDeliveryStatus</cond>
<then>
<call id="getPrimarySBDHPatientCPR" path="Scriptlets/FhirExpressionScriptletWithResult.xml" from="utility-suite">
<input name="input">$matchingPrimarySBDH</input>
<input name="expression">"/sbdhNS:StandardBusinessDocument/sbdhNS:StandardBusinessDocumentHeader/sbdhNS:BusinessScope/sbdhNS:Scope[sbdhNS:Type = 'PATIENTID']/sbdhNS:InstanceIdentifier"</input>
</call>
<call path="Scriptlets/FhirExpressionScriptletWithValidation.xml" from="utility-suite">
<input name="input">$userData{providedEDSAuditEvent}</input>
<input name="expression" asTemplate="true">"entity.where(type.code = 'ehmiPatient').what.identifier.value"</input>
<input name="expectedValue">$getPrimarySBDHPatientCPR{output}</input>
<input name="stepDescription">"Assert that the ehmiPatient identifier is the same as the provided SBDH patient identifier"</input>
</call>
</then>
</if>
<if title="Is SBDH Ack or SBDH FHIR Ack?" desc="$isSBDHAckOrSBDHFhirAck">
<cond>$isSBDHAckOrSBDHFhirAck</cond>
<then>
<group title="Entity ehmiOrigMessage">
<call path="Scriptlets/FhirExpressionScriptletWithValidation.xml" from="utility-suite" stopOnError="true">
<input name="input">$providedEDSAuditEvent</input>
<input name="expression">"entity.where(type.code = 'ehmiOrigMessage').exists()"</input>
<input name="stepDescription">"Assert that the ehmiOrigMessage entity exists"</input>
</call>
<call id="getSBDHOriginalMessageEnvelopeIdentifier" path="Scriptlets/XPathExpressionScriptletWithResult.xml" from="utility-suite">
<input name="input">$matchingSBDH</input>
<input name="expression">"/sbdhNS:StandardBusinessDocument/sbdhNS:StandardBusinessDocumentHeader/sbdhNS:BusinessScope/sbdhNS:Scope[sbdhNS:Type = 'ORIGINALMESSAGEENVELOPEIDENTIFIER']/sbdhNS:InstanceIdentifier"</input>
</call>
<call path="Scriptlets/FhirExpressionScriptletWithValidation.xml" from="utility-suite">
<input name="input">$providedEDSAuditEvent</input>
<input name="expression">"entity.where(type.code = 'ehmiOrigMessage').what.identifier.value"</input>
<input name="expectedValue">$getSBDHOriginalMessageEnvelopeIdentifier{output}</input>
<input name="stepDescription">"Assert that the ehmiOrigMessage identifier matches the SBDH ORIGINALMESSAGEIDENTIFIER scope"</input>
</call>
<call id="getSBDHOriginalMessageStandard" path="Scriptlets/XPathExpressionScriptletWithResult.xml" from="utility-suite">
<input name="input">$matchingSBDH</input>
<input name="expression">"/sbdhNS:StandardBusinessDocument/sbdhNS:StandardBusinessDocumentHeader/sbdhNS:BusinessScope/sbdhNS:Scope[sbdhNS:Type = 'ORIGINALMESSAGESTANDARD']/sbdhNS:InstanceIdentifier"</input>
</call>
<call path="Scriptlets/FhirExpressionScriptletWithValidation.xml" from="utility-suite">
<input name="input">$providedEDSAuditEvent</input>
<input name="expression">"entity.where(type.code = 'ehmiOrigMessage').detail.where(type = 'ehmiMessageType').value"</input>
<input name="expectedValue">$getSBDHOriginalMessageStandard{output}</input>
<input name="stepDescription">"Assert that the ehmiOrigMessage detail matches the SBDH ORIGINALMESSAGESTANDARD scope"</input>
</call>
<call id="getSBDHOriginalMessageVersion" path="Scriptlets/XPathExpressionScriptletWithResult.xml" from="utility-suite">
<input name="input">$matchingSBDH</input>
<input name="expression">"/sbdhNS:StandardBusinessDocument/sbdhNS:StandardBusinessDocumentHeader/sbdhNS:BusinessScope/sbdhNS:Scope[sbdhNS:Type = 'ORIGINALMESSAGEVERSION']/sbdhNS:InstanceIdentifier"</input>
</call>
<call path="Scriptlets/FhirExpressionScriptletWithValidation.xml" from="utility-suite">
<input name="input">$providedEDSAuditEvent</input>
<input name="expression">"entity.where(type.code = 'ehmiOrigMessage').detail.where(type = 'ehmiMessageVersion').value"</input>
<input name="expectedValue">$getSBDHOriginalMessageVersion{output}</input>
<input name="stepDescription">"Assert that the ehmiOrigMessage detail matches the SBDH ORIGINALMESSAGEVERSION scope"</input>
</call>
</group>
</then>
</if>
</steps>
</scriptlet>