Introduction to reading HL7v2

Introduction to reading HL7v2

What do I need to know to get started?

HL7v2 is a set of standards set out to allow healthcare systems to send each other updates on patient-related information. If you’re just starting out in healthcare IT and want a quick primer on these standards please read on.

Reading the message

HL7v2 messages are a collection of lines, each with their own standards. Each line, referred to as a segment, contains a collection of information related to one aspect of a patient’s information. Segments are made up of fields, which each contain a particular data point, which may need to be further broken down into repetitions, components, and sub-components. Generally, fields are separated by the pipe character (|), repetitions by a tilde (~), components by a caret (^) and sub-components by an ampersand (&).

Let’s go through an example to see how all this comes together.

Below is the Patient Identification (PID) segment of an HL7v2 message for a patient named "Mickey M Mouse" with multiple EMR medical record numbers, a home address, phone number, and other demographic details:

PID|1||13579^BobsOrtho~2468~StevesHospital||Mouse^Mickey^M||19271118|M|||The Magic Kingdom^1675 North Buena Vista Drive^Lake Buena Vista^FL^32830||8777642539

Breakdown of example:

Field NameValueDescription
Segment Header (unofficial name)PIDIndicates the segment is following the Patient Identification segment standard. The MSH segment would tell us which version of the Patient Identification standard to use. In this case we’ll assume version 2.3
PID-11This indicates that we are referring to the first patient listed in the message. Generally you won't find a second.
PID-2This isn't filled out in our example, but could contain a single patient ID/medical record number (MRN)
PID-313579^BobsOrtho~2468^StevesHospitalThis PID-3 value uses the repetition indicator (~), meaning that there are two PID-3s here, 13579^BobsOrtho and 2468^StevesHospital. These are further broken down by the component separator (^) to show that 13579 is the MRN for the organization BobsOrtho and 2468 is the identifier for StevesHospital
PID-4This is blank in our example but could contain an alternate ID to what we saw in PID-2
PID-5Mouse^Mickey^MPID-5 always contains the patient's name. In this case the name is further broken down to the patient's last name, first name, and middle initial using the component separator (^).

Each component is identified as a sub-item of the overall field by it's position.

In this example:
PID-5.1 is "Mouse"
PID-5.2 is "Mickey"
PID-5.3 is "M"
PID-6This is blank in our example but is where you may put the patient's mother's maiden name
PID-72019271118The patient's date of birth. Time may also be added if known using numbers only but otherwise following the ISO 8601 basic standard of yyyyMMddHHmmss.
PID-8MPatient administrative sex.
PID-9Patient Alias
PID-10Patient Race, if known
PID-11The Magic Kingdom^1675 North Buena Vista Drive^Lake Buena Vista^FL^32830Patient Address

In this example:
PID-11.1: Address line 1
PID-11.2: Address line 2
PID-11.3: City
PID-11.4: State
PID-11.5: Postal Code
PID-12Blank in this example but could contain a County Code
PID-138777642539Patient phone number

You'll need some kind of reference to know what the formatting is for each segment and the versions of that segment. I find's HL7 Definition site to be an invaluable resource in looking up these field definitions.

PLEASE NOTE: The MSH segment uses whatever character comes after MSH as MSH-1, as the standard needed a way to indicate which character is the field separator. Because of this many people get confused over MSH field names and reference them incorrectly.

Message Types

Because HL7v2 messages are triggered by events in an electronic medical record system, there is a list of events which may generate a message. Which event was the trigger is listed in MSH-9 (remember from the end of the last section that MSH numbering appears to be off due to MSH-1 being the first pipe character). A list of Message Types (MSH-9.1) can be found here, while a list of triggering events may be found here.

Please note that not all message types support all trigger events.

Common message types you'll encounter are:

Message TypeDescription
ADTAdmit/Discharge/Transfer messages

Generally used for sharing patient demographic data
MDMMedical Document Management

Documents from an EMR, usually transcribed notes or reports
ORMOrder Message

Information about a new order to a lab, radiology department, etc.
ORUOder Results Unsolicited

Results for a lab or test
SIUScheduling Information Unsolicited

Information about patient scheduling


There's a TON more to HL7, such as determining which segments and fields are optional, what the proper order of segments are for a given message type, the differences between versions of HL7v2, custom segments for data outside the standard (those are called "z-segments" if you're curious), but those are beyond the scope of this primer on reading HL7v2 messages.