NextGen Knowledge Center

Common Scenarios

Re-queue a message if the HL7 ACK has an AE code

if (msg['MSA']['MSA.1']['MSA.1.1'].toString() == 'AE') {
    responseStatus = QUEUED;
    responseStatusMessage = 'Application Error NACK received.';
    responseErrorMessage = msg['MSA']['MSA.3']['MSA.3.1'].toString();

Force a queuing message to error if the number of send attempts exceeds some threshold

if (responseStatus == QUEUED && connectorMessage.getSendAttempts() >= 5) {
    responseStatus = ERROR;
    responseStatusMessage = 'Maximum send attempts exceeded.';
}

Route the response data to a downstream channel

if (responseStatus == SENT) {
    router.routeMessageByChannelId('channel ID here', response.getMessage());
}