web stats
Processing Response Objects in the Response Transformer for custom Acknowledgment - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Thread Tools Display Modes
Old 01-08-2014, 08:25 AM
amith amith is offline
Mirth Newb
Join Date: Aug 2010
Location: London, UK
Posts: 7
amith is on a distinguished road
Default Processing Response Objects in the Response Transformer for custom Acknowledgment

I'm using Mirth I think Mirth is AWESOME!!!!

I currently have a 2 working channels on Mirth

Channel 1) TEST_ADT_HL7_To_XML
Channel 2) TEST_XML_Sender

Channel 1 - Receives an HL7 message, converts it to a custom XML and send it to Channel 2.
Channel 2 - Receives an XML send to a HTTP listener.
This works with an XML Response acknowledgemtn from the HTTP listener.
The response is in an XML format.
HTML Code:
	<Message>Payload does not contain a value</Message>
I am able to process it all the way to the sending application. Until I turn On "Persistent queues". Once this is ON, the response will always be queued from the destination as expected. Using the "Send response to" doesn't work as the response is in XML format.

I have moved these channels to Mirth 3.0 to make use on the "Response Transformer".

In the "Response Transformer" I have the following code:
var ResponseMessage = response.getMessage()
logger.info("ResponseMessage: "+ ResponseMessage.toString());

var ResponseXML = new XML(ResponseMessage.toString());
logger.info("Response XML=" + ResponseXML.toString());

responseMap.put('ACK', ResponseFactory.getSentResponse(ResponseXML));
In the Source connector, Under "Response Settings->Response", I selected "ACK"

I am able to see the message content of response object in the logs. But the response does not make it to channel 1 (TEST_ADT_HL7_To_XML).

When I apply
return "My Message response";
in the "Post processor script", I get a response. But I'm unable to access the response object("ACK") that the "Response Transformer" created.

I've read every 'response' thread on this forum. Tried Mirth version 2.x and now version 3. But I'm not getting any closer to a solution.

How can I process the Response Object correctly so that Channel 1 receives the XML response?

Many Thanks in Advance for your help.
Attached Files
File Type: xml TEST_ADT_HL7_To_XML.xml (22.5 KB, 116 views)
File Type: xml TEST_XML_Sender.xml (12.6 KB, 72 views)

Last edited by amith; 01-08-2014 at 09:19 AM.
Reply With Quote
Old 01-08-2014, 04:02 PM
narupley's Avatar
narupley narupley is online now
Mirth Employee
Join Date: Oct 2010
Posts: 7,126
narupley is on a distinguished road

If your destination has queuing enabled, then it does not make sense to respond from that destination (or from a custom variable created by the destination's response transformer). The whole point of destination queuing is to drop a receiving message in a queue and move on. There would be nothing to respond from, because your destination hasn't even sent the message yet.

There are some hacky ways around it, but you should probably rethink your message/channel workflow instead. Generally this is done by moving the point of queuing up higher in the chain. So if Channel 1 sends to Channel 2 which sends to some outbound system, and Channel 1 should receive the response from the outbound system, then Channel 1 should be the one with destination queuing enabled, not Channel 2. Of course, this means that the originating system that sent to Channel 1 in the first place would not be able to receive that response.
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.

- How do I foo?
- You just bar.
Reply With Quote
Old 01-09-2014, 08:09 AM
amith amith is offline
Mirth Newb
Join Date: Aug 2010
Location: London, UK
Posts: 7
amith is on a distinguished road

Thank you for your reply, OH Legendary "narupley". You're headed for 3000 posts...WOW!! You saved my bacon countless times.

I need the queue to be on the HTTP listener end, just incase it goes DOWN. The message will then queue instead of erroring and will be processed when UP again.

I am going to use another channel to process the response by using the "Send response to". I will email the error response to someone.
Reply With Quote
Old 01-28-2014, 08:25 AM
amith amith is offline
Mirth Newb
Join Date: Aug 2010
Location: London, UK
Posts: 7
amith is on a distinguished road
Default custom Acknowledgment with queues

I've found a hacky way around this.
My Solution with Mirth v3.01: On the Source channel transformer(TEST_ADT_HL7_To_XML):

On the Response End channel Response Transformer (TEST_XML_Sender) - Update the response flag.

if (response.getMessage() != '') 
    var ResponseMessage = response.getMessage()
    var ResponseXML = new XML(ResponseMessage.toString());
}else{//wait if queued}
On the Response End channel Post-Processor(TEST_XML_Sender) - Set the Response setting to "Post Processor" Write a While loop. (use a timeoout if you want don't want to wait forever)

var ADTResponseReadyFlag = globalMap.get("ADTRESPONSEREADYFLAG");

if(debug)logger.info("Start Response Wait")
while(ADTResponseReadyFlag == "false")
  ADTResponseReadyFlag = globalMap.get("ADTRESPONSEREADYFLAG");
if(debug) logger.info("End Response Wait")
return globalMap.get("ADTRESPONSE");

Last edited by amith; 01-28-2014 at 08:27 AM. Reason: code blocking
Reply With Quote

acknowledgement, mirth 3.0, queue, response, xml

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -8. The time now is 04:49 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Mirth Corporation