HL7 (Health Level 7) messages exchange electronic data between contrasting healthcare systems. The HL7 standard plays a significant role in healthcare interoperability as it outlines a messaging standard to provide consistency for the transfer of health-related data. HL7 messages are presented in human-readable (ASCII) format and require an understanding of the message structure and organization to be interpreted easily.
Three main components define the HL7 standard message structure:
- Sub-composites or sub-fields
Each HL7 message contains one item or record of health-related data, such as laboratory records, patient identification, patient records, billing information, or patient visits. In this article, we discuss the contents of an HL7 message and observe how it is organized.
One or more segments make up an HL7 message and contain a specific category of healthcare data. Segments are grouped together in a defined sequence, with the name of each segment present in the message and specified by three characters that are present in the first field or composite. There are over 120 HL7 segment characters available in HL7 messages, including PID, MSH, PV1, and NK1.
The segment that contains information about the HL7 message itself is the MSH (Message header) segment. The MSH segment includes data about the receiver and sender of the message, the date and time it was sent, and the type of message. The MSH is specified in the first segment in every HL7 message
The other frequently used segment names contain the following information; PV1 (Patient visits) contains data about the patient’s clinic or hospital stay, referring doctor, assigned bed, etc., NK1 (next of kin) is contact information pertaining to the patient’s next of kin, and PID (patient information) the patient’s demographic information (name, surname, home address, etc.).
If a message needs to contain customized data that cannot be included in a segment, then it is a Z-segment, and all custom segments begin with Z.
HL7 Composites Or Fields
Segments can contain further information, as each segment in a message is comprised of one or more fields (or composites). Fields or composites are separated from each other by │ (a vertical pipe). Fields can contain other fields (sub-composites) or be primitive data such as a character number or string. Sub-composites are separated by ^ characters, with sub-sub-composites (fields within sub-composites) being separated by & characters. Sub-sub composites will only contain primitive data.
Delimiter (separator) characters are used to separate the components or fields of an HL7 message, for example, separate one sub composite (Name) from another (Surname) or separate composites (Addresses) within a segment.
The table below lists and characterizes the default delimiter characters used in HL7 messaging:
│ (vertical pipe)
Composite/fields delimiter – used to separate one composite from another.
0x0D – <cr> (Carriage return)
Marks the end of each segment entered.
Sub-Field delimiter – Used to generally separate sub-composites.
Separates any repeating fields (e.g., two addresses in patient information).
Sub-sub-field or composite delimiter- separates
/ (Backward slash)
Is an escape character.
HL7 has a system for ‘escaping’/replacing any user data that contains delimiter (separator) characters, with each delimiter character having a corresponding escape character. These escape sequences are case-sensitive and begin and end with the escape character.
The table below demonstrates the standard HL7 escape sequences for each character:
If seen within HL7 messages, it indicates
│ (Vertical pipe)
Field or composite separator (delimiter) character
Any repetition of a separator (delimiter) character
Component separator (delimiter) character
/ (Backward slash)
Sub-sub separator (delimiter) component or field
HL7 Message Types
HL7 message types are present in every message, and they describe and outline the purpose of the message being transferred. HL7 standard Message types are used in partnership with a trigger event and are defined by a three-character code. Trigger events are vital as they are real-world events such as a patient being discharged from the hospital and initiating the sending of the message (based on message type).
Examples of Trigger events:
- A01 (Admit a patient)
- A02 (Patient Transfer)
- A03 (Patient Discharge)
- A04 (Register)
- 001 (send an order)
- R01 (send order results)
Examples of the most frequently used HL7 message types:
- SIU- Scheduling information unsolicited
- MDM- Medical document management
- RDE- Pharmacy/treatment encoded order
- ACK- General Acknowledgement
- ADT- Admit, Discharge, Transfer
- DFT- Detailed financial transaction
- RAS- Pharmacy/treatment administration
- QRU- Observation result (unsolicited)
- ORM- Order (treatment/pharmacy)
- RGV- Pharmacy/treatment Give
- MFN- Master Files notification
- BAR- Add/Charge billing account
- QRY- Query, Original mode
When looking at an HL7 message, both the trigger event and the message type will be found in the MSH-9 field or component of the message. For example, if you see ADT-A02, the ADT is the message type Admit, Discharge, Transfer, and the A02 is the trigger event. According to the HL7 Standard, an ADT-A02 message is defined as a “patient transfer” message.
Example Of An HL7 Message
PID||0493575^^^2^ID1|45472||BROWN^JANE^^^^|BROWN^JANE^^^^|19480203|F||B|57 DOWN AVE^^HOWICK^OH^44123^USA||(216)542-7869|||F|NON|400003403~1129086|
PV1||O|168 ~219~C~PMA^^^^^^^^^||||277^JAMESDOE^CINDY^^^^|||||||||| ||2688684|||||||||||||||||||||||||199912271408||||||002376853
In this example of an HL7 message:
The highlighted row beginning with NK1 is one segment of this HL7 message. In the segment named PID, we can see each field within the segment separated by │. Fields are further separated into sub-fields by ^ characters, for example, the patient’s name and surname.
MSH, PID, NK1, PV1: These are the segment names (headers) seen in the first field or composite of the message. The first segment of the message is the mandatory MSH and tells us that an SMS was involved in the receiving and sending of data.
ADT^03 tells us that the message type and the target event ‘03’ is “Discharge a patient.”
Another feature of HL7 messaging is that it allows for the repetition of some components and fields, such as multiple contact numbers (for home and work) or next of kin.
The HL7 standard provides a universal messaging format ensuring that when triggered by events, the correct message and its corresponding healthcare data are transferred efficiently and smoothly between systems.