web stats
Mirth Community - View Single Post - Message validation
View Single Post
  #6  
Old 02-21-2012, 05:34 PM
Linh Linh is offline
Mirth Newb
 
Join Date: Feb 2012
Posts: 6
Linh is on a distinguished road
Default

Hi narupley,

This is my setup. Hope it will helps other people and if you see any problem, please let me know. I really appreciate your and other people's feedback.

I put your ACK setAck() function in the Channels' Code Template to be able to reuse it. The function buildAckMsg will have this statement "return new Response(responseStatus,SerializerFactory.getHL7Se rializer().fromXML(ack));" at the end.

My set up has 1) HL7 Receiver Channel, which will forward to the next Channel for further processing.

1) HL7 Receiver Channel:
Source:
LLP Listener
Send ACK: Respond from "ResponseMsg" (this is a variable which will be set in Channel's postprocessor)

Destination:
Connector type: Channel Writer, write to Channel "My Next Channel")
Wait for Channel Response: Yes

Transformer: javascript: (to save a reference to the message in postprocessor)
channelMap.put('rawMsg', messageObject.getRawData());
channelMap.put('xmlMsg', msg);


Postprocessor script:
// This script executes once after a message has been processed

var responseFromChannel = responseMap.get('My Next Channel').toString();

var xmlMsg = channelMap.get('xmlMsg');

if(responseFromChannel.indexOf('Message has been filtered') >= 0)
{
var ackMsg = buildAckMsg(xmlMsg, 'AR', "Message Rejected");
responseMap.put('ResponseMsg', ackMsg);
}
else if (responseFromChannel.indexOf('ERROR') >= 0 || responseFromChannel.indexOf('FAILURE') >= 0)
{
var ackMsg = buildAckMsg(xmlMsg, 'AE', "An Error Occurred Processing Message");
responseMap.put('ResponseMsg', ackMsg);
}
else
{
var ackMsg = buildAckMsg(xmlMsg, 'AA', "Message received and processed successfully");
responseMap.put('ResponseMsg', ackMsg);
}

return;

2) My Next Channel:
Source:
Channel Reader

Destinations:
Has a Filter that has my filtering logic.



Thanks narupley, you have saved my day.

Linh
Reply With Quote