In constructing a message certain special characters are used. They are the segment terminator, the field separator, the component separator, subcomponent separator, repetition separator, and escape character. The segment terminator is always a carriage return (in ASCII, a hex 0D). The other delimiters are defined in the MSH segment, with the field delimiter in the 4th character position, and the other delimiters occurring as in the field called Encoding Characters, which is the first field after the segment ID. The delimiter values used in the MSH segment are the delimiter values used throughout the entire message. In the absence of other considerations, HL7 recommends the suggested values found in Figure 2-1 delimiter values.
At any given site, the subset of the possible delimiters may be limited by negotiations between applications. This implies that the receiving applications will use the agreed upon delimiters, as they appear in the Message Header segment (MSH), to parse the message.
Delimiter |
Suggested Value |
Encoding Character Position |
Usage |
Segment Terminator |
<cr> hex 0D |
- |
Terminates a segment record. This value cannot be changed by implementors. |
Field Separator |
| |
- |
Separates two adjacent data fields within a segment. It also separates the segment ID from the first data field in each segment. |
Component Separator |
^ |
1 |
Separates adjacent components of data fields where allowed. |
Subcomponent Separator |
& |
4 |
Separates adjacent subcomponents of data fields where allowed. If there are no subcomponents, this character may be omitted. |
Repetition Separator |
~ |
2 |
Separates multiple occurrences of a field where allowed. |
Escape Character |
\ |
3 |
Escape character for use with any field represented by an ST, TX or FT data type, or for use with the data (fourth) component of the ED data type If no escape characters are used in a message, this character may be omitted. However, it must be present if subcomponents are used in the message. |