By convention, a standard segment grammar notation is defined to provide a convenient way to indicate the segments that can be included in a particular type of HL7 message.
Many vendors use this segment grammar notation to specify what segments may be included with each type of HL7 message that they send.
In the standard segment grammar notation, segments are listed from left to right, starting with the first segment in the message (which is always MSH). For example, consider the following HL7 message example.
HL7 Message Example
MSH|^~\&|EPIC|EPICADT|SMS|SMSADT|199912271408|CHARRIS|ADT^A04|1817457|D|2.5|
PID||0493575^^^2^ID 1|454721||DOE^JOHN^^^^|DOE^JOHN^^^^|19480203|M||B|254 MYSTREET AVE^^MYTOWN^OH^44123^USA||(216)123-4567|||M|NON|400003403~1129086|
NK1||ROE^MARIE^^^^|SPO||(216)123-4567||EC|||||||||||||||||||||||||||
PV1||O|168 ~219~C~PMA^^^^^^^^^||||277^ALLEN MYLASTNAME^BONNIE^^^^|||||||||| ||2688684|||||||||||||||||||||||||199912271408||||||002376853
The segment grammar notation for this message would be:
MSH PID NK1 PV1
In the segment grammar notation, optional segments are enclosed in square brackets [].
For example, if a PV2 (Patient Visit – Additional Information) segment can be optionally included with messages such as the one shown above, the segment grammar looks like this:
MSH PID NK1 PV1 [PV2]
Repeating segments are enclosed in curly brackets {}.
For example, if multiple NK1 segments can be included, the segment grammar looks like this:
MSH PID {NK1} PV1 [PV2]
A segment that is both optional and can be repeated is enclosed in both square brackets and curly brackets. For example, if the NK1 segment is optional but can be repeated, the segment grammar looks like this:
MSH PID [{NK1}] PV1 [PV2]
Optional or repeating segment groups are indicated by specifying multiple segment names inside square brackets or curly brackets.
For example, consider the following sample Lab Result message.
HL7 Lab Result Message Sample
PID|||CR3^^^ADT1||CRTHREE^PAUL|||||||||||||PatientAcct||||||||||||
OBR||||4550|||20010501141500.0000||||||||||||||||||F||||||||||||||||||
OBX|1|HD|SR Instance UID||1.113654.1.2001.30.2.1||||||F||||||
OBX|2|TX|SR Text||Lungs expanded and clear. Conclusions Normal PA chest x-ray.||||||F||||||
OBR||||4551|||20010501141500||||||||||||||||||F||||||||||||||||||
OBX|1|HD|SR Instance UID||1.113654.1.2001.10.2.1.603||||||F||||||
OBX|2|HD|Study Instance UID|1|1.113654.1.2001.10||||||F||||||
OBX|3|HD|Series Instance UID|1|1.113654.1.2001.10.1||||||F||||||
This message can optionally contain one or more Result Groups, with each Result Group consisting of one OBR message and one or more OBX messages. The segment grammar notation for this message is:
MSH PID [{OBR {OBX}}]
Here, OBR {OBX} is the segment grammar notation for a Result Group. The Result Group is enclosed in both square and curly brackets, as it is optional and can be repeated.
Over 120 different HL7 segments are available for use in HL7 messages to communicate health data. For further details on the HL7 message structure, including in depth information on segments, composites and delimiters, visit iNTERFACEWARE’s comprehensive guide to HL7.
Looking for professional advice? Iguana is the leading HL7 integration engine on the market, trusted globally for 20+ years. To learn more about HL7 data exchange, contact one of our integration engine experts today.