HL7 v2.5.1 Specificationsv2.5.1

to moveEnter to openTry PID-5, ADT, 0004

MSH: Message header

Before you open a letter you look at the envelope: who sent it, who it is for, when it was posted, and what kind of post it is. MSH is that envelope. It carries nothing about the patient; it tells the receiving system what has arrived and how to read the rest.

MSH is the first line of every HL7 v2 message. It sets the delimiters the rest of the message uses. It also names the sender, the receiver, the time and the kind of message.

The shape of one line

MSHsegmentwhat kind of line this is
|MSH-1Field Separator
^~\&MSH-2Encoding Characters
LABSYSMSH-3Sending Application
STJOSEPHMSH-4Sending Facility
EPICMSH-5Receiving Application
STJOSEPHMSH-6Receiving Facility
20240314141207MSH-7Date/Time Of Message
 MSH-8Security
ORU^R01^ORU_R01MSH-9Message Type
LR20240314-88412MSH-10Message Control ID
PMSH-11Processing ID
2.5.1MSH-12Version ID

required empty in this messageevery box is one | apart

Where MSH appears

MessageSegment order
Every messageMSH is always first, and always exactly once
ADT^A01 admitMSH → EVN → PID → [PD1] → PV1
ACK acknowledgmentMSH → MSA → [ERR]
BatchFHS → {BHS → {MSH …} → BTS} → FTS

MSH appears in 187 of the 202 message structures the standard defines.

A whole message

MSH from a lab result sent to a hospital EHR
MSH|^~\&|LABSYS|STJOSEPH|EPIC|STJOSEPH|20240314141207||ORU^R01^ORU_R01|LR20240314-88412|P|2.5.1|||AL|NE|USA|ASCII|en
PID|1||1000345678^^^STJOSEPH^MR||CARTWRIGHT^ELEANOR^MAY^^^^L||19510822|F
OBR|1|ORD8842^EPIC|LAB77213^LABSYS|CBC^COMPLETE BLOOD COUNT^L|||20240314103000|||||||||1447312^OKONKWO^ADAEZE^^^^MD||||||20240314141000|||F
OBX|1|NM|718-7^HEMOGLOBIN^LN||11.8|g/dL|12.0-15.5|L|||F|||20240314141000

Every field

SEQLENDTOPTRP/#TBL#ITEM#Element nameCardinality
MSH-11STR00001Field Separator1..1
MSH-24STR00002Encoding Characters1..1
227HDO036100003Sending Application0..1

MSH-3 is a HD, which holds 3 components separated by carets.

SEQLENDTOPTTBL#Component name
HD.120ISO0300Namespace ID
HD.2199STCUniversal ID
HD.36IDC0301Universal ID Type
227HDO036200004Sending Facility0..1

MSH-4 is a HD, which holds 3 components separated by carets.

SEQLENDTOPTTBL#Component name
HD.120ISO0300Namespace ID
HD.2199STCUniversal ID
HD.36IDC0301Universal ID Type
227HDO036100005Receiving Application0..1

MSH-5 is a HD, which holds 3 components separated by carets.

SEQLENDTOPTTBL#Component name
HD.120ISO0300Namespace ID
HD.2199STCUniversal ID
HD.36IDC0301Universal ID Type
227HDO036200006Receiving Facility0..1

MSH-6 is a HD, which holds 3 components separated by carets.

SEQLENDTOPTTBL#Component name
HD.120ISO0300Namespace ID
HD.2199STCUniversal ID
HD.36IDC0301Universal ID Type
26TSR00007Date/Time Of Message1..1

MSH-7 is a TS, which holds 2 components separated by carets.

SEQLENDTOPTTBL#Component name
TS.124DTMRTime
TS.21IDB0529Degree of Precision
MSH-840STO00008Security0..1
15MSGR00009Message Type1..1

MSH-9 is a MSG, which holds 3 components separated by carets.

SEQLENDTOPTTBL#Component name
MSG.13IDR0076Message Code
MSG.23IDR0003Trigger Event
MSG.37IDR0354Message Structure
MSH-1020STR00010Message Control ID1..1
3PTR00011Processing ID1..1

MSH-11 is a PT, which holds 2 components separated by carets.

SEQLENDTOPTTBL#Component name
PT.11IDO0103Processing ID
PT.21IDO0207Processing Mode
60VIDR00012Version ID1..1

MSH-12 is a VID, which holds 3 components separated by carets.

SEQLENDTOPTTBL#Component name
VID.15IDOVersion ID
VID.2483CEO0399Internationalization Code
VID.3483CEOInternational Version ID
MSH-1315NMO00013Sequence Number0..1
MSH-14180STO00014Continuation Pointer0..1
MSH-152IDO015500015Accept Acknowledgment Type0..1
MSH-162IDO015500016Application Acknowledgment Type0..1
MSH-173IDO039900017Country Code0..1
MSH-1816IDOY021100692Character Set0..*
250CEO00693Principal Language Of Message0..1

MSH-19 is a CE, which holds 6 components separated by carets.

SEQLENDTOPTTBL#Component name
CE.120STOIdentifier
CE.2199STOText
CE.320IDO0396Name of Coding System
CE.420STOAlternate Identifier
CE.5199STOAlternate Text
CE.620IDO0396Name of Alternate Coding System
MSH-2020IDO035601317Alternate Character Set Handling Scheme0..1
427EIOY01598Message Profile Identifier0..*

MSH-21 is a EI, which holds 4 components separated by carets.

SEQLENDTOPTTBL#Component name
EI.1199STOEntity Identifier
EI.220ISO0363Namespace ID
EI.3199STCUniversal ID
EI.46IDC0301Universal ID Type

Open this MSH message in HL7 Studio

Field notes

Vendor behaviour

What follows describes patterns common to these systems' standard interfaces. Every installation is configured, so confirm against the interface specification for the site you are integrating with.

Epic

Epic interfaces are configured per connection, so MSH-3 and MSH-4 carry whatever was agreed during implementation and nothing Epic-wide, and they are the fields to confirm in writing before go-live. Epic populates MSH-9 component 3 with the structure code on modern builds.

Mapping to FHIR

MSH corresponds to FHIR MessageHeader, but only when the FHIR side is genuinely using the messaging paradigm. Most v2-to-FHIR work is not: it turns an ADT feed into Patient and Encounter resources through a REST API, and in that case MSH carries no clinical content to map and becomes provenance instead. Sending facility and message timestamp belong in a Provenance resource, and the message control ID is worth keeping as a Provenance identifier for tracing.

HL7 v2FHIR R4Note
MSH-3, MSH-4MessageHeader.sourceor Provenance.agent when not using messaging
MSH-5, MSH-6MessageHeader.destination
MSH-7MessageHeader.meta.lastUpdatedor Provenance.recorded
MSH-9MessageHeader.eventCoding
MSH-10Bundle.identifier

Parsing pitfalls

Message types carrying MSH

MSH appears in 187 message structures, belonging to 106 message types.