Sidebar

How do I process HL7 ACK messages on the destination node?

0 votes
996 views
asked Dec 11, 2013 by gary-t-8719 (14,860 points)
edited Dec 11, 2013 by gary-t-8719

1 Answer

0 votes
 
Best answer

The default ACK Script on a destination node is coded for an HL7 message. If you are sending HL7 message data and want to process an ACK script then you can select the “Wait For Ack:” check box and use the default ACK script provided as shown below.

if (response === null || response.length === 0) {
   return false;
}
var ackMessage = qie.parseHL7String(response);
var msgId = message.getNode('MSH-10');
var ackId = ackMessage.getNode('MSA-2');
if ((msgId.equals('') && ackId.equals('')) || !msgId.equals(ackId)) {
   throw "Ack id (" + ackId + ") not equal to message id (" + msgId + "): '" + response + "'";
}
return ackMessage.getNode('MSA-1').endsWith('A');

The default HL7 ACK script Checks that the response is not empty and that the message id (MSH-10) is equal to the acknowledgement message id (MSA-2). If these conditions are not meet then an error is generated. Otherwise, QIE deconstructs the response and checks that the Value in MSA-1 ends with an A indicating that the message was “Accepted”. We only check the last characters as HL7 defines the following valid values in MSA-1. Notice that all valid values that are accepted end with A.

 

Value

Description

AA

Application Accept

AE

Application Error

AR

Application Reject

CA

Commit Accept

CE

Commit Error

CR

Commit Reject

 

 

Notice that in the default script response is being parsed as HL7 and stored in a variable called ackMessage “var ackMessage = qie.parseHL7String(response);” Parsing the response as HL7 allows the user to use any of the QIE functions found in the Code Wizard and gives meaning to the HPATH’s (i.e. MSA-2) used when accessing specific fields from the ackMessage.

 

Important Notes:

1.       QIE stores the ACK message in a reserved variable named “response”.

2.       The response is a data type of “string”, so in order to make use of the Node Paths (i.e. HPath’s, XPath’s, et cetera) the response must be parsed as a particular message type (HL7, XML, CSV et cetera). For more information refer to the “Parse String” functions under the Code Wizard -> QIE System Functions.

3.       After deconstructing the response and checking for specific values in the response the return value of the ACK Script must be either “true” or “false”.

 

See also How do ACK (Message Acknowledgment) scripts work in QIE

answered Dec 12, 2013 by gary-t-8719 (14,860 points)
selected Dec 17, 2013 by ron-s-6919
...