Healthcare Interoperability Blog

interfaceware.com
  • Iguana Integration Engine
  • Resource Center
  • Blog
Home Understanding HL7 Segment Grammar Notation

Understanding HL7 Segment Grammar Notation

HL7 Segment Grammar Notation

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

MSH|^~\&|MESA_RPT_MGR|EAST_RADIOLOGY|REPOSITORY|XYZ|||ORU^R01|MESA3b781ae8|P|2.5||||||||
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.

Additional Resources:

5 Ways To Speed Up HL7 Integration

Sep 30, 2021iNTERFACEWARE
  • Email
  • LinkedIn
  • More
  • Facebook
  • Twitter

Related

Webinar Series | Part 2: Interface Development: Solutions & WorkflowsDoes HL7 software compliance actually exist?
September 30, 2021 HL7 InformationHL7, hl7 segment grammar, hl7 segments, integration engine
Enjoying this blog?

Sign up to receive healthcare integration news, just like this, from iNTERFACEWARE Inc.

iNTERFACEWARE needs the contact information you provide to us to contact you about our products and services. You may unsubscribe from these communications at any time. For information on how to unsubscribe, as well as our privacy practices and commitment to protecting your privacy, please review our Privacy Policy.

Resources

Integration Resources & Guides

HL7 Resources

Iguana Case Studies

Iguana Integration Engine

Overview: Integration Engine

Features: Building HL7 Interfaces

Benefits: Why Choose Iguana

Company

About Us

Integration Services

Contact Us

Connect

LinkedIn

Twitter

YouTube

© - iNTERFACEWARE Inc.