The Demo site for our new HL7 Version 2+ (plus) Standard
visit the hl7 website

Draft Website - For Review Purposes Only

Query

Chapter Co-Chair and Editor

Anthony Julian
Mayo Clinic

Chapter Co-Chair

Nick Radov
United Healthcare

Chapter Co-Chair

Dave Shaver
Corepoint Health

Chapter Co-Chair

Sandy Stuart
Kaiser Permanente

Chapter Editor Emeritus

Peter Gilbert
Meridian Health Plan

Sponsoring Committee:

Infrastructure and Messaging

List Server:

inm@lists.hl7.org


INTRODUCTION

This chapter defines the rules that apply to queries and to their responses. It also defines the unsolicited display messages because their message syntax is query-like in nature.

Version 2.4 of the standard introduced new models for query and response messages. The layout of this chapter is structured such that all information pertaining to those newly defined query/response message pairs, including auxiliary protocols, appears in sections 5.2–5.9 and the previously defined queries appear in section 5.10. Outstanding issues appear in the final section, 5.11.

Topic

Section Reference

Introduction

5.2

Query/Response Model

5.2.1

Evolution of the Query Standard

5.2.2

Query Development Methodology

5.2.3

Response Formats

5.2.4

Query Specification Formats

5.2.5

Summary Chart of Query/Response Pairs

5.2.6

Query/Response Profile

0

Query/Response Message Pairs

5.3.3.4

Query/Response Message Segments

0

Auxiliary Query Protocols

5.6

Publish and Subscribe

5.7

Query Implementation Considerations

5.8

Query/Response Message Examples

5.9

Superseded Query/Response Trigger Events and Message Pairs

5.10

Display Messages

5.10.1

Original Mode Queries

5.10.2

Outstanding Issues

5.11


The Standard embraces the most common queries that are likely to occur. These are defined by the functional chapters. The following represents typical examples of queries supported by the Standard:

  1. data regarding a single patient, e.g., send all lab results for patient #123456

  2. data regarding multiple patients, e.g., send the list of patients whose attending physician is Dr. #123

  3. data that is not patient related, e.g., send the age specific normal values for serum protein.

  4. data within a specified time range, e.g., send all serum glucose results, reported between January 1, 1998 through December 31, 1999, for patient #123456.

The variety of potential queries is almost unlimited. There was no attempt here to define a Standard that would cover every possible query. Chapter 5 discusses general ways query/response pairs are structured. Functional chapters discuss specific query/response pairs required for their needs. The technical committees responsible for functionally-specific chapters define detailed content of the query/response segment patterns within those chapters.

In particular, there is no implication that a specific system SHALL support generalized queries or Conformance Statements to comply with the Standard. Rather, these transactions provide a format, or a set of tools to support queries to the extent desired by the institution. The resources available and local policies will influence the type of queries that MAY BE implemented.

Query/response model

A query with its response should be thought of as a message pair. The following illustration shows the three generic models of message pairs: the declarative, interrogative, and imperative. Within each model, one system assumes the role of initiator and the other system assumes the role of responder. HL7 queries follow the "interrogative" style of messaging as described below.

Note: All messaging in HL7 assumes a single basic paradigm using a point-to-point transmission of an initial message from a sender to a receiver, followed by a response or acknowledgement message from the receiver back to the sender. The response/acknowledgment message may be optional depending on several use cases that will be discussed below. The point-to-point transmission is defined independent of any particular technology or architecture.


The declarative model is employed for distribution or broadcast of unsolicited events such as the ORU and RDS. Clients (interested parties) that desire information that resides on a Server or data owner may "subscribe" to be updated when new information is available on the Server. The Server initiates a transmission of event information. This transmission may be to a single Client, or may be a broadcast to multiple Clients. Each Client responds with an acknowledgement of receipt.

The interrogative model is employed for queries. A Client initiates a query (a request for data) to the Server. The Server processes the query, responds with a report of success or failure of the query to the Client, and further responds by delivering information requested by the query.

The imperative model is employed for remote interoperation. A Client initiates a request for action (such as an order) to the Server. The Server processes the request and responds with a report of success or failure to the Client.

Note: In HL7 v2, there is no formal assumption of client-server architecture, or of a particular "publish and subscribe" architecture. Thus the roles of the intercommunicating applications may change according to the messaging needs. i.e., an application may be a data owner or Server for one set of messages (e.g., an order entry system creating orders), and an interested party or Client for another set of messages (e.g., an order entry system receiving order status messages from an ancillary departmental system). Furthermore, the "data owning" system may be a middleware component such as an "application server" or a "messaging gateway" or "router" that distributes information from a server application. In the discussions below, "Client" and "Server" are used as shorthand synonyms for "requesting system/application" and "responding system/application" without implying the assumption of a client/server architecture. Likewise, the support for "publish and subscribe" does not assume a particular operating system or architecture, but is defined at the application level (level 7), in a technology-neutral form. The phrase "data owner" is used to refer to the human institution that operates the Server program. One would say that "the data owner defines the data to be made available by the Server program."


Evolution of the query standard

The Query Standard, like the HL7 Standard in general, has been evolving since its inception in Version 2.1. Version 2.4 introduced a new methodology intended to supersede the previous generation of queries.

Original Mode Queries

Originally, the parameters of an HL7 query were carried by the QRD and QRF segments. Because these segments were intended to be used by all queries, the content of these segments could only be loosely defined. Such "original mode queries" actually represent just a starting point for defining queries.

In these original mode queries, separate trigger events were used to differentiate between an immediate response and a deferred response. In addition, some of the functional chapters defined queries and responses with separate trigger events.

Enhanced Mode Queries

In HL7 v 2.3, "enhanced mode queries" were introduced that attempted to provide for a much higher level of precision in queries. Four new ways of specifying a query were introduced in Version 2.3.

  • An Embedded Query Language query, which supports free-form select statements, based on the query language of choice (e.g., SQL)

  • a Virtual Table request query which supports queries against server database tables (virtual or actual) based on specific selection criteria

  • a stored procedure request, which enables an application on one system to execute a stored procedure on another system, which is coded to extract specific data

  • an event replay request message, which is used to request data formatted as an event replay response

"Enhanced Mode" introduced three new ways to pass data to the responding system (e.g., a Server).

  1. Passing values to specific parameters of a query. (Used by the stored procedure and event replay queries.) This is the most common and straightforward technique for creating queries. The drawback is that the client is tightly limited in the range of queries it can formulate.

  2. Passing the query as a single complex query "expression". (Used by the Virtual Table query.) The query is defined by an expression-tree made up of the usual AND OR, '<' , '>', ... Operators can refer to column names or variables defined by the Server. These Queries give the Client significant flexibility in specifying their query over the columns that the Server has permitted. The cost of this Client flexibility is that the Server SHALL evaluate the query expression, rather than simply plug parameter values into an existing stored procedure.

  3. Passing the query as a single string in an existing database query language such as SQL. (Used by the EQL External Query Language query.) An EQL query is represented as a string formatted in the particular syntax of an existing query language. The Server will probably pass this string expression directly to an existing database engine to evaluate the query, which will have to parse this expression to recover the query. The drawback of this technique is that different database engines use different query languages, and so the exact query string which the Client constructs will depend on the Server's query language.

Also in Version 2.3, the use of the trigger event was moving closer to the definition set forth in chapter 2. Each offered query had its own trigger event. In Version 2.3.1 each response had its own trigger event.

Version 2.4 Queries

Users of v 2.3 queries encountered some somewhat arbitrary limitations suggested by the v 2.3 standard. A close reading of the v 2.3 virtual table query wording made it appear that the only way a query could be specified by a QSC selection expression was if it returned tabular (RDT) results, and it seemed that query-by-parameter queries could not return tabular results.

Versions of the HL7 standard after v 2.3.1 more cleanly separate how a query is specified from how the data is returned, and they emphasize the existence of a "Conformance Statement." HL7 continues to support the semantics of the Stored Procedure/Event Replay queries and the Virtual Table queries, but formulates the syntax more clearly using a single new query, the Query By Parameter (QBP).

The QBP query is intended to unify the semantics of the stored-procedure, event-replay and virtual-table queries within the framework of a precise conformance statement.

The standard recognizes the continued use of the Original Mode queries (QRD/QRF), but uses a new query formalism to explain their semantics more clearly.

The bulk of the new material after Version 2.3.1 consists of defining a format for Conformance Statements, and giving examples of query design and use.

Note: Version 2.5 introduced a new, use-case-based mechanism for conformance in Section 2.12 of Chapter 2. Query implementers are encouraged to review and, where appropriate, adopt the profiling structures outlined in that section. Conformance Statement structures introduced in Version 2.4 have been renamed Query Profiles.


Compatibility with past versions

For backward compatibility, both the "original" and "enhanced" queries remain in the standard, but their description has been relegated to a "for backward compatibility only" section. The main part of this chapter is a complete and consistent explanation of the recommended approach to HL7 queries in Version 2.4 and later.

As in versions of the standard prior to 2.4, the detailed domain content of the query and response messages is defined by the technical committees responsible for the functionally-specific chapters; the basic forms and methodology for queries and responses are defined in this chapter.

Sections 5.2.4, "Response format," and 5.2.5, "Query specification formats," discuss Response Formats and Query Specification Formats.

Query development methodology

Typically, an individual HL7 conformant query would evolve as follows:

An institution, or data owner, decides that it would like to make information available via a query. It decides precisely what data will be made available and how it will be offered. Knowing its own data, the data owner will define its query to return one of three representations of the data:

  1. As traditional HL7 segments. (See section 5.2.4.1, "Segment pattern response.")

  2. As rows and columns of data from a precisely defined Virtual Table. (See section 5.2.4.2, "Tabular response.")

  3. As rows of human readable text ready to output to a screen or printer. (See section 5.2.4.3, "Display response.")

Next, the data owner specifies exactly which input variables the Client can use to control the data that the Server agrees to return.

The complete specification of what data are available, how the data will be returned, and what variables can be valued or constrained in a Query is called the Query Profile.

The Query Profile concept is critical to the proper usage of the query/response pair. In the absence of a Query Profile, the Client would be unaware of the existence of the query, let alone how to use it or what to expect from it. The data owner advertises the existence of, and support for, a query by publishing a Query Profile.

The Query Profile has the following broad structure:

Introduction including title, trigger events, mode, characteristics and purpose

Query Grammar

Response Grammar

Input Specification and Commentary

Response Control

Output specifications and Commentary


Query Profile: A declaration which sets forth the name of the query supported by the Server, the logical structure of the information that can be queried, and the logical structure of what can be returned.


Section 0, Note that the Vaccination Query related messages have been removed as these were deprecated and withdrawn as of v 2.8.

Acknowledgment Choreography

As of Version 2.9 Infrastructure and Messaging requires that Acknowledgment Choreography be explicitly specified in MSH-15 and MSH-16. Because of the nature of the Query and Response Messaging pattern, the Response message is always an Application Acknowledgment. To specify this, the value in MSH-16 SHALL always be “AL” to indicate that there will always be an Application Acknowledgment to the Query Message. See Chapter 2 for more details on this subject.

QUERY/RESPONSE PROFILE," will explain the Query Profile in detail.

The next section elaborates on the three styles of response data (segment pattern, tabular, and display) that a data owner may use to represent its data.

The introduction of the Query Profile concept is not intended to imply system certification. It is intended to promote well-specified queries. As in previous versions, support for queries is not required for HL7 conformance.

Response format

The first decision a data owner SHALL make in formulating a query is to decide which style of representing data is most appropriate for their needs.

HL7 recognizes three main styles of representing responses to queries: tabular, segment pattern, or display. Segment pattern and tabular were previously known as record-oriented as described in earlier versions of this Standard. Segment pattern responses consist of a set of HL7 segments. Each query will define, in its Query Profile, the precise grammar of HL7 segments that it will return. Tabular responses return data as a set of rows, one RDT segment per row. Display queries return data in DSP segments. An HL7 conformant system interested in supporting queries will choose one or more of these styles before proceeding with a detailed design.

Tabular

The responding system formats the data in a relational format, as rows and columns.

Segment pattern

The responding system formats the data on the basis of an application-specific segment-oriented (record-oriented) message.

Display

The responding system formats the data in human readable format for direct outputting to a display device (in both original and enhanced modes).


These structures support all original mode and enhanced mode responses, as well as the Conformance Based Queries.

Segment pattern response

Segment Pattern data responses reflect the traditional way of offering data within HL7. The Server responds to queries by returning a pattern of HL7 segments. For example, the core of a response to a query for Lab data might be defined by the following segment grammar:

{PID

OBR

[{OBX}]

}

For example, patient information will be returned in the PID segment and laboratory results in OBR and OBX segments. In this style, the message returned by a Server is often a close approximation to an existing unsolicited update HL7 message.

In creating a Query Profile for a segment pattern response, the data owner SHALL decide on the exact segment grammar it will return. The output specification of the Query Profile for a segment pattern response will have a structure very similar to the message definition of a standard HL7 transaction. It SHALL define a grammar of segments that will be returned, and, for each segment, it should clarify, where necessary, the meaning of each field, the cardinality of the data, and whether the data is optional or required.

Tabular response

A data owner may decide that the best model for the data it wishes to offer is that of a fairly conventional table of rows and columns. In this case, a data owner advertises support for a straightforward ("virtual") table of data, with specific columns of specific data types. It further indicates which of the columns the Client can constrain in its query. The response to a query will be in the form of a set of rows from the advertised table.

The Virtual Table is an abstraction around a traditional database table. However, there are important differences between a traditional database table and the Virtual Table. The Virtual Table need not be based on a single table or collection of data. It may represent a "join" or combination of data among database tables (although the "join" or combination is not explicitly exposed to the Client).

The concept of table, borrowed from the relational database world, is used merely as a representational aid. The actual internal data structure of the Server need not be relational. Virtual Tables may be used to present data elements from internal structures that are hierarchical, object-oriented, or otherwise non-relational in nature.

Virtual Tables therefore insulate the user from the exact data layout or representation in the data source. That is to say, the requestor need not understand the structure of the tables, rows and columns of the database being queried but only the structure of the Virtual Table representation. Likewise, the responder (database owner) does not have to expose the structure of the real database. Neither the owner nor the requestor needs to worry if the structure of the database changes.

The rows and columns of the Virtual Table for a query are fully described in the Query Profile for that query.

A virtual table data representation is appropriate when the information being offered is relatively simple. It would not be the appropriate representation for lab reports that typically involve a complex nesting of results into sections. Data carried by the typical HL7 segment or segment group could be modeled as a virtual table. For example, the ADT system might offer a table consisting of the fields of PID, NK1 and a single PV1 segment. On the other hand, it would be difficult to represent the visit history of a patient in a single virtual table.

Display response

A display message can be generated where the update information does not need to be captured by the receiving system's database, but only displayed, either on a visual medium (such as a PC, workstation or a CRT) or on printed medium.

The display response does not actually represent a formal style of data organization. It represents a decision to return data formatted for human, rather than for computer, consumption. The Server offers a pretty-printed version of the data in a format that is meaningful for human readers. Logically, the content of the pretty-printed message might be the complex data carried by an HL7 segment pattern, or could be a simple record normally carried by a tabular response.

Choosing among available response formats

In practice, it is easy to decide which style of data to offer. In general, segment pattern responses are able to carry complex data structures (e.g., an entire laboratory report) while tabular responses are typically simple data structures. Therefore, tabular response is intended as a simpler tool to accomplish a simpler task. There is no need for the Client to understand, parse and process the deep structure and relationships implied by the segment pattern response. The Client does not need a complex state machine to do segment level parsing. The rows all have the same structure so only a simple state machine is needed.

If the query is defined by an HL7 technical committee, then the decision is already made. If, on the other hand, no query is yet defined but the domain of the data is well covered by HL7, then it is probable that there are existing HL7 segments that could carry the data. A Z query may be constructed out of the existing HL7 segments. If the data is site specific, the site can either create its own Z segments and offer a segment pattern response (which makes particular sense if the overall data is complex) or it can define its own Virtual Table, offer a tabular response and let the Client process each record.

Once it is known what data a Server is making available, then the data can be ordered or requested. This is analogous to needing to refer to a catalog before ordering an item by mail.

Query specification formats

The previous section explained the three representations for data that are returned to a query client. This section discusses how the client may represent a query for information.

HL7 now recommends one primary way with 3 basic variants for specifying a query.

This query model with its variants is intended to assist implementers in translating specific query needs from the ordinary prose of the business model into an appropriate HL7 query paradigm. The paradigm selected will depend upon the philosophy of the institution: whether to allow relative freedom to client systems in composing query expressions, or to control rigidly the fields and operations to be offered. The following paragraphs compare and contrast the features of each of the HL7 query variant models. The differences between them lie mainly in the processing they require on the Server side.

Query by Simple Parameter

The first variant is called the Simple Parameter query. In the simple parameter query, the input parameters are passed in order as successive fields of an HL7 segment. The Server need only read them from the corresponding HL7 fields, and plug them into an internal function to evaluate the query.

This is the most basic form of the query in which the Server specifies a fixed list of parameters in its Query Profile. (For example, the Server may direct the querying system to specify a medical record number, a beginning date, and an ending date.) When invoking the query, the Client passes a specific value for each parameter. This is analogous to invoking a stored procedure against a database.

The parameter definition segment (i.e., the QPD) can be seen as a generalization of the QRD and QRF segments of the original mode query. Each field in the QRD and QRF corresponds to 1 parameter of the QPD instance. HL7 recommends that queries defined by QRD and QRF segments be recast as a version 2.4 or later Query By Parameter.

The obvious implementation gain is that the Server can simply map the input values to the parameters specified in the Query Profile. An already known function or procedure is called to evaluate the query and select data to be returned. The bulk of the work effort has already been invested in the development of this predefined function or procedure.

Query by Example Variant:

The Query by Example (QBE) is an extension of Query by Parameter (QBP) in which search parameters are passed by sending them in the segment which naturally carries them, instead of as fields of the QPD segment. For example, if one wanted to perform a "find_candidates" query using QBE, one would send the demographics information on which to search in the PID and/or PD1 segments, leaving blank those fields in the segment sent that are not query parameters. If, for example, religion were not one of the query parameters, PID-17 would be left blank when the PID was sent in the query. Parameters which do not occur naturally in an HL7 message, such as search algorithm, confidence level, etc., would continue to be carried in the QPD segment as they are in the Query by Parameter. The exact segments and fields available for use as query parameters would be specified in the Query Profile for the query.

Query Using the QSC Variant:

The third variant is known as the QSC variant because of its use of the QSC data type, which was used in the Virtual Table query. The Query Profile for the query will define all the variables that the Client may use in an expression. At runtime, the Client is able to define the exact search criteria by constructing a "tree" of operator/operand nodes that constrain the available input parameters. To evaluate the query, the Server SHALL be willing to analyze and interpret the query expression at runtime. The Server may translate the input expression into its local data access language, or perhaps it will interpret the request itself, and evaluate the expression for each item of the virtual table. The client's Complex Expression is analogous to an SQL selection statement against a relational database.

This variant is most like the Virtual Table Query (VQQ).

There are a number of factors to consider in determining which variant to offer. In the Complex Expression (QSC) variant, the Client may select any or all of the variables offered and may specify any permissible operators and values for each variable. By contrast, in the Simple Parameter variant or the Query by Example variant, the Client SHALL provide values for exactly the set of variables offered.

The Simple Parameter variant is easy to parse and process because it has positional fields; i.e., the parameters are in a predefined and fixed order. Likewise, the Query by Example variant lends itself to simple processing, since parameters will occur in known positions in defined segments. The Complex Expression variant, on the other hand, requires more involved parsing and processing because of its flexibility and the optionality of its elements. Thus, while the Complex Expression variant offers more functionality to the Client, it is more burdensome for the Server to process. Conversely, the Simple Parameter and Query by Example variants offer less functionality to the Client but are generally easier for the Server to implement; they are often based on existing stored procedures on the Server's system.

Expressing the same data using the variants

The following is an example of a query stated in all three variant forms. This example is presented to illustrate the utility of each format for the purpose of offering a query. Which format to use depends upon the level of processing complexity to be implemented on the Server and the degree of specification flexibility required by the Client.

The purpose of the query is to allow a simple inquiry upon an administrative database. Suppose a patient information request is submitted by the Client. The Server is to respond with demographic information: patient's date of birth, sex, and ZIP code.

Expression as simple parameters

As we have seen, this variant requires an exact parameter specification.

The client system transmits a QBP query message in the following format:

MSH|^~VALUEamp;|FEH.IVR|HUHA.CSC|HUHA.DEMO||199902031135-0600||QBP^Z58^QBP_Q13|1|D|2.8

QPD|Z58^Pat Parm Qry 2|Q502|111069999

RCP|I

The names of the input and output fields are not specified in the query message, but by the Query Profile, identified by QPD-1-message query name. The MSH-9.2-trigger event and the QPD-1-message query name are this query's only distinguishing elements. The requesting system SHALL refer to this query's Query Profile to learn more about the input and output fields.

Expression as query by example

Just as in the Simple Parameter variant, the Query by Example requires an exact parameter specification. The distinction in a Query by Example is that segments other than QPD are used to transmit the parameters. The segments offered should be already-existing segments that the Server can parse easily.

The client system transmits a Query by Example in the following format.

MSH|^~VALUEamp;|FEH.IVR|HUHA.CSC|HUHA.DEMO||199902031135-0600||QBP^Z58^QBP_Q13|1|D|2.8

QPD|Z58^Pat Parm Qry 2|Q502

RCP|I

Parameters used in this query are specified in the Query Profile.

Expression as a complex expression

In contrast, the Complex Expression variant allows flexible input specifications. This allows more choices for the Client system, but can require more complex processing capability on the part of the Server System.

If the above Simple Parameter variant were to be stated as a Complex Expression, it might look like this.

MSH|^~VALUEamp;|FEH.IVR|HUHA.CSC|HUHA.DEMO||199902031135-0600||QBP^Q13^QBP_Q13|1|D|2.8

QPD|Z999^Pat Sel Qry 1|Q501|@MedicalRecordNo^EQ^111069999

RCP|I

Note the explicit statement of the input field name in QPD-3-user parameters. Also, note that this query might be used to specify and request other fields, depending upon the specification of what is permitted by the server system's Query Profile.

Query Modalities

Simple Parameter Variant

The Server specifies parameters and the Client passes specific values to the parameters when the query is invoked.

Complex Expression Variant

The Server offers variables which can be used by the Client who passes a constraining expression (subject to any limitations specified by the Query Profile) over those variables when invoking the query.


Using the new modalities shown in the table, the variety and number of queries is almost unlimited. There is no implication that a specific Server must support all of these potential generalized queries to comply with the Standard. Rather, these transactions provide a format, or a set of tools, to support queries to the extent desired by the institution. The resources available and local policies will influence the types of queries that are implemented.

Summary chart of query/response pairs

The following chart delineates the query/response messages defined in chapter 5:

Description

Query

Response

Response type

Defining segment(s)

Sec Ref

Cancel query

QCN

5.4.6

Query By Parameter

QBP

QPD

5.4.1, 5.4.2, 5.4.3

Query, original Mode (withdrawn)

QRY

Original mode (withdrawn)

QRD/QRF

Display response

RDY

Display

DSP

5.4.3

Response Segment Pattern

RSP

Segment pattern

5.4.1

Response tabular

RTB

tabular

RDF/RDT

5.4.2

Unsolicited display message (withdrawn)

UDM

Display (withdrawn)

URD/URS


The following chart delineates the query/response messages defined in the functional chapters:

Description

Query

Response

Response type

Defining
segment(s)

Sec Ref

ADT response (withdrawn)

QRY^A19

ADR^A19

Original mode (withdrawn)

QRD/QRF

Allocate identifiers

QBP^Q24

RSP^K24

Segment pattern

QBP

3.3.59

Ancillary RPT (display) (for backward compatibility only)

ARD

Original mode

7

Find candidates

QBP^Q22

RSP^K22

Segment pattern

QBP

3.3.57

Get corresponding identifiers

QBP^Q23

RSP^K23

Segment pattern

QBP

3.3.58

Get person demographics

QBP^Q21

RSP^K21

Segment pattern

QBP

3.3.56

Order status query/ Order status response (withdrawn)

OSQ^Q06

OSR^Q06

Original mode (withdrawn)

QRD/QRF

Pharmacy administration information (withdrawn)

QRY^Q27

RAR^RAR

Original mode (withdrawn)

QRD/QRF

Master files query

MFQ

Original mode

8.4.3

Master files query response

MFR

Original mode

8.43

Personnel information

QBP^Qnn

RSP^Knn

Segment pattern

QBP

15.3.7

Pharmacy dispense information (withdrawn)

QRY^Q28

RDR^RDR

Original mode(withdrawn)

QRD/QRF

Pharmacy dose information (withdrawn)

QRY^Q30

RGR/RGR

Original mode (withdrawn)

QRD/QRF

Pharmacy encoded order information (withdrawn)

QRY^Q29

RER^RER

Original mode (withdrawn)

QRD/QRF

Pharmacy prescription order response (withdrawn)

QRY^Q26

ROR^ROR

Original mode (withdrawn)

QRD/QRF

Request clinical information (withdrawn)

RQC^I05

Original mode (withdrawn)

QRD/QRF

Results of observation, query for (withdrawn)

QRY^R02

ORF^R04

Original mode (withdrawn)

QRD/QRF

Return Clinical Information (withdrawn)

RCI^I05

Original mode (withdrawn)

QRD/QRF

Return Clinical List (withdrawn)

RCL^I06

Original mode (withdrawn)

QRD/QRF

Return patient referral

RRI

Original mode

11.5

Return patient referral

RRI

Original mode

11.5

Schedule query

SQM

Original mode

10.5.3

Schedule query response

SQR

Original mode

10.5.3


Note that the Vaccination Query related messages have been removed as these were deprecated and withdrawn as of v 2.8.

Acknowledgment Choreography

As of Version 2.9 Infrastructure and Messaging requires that Acknowledgment Choreography be explicitly specified in MSH-15 and MSH-16. Because of the nature of the Query and Response Messaging pattern, the Response message is always an Application Acknowledgment. To specify this, the value in MSH-16 SHALL always be “AL” to indicate that there will always be an Application Acknowledgment to the Query Message. See Chapter 2 for more details on this subject.

QUERY/RESPONSE PROFILE

The introduction of the Query/Response Profile1 concept is not intended to imply system certification. It is intended to promote the definition and implementation of well-specified queries. As in previous versions, support for queries is not required for HL7 conformance.

In the introduction, the data owner describes the data being made available and the purpose of the query. He specifies the exact coded value for the Query Name which the Client SHALL use to invoke this query.

The Query Grammar defines the exact segments the Client MAY send. For each field of those segments, the Query Profile SHALL define how the Server will interpret client values. (For example, the patient name field is interpreted as a regular expression match.)

The Response Grammar defines the exact pattern of segments that the Server will return. Each Segment Pattern Response will specify its own pattern of segments. (For example, lab data queries will return patterns of OBR and OBX, while demographic queries might respond with patterns of PID, PV1,... segments.) When a data owner defines a tabular response query, the response grammar might simply be a list of RDT segments that carry rows of data. The user selects columns from a Virtual Table to define the output for the Query by Parameter/Tabular Response (QBP/RTB).

Note that in the case of an HL7-defined query, a specific section of the HL7 Standard will define a Query Profile. By contrast, in the case of a site defined query, the Query Profile is written by analysts and programmers of the Server application/system, and is available to the analysts and programmers of the Client application/system.

Although the Query Profile was a new construct with Version 2.4, it may also be used with the previous generation queries.

Note: Version 2.5 introduced a new, use-case-based mechanism for conformance in Chapter 2. Query implementers are encouraged to review and, where appropriate, adopt the profiling structures outlined in that chapter. Current Query Profile structures are retained in Chapter 5 pending revision to the new structures in the next version of the Standard.


[1] Formerly known as the Conformance Statement, this artifact will be referred to throughout the rest of this document as the Query Profile to distinguish it from an implementor assertion of conformance to a particular profile. The Query Profile is understood to include the definition of the appropriate response message(s).

Using the Query Profile

Critical to the proper usage of the new query/response pairs is the Query Profile concept. In the absence of a Query Profile, the Client might not be aware of the existence of a query, or might not know how to use it or what to expect from it.

The Server advertises the existence of, and support for, a query by publishing a Query Profile. The Query Profile identifies the query, specifies what items can be queried and describes what the response will look like.

Query Profile: A declaration which sets forth the name of the query supported by the Server, the logical structure of the information that can be queried, and the logical structure of what can be returned.


A number of examples of Query Profiles can be found in section 5.9, "QUERY/RESPONSE MESSAGE EXAMPLES."

Query with tabular response example

The user wishes to know the identity of the patient whose medical record number is "555444222111".

MSH|^~VALUEamp;|PCR|GenHosp|MPI||199811201400-0800||QBP^Q40^QBP_Q13|8699|P|2.8||||||||

QPD|Q40^WhoAmI^HL7nnnn|Q0001|555444222111^^^MPI^MR|||19980531|19990531|

RCP|I|

RDF|6|PatientList^CX^20~PatientName^XPN^48~Mother'sMaidenName^XPN^48~DOB^DTM^24~Sex^IS^1~Race^CWE^80|

The MPI system returns the following RTB message

MSH|^~VALUEamp;|MPI|GenHosp|PCR||199811201400-0800||RTB^K13^RTB_K13|ACK9901|P|2.8||||||||

MSA|AA|8699|

QAK|Q0001|OK|Q40^WhoAmI^HL7nnnn|1|

QPD|Q28^WhoAmI^HL7nnnn|Q0001|555444222111^^^MPI^MR|||19980531|19990531|

RDF|6|PatientList^CX^20~PatientName^XPN^48~Mother'sMaidenName^XPN^48~DOB^DTM^24~Sex^IS^1~Race^CWE^80|

RDT|555444222111^^^MPI^MR|Everyman^Adam||19600614|M||

Example of Query Profile with tabular response

Query Profile

Query Statement ID (Query ID=Z99):

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_Z84

Query Characteristics:

Returns response sorted by PatientLastName unless otherwise specified. Note that neither the PID nor the RDF segments are used.

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:


QBP^Z99^QBP_Q13: Query Grammar: QBP Message
HL7 MessageStructure Table - QBP_Q13
Segment Cardinality Must Implement Status
QBP_Q13
MSH 1..1 Yes
SFT 0..*
UAC 0..1
QPD 1..1 Yes
PID 0..1
RDF 0..1
RCP 1..1 Yes
RDF 0..1
DSC 0..1

Original Mode Acknowledgement Choreography for QBP^Z99^QBP_Q13

Send Application Ack: RSP^Z84^RSP_Z84

Enhanced Mode Acknowledgement Choreography for QBP^Z99^QBP_Q13

When the MSH-15 value of a QBP^Z99^QBP_Q13 message is AL or ER or SU, an ACK^Z84^ACK message SHALL be sent as an immediate ack.

When the MSH-15 value of a QBP^Z99^QBP_Q13 message is NE, an immediate ack SHALL NOT be sent.

When the MSH-16 value of a QBP^Z99^QBP_Q13 message is AL, a RSP^Z84^RSP_Z84 message SHALL be sent as an application ack.

When the MSH-16 value of a QBP^Z99^QBP_Q13 message is NE or ER or SU, an application ack SHALL NOT be sent.

Field Value Send Response
MSH-15 AL, ER, SU immediate ack: ACK^Z84^ACK
NE (none)
MSH-16 AL application ack: RSP^Z84^RSP_Z84
NE, ER, SU (none)

RSP^Z84^RSP_Z84: Response Grammar: RTB Message
HL7 MessageStructure Table - RTB_K13
Segment Cardinality Must Implement Status
RTB_K13
MSH 1..1 Yes
SFT 0..*
UAC 0..1
MSA 1..1 Yes
ERR 0..1
QAK 1..1 Yes
QPD 1..1 Yes
ROW_DEFINITION 0..1
RDF 1..1 Yes
RDT 0..*
DSC 0..1

Original Mode Acknowledgement Choreography for RSP^Z84^RSP_Z84

Send An Acknowlegment is never sent in original mode.

Enhanced Mode Acknowledgement Choreography for RSP^Z84^RSP_Z84

When the MSH-15 value of a RSP^Z84^RSP_Z84 message is AL or ER or SU, an ACK^Z84^ACK message SHALL be sent as an immediate ack.

When the MSH-15 value of a RSP^Z84^RSP_Z84 message is NE, an immediate ack SHALL NOT be sent.

Never send an application ack in enhanced mode.

Field Value Send Response
MSH-15 AL, ER, SU immediate ack: ACK^Z84^ACK
NE (none)
MSH-16 NE (none)

QPD Input Parameter Specification

Field Seq (Query ID=Z99)

Field Name

Key/

Search

Sort

LEN

TYPE

Opt

Rep

Match Op

TBL

Segment Field Name

Service Identifier Code

Element Name

1

MessageQueryName

60

CWE

R

2

QueryTag

32

ST

R

3

PatientList

S

Y

20

CX

O

PID-3

PID-3 Patient Identifier List


QPD Input Parameter Field Description and Commentary

Input Parameter (Query ID=Z99)

Comp. Name

DT

Description

MessageQueryName

CWE

SHALL be valued Z99^WhoAmI^HL7nnnn.

QueryTag

ST

Unique to each query message instance.

PatientList

CX

Components: <ID (ST)> ^ <check digit (ST)> ^ <code identifying the check digit scheme employed (ID)> ^ < assigning authority (HD)> ^ <identifier type code (IS)> ^ < assigning facility (HD)>

The combination of values for PatientID, and PatientIDAssigningAuthority, are intended to identify a unique entry on the PATIENT_MASTER table. The PatientIDTypeCode is useful for further filtering or to supply uniqueness in the event that the assigning authority may have more than one coding system. (The PATIENT_MASTER table contains a constraint that prevents multiple patients from being identified by the same combination of field values.) This PATIENT_MASTER entry will be searched against on the PHARMACY_DISPENSE_TRANSACTION table to retrieve the rows fulfilling the query conditions.

If this field is not valued, all values for this field are considered to be a match.

ID

ST

If this field, PID.3.1, is not valued, all values for this field are considered to be a match.

Assigning Authority

HD

If this field, PID.3.4, is not valued, all values for this field are considered to be a match.

Identifier Type Code

CWE

If this field, PID.3.5, is not valued, all values for this field are considered to be a match.


RCP Response Control Parameter Field Description and Commentary

Field Seq (Query ID=Z99)

Name

Component Name

LEN

DT

Description

1

Query Priority

1

ID

(D)eferred or (I)mmediate. Default is I.

2

Quantity Limited Request

10

CQ

Quantity

NM

Number of units (specified by the following component) that will be returned in each increment of the response. If no value is given, the entire response will be returned in a single increment.

Units

CWE

CHaracters, LInes, PaGes, or RecorDs. Default is LI.

3

Response Modality

60

CWE

Real time or Batch. Default is R.

6

Sort-by Field

256

SRT

Sort-by Field

ST

Segment field name of an output column by which the response may be sorted. SHALL contain a Y in the Sort column of the output specification table.

Sequencing

ID

As specified in HL7 Table 0397- Sequencing. Default is Ascending.


Output Specification and Commentary: Virtual Table

ColName (Query ID=Z99)

Key/

Search

Sort

LEN

TYPE

Opt

Rep

Match Op

TBL

Segment Field Name

Service Identifier Code

Element Name

PatientList

S

Y

20

CX

O

PID.3

PID-3: Patient Identifier List

PatientName

48

XPN

PID.5

PID-5 Patient Name

Mother'sMaidenName

48

XPN

PID.6

PID-6 Mother's Maiden Name

DOB

24

DTM

PID.7

PID-7 Date/Time of Birth

Sex

1

CWE

PID.8

PID-8 Sex

Race

80

CWE

PID.10

PID-10 Race


Formal specification of the Query Profile

The Query Profile contains the following information:

  • Query Profile ID: The unique identifier applying to this query's Query Profile. This value is transmitted as the first component of QPD-1-Message query name. For sites implementing the Conformance SIG's Implementation Guide, this value shall also be transmitted in MSH-21-Query Profile ID.

  • Formal Query Name: identifies a unique query or publication, e.g., PharmacyDispenseHistory.

  • Query Trigger: identifies the trigger event for the query. Note that more than one Query Profile may map to the same generic trigger event (Q10 through Q15). If a non-generic trigger event is used, it should correspond to exactly one Query Profile.

  • The use of Q for HL7-standard query trigger events is conventional; another letter may be used if the supply of Q triggers is exhausted.

  • The assignment of a trigger event, while mandatory, is intended to facilitate processing rather than to identify a query uniquely. A query is uniquely identified by the value transmitted in QPD-1-Message query name. This value SHALL be the same in both the query and response messages, even though the trigger event for the query differs from the trigger event for the response.

  • Response Trigger: identifies the unique trigger event for the response. Note that more than one Query Profile may map to the same generic trigger event (K10 through K15). If a non-generic trigger event is used, it should correspond to exactly one Query Profile.

  • The use of K for HL7-standard response trigger events is conventional; another letter may be used if the supply of K triggers is exhausted.

  • Query Priority: Specifies if the query is immediate, deferred or selectable.

  • Query Characteristics: Narrative describing general feature of the query.

  • Purpose: Describes intent of query.

  • Query Grammar: defines the logical structure of what can be sent by the Client. The structure of this part of the Query Profile is very similar in appearance to a message syntax.

  • Response Grammar: defines the logical structure of what can be returned by the Server. The structure of this part of the Query Profile is very similar in appearance to a message syntax with two additional columns: Comment and Support Indicator.

  • Data Model: the logical structure of the information that can be queried. It can be thought of as a set of rows or a list of items having the same format as the Virtual Table structure described in the next section. This works for both tabular and segment pattern queries. A display query can be considered as orthogonal to the tabular and segment pattern queries and follows the same input structure. This is not always included in the Query Profile.

  • Input Parameter Field Specification and Commentary: Cites the allowable parameters that can be passed to the recipient. The structure of this part of the Query Profile is very similar in appearance to an HL7 Segment Attribute Table with several additional columns: ColName, Key/Search, Sort, MatchOp, SegmentFieldName, and Service Identifier Code.

  • A QPD Input Parameters table and corresponding explanation table is always provided. These tables discuss all the fields of the QPD segment, including QPD-1-Message query name and QPD-2-Query tag. If the query is a Query by Example, additional input parameters and explanation tables are provided for all the fields that may be populated in the example segments.

  • Response Control: Specifies execution date and time, restrictions on amount of data, and query modality. This is not always included in the Query Profile.

  • Output Specification and Commentary: Used for tabular and display response. For the tabular response, it specifies the column names that will be returned. The structure of this part of the Query Profile is very similar in appearance to an Attribute Table with several additional columns: ColName, Key/Search, Sort, MatchOp, SegmentFieldName, and Service Identifier Code. For the display response, it describes the format of the data that will be returned.

Note that in the case of an HL7-defined query, a specific section of the HL7 standard will define a Query Profile. The existence of a standard Query Profile for any given query does not mean that a system SHALL implement this particular query to be conformant to the HL7 Standard. However, systems that do implement the query SHALL follow the specifications as given in the Query Profile.

Sites that wish to offer queries not specified by the Standard may create their own Query Profiles. By contrast to an HL7-standard query, in the case of a site defined query, the Query Profile is written by the Server, and is available to the analysts and programmers of the Client system to enable them to know the exact behavior of the Server.

Although the Query Profile was a new construct with version 2.4, it may also be used with the previous generation queries.

Input Parameter Specification and Input Field Description and Commentary are always included for the QPD segment. When the Query by Example variant is used, they are provided for the QBE as well. An Output Specification and Commentary showing a Virtual Table is provided for queries that accommodate a tabular response.

For Query Profiles published in the HL7 Standard, each table includes the Query Profile ID in parentheses in the upper left-hand cell. This allows the table to be imported automatically into the HL7 database.

Steps for developing a Query Profile

  1. Before composing the Query Profile, express the query in ordinary English sentences.

  2. Transform the query into a mathematical or pseudo-language statement. A syntax such as SQL provides a useful mechanism.

  3. From the pseudo-statement, extract the parameters and the operations upon the parameters.

  4. Advertise the parameters in the Query Profile.

  5. Within the Query Profile, explain the operations that will be performed upon the parameters: relational conjunctions, equality/inequality, etc. Use examples to aid the user in understanding how the query might be invoked in specific instances.

Query Profile introduction

The Query Profile begins with a table that summarizes the characteristics and identifying information about the query to which the Query Profile applies.

Query Profile

Query Statement ID (Query ID=Znn):

Znn

Type:

Query Name:

Query Trigger (= MSH-9):

Query Mode:

Response Trigger (= MSH-9):

Query Characteristics:

Purpose:

Response Characteristics:

Based on Segment Pattern:


Query Statement ID: The unique identifier applying to this Query Profile. This value is transmitted as the first component of QPD-1-Message query name.

Type: Usually Query, except for publish-and subscribe Query Profiles (see section 5.7.3.1, "Example of a publish and subscribe Query Profile") for which the value should be Publish.

Query Name: The name corresponding to the identifier in Query Statement ID. This value is transmitted as the second component of QPD-1-Message query name.

Query Trigger (= MSH-9): The exact value that the Client will transmit in the MSH-9-Message type field of the query message.

Query Mode: Whether the query may be sent in Real time (including Bolus) or in Batch; see section 5.5.6.3, "Interactive continuation of response messages." The value Both indicates that both real-time/bolus and batch modes are acceptable.

Response Trigger (= MSH-9): The exact value that the Server will transmit in the MSH-9-Message type field of the response message.

Query Characteristics: Particular features of this query. This is free text intended to help the query implementor in selecting among queries.

Purpose: The end result that this query is intended to accomplish. Free text.

Response Characteristics: Particular features of this response. This is free text intended to help the query implementor in selecting among queries.

Based on Segment Pattern: For queries that return a segment pattern response, this is the (non-query response) message type upon which the segment pattern is based.

Query grammar

The Query Profile shows a query grammar. This is a brief model of the segments used in the query message.

Query Grammar: This and the following column specify the HL7 code name and full name of each segment sent in the query. Braces specify that the segment or segment group is repeatable; brackets specify the optionality of the segment or segment group.

Section Reference: Specifies where in the standard further information about the segment can be found.

When the Query by Example variant is used, the Query Grammar shows the segments that may be used to transmit parameters and the order in which they appear. Segments used to transmit parameters are always sent immediately following the QPD segment.

Response grammar

The Query Profile always shows a response grammar. If the query response is segment pattern, the response grammar should specify the segments, order, optionality, and repetition as do message specifications within the HL7 Standard.

Response Grammar: This and the following column specify the HL7 code name and full name of each segment returned in the response. Braces specify that the segment or segment group is repeatable; brackets specify the optionality of the segment or segment group.

For Query Profiles published in the HL7 Standard, the Response Grammar table includes the Query Profile ID in parentheses in the upper left-hand cell. This allows the table to be imported automatically into the HL7 database.

Message Description: The full text name of the segment.

Group Control: The name of a segment group.

Comment: Specifies in English: 1) the opening or closing of a segment group, and 2) the relevance of the segment in a Hit Count. (Only positive value is noted.)

Support Indicator: Allows the Server to indicate: 1) whether an optional segment or segment group will be supported, or 2) that the segment or segment group is dependent on an input parameter. The default understanding is that if the Server knows the information, it will be sent.

Sec Ref:     Specifies where in the standard further information about the segment can be found.

Response grammar for display response

The response grammar for a display response lists the segment names, descriptions, and section references for the segments to be returned by the Server, as described in the previous section. In addition, the print text is displayed, as in the following example.

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

DSP||| GENERAL HOSPITAL – PHARMACY DEPARTMENT DATE:mm-dd-yy

DSP||| DISPENSE HISTORY REPORT PAGE n

DSP|||MRN Patient Name MEDICATION DISPENSED DISP-DATE

DSP|||XXXXX XXXXXx, XXXXX XXXXXXXXXXXXXXXX mm/dd/ccyy

...

DSP||| << END OF REPORT >>


QPD input parameter specification

The Input Parameter Specification section of the Query Profile looks very much like an attribute table and is followed by a commentary on the fields. Each row of the QPD Input Parameter Specification specifies one user parameter within the QPD segment. Values for user parameters are transmitted in successive fields of the QPD segment, beginning at QPD-3.

When the QSC variant is employed (see section 5.2.5.1.3, "Expression as a complex expression"), a complex query expression may be used as the only input parameter, or may be combined with other (simple) input parameters.

QPD Input Parameter Specification

Field Seq (Query ID=Z99)

Name

Key/

Search

Sort

LEN

TYPE

Opt

Rep

Match Op

TBL

Segment Field Name

Service Identifier Code

Element Name


The following is a description of the attributes of the above table.

Field Seq: The ordinal number of the element being discussed. Sequence 1 is always Message Query Name, and sequence 2 is always Query Tag. Sequence 3 and above are reserved for user parameters.

Name: the user-defined name for the element as will be used in the query. Example: MedicationDispensed. When Name is derived from an actual HL7 element (segment and field), the segment field name and element name appear in the columns headed by those names. When Name is not derived from an actual HL7 element (segment and field), the source system defines the values they expect in this field.

For Query Profiles published in the HL7 Standard, the Input Parameter Specification table includes the Query Profile ID in parentheses in the upper left-hand cell. This allows the table to be imported automatically into the HL7 database.

Key/Search: This field identifies which element is the key and which elements are searchable. The key field is designated by a value of 'K'. A value of 'S' designates fields upon which an indexed search can be performed by the source. 'L' designates non-indexed fields. (Note that searching on a non-indexed field requires the Server to perform a linear scan of the data base.) If this column is left blank, the field may not be searched.

Sort: valued as "Y" if the output of the query can be sorted on this field. This column should only be valued in Virtual Tables that are used as output specifications.

Len: the maximum field length that will be transmitted by the source.

Type: the data type of this user parameter. The values available for this field are described in Chapter 2, section 2.16 of this standard. Data types QIP and QSC are available for transmitting complex user parameters.

Opt: defines whether the field is required ('R'), optional ('O'), conditionally required ('C'), or required for backward compatibility ('B').

Rep: valued as 'Y' if the field may repeat (i.e., be multiply valued).

Match Op: the relational operator that will be applied against the value that the querying system specifies for this field.

Note: These are defined by HL7 Table 0209 – Relational Operator, a component of the QSC data type


TBL: identifies the HL7 table from which the values are derived.

Segment Field Name: identifies the HL7 segment and field from which the new definition is derived. This field will be blank if the Name is NOT derived from an actual HL7 segment and field.

Service Identifier Code: a value of data type CWE that contains the applicable LOINC code, if it exists, or the applicable HL7 code, if it exists, if no Segment Field Name has been identified. If a Segment Field Name has been identified, this field is not populated.

Element Name: the name of the element identified by Segment Field Name. This may also be a user-defined 'Z'-element.

QPD input parameter field description and commentary

The QPD Input Parameter Field Description and Commentary provides a more detailed description of each of the fields transmitted in the QPD segment.

Input Parameter (Query ID=Znn)

Comp. Name

DT

Description

MessageQueryName

CWE

SHALL be valued Z99^WhoAmI^HL7nnnn.

QueryTag

ST

Unique to each query message instance.

InputItem...

CX


Input Parameter: The name of the field whose value is being transmitted.

Comp. Name: When the Input Parameter is of a composite data type (e.g., XPN), this is the name of an individual component of the composite input parameter. Only those components that may be valued should be listed in this column.

DT: The data type of the parameter or component.

Description: A narrative description of the parameter or component and how it is to be used.

QBE input parameter specification

In the Query by Example variant, discussed below in section 5.9.7, "Query by example (QBP) / tabular response (RTB)," the Query Profile may specify that the client may use fields within actual message segments, such as the PID segment, to transmit parameter information. Where this is permitted, the Query Profile includes a "QBE Input Parameter Specification" table to specify which fields may be used to transmit the parameters.

QBE Input Parameter Specification

Segment Field Name (Query ID=Z99)

Name

Key/

Search

Sort

LEN

TYPE

Opt

Rep

Match Op

TBL

Service Identifier Code

Element Name


Fields are indicated by their actual Segment Field Name, which specifies both segment and position. Except for this distinguishing feature, the remaining columns in this table are identical in meaning to their counterparts in the "QPD input parameter specification" in section 5.3.2.6 above.

Each row of the QBE Input Parameter Specification specifies one field that may be used to transmit user parameters within the example segment(s).

QBE input parameter field description and commentary

The QPD Input Parameter Field Description and Commentary provides a more detailed description of each of the fields transmitted in the example segments sent in a Query by Example.

QBE Input Parameter Field Description and Commentary

Input Parameter (Query ID=Znn)

Comp. Name

DT

Description


Fields are indicated by their actual Segment Field Name, which specifies both segment and position. Except for this distinguishing feature, the remaining columns in this table are identical in meaning to their counterparts in the "QPD input parameter field description and commentary" in section 5.3.2.7 above.

RCP input parameter field description and commentary

The RCP Input Parameter Field Description and Commentary provides a more detailed description of each of the fields transmitted in the RCP (Response Control Parameters) segment.

RCP Response Control Parameter Field Description and Commentary

Field Seq (Query ID=Znn)

Name

Component Name

LEN

DT

Description


Field Seq: The position within the RCP segment that the field occupies.

Name: The name of the field whose value is being transmitted.

Component Name: When the field referenced by Name is of a composite data type (e.g., XPN), this is the name of an individual component of the composite input parameter. Only those components that may be valued should be listed in this column.

LEN: The maximum length of the field.

DT: The data type of the parameter or component.

Description: A narrative description of the parameter or component and how it is to be used.

Input specification: virtual table

When the QSC variant is in use, the Query Profile includes a Virtual Table specification listing the fields that the Client may include in the complex expression parameter.

Input Specification: Virtual Table

ColName (Query ID=Znn)

Key/

Search

Sort

LEN

TYPE

Opt

Rep

Match Op

TBL

Segment Field Name

Service Identifier Code

Element Name


The ColName column identifies each field name that the Client may include in the complex query expression. Other columns in this table are defined as in section 5.3.2.6 above.

When both the QSC variant and a tabular response are specified, this table is labeled "Input/Output Specification: Virtual Table" and no separate output specification is provided.

Virtual table field description and commentary

The Virtual Table Field Description and Commentary provides a more detailed description of each of the fields listed in the Virtual Table.

Virtual Table Field Description and Commentary

ColName (Query ID=Znn)

Comp. Name

DT

Description


ColName: The name used to identify the column, or field, in the complex expression.

Comp. Name: When the ColName is of a composite data type (e.g., XPN), this is the name of an individual component of the column. Only those components that may be valued should be listed.

When specifying a field in the complex expression, both the ColName and Comp. Name attributes should be sent if only a single component is being identified. For instance, PatientList.ID would specify the ID component of the PatientList field.

DT: The data type of the field or component.

Description: A narrative description of the field or component and how it is to be used.

Output specification for tabular response

The output specification for the tabular response consists of the Virtual Table description, i.e., the columns and rows. It has the same columns as the input specification, but the rows reflect all of the available rows in the table, not just those that can be filtered upon input.

Output Specification and Commentary: Virtual Table

ColName (Query ID=Z99)

Key/

Search

Sort

LEN

TYPE

Opt

Rep

Match Op

TBL

Segment Field Name

Service Identifier Code

Element Name


The usage of the columns in this table is as described in section 5.3.2.8, "QBE input parameter specification." Note that the Key/Search and Match Op fields are only meaningful when a virtual table is used in the input specification (QSC variant).

When the QSC variant is in use, the "Input/Output Specification and Commentary" virtual table is used for selection of output fields. No separate table is specified for output.

Query Profile templates

Query Profile template for query with tabular response

Query Profile

Query Statement ID (Query ID=Znn):

Type:

Query Name:

Query Trigger (= MSH-9):

Query Mode:

Response Trigger (= MSH-9):

Query Characteristics:

Purpose:

Response Characteristics:

Based on Segment Pattern:


The message structure for QBP^Znn^QPB_Q13 can be found in 5.3.1.2. Use the QBP^Q13^QPB_Q13 Message structure.

QPD Input Parameter Specification

Field Seq (Query ID=Znn)

Name

Key/

Search

Sort

LEN

TYPE

Opt

Rep

Match Op

TBL

Segment Field Name

Service Identifier Code

Element Name

1

MessageQueryName

60

CWE

R

2

QueryTag

32

ST

R

3

InputItem . . .


QPD Input Parameter Field Description and Commentary

Input Parameter (Query ID=Znn)

Comp. Name

DT

Description

MessageQueryName

CWE

SHALL be valued Znn^<query name>^HL7nnnn.

QueryTag

ST

Unique to each query message instance.

InputItem1

DataType

Components: (if applicable)

(Description)

(Valuation note)

Component1 (if applicable)

DataType

(Valuation note)


[The following table is used only for the Complex Expression (QSC) variant.]

Input Specification: Virtual Table

ColName (Query ID=Znn)

Key/

Search

Sort

LEN

TYPE

Opt

Rep

Match Op

TBL

Segment Field Name

Service Identifier Code

Element Name


[The following table is used only for the Complex Expression (QSC) variant.]

Virtual Table Field Description and Commentary

ColName (Query ID=Znn)

Comp. Name

DT

Description


[The following table is used only for the Query by Example variant.]

QBE Input Parameter Specification

Segment Field Name (Query ID=Znn)

Name

Key/

Search

Sort

LEN

TYPE

Opt

Rep

Match Op

TBL

Service Identifier Code

Element Name


[The following table is used only for the Query by Example (QBE) variant.]

QBE Input Parameter Field Description and Commentary

Input Parameter (Query ID=Znn)

Comp. Name

DT

Description


RCP Response Control Parameter Field Description and Commentary

Field Seq (Query ID=Znn)

Name

Component Name

LEN

DT

Description


Output Specification and Commentary: Virtual Table

ColName (Query ID=Znn)

Key/

Search

Sort

LEN

TYPE

Opt

Rep

Match Op

TBL

Segment Field Name

Service Identifier Code

Element Name


Query Profile template for query with segment pattern response

Query Profile

Query Statement ID (Query ID=Znn):

Type:

Query Name:

Query Trigger (= MSH-9):

Query Mode:

Response Trigger (= MSH-9):

Query Characteristics:

Purpose:

Response Characteristics:

Based on Segment Pattern:


QPD Input Parameter Specification

Field Seq (Query ID=Znn)

Col Name

Key/

Search

Sort

LEN

TYPE

Opt

Rep

Match Op

TBL

Segment Field Name

Service Identifier Code

Element Name

1

MessageQueryName

60

CWE

R

2

QueryTag

32

ST

R

3

InputItem . . .


QPD Input Parameter Field Description and Commentary

Input Parameter (Query ID=Znn)

Comp. Name

DT

Description

MessageQueryName

CWE

SHALL be valued Znn^<query name>^HL7nnnn.

QueryTag

ST

Unique to each query message instance.

InputItem1

DataType

Components: (if applicable)

(Description)

(Valuation note)

Component1 (if applicable)

DataType

(Valuation note)


[The following table is used only for the Complex Expression (QSC) variant.]

Input Specification: Virtual Table

ColName (Query ID=Znn)

Key/

Search

Sort

LEN

TYPE

Opt

Rep

Match Op

TBL

Segment Field Name

Service Identifier Code

Element Name


[The following table is used only for the Complex Expression (QSC) variant.]

Virtual Table Field Description and Commentary

ColName (Query ID=Znn)

Comp. Name

DT

Description


[The following table is used only for the Query by Example (QBE) variant.]

QBE Input Parameter Specification

Segment Field Name (Query ID=Znn)

Name

Key/

Search

Sort

LEN

TYPE

Opt

Rep

Match Op

TBL

Service Identifier Code

Element Name


[The following table is used only for the Query by Example variant.]

QBE Input Parameter Field Description and Commentary

Input Parameter (Query ID=Znn)

Comp. Name

DT

Description


RCP Response Control Parameter Field Description and Commentary

Field Seq (Query ID=Znn)

Name

Component Name

LEN

DT

Description


Query Profile for query with display response

Query Profile

Query Statement ID (Query ID=Znn):

Type:

Query Name:

Query Trigger (= MSH-9):

Query Mode:

Response Trigger (= MSH-9):

Query Characteristics:

Purpose:

Response Characteristics:

Based on Segment Pattern:


The message structure for QBP^Znn^QPB_Q15 can be found in 5.4.3. Use the QBP^Q15^QPB_Q15 Message structure.

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

DSP||| (data in actual display format)


QPD Input Parameter Specification

Field Seq (Query ID=Znn)

Name

Key/

Search

Sort

LEN

TYPE

Opt

Rep

Match Op

TBL

Segment Field Name

Service Identifier Code

Element Name

1

MessageQueryName

60

CWE

R

2

QueryTag

32

ST

R

InputItem


QPD Input Parameter Field Description and Commentary

Input Parameter (Query ID=Znn)

Comp. Name

DT

Description

MessageQueryName

CWE

SHALL be valued Znn^<query name>^HL7nnnn.

QueryTag

ST

Unique to each query message instance.

InputItem1

DataType

Components: (if applicable)

(Description)

(Valuation note)

Component1 (if applicable)

DataType

(Valuation note)


[The following table is used only for the Complex Expression (QSC) variant.]

Input Specification: Virtual Table

ColName (Query ID=Znn)

Key/

Search

Sort

LEN

TYPE

Opt

Rep

Match Op

TBL

Segment Field Name

Service Identifier Code

Element Name


[The following table is used only for the Complex Expression (QSC) variant.]

ColName (Query ID=Znn)

Comp. Name

DT

Description


[The following table is used only for the Query by Example (QBE) variant.]

QBE Input Parameter Specification

Segment Field Name (Query ID=Znn)

Name

Key/

Search

Sort

LEN

TYPE

Opt

Rep

Match Op

TBL

Service Identifier Code

Element Name


[The following table is used only for the Query by Example variant.]

QBE Input Parameter Field Description and Commentary

Input Parameter (Query ID=Znn)

Comp. Name

DT

Description


RCP Response Control Parameter Field Description and Commentary

Field Seq (Query ID=Znn)

Name

Component Name

LEN

DT

Description


Query Profile table summaries

The following table lists the tables that are to be included in each Query Profile. The differences arise both from the query variant used and the response type provided.

Response Type

Query Variant

Table Included

Section Reference

Display

None (QPD)

Query Profile introduction

5.3.2.2

Query grammar

5.3.2.3

Response grammar for display response

5.3.2.5

QPD input parameter specification

5.3.2.6

QPD input parameter field description and commentary

5.3.2.7

RCP input parameter field description and commentary

5.3.2.10

Display

QBE

Query Profile introduction

5.3.2.2

Query grammar

5.3.2.3

Response grammar for display response

5.3.2.5

QPD input parameter specification

5.3.2.6

QPD input parameter field description and commentary

5.3.2.7

QBE input parameter specification

5.3.2.8

QBE input parameter field description and commentary

5.3.2.9

RCP input parameter field description and commentary

5.3.2.10

Display

QSC

Query Profile introduction

5.3.2.2

Query grammar

5.3.2.3

Response grammar for display response

5.3.2.5

QPD input parameter specification

5.3.2.6

QPD input parameter field description and commentary

5.3.2.7

Input specification: virtual table

5.3.2.11

Virtual table field description and commentary

5.3.2.12

Tabular

None (QPD)

Query Profile introduction

5.3.2.2

Query grammar

5.3.2.3

Response grammar

5.3.2.4

QPD input parameter specification

5.3.2.6

QPD input parameter field description and commentary

5.3.2.7

RCP input parameter field description and commentary

5.3.2.10

Output specification for tabular response

5.3.2.13

Tabular

QBE

Query Profile introduction

5.3.2.2

Query grammar

5.3.2.3

Response grammar

5.3.2.4

QPD input parameter specification

5.3.2.6

QPD input parameter field description and commentary

5.3.2.7

QBE input parameter specification

5.3.2.8

QBE input parameter field description and commentary

5.3.2.9

RCP input parameter field description and commentary

5.3.2.10

Output specification for tabular response

5.3.2.13

Tabular

QSC

Query Profile introduction

5.3.2.2

Query grammar

5.3.2.3

Response grammar

5.3.2.4

QPD input parameter specification

5.3.2.6

QPD input parameter field description and commentary

5.3.2.7

Input/output specification: virtual table

5.3.2.11

Virtual table field description and commentary

5.3.2.12

RCP input parameter field description and commentary

5.3.2.10

Segment pattern

None (QPD)

Query Profile introduction

5.3.2.2

Query grammar

5.3.2.3

Response grammar

5.3.2.4

QPD input parameter specification

5.3.2.6

QPD input parameter field description and commentary

5.3.2.7

RCP input parameter field description and commentary

5.3.2.10

Segment pattern

QBE

Query Profile introduction

5.3.2.2

Query grammar

5.3.2.3

Response grammar

5.3.2.4

QPD input parameter specification

5.3.2.6

QPD input parameter field description and commentary

5.3.2.7

QBE input parameter specification

5.3.2.8

QBE input parameter field description and commentary

5.3.2.9

RCP input parameter field description and commentary

5.3.2.10

Segment pattern

QSC

Query Profile introduction

5.3.2.2

Query grammar

5.3.2.3

Response grammar

5.3.2.4

QPD input parameter specification

5.3.2.6

QPD input parameter field description and commentary

5.3.2.7

Input specification: virtual table

5.3.2.11

Virtual table field description and commentary

5.3.2.12

RCP input parameter field description and commentary

5.3.2.10


QUERY/RESPONSE MESSAGE PAIRS

The query recommended for use in v 2.4 and later is the Query by Parameter (QBP). The query/response message pairs that follow in this section supersede the previous generation of original mode and enhanced queries that are described in sections 5.10.2, "Original mode queries," and, in v 2.6 and preceding, 5.10.3, "Originally Mode Deferred Access," and 5.10.4, "Other Query/Response Message Segments."

All queries SHALL have a Query Name. The Query Name field, which is a CWE data type, uniquely identifies a Query Profile.

The QBP allows for several variants in defining the selection criteria.

The first variant, the Query by (Simple) Parameter, is to declare a sequence of one to many HL7 fields. Each of these fields will retain its data type as defined in the original HL7 usage. Each field corresponds to a parameter in the Query Profile.

Note: It is the responsibility of the Server to declare explicitly the purpose of the query, the meaning of each of the query parameters, and the relationships among the parameters. These declarations are made in the Query Profile.


A second variant, the Query by Example, allows the specification of parameters within actual HL7 segments other than the QPD. For example, the Query Profile might permit the use of the PID segment to transmit specific patient identification parameters. Each such parameter is specified in the QBE Input Parameter Specification and QBE Input Parameter Field Description and Commentary tables.

The third variant uses a single QPD parameter in the form of a complex query selection expression. This field with its QSC data type allows the defining segment to be broader in scope and allows any field in the target data to be selected and filtered unless constrained through the Query Profile. It explicitly states any relational operators such as AND and OR. It is intended to support a wide range of combinations of parameters.

The difference in how parameters are passed in each of these three variants is as follows:

  • Query by Simple Parameter passes each client value to the Server positionally using only the third and successive fields of the QPD segment.

  • Query by Example passes parameters using HL7 segments, such as PID, that are defined in the endpoint application chapters. The third and successive fields of the QPD segment also may be used in this variant.

  • In the QSC Selection Criteria variant, the parameter values are all contained within a single complex query selection expression that is passed in QPD-3.

Each generic query has a specific message syntax, a unique trigger event, and a unique message structure. Each generic response also has a specific message syntax, a unique trigger event, and a unique message structure.

There are three generic message structures, each of which accommodates the specific detail needed in each of the three response types.

  • The QBP_Q11 structure supports a Segment Pattern Response and contains the MSH, QPD, RCP, and DSC segments. Its default trigger event is Q11. A standard or site-defined query may use this trigger event or may specify a unique trigger event value in its Query Profile. If a unique trigger event value is chosen for a site-defined query, that value SHALL begin with Z.

  • The QBP_Q13 structure supports a Tabular Response and contains the MSH, RCP, RDF, and DSC segments. Its default trigger event is Q13. A standard or site-defined query may use this trigger event or may specify a unique trigger event value in its Query Profile. If a unique trigger event value is chosen for a site-defined query, that value SHALL begin with Z.

  • The QBP_Q15 structure supports a Display Response and contains the MSH, QPD, RCP, and DSC segments. Its default trigger event is Q15. A standard or site-defined query may use this trigger event or may specify a unique trigger event value in its Query Profile. If a unique trigger event value is chosen for a site-defined query, that value SHALL begin with Z.

The new queries support both immediate and deferred response. This information is carried in the RCP segment along with the execution date and time.

The query definition segment is echoed back in the response. This is particularly important in a continuation situation. Otherwise, the sender might conceivably have to manage a queue of queries.

QBP/RSP – query by parameter/segment pattern response (events vary)

QBP^Q11^QBP_Q11: Query By Parameter
HL7 MessageStructure Table - QBP_Q11
Segment Cardinality Must Implement Status
QBP_Q11
MSH 1..1 Yes
ARV 0..*
SFT 0..*
UAC 0..1
QPD 1..1 Yes
QBP 0..1
... 0..1
RCP 1..1 Yes
DSC 0..1

Original Mode Acknowledgement Choreography for QBP^Q11^QBP_Q11

Send Application Ack: RSP^K11^RSP_K11

Enhanced Mode Acknowledgement Choreography for QBP^Q11^QBP_Q11

When the MSH-15 value of a QBP^Q11^QBP_Q11 message is AL or ER or SU, an ACK^Q11^ACK message SHALL be sent as an immediate ack.

When the MSH-15 value of a QBP^Q11^QBP_Q11 message is NE, an immediate ack SHALL NOT be sent.

When the MSH-16 value of a QBP^Q11^QBP_Q11 message is AL, a RSP^K11^RSP_K11 message SHALL be sent as an application ack.

When the MSH-16 value of a QBP^Q11^QBP_Q11 message is NE or ER or SU, an application ack SHALL NOT be sent.

Field Value Send Response
MSH-15 AL, ER, SU immediate ack: ACK^Q11^ACK
NE (none)
MSH-16 AL application ack: RSP^K11^RSP_K11
NE, ER, SU (none)

The QBP_Q11 structure supports a Segment Pattern Response and contains the MSH, QPD, RCP, and DSC segments. Its default trigger event is Q11. A standard or site-defined query may use this trigger event or may specify a unique trigger event value in its Query Profile. If a unique trigger event value is chosen for a site-defined query, that value SHALL begin with Z.

RSP^K11^RSP_K11: Segment Pattern Response
HL7 MessageStructure Table - RSP_K11
Segment Cardinality Must Implement Status
RSP_K11
MSH 1..1 Yes
SFT 0..*
UAC 0..1
MSA 1..1 Yes
ERR 0..*
QAK 1..1 Yes
QPD 1..1 Yes
SEGMENT_PATTERN 0..1
... 1..1 Yes
DSC 0..1

Original Mode Acknowledgement Choreography for RSP^K11^RSP_K11

Send An Acknowlegment is never sent in original mode.

Enhanced Mode Acknowledgement Choreography for RSP^K11^RSP_K11

When the MSH-15 value of a RSP^K11^RSP_K11 message is AL or ER or SU, an ACK^K11^ACK message SHALL be sent as an immediate ack.

When the MSH-15 value of a RSP^K11^RSP_K11 message is NE, an immediate ack SHALL NOT be sent.

Never send an application ack in enhanced mode.

Field Value Send Response
MSH-15 AL, ER, SU immediate ack: ACK^K11^ACK
NE (none)
MSH-16 NE (none)

The RSP_K11 supports a Segment Pattern Response to the QBP and contains the MSH, MSA, ERR, QAK, QPD, variable content segments, and the DSC. Its default trigger event is K11. A standard or site-defined response may use this trigger event or may specify a unique trigger event value in its Query Profile. If a unique trigger event value is chosen for a site-defined response, that value SHALL begin with Z.

Note on QBP: Query By Example variant: The query by example is an extension of Query by Parameter (QBP) in which search parameters are passed by sending them in the segment which naturally carries them. A Query Profile which uses this variant SHALL replace the ellipses in the input QBP_Q11 grammar above, with the specific segments that it accepts.


Note: The indicated trigger events are the default values for MSH-9-2-Trigger event. Standard and site-defined queries may use these trigger events or may specify unique trigger event values in their Query Profiles. Unique trigger event values for site-defined queries SHALL begin with Z.


Note on RSP: The Query Profile for each QBP/RSP pair shall specify an explicit segment pattern grammar in place of the ellipses shown above in the RSP_K11 grammar.


QBP/RTB – query by parameter/tabular response (events vary)

The QBP_Q13 structure supports a Tabular Response and contains the MSH, RDF, RCP, and DSC segments. Its default trigger event is Q13. A standard or site-defined query may use this trigger event or may specify a unique trigger event value in its Query Profile. If a unique trigger event value is chosen for a site-defined query, that value SHALL begin with Z.

Unless otherwise specified in the query's Query Profile, the default value for the RDF segment shall be understood to contain all available fields from the Virtual Table. The Client may override the default RDF by specifying explicitly the columns to be returned.

The message structure for QBP^Q13^QPB_Q13 can be found in 5.3.1.2. Use the QBP^Q13^QPB_Q13 Message structure.

RTB^K13^RTB_K13: Table Based Response
HL7 MessageStructure Table - RTB_K13
Segment Cardinality Must Implement Status
RTB_K13
MSH 1..1 Yes
SFT 0..*
UAC 0..1
MSA 1..1 Yes
ERR 0..1
QAK 1..1 Yes
QPD 1..1 Yes
ROW_DEFINITION 0..1
RDF 1..1 Yes
RDT 0..*
DSC 0..1

Original Mode Acknowledgement Choreography for RTB^K13^RTB_K13

Send An Acknowlegment is never sent in original mode.

Enhanced Mode Acknowledgement Choreography for RTB^K13^RTB_K13

When the MSH-15 value of a RTB^K13^RTB_K13 message is AL or ER or SU, an ACK^K13^ACK message SHALL be sent as an immediate ack.

When the MSH-15 value of a RTB^K13^RTB_K13 message is NE, an immediate ack SHALL NOT be sent.

Never send an application ack in enhanced mode.

Field Value Send Response
MSH-15 AL, ER, SU immediate ack: ACK^K13^ACK
NE (none)
MSH-16 NE (none)

The RTB_K13 supports a Tabular Response to the QBP and contains the MSH, MSA, ERR, QAK, QPD, RDF, RDT and the DSC. Its default trigger event is K13. A standard or site-defined response may use this trigger event or may specify a unique trigger event value in its Query Profile. If a unique trigger event value is chosen for a site-defined response, that value SHALL begin with Z.

The RTB_K13 structure requires that, if any RDT segments are returned, they be preceded by an RDF segment containing the row definition specification for the RDT segments. If no RDF was sent in the query, the default RDF is returned in the RTB_K13.

Note: The indicated trigger events are the default values for MSH-9-2-Trigger event. Standard and site-defined queries may use these trigger events or may specify unique trigger event values in their Query Profiles. Unique trigger event values for site-defined queries SHALL begin with Z.


QBP/RDY – query by parameter/display response (events vary)

QBP^Q15^QBP_Q15: Query By Parameter
HL7 MessageStructure Table - QBP_Q15
Segment Cardinality Must Implement Status
QBP_Q15
MSH 1..1 Yes
SFT 0..*
UAC 0..1
QPD 1..1 Yes
... 0..1
RCP 1..1 Yes
DSC 0..1

Original Mode Acknowledgement Choreography for QBP^Q15^QBP_Q15

Send Application Ack: RDY^K15^RDY_K15

Enhanced Mode Acknowledgement Choreography for QBP^Q15^QBP_Q15

When the MSH-15 value of a QBP^Q15^QBP_Q15 message is AL or ER or SU, an ACK^Q15^ACK message SHALL be sent as an immediate ack.

When the MSH-15 value of a QBP^Q15^QBP_Q15 message is NE, an immediate ack SHALL NOT be sent.

When the MSH-16 value of a QBP^Q15^QBP_Q15 message is AL, a RDY^K15^RDY_K15 message SHALL be sent as an application ack.

When the MSH-16 value of a QBP^Q15^QBP_Q15 message is NE or ER or SU, an application ack SHALL NOT be sent.

Field Value Send Response
MSH-15 AL, ER, SU immediate ack: ACK^Q15^ACK
NE (none)
MSH-16 AL application ack: RDY^K15^RDY_K15
NE, ER, SU (none)

The QBP_Q15 structure supports a Display Response and contains the MSH, QPD, RCP, and DSC segments. Its default trigger event is Q15. A standard or site-defined query may use this trigger event or may specify a unique trigger event value in its Query Profile. If a unique trigger event value is chosen for a site-defined query, that value SHALL begin with Z.

RDY^K15^RDY_K15: Display Based Response
HL7 MessageStructure Table - RDY_K15
Segment Cardinality Must Implement Status
RDY_K15
MSH 1..1 Yes
SFT 0..*
UAC 0..1
MSA 1..1 Yes
ERR 0..1
QAK 1..1 Yes
QPD 1..1 Yes
DSP 0..*
DSC 0..1

Original Mode Acknowledgement Choreography for RDY^K15^RDY_K15

Send An Acknowlegment is never sent in original mode.

Enhanced Mode Acknowledgement Choreography for RDY^K15^RDY_K15

When the MSH-15 value of a RDY^K15^RDY_K15 message is AL or ER or SU, an ACK^K15^ACK message SHALL be sent as an immediate ack.

When the MSH-15 value of a RDY^K15^RDY_K15 message is NE, an immediate ack SHALL NOT be sent.

Never send an application ack in enhanced mode.

Field Value Send Response
MSH-15 AL, ER, SU immediate ack: ACK^K15^ACK
NE (none)
MSH-16 NE (none)

The RDY_K15 supports a Display Response to the QBP and contains the MSH, MSA, ERR, QAK, DSP, and the DSC. Its default trigger event is K15. A standard or site-defined response may use this trigger event or may specify a unique trigger event value in its Query Profile. If a unique trigger event value is chosen for a site-defined response, that value SHALL begin with Z.

Note: The indicated trigger events are the default values for MSH-9-2-Trigger event. Standard and site-defined queries may use these trigger events or may specify unique trigger event values in their Query Profiles. Unique trigger event values for site-defined queries SHALL begin with Z.


Note on QBP: Query By Example variant: The query by example is an extension of Query by Parameter (QBP) in which search parameters are passed by sending them in the segment which naturally carries them. A Query Profile which uses this variant SHALL replace the ellipses in the input QBP_Q11 grammar above, with the specific segments that it accepts.


QSB – Create subscription (Event Q16)

See section 5.7, "PUBLISH AND SUBSCRIBE" for more information about this event.

QSB^Q16^QSB_Q16: Create Subscription
HL7 MessageStructure Table - QBP_Q21
Segment Cardinality Must Implement Status
QBP_Q21

Original Mode Acknowledgement Choreography for QSB^Q16^QSB_Q16

Send Application Ack: ACK^Q16^ACK

Enhanced Mode Acknowledgement Choreography for QSB^Q16^QSB_Q16

When the MSH-15 value of a QSB^Q16^QSB_Q16 message is AL or ER or SU, an ACK^Q16^ACK message SHALL be sent as an immediate ack.

When the MSH-15 value of a QSB^Q16^QSB_Q16 message is NE, an immediate ack SHALL NOT be sent.

When the MSH-16 value of a QSB^Q16^QSB_Q16 message is AL, an ACK^Q16^ACK message SHALL be sent as an application ack.

When the MSH-16 value of a QSB^Q16^QSB_Q16 message is NE or ER or SU, an application ack SHALL NOT be sent.

Field Value Send Response
MSH-15 AL, ER, SU immediate ack: ACK^Q16^ACK
NE (none)
MSH-16 AL application ack: ACK^Q16^ACK
NE, ER, SU (none)

ACK^Q16^ACK: General Acknowledgment
HL7 MessageStructure Table - ACK
Segment Cardinality Must Implement Status
ACK
MSH 1..1 Yes
SFT 0..*
UAC 0..1
MSA 1..1 Yes
ERR 0..*

Original Mode Acknowledgement Choreography for ACK^Q16^ACK

Send An Acknowlegment is never sent in original mode.

Enhanced Mode Acknowledgement Choreography for ACK^Q16^ACK

When the MSH-15 value of an ACK^Q16^ACK message is AL or ER or SU, an ACK^Q16^ACK message SHALL be sent as an immediate ack.

When the MSH-15 value of an ACK^Q16^ACK message is NE, an immediate ack SHALL NOT be sent.

Never send an application ack in enhanced mode.

Field Value Send Response
MSH-15 AL, ER, SU immediate ack: ACK^Q16^ACK
NE (none)
MSH-16 NE (none)

QVR – query for previous events (Event Q17)

The Query for Previous Events is like a Query by Parameter with a Segment Pattern Response except that the response consists of zero to many messages of the type defined in the Query Profile rather than a single response message containing multiple iterations of the segment pattern. While the messages sent in response to a QVR will reflect events which occurred in the past, the time stamp in the message header will reflect the time the message is actually constructed (current time). It is also similar to the previous generation VQQ/RQQ Event Replay.

While the response is similar to subscription messages, it differs from subscription in that the response messages are the result of "interrogating" the database rather than events being triggered in the current timeframe.

In a Query for Previous Events, the Server still has to parse the query, but avoids the handshaking protocols required in normal query/response situations. The Server acknowledges the query with the general acknowledgement message ACK. The Server then transmits a sequence of messages as if they were simulated unsolicited messages. This is useful for low end systems that unable to deal with the overhead of the query response message syntax, i.e., systems that can only process unsolicited update messages.

Systems that choose to offer the QVR should offer guidance in the Query Profile, where appropriate, concerning the scope and size of the data requested by the Client. Moreover, the Query Profile should contain language cautioning Clients of the potential for harm from getting messages out of the original sequence and/or context.

Use cases for this query are as follows: 1) to populate a database initially, 2) to recover from an extended down time on the part of the recipient, or 3) to enable systems which normally receive unsolicited data to be extended to act as a query client with minimal modification.

Note: If there is a concern that it will be difficult to distinguish these messages from any current realtime messages, e.g., if they are going down the same pipe, the data offerer might choose to designate a unique MSH-3 Sending application for the messages it sends in response to a QVR. This would allow downstream systems to recognize which messages were the result of the QVR, versus which are the result of current realtime activity on the sending system. For example, there may be 2 systems receiving pharmacy dispense messages. If system A wishes to issue a QVR to receive a historical load, system B might misinterpret the QVR results coming over the pipe as actual live data. A separate Sending Application name would allow for easy differentiation.


QVR^Q17^QVR_Q17: Query for Previous Events
HL7 MessageStructure Table - QVR_Q17
Segment Cardinality Must Implement Status
QVR_Q17
MSH 1..1 Yes
SFT 0..*
UAC 0..1
QPD 1..1 Yes
QBP 0..1
... 0..1
RCP 1..1 Yes
DSC 0..1

Original Mode Acknowledgement Choreography for QVR^Q17^QVR_Q17

Send Application Ack: ACK^Q17^ACK

Enhanced Mode Acknowledgement Choreography for QVR^Q17^QVR_Q17

When the MSH-15 value of a QVR^Q17^QVR_Q17 message is AL or ER or SU, an ACK^Q17^ACK message SHALL be sent as an immediate ack.

When the MSH-15 value of a QVR^Q17^QVR_Q17 message is NE, an immediate ack SHALL NOT be sent.

When the MSH-16 value of a QVR^Q17^QVR_Q17 message is AL, an ACK^Q17^ACK message SHALL be sent as an application ack.

When the MSH-16 value of a QVR^Q17^QVR_Q17 message is NE or ER or SU, an application ack SHALL NOT be sent.

Field Value Send Response
MSH-15 AL, ER, SU immediate ack: ACK^Q17^ACK
NE (none)
MSH-16 AL application ack: ACK^Q17^ACK
NE, ER, SU (none)

ACK^Q17^ACK: General Acknowledgment
HL7 MessageStructure Table - ACK
Segment Cardinality Must Implement Status
ACK
MSH 1..1 Yes
SFT 0..*
UAC 0..1
MSA 1..1 Yes
ERR 0..*

Original Mode Acknowledgement Choreography for ACK^Q17^ACK

Send An Acknowlegment is never sent in original mode.

Enhanced Mode Acknowledgement Choreography for ACK^Q17^ACK

When the MSH-15 value of an ACK^Q17^ACK message is AL or ER or SU, an ACK^Q17^ACK message SHALL be sent as an immediate ack.

When the MSH-15 value of an ACK^Q17^ACK message is NE, an immediate ack SHALL NOT be sent.

Never send an application ack in enhanced mode.

Field Value Send Response
MSH-15 AL, ER, SU immediate ack: ACK^Q17^ACK
NE (none)
MSH-16 NE (none)

The QVR message segments are identical to those of the QBP. A QVR Query Profile may use either the QSC or query by example syntactic variants as well as the query by simple parameter.

QCN/ACK – cancel query/acknowledge message (Event J01)

QCN^J01^QCN_J01: Cancel Query
HL7 MessageStructure Table - QCN_J01
Segment Cardinality Must Implement Status
QCN_J01
MSH 1..1 Yes
SFT 0..*
UAC 0..1
QID 1..1 Yes

Original Mode Acknowledgement Choreography for QCN^J01^QCN_J01

Send Application Ack: ACK^J01^ACK

Enhanced Mode Acknowledgement Choreography for QCN^J01^QCN_J01

When the MSH-15 value of a QCN^J01^QCN_J01 message is AL or ER or SU, an ACK^J01^ACK message SHALL be sent as an immediate ack.

When the MSH-15 value of a QCN^J01^QCN_J01 message is NE, an immediate ack SHALL NOT be sent.

When the MSH-16 value of a QCN^J01^QCN_J01 message is AL, an ACK^J01^ACK message SHALL be sent as an application ack.

When the MSH-16 value of a QCN^J01^QCN_J01 message is NE or ER or SU, an application ack SHALL NOT be sent.

Field Value Send Response
MSH-15 AL, ER, SU immediate ack: ACK^J01^ACK
NE (none)
MSH-16 AL application ack: ACK^J01^ACK
NE, ER, SU (none)

ACK^J01^ACK: General Acknowledgment
HL7 MessageStructure Table - ACK
Segment Cardinality Must Implement Status
ACK
MSH 1..1 Yes
SFT 0..*
UAC 0..1
MSA 1..1 Yes
ERR 0..*

Original Mode Acknowledgement Choreography for ACK^J01^ACK

Send An Acknowlegment is never sent in original mode.

Enhanced Mode Acknowledgement Choreography for ACK^J01^ACK

When the MSH-15 value of an ACK^J01^ACK message is AL or ER or SU, an ACK^J01^ACK message SHALL be sent as an immediate ack.

When the MSH-15 value of an ACK^J01^ACK message is NE, an immediate ack SHALL NOT be sent.

Never send an application ack in enhanced mode.

Field Value Send Response
MSH-15 AL, ER, SU immediate ack: ACK^J01^ACK
NE (none)
MSH-16 NE (none)

QSX /ACK – cancel subscription/acknowledge message (Event J02)

See section 5.6, "AUXILIARY QUERY PROTOCOLS" for more information about this event.

QSX^J02^QCN_J01: Cancel Subscription
HL7 MessageStructure Table - QCN_J01
Segment Cardinality Must Implement Status
QCN_J01
MSH 1..1 Yes
SFT 0..*
UAC 0..1
QID 1..1 Yes

Original Mode Acknowledgement Choreography for QSX^J02^QCN_J01

Send Application Ack: ACK^J02^ACK

Enhanced Mode Acknowledgement Choreography for QSX^J02^QCN_J01

When the MSH-15 value of a QSX^J02^QCN_J01 message is AL or ER or SU, an ACK^J02^ACK message SHALL be sent as an immediate ack.

When the MSH-15 value of a QSX^J02^QCN_J01 message is NE, an immediate ack SHALL NOT be sent.

When the MSH-16 value of a QSX^J02^QCN_J01 message is AL, an ACK^J02^ACK message SHALL be sent as an application ack.

When the MSH-16 value of a QSX^J02^QCN_J01 message is NE or ER or SU, an application ack SHALL NOT be sent.

Field Value Send Response
MSH-15 AL, ER, SU immediate ack: ACK^J02^ACK
NE (none)
MSH-16 AL application ack: ACK^J02^ACK
NE, ER, SU (none)

ACK^J02^ACK: General Acknowledgment
HL7 MessageStructure Table - ACK
Segment Cardinality Must Implement Status
ACK
MSH 1..1 Yes
SFT 0..*
UAC 0..1
MSA 1..1 Yes
ERR 0..*

Original Mode Acknowledgement Choreography for ACK^J02^ACK

Send An Acknowlegment is never sent in original mode.

Enhanced Mode Acknowledgement Choreography for ACK^J02^ACK

When the MSH-15 value of an ACK^J02^ACK message is AL or ER or SU, an ACK^J02^ACK message SHALL be sent as an immediate ack.

When the MSH-15 value of an ACK^J02^ACK message is NE, an immediate ack SHALL NOT be sent.

Never send an application ack in enhanced mode.

Field Value Send Response
MSH-15 AL, ER, SU immediate ack: ACK^J02^ACK
NE (none)
MSH-16 NE (none)

QUERY/RESPONSE MESSAGE SEGMENTS

This section includes all message segments, except for the general message segments, used for the query/response pairs recommended for use in v 2.4 and later.

DSP - Display Data Segment

The DSP segment is used to contain data that has been preformatted by the sender for display. The semantic content of the data is lost; the data is simply treated as lines of text.

HL7 Attribute Table - DSP - display data segment
Seq# DataElement Description Must Implement Flags Cardinality Length C.LEN Vocabulary DataType
DSP
1 00061 Set ID – DSP [0..1] [1..4] SI
2 00062 Display Level [0..1] [1..4] SI
3 00063 Data Line SHALL = [1..1] 300 TX
4 00064 Logical Break Point = [0..1] 2 ST
5 00065 Result ID = [0..1] 20 TX

DSP-1: Set ID – DSP (SI) 00061

Definition: This field is used optionally to number multiple display segments.

DSP-2: Display Level (SI) 00062

Definition: This field contains numbering to define groups of fields as assigned by the individual sites or applications.

DSP-3: Data Line (TX) 00063

Definition: This field contains an actual line as it should be displayed. As described for the TX data type, highlighting and other special display characteristics may be included.

DSP-4: Logical Break Point (ST) 00064

Definition: This field is non-null if this line is the last line of a logical break point in the response as defined by the responding system.

Often the lines of display text will fall into logical groups that differ from the physical size of a screen or printer page. For example, a complete battery or an entire radiology report might be thought of as comprising a logical group, though it might have as few as six or as many as 120 lines. Knowledge of the logical break points in the display data can be useful to the application system that is displaying or printing data. For this reason, DSP-4-Logical break point is used. The sending application (the one that formats the data) places the logical break points where appropriate. If there is a particular ancillary result ID associated with the data delineated by DSP-4-Logical break point, the value of this ID also can be returned in DSP-5-Result ID. Then if the user selects the area of the display delineated by DSP-4-Logical break point, the displaying system can query for the associated DSP-5-Result ID.

DSP-5: Result ID (TX) 00065

Definition: When the user selects a result ID (defined by DSP-4-Logical break point) from the screen display corresponding to a record in which DSP-5-Result ID is non-null, the application can initiate a second query (a separate session) to the ancillary with the QRD-10-What department data code filled in with this non-null value (e.g., the ancillary accession number or its equivalent). The ancillary response will contain the report referenced by this result ID (e.g., accession number). The ancillary should correlate the result ID with DSP-4-Logical break point as follows: If more than one line of text is sent per result, DSP-5-Result ID should be only non-null for a DSP segment that contains a non-null DSP-4-Logical break point. This field may be broken into components by local agreement. A common example might be to include placer order number, filler order number, and universal service identifier. Whenever such fields are used as components of the result ID, their components will be sent as subcomponents.

QAK - Query Acknowledgment Segment

The QAK segment contains information sent with responses to a query. The QAK segment may appear as an optional segment placed after the (optional) ERR segment in any query response (message) to any original mode query.

HL7 Attribute Table - QAK - query acknowledgment segment
Seq# DataElement Description Must Implement Flags Cardinality Length C.LEN Vocabulary DataType
QAK
1

00696 Query Tag MAY
True:
False:
C=
[1..1]
[0..1]
32 ST
2 00708 Query Response Status [0..1] [2..2] ID
3 01375 Message Query Name [0..1] CWE
4 01434 Hit Count Total = [0..1] 10 NM
5 01622 This payload = [0..1] 10 NM
6 01623 Hits remaining = [0..1] 10 NM

QAK-1: Query Tag (ST) 00696

(Definition from QAK.1 in Ch. 5)

Definition: This field may be valued by the initiating system to identify the query, and may be used to match response messages to the originating query. If it is valued, the responding system is required to echo it back as the first field in the query acknowledgment segment (QAK). This field differs from MSA-2-message control ID in that its value remains constant for each message (i.e., all continuation messages) associated with the query, whereas MSA-2-Message control ID may vary with each continuation message, since it is associated with each individual message, not the query as a whole. QAK-1-Query tag is not conditional on the presence of the QRD-1-Query ID field in the original mode queries; in the original mode queries QAK-1-Query tag is not used.

(Definition from QID.1 in Ch. 5)

Definition: This field identifies the instance of a query.

(Definition from QPD.2 in Ch. 5)

Definition: This field may be valued by the initiating system to identify the query, and may be used to match response messages to the originating query. If this field is valued, the responding system is required to echo it back as the first field in the query acknowledgement segment (QAK).

This field differs from MSA-2-Message control ID in that its value remains constant for each message (i.e., all continuation messages) associated with the query, whereas MSA-2-Message control ID may vary with each continuation message, since it is associated with each individual message, not the query as a whole.

Implementation considerations: It is not necessary to value this field in implementations where the only return message on the socket will be the response to the query that was just sent. Conversely, in an "asynchronous" implementation where many queries, responses, and other messages may be communicated bidirectionally over the same socket, it is essential that this field be valued so that the Client knows to which query the Server is responding.

QAK-2: Query Response Status (ID) 00708

Definition: This field allows the responding system to return a precise response status. It is especially useful in the case where no data is found that matches the query parameters, but where there is also no error. Refer to HL7 Table 0208 – Query Response Status in Chapter 2C, Code Tables, for valid values.

QAK-3: Message Query Name (CWE) 01375

(Definition from QAK.3 in Ch. 5)

Definition: This field contains the name of the query. These names are assigned by the function-specific chapters of this specification. Site-specific event replay query names begin with the letter "Z." Refer to User defined table 0471 – Query name in Chapter 2C, Code Tables, for suggested values.

(Definition from QID.2 in Ch. 5)

Definition: This field contains the name of the query. These names are assigned by the function-specific chapters of this specification. Site-specific query names begin with the letter "Z." Refer to User defined table 0471 – Query name for suggested values.

(Definition from QPD.1 in Ch. 5)

Definition: This field contains the name of the query. These names are assigned by the function-specific chapters of this specification. It is one to one with the Query Profile for this query name, and it is in fact an identifier for that Query Profile. Site-specific query names begin with the letter "Z." Refer to User defined table 0471 – Query name in Chapter 2C, Code Tables, for suggested values.

QAK-4: Hit Count Total (NM) 01434

Definition: This field, when used, contains the total number of records found by the Server that matched the query. For tabular responses, this is the number of rows found. For other response types, the Query Profile defines the meaning of a "hit."

QAK-5: This payload (NM) 01622

Definition: This field, when used, contains the total number of matching records that the Server sent in the current response. Where the continuation protocol is used to transmit the response in partial installments, this number will differ from the value sent in QAK-4-Hit count total.

QAK-6: Hits remaining (NM) 01623

Definition: This field, when used, contains the number of matching records found by the Server that have yet to be sent. It is only meaningful when the Server uses the continuation protocol to transmit partial responses.

QID - Query Identification Segment

The QID segment contains the information necessary to uniquely identify a query. Its primary use is in query cancellation or subscription cancellation.

HL7 Attribute Table - QID - query identification segment
Seq# DataElement Description Must Implement Flags Cardinality Length C.LEN Vocabulary DataType
QID
1 00696 Query Tag SHALL = [1..1] 32 ST
2 01375 Message Query Name SHALL [1..1] CWE

QID-1: Query Tag (ST) 00696

(Definition from QAK.1 in Ch. 5)

Definition: This field may be valued by the initiating system to identify the query, and may be used to match response messages to the originating query. If it is valued, the responding system is required to echo it back as the first field in the query acknowledgment segment (QAK). This field differs from MSA-2-message control ID in that its value remains constant for each message (i.e., all continuation messages) associated with the query, whereas MSA-2-Message control ID may vary with each continuation message, since it is associated with each individual message, not the query as a whole. QAK-1-Query tag is not conditional on the presence of the QRD-1-Query ID field in the original mode queries; in the original mode queries QAK-1-Query tag is not used.

(Definition from QID.1 in Ch. 5)

Definition: This field identifies the instance of a query.

(Definition from QPD.2 in Ch. 5)

Definition: This field may be valued by the initiating system to identify the query, and may be used to match response messages to the originating query. If this field is valued, the responding system is required to echo it back as the first field in the query acknowledgement segment (QAK).

This field differs from MSA-2-Message control ID in that its value remains constant for each message (i.e., all continuation messages) associated with the query, whereas MSA-2-Message control ID may vary with each continuation message, since it is associated with each individual message, not the query as a whole.

Implementation considerations: It is not necessary to value this field in implementations where the only return message on the socket will be the response to the query that was just sent. Conversely, in an "asynchronous" implementation where many queries, responses, and other messages may be communicated bidirectionally over the same socket, it is essential that this field be valued so that the Client knows to which query the Server is responding.

QID-2: Message Query Name (CWE) 01375

(Definition from QAK.3 in Ch. 5)

Definition: This field contains the name of the query. These names are assigned by the function-specific chapters of this specification. Site-specific event replay query names begin with the letter "Z." Refer to User defined table 0471 – Query name in Chapter 2C, Code Tables, for suggested values.

(Definition from QID.2 in Ch. 5)

Definition: This field contains the name of the query. These names are assigned by the function-specific chapters of this specification. Site-specific query names begin with the letter "Z." Refer to User defined table 0471 – Query name for suggested values.

(Definition from QPD.1 in Ch. 5)

Definition: This field contains the name of the query. These names are assigned by the function-specific chapters of this specification. It is one to one with the Query Profile for this query name, and it is in fact an identifier for that Query Profile. Site-specific query names begin with the letter "Z." Refer to User defined table 0471 – Query name in Chapter 2C, Code Tables, for suggested values.

QPD - Query Parameter Definition Segment

The QPD segment defines the parameters of the query.

HL7 Attribute Table - QPD - query parameter definition segment
Seq# DataElement Description Must Implement Flags Cardinality Length C.LEN Vocabulary DataType
QPD
1 01375 Message Query Name SHALL [1..1] CWE
2

00696 Query Tag MAY
True:
False:
C=
[1..1]
[0..1]
32 ST
3 01435 User Parameters = [0..1] 256 Varies

QPD-1: Message Query Name (CWE) 01375

(Definition from QAK.3 in Ch. 5)

Definition: This field contains the name of the query. These names are assigned by the function-specific chapters of this specification. Site-specific event replay query names begin with the letter "Z." Refer to User defined table 0471 – Query name in Chapter 2C, Code Tables, for suggested values.

(Definition from QID.2 in Ch. 5)

Definition: This field contains the name of the query. These names are assigned by the function-specific chapters of this specification. Site-specific query names begin with the letter "Z." Refer to User defined table 0471 – Query name for suggested values.

(Definition from QPD.1 in Ch. 5)

Definition: This field contains the name of the query. These names are assigned by the function-specific chapters of this specification. It is one to one with the Query Profile for this query name, and it is in fact an identifier for that Query Profile. Site-specific query names begin with the letter "Z." Refer to User defined table 0471 – Query name in Chapter 2C, Code Tables, for suggested values.

QPD-2: Query Tag (ST) 00696

(Definition from QAK.1 in Ch. 5)

Definition: This field may be valued by the initiating system to identify the query, and may be used to match response messages to the originating query. If it is valued, the responding system is required to echo it back as the first field in the query acknowledgment segment (QAK). This field differs from MSA-2-message control ID in that its value remains constant for each message (i.e., all continuation messages) associated with the query, whereas MSA-2-Message control ID may vary with each continuation message, since it is associated with each individual message, not the query as a whole. QAK-1-Query tag is not conditional on the presence of the QRD-1-Query ID field in the original mode queries; in the original mode queries QAK-1-Query tag is not used.

(Definition from QID.1 in Ch. 5)

Definition: This field identifies the instance of a query.

(Definition from QPD.2 in Ch. 5)

Definition: This field may be valued by the initiating system to identify the query, and may be used to match response messages to the originating query. If this field is valued, the responding system is required to echo it back as the first field in the query acknowledgement segment (QAK).

This field differs from MSA-2-Message control ID in that its value remains constant for each message (i.e., all continuation messages) associated with the query, whereas MSA-2-Message control ID may vary with each continuation message, since it is associated with each individual message, not the query as a whole.

Implementation considerations: It is not necessary to value this field in implementations where the only return message on the socket will be the response to the query that was just sent. Conversely, in an "asynchronous" implementation where many queries, responses, and other messages may be communicated bidirectionally over the same socket, it is essential that this field be valued so that the Client knows to which query the Server is responding.

QPD-3: User Parameters (Varies) 01435

Definition: These successive parameter fields hold the values that the Client passes to the Server.

The client data is presented as a sequence of HL7 fields. Beginning at QPD-3-User parameters, the remaining fields of the QPD segment carry user parameter data. Each QPD user parameter field corresponds to one parameter defined in the Query Profile, where each name, type, optionality, and repetition of each parameter has been specified. While these parameters are understood to be usually "anded" together, the user SHALL inspect the required Query Profile to properly understand each. Except in the QSC variant, the parameter names do not need to be stated in the query; they are understood to be positional based on the Query Profile.

Each parameter field may be specified in the Query Profile to be of any single data type, including the complex QIP and QSC types. Parameter fields may also contain the sort control (SRT) field or the segment group (ID) field defined in Sections 5.5.6.6, "RCP-6 Sort-by Field (SRT) 01624," and 5.5.6.7, "RCP-7 Segment Group Inclusion (ID) 01594," below.

Parameter fields in the QPD segment appear in the same order as in the Query Profile.

Note: Query By Example: The Query by Example is an extension of Query by Parameter (QBP) in which search parameters are passed by sending them in the segment which naturally carries them. Thus if one wanted to perform a "find_candidates" query using query by example, one would send the demographics information on which to search in the PID and/or PD1 segments leaving blank those fields in the segment sent which are not query parameters. If, for example, religion were not one of the query parameters, PID-17 would be left blank when the PID was sent in the query. Parameters which do not occur naturally in an HL7 message, such as search algorithm, confidence level, etc, would continue to be carried in the QPD segment as they are in the Query by Parameter. The segments and fields available for use as query parameters would be specified in the Query Profile for the query.


QRI - Query Response Instance Segment

The QRI segment is used to indicate the weight match for a returned record (where the responding system employs a numeric algorithm) and/or the match reason code (where the responding system uses rules or other match options).

Examples of the use of this segment appear in Chapter 3, "Patient Administration," section 3.3.57, "Find Candidates and Response."

HL7 Attribute Table - QRI - query response instance segment
Seq# DataElement Description Must Implement Flags Cardinality Length C.LEN Vocabulary DataType
QRI
1 01436 Candidate Confidence # [0..1] 10 NM
2 01437 Match Reason Code [0..*] [2..2] CWE
3 01438 Algorithm Descriptor [0..1] CWE

QRI-1: Candidate Confidence (NM) 01436

Definition: This field contains a numeric value indicating the match weight or confidence level associated with the record.

Example: |0.88| or |12.32|

One use of this optional field is in Patient Look-up transactions where the searching system employs a numeric algorithm for determining potential matches to patient/person look-ups.

QRI-2: Match Reason Code (CWE) 01437

Definition: This field contains a coded value indicating what search components (e.g., name, birth date, social security number) of the record returned matched the original query where the responding system does not assign numeric match weights or confidence levels. In short, it provides a method for passing a descriptive indication of why a particular record was found.

.Refer to User-defined Table 0392 – Match reason in Chapter 2C, Code Tables, for suggested values.

QRI-3: Algorithm Descriptor (CWE) 01438

Definition: This field contains a text value indicating the name or identity of the specific search algorithm to which the RCP-5 Search confidence threshold and the QRI-1 Candidate confidence refer. Note that there are sometimes significant differences among the algorithms in their numeric scales (e.g., one is 0-100, another might be 10 – 20) as well as their meanings of the same value (two algorithms with an 80% match might not return the same records). Refer to User-defined Table 0393 – Match algorithms in Chapter 2C, Code Tables, for suggested values.

Example: |MATCHWARE_1.2^^HL70393| or |LINKSOFT_2.01^^HL70393|

One use of this optional field is in Patient Look-up transactions where the searching system employs a numeric algorithm for determining potential matches to patient/person look-ups.

RCP - Response Control Parameter Segment

The RCP segment is used to restrict the amount of data that should be returned in response to query.

HL7 Attribute Table - RCP - response control parameter segment
Seq# DataElement Description Must Implement Flags Cardinality Length C.LEN Vocabulary DataType
RCP
1 00027 Query Priority [0..1] [1..1] ID
2 00031 Quantity Limited Request [0..1] CQ
3 01440 Response Modality [0..1] CNE
4

01441 Execution and Delivery Time MAY
True:
False:
C
[1..1]
[0..1]
DTM
5 01443 Modify Indicator [0..1] [1..1] ID
6 01624 Sort-by Field [0..*] SRT
7 01594 Segment group inclusion [0..*] [1..256] ID

RCP-1: Query Priority (ID) 00027

Definition: This field contains the time frame in which the response is expected. Refer to HL7 Table 0091 – Query priority in Chapter 2C, Code Tables, for valid values. Table values and subsequent fields specify time frames for response.

RCP-2: Quantity Limited Request (CQ) 00031

Definition: This field contains the maximum length of the response that can be accepted by the requesting system. Valid entries are numerical values (in the first component) given in the units specified in the second component. Default is LI (lines).

Refer to HL7 Table 0126 – Quantity limited request in Chapter 2C, Code Tables, for valid entries for the second component. In a segment pattern response, a line is defined as a single segment.

RCP-3: Response Modality (CNE) 01440

Definition: This field specifies the timing and grouping of the response message(s). Refer to HL7 Table 0394 – Response modality in Chapter 2C, Code Tables, for valid values.

RCP-4: Execution and Delivery Time (DTM) 01441

Definition: Specifies the time the response is to be returned. This field is only valued when RCP-1-Query priority contains the value D (Deferred).

RCP-5: Modify Indicator (ID) 01443

Definition: This field specifies whether the subscription is new or is being modified. Refer to HL7 Table 0395 – Modify indicator in Chapter 2C, Code Tables, for valid values.

RCP-6: Sort-by Field (SRT) 01624

Definition: For queries requesting a tabular response, this field specifies by which fields the response is to be sorted, and the order(s) in which sorting is to be performed. When the QSC variant is not in use, the values specified for the first component in this field are derived from the ColName field of the Output Specification and Commentary; see section 5.3.3.1, "Query Profile template for query with tabular response." When the QSC variant is used, the values are derived from the ColName field of the Input/Output Specification and Commentary; see section 5.9.4.1, "Pharmacy example" for an example.

Each repetition of this field specifies a single sort field. Thus, the first repetition of this field specifies the primary sort field; the second repetition specifies the secondary sort field; etc.

RCP-7: Segment group inclusion (ID) 01594

Definition: Specifies those optional segment groups which are to be included in the response. Refer to HL7 Table 0391—Segment group in Chapter 2C, Code Tables, for values for Segment Group. This is a repeating field, to accommodate inclusion of multiple segment groups. The default for this field, not present, means that all relevant groups are included.

RDF - Table Row Definition Segment

The RDF segment defines the content of the row data segments (RDT) in the tabular response (RTB).

  • As an optional segment in a query either a QBP or QBS, this segment can be used to limit the number of columns returned and to specify what column positions the fields occupy (where supported, these features can be used to override the defaults for the particular query). If omitted, all fields defined for the query are returned in their default column order.

  • As a required segment in a tabular response (RTB) to either a QBP or QBS, this segment defines the contents of the table row data (RDT) segments that follows. It is not necessarily an echo back of the segment as it appeared in the query.

HL7 Attribute Table - RDF - table row definition segment
Seq# DataElement Description Must Implement Flags Cardinality Length C.LEN Vocabulary DataType
RDF
1 00701 Number of Columns per Row SHALL = [1..1] 3 NM
2 00702 Column Description SHALL [1..*] RCD

RDF-1: Number of Columns per Row (NM) 00701

Definition: This field specifies the number of data columns (and therefore the number of fields) contained within each row of returned data.

RDF-2: Column Description (RCD) 00702

Definition: Each repetition of this field consists of three components:

The segment field name that identifies the field occupying the column. The segment field name SHALL agree with the column name as it appears in the Query Profile. Use of the @ sign as prefix to the column name is optional.

  • The 2 or 3 character HL7 data type, as defined in Chapter 2. Refer to HL7 Table 0440 – Data types in Chapter 2C, Code Tables, for valid values.

  • The maximum width of the column, as dictated by the responding system. (This may vary from the HL7-defined maximum field length.)

RDT - Table Row Data Segment

The RDT segment contains the row data of the tabular data response message (TBR).

HL7 Attribute Table - RDT - table row data segment
Seq# DataElement Description Must Implement Flags Cardinality Length C.LEN Vocabulary DataType
RDT
1 00703 Column Value SHALL [1..1] Varies

RDT-1: Column Value (Varies) 00703

Definition: This field is a requested field. Fields occur in the position order defined for the query or table (unless overridden by an optional RDF segment on a stored procedure request or Virtual Table query message), separated by field delimiters.

AUXILIARY QUERY PROTOCOLS

This section discusses properties of queries that can be described as global properties. These properties enable the Client and Server to deal with timing and sizing issues and to handle exceptions.

Immediate vs. deferred response

Responses to queries can be either immediate or deferred. In the immediate mode, the responding process gives the response immediately or in a short period during which the requesting process will wait for the response. In the deferred mode, the response is returned asynchronously, as a separate message pair. Also, a time interval for the deferred transaction may be specified.

In the case of immediate mode query, the Server does NOT send a General Acknowledgement (ACK). The acknowledgement of the query is contained within the response message. In the case of deferred mode, the query is acknowledged immediately by an ACK. The Server sends the deferred response at the appropriate time. The Client acknowledges the response with an ACK. In short, the deferred query transaction consists of 2 "round trips."

If an immediate mode query message is malformed, a negative ACK is immediately sent.

Use cases for Deferred Response include:

  1. evaluate the query conditions at a certain point in time and then return the response. For example, "At 9 AM tomorrow, evaluate query and return response";

  2. produce a large report to be communicated to the Server at an off-peak hour. For example, a response which contains all admissions records for the month to be sent at 4:00 a.m., or a reference lab results listing to be sent at noon. A deferred response can benefit both Server and Client in such cases, especially where the generation, communication, and receipt of segments can all be done at times of otherwise low-volume processing.

If the Query Profile indicates that the Server will support both immediate and deferred responses, then the Client may indicate the desired value of this property by sending it in the RCP-1 Response priority field. If the Server supports only one response type, then the value specified by the Client SHALL agree.

The following examples demonstrate how the same query could be invoked in either immediate or deferred mode.

Immediate response

The Client submits the following query and indicates that an immediate response is desired by setting RCP-1-Response priority to "I".

MSH|^~VALUEamp;|PCR|Gen Hosp|PIMS||199811201400-0800||QBP^Q42^QBP_Q13|ACK9901|P|2.8||||||||

QPD|Q42^Tabular Dispense History^HL70471|Q0010|555444222111^^^MPI^MR| |19980531|19990531|

RCP|I|999^RD|

RDF|3|PatientList^ST^20~PatientName^XPN^48~MedicationDispensed^ST^40~RXD.3^DTM^24

The Server responds one minute later.

MSH|^~VALUEamp;|PIMS|Gen Hosp|PCR||199811201401-0800||RTB^K42^RTB_K13|8858|P|2.8||||||||

MSA|AA|8699|

QAK|Q010|OK|Q42^Tabular Dispense History^HL7nnn|4

QPD|Q42^Tabular Dispense History^HL7nnn|Q0010|555444222111^^^MPI^MR||19980531|19990531|

RDF|7|PatientId^CX^20~PatientName^XPN^48~OrderControlCode^ID^2~ MedicationDispensed^CWE^100~DispenseDate^DTM^24~QuantityDispensed^NM^20~ OrderingProvider^XCN^120

RDT|555444222111^^^MPI^MR|Everyman^Adam|RE|525440345^Verapamil Hydrochloride 120 mg TAB^NDC |199805291115-0700|100|77^Hippocrates^Harold^H^III^DR^MD

RDT|555444222111^^^MPI^MR|Everyman^Adam|RE|00182196901^VERAPAMIL HCL ER TAB 180MG ER^NDC |19980821-0700|100|77^Hippocrates^Harold^H^III^DR^MD

RDT|555444222111^^^MPI^MR|Everyman^Adam|RE|00172409660^BACLOFEN 10MG TABS^NDC |199809221415-0700|10|88^Seven^Henry^^^DR^MD

RDT|555444222111^^^MPI^MR|Everyman^Adam|RE|00054384163^THEOPHYLLINE 80MG/15ML SOLN^NDC|199810121145-0700|10|99^Assigned^Amanda^^^DR^MD

Deferred response example

The Client submits the following query and indicates that a deferred response is desired by setting RCP-1-Response priority to "D".

MSH|^~VALUEamp;|PCR|Gen Hosp|PIMS||199811201400-0800||QBP^Q42^QBP_Q13|ACK9901|P|2.8||||||||

QPD|Q42^Tabular Dispense History^HL7nnn|Q0010|555444222111^^^MPI^MR| |19980531|19990531|

RCP|D|999^RD|

RDF|3|PatientList^ST^20~PatientName^XPN^48~MedicationDispensed^ST^40~RXD.3^DTM^24

The Server responds one minute later with a general acknowledgement.

MSH|^~VALUEamp;|PIMS|Gen Hosp|PCR||199811201401-0800||ACK^Q42^ACK|8875|P|2.8||||||||

MSA|AA|8699|

The Server responds the following morning with the desired data.

MSH|^~VALUEamp;|PIMS|Gen Hosp|PCR||199811210300-0800||RTB^K42^RTB_K13|9950|P|2.8||||||||

QAK|Q010|OK|Q42^Tabular Dispense History^HL7nnn|4

QPD|Q42^Tabular Dispense History^HL7nnn|Q0010|555444222111^^^MPI^MR||19980531|19990531|

RDF|7|PatientId^CX^20~PatientName^XPN^48~OrderControlCode^ID^2~ MedicationDispensed^CWE^100~DispenseDate^DTM^24~QuantityDispensed^NM^20~ OrderingProvider^XCN^120

RDT|555444222111^^^MPI^MR|Everyman^Adam|RE|525440345^Verapamil Hydrochloride 120 mg TAB^NDC |199805291115-0700|100|77^Hippocrates^Harold^H^III^DR^MD

RDT|555444222111^^^MPI^MR|Everyman^Adam|RE|00182196901^VERAPAMIL HCL ER TAB 180MG ER^NDC |19980821-0700|100|77^Hippocrates^Harold^H^III^DR^MD

RDT|555444222111^^^MPI^MR|Everyman^Adam|RE|00172409660^BACLOFEN 10MG TABS^NDC |199809221415-0700|10|88^Seven^Henry^^^DR^MD

RDT|555444222111^^^MPI^MR|Everyman^Adam|RE|00054384163^THEOPHYLLINE 80MG/15ML SOLN^NDC|199810121145-0700|10|99^Assigned^Amanda^^^DR^MD

The Client responds immediately with a general acknowledgement.

MSH|^~VALUEamp;|PCR|Gen Hosp|PIMS||199811210300-0800||ACK^K42^ACK|8750|P|2.8||||||||

MSA|AA|9950|

Query cancellation

Canceling a query is equivalent to canceling an order in that it is asking the discontinuation of a request for which a response may already be on its way. In the case of an interactive query, a cancellation request is a courtesy on the part of the Client, but not strictly required. How long the query will stay open is an implementation issue.

Although the effect to the Client is the same as if it had not sent any message (no further query data is received), receipt of this message by the Server enables it to discard any unsent continuation data that might be queued.

MSH|^~VALUEamp;|||||||QCN^Jnn^QCN_J01|...

QID|Q001|Q99^SomeQuery^0003|...

...

Interactive continuation of response messages

The Interactive Continuation Protocol defines the methodology for the intentional transmission of a large query-response payload over multiple HL7 messages. Without this protocol, the response would be returned in a single large logical message.

The protocol is called interactive because there is an ongoing dialog between the Client and the Server. The dialog commences when the Client issues a query for a potentially large amount of data, but specifies in the RCP-2-Quantity limited request, that only a limited amount of data is to be returned in each continued response. The Server then returns one response message containing data up to the requested quantity. The Client may continue to ask for further subsets of the data until the entire set is exhausted or may choose to cancel the query.

This use of the term "continuation" responses in queries should not be confused with its use in continuing an unsolicited fragmented message. In the case of continuing a response to query the control is on the side of the querying application and there is an explicit cancellation event. In the case of continuation of an unsolicited message, the control is on the part of the sending application and there is no concept of canceling the message transmission.

Segment fragmentation and message fragmentation are discussed in Chapter 2.

Interactive continuation algorithm and rules

The rules for the interactive continuation (of a query response) are as follows:

  • If the Server is sending a subset of the data, the message is terminated with a DSC segment with the DSC-1-Continuation pointer set to the appropriate pointer value and the DSC-2 -Continuation type set to "I".

  • If the Client wishes to receive the next installment, the query is sent again with a DSC segment following the RCP. The DSC-1-Continuation pointer echoes the value sent by the Server.

  • The Server continues to send installments in response to the Client's request until there is no more data. The end of data is signified by the absence of the DSC segment OR an empty value in DSC-1-Continuation pointer.

  • If the Client wishes to cancel the query before the end of the data is reached, a Cancel query is sent.

In addition to DSC-1-Continuation pointer, QAK-1-Query tag may be used to confirm to the Client which query instance the Server is responding to, since the Client may not be relied upon to have retained the text of each query message and continuation request.

The value of MSH-10-Message control ID will be different for every message sent by the Client (i.e., the initial query and each continuation request). Thus the value of MSA-2-Message control ID for each message sent by the Server (which echoes the value of MSH-10-Message control ID from the Client) will vary among multiple response payload messages. By contrast, QAK-1-Query tag will remain the same across all response payload messages to a given query instance.

Use case

One use of queries is to retrieve data from one application for presentation to users of another. This approach might be used for users of a patient care system retrieving data from lab or other ancillaries. It also might permit users of a pharmacy system to retrieve a patient's lab results from the lab system or non-pharmacy order data from the patient care system. Almost any other application system could be the source of data or the system initiating the query for its users.

Of particular interest is the case where the inquiring user formulates the query online at the terminal of one system and waits while that system sends the query to another. The inquiring user gets the response and displays it at their terminal. The user formulating such a query may only have limited understanding of what data is available for a given patient. Sometimes the user's preference would be to make a simple query such as "give me recent data in reverse chronological sequence" rather than "give me data for yesterday," since there may be some data available for today, or there may be data from two days ago that is of interest. The user will look at the data returned and simply quit looking at it after finding the part that is of interest. (The time frames or the sort sequence may differ, or the user may wish to impose some selectivity on the response, but the general principle remains the same. The user would prefer to make a vague statement of the interest, have the data presented in order of decreasing likelihood of interest, and quit when he or she has seen enough.)

While beneficial to the user, this way of requesting data could be very burdensome when the resulting query takes place over an inter-application interface. If the Server were to retrieve, format, and send all the data the user might like to see, the processing load would be extremely high and the response time unacceptable.

The interactive continuation protocol provides a way to permit the users to formulate queries loosely while limiting the processing burden on the Server. The Client specifies the general constraints of the query and an amount of data to be returned. (For example, the query might be for lab results for patient #12379 and 44 lines would be requested.) The Server retrieves and formats the specified amount of data and returns it with a special key field, DSC-1-Continuation pointer. The Server presents the requested data to the user and retains the continuation pointer field for use if another query is needed. The internal structure of the value is not known to the Client.

If, after viewing the data, the user requests more, the Client sends the query again in a format that is identical with the first, except that DSC-1-Continuation pointer value is included and the requested amount of data may be changed. The Server may use the continuation pointer field as a key into its database to continue retrieval and formatting of the results. If the user does not request more data, no further messages are exchanged.

The initiating system may also explicitly terminate the query by sending a QCN^J01 (cancel query) message. Receipt of the QCN^J01 message by the responding system enables it to discard any unsent continuation data that might be queued.

Example of interactive continuation protocol

The user wishes to know all the medications dispensed for the period between January 1, 1998, and December 31, 1999, for the patient whose medical record number is "555444222111". The Client submits the following query and invokes the interactive continuation protocol. Note that the quantity has been limited to 8 lines.

MSH|^~VALUEamp;|PCR|Gen Hosp|IE||200009171400-0800||QBP^Q41^QBP_Q15|8699|P|2.8||||||||

QPD|Q41^DispenseHistory^HL7nnnn|Q001|555444222111^^^MPI ^MR||19980101|19991231|

RCP|I|8^LI|

The pharmacy system identifies medical record number "555444222111" as belonging to Adam Everyman and locates 7 prescription dispenses meeting the criteria. As shown in the following response, eight lines of data are returned as requested. The response ends with a DSC segment showing the continuation pointer and the indication that this is a logical breaking point.

MSH|^~VALUEamp;|PIMS|Gen Hosp|PCR||200009171401-0800||RDY^R41^RDY_K15|8858|P|2.8||||||||

MSA|AA|8699|

QAK|Q001|OK|Q41^DispenseHistory^HL7nnnn|^8

QPD|Q41^DispenseHistory^HL7nnnn|Q001|555444222111^^^MPI^MR||19980101|19991231|

DSP||| GENERAL HOSPITAL – PHARMACY DEPARTMENT DATE:09-17-00

DSP||| DISPENSE HISTORY REPORT PAGE 1

DSP|||MRN Patient Name MEDICATION DISPENSED DISP-DATE

DSP|||555444222111 Everyman,Adam VERAPAMIL HCL 120 mg TAB 10/12/1999

DSP|||555444222111 Everyman,Adam VERAPAMIL HCL ER TAB 180MG 09/21/1999

DSP|||555444222111 Everyman,Adam BACLOFEN 10MG TABS 08/22/1999

DSP|||555444222111 Everyman,Adam THEOPHYLLINE 80MG/15ML SOL 05/29/1999

DSP||| << END OF Screen>>

DSC|77|I|

The Client wishes to receive another payload. 2

MSH|^~VALUEamp;|PCR|Gen Hosp|IE||199811201405-0800||QBP^Q41^QBP_Q15|8890|P|2.8||||||||

QPD|Q41^DispenseHistory^HL7nnnn|Q001|555444222111^^^MPI^MR||19980101|19991231|

RCP|I|8^LI|

DSC|77|I|

The Server returns the next payload and indicates in QAK-4-Hit count that this is the last of the data..

MSH|^~VALUEamp;|PIMS|Gen Hosp|PCR||199811201407-0800||RDY^K15^RDY_K15|8898|P|2.8||||||||

MSA|AA|8890|

QAK|Q001|OK|Q41^DispenseHistory^HL7nnnn|^7^^Y|

QPD|Q41^DispenseHistory^HL7nnnn|Q001|555444222111^^^MPI^MR||19980101|19991231|

DSP||| GENERAL HOSPITAL – PHARMACY DEPARTMENT DATE:09-17-99

DSP||| DISPENSE HISTORY REPORT PAGE 1

DSP|||MRN Patient Name MEDICATION DISPENSED DISP-DATE

DSP|||555444222111 Everyman,Adam VERAPAMIL HCL 120 mg TAB 05/29/1998

DSP|||555444222111 Everyman,Adam VERAPAMIL HCL ER TAB 180MG 04/21/1998

DSP|||555444222111 Everyman,Adam BACLOFEN 10MG TABS 04/22/1998

DSP||| << END OF REPORT>>

The query/response is now completed.

[2]     If the Client elects to cancel the query at this point, a cancel query message will be sent. The query would look as follows:

[2] MSH||||||||QCN^J01^QCN_J01|8956|P|2.8

[2] QUD…

Message fragmentation example

Query responses, like unsolicited updates, may need to force the continuation of a message, or even a segment, across multiple physical messages. This is more precisely described as fragmenting. Fragmentation is discussed in detail in Chapter 2. Those aspects pertaining to how this would apply to a query response are repeated here for the reader's convenience.

The Client requests the last chest x-ray for the patient whose medical record number is 555444222111. The following query is submitted.

MSH|^~VALUEamp;|CIS||RAD||199910180900-0700||QBP^Q61^QBP_Q11|7777|P|2.7|

QPD|Q61^Radiology Result^HL7nnnn|Q98|555444222111^^^^MR|

RCP|I|

The Server returns the following response but the OBX segment that contains a DICOM image overflows its buffer. The segment is fragmented as follows:

MSH|^~VALUEamp;|RAD||CIS||||RSP^K61^RSP_K61|5555|P|2.8|

MSA|AA|7777|

QAK|Q98|OK|Q61^Radiology Result^HL7nnnn|

QPD|Q61^Radiology Result^HL7nnnn|Q98|555444222111^^^^MR|

PID|||5554442221111^^^^MR|

ORC

OBR

OBX||ED|13^^L||abcdefghij|

ADD|

DSC|99|F|

The Client returns an ACK upon receipt of the response.

MSH|^~VALUEamp;|CIS||RAD||||ACK^K61^ACK|7780|P|2.8|

MSA|AA|5555|

The Server sends the following continued response. Note that the ADD segment will contain the remainder of the data from the fragmented segment. The response then continues on as normal.

MSH|^~VALUEamp;|RAD||CIS||||RSP^K61^RSP_K61|5560|P|2.7||99|

ADD|klmnop|

OBX|

...

The Client returns an ACK upon receipt of the response.

MSH|^~VALUEamp;|CIS||RAD||||ACK^K61|7782|P|2.8|

MSA|AA|5560|

Batch message as a query response

The HL7 query also can be used to query for a batch in the following manner:

  1. Use the value B of RCP-3-Response modality to specify a batch response.

Note: If using old style query mode, the value BB or BL of QRD-5-Deferred response type may be used to specify a batch response. The query will be acknowledged with a general acknowledgment as in the Deferred Access example above


  1. In addition, insert into the batch file the query defining and RCP segments as follows:

[FHS]

(file header segment)

{

[BHS]

(batch header segment)

QPD

Query defining segment Note: if using old style query mode, the QRD and QRF segments may be used.

[RCP]

{

MSH

(one or more HL7 messages)

....

....

....

}

[BTS]

(batch trailer segment)

}

[FTS]

(file trailer segment)


  1. The acknowledgment of a batch is described in Chapter 2.

  2. The Query Profile should stipulate if the batch modality is supported.

Query error response

A query/response error can occur at 3 levels:

  • Communication failure (broken connection, timeout)

  • Malformed message (message reject)

  • Malformed query (application error)

If the application receiving the query detects an error while processing the query, the preferred method of response is to return an Application Error (AE) or Application Reject (AR) condition in the MSA-1-Acknowledgement code of the applicable query response message. Further description of the error code is to be included in ERR-1-Error code and location. Note that MSA-6-Error condition is retained for backward compatibility for those applications not using the ERR segment. Thus far, this method is consistent with the methods used elsewhere for reporting errors in acknowledgement messages, irrespective of the type of message being acknowledged. In addition, because this is a query response, it is important to include the QAK segment because it specifies the query tag that will identify the particular query instance that was in error. This is of particular importance where a query response may span more than one message.

In summary, use the ERR segment to describe the error if the message fails because of

  • a malformed message

  • a malformed query – problem with query tag, problems with parameters

The ERR segment supersedes QAK-2-Query response status.

There are 3 common situations that can arise in a query error response:

Situation 1: Malformed Message

The query message itself is bad. The parser does not get to the actual query content. Something is wrong with the envelope, i.e., the message is malformed.

The only response is a negative ACK message containing the MSH, MSA and the ERR. That is, the Server creates an ACK message with AR in MSA-1-Acknowledgement code in the above sentence. The dialogue is ended.

Situation 2: Malformed Query

The query message got to the Server and is legitimate, but the Server cannot process the query for some reason, i.e., the query is malformed.

The Response message indicates a negative acknowledgement and shows the problem in the ERR. The response message contains the MSH, MSA, ERR, QAK and the query defining segment if available. That is, the Server creates an ACK message with AE in MSA-1-Acknowledgement code in the above sentence. The rest of the message is absent.

Note that the continuation (DSC) segment is not sent or, if it is, its continuation pointer field (DSC-1-Continuation pointer) is null.

Note: The use of AE (application error) and AR (application reject) codes in QAK-2-Query response status has been deprecated in favor of the ERR segment.


Situation 3: No data found

The query is well formed, but there is no data to be returned by the query. This is not strictly an error condition. This example clarifies the protocol to be followed.

The Response message contains MSH, MSA, QAK, and query defining segment. The QAK would indicate "no records found". The rest of the message is absent, i.e., no blank rows or segments are sent.

Note: If the responding application successfully processes the query, but is unable to find any qualifying data, this is not an error condition. The responding application returns an Application Accept (AA) in the MSA segment of the query response message, but does not return any data segments (DSP, RDT, or iterations of the items that are counted in hit counts). The continuation (DSC) segment is not sent or, if it is, its continuation pointer field (DSC-1- Continuation pointer) is null. If the QAK segment is being used, the field QAK-2-Query response status is valued with NF (no data found, no errors).


PUBLISH AND SUBSCRIBE

This section outlines the framework/process of the publish and subscribe machinery.

Introduction

"Publish and subscribe" refers to the ability of one system, the "Publisher", to offer a data stream that can be sent to recipient systems upon subscription. In one sense, the entire HL7 unsolicited update paradigm, in which the sender sends out a stream of messages to recipients, is a kind of publish and subscribe mechanism. Subscriptions to unsolicited updates are established at interface set-up time when analysts on both sides agree to start sending a stream of data.

This section describes a mechanism by which the Publisher defines a stream of data, but also agrees to selectively subset the message stream based on query-like data constraints. In the normal case, the right of the Subscriber to subscribe is decided at interface setup time. At runtime, the Subscriber controls the data rules under which it sends messages.

Runtime subscription has existed in earlier versions of HL7, but little attention has been drawn to it. Original mode queries could define an open ended time interval in QRF-9 - When quantity/timing qualifier. The unexplained semantics of this field had been interpreted to mean: If the QRF-9 specified an end time in the future, then the source system would keep sending results using the query continuation protocol.

This section elaborates on such a mechanism, and more cleanly ties the selective filtering into the whole query facility.

Details

Subscription is a process/protocol that allows one system to request that prospective data be sent for a specified period of time, or for an open-ended period of time until further notice. It allows a message stream to be selectively filtered by a query-like mechanism. Specific messages have been defined for subscription and the canceling of a subscription.

A Publisher is one who possesses and transmits streams of data. The Publisher might be a mediator or a broker, such as an interface engine. The Publisher is not necessarily the system that collected the data, but it is the system willing to transmit it

With traditional "unsolicited update subscriptions" a Publisher sends the entire data stream to the recipients. A Publisher normally transmits unfiltered data. However, the Publisher may agree to selectively filter the stream of data within parameters as defined by analysts. For each filterable stream, the Publisher defines a Query Profile that lists the data values that may be used in the filter expression, and defines the segment pattern for the messages that are selected.

If supported in the Query Profile, a subscription may be modified at a later date. RCP-6-Modify indicator is set to "M", and the Action Code parameter is set to "A" or "D" as appropriate. If modification is allowed, the Server bears responsibility for maintaining the filter list. If, as is usually the case, the onus of retaining the filters is on the Client, modification is not allowed and would not be part of the Query Profile.

Examples

A lab system normally sends all reports to the central archive. To provide better service to other departments, the Lab decides to offer a filtered stream in addition to the full stream going to the archive.

The lab decides that it will allow recipients to select based on the MRN of the patient, on the type of study (OBR-4), and on the ordering provider (OBR-16). It names this filtered stream "ORU-Subscription" and writes a conformance specification.

At interface setup time, permission is given for four systems, CommunityNorth, CommunitySouth, CommunityEast and CommunityWest to receive this filtered stream.

The Query Profile for this published filtered stream might be:

Example of a publish and subscribe Query Profile

Query Profile

Publication ID (Query ID=Z83):

Z83

Type:

Publish

Publication Name:

ORU Subscription

Query Trigger (= MSH-9):

QSB^Z83^QSB_Q16

Query Mode:

Both

Response Trigger (= MSH-9):

ORU^R01^ORU_R01

Query Characteristics:

Returns lab results reports for the patient(s) as constrained in the input parameters.

Purpose:

Sends Lab Results, either filtered or unfiltered, as specified in the input parameters.

Response Characteristics:

A standard query response is not received from the server. Instead, actual ORU messages are returned corresponding to the constraints expressed in the input parameters.

The input parameters are ANDed when selecting data to be returned. That is, all input parameters that are specified SHALL be satisfied in order for a result report to be sent.

Based on Segment Pattern:

R01


QSB^Z83^QSB_Q16: Query Grammar: QSB Message
HL7 MessageStructure Table - QBP_Q21
Segment Cardinality Must Implement Status
QBP_Q21

See the definition of the ORU^R01 Message Structure in Chapter 7, section 7.3.1, ORU – Unsolicited Observation Message (Event R01).

QPD Input Parameter Specification

Field Seq (Query ID=Z83)

ColName

Key/

Search

Sort

LEN

DT

Opt

RP/#

Match Op

TBL #

Segment Field Name

Service Identifier Code

Element Name

1

MessageQueryName

60

CWE

R

Message Query Name

2

QueryTag

32

ST

R

Query Tag

3

MRN

CX

O

Y

PID.3

4

ActionCode

ID

O

0323

5

PatientLocation

PL

O

Y

PV1.3

6

HospitalService

CWE

O

Y

PV1.10

7

SRVC

CWE

O

Y

OBR.4

8

PVDR

CN

O

Y

OBR.16


QPD Input Parameter Field Description and Commentary

Input Parameter (Query ID=Z83)

Comp. Name

DT

Description

MessageQueryName

CWE

SHALL be valued Z83^ORU Subscription^HL7nnnn.

QueryTag

ST

Unique to each query message instance.

MRN

CX

One or more patient identifiers may be sent. When a list is provided, results will be sent if any parameter matches any ID known for a patient. Sending no value matches all patients

ActionCode

ID

If the subscription is being modified, the desired action e.g., Add or Delete is carried in this field.

PatientLocation

PL

When a list is provided, results will be sent if any parameter matches PV1.3 for any result. Sending no value matches all results.

HospitalService

CWE

When a list is provided, results will be sent if any parameter matches PV1.10 for any result. Sending no value matches all results.

SRVC

CWE

When a list is provided, results will be sent if any parameter matches OBR.4 for any result.. Sending no value matches all results.

PVDR

CN

When a list is provided, results will be sent if any parameter matches OBR.16 for any result.. Sending no value matches all results.


RCP Response Control Parameter Field Description and Commentary

Field Seq (Query ID=Z99)

Name

Component Name

LEN

DT

Description

1

Query Priority

1

ID

(D)eferred or (I)mmediate. Default is I.

2

Quantity Limited Request

10

CQ

Quantity

NM

Number of units (specified by the following component) that will be returned in each increment of the response. If no value is given, the entire response will be returned in a single increment.

Units

CWE

Characters, Lines, PaGes, or RecorDs. Default is LI.

3

Response Modality

60

CWE

Real time or Batch. Default is R.

7

Segment group inclusion

256

ID

What segment group(s) are to be included. If this field is not valued, all segment groups will be included.


Establishing a subscription

To establish the subscription to see lab results for two patients, an authorized Subscriber (e.g., CommunityWest) would send a query message with event code Q99:

MSH|^~VALUEamp;|CPR|COMWEST|PS^LAB||||QSB^Q99^QSB_Q16|8888|P|2.8|

QPD|Q99^ORU_Subscription^HL7nnnn|Q0044|1234^^^MPI^MR~4567^^^MPI^MR|

RCP||||||N|

As results are generated by the Lab, they are all sent to the archive. In addition, the Lab has a list of all subscription requests (such as the message, above). For each message, it checks the query filters associated with the subscription against the message being considered. If the message matches the query, it is sent to the recipient.

For example, a hit on patient 4567 would result in the message:

MSH|^~VALUEamp;|PS^LAB||CPR|COMWEST||||ORU^R01^ORU_R01|4409|P|2.8|

PID|||4567^^^MPI^MR|....

OBR|....

OBX|...

Note: The result message has message type ORU^R01^ORU_R01 (as specified by the Query Profile).


Canceling a subscription

Canceling a subscription is analogous to canceling a query. See sections 5.4.6 and 0.

The template would be as follows:

MSH|^~VALUEamp;|||||||QSX^Jnn^QSX_J01|

QID...

To cancel the subscription cited in the previous section, CommunityWest would send a cancel message with event code J99:

MSH|^~VALUEamp;|CPR|COMWEST|PS^LAB||||QSX^J99^QSX_J01|

QID|Q0044|Q99^ORU_Subscription^HL70003|

QUERY IMPLEMENTATION CONSIDERATIONS

Implementation issues are discussed in section 5.2.

QUERY/RESPONSE MESSAGE EXAMPLES

Query by parameter (QBP) / segment pattern response (RSP)

Proposed dispense history example and Query Profile

The following is the structure of the Pharmacy Dispense Information (RDR) message, an original-mode query that was defined in Chapter 4.

RDR^RDR^RDR_RDR: Pharmacy/treatment Dispense Information
HL7 MessageStructure Table - RDR_RDR
Segment Cardinality Must Implement Status
RDR_RDR
MSH 1..1 Yes
MSA 1..1 Yes
ERR 0..*
SFT 0..1
UAC 0..1
DEFINITION 1..* Yes

Query Definition

Query Filter

PATIENT 0..1
PID 1..1 Yes
NTE 0..*
ORDER 1..* Yes
ORC 1..1 Yes
TIMING 0..*
TQ1 1..1 Yes
TQ2 0..*
ENCODING 0..1
RXE 1..1 Yes
RXR 1..* Yes
RXC 0..*
TIMING_ENCODED 0..*
TQ1 1..1 Yes
TQ2 0..*
DISPENSE 1..* Yes
RXD 1..1 Yes
RXR 1..* Yes
RXC 0..*
DSC 0..1

The function served by that query can be more clearly defined within the new query functionality. In the RDR message, the full meaning of the filter elements in the QRD and QRF segments could be discerned only by inference. By contrast, needed parameters can be explicitly defined in the Query Profile for the new Dispense History query, as shown in the following example.

Example: The user wishes to know all the medications dispensed for the patient whose medical record number is "555444222111" for the period beginning 5/31/98 and ending 5/31/99. The following QBP message is generated:

MSH|^~VALUEamp;|PCR|Gen Hosp|PIMS||199811201400-0800||QBP^Z81^QBP_Q11|ACK9901|P|2.8||||||||

QPD|Z81^Dispense History^HL7nnnn|Q001|555444222111^^^MPI^MR||19980531|19990531|

RCP|I|999^RD|

The pharmacy system identifies medical record number "555444222111" as belonging to Adam Everyman and locates 4 prescription dispenses for the period beginning 5/31/98 and ending 5/31/99and returns the following RSP message:

MSH|^~VALUEamp;|PIMS|Gen hosp|PCR||199811201400-0800||RSP^Z82^RSP_Z82|8858|P|2.8||||||||

MSA|AA|ACK9901|

QAK|Q001|OK|Z81^Dispense History^HL7nnnn|4|

QPD|Z81^Dispense History^HL7nnnn|Q001|555444222111^^^MPI^MR||19980531|19990531|

PID|||555444222111^^^MPI^MR||Everyman^Adam||19600614|M||C|2101 Webster # 106^^Oakland^CA^94612||^^^^^510^6271111|^^^^^510^6277654|||||343132266|||N|||||||||

ORC|RE||89968665||||||199805121345-0700|||77^Hippocrates^Harold^H^III^DR^MD||^^^^^510^ 2673600||||||

RXE|1^BID^^19980529|00378112001^Verapamil Hydrochloride 120 mg TAB^NDC |120||mgm||||||||||||||||||||||||||

RXD|1|00378112001^Verapamil Hydrochloride 120 mg TAB^NDC |199805291115-0700|100|||1331665|3|||||||||||||||||

RXR|PO||||

ORC|RE||89968665||||||199805291030-0700|||77^Hippocrates^Harold^H^III^DR^MD||^^^^^510^ 2673600||||||

RXE|1^^D100^^20020731^^^TAKE 1 TABLET DAILY –GENERIC FOR CALAN SR|00182196901^VERAPAMIL HCL ER TAB 180MG ER^NDC |100||180MG|TABLET SA|||G|||0|BC3126631^CHU^Y^L||213220929|0|0|19980821|||

RXD|1|00182196901^VERAPAMIL HCL ER TAB 180MG ER^NDC |19980821|100|||213220929|0|TAKE 1 TABLET DAILY –GENERIC FOR CALAN SR||||||||||||

RXR|PO||||

ORC|RE||235134037||||||199809221330-0700|||8877^Hippocrates^Harold^H^III^DR^MD||^^^^^555^555-5001||||||RXD|1|00172409660^BACLOFEN 10MG TABS^NDC|199809221415-0700|10|||235134037|5|AS DIRECTED||||||||||||

RXR|PO||||

ORC|RE||235134030||||||199810121030-0700|||77^Hippocrates^Harold^H^III^DR^MD||^^^^^555^555-5001||||||

RXD|1|00054384163^THEOPHYLLINE 80MG/15ML SOLN^NDC|199810121145-0700|10|||235134030|5|AS DIRECTED||||||||||||

RXR|PO

Associated dispense history Query Profile
Query Profile

Query Statement ID (Query ID=Z81):

Z81

Type:

Query

Query Name:

Dispense History

Query Trigger (= MSH-9):

QBP^Z81^QBP_Q11

Query Mode:

Both

Response Trigger (= MSH-9):

RSP^Z82^RSP_Z82

Query Characteristics:

May specify patient, medication, a date range, and how the response is to be sorted.

Purpose:

To retrieve patient pharmacy dispense history information from the Server.

Response Characteristics:

Sorted by Medication Dispensed unless otherwise specified in SortControl.

Based on Segment Pattern:

RDS_O01


The message structure for QBP^Z81^QPB_Q11 can be found in 5.4.1. Use the QBP^Q11^QPB_Q11 Message structure.

RSP^Z82^RSP_Z82: Response Grammar: Pharmacy Dispense Message
HL7 MessageStructure Table - RSP_Z82
Segment Cardinality Must Implement Status
RSP_Z82
MSH 1..1 Yes
SFT 0..*
UAC 0..1
MSA 1..1 Yes
ERR 0..1
QAK 1..1 Yes
QPD 1..1 Yes
RCP 1..1 Yes
QUERY_RESPONSE 1..* Yes
PATIENT 0..1
PID 1..1 Yes
PD1 0..1
NTE 0..*
VISIT 0..1
AL1 1..* Yes
PV1 1..1 Yes
PV2 0..1
COMMON_ORDER 1..* Yes
ORC 1..1 Yes
RXD 1..1 Yes
RXR 1..* Yes
RXC 0..*
TIMING 0..*
TQ1 1..1 Yes
TQ2 0..*
ORDER_DETAIL 0..1
RXO 1..1 Yes
NTE 0..*
RXR 1..* Yes
TREATMENT 0..1
RXC 1..* Yes
NTE 0..*
ENCODED_ORDER 0..1
RXE 1..1 Yes
RXR 1..* Yes
RXC 0..*
TIMING_ENCODED 0..*
TQ1 1..1 Yes
TQ2 0..*
OBSERVATION 1..* Yes
OBX 0..1
NTE 0..*
DSC 0..1

Input Parameter Specification

Field Seq (Query ID=Z81)

Name

Key/

Search

Sort

LEN

TYPE

Opt

Rep

Match Op

TBL

Segment Field Name

Service Identifier Code

Element Name

1

MessageQueryName

60

CWE

R

2

QueryTag

32

ST

R

PatientList

S

Y

20

CX

O

PID.3

PID-3: Patient Identifier List

MedicationDispensed

S

Y

100

CWE

O

=

RXD.2

RXD-2: Dispense/Give Code

DispenseDate.LL

S

Y

24

DTM

O

>
=

RXD.3

RXD-3: Date/Time Dispensed

DispenseDate.UL

S

Y

24

DTM

O

<
=

RXD.3

RXD-3: Date/Time Dispensed


Input Parameter Field Description and Commentary

Input Parameter (Query ID=Z81)

Comp. Name

DT

Description

MessageQueryName

CWE

SHALL be valued Z81^Dispense History^HL7nnnn.

QueryTag

ST

Unique to each query message instance.

PatientList

CX

The combination of values for PatientList.ID, and PatientList.AssigningAuthority, are intended to identify a unique entry on the PATIENT_MASTER table. The PatientList.IdentifierTypeCode is useful for further filtering or to supply uniqueness in the event that the assigning authority may have more than one coding system. (The PATIENT_MASTER table contains a constraint that prevents multiple patients from being identified by the same combination of field values.) This PATIENT_MASTER entry will be searched against on the PHARMACY_DISPENSE_TRANSACTION table to retrieve the rows fulfilling the query conditions.

If this field is not valued, all values for this field are considered to be a match.

If one PID.3 is specified, only 1 segment pattern will be returned.

ID