Parse SOAP response & send HL7V2 ADT

This channel will explain how to parse the SOAP response which will be received from the webservice endpoint which will be a SOAP XML.

Mirth will fetch this XML, parse the SOAP data and convert it into HL7V2 ADT message and send it to the sender.

Mirth : 3.2.1.7650

Have the below HL7v2 available in the POSTMAN of your system. This message will be received by the Mirth as HTTP listener.

MSH|^~\&|TEST|DH|ADT|DH|201301011226||ADT^A08|HG201001|P|2.3|EVN|A08|201301011223||PID|||MRN04160^7^M12||TEST^JACK^R^||19900903|M||2106-3|No5 AskVAsk Street^^Beta^WH^11136-1020|US|(414)222-9595^^^AxeData@test.com|(414)123-4597|EN|S||MRN27485987^2^M10|986410430|978974^NC||HIN1|Medicare|CD430677||1|||||||IN2|Medicaid|B025546788||1|||||||PD1|02997173|Data|Data2^20161011^20161111^Enrolled^Other||||02693680|Y|Enrolled|||

We will transform this data to the webservice specified format (XML), and the webservice will send a response like the below:

<S:Envelope xmlns:S=”http://test.xmlsoap.org/soap/envelope/&#8221; xmlns:SOAP-ENV=”http://test.xmlsoap.org/soap/envelope/”&gt;
<SOAP-ENV:Header/>
<S:Body>
<ns1:addInformation xmlns:ns2=”http://Getdatawebservice/”&gt;
<send>
<MrnNumber>MRN5023150</MrnNumber>
<isError>True</isError>
<ErrorReason>Patient deceased</ErrorReason>
</send>
</ns1:addInformation>
</S:Body>
</S:Envelope>

Now, we wanted to take the error reason and send it to the sender as HL7V2 response. To do that, go the the Edit Response tab of this destination, and type as below:

var updateMsg= new XML (msg).toString().replace(/:/g,”)
var newMsg= new XML (updateMsg);

var checkError = newmsg[‘SBody’][‘ns1addInformation ‘][‘send’][‘isError’].toString();
if(checkError==”false”)
{
var errorMessage = “Message Sent Successfully”;
channelMap.put(“errorMessage”,errorMessage);
}else{
var errorMessage = newmsg[‘SBody’][‘ns1addInformation ‘][‘send’][‘ErrorReason’].toString();
channelMap.put(“errorMessage”,errorMessage);
}

Now create another destination and create a MSA segment in the outbound template as follows:

MSA|||||||

Inside the transformer do the following:

tmp[‘MSH’] = $(‘MSH’);
tmp[‘MSA’][‘MSA.2’][‘MSA.2.1’] = $(‘errorMessage’);

Make the destination as Javascript Writer and copy the following code in the code area part

return connectorMessage.getEncodedData();

Deploy the channel, and send the message from the postman and you will get the response like this

MSH|^~\&|TEST|DH|ADT|DH|20141125094031||ADT^A08|c6e86566-41c3-468c-8b35-0573cee6f2e0|T|2.6
MSA||Patient deceased|||

 

Happy Integrating !!!!!!!!!!!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: