R – Mirth: sharing the SOAP response between Destinations in the same channel

mirth

Consider a scenario where a Mirth channel has one or more Destinations. In this scenario, there are 4 Destinations.

The channel's Source Type is LLP Listener with incoming datatype as HL7 v2.x.

The channel's Destinations are as follows:

  1. File Writer – Write the message to disk. Really this is just for development purposes.
  2. Javascript Writer – Write the message to DB. Get a primary key. Put that key on the ChannelMap for future Destinations.
  3. SOAP Sender – Call a web service and receive a response. The call runs smoothly.
  4. Javascript Writer – Take the response from the SOAP Sender above, and write it to a DB, associating the answer with the primary key from the 1st Destination.

One challenge is getting the SOAP response from the SOAP Sender Destination, and saving it somewhere for the 4th destination. The SOAP Sender allows you to send a SOAP response to another channel, but I need it in the next destination. I have to be able to receive it in the same channel.

Question:
How can I have the XML SOAP results from the 3rd Destination be saved/sent to the 4th Destination?

Best Answer

I assume your channels are synchronized

Assume your step 3 SOAP sender destination is called SOAPDestination, then in step 4, you can do this:

var destination = responseMap.get('SOAPDestination');

var responseMessage = destination.getMessage();

// open db connection

// write responseMessage along with the primary key you stored back in step 2

// close db connection

Related Topic