Skip to content
The Path

Module 2 · Reading an HL7 v2 message·12 min

The MSH segment in detail

Who sends, to whom, when, what, with which ID: the envelope of every message.

Before opening a letter, you read the envelope: sender, recipient, postmark. An HL7 system does the same. Before touching the patient, it reads the MSH segment, always on the first line, to learn who is talking, to whom, when, and about what.

The sleep lab software sends Marie Dubois’s AHI to the Leleux Clinic patient record.

ORU^R01^ORU_R01· Observation result (unsolicited)
||||||||||
||||||||
||||
|||||||||||

Click each MSH field as you follow the lesson. We walk through it from left to right.

Off by one

In MSH, the bar right after the segment name is the first field, MSH-1. The next four characters make up MSH-2. So when you count bars, you are always one step off compared with other segments. Remember the rule: in MSH, the first text after ^~\& is MSH-3.

Those first two fields have their own lesson, the one on delimiters. Let us move on.

MSH-3 to MSH-6: who talks to whom

Four fields, two pairs:

  • MSH-3: the sending application. Here SLEEPLAB, the sleep lab software.
  • MSH-4: the sending facility, or more broadly the organization responsible for that application. Here LELEUX.
  • MSH-5: the receiving application. Here HIS, the patient record system.
  • MSH-6: the receiving facility.

The values are entirely site-defined. The standard provides no list: the integration team decides that the lab is called SLEEPLAB. These fields are of type HD, which can carry a short name, a universal ID and the type of that ID: SLEEPLAB^1.2.3^ISO, for example. In practice, the short name alone is very common.

MSH-7: when the message was created

MSH-7 holds the date and time when the sending system created the message. Not the time of the test, not the time it hit the network. The format runs from year down to second: 20260627083000 reads June 27, 2026 at 8:30:00.

If a time zone is given, for example 20260627083000+0200, it becomes the default time zone for the whole message. The field has been required since version 2.4.

MSH-8 (security) exists, but the standard does not define how to use it. You will almost always see it empty.

MSH-9: the message type

The most important field in MSH. It has three components:

Component Role Example
MSH-9.1 message code (table 0076) ORU: a result
MSH-9.2 trigger event (table 0003) R01: a result is available
MSH-9.3 message structure (table 0354) ORU_R01: the expected segment layout

The receiver uses it to know which segments to expect, and often which application to route the message to.

The third component tends to surprise people. Several events share one structure. An admission A01, a patient registration A04, an update A08 and a cancelled discharge A13 all use the ADT_A01 structure. So ADT^A04^ADT_A01 is perfectly normal. In 2.5.1 all three components are required, even though you will meet plenty of messages that stop at ORU^R01.

MSH-10: the control ID

MSH-10 identifies the message uniquely. The sender builds it however it likes: a counter, a date plus a number, a generated ID. Here, MSG00022.

Its real job shows in the reply. The receiver sends that ID back in the MSA segment of its acknowledgement, in field MSA-2. Here is the acknowledgement returned after an admission sent with MSH-10 = MSG00002:

The reply sent back after receiving the admission. The MSA segment carries the verdict: AA, accepted.

ACK^A01^ACK· Acknowledgement
||||||||||
||

That link is how the sender knows which message was accepted. Reuse an MSH-10 and two messages become impossible to tell apart in the logs.

MSH-11: production, training or debugging

MSH-11 says which environment should process the message. Its first component comes from table 0103:

Code Meaning
P Production
T Training
D Debugging

A second component, rarely filled in, gives the mode: archive (A), restore from archive (R), initial load (I) or current processing transmitted at intervals, scheduled or on demand (T). When it is absent, it means current processing.

MSH-12: the version

MSH-12 states the version of the standard in use, here 2.5.1. The receiver compares it with its own to interpret the message correctly. Two optional components serve HL7’s international affiliates; you will rarely see them.

MSH-15 and MSH-16: which acknowledgements to expect

These two fields drive enhanced acknowledgement mode. MSH-15 covers the accept acknowledgement (the message arrived safely), MSH-16 the application acknowledgement (the message was processed). Both use table 0155:

Code When to send the acknowledgement
AL always
NE never
ER only on error or rejection
SU only on success

If both fields are empty, as in our example, original mode applies. The acknowledgements lesson covers both modes in detail.

MSH-18: the character set, or the accent problem

MSH-18 says how to turn the bytes of the message into letters. Its values come from table 0211. Empty means 7-bit ASCII, with no accented letters at all. 8859/1 announces Latin-1, UNICODE UTF-8 announces UTF-8. When sender and receiver disagree, “Santé” shows up as “Santé”.

Most examples in this course stay in ASCII so they read cleanly everywhere. The next lesson, “Character sets and accents”, shows a real UTF-8 message and walks through the encodings byte by byte.

MSH at a glance

Field Name Type Required in 2.5.1
MSH-1 field separator ST yes
MSH-2 encoding characters ST yes
MSH-3 sending application HD no
MSH-4 sending facility HD no
MSH-5 receiving application HD no
MSH-6 receiving facility HD no
MSH-7 date/time of message TS yes
MSH-8 security ST no
MSH-9 message type MSG yes
MSH-10 message control ID ST yes
MSH-11 processing ID PT yes
MSH-12 version ID VID yes
MSH-15 accept acknowledgement type ID no
MSH-16 application acknowledgement type ID no
MSH-13, MSH-14 sequence number, continuation pointer NM, ST no
MSH-17 country code ID no
MSH-18 character set ID no
MSH-19 principal language of message CE no
MSH-20 alternate character set handling scheme ID no
MSH-21 message profile identifier EI no

Fields MSH-13 to MSH-21 are less common. Remember MSH-18, covered above, and MSH-21, which states the message profile (the formal specification of an interface) the message conforms to.

And in FHIR?

The FHIR counterpart of MSH is the MessageHeader resource, at the top of a message Bundle. The official v2-to-FHIR mapping guide puts MSH-9 in eventCoding, MSH-3 in source, MSH-4 in sender, MSH-5 in destination (target or name) and MSH-6 in destination.receiver. MSH-10 has no place in MessageHeader: it goes to Bundle.identifier, and MSH-7 to Bundle.timestamp.

Check your understanding

1 of 5

You receive MSH|^~\&|SLEEPLAB|LELEUX|HIS|LELEUX|20260627083000||ORU^R01^ORU_R01|MSG00022|P|2.5.1. What is MSH-5?

+50 XPPass the quiz (4 correct answers) to complete the lesson.

Reviewed and checked on 28 September 2026