HL7 v2 is still the backbone of hospital interoperability: admissions, orders, results, and discharge summaries move between systems as pipe-delimited text messages. This guide decodes the structure — delimiters, segments, fields, and components — so you can read a raw message instead of staring at it.
Delimiters Come First
Every HL7 v2 message starts with an MSH segment that declares its own delimiters in the first eight characters:
MSH|^~\&|SENDING_APP|SENDING_FAC|RECV_APP|RECV_FAC|202609261030||ADT^A01|MSG00001|P|2.5
The character after MSH is the field separator (|), and the next four characters — conventionally ^~\& — are the component, repetition, escape, and sub-component separators. All parsing keys off these characters; a message with different delimiters is still valid HL7.
Segments, Fields, Components
- Segment — one line of the message, identified by a 3-character ID (MSH, PID, OBR, OBX, EVN…).
- Field — a value between field separators. PID-3 is the third field of the PID segment (patient identifier list).
- Component — a value split by
^. PID-5^1 is the patient's family name inside the name field. - Repetition — multiple values separated by
~(e.g., several patient identifiers in PID-3).
A Real ADT^A01 Message, Decoded
MSH|^~\&|EPIC|GENERAL_HOSPITAL|LAB|LAB|20260926103015||ADT^A01|MSG00001|P|2.5 EVN|A01|20260926103000 PID|1||123456^^^MRN||Doe^John^A||19850315|M|||123 Main St^^Springfield^IL^62701 PV1|1|I|ICU^101^1||||1234^Smith^Jane^^^^MD|||||||||||VN123456
Read top to bottom: MSH declares sender/receiver, timestamp, message type (ADT-A01 = patient admission) and version. EVN records the event. PID carries patient demographics — MRN 123456, John A. Doe, born 1985-03-15. PV1 describes the visit — inpatient, ICU bed 101, attending Dr. Jane Smith.
Common Segments and Message Types
| Segment | Purpose |
|---|---|
| MSH | Message header — delimiters, sender, type, version |
| EVN | Event type and timestamp |
| PID | Patient identification and demographics |
| PV1 | Visit/encounter details, location, attending |
| OBR | Observation request (order) |
| OBX | Observation result — lab values, vitals, notes |
| MSA | Acknowledgment (AA = accepted, AE = error) |
The most common message types are ADT (admission/discharge/transfer events A01–A40), ORM/ORU (orders and results), SIU (scheduling), and DFT (billing). Every message type has a required segment sequence defined by the standard — a missing PID in an ADT is a structural error.
Parsing Pitfalls
- Positional fields. Empty fields are significant —
PID|1||123means field 2 is empty, not that 123 is field 2. Trailing empty fields may be omitted entirely. - Escaping. Literal delimiter characters in text are escaped with
\F\,\S\,\R\,\E\,\T\. - Encoding. HL7 v2 messages travel over MLLP wrapped in VT/FS control characters (0x0B … 0x1C0D) — a raw message pasted from a socket log includes them.
- Version drift. v2.3 vs v2.5 vs v2.8 change optionality and data types; always check MSH-12.
To inspect a message without writing a parser, paste it into our free HL7 Parser — it splits the message into segments and fields, highlights the message type, and validates structure in your browser with no data leaving your machine. If you're consuming HL7 feeds into a FHIR-based system, our FHIR Validator checks the resulting resources, and the HL7 v2 vs FHIR comparison covers when to use which.
Frequently Asked Questions
What does the MSH segment contain?
The encoding characters (MSH-1/2), sending and receiving applications and facilities (MSH-3 to MSH-6), timestamp (MSH-7), message type (MSH-9, e.g. ADT^A01), control ID (MSH-10), processing ID (MSH-11), and HL7 version (MSH-12).
What is the difference between ADT and ORU messages?
ADT messages report patient movement events (admission, transfer, discharge). ORU messages report clinical observations and results — lab values, radiology reports. An order flows as ORM, its result returns as ORU.
Is HL7 v2 still used, or has FHIR replaced it?
Still dominant inside hospitals — most EHR, lab, and imaging integrations run on v2 feeds. FHIR is the growing standard for APIs and external exchange, but coexistence is the reality; many organizations translate v2 to FHIR at the boundary.
How do I parse an HL7 message online?
Paste the raw message into our HL7 Parser — it auto-detects delimiters, decodes segments and fields, and validates the structure. Everything runs locally in your browser.




