Ringholm-Logo Ringholm  Whitepaper Ringholm page header

HL7 Query/Response Conformance Statements

Copyright Ringholm bv © 2002,2008 All Rights Reserved.
See http://www.ringholm.com/docs/00500_en.htm for the latest version of this document.
Author: Frank Oemig - Associated Sr.Consultant, Ringholm bv
Document status: Final 1.7 (2005-12-17)
Please send questions and comments to frank@oemig.de.


Query/Response Conformance Statements are used to specify the behavior and format of HL7 query messages and their related response messages. Even though 95% of all HL7 query interfaces are relatively straightforward Conformance Statements contribute to the goal of creating testable and verifyable HL7 message interfaces. Query/Response Conformance Statements are defined in chapter 5 of HL7 version 2.4 and higher.

1. Introduction

The core elements of the HL7 standard are Message Structures and Trigger Events. A Trigger Event refers to a real-world event which causes a related message structure to be sent. The exchange of a message between applications is referred to as a message interaction.

HL7 supports three different message interaction models:

  • Declarative: an informative notification of something that has happened.
  • Imperative: the receiver is ordered/requested to do something.
  • Interrogative: the receiver has to respond with a copy of its data.

In case of the declarative message interaction model, the Trigger Event is caused by an event within a sending application (e.g. a patient has been discharged, a discharge note has been finalized). The application transmits a message once a Trigger Event occurs to notify others of the event. A distribution mechanism ensures that all systems which might need this information will receive a copy of this message. The sending application or a message broker may be responsible for the distribution of the messages. The receiving application may have to respond to the message with an acknowledgement if the sending application so requested in its message.

In case of the imperative message interaction model, the Trigger Event is caused by an event within an application (e.g. a lab order has been created). The application transmits a message once a Trigger Event occurs. The message contains a service request which has to be performed by the receiving application (e.g. "perform this laboratory order"). The receiving application has to respond with an application level response as soon as the requested task has been performed. (e.g. as soon as the laboratory results become available).


In case of the interrogative message interaction model, the Trigger Event is related to the receipt of a query message. The application which receives the query message has to respond with a response message.

2. Query Variations

Query messages and Response message can be constructed in various ways. During the development process of the various HL7 version 2.x standards new ways of specifying queries have been added.

The method of specifying Query Parameters can be done in one of three ways:

  • Query by parameter: passes the input parameters as successive fields of the QPD segment. This solution has the advantage that all parameters are sent in one single segment. The contents of the QPD segment are described in the Query/Response Conformance Statement.
  • Query by example: search parameters are passed by sending them in the segments which naturally carry them (e.g. the patient identification is transmitted in the PID segment).
  • Query by selection criteria: transmits the parameters in the form of an expression. This option allows for complex queries using operators (e.g. "equal" or "less than"). This method of querying can be compared with a SELECT WHERE SQL statement.
Independent of the exact way in which the query parameters were specified, the desired format of the response can be one of three different formats:

  • Segments oriented: the response is a "classic" HL7 message incorporating existing segments.
  • Table oriented: the response contains a new repeating segment. The fields in this segment represent the columns of a single row of the response table.
  • Formatted text: to be used for printing or display purposes.
Over 95% of all HL7 query implementations are based on Query By Parameter query messages and Segment Oriented response messages.

Given that there are many variations in the structure of query and response messages, you need to have a way of formally describing them. HL7 versions 2.4 and higher address this by provide a means for this purpose by way of Query/Response Conformance Statements. The next section describes the various parts of a Query/Response Conformance Statement.

3. Structure of a Query/Response Conformance Statement

A Query/Response Conformance Statement is comprised of optional as well as mandatory parts, which can be combined according to the type of query. Each part can be represented in form of a table. A Query/Response Conformance Statement is comprised of the following parts:
  • Introduction
  • Query and response message
  • Specification of the query parameters
  • Response control
  • Virtual table for in-/output
  • Formatted text for display

The introduction contains an overview of the Query and its related Response in terms of event codes and message types. An example is shown below.

Query Statement ID: Z99
Type: Query (or Publish)
Query Name: Who Am I
Query Trigger (= MSH-9): QBP^Z99^QBP_Q13
Query Mode: Both
Response Trigger (= MSH-9): RSP^Z84^RSP_K13
Query Characteristics: Returns response sorted by PatientLastName unless otherwise specified.
Purpose: Find the identity of the patient for specified medical record number(s)
Response Characteristics: Returns response sorted by PatientLastName unless otherwise specified.
Based on Segment Pattern:  

The structure of the Query and the Response messages are described using the standard abstract message syntax definition tables. If the structure of a response message is equal to that of a message published in the standard a reference to the message structure suffices.
Three columns related to the specification of conformance details have been added to the message definition table. The table also allows for the identification of a specific group of segments by means of a group name. The group names can be used to restrict the depth of the response message.

Based on the example message definition table shown below: using the group name the Conformance Statement could identify if the response should contain both the OBRG group and the OBXG group, or only those segments contained in the OBRG group.

ORU^R01^ORU_R01Response Grammar: ORU MessageGroup ControlCommentSupport Indicator Sec Ref.
{ OBRGBegin OBR Group  
 [ ORC ]Order Common   4.5.1
 OBRObservations Report ID   7.4.1
 [{ NTE }]Notes and Comments   2.16.10
 { OBXGBegin OBX Group  
 [ OBX ] Observation/Result   7.4.2
 [{ NTE }]Notes and Comments    
 }  Close OBX Group  
 [{ CTI }]Clinical Trial Identification   7.8.4
 }  Close OBR Group  

If there are no existing segments in the HL7 standard that match the requirement of the response message, a Table oriented response should be used instead of a Segment oriented response. The RDT and RDF segments contained in Table oriented response messages control the contents and the structural definition of the table including data types, optionalities and other conditions.

ColName (Query ID=Z99)Key/ SearchSortLENTYPEOptRepMatch OpTBLSegment Field NameService Identifier CodeElement Name
Patient ListSY20CXO   PID.3 PID-3: Patient Identifier List
Patient Name  48XPN    PID.5 PID-5 Patient Name
Mother's Maiden Name  48XPN    PID.6 PID-6 Mother's Maiden Name
DOB  26TS    PID.7 PID-7 Date/ Time of Birth
Sex  1IS    PID.8 PID-8 Sex
Race  80CE    PID.10 PID-10 Race

If the response is in the form of Formatted Text the Query/Response Conformance Statement contains an example of the response message.

The data will display as follows: (Query ID=Z99)


4. Conclusion

Query/Response Conformance Statements are a very useful mechanism to document the structure of Query and Response messages. Especially for complicated queries its use should be seen as mandatory.

Query/Response Conformance Statements, which relate to Query and Response messages (and the structure of which is defined in chapter 5) should not be confused with Message Conformance Profiles, which relate to all HL7 messages. The structure of Message Conformance Profiles is defined in chapter 2.12.

5. References

[HL7] "HL7 2.5", 2005, http://www.hl7.org/, chapter 5 "Query".

About Ringholm bv

Ringholm bv is a group of European experts in the field of messaging standards and systems integration in healthcare IT. We provide the industry's most advanced training courses and consulting on healthcare information exchange standards.