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