Category Archives: Mirth

Understanding HL7 Messages

A project building a string of medical sites brought me to where I needed to understand the medical encoding language of HL7. This is a brief tutorial on understanding an example HL7 message:

An HL7 message consists of one or more segments. A carriage return character (r, or 0D in hexadecimal) separates one segment from another. Each segment is presented on a separate line(see below example).

An HL7 segment has one or more composites (fields). A pipe (|) character separates one composite from another.

When a composite contains other composites, known as sub-composites (sub-fields), they are usually separated by (^) characters.

Example HL7 message:


PID||0493575^^^2^ID 1|454721||DOE^JOHN^^^^|DOE^JOHN^^^^|19480203|M||B|254 MYSTREET AVE^^MYTOWN^OH^44123^USA||(216)123-4567|||M|NON|400003403~1129086|


PV1||O|168 ~219~C~PMA^^^^^^^^^||||277^ALLEN MYLASTNAME^BONNIE^^^^|||||||||| ||2688684|||||||||||||||||||||||||199912271408||||||002376853

Message details:

In the above HL7 message, I separated each line with an empty line between them in case your browser displays them in a broken fashion. It is important to realize that each of the four blocks of text in the message is intended to be on one line and are normally separated by a r or 0D character code as explained above.



Installing Mirth on Linux Amazon EC2

For a recent health care information system integration job, I was required to learn how to use HL7 and the MIRTH integration engine. Here is how I learned to install MIRTH on an Amazon cloud server.

NOTE: some of the information in this tutorial was hard to come by. Mirth doesn't offer high level support unless you purchase it for $5000 and up depending on the type of membership you acquire, so I did a lot of trial and error to figure this out and hope it helps others in a similar situation. -Ian L. author

Set up an appropriate server

First thing you need to do is make sure your server instance can support Mirth. The main concern here is that it has JRE and proper ports. Check your instance for JRE by typing the following at the command prompt for your server:

java -version

and make sure it returns version 1.6 or better.

Next, checĀ  your security group from the Amazon EC2 console and make sure you allow the following ports:

SSH tcp 22 22
HTTPS tcp 443 443
HTTP tcp 80 80
Custom tcp 8080 8080
Custom tcp 8443 8443

If you don't have a port such as 8443, then add it or start a new instance with a new security group and manually add the proper ports indicated above.

Installing MIRTH

Installing MIRTH is simple using wget. Simply use the following commands

First login as root or use sudo in front of the command like in the following example:

It took a few minutes for it to download in my case. After it is done, use the following command to extract it:

sudo tar xvfz mirthconnect-

It will not work if you are not logged in as root or use the sudo command in front of the tar command as in the above example.

Starting Mirth Connect

Here I got a little chung up because the tutorial I read said to change to the directory like this"

cd Mirth Connect

weill that didn't work because Linux doesn't like spaces in directory names, so you have to escape it with a backslash like this:

cd Mirth/ Connect

Once you are in the Mirth Connect directory, run the following start command:

./mirthconnect_service start

Accessing Mirth from a Browser

The next thing you should do is open the GUI in your browser using your server's IP or domain name followed by a semi-colon and the port no. The default port is 8080 so I used:

replace the IP address with your own in the above command.