Sidebar

What is a MessageModelException: Unknown segment: 'xxx' error?

0 votes
1.4K views
asked Sep 22, 2016 by rich-c-2789 (16,180 points)
I see this error with different letters in place of the 'xxx'.   What might be the cause?

1 Answer

0 votes

This error indicates that the message could not be parsed into an HL7 message model.  By default QIE will allow a HEX(0D) "\r", HEX(0A) "\n", or HEX(0D0A) "\r\n" to act as the segment delimiter.  This makes the engine more flexible on it's ability to receive messages from other systesm.  However, the HL7 v2 specification indicates that only a HEX(0D) "\r" can be used as a segment delimiter.

With this in mind there are two things can can cause the above error.  First, if the message is following the spec and using a HEX(0D) "\r" as the segment delimiter, then having a HEX(0A) "\n" in the content of the message (such as an address) is allowed.  Because QIE by default treats the HEX(0D) "\r" and the HEX(0A) "\n" as the segment delimiter it detects the HEX(0A) "\n" as a new segment.

For example, if we have the following address field:

123 Some Long Street, \nInSomeCity, State

In the QIE editor this message would actually look like this:

123 Some Long Street, [x0A]InSomeCity, State

Results in an exception message like:

[line: 69] MessageModelException: Unknown segment: 'InS' in at line number 69

The easiest way to correct this scenario is to change the source of the channel to use only HEX(0D) "\r" as the segment delimiter.  This can be done by navigating to the source node on the channel and selecting the checkbox to override the segment delimiter when parsing the message.

By changing the configuration we are forcing QIE to obey the HL7 specification and only use the HEX(0D) '\r' as the segment delimiter.  If the sending system sends a HEX(0D0A) '\r\n' as the segment delimiter the message will fail to parse correctly.

The second cause of this exception is if the message is not following the HL7 specification.  In that case a HEX(0D) '\r' could be found in the message content.  If this is the case, then the sending system should be fixed to escape the HEX(0D) to a string \X000d\ instead.  The below referenced questions could help you deal with the carriage returns in the message before going to the inbound queue for processing.

For example the previous example address field if it is invalid will look like this:

123 Some Long Street, \r\nInSomeCity, State

In the QIE editor it will show like this:

123 Some Long Street, [x0D][x0A]InSomeCity, State

Results in an exception message like:

[line: 69] MessageModelException: Unknown segment: 'InS' in at line number 69

If it is escaped, then it would be valid and would look like this in the QIE editor:

123 Some Long Street, \X000d\[x0A]InSomeCity, State

See also:

What does this error mean? [line: 157] MessageModelException: Unknown segment: 'und' in at line number 157

Dealing with new line or carriage returns in address field (or any field) in the inbound message

Can I intercept or preprocess messages? How to handle systems that send too much or invalid data?

 

 

answered Sep 22, 2016 by rich-c-2789 (16,180 points)
edited Nov 9, 2020 by ben-s-7515
...