HL7 Message Notes
HL7 Message definition and description were already mentioned in our previous posts. Today we continue to speak about HL7 Message structure.
There is a standard HL7 Message notation that is used to document the structure of an HL7 message. This notation consists of 5 rules:
- All messages start with an MSH Segment
- Required segments have the three character id printed
- Optional Segments are bracketed [ NTE ]
- Repeating Segments, at least 1 is required, are enclosed in curly brackets {NTE}
- Optional Repeating segments are enclosed with regular brackets and curly brackets -[{NTE}].
The following is the Definition of Patient Transfer in Version 2.3.1.
MSH Message Header
[{ SFT }] Software Segment
EVN Event Type
PID Patient Identification
[ PD1 ] Additional Demographics
PV1 Patient Visit
[ PV2 ] Patient Visit – Additional Info.
[{ DB1 }] Disability Information
[{ OBX }] Observation/Result
The following is the Definition of Patient Transfer in Version 2.5:
MSH Message Header
[{ SFT }] Software Segment
EVN Event Type
PID Patient Identification
[ PD1 ] Additional Demographics
[{ ROL }] Role
PV1 Patient Visit
[ PV2 ] Patient Visit – Additional Info.
[{ ROL }] Role
[{ DB1 }] Disability Information
[{ OBX }] Observation/Result
[ PDA ] Patient Death and Autopsy
Note that Segments have been added between versions. Proper parsing rules will act as if the additional segments did not exist.
It was impossible to standardize all elements in the data exchange. So to maintain flexibly and cause differences between implementations, HL7 allows the definition and inclusion of a user-defined segment – called the Z-Segment. The Z-segment may be defined starting with a segment Id of “Z” + 2 additional characters and included in any message.
HL7 mandates a message protocol where the message is acknowledged by the receiver. This is done with an ACK message which consists of 2 segments:
MSH segment
MSA segment.
The receiving application must respond with an ACK Message. The sending application will continue to resent the same message until it has received the ACK message. This is done to insure that data will not be lost in transmission. Generally, some trigger is put in place in the sending application to report an error by the receiving app. As part of this data, element 10 of the MSH segment contains a unique message id which is echoed in the field 2 of the MSA segment in the ACK Message.
Here is a lab result message.
MSH|^~\&|*SETUP*|MCL|*SETUP*|ORDERING CO|20040824135642||ORU^R01|20042370000075|P|2.4||||
PID|1|99995201307400032|T0536646|PAL007|TOUCHET^ROGET D^||19450201|M|||||6518553055|||
PV1||L|||||^||
ORC|RE||T0536646|||||||||||||^||
OBR|1|||2217^GLUCOSE|||||||N|||20040824124500||^||TXE||||20040824124724|||F||R|
OBX|1|NM|2217^GLUCOSE|1|85|MG/DL|65 – 110||||F|||200408241247|SA1|DBM^BEDOR^LOU|
NTE|1|CODE^L175| |
NTE|2|CODE^L175| TESTING PERFORMED AT CLINICAL PATHOLOGY LABORATORY|
NTE|3|CODE^L175| 2911 FIRST AVENUE CEDAR PARK, TX 78613|
NTE|4|CODE^L175| CLIA NO. 45D0999999|
The vertical bar, “|”, is the element delimiter in this message, Note the occurrences of “||”. In these cases, the element between the vertical bars is not being sent. In the case of |””|, the element being sent is null and should overwrite that data in the receiving application.
The construction of the HL7 message should eliminate trailing fields in a segment where no information is being sent. Thus “PV1||L|||||^||” would be “PV1||L”. In many implementations this is not done.