HL7 stands for Health Level Seven. It is both the name of the standards body, HL7 International, founded in 1987, and shorthand for its most used standard, HL7 version 2. When someone in a hospital says "we send you an HL7 feed", they mean v2 messages: short text messages that announce an event, such as a patient being admitted or a lab result being ready.
The "Level Seven" refers to the application layer, layer 7 of the OSI network model.
How an HL7 v2 message is built
A message is plain text. Each line is a segment that starts with a three-letter code. Fields are separated by |, components by ^, and repetitions by ~. The first segment, MSH, declares the delimiters, the sender, the receiver, the message type and the version.
Common segments:
- MSH: message header
- PID: patient identification
- PV1: patient visit
- OBR and OBX: an order and its result observations
Common message types:
- ADT: admit, discharge, transfer (for example
ADT^A01for an admission) - ORM or OML: orders
- ORU: observation results, usually lab results
- SIU: scheduling
Example: a lab result (ORU^R01)
MSH|^~\&|LAB|CITYHOSP|EHR|CITYHOSP|202611211030||ORU^R01|MSG00001|P|2.5.1
PID|1||123456^^^CITYHOSP^MR||Sharma^Anita||19840312|F
OBR|1||LAB7788|58410-2^CBC panel^LN
OBX|1|NM|718-7^Hemoglobin^LN||13.2|g/dL|12.0-15.5|N|||F
The lab system sends this to the EHR. The EHR replies with an ACK message carrying MSA|AA|MSG00001 (accepted) or an error code. If no ACK arrives, the sender retries, so receivers should detect duplicate message control IDs.
Transport: MLLP and interface engines
Messages usually travel over MLLP (Minimal Lower Layer Protocol), which wraps each message in start and end bytes on a plain TCP connection. MLLP has no encryption of its own, so feeds that leave the hospital network go through a VPN or TLS tunnel. Hospitals route feeds through an interface engine that receives, transforms, queues and forwards messages, much like a message queue with mapping rules.
Versions
Version 2.9 (2019) is the latest numbered release, but most live interfaces run older versions such as 2.3, 2.4 or 2.5.1. The versions are broadly backward compatible, and the version a sender uses appears in MSH-12.
HL7 v2 vs FHIR
HL7 v2 pushes event messages between systems inside a hospital. FHIR exposes data as resources through a REST API in JSON, and suits apps and data sharing between organisations. A typical product receives v2 feeds from the hospital and offers FHIR to everything else, as explained in our HL7 vs FHIR guide.
Common problems
- Site variation. Optional fields and custom Z-segments differ by hospital and vendor. Ask for real sample messages before you write the mapping.
- Silent failures. A feed that stops sending looks the same as a quiet night. Alert on missing traffic.
- Encoding. Escape sequences such as
\F\for a pipe inside a field are easy to miss. - PHI in logs. Raw messages contain protected health information, so treat interface logs as sensitive data.
We build HL7 and FHIR interfaces for MedTech products as part of our product engineering work.