HL7 resources

HL7 MSH (Message Header)

The HL7 MSH (Message Header) segment is present in every HL7 message type and defines the message’s source, purpose, destination, and certain syntax specifics like delimiters (separator characters) and character sets. It is always the first segment in the HL7 message, with the only exception being HL7 batch messages.

There are 19 fields in the MSH segment, six of which (field separator, encoding characters, message type, message control ID, processing ID, and version ID) are required for all messages processed using the HL7 standard. The most important of the MSH fields, and perhaps the most important field in the entire message, is the MSH-9 (Message Type) field. This field specifies what type of message is being transmitted (ADTORMORUACK, etc.) and what the trigger event is. When a message is loaded, often the first field examined in order to determine processing is the value in this field.

The fields in the MSH segment are as follows:

11STR Field Separator
24STR Encoding Characters
3180HDO Sending Application
4180HDO Sending Facility
5180HDO Receiving Application
6180HDO Receiving Facility
726TSO Date/Time of Message
840STO Security
97CM_MSGR Message Type
1020STR Message Control Id
113PTR Processing Id
128IDR Version Id
1315NMO Sequence Number
14180STO Continuation Pointer
152IDO Accept Acknowledgement Type
162IDO Application Acknowledgement Type
172IDO Country Code
186IDO Character Set
193CEO Principal Language of Message

*Note: For the complete HL7 Standard, please go to the HL7 organization website.

The first two fields in the MSH segment define the separator characters to be used throughout the message. The MSH-1 field defines the field separator, and the MSH-2 field defines the other separator characters for the message in this order: component, field repeat, escape character, subcomponent.

The HL7 standard requires that a carriage return (ASCII 13 or HEX 0D) be used as the segment separator, so this value cannot be changed. However the HL7 recommended values for the other separator characters include the following:

|Field separator (pipe)Separates fields in a message
^Component separator (hat)Separates components in a field
~Field repeat separatorSeparates repeated fields in a segment
Escape characterUsed to signal special characters in a field of text (i.e. H = start highlighting; F = component separator)
&Sub-component separatorSeparates components within components (see Data Types)

The values in the chart are recommended values – and are generally utilized by most systems – but you may elect to use different separator characters in your message if you choose (with the exception of the segment separator). If you do elect to use other separator characters, the chosen values must be specified in the MSH-2 segment for the message.

The beginning of an HL7 message using the recommended values looks like this:


The other required MSH fields are described below:

  • MSH-9 (Message Type) – the type of message and trigger event
  • MSH-10 (Message Control ID) – a number or other unique identifier for the message.
  • MSH-11 (Processing ID) – specifies the HL7 processing ID or processing mode; HL7 processing IDs include D (debugging), P (production), T (training); HL7 processing modes include A (archive), R (restore from archive), I (initial load), not present (default value, means “current processing”)
  • MSH-12 (Version ID) – the HL7 version used in the message (i.e. 2.1, 2.3, 3.0, etc.); allows the receiving system to select the appropriate HL7 version to interpret the message.

Non-conformance to the MSH segment

Not all systems will send messages with MSH segments that conform to the HL7 requirements described above. For instance, the messages may not include a Message ID or Version ID, or they may include additional fields of information that are not specified in the HL7 standard. For this reason, it is important that your system be able to anticipate non-conformant messages and know how to process these messages in an effective manner.

Register for an upcoming HL7: First Steps training class.

You might also like

HL7 resources

HL7 Data Types

HL7 data types define the kind of data included in a field used in the HL7 message structure. Examples include a string, text, timestamp, address, or coded element.

Read more >

HL7 resources

RIM-Reference Information Model

The HL7 Reference Information Model (RIM) represents a static model of healthcare workflows as viewed by the HL7 standards development group.

Read more >

HL7 resources

Minimum Layer Protocol – MLP

MLP is how an application should wrap an HL7 message to ensure HL7 compliant applications know where a message starts and stops, and where the next message begins.

Read more >