· Jul 21, 2020

Problem With Message/Segment Terminators


 A device is sending me HL7 messages (ORM^O01)

the framing is set to "None"

and i get the following error:

3 Segments
Build Map Status = 'ERROR <EnsEDI>ErrMapRequired: Missing required PID element at segment 2 (PID)'
'ERROR <EnsEDI>ErrMapRequired: Missing required OBR element at segment 2 (PID)'
'ERROR <EnsEDI>ErrMapSegUnrecog: Unrecognized Segment 2:'PID' found after segment 1 (MSH)'

i seems that there framing chars in at the beginning and end of each segment

(in Hex)

 0b (MSH DATA HERE)  1c 0d  0b  (PID DATA HERE)  1c   0d   0b  (OBR DATA HERE)  1c 0d

i have tried all the Framing options of no help.

how can i fix this ? (i'm a newbie so....)



Discussion (3)1
Log in or sign up to continue


What are your settings for charset, content type and content encoding?

I would expect to see something like this:

  1. ContentEncoding = "HL7-ER7"
  2. ContentCharset = "UTF-8"
  3. ContentType = "application/hl7-v2"

The most common type of framing is MLLP. If you are acting as an HL7 server tand you don't know what the client framin is then set framing to flexible. that way ensemble will try and detect the framing based on the properties listed above and by looking for tell tale characters (segment terminators) such as LF $c(10) or CR,LF $c(13,10).  Depending on the properties listed above you may see the terminator represented as "/r". 

If you are the HL7 client then you can get away with framing = none provided both you and the 3rd party server are consistent on the content type, charset and encoding.

I hope that gives you some ideas of what to look out for and the questions you need to ask the 3rd party application you are trying to communicate with.



Hi Yakov,

I'm not sure which class you are using for your service, some assumptions will be made below:

In general, the service framing is regarding the Startblock(s) (before MSH) and Endblock(s)(at the end of the entire Hl7 Message), and not regarding the Segment Terminators.

First resolution:

Have the source send a correctly formatted HL7 message, as it appears they are utilizing a start and endblock on each segment instead of only a single time per HL7 message.

Second resolution:

I'm not aware of any direct out of the box way of explicitly set the segment terminators,  so an additional custom class may need to be created. I would look into the method GetSegmentTerminator of EnsLib.HL7.Service.Standard class.

Thanks David,

There is no chance the source will correct their side

so will use second resolution:

should this do the job?

Class Test.BS.HL7.DMS.TCPService Extends EnsLib.HL7.Service.TCPService

/// Return the segment terminator string that the Parser and the document.ImportFromIOStream() method will use.
Method GetSegmentTerminator() As %String
    Quit $C(28,13,11)

Parameter ADAPTER = "Test.Adapter.HL7.DMS.TCPInboundAdapter";