Simple date filter in Mirth Connect

Categories: mirth   Mirth   Technology

[Note: I moved this post over from my other blog, since this is a more appropriate place for it. It was originally written in 9/2010, and I do things a little differently now. I copied this verbatim, so the information is the same. I’ll follow up with more information here instead of at the other blog.]

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.It’s pretty straight forward.  Treat the date (with a timestamp on it) as a number, and compare to a our cutoff date.

//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; }

Tada.  All good now.

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

Written on August 5, 2012