Skip to main content

Problem

The error “ MSH segment is either missing or not at the start" indicates that after parsing an HL7 message with hl7.parse, the MSH segment could not be found or is not at the start.

Causes

  1. MSH segment is missing.

  2. MSH segment is not the first segment.

  3. There is whitespace or character(s) before the MSH segment.

  4. MSH segment is not defined or is not the first child for the corresponding message definition in the vmd.

  5. MSH segment is not defined as a child in the catchall message definition, even if the inbound message is not filtered by the catchall.

Case 5 is only applicable on IguanaX versions 10.1.112 and below.

Solutions

Case 1 - Verify MSH segment is not missing

Review the HL7 message for verification. The MSH segment must exist before parsing.

Case 2 - Verify MSH is the first segment

Review the HL7 message for verification. The MSH segment must be the first segment.

Case 3 - Verify there are no characters in front of the MSH segment

To confirm there are no characters in front of the MSH segment:

  1. Find the message in the logs.

  2. Double click the message, or click the […] on the right side of the logged message to go into detailed view for the message.

  3. Verify there are no characters in front of the HL7 message.

  4. You can also change the view to “View as Hexadecimal”. The message must begin with 4D 53 48 7C → that is MSH| at byte 0.

Example: HL7 Message with no characters in front in Hexadecimal view

Example: HL7 Message with a whitespace character in front in Hexadecimal view

Case 4 - Review the .vmd file to verify the MSH segment exists as the first child for the corresponding message definition

To review the vmd file for the inbound message's corresponding message definition:

  1. Click on the .vmd file.

  2. Click on the corresponding message definition (i.e. “ADT”) to view it.

  1. Ensure MSH segment exists and is the first child defined.

Case 5 - Review the .vmd file to verify the MSH segment exists as the first child in the catchall message definition

There is a bug in versions 10.1.112 and below where the inbound message unexpectedly throws this error during parsing, even when the HL7 message has a correct MSH segment.

This is because the catchall message definition in the vmd file does not have an existing MSH child or it is not the first child defined.

This is a bug on versions 10.1.112 and below.

Option 2 Add the MSH segment to the catchall message definition

Review the vmd file to ensure a MSH segment exists and is defined as the first child for the Catchall message definition.