HL7 Inspector Healthcare Interoperability Toolkit
Visual Guide

Learn HL7 v2 the visual way

HL7 v2 is the language hospitals use to talk to each other. Here's how to read it — one picture at a time.

1987v2.0 1990v2.1 1994v2.2 1999v2.3 2003+ v2.5 → 2.9 Today v2.5.1

HL7 v2 has been the backbone of hospital messaging since 1987. Version 2.5.1 is the most widely deployed today.

01

Anatomy of an HL7 message

A message is not a blob of text. It's a carefully structured document with three levels of nesting: segments → fields → components.

PID|1|2|123456^^^MRN^MR||DOE^JOHN^A||19800115|M
Segment
3-letter code: PID = Patient Identification
Field
Separated by |. Position 1, 2, 3, ...
Component
Separated by ^. Sub-parts of a field.
1

Segment

One line = one segment. Starts with a 3-letter code (MSH, PID, PV1...). Each carries a specific kind of information.

2

Field

Parts of a segment, separated by the pipe |. Each position has a fixed meaning (PID-5 is always the patient name).

3

Component

Parts of a field, separated by ^. Patient name DOE^JOHN^A = Family DOE, Given JOHN, Middle A.

4

Repetition

Repeating values inside a field, separated by ~. Multiple phone numbers: 555-1111~555-2222.

02

The main segment types

Every HL7 message starts with MSH. Other segments appear based on the message type. Click each card to see a real example.

03

The five delimiters

HL7 uses five special characters to break up a message. They're declared in MSH-1 and MSH-2 — so they can technically change per message!

|
Field Separator
Separates fields. Declared in MSH-1.
PID|1|123|DOE
^
Component Separator
Separates parts of a field. Declared in MSH-2.1.
DOE^JOHN^A
~
Repetition Separator
Separates repeated values. Declared in MSH-2.2.
555-1111~555-2222
\
Escape Character
Marks escaped sequences. Declared in MSH-2.3.
\F\ = literal pipe
&
Subcomponent Separator
Separates parts of a component. Declared in MSH-2.4.
AUTH&MRN
Why does it matter? Most tools assume the standard delimiters. A truly robust parser reads them from MSH — that's what HL7 Inspector does.
04

How field positions work

Each segment has numbered positions. We write them as SEG-N, e.g. PID-5. The count starts at 1 after the segment name.

PID
|
1
|
2
|
123456^^^MRN
|
4
|
DOE^JOHN^A
|
6
|
19800115
|
M
PID-3 Patient Identifier
PID-5 Patient Name
PID-7 Date of Birth
PID-8 Administrative Sex
Empty ≠ missing. Two pipes in a row (||) means the field exists but is empty. That's different from the field being absent.
05

Read a real message, line by line

Here's an actual ADT^A01 (patient admission). Click any line to see what it means.

👆

Click any line to see its explanation.

06

Common message types

The MSH-9 field tells you the message type and trigger event, written as TYPE^EVENT.

ADT
Admit, Discharge, Transfer
A01 Admit · A03 Discharge · A08 Update
Patient movement
ORU
Observation Result (Unsolicited)
R01 Result · R30 Point-of-care
Lab & diagnostic results
ORM
Order Message
O01 Order · O02 Response
Placing orders
SIU
Scheduling Information Unsolicited
S12 New appointment · S14 Modification
Appointment booking
ACK
General Acknowledgement
AA Accept · AE Error · AR Reject
Confirms a message was received
MFN
Master File Notification
M01 Update · M02 Add
Reference data updates
07

Common pitfalls

Mistakes that trip up newcomers and experienced engineers alike.

⚠

Assuming standard delimiters

Most systems use |^~\&, but the spec allows any. Always read MSH-1 and MSH-2 before parsing.

⚠

Confusing empty fields with missing ones

PID|1||X means field 2 is empty. PID|1|X means field 2 is X and field 3 doesn't exist. Both are legal.

⚠

Trimming whitespace that matters

Never trim spaces inside field values — some systems use them as part of the value. Only trim around the delimiters.

⚠

Ignoring the version field

MSH-12 tells you the version. Field meanings change between 2.3 and 2.5.1. Always parse version-aware.

⚠

Assuming CRLF everywhere

HL7 uses \r as segment terminator. Some systems send \r\n or just \n. Normalize first.

⚠

Sending PHI over unencrypted channels

HL7 messages often carry names, MRNs, and dates of birth. Never log them in plaintext or send over non-TLS connections.

Ready to try it?

Paste a real (synthetic) HL7 message and see every field annotated live.

Open HL7 Inspector