Skip to content

Conformance

How a message profile narrows the HL7v2 standard for one interface, and what it means for a system to conform to it.

The HL7v2 standard defines what a message can contain. Most segments and fields are optional, many fields can repeat, and the same information can often be sent in more than one valid way. Conformance is the part of the standard that narrows these options for a particular use, so that the systems on an interface, the connection between two specific systems, agree on what their messages actually contain.

Where conformance is defined depends on the version. The HL7v2 standard first defined it explicitly in version 2.5, as a section of Chapter 2, and moved it to a separate Chapter 2B in version 2.6. HL7 also publishes the HL7 Version 2 Conformance Methodology (opens in a new tab), a separate document that describes the methodology in more detail.

A message profile is the document that records these narrowed options. It specifies one message, such as ADT^A04, for one context of use: which segments, fields, and components the source populates, how many times each can occur, and which values each can hold. A system conforms to a message profile when the messages it sends and accepts satisfy that profile.

Terminology

Profile is the usual short form of message profile. Profiles also appear under other names, such as interface specification or conformance profile, and range from documents written for people to machine-readable definitions.

Purpose

The HL7v2 standard is permissive by design. This flexibility allows one standard to serve many different institutions, but it also means that two systems can both follow the standard and still misread each other's messages. A profile prevents this by recording the agreement before any message is exchanged. It serves four purposes:

  • Specification. It defines exactly what each system sends and accepts, so that both systems are built to the same definition.
  • Testing. It defines the messages that the interface must handle, so that test cases can be derived from it.
  • Validation. It defines the rules that each message is checked against, during testing and in production.
  • Documentation. It records the interface's local choices, including any Z-segments, the locally defined segments that the standard does not describe.

Example

The standard defines PID-3, the patient identifier list, as a repeating field, and does not specify the order of the repetitions. Two sources can therefore send the same patient's identifiers in different ways:

Two valid values of PID-3
PID|1||12345^^^HOSP^MR
PID|1||987654321^^^NATION^NI~12345^^^HOSP^MR

The first source sends only the medical record number (MR). The second sends a national identifier (NI) first and the medical record number second. Both messages are valid HL7v2. A destination that reads the medical record number from the first repetition takes the national identifier from the second source instead, and can attach that patient's results to the wrong record. Nothing in either message reveals the mismatch, because both are valid and HL7v2 messages do not name their fields. A profile for the interface removes the ambiguity, for example by limiting PID-3 to the medical record number.

The same kind of mismatch can occur in any field that an interface depends on: a field that the destination needs but the source leaves empty, a code that the destination does not recognize, or a value longer than the destination can store. In healthcare, each of these can leave a patient record incomplete or incorrect.

Profile levels

Profiles are built in layers. Each profile is derived from a parent, either the standard or another profile, and adds constraints to it. A derived profile can only narrow its parent's requirements, never relax them: an element that the parent requires remains required, while an element that the parent leaves optional can become required or be excluded.

The Conformance Methodology names three levels:

  • A standard profile is the message as the HL7v2 standard defines it, with every option still open. Conformance at this level says little, because the standard allows so many variations.
  • A constrainable profile resolves some options and leaves others open, to be resolved by the profiles derived from it. National and sector implementation guides, and the generic interfaces that vendors ship, are usually constrainable profiles.
  • An implementable profile leaves no option open and describes one interface completely. Only at this level can the conformance of an interface be assessed in full.

A typical chain starts from the constrainable profile of a national implementation guide. A hospital group refines it for its facilities, and the vendor that installs the interface resolves the remaining options at each site, which produces an implementable profile. A chain can have as many levels as the use requires; a state-level profile, for example, can be derived from a national one. Every interface in production follows an implementable profile, whether or not anyone has written it down.

Extensibility

Constraints narrow what the standard allows. Additions that the standard does not define, such as Z-segments or locally defined codes, are extensions. A profile documents the extensions that an interface uses alongside its constraints.

Implementation guides

An implementation guide is a published document that collects the profiles for one or more use cases. Standards bodies, national programs, and sector consortia write them, and they account for most of the constraints applied to HL7v2 in practice.

The IHE (opens in a new tab) technical frameworks define HL7v2 profiles for patient administration, laboratory, and radiology workflows, and vendors test their products against them. In the United States, federal regulation for electronic health records specified version 2.5.1 implementation guides for laboratory results (ORU^R01), immunization reporting (VXU^V04), and syndromic surveillance (ADT). A site that adopts an implementation guide inherits its constraints and adds its own, which produces an implementable profile for each interface.

Constraints

The standard states requirements for every part of a message, and each requirement belongs to a particular definition. The message definition, written in abstract message syntax, states whether each segment and group is optional or repeating. Each segment definition states, for each of its fields, whether it is optional or repeating, its maximum length, and its data type. Each data type definition states the same for its components.

A profile constrains each of these definitions, element by element:

ElementDefined inConstrained by
Segment, groupMessage definitionUsage, cardinality
FieldSegment definitionUsage, cardinality, length, values
Component, sub-componentData type definitionUsage, length, values

Components and sub-components do not repeat, so they have no cardinality.

The following excerpt of a profile for ADT^A04 compares the profile with the standard's definition in version 2.5.1. The usage codes are described in Usage.

ElementTypeStandardProfile
PD1SegmentOptionalX: not sent
PIDSegmentRequiredR, [1..1]
PID-3FieldRequired, repeatingR, [1..1]
PID-3.5ComponentAny code from table 0203R, MR only
PID-7FieldOptionalRE: sent when known
PID-8FieldOptional, codes from table 0001RE, F, M, or U only
PID-19FieldRetained for backward compatibilityX: not sent
PID-29FieldOptionalC: required if PID-30 is Y

Each row narrows the standard. The optional PD1 segment is excluded. PID-3 is limited to one repetition, and its identifier type, a component, is limited to the medical record number. PID-29, the date of death, becomes required whenever PID-30 states that the patient has died. A message from the second source in the Example does not conform to this profile, because its PID-3 has two repetitions.

Usage

Usage specifies whether an element must be present. Usage codes replace the standard's optionality codes with stricter ones:

CodeNameMeaning
RRequiredThe source must populate the element; the destination must process it.
RERequired but may be emptyThe source must populate the element if the data is available; the destination must process it when present.
OOptionalNeither the source nor the destination is required to support the element. A fully constrained profile contains no O elements.
CConditionalThe element is required or not depending on a stated predicate, such as "required if PV1-2 is I".
XNot supportedThe source must not populate the element; a destination may reject a message that does.

Cardinality

Cardinality specifies how many times a segment, group, or field can occur, as a [min..max] range. PID-3 with cardinality [1..3] must contain at least one identifier and at most three.

Values

Value constraints specify what a field or component can contain: its maximum length and, for a coded element, the codes that the interface uses. Data types and Tables describe field values and codes in detail.

Structure

At the message level, usage and cardinality together determine the structure of the message. A segment or group with usage X is removed, and one with cardinality [1..1] appears exactly once. The order of the segments remains the one that the standard defines. A profile can also add the interface's Z-segments.

Profile identifier

A message can identify the profile it follows in MSH-21, the message profile identifier:

MSH-21 citing a profile
MSH|^~\&|SendingApp|SendingFacility|ReceivingApp|ReceivingFacility|20230630120000||VXU^V04^VXU_V04|MSG000007|P|2.5.1|||ER|AL|||||Z22^CDCPHINVS|

In this example, the message declares that it follows profile Z22 from the CDC immunization guide. The identifier is the source's claim that the message conforms to that profile, and a destination can select its validation rules from it. Most messages leave MSH-21 empty, and most interfaces identify the profile by other means, such as the connection on which the message arrives.

Validation

Conformance has two sides: the source sends only messages that the profile permits, and the destination accepts every message that the profile permits. A destination that rejects a message the profile permits is non-conformant in the same way as a source that sends a message the profile forbids.

Conformance is tested by comparing each message with the profile, element by element, and reporting every discrepancy: an empty required field, too many repetitions, a code that the profile does not allow, or a segment in the wrong position. A destination that validates incoming messages reports these discrepancies to the source in its acknowledgment, as described under Acknowledgments.

A machine-readable profile allows this testing to be automated. HL7 publishes an XML schema for profiles, and the US National Institute of Standards and Technology (NIST) maintains tools for authoring profiles and testing messages against them. A machine-readable profile can also generate example messages and test cases, which keeps them consistent with the profile.

Trade-offs

Profiles turn the flexibility of the standard into a precise agreement, at the cost of maintenance:

  • Precision. Each side can build to the profile and test against it, instead of negotiating every option in the standard separately for each interface.
  • Maintenance. Each interface needs its own profile. Vendors and national programs publish profiles that overlap without being aligned, and most sites keep their profiles as documents rather than machine-readable definitions.
  • Drift. A profile describes an interface at a point in time. When either system changes, the profile must change with it, or it no longer describes the messages that the interface carries.

Further reading