web stats
How we made Mirth work with HL7 v3 WCF web service - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 03-05-2012, 12:47 PM
janbrogger janbrogger is offline
Mirth Newb
 
Join Date: Feb 2012
Posts: 6
janbrogger is on a distinguished road
Default How we made Mirth work with HL7 v3 WCF web service

This is in response to a previous thread that we posted. I thought I'd write a little on what worked, and how we got there.

The problem
  1. The web services gave us a "400: bad request" when we tried to send it a request that we thought was meaningful.

The solution
  1. Install Mirth
  2. Download the WSDL files of the web service (e.g. EncounterManager) and put them under Mirth Server\public_html\EncounterManager so that Mirth can host them.
  3. In the local WSDL file above, modify it and make sure that the SOAP action at the end points to the actual web service:
    Quote:
    <soap:address location="http://your-server/HL7Connector/GetDemographicsService30/"/>
  4. Restart Mirth if it is already started.
  5. In Mirth Connect, create a new channel, for example "Sender"
  6. Just for testing, make the source of this channel a file reader that reads something in (e.g. a patient identifier from a text file). For example, make it poll C:\MirthTesting\unread. Tell Mirth to move the file after it is finished to C:\MirthTesting\read
  7. On the summary page of the new transformer, click "Set data types". Set it to Source connector inbound = Delimited text, Source connector outbound=HL7, Destination 1 outbound = Delimited text. This is just for testing, you can do fancy HL7 stuff later.
  8. In the source, click on "Edit transformer".
  9. Click "Add new step", enter the new variable name "patientIdWanted" and enter for the mapping, "messageObject.getRawData()". This makes Mirth read the content of whatever text files you put into the "Unread" directory and put into a variable that you can use later (into the channel map)
  10. Make the destination of your new channel into a Web service sender. Enter the URL of the local WSDL (e.g. http://localhost:8080/EncounterManag...Fulfiller.wsdl)
  11. Click Get operations, then Generate Envelope.
  12. The SOAP envelope is very large and full of HL7 non-sense (to me). Replace it with a simple example that works, and remove all the unncessary HL7 cruft. Your provider should give you a working example.
  13. You now need to put the variables you read in from the file reader, into the SOAP envelope. Your SOAP envelope should contain a "payload", e.g. the patient identifier somewhere. For the GetDemographics query, it looked like this (portion of it). Note that the ${patientIdWanted} is where Mirth replaces the value in the template, from whatever we put into the channel map from the text file above.
    Quote:
    <queryByParameter>
    <queryId extension="080527104501_37" root="2.16.578.1.34.1.222.12"/>
    <statusCode code="new"/>
    <parameterList>
    <patientIdentifier>
    <value root="2.16.578.1.35.1000.1" extension="${patientIdWanted}"/>
    <semanticsText>Patient.id</semanticsText>
    </patientIdentifier>
    </parameterList>
    </queryByParameter>
  14. Now save this channel.
  15. Create a new channel to receive what the web service in the previous step sent you. Call it "Receiver"
  16. In the new channel, set the data types all to "Delimited text". Again, just for testing.
  17. Set the source of the "Receiver" channel to "Channel reader"
  18. Set the destination of the new channel to "File writer". Enter a directory and a file name, e.g. C:\MirthTesting\read\webservice-response.txt. In the template, enter "${message.rawData}" to see everything that Mirth has.
  19. Go back to the first channel, select the destination that is web service sender, enter the second channel as the destination of the response.
  20. Save changes, validate connector, redeploy all channels.
  21. Now create a text file with a patient identifier in it, and put it into C:\MirthTesting\unread
  22. Mirth will read this file (then move it to the "read" directory). Your first channel will get the text file in, move the content into the channel map ${patientIdWanted}. Your web service will then get the SOAP envelope. The response will be sent to the second file, and dumped as plain text.
Stuff that was helpful
  • Realizing that Mirth is a nuclear sub: powerful and mysterious. No manual!
  • Being somewhat proficient in C# and Java
  • Having examples of HL7 messages that make sense
  • Using Visual Studio to generate a pure C# client to verify that we could read from the web service with plain C#. (We used Mirth to host the WSDL files, but you could use IIS)
  • Using Eclipse to generate a Java client to verify that we could read from the web service with Java. We used the SOAPUI (the same as Mirth uses) with Eclipse Indigo EE edition (from the command line using wsimport.bat)
  • Downloading Mirth from source and running it from Eclipse.
  • Turning on HTTP dumping (in Eclipse). Enter under "Run config", VM arguments:
    Code:
     -Dcom.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.dump=true
    . This lets you see exactly what Mirth (or your Java client) sends to the web service.
  • Add a pre-processing script to your sender channel to see what Mirth actually does:
    Code:
    FileUtil.write('C:/MirthTesting/read/sender_preprocessmessage_in.txt', false, message);return message;
  • Add a post-procesing script to your sender channel to see what Mirth does:
    Code:
    FileUtil.write('C:/MirthTesting/read/dipssender_postprocessmessage.txt', false, message);
    return;

To actually make this work, we had to make one change to the Mirth source code. With JDK1.7 that we used, Mirth didn't actually send the SOAP action. In Server/.../WebServiceMessageDispatcher.Java line 137, we had to add:
Code:
dispatch.getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, true);
(taken from this blog post)
Reply With Quote
  #2  
Old 03-05-2012, 12:55 PM
jacobb jacobb is offline
Mirth Employee
 
Join Date: Aug 2006
Location: Irvine, CA
Posts: 1,218
jacobb is an unknown quantity at this point
Default

Thanks for the writeup! I'm curious what your thoughts are on including your source code modification to Mirth Connect for the general case. If you could make an argument for it in a JIRA issue, that would be very useful.
__________________
Jacob Brauer
Director, Software Development
NextGen Healthcare

Reply With Quote
  #3  
Old 03-05-2012, 01:10 PM
janbrogger janbrogger is offline
Mirth Newb
 
Join Date: Feb 2012
Posts: 6
janbrogger is on a distinguished road
Default

Quote:
Originally Posted by jacobb View Post
Thanks for the writeup! I'm curious what your thoughts are on including your source code modification to Mirth Connect for the general case. If you could make an argument for it in a JIRA issue, that would be very useful.
Mindreader! I was writing it up in JIRA (#2109) as you wrote your reply. Patch submitted. I'm not really a Java guy so bear with me. It is just one line.
Reply With Quote
  #4  
Old 03-05-2012, 01:18 PM
jacobb jacobb is offline
Mirth Employee
 
Join Date: Aug 2006
Location: Irvine, CA
Posts: 1,218
jacobb is an unknown quantity at this point
Default

Quote:
Originally Posted by janbrogger View Post
Mindreader! I was writing it up in JIRA (#2109) as you wrote your reply. Patch submitted. I'm not really a Java guy so bear with me. It is just one line.
Thanks! I'm just not sure yet if this change could negatively affect anyone. We will definitely consider it for the next release.
__________________
Jacob Brauer
Director, Software Development
NextGen Healthcare

Reply With Quote
  #5  
Old 07-18-2012, 05:03 AM
nikhilb nikhilb is offline
Mirth Newb
 
Join Date: May 2012
Posts: 19
nikhilb is on a distinguished road
Default

hi,
Where I will get this WebServiceMessageDispatcher.java file
My root dir path for mirth is C:\Program Files\Mirth
I am not able to find this file.
Please let me know where i can find this (full path)

Thanks in advance,
Nikhil.
Reply With Quote
  #6  
Old 07-18-2012, 05:13 AM
wello007 wello007 is offline
OBX.3 Kenobi
 
Join Date: Dec 2007
Posts: 160
wello007 is an unknown quantity at this point
Default

This is part of the Server source code and not of a binary installation
Reply With Quote
Reply

Tags
bad request, hl7v3, wcf

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 12:06 AM.


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