Documentation

HL7 v2 reference and tool guide

A short reference for reading HL7 v2 messages, plus notes on how the tools work.

Getting started

The HL7 Inspector preview reads one HL7 v2 message at a time.

  1. Paste a message, or choose Load sample. Use synthetic or de-identified data only.
  2. Choose Inspect message. A summary shows the message type, control ID and version from the MSH segment.
  3. Select a segment to see its fields. Fields with components or repetitions are expanded below the raw value.

Limits of the preview: messages up to 20 KB; one message at a time; structure only. The preview does not validate a message against HL7 standards, implementation guides or conformance profiles, and it does not decode escape sequences.

HL7 v2 basics

An HL7 v2 message is plain text made of segments. Each segment is one line and starts with a three-character ID, such as PID. Segments end with a carriage return character. Inside a segment, fields are separated by a field separator (normally |). Fields can contain components, and components can contain subcomponents. A field can also repeat.

A short synthetic example:

MSH|^~\&|SENDAPP|SENDFAC|RECVAPP|RECVFAC|20261010093000||ADT^A01^ADT_A01|MSG00001|P|2.5.1
EVN|A01|20261010093000
PID|1||000123^^^SENDFAC^MR||DOE^JANE^Q||19800101|F|||123 SAMPLE ST^^EXAMPLEVILLE^ZZ^00000^USA||^PRN^PH^^^555^0100
PV1|1|I|WARD1^101^A^SENDFAC||||1234^SAMPLE^DOCTOR^A

The first segment, MSH, declares the delimiters used in the rest of the message, so a reader should take them from MSH rather than assume them.

Delimiters

These are the usual defaults. The message itself is the authority: MSH-1 holds the field separator and MSH-2 holds the other four characters.

Default HL7 v2 delimiters
CharacterRoleWhere it is declared
|Field separatorMSH-1
^Component separatorMSH-2, position 1
~Repetition separatorMSH-2, position 2
\Escape characterMSH-2, position 3
&Subcomponent separatorMSH-2, position 4

Field addresses

A value is addressed as SEGMENT-field.component.subcomponent. Fields are numbered from 1 in the order they appear after the segment ID. The MSH segment is a special case: the field separator itself counts as MSH-1, so the first field after the separator is MSH-2, and the first field after the encoding characters is MSH-3.

Example addresses using the sample message
AddressMeaningValue in the sample
MSH-9Message typeADT^A01^ADT_A01
MSH-10Message control IDMSG00001
MSH-12Version ID2.5.1
PID-3Patient identifier list000123^^^SENDFAC^MR
PID-5Patient nameDOE^JANE^Q
PID-5.1Family name (first component of PID-5)DOE
PV1-2Patient classI

Field meanings depend on the HL7 version. The table above reflects the v2.5.1 sample; check the specification for the version you use.

Common segments

Commonly seen HL7 v2 segments
IDNameTypical purpose
MSHMessage HeaderDelimiters, sender and receiver, message type, control ID, version
EVNEvent TypeTrigger event details for ADT messages
PIDPatient IdentificationPatient identifiers, name, birth date, sex, address
PV1Patient VisitVisit or encounter details such as patient class and location
NK1Next of Kin / Associated PartiesRelated persons and contacts
ORCCommon OrderOrder control and identifiers shared across order types
OBRObservation RequestDetails of a requested test or observation
OBXObservation / ResultAn individual result value, often repeated
NTENotes and CommentsFree-text notes attached to the preceding segment
DG1DiagnosisDiagnosis information
AL1Patient Allergy InformationAllergy details
MSAMessage AcknowledgmentAcknowledgment code and the control ID being acknowledged
ERRErrorError information in an acknowledgment

Common message types

MSH-9 holds the message type and trigger event, for example ADT^A01.

Commonly seen HL7 v2 message types
TypeNameExample
ADTAdmit, Discharge, TransferADT^A01 admit or visit notification
ORMOrder messageORM^O01 general order
ORUObservation result (unsolicited)ORU^R01 result report
SIUScheduling information (unsolicited)SIU^S12 new appointment
VXUVaccination record update (unsolicited)VXU^V04
ACKGeneral acknowledgmentReply carrying an MSA segment

Escape sequences

When a delimiter character must appear inside a value, HL7 v2 uses an escape sequence that starts and ends with the escape character (normally \). The Inspector preview shows these sequences as they appear in the message and does not decode them.

Common escape sequences
SequenceRepresents
\F\Field separator
\S\Component separator
\T\Subcomponent separator
\R\Repetition separator
\E\Escape character

Notes for Mirth Connect developers Planned

In a Mirth Connect transformer, an inbound HL7 v2 message is typically exposed as an XML-like object, where each field and component has an element name built from its address. As a general pattern, PID-5.1 is written like this:

var familyName = msg['PID']['PID.5']['PID.5.1'].toString();

The exact structure can depend on your channel's data type settings and HL7 version, so confirm it against your own channel. Helper tools that generate these references are planned and are not available yet.

This project is independent and is not affiliated with or endorsed by NextGen Healthcare.

Roadmap

The roadmap is a plan, not a commitment. There are no release dates.

  • Phase 1 (this build): website foundation, Inspector preview, documentation, proposed pricing, contact form, account page placeholders.
  • Phase 2: a stronger Inspector (escape handling, version-specific field names), accounts, saved snippets, and the first version of message comparison.
  • Later: Mirth Connect helper tools, paid plans and checkout, and API access. Each is subject to change after feedback.