Sidebar

Can I have one ACK Script that would work for HL7 or XML messages?

0 votes
497 views
asked Jun 23, 2015 by michael-h-5027 (14,350 points)
What are the different types of ACK?

1 Answer

0 votes

One ACK that can be used to handle a variety of messages is:

if (response === null || response.length === 0) {
   return false;
}
var isXML = true;
try {
   response = qie.parseXMLString(response);
} catch (err) {
   isXML = false;
}
var ackMessage;
if (isXML) {
   ackMessage = qie.parseHL7String(response.getNode("//" + response.getNode("//*[contains(text(), 'MSH|^~\\')]")));
} else {
   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');

 

 

Standard HL7 Ack:

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');

 

HL7 wrapped in xml ack (Would like to find a way to automate finding the HL7.

if (response === null || response.length === 0) {

return false;

}

response = qie.parseXMLString(response);

var ackMessage = qie.parseHL7String(response.getNode('//return'));

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');

 

HIE/PNR ack:

return response !== null && response.length > 0 && response.indexOf('RegistryErrorList') === -1;  

OR 

return StringUtils.containsIgnoreCase(response, 'ResponseStatusType:Success');

 

answered Jun 23, 2015 by michael-h-5027 (14,350 points)
edited Aug 23, 2019 by amanda-w-3695
...