by xProgrammer » Tue May 02, 2017 9:53 pm
Hi Jeff
I thought the following might be useful information just in case you run into a source of HL7 messages where the preferred deliniators were not used
In HL7 messaging, the separator characters are also known as the message delimiters or special encoding characters. The following are the HL7 recommended values:
(x0D) Segment separator
| Field separator, aka pipe
^ Component separator, aka hat
& Sub-component separator
~ Field repeat separator
\ Escape character
The segment separator is not negotiable. It is always a carriage return (ASCII 13 or HEX 0D). The others are suggested values only, but usually used as indicated above. The HL7 standard lets you choose your own as long as you show them in the MSH segment.
The MSH is the first segment of all HL7 messages (except HL7 batch messages). The field separator is presented as the 4th character in the message and it also represents the first field of the MSH segment. Since the first field of the MSH is typically only a pipe,’|’, counting MSH fields becomes tricky. Field 2 of the MSH (MSH-2) contains the other separator characters in this order: component, field repeat, escape, and sub-component.
Thus, the following is an example of the beginning of an HL7 message:
MSH|^~\&|…
The delimiter values used in the MSH segment are supposed to be the delimiter values used throughout the entire message. Encoding HL7 messages in this manner allows an application parser to simply use the special characters in the MSH to parse the message. However, beware that many application parsers just use hard coded values and ignore MSH-1 (Field Separator) and MSH-2 (Encoding Characters).
Regards
Doug