[8/2012 Note: I moved this over to my other blog,, where it more appropriately fits, and will post any followup posts there.]

In my last post, I talked about starting to use Mirth to receive some HL7 records.  I still think it’s great.

We’re receiving a number of different record types,  ADT-03, 06, 08, etc., all of which we handle differently.  My original channel dumped everything to one place.  After a few records, I quickly realized that I needed to handle updates (differently).  Here’s what I did.

First, I got a list of what records I wanted to handle differently:  Message types A03, A08, A31.  Note that I capture the message type in the source transform.  For the incoming record, I receive everything, and in the source transform, pull the fields I need into local variables. (One of the examples in the Mirth documentation shows doing it this way, and it does make it easier down the line.)

Then, in my destinations, I “cloned” the current destination, gave it a new name, and changed the directory to drop the file. (It’s a file writer destination.)

Then, I added a Filter to the destination.  Go into Filters, and add new.  For this, I made it a simple Rule Builder, and said to “Accept” records if equal.  And in the values, I added the list of my record types.   (Note these are strings, so in the values, enclose them in single quotes.)  Save, and it’s done.

Back in my original channel, I added a similar filter to only accept the record types of A01 and A04. This will prevent the other records from processing.

The other issue I had to deal with was updates for old records coming in.  After talking to the business owner, we decided that anything older than 1/1/2010 we could safely ignore.

So, I added another filter to the update destination.  But this time, I couldn’t use the Rule Builder, so needed some JavaScript.

Add a new filter.  Doubleclick on the “Type” in the filter (on the right side), and select JavaScript.

Then, write out the script.

//Variable from the source transform var admitDate = $('patientVisit_admitDateOrTime_value'); //Reject admit dates prior to 1/1/2010 if (parseInt(admitDate)> 20100101000000) { return true; } else { return false; }

It’s pretty straight forward.  Treat the date (with a timestamp on it) as a number, and compare to a our cutoff date.

Tada.  All good now.

(Note:  Thanks to the Mirth forums and the people there…searching the archives has been invaluable.)

Written on