Deerwalk Blog

Mirth Connect Quick Start

Posted by Nishant Karki on January 05, 2011

HL7 can be said as the standard that has been set for data interchange in Healthcare systems. Mirth is an open source cross platform HL7 interface engine that enables bidirectional message sending. It eases the process of generating and sending messages over multiple transports. Mirth is distributed under the MPL 1 license. At Deerwalk we have had to communicate with many HL7 systems and have found Mirth to be a good framework for interfacing with HL7. We have noticed that there is not a lot of documentation on getting a Mirth solution up and running so we have built a quick start guide to using Mirth.


Setting up Mirth

First off we need to download Mirth and install on our development machine. Mirth connect setup can be easily acquired from the download section of their official website ( There are installers for Windows, Linux and Mac OS X. In this quick start guide we will be using the Windows version. Once Mirth is installed on your system it will need to be configured through the Mirth Connect Server Manager. To do this from the Programs->Mirth launch the ‘Mirth Connect Server Manager’.

By default Mirth uses ports 8080, 8443 and 1099 and these should work fine unless they conflict with other services on the existing system, in which case they can be changed in the server tab. The database tab determines which database Mirth uses for its internal purposes. Mirth provides support for Derby, Postgres, MySql, oracle and SQL Server. Obviously the choice in database can affect the overall performance of Mirth in this walk through we have chosen to use SQL Server.


Data transformation using Mirth begins with creating a channel. A channel takes in raw data and outputs the transformed message. Our projects normally involve reading data from a SQL Server and generating a PID segment of an HL7 message. In order to do this a channel has to be setup and has the following parts to be configured:

i. Summary:
This section contains the basic configurations for a channel such as channel name, incoming data format, initial state of channel and few others that are not too important here. The Incoming data field is active only for source of listener types such as LLP listeners.
ii. Source:
This tab allows the selection of a data source for the channel. There are various sources to choose from such as file reader, socket listener, database reader and many more. As mentioned we generally are reading from a SQL Server source and in the figure below that data source has been selected. The typical JDBC connection url is used to specify the server, port and database. In addition there are fields for the username and password for the SQL Server connection. There are two options for polling data from the data source, either a fixed interval or a fixed time of day. In this case the interval type polling has been selected with an interval of every 5000 ms. Here, a simple SQL query is used to used to specify the data to be pulled from the database but if acquiring the data required more complex process, JavaScript could be used.
The next step is to map the acquired data to the internal variables in Mirth. These variables are used in the destination to generate messages. To get to the Source Transformer, while selecting the Source tab, click on the Edit Transformer within the Channel Tasks. In the ‘Message Trees’ tab of ‘Source Transformer’ window the result set are shown as a list. To map it to a variable right click on any element of the result set and then click on map to variable. Be sure to map all the elements of the result set.
iii. Destination:
In the destination tab there already is a destination named ‘destination1’ by default. Set the options for the destination as shown in the figure below. For ‘Template’ drag the ‘Encoded Data’ from ‘Destination Mappings’ to ‘Template’. We have set the connector type to File writer and set the destination file as ‘D:\output.txt’, but Mirth can support various other destination types such as Database, Email, Http, Ftp ,LLP. The ‘${message.encodedData}’ is the representation of the output from the outbound template within the Destination Transformer.
Once the outbound template is set, add a new step and change the type to ‘Message Builder’. The mapping is then done as shown in the picture below. This walkthrough will not discuss the how to determine the position of segment in an HL7 message. In this example however the 1st subcomponent of the 5th component of PID is the patient last name and it is referenced as tmp[‘PID’][‘PID.5’][‘PID.5.1’] where tmp is the variable representing the outbound message.

Hope this helps you get started with Mirth. It would be great to know that we helped somebody escape the unnecessary hardships that we had to go through just to learn the basics of Mirth.

Subscribe to Blog Updates

Posts by Topic

see all

Recent Posts