Getting to know Mirth

Categories: Javascript   mirth   Mirth   Technology

[Copied from my other blog, GoneSomewhere.com, since this is more relevant place to put it. I copied verbatim, so some of the information is a little old. I do things a little differently now, which I’ll write about sometime. This was originally written 8/2010.]

I work is data; moving it back and forth, parsing it into different format’s, and sticking it into different applications. When working with our partners, we do it the old fashioned way: FTP. It’s dependable and everyone can do it, and none of our data has been time-critical, so it can be batched to run in the middle of the night.

Over the last four years, we’ve talked about doing near-real time, if anyone ever came to us and wanted to do it. I built up our system to handle this, assuming if anyone did, we’d still be using FTP, just needing to pick up files more often. No problem, I say, my code can handle it. (And it does, since often times I get multiple files in at once from different customers, and get them all processed within a couple minutes.)

We finally had not one, but two partners agree to send us real-time data. Exciting, but with two issues to be resolved:

The data is HL7, a format we currently don’t work with. That means writing a parser for it. HL7 is sent over a TCP/IP connection. Er, something we’ve never thought about doing, so writing a port listener is also needed. I spent a few hours writing the port listener. It was a fun project…I entertained myself for a good 5 minutes using Telnet to test it, and watching my words get echoed back to me. (Yeah, simple minds…) But then it came time to write the HL7 parser, I was a bit at a loss. I’ve done tons of work with X12, so figured it would be about the same, so I started looking around to see what’s out there.

After spending some time looking an nHapi, and not being thrilled, I was just about to throw the towel in and start from scratch when I ran into a reference to Mirth Connect over at Coding Headache. I read all of his posts about it, and decided to give it a try. Mirth Corp has a nice set of videos going through what the product is, and it’s worth spending the hour watching them.

A simple summary: This is really cool! A day and a half later, and I’m ready to begin testing with our partner, with no coding required.

Installation is pretty straight forward, and took about 10 minutes:

Download Java. Download Mirth Connect. Run through the Mirth installation wizard, accepting all defaults. Go read the installation guide to see if I was supposed to do something prior to installation. :) The wiki that is set up has some examples and pointers to other blogs. I spent a while digging through them, before trying to get going.

Here’s some gotcha’s I ran into:

First off, you need sample data to get started. Get a copy of an HL7 transaction, you’ll need this for the transform. Once you paste it into the “Inbound Message Template” textbox, make sure all your segments are on separate lines. (You need a crlf as part of the segment terminator.)

You’ll also need a sample for your destination. In my case, this was simple, since I wanted to pump the data out as XML. I have a pretty generic schema, so just created a simple XML layout and pasted it in. You can also use a delimited file (csv or pipe delimited, for example.)

Once you have these, the mapping is pretty simple. Drag and drop from the orgin to the destination. I ran into issues where I was using too high of a level to map. I’d suggest always going from the lowest level. That is, if segment ABC1.3 is a name field, go lower to map ABC1.3.1. (If you look at the mapping, this makes sense.)

Also, if you’re going to manually update a map, be sure to specify the full path. So instead of writing out ABC[1.3], you need to write out ABC[1].[ABC1.3][ABC1.3.1] to get the right data. This is taken care of if you drag and drop.

Here’s the big issue I ran into, and I’m still working to get around it. If you have IIS running on the machine, the Mirth server will tell you the ports are already in use.

Changing to use non-default ports might fix this, I haven’t tried yet. Turning off IIS and restarting Mirth got rid of the errors. Also, I didn’t see that having the ports in use affected the program running, but right now, I’m only using a file listener, not the LLP listener. Once I switch over, I’ll post an update.

So far, I think this tool is going to be great. I’m starting to look into using it for some of the X12 tranactions I deal with, along with just moving files around our intranet. I’ll post more about it once I get into testing with our partners.

(One of our partners is using Biztalk, with I’ve looked using. We’re going to connect with them with a WCF service, but I may try doing a web service through Mirth with them, just to see how it goes.)

 

Written on August 5, 2012