Mirth Connect is an open source application used for healthcare data integrations, specifically designed for HL7 interfaces. It is widely used for transfer of health data between two parties in an order to results cycle. But what happens when you need to transfer data to another party who isn’t using an HL7 interface? Limiting your inbound/outbound capabilities to only the HL7 format may prevent adding new customers. But, adding a second interface/solution may not be worth the cost of adding the new customer. The need to invest in a second solution is resolved by the different Connector Types available within Mirth Connect.
In this post, I am going to show you an example of how to interface HL7 data to a Web Service. We implemented this back in 2012 for a client. Our client had an existing HL7 interface and was receiving HL7 orders, processing the claim, and sending back HL7 results. They had a potential customer also looking for an electronic data transfer. However, they were not using HL7 formatted data. The potential customer used an application that received data via a secured SOAP request. Because this was a single client, it was unlikely that building a separate interface specifically for the integration would be the best business decision. So, we explored the possibility of using existing functionality (Mirth Connect) to send data to this web service.
Check out our example below, and find more information on Mirth Connect here: http://www.mirthcorp.com/products/mirth-connect
// open a connection to the Web Service
var url = new java.net.URL("https://testinterface.com/Document.asmx");
var conn = url.openConnection();
// set the connection Timeout
var connectTimeout = 30000;
Here we are returning the XML from our Source tab under the Transformers. This isn’t the only way to do it, but this worked best for us and our current solution.
var messageString = messageObject.getEncodedData();
You could also do something like this, where you build out the Request XML and use Transformer variables that you include as XML Node Text
var messageString = "<SOAP:Body><Patient>" + messagePatient + "</Patient><MRN>" + messageMRN + "</MRN></SOAP:Body>"
conn.setRequestProperty("Content-Type", "text/xml; charset=utf-8");
// Write our XML data to the Web Service URL
var outStream = conn.getOutputStream();
var objectStream = new java.io.OutputStreamWriter(outStream);
var inStream = new java.io.BufferedReader(new java.io.InputStreamReader(conn.getInputStream()));