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

19.3.27 Query (99.1.5)

20 .Query (5)

5

Chapter Co-Chair

Chapter Co-Chair and Editor

Anthony JulianMayo Clinic

Nick RadovUnited Healthcare

Chapter Co-Chair

Dave ShaverCorepoint Health

Chapter Co-Chair

Sandy StuartKaiser Permanente

Chapter Editor Emeritus

Peter GilbertMeridian Health Plan

Sponsoring Committee:

Infrastructure and Messaging

List Server:

inm@lists.hl7.org

20.1 CHAPTER 5 CONTENTS (5.1)

20.2 INTRODUCTION (5.2)

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:

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.

20.2.1 Query/response model (5.2.1)

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."

20.2.2 Evolution of the query standard (5.2.2)

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.

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

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.

20.2.3 Query development methodology (5.2.3)

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:

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:

Response Control

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

Query Grammar

Response Grammar

Input Specification and Commentary

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.

20.2.4 Response format (5.2.4)

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.

20.2.4.1 hiddentext (5.2.4.0)

20.2.4.2 Segment pattern response (5.2.4.1)

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.

20.2.4.3 Tabular response (5.2.4.2)

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.

20.2.4.4 Display response (5.2.4.3)

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.

20.2.4.5 Choosing among available response formats (5.2.4.4)

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.

20.2.5 Query specification formats (5.2.5)

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.

20.2.5.1 hiddentext (5.2.5.0)

20.2.5.2 Expressing the same data using the variants (5.2.5.1)

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.

20.2.5.2.1 Expression as simple parameters (5.2.5.1.1)

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

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

MSH|^~\&|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.

20.2.5.2.2 Expression as query by example (5.2.5.1.2)

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|^~\&|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.

20.2.5.2.3 Expression as a complex expression (5.2.5.1.3)

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|^~\&|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.

20.2.6 Summary chart of query/response pairs (5.2.6)

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.

20.2.7 Acknowledgment Choreography (5.2.7)

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.

20.3 QUERY/RESPONSE PROFILE (5.3)

The introduction of the Query/Response Profile 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.

20.3.1 Using the Query Profile (5.3.1)

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."

20.3.1.1 hiddentext (5.3.1.0)

20.3.1.2 Query with tabular response example (5.3.1.1)

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

MSH|^~\&|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|^~\&|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||

20.3.1.3 Example of Query Profile with tabular response (5.3.1.2)

Query Profile

Segment Cardinality Implement Status
QBP^Z99^QBP_Q13
MSH

Message Header

[1..1] SHALL
ARV

Access Restriction

  v2.9
UAC

User Authentication Credential Segment

[0..1]  
QPD

Query Parameter Definition

[1..1] SHALL
PID

Patient Identification

[0..1]  
RDF

Table Row Definition

[0..1]  
RCP

Response Control Parameter

[1..1] SHALL
RDF

Table Row Definition

[0..1]  
DSC

Continuation Pointer

[0..1]  

 

QBP_Q13

MSH-15 MSH-16 Immediate ACK Application Ack
Blank Blank - RSP^Z84^RSP_Z84
NE AL - RSP^Z84^RSP_Z84
AL, SU, ER AL ACK^Z84^ACK RSP^Z84^RSP_Z84
We need some ER7 examples...
We need some XML examples...
Segment Cardinality Implement Status
RSP^Z84^RSP_Z84
MSH

Message Header

[1..1] SHALL
SFT

Software Segment

 
MSA

Message Acknowledgment

[1..1] SHALL
ERR

Error

[0..1]  
QAK

Query Acknowledgment

[1..1] SHALL
QPD

Query Parameter Definition

[1..1] SHALL
ROW_DEFINITION [0..1]  
RDF

Table Row Definition

[1..1] SHALL
RDT

Table Row Data

 
DSC

Continuation Pointer

[0..1]  

 

RSP_Z84

MSH-15 MSH-16 Immediate ACK Application Ack
Blank Blank - -
NE NE - -
AL, SU, ER NE ACK^Z84^ACK -
We need some ER7 examples...
We need some XML examples...

QPD Input Parameter Specification

QPD Input Parameter Field Description and Commentary

RCP Response Control Parameter Field Description and Commentary

Output Specification and Commentary: Virtual Table

20.3.2 Formal specification of the Query Profile (5.3.2)

The Query Profile contains the following information:

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.

20.3.2.1 hiddentext (5.3.2.0)

20.3.2.2 Steps for developing a Query Profile (5.3.2.1)

20.3.2.3 Query Profile introduction (5.3.2.2)

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: 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.

20.3.2.4 Query grammar (5.3.2.3)

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

Segment Cardinality Implement Status
QBP^Znn^QBP_Qnn
MSH

Message Header

[1..1] SHALL
SFT

Software Segment

 
QPD

Query Parameter Definition

[1..1] SHALL
RDF

Table Row Definition

[0..1]  
RCP

Response Control Parameter

[1..1] SHALL
DSC

Continuation Pointer

[0..1]  

 

QBP_Qnn

MSH-15 MSH-16 Immediate ACK Application Ack
Blank Blank - RTB^Znn^RTB_Knn
NE AL - RTB^Znn^RTB_Knn
AL, SU, ER AL ACK^Znn^ACK RTB^Znn^RTB_Knn
We need some ER7 examples...
We need some XML examples...

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.

20.3.2.5 Response grammar (5.3.2.4)

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.

Segment Cardinality Implement Status
RTB^Znn^RTB_Knn
MSH

Message Header

[1..1] SHALL
SFT

Software Segment

 
MSA

Message Acknowledgment

[1..1] SHALL
ERR

Error

[0..1]  
QAK

Query Acknowledgment

[1..1] SHALL
QPD

Query Parameter Definition

[1..1] SHALL
Hxx

any HL7 segment

[1..1] SHALL
DSC

Continuation Pointer

[0..1]  

 

RTB_Knn

MSH-15 MSH-16 Immediate ACK Application Ack
We need some ER7 examples...
We need some XML examples...

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.

20.3.2.6 Response grammar for display response (5.3.2.5)

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.

Segment Cardinality Implement Status
RDY^Znn^RDY_K15
MSH

Message Header

[1..1] SHALL
SFT

Software Segment

 
MSA

Message Acknowledgment

[1..1] SHALL
ERR

Error

[0..1]  
QAK

Query Acknowledgment

[1..1] SHALL
QPD

Query Parameter Definition

[1..1] SHALL
DSP

Display Data

 
DSC

Continuation Pointer

[0..1]  

 

RDY_K15

MSH-15 MSH-16 Immediate ACK Application Ack
Blank Blank - -
Blank Blank - -
Blank Blank - -
NE AL - -
NE AL - -
NE AL - -
AL, SU, ER AL ACK^K15^ACK -
AL, SU, ER AL ACK^Znn^ACK -
AL, SU, ER AL ACK^Znn^ACK -
We need some ER7 examples...
We need some XML examples...

20.3.2.7 QPD input parameter specification (5.3.2.6)

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

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.

20.3.2.8 QPD input parameter field description and commentary (5.3.2.7)

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: 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.

20.3.2.9 QBE input parameter specification (5.3.2.8)

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

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).

20.3.2.10 QBE input parameter field description and commentary (5.3.2.9)

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

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.

20.3.2.11 RCP input parameter field description and commentary (5.3.2.10)

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: 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.

20.3.2.12 Input specification: virtual table (5.3.2.11)

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

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.

20.3.2.13 Virtual table field description and commentary (5.3.2.12)

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: 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.

20.3.2.14 Output specification for tabular response (5.3.2.13)

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

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.

20.3.3 Query Profile templates (5.3.3)

20.3.3.1 hiddentext (5.3.3.0)

20.3.3.2 Query Profile template for query with tabular response (5.3.3.1)

Query Profile

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

Segment Cardinality Implement Status
RTB^Znn^RTB_K13
MSH

Message Header

[1..1] SHALL
SFT

Software Segment

 
MSA

Message Acknowledgment

[1..1] SHALL
ERR

Error

[0..1]  
QAK

Query Acknowledgment

[1..1] SHALL
QPD

Query Parameter Definition

[1..1] SHALL
ROW_DEFINITION [0..1]  
RDF

Table Row Definition

[1..1] SHALL
RDT

Table Row Data

 
DSC

Continuation Pointer

[0..1]  

 

RTB_K13

MSH-15 MSH-16 Immediate ACK Application Ack
Blank Blank - -
Blank Blank - -
NE AL - -
NE AL - -
AL, SU, ER AL ACK^K13^ACK -
AL, SU, ER AL ACK^Znn^ACK -
We need some ER7 examples...
We need some XML examples...

QPD Input Parameter Specification

QPD Input Parameter Field Description and Commentary

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

Input Specification: Virtual Table

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

Virtual Table Field Description and Commentary

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

QBE Input Parameter Specification

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

QBE Input Parameter Field Description and Commentary

RCP Response Control Parameter Field Description and Commentary

Output Specification and Commentary: Virtual Table

20.3.3.3 Query Profile template for query with segment pattern response (5.3.3.2)

Query Profile

Segment Cardinality Implement Status
QBP^Znn^QBP_Q11
MSH

Message Header

[1..1] SHALL
ARV

Access Restriction

 
UAC

User Authentication Credential Segment

[0..1]  
QPD

Query Parameter Definition

[1..1] SHALL
QBP [0..1]  
Hxx

any HL7 segment

[0..1]  
RCP

Response Control Parameter

[1..1] SHALL
DSC

Continuation Pointer

[0..1]  

 

QBP_Q11

MSH-15 MSH-16 Immediate ACK Application Ack
Blank Blank - RSP^K11^RSP_K11
Blank Blank - RSP^Znn^RSP_Znn
Blank Blank - RSP^K31^RSP_K31
NE AL - RSP^K11^RSP_K11
NE AL - RSP^Znn^RSP_Znn
NE NE - -
AL, SU, ER AL ACK^Q11^ACK RSP^K11^RSP_K11
AL, SU, ER AL ACK^Znn^ACK RSP^Znn^RSP_Znn
AL, SU, ER NE ACK^Q31^ACK -
NE AL, SU, ER - RSP^K31^RSP_K31
AL, SU, ER AL, SU, ER ACK^Q31^ACK RSP^K31^RSP_K31
We need some ER7 examples...
We need some XML examples...
Segment Cardinality Implement Status
RSP^Znn^RSP_Znn
MSH

Message Header

[1..1] SHALL
SFT

Software Segment

 
MSA

Message Acknowledgment

[1..1] SHALL
ERR

Error

[0..1]  
QAK

Query Acknowledgment

[1..1] SHALL
QPD

Query Parameter Definition

[1..1] SHALL
Hxx

any HL7 segment

[0..1]  
DSC

Continuation Pointer

[0..1]  

 

RSP_Znn

MSH-15 MSH-16 Immediate ACK Application Ack
Blank Blank - -
NE AL - -
AL, SU, ER AL ACK^Znn^ACK -
We need some ER7 examples...
We need some XML examples...

QPD Input Parameter Specification

QPD Input Parameter Field Description and Commentary

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

Input Specification: Virtual Table

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

Virtual Table Field Description and Commentary

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

QBE Input Parameter Specification

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

QBE Input Parameter Field Description and Commentary

RCP Response Control Parameter Field Description and Commentary

20.3.3.4 Query Profile for query with display response (5.3.3.3)

Query Profile

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

Segment Cardinality Implement Status
RDY^Znn^RDY_K15
MSH

Message Header

[1..1] SHALL
SFT

Software Segment

 
MSA

Message Acknowledgment

[1..1] SHALL
ERR

Error

[0..1]  
QAK

Query Acknowledgment

[1..1] SHALL
QPD

Query Parameter Definition

[1..1] SHALL
DSP

Display Data

 
DSC

Continuation Pointer

[0..1]  

 

RDY_K15

MSH-15 MSH-16 Immediate ACK Application Ack
Blank Blank - -
Blank Blank - -
Blank Blank - -
NE AL - -
NE AL - -
NE AL - -
AL, SU, ER AL ACK^K15^ACK -
AL, SU, ER AL ACK^Znn^ACK -
AL, SU, ER AL ACK^Znn^ACK -
We need some ER7 examples...
We need some XML examples...

QPD Input Parameter Specification

QPD Input Parameter Field Description and Commentary

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

Input Specification: Virtual Table

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

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

QBE Input Parameter Specification

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

QBE Input Parameter Field Description and Commentary

RCP Response Control Parameter Field Description and Commentary

20.3.3.5 Query Profile table summaries (5.3.3.4)

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

20.4 QUERY/RESPONSE MESSAGE PAIRS (5.4)

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:

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 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.

20.4.1 QBP/RSP - query by parameter/segment pattern response (events vary) (5.4.1)

Segment Cardinality Implement Status
QBP^Q11^QBP_Q11
MSH

Message Header

[1..1] SHALL
ARV

Access Restriction

 
UAC

User Authentication Credential Segment

[0..1]  
QPD

Query Parameter Definition

[1..1] SHALL
QBP [0..1]  
Hxx

any HL7 segment

[0..1]  
RCP

Response Control Parameter

[1..1] SHALL
DSC

Continuation Pointer

[0..1]  

 

QBP_Q11

MSH-15 MSH-16 Immediate ACK Application Ack
Blank Blank - RSP^K11^RSP_K11
Blank Blank - RSP^Znn^RSP_Znn
Blank Blank - RSP^K31^RSP_K31
NE AL - RSP^K11^RSP_K11
NE AL - RSP^Znn^RSP_Znn
NE NE - -
AL, SU, ER AL ACK^Q11^ACK RSP^K11^RSP_K11
AL, SU, ER AL ACK^Znn^ACK RSP^Znn^RSP_Znn
AL, SU, ER NE ACK^Q31^ACK -
NE AL, SU, ER - RSP^K31^RSP_K31
AL, SU, ER AL, SU, ER ACK^Q31^ACK RSP^K31^RSP_K31
We need some ER7 examples...
We need some XML examples...

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.

Segment Cardinality Implement Status
RSP^K11^RSP_K11
MSH

Message Header

[1..1] SHALL
SFT

Software Segment

 
MSA

Message Acknowledgment

[1..1] SHALL
ERR

Error

 
QAK

Query Acknowledgment

[1..1] SHALL
QPD

Query Parameter Definition

[1..1] SHALL
SEGMENT_PATTERN [0..1]  
Hxx

any HL7 segment

[1..1] SHALL
DSC

Continuation Pointer

[0..1]  

 

RSP_K11

MSH-15 MSH-16 Immediate ACK Application Ack
Blank Blank - -
NE AL - -
AL, SU, ER AL ACK^K11^ACK -
We need some ER7 examples...
We need some XML examples...

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.

20.4.2 QBP/RTB - query by parameter/tabular response (events vary) (5.4.2)

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.

Segment Cardinality Implement Status
RTB^K13^RTB_K13
MSH

Message Header

[1..1] SHALL
SFT

Software Segment

 
MSA

Message Acknowledgment

[1..1] SHALL
ERR

Error

[0..1]  
QAK

Query Acknowledgment

[1..1] SHALL
QPD

Query Parameter Definition

[1..1] SHALL
ROW_DEFINITION [0..1]  
RDF

Table Row Definition

[1..1] SHALL
RDT

Table Row Data

 
DSC

Continuation Pointer

[0..1]  

 

RTB_K13

MSH-15 MSH-16 Immediate ACK Application Ack
Blank Blank - -
Blank Blank - -
NE AL - -
NE AL - -
AL, SU, ER AL ACK^K13^ACK -
AL, SU, ER AL ACK^Znn^ACK -
We need some ER7 examples...
We need some XML examples...

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.

20.4.3 QBP/RDY - query by parameter/display response (events vary) (5.4.3)

Segment Cardinality Implement Status
QBP^Q15^QBP_Q15
MSH

Message Header

[1..1] SHALL
SFT

Software Segment

 
QPD

Query Parameter Definition

[1..1] SHALL
Hxx

any HL7 segment

[0..1]  
RCP

Response Control Parameter

[1..1] SHALL
DSC

Continuation Pointer

[0..1]  

 

QBP_Q15

MSH-15 MSH-16 Immediate ACK Application Ack
Blank Blank - RDY^K15^RDY_K15
NE AL - RDY^K15^RDY_K15
AL, SU, ER AL ACK^Q15^ACK RDY^K15^RDY_K15
We need some ER7 examples...
We need some XML examples...

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.

Segment Cardinality Implement Status
RDY^K15^RDY_K15
MSH

Message Header

[1..1] SHALL
SFT

Software Segment

 
MSA

Message Acknowledgment

[1..1] SHALL
ERR

Error

[0..1]  
QAK

Query Acknowledgment

[1..1] SHALL
QPD

Query Parameter Definition

[1..1] SHALL
DSP

Display Data

 
DSC

Continuation Pointer

[0..1]  

 

RDY_K15

MSH-15 MSH-16 Immediate ACK Application Ack
Blank Blank - -
Blank Blank - -
Blank Blank - -
NE AL - -
NE AL - -
NE AL - -
AL, SU, ER AL ACK^K15^ACK -
AL, SU, ER AL ACK^Znn^ACK -
AL, SU, ER AL ACK^Znn^ACK -
We need some ER7 examples...
We need some XML examples...

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.

20.4.4 QSB - Create subscription (Event Q16) (5.4.4)

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

Segment Cardinality Implement Status
QSB^Q16^QSB_Q16
MSH

Message Header

[1..1] SHALL
SFT

Software Segment

 
QPD

Query Parameter Definition

[1..1] SHALL
RCP

Response Control Parameter

[1..1] SHALL
DSC

Continuation Pointer

[0..1]  

 

QSB_Q16

MSH-15 MSH-16 Immediate ACK Application Ack
Blank Blank - ACK^Q16^ACK
NE AL - ACK^Q16^ACK
AL, SU, ER AL ACK^Q16^ACK ACK^Q16^ACK
We need some ER7 examples...
We need some XML examples...
Segment Cardinality Implement Status
ACK^Q16^ACK
MSH

Message Header

[1..1] SHALL
SFT

Software Segment

 
MSA

Message Acknowledgment

[1..1] SHALL
ERR

Error

 

 

ACK

We need some ER7 examples...
We need some XML examples...

20.4.5 QVR - query for previous events (Event Q17) (5.4.5)

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.
Segment Cardinality Implement Status
QVR^Q17^QVR_Q17
MSH

Message Header

[1..1] SHALL
SFT

Software Segment

 
QPD

Query Parameter Definition

[1..1] SHALL
QBP [0..1]  
Hxx

any HL7 segment

[0..1]  
RCP

Response Control Parameter

[1..1] SHALL
DSC

Continuation Pointer

[0..1]  

 

QVR_Q17

MSH-15 MSH-16 Immediate ACK Application Ack
Blank Blank - ACK^Q17^ACK
NE AL - ACK^Q17^ACK
AL, SU, ER AL ACK^Q17^ACK ACK^Q17^ACK
We need some ER7 examples...
We need some XML examples...
Segment Cardinality Implement Status
ACK^Q17^ACK
MSH

Message Header

[1..1] SHALL
SFT

Software Segment

 
MSA

Message Acknowledgment

[1..1] SHALL
ERR

Error

 

 

ACK

We need some ER7 examples...
We need some XML examples...

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.

20.4.6 QCN/ACK - cancel query/acknowledge message (Event J01) (5.4.6)

Segment Cardinality Implement Status
QCN^J01^QCN_J01
MSH

Message Header

[1..1] SHALL
SFT

Software Segment

 
QID

Query Identification

[1..1] SHALL

 

QCN_J01

MSH-15 MSH-16 Immediate ACK Application Ack
Blank Blank - ACK^J02^ACK
Blank Blank - ACK^J01^ACK
NE AL - ACK^J02^ACK
NE AL - ACK^J01^ACK
AL, SU, ER AL ACK^J02^ACK ACK^J02^ACK
AL, SU, ER AL ACK^J01^ACK ACK^J01^ACK
We need some ER7 examples...
We need some XML examples...
Segment Cardinality Implement Status
ACK^J01^ACK
MSH

Message Header

[1..1] SHALL
SFT

Software Segment

 
MSA

Message Acknowledgment

[1..1] SHALL
ERR

Error

 

 

ACK

We need some ER7 examples...
We need some XML examples...

20.4.7 QSX /ACK - cancel subscription/acknowledge message (Event J02) (5.4.7)

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

Segment Cardinality Implement Status
QSX^J02^QCN_J01
MSH

Message Header

[1..1] SHALL
SFT

Software Segment

 
QID

Query Identification

[1..1] SHALL

 

QCN_J01

MSH-15 MSH-16 Immediate ACK Application Ack
Blank Blank - ACK^J02^ACK
Blank Blank - ACK^J01^ACK
NE AL - ACK^J02^ACK
NE AL - ACK^J01^ACK
AL, SU, ER AL ACK^J02^ACK ACK^J02^ACK
AL, SU, ER AL ACK^J01^ACK ACK^J01^ACK
We need some ER7 examples...
We need some XML examples...
Segment Cardinality Implement Status
ACK^J02^ACK
MSH

Message Header

[1..1] SHALL
SFT

Software Segment

 
MSA

Message Acknowledgment

[1..1] SHALL
ERR

Error

 

 

ACK

We need some ER7 examples...
We need some XML examples...

20.5 QUERY/RESPONSE MESSAGE SEGMENTS (5.5)

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.

20.5.1 DSP - display data segment (5.5.1)

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

Base Framework
Seq#Data ElementDescriptionFlagsImplementCardinalityLengthC.LENVocabularyData Type
DSP
100061Set ID - DSP MAY[0..1][1..4]
SI

Sequence ID

200062Display Level MAY[0..1][1..4]
SI

Sequence ID

300063Data Line SHOULD[1..1] 300
TX

Text Data

400064Logical Break Point MAY[0..1] 2
ST

String Data

500065Result ID MAY[0..1] 20
TX

Text Data

Seq#Data ElementDescriptionFlagsImplementCardinalityLengthC.LENVocabularyData Type
DSP
100061Set ID - DSP MAY[0..1][1..4]
SI

Sequence ID

200062Display Level MAY[0..1][1..4]
SI

Sequence ID

300063Data Line SHALL[1..1] 300
TX

Text Data

400064Logical Break Point MAY[0..1] 2
ST

String Data

500065Result ID MAY[0..1] 20
TX

Text Data

Base FrameworkBase Standard Profile
Seq#Data ElementDescriptionFlagsImplementCardinalityLengthC.LENVocabularyData TypeImplementVocabulary
DSP 
100061Set ID - DSP MAY[0..1][1..4]
SI

Sequence ID

MAY
200062Display Level MAY[0..1][1..4]
SI

Sequence ID

MAY
300063Data Line SHOULD[1..1] 300
TX

Text Data

SHALL
400064Logical Break Point MAY[0..1] 2
ST

String Data

MAY
500065Result ID MAY[0..1] 20
TX

Text Data

MAY
Base Framework Base Standard Profile
Seq# Data Element Description Flags Optionality Repetition Length C.LEN Table Data Type Optionality Table
DSP  
1 00061 Set ID - DSP   O   [1..4]  
SI

Sequence ID

   
2 00062 Display Level   O   [1..4]  
SI

Sequence ID

   
3 00063 Data Line   O     300  
TX

Text Data

R  
4 00064 Logical Break Point   O     2  
ST

String Data

   
5 00065 Result ID   O     20  
TX

Text Data

   
Seq# Data Element Description Optionality Repetition Length C.LEN Table Data Type
DSP
1 00061 Set ID - DSP O   [1..4]  
SI

Sequence ID

2 00062 Display Level O   [1..4]  
SI

Sequence ID

3 00063 Data Line R     300  
TX

Text Data

4 00064 Logical Break Point O     2  
ST

String Data

5 00065 Result ID O     20  
TX

Text Data

20.5.1.1 DSP field definitions (5.5.1.0)

20.5.1.2 DSP-1 Set ID – DSP (SI) 00061 (5.5.1.1)

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

20.5.1.3 DSP-2 Display Level (SI) 00062 (5.5.1.2)

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

20.5.1.4 DSP-3 Data Line (TX) 00063 (5.5.1.3)

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.

20.5.1.5 DSP-4 Logical Break Point (ST) 00064 (5.5.1.4)

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.

20.5.1.6 DSP-5 Result ID (TX) 00065 (5.5.1.5)

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.

20.5.2 QAK- query acknowledgment segment (5.5.2)

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

Base Framework
Seq#Data ElementDescriptionFlagsImplementCardinalityLengthC.LENVocabularyData Type
QAK

100696Query Tag
C

Condition defined for this element

=

Truncation not allowed!

MAY[0..1] 32
ST

String Data

200708Query Response Status MAY[0..1][2..2]univ: QueryResponseStatus (CD) hl7VS-queryResponseStatus (VS) queryResponseStatus (CS)
ID

Coded Value for HL7 Defined Tables

301375Message Query Name MAY[0..1] QueryName (CD)
CWE

Coded with Exceptions

401434Hit Count Total
=

Truncation not allowed!

MAY[0..1] 10
NM

Numeric

501622This payload
=

Truncation not allowed!

MAY[0..1] 10
NM

Numeric

601623Hits remaining
=

Truncation not allowed!

MAY[0..1] 10
NM

Numeric

Conditions/Invariants

The root for the expression is on the segment.

Seq. Referenced Elements Introduction Invariant Comment
1 ?

Seq#Data ElementDescriptionFlagsImplementCardinalityLengthC.LENVocabularyData Type
QAK

100696Query Tag
C

Condition defined for this element

=

Truncation not allowed!

MAY[0..1] 32
ST

String Data

200708Query Response Status MAY[0..1][2..2]univ: QueryResponseStatus (CD) hl7VS-queryResponseStatus (VS) queryResponseStatus (CS)
ID

Coded Value for HL7 Defined Tables

301375Message Query Name MAY[0..1] QueryName (CD)
CWE

Coded with Exceptions

401434Hit Count Total
=

Truncation not allowed!

MAY[0..1] 10
NM

Numeric

501622This payload
=

Truncation not allowed!

MAY[0..1] 10
NM

Numeric

601623Hits remaining
=

Truncation not allowed!

MAY[0..1] 10
NM

Numeric

Base FrameworkBase Standard Profile
Seq#Data ElementDescriptionFlagsImplementCardinalityLengthC.LENVocabularyData TypeImplementVocabulary
QAK 

100696Query Tag
C

Condition defined for this element

=

Truncation not allowed!

MAY[0..1] 32
ST

String Data

MAY
200708Query Response Status MAY[0..1][2..2]univ: QueryResponseStatus (CD) hl7VS-queryResponseStatus (VS) queryResponseStatus (CS)
ID

Coded Value for HL7 Defined Tables

MAY 
301375Message Query Name MAY[0..1] QueryName (CD)
CWE

Coded with Exceptions

MAY
401434Hit Count Total
=

Truncation not allowed!

MAY[0..1] 10
NM

Numeric

MAY
501622This payload
=

Truncation not allowed!

MAY[0..1] 10
NM

Numeric

MAY
601623Hits remaining
=

Truncation not allowed!

MAY[0..1] 10
NM

Numeric

MAY
Base Framework Base Standard Profile
Seq# Data Element Description Flags Optionality Repetition Length C.LEN Table Data Type Optionality Table
QAK  

1 00696 Query Tag
C

Condition defined for this element

O     32=  
ST

String Data

   
2 00708 Query Response Status   O   [2..2]  
ID

Coded Value for HL7 Defined Tables

  (0208)
3 01375 Message Query Name   O      
CWE

Coded with Exceptions

  (0471)
4 01434 Hit Count Total   O     10=  
NM

Numeric

   
5 01622 This payload   O     10=  
NM

Numeric

   
6 01623 Hits remaining   O     10=  
NM

Numeric

   
Seq# Data Element Description Optionality Repetition Length C.LEN Table Data Type
QAK
1 00696 Query Tag C     32=  
ST

String Data

2 00708 Query Response Status O   [2..2] (0208)
ID

Coded Value for HL7 Defined Tables

3 01375 Message Query Name O     (0471)
CWE

Coded with Exceptions

4 01434 Hit Count Total O     10=  
NM

Numeric

5 01622 This payload O     10=  
NM

Numeric

6 01623 Hits remaining O     10=  
NM

Numeric

20.5.2.1 QAK field definitions (5.5.2.0)

20.5.2.2 QAK-1 Query Tag (ST) 00696 (5.5.2.1)

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.

20.5.2.3 QAK-2 Query Response Status (ID) 00708 (5.5.2.2)

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.

20.5.2.4 QAK-3 Message Query Name (CWE) 01375 (5.5.2.3)

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.

20.5.2.5 QAK-4 Hit Count Total (NM) 01434 (5.5.2.4)

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."

20.5.2.6 QAK-5 This Payload (NM) 01622 (5.5.2.5)

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.

20.5.2.7 QAK-6 Hits Remaining (NM) 01623 (5.5.2.6)

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.

20.5.3 QID- query identification segment (5.5.3)

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

Base Framework
Seq#Data ElementDescriptionFlagsImplementCardinalityLengthC.LENVocabularyData Type
QID
100696Query Tag
=

Truncation not allowed!

SHOULD[1..1] 32
ST

String Data

201375Message Query Name SHOULD[1..1] QueryName (CD)
CWE

Coded with Exceptions

Seq#Data ElementDescriptionFlagsImplementCardinalityLengthC.LENVocabularyData Type
QID
100696Query Tag
=

Truncation not allowed!

SHALL[1..1] 32
ST

String Data

201375Message Query Name SHALL[1..1] QueryName (CD)
CWE

Coded with Exceptions

Base FrameworkBase Standard Profile
Seq#Data ElementDescriptionFlagsImplementCardinalityLengthC.LENVocabularyData TypeImplementVocabulary
QID 
100696Query Tag
=

Truncation not allowed!

SHOULD[1..1] 32
ST

String Data

SHALL
201375Message Query Name SHOULD[1..1] QueryName (CD)
CWE

Coded with Exceptions

SHALL
Base Framework Base Standard Profile
Seq# Data Element Description Flags Optionality Repetition Length C.LEN Table Data Type Optionality Table
QID  
1 00696 Query Tag   O     32=  
ST

String Data

R  
2 01375 Message Query Name   O     (0471)
CWE

Coded with Exceptions

R  
Seq# Data Element Description Optionality Repetition Length C.LEN Table Data Type
QID
1 00696 Query Tag R     32=  
ST

String Data

2 01375 Message Query Name R     (0471)
CWE

Coded with Exceptions

20.5.3.1 QID field definitions (5.5.3.0)

20.5.3.2 QID-1 Query Tag (ST) 00696 (5.5.3.1)

Definition: This field identifies the instance of a query.

20.5.3.3 QID-2 Message Query Name (CWE) 01375 (5.5.3.2)

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.

20.5.4 QPD - query parameter definition (5.5.4)

The QPD segment defines the parameters of the query.

HL7 Attribute Table - QPD - Query Parameter Definition

Base Framework
Seq#Data ElementDescriptionFlagsImplementCardinalityLengthC.LENVocabularyData Type
QPD
101375Message Query Name SHOULD[1..1] QueryName (CD)
CWE

Coded with Exceptions


200696Query Tag
C

Condition defined for this element

=

Truncation not allowed!

MAY[0..1] 32
ST

String Data

301435User Parameters (in successive fields)
=

Truncation not allowed!

MAY[0..1] 256
varies

variable data type

Conditions/Invariants

The root for the expression is on the segment.

Seq. Referenced Elements Introduction Invariant Comment
1 ?

Seq#Data ElementDescriptionFlagsImplementCardinalityLengthC.LENVocabularyData Type
QPD
101375Message Query Name SHALL[1..1] QueryName (CD)
CWE

Coded with Exceptions


200696Query Tag
C

Condition defined for this element

=

Truncation not allowed!

MAY[0..1] 32
ST

String Data

301435User Parameters (in successive fields)
=

Truncation not allowed!

MAY[0..1] 256
varies

variable data type

Base FrameworkBase Standard Profile
Seq#Data ElementDescriptionFlagsImplementCardinalityLengthC.LENVocabularyData TypeImplementVocabulary
QPD 
101375Message Query Name SHOULD[1..1] QueryName (CD)
CWE

Coded with Exceptions

SHALL

200696Query Tag
C

Condition defined for this element

=

Truncation not allowed!

MAY[0..1] 32
ST

String Data

MAY
301435User Parameters (in successive fields)
=

Truncation not allowed!

MAY[0..1] 256
varies

variable data type

MAY
Base Framework Base Standard Profile
Seq# Data Element Description Flags Optionality Repetition Length C.LEN Table Data Type Optionality Table
QPD  
1 01375 Message Query Name   O     (0471)
CWE

Coded with Exceptions

R  

2 00696 Query Tag
C

Condition defined for this element

O     32=  
ST

String Data

   
3 01435 User Parameters (in successive fields)   O     256=  
varies

variable data type

   
Seq# Data Element Description Optionality Repetition Length C.LEN Table Data Type
QPD
1 01375 Message Query Name R     (0471)
CWE

Coded with Exceptions

2 00696 Query Tag C     32=  
ST

String Data

3 01435 User Parameters (in successive fields) O     256=  
varies

variable data type

20.5.4.1 QPD field definitions (5.5.4.0)

20.5.4.2 QPD-1 Message Query Name (CWE) 01375 (5.5.4.1)

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.

20.5.4.3 QPD-2 Query Tag (ST) 00696 (5.5.4.2)

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.

20.5.4.4 QPD-3 User Parameters (Varies) 01435 (5.5.4.3)

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.

20.5.4.4.1 Note on QPD usage for query by example variant. (5.5.4.3.1)
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.

20.5.5 QRI - query response instance segment (5.5.5)

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

Base Framework
Seq#Data ElementDescriptionFlagsImplementCardinalityLengthC.LENVocabularyData Type
QRI
101436Candidate Confidence
=

Truncation allowed.

MAY[0..1] 10
NM

Numeric

201437Match Reason Code MAY[0..*][2..2]ex.:MatchReason (CD)
CWE

Coded with Exceptions

301438Algorithm Descriptor MAY[0..1] ex.:MatchAlgorithms (CD)
CWE

Coded with Exceptions

Seq#Data ElementDescriptionFlagsImplementCardinalityLengthC.LENVocabularyData Type
QRI
101436Candidate Confidence
=

Truncation allowed.

MAY[0..1] 10
NM

Numeric

201437Match Reason Code MAY[0..*][2..2]ex.:MatchReason (CD) hl7VS-matchReason (VS) matchReason (CS)
CWE

Coded with Exceptions

301438Algorithm Descriptor MAY[0..1] ex.:MatchAlgorithms (CD)
CWE

Coded with Exceptions

Base FrameworkBase Standard Profile
Seq#Data ElementDescriptionFlagsImplementCardinalityLengthC.LENVocabularyData TypeImplementVocabulary
QRI 
101436Candidate Confidence
=

Truncation allowed.

MAY[0..1] 10
NM

Numeric

MAY
201437Match Reason Code MAY[0..*][2..2]ex.:MatchReason (CD)
CWE

Coded with Exceptions

MAYhl7VS-matchReason (VS) matchReason (CS)
301438Algorithm Descriptor MAY[0..1] ex.:MatchAlgorithms (CD)
CWE

Coded with Exceptions

MAY
Base Framework Base Standard Profile
Seq# Data Element Description Flags Optionality Repetition Length C.LEN Table Data Type Optionality Table
QRI  
1 01436 Candidate Confidence   O     10#  
NM

Numeric

   
2 01437 Match Reason Code   O Y [2..2]  
CWE

Coded with Exceptions

  (0392)
3 01438 Algorithm Descriptor   O      
CWE

Coded with Exceptions

  (0393)
Seq# Data Element Description Optionality Repetition Length C.LEN Table Data Type
QRI
1 01436 Candidate Confidence O     10#  
NM

Numeric

2 01437 Match Reason Code O Y [2..2] (0392)
CWE

Coded with Exceptions

3 01438 Algorithm Descriptor O     (0393)
CWE

Coded with Exceptions

20.5.5.1 QRI field definitions (5.5.5.0)

20.5.5.2 QRI-1 Candidate Confidence (NM) 01436 (5.5.5.1)

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.

20.5.5.3 QRI-2 Match Reason Code (CWE) 01437 (5.5.5.2)

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.

20.5.5.4 QRI-3 Algorithm Descriptor (CWE) 01438 (5.5.5.3)

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.

20.5.6 RCP - response control parameter segment (5.5.6)

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

Base Framework
Seq#Data ElementDescriptionFlagsImplementCardinalityLengthC.LENVocabularyData Type
RCP
100027Query Priority MAY[0..1][1..1]univ: V2QueryPriority (CD) hl7VS-queryPriority (VS) queryPriority (CS)
ID

Coded Value for HL7 Defined Tables

200031Quantity Limited Request MAY[0..1] univ: QuantityLimitedRequest (CD)
CQ

Composite Quantity with Units

301440Response Modality MAY[0..1] univ: V2ResponseModality (CD) hl7VS-responseModality (VS) responseModality (CS)
CNE

Coded with No Exceptions


401441Execution and Delivery Time
C

Condition defined for this element

MAY[0..1] 
DTM

Date/Time

501443Modify Indicator MAY[0..1][1..1]univ: V2ModifyIndicator (CD) hl7VS-modifyIndicator (VS) modifyIndicator (CS)
ID

Coded Value for HL7 Defined Tables

601624Sort-by Field MAY[0..*] 
SRT

Sort Order

701594Segment group inclusion  MAY[0..*][1..256]univ: SegmentGroup (CD) hl7VS-segmentGroup (VS) segmentGroup (CS)
ID

Coded Value for HL7 Defined Tables

Conditions/Invariants

The root for the expression is on the segment.

Seq. Referenced Elements Introduction Invariant Comment
1 ?

Seq#Data ElementDescriptionFlagsImplementCardinalityLengthC.LENVocabularyData Type
RCP
100027Query Priority MAY[0..1][1..1]univ: V2QueryPriority (CD) hl7VS-queryPriority (VS) queryPriority (CS)
ID

Coded Value for HL7 Defined Tables

200031Quantity Limited Request MAY[0..1] univ: QuantityLimitedRequest (CD) hl7VS-quantityLimitedRequest (VS) quantityLimitedRequest (CS)
CQ

Composite Quantity with Units

301440Response Modality MAY[0..1] univ: V2ResponseModality (CD) hl7VS-responseModality (VS) responseModality (CS)
CNE

Coded with No Exceptions


401441Execution and Delivery Time
C

Condition defined for this element

MAY[0..1] 
DTM

Date/Time

501443Modify Indicator MAY[0..1][1..1]univ: V2ModifyIndicator (CD) hl7VS-modifyIndicator (VS) modifyIndicator (CS)
ID

Coded Value for HL7 Defined Tables

601624Sort-by Field MAY[0..*] 
SRT

Sort Order

701594Segment group inclusion  MAY[0..*][1..256]univ: SegmentGroup (CD) hl7VS-segmentGroup (VS) segmentGroup (CS)
ID

Coded Value for HL7 Defined Tables

Base FrameworkBase Standard Profile
Seq#Data ElementDescriptionFlagsImplementCardinalityLengthC.LENVocabularyData TypeImplementVocabulary
RCP 
100027Query Priority MAY[0..1][1..1]univ: V2QueryPriority (CD) hl7VS-queryPriority (VS) queryPriority (CS)
ID

Coded Value for HL7 Defined Tables

MAY 
200031Quantity Limited Request MAY[0..1] univ: QuantityLimitedRequest (CD)
CQ

Composite Quantity with Units

MAYhl7VS-quantityLimitedRequest (VS) quantityLimitedRequest (CS)
301440Response Modality MAY[0..1] univ: V2ResponseModality (CD) hl7VS-responseModality (VS) responseModality (CS)
CNE

Coded with No Exceptions

MAY 

401441Execution and Delivery Time
C

Condition defined for this element

MAY[0..1] 
DTM

Date/Time

MAY
501443Modify Indicator MAY[0..1][1..1]univ: V2ModifyIndicator (CD) hl7VS-modifyIndicator (VS) modifyIndicator (CS)
ID

Coded Value for HL7 Defined Tables

MAY 
601624Sort-by Field MAY[0..*] 
SRT

Sort Order

MAY
701594Segment group inclusion  MAY[0..*][1..256]univ: SegmentGroup (CD) hl7VS-segmentGroup (VS) segmentGroup (CS)
ID

Coded Value for HL7 Defined Tables

MAY 
Base Framework Base Standard Profile
Seq# Data Element Description Flags Optionality Repetition Length C.LEN Table Data Type Optionality Table
RCP  
1 00027 Query Priority   O   [1..1]  
ID

Coded Value for HL7 Defined Tables

  (0091)
2 00031 Quantity Limited Request   O      
CQ

Composite Quantity with Units

  (0126)
3 01440 Response Modality   O      
CNE

Coded with No Exceptions

  (0394)

4 01441 Execution and Delivery Time
C

Condition defined for this element

O      
DTM

Date/Time

   
5 01443 Modify Indicator   O   [1..1]  
ID

Coded Value for HL7 Defined Tables

  (0395)
6 01624 Sort-by Field   O Y    
SRT

Sort Order

   
7 01594 Segment group inclusion   O Y [1..256]  
ID

Coded Value for HL7 Defined Tables

  (0391)
Seq# Data Element Description Optionality Repetition Length C.LEN Table Data Type
RCP
1 00027 Query Priority O   [1..1] (0091)
ID

Coded Value for HL7 Defined Tables

2 00031 Quantity Limited Request O     (0126)
CQ

Composite Quantity with Units

3 01440 Response Modality O     (0394)
CNE

Coded with No Exceptions

4 01441 Execution and Delivery Time C      
DTM

Date/Time

5 01443 Modify Indicator O   [1..1] (0395)
ID

Coded Value for HL7 Defined Tables

6 01624 Sort-by Field O Y    
SRT

Sort Order

7 01594 Segment group inclusion O Y [1..256] (0391)
ID

Coded Value for HL7 Defined Tables

20.5.6.1 RCP field definitions (5.5.6.0)

20.5.6.2 RCP-1 Query Priority (ID) 00027 (5.5.6.1)

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.

20.5.6.3 RCP-2 Quantity Limited Request (CQ) 00031 (5.5.6.2)

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.

20.5.6.4 RCP-3 Response Modality (CNE) 01440 (5.5.6.3)

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.

20.5.6.5 RCP-4 Execution and Delivery Time (DTM) 01441 (5.5.6.4)

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).

20.5.6.6 RCP-5 Modify Indicator (ID) 01443 (5.5.6.5)

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.

20.5.6.7 RCP-6 Sort-by Field (SRT) 01624 (5.5.6.6)

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.

20.5.6.8 RCP-7 Segment Group Inclusion (ID) 01594 (5.5.6.7)

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.

20.5.7 RDF - table row definition segment (5.5.7)

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

HL7 Attribute Table - RDF - Table Row Definition

Base Framework
Seq#Data ElementDescriptionFlagsImplementCardinalityLengthC.LENVocabularyData Type
RDF
100701Number of Columns per Row
=

Truncation not allowed!

SHOULD[1..1] 3
NM

Numeric

200702Column Description SHOULD[1..*] univ: DataTypes (CD)
Seq#Data ElementDescriptionFlagsImplementCardinalityLengthC.LENVocabularyData Type
RDF
100701Number of Columns per Row
=

Truncation not allowed!

SHALL[1..1] 3
NM

Numeric

200702Column Description SHALL[1..*] univ: DataTypes (CD) hl7VS-dataTypes (VS) dataTypes (CS)
Base FrameworkBase Standard Profile
Seq#Data ElementDescriptionFlagsImplementCardinalityLengthC.LENVocabularyData TypeImplementVocabulary
RDF 
100701Number of Columns per Row
=

Truncation not allowed!

SHOULD[1..1] 3
NM

Numeric

SHALL
200702Column Description SHOULD[1..*] univ: DataTypes (CD)SHALLhl7VS-dataTypes (VS) dataTypes (CS)
Base Framework Base Standard Profile
Seq# Data Element Description Flags Optionality Repetition Length C.LEN Table Data Type Optionality Table
RDF  
1 00701 Number of Columns per Row   O     3=  
NM

Numeric

R  
2 00702 Column Description   O Y   (0440) R  
Seq# Data Element Description Optionality Repetition Length C.LEN Table Data Type
RDF
1 00701 Number of Columns per Row R     3=  
NM

Numeric

2 00702 Column Description R Y   (0440)

20.5.7.1 RDF field definitions (5.5.7.0)

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

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

20.5.7.3 RDF-2 Column Description (RCD) 00702 (5.5.7.2)

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.

20.5.8 RDT - table row data segment (5.5.8)

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

HL7 Attribute Table - RDT - Table Row Data

Seq# Data Element Description Optionality Repetition Length C.LEN Table Data Type
RDT
1 00703 Column Value R      
varies

variable data type

20.5.8.1 RDT field definitions (5.5.8.0)

20.5.8.2 RDT-1 Column Value (varies) 00703 (5.5.8.1)

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.

20.6 AUXILIARY QUERY PROTOCOLS (5.6)

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.

20.6.1 Immediate vs. deferred response (5.6.1)

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:

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.

20.6.1.1 hiddentext (5.6.1.0)

20.6.1.2 Immediate response (5.6.1.1)

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

MSH|^~\&|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|^~\&|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

20.6.1.3 Deferred response example (5.6.1.2)

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

MSH|^~\&|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|^~\&|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|^~\&|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|^~\&|PCR|Gen Hosp|PIMS||199811210300-0800||ACK^K42^ACK|8750|P|2.8||||||||

MSA|AA|9950|

20.6.2 Query cancellation (5.6.2)

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|^~\&|||||||QCN^Jnn^QCN_J01|...

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

...

20.6.3 Interactive continuation of response messages (5.6.3)

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.

20.6.3.1 hiddentext (5.6.3.0)

20.6.3.2 Interactive continuation algorithm and rules (5.6.3.1)

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

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.

20.6.3.3 Use case (5.6.3.2)

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.

20.6.3.4 Example of interactive continuation protocol (5.6.3.3)

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|^~\&|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|^~\&|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.

MSH|^~\&|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|^~\&|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.

20.6.3.5 Message fragmentation example (5.6.3.4)

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|^~\&|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|^~\&|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|^~\&|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|^~\&|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|^~\&|CIS||RAD||||ACK^K61|7782|P|2.8|

MSA|AA|5560|

20.6.4 Batch message as a query response (5.6.4)

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

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

[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)

20.6.5 Query error response (5.6.5)

A query/response error can occur at 3 levels:

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

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).

20.7 PUBLISH AND SUBSCRIBE (5.7)

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

20.7.1 Introduction (5.7.1)

"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.

20.7.2 Details (5.7.2)

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.

20.7.3 Examples (5.7.3)

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:

20.7.3.1 hiddentext (5.7.3.0)

20.7.3.2 Example of a publish and subscribe Query Profile (5.7.3.1)

Query Profile

Segment Cardinality Implement Status
QSB^Z83^QSB_Q16
MSH

Message Header

[1..1] SHALL
SFT

Software Segment

 
QPD

Query Parameter Definition

[1..1] SHALL
RCP

Response Control Parameter

[1..1] SHALL
DSC

Continuation Pointer

[0..1]  

 

QSB_Q16

MSH-15 MSH-16 Immediate ACK Application Ack
Blank Blank - ACK^Q16^ACK
NE AL - ACK^Q16^ACK
AL, SU, ER AL ACK^Q16^ACK ACK^Q16^ACK
We need some ER7 examples...
We need some XML examples...

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

QPD Input Parameter Field Description and Commentary

RCP Response Control Parameter Field Description and Commentary

20.7.4 Establishing a subscription (5.7.4)

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|^~\&|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|^~\&|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).

20.7.5 Canceling a subscription (5.7.5)

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

The template would be as follows:

MSH|^~\&|||||||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|^~\&|CPR|COMWEST|PS^LAB||||QSX^J99^QSX_J01|

QID|Q0044|Q99^ORU_Subscription^HL70003|

20.8 QUERY IMPLEMENTATION CONSIDERATIONS (5.8)

Implementation issues are discussed in section 5.2.

20.9 QUERY/RESPONSE MESSAGE EXAMPLES (5.9)

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

20.9.1.1 hiddentext (5.9.1.0)

20.9.1.2 Proposed dispense history example and Query Profile (5.9.1.1)

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

Segment Cardinality Implement Status
RDR^RDR^RDR_RDR
MSH

Message Header

[1..1] SHALL
MSA

Message Acknowledgment

[1..1] SHALL
SFT

Software Segment

[0..1]  
UAC

User Authentication Credential Segment

[0..1]  
DEFINITION [1..*] SHALL
QRD

QRD (added by default)

[1..1] SHALL
QRF

QRF (added by default)

[0..1]  
PATIENT [0..1]  
PID

Patient Identification

[1..1] SHALL
NTE

Notes and Comments

 
ORDER [1..*] SHALL
ORC

Common Order

[1..1] SHALL
TIMING  
TQ1

Timing/Quantity

[1..1] SHALL
TQ2

Timing/Quantity Relationship

 
ENCODING [0..1]  
RXE

Pharmacy/Treatment Encoded Order

[1..1] SHALL
TIMING_ENCODED  
TQ1

Timing/Quantity

[1..1] SHALL
TQ2

Timing/Quantity Relationship

 
RXR

Pharmacy/Treatment Route

[1..*] SHALL
RXC

Pharmacy/Treatment Component Order

 
DISPENSE [1..*] SHALL
RXD

Pharmacy/Treatment Dispense

[1..1] SHALL
RXR

Pharmacy/Treatment Route

[1..*] SHALL
RXC

Pharmacy/Treatment Component Order

 
DSC

Continuation Pointer

[0..1]  

 

RDR_RDR

MSH-15 MSH-16 Immediate ACK Application Ack
We need some ER7 examples...
We need some XML examples...

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|^~\&|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|^~\&|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

20.9.1.2.1 Associated dispense history Query Profile (5.9.1.1.1)

Query Profile

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

Segment Cardinality Implement Status
RSP^Z82^RSP_Z82
MSH

Message Header

[1..1] SHALL
ARV

Access Restriction

  v2.9
UAC

User Authentication Credential Segment

[0..1]  
MSA

Message Acknowledgment

[1..1] SHALL
ERR

Error

[0..1]  
QAK

Query Acknowledgment

[1..1] SHALL
QPD

Query Parameter Definition

[1..1] SHALL
RCP

Response Control Parameter

[1..1] SHALL
QUERY_RESPONSE [1..*] SHALL
PATIENT [0..1]  
PID

Patient Identification

[1..1] SHALL
PD1

Patient Additional Demographic

[0..1]  
NTE

Notes and Comments

 
VISIT [0..1]  
AL1

Patient Allergy Information

[1..*] SHALL
PV1

Patient Visit

[1..1] SHALL
PV2

Patient Visit - Additional Information

[0..1]  
COMMON_ORDER [1..*] SHALL
ORC

Common Order

[1..1] SHALL
TIMING  
TQ1

Timing/Quantity

[1..1] SHALL
TQ2

Timing/Quantity Relationship

 
ORDER_DETAIL [0..1]  
RXO

Pharmacy/Treatment Order

[1..1] SHALL
NTE

Notes and Comments

 
RXR

Pharmacy/Treatment Route

[1..*] SHALL
TREATMENT [0..1]  
RXC

Pharmacy/Treatment Component Order

[1..*] SHALL
NTE

Notes and Comments

 
ENCODED_ORDER [0..1]  
RXE

Pharmacy/Treatment Encoded Order

[1..1] SHALL
TIMING_ENCODED  
TQ1

Timing/Quantity

[1..1] SHALL
TQ2

Timing/Quantity Relationship

 
RXR

Pharmacy/Treatment Route

[1..*] SHALL
RXC

Pharmacy/Treatment Component Order

 
RXD

Pharmacy/Treatment Dispense

[1..1] SHALL
RXR

Pharmacy/Treatment Route

[1..*] SHALL
RXC

Pharmacy/Treatment Component Order

 
OBSERVATION [1..*] SHALL
OBX

Observation/Result

[0..1]  
NTE

Notes and Comments

 
DSC

Continuation Pointer

[0..1]  

 

RSP_Z82

MSH-15 MSH-16 Immediate ACK Application Ack
We need some ER7 examples...
We need some XML examples...

Input Parameter Specification

Input Parameter Field Description and Commentary

20.9.1.3 Comprehensive pharmacy information examples and Query Profile (5.9.1.2)

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|^~\&|PCR|Gen Hosp|PIMS||199811201400-0800||QBP^Z85^QBP_Q11|8332|P|2.8||||||||

QPD|Z85^Pharmacy Information Comprehensive^HL7nnnn|Q002|555444222111^^^MPI^MR ||||19980531|19990531||RXO~RXG~RXA|

RCP|I|999^RD|

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

MSH|^~\&|PIMS|Gen hosp|PCR||199811201400-0800||RSP^Z86^RSP_Z86|8858|P|2.8||||||||

MSA|AA|8332|

QAK|Q002|OK|Z85^Pharmacy Information Comprehensive^HL70003|4|

QPD|Z85^Pharmacy Information Comprehensive^HL7nnnn|Q002|555444222111^^^MPI^MR ||||19980531|19990531||RXO~RXG~RXA|

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^5555001||||||RXD|1|00172409660^BACLOFEN 10MG TABS^NDC|199809221415-0700|10|||199810310600-0700|5|AS DIRECTED||||||||||||

RXR|PO||||

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

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

RXR|PO

OBX|1|ST|2951-2^SODIUM^LN||150|mmol/l|136-148|H||A|F|19850301||199811180700-0800

OBX|2|ST|2823-3^POTASSIUM^LN||4.5|mmol/l|3.5-5|N||N|F|19850301||199811180700-0800

OBX|3|ST|2075-0^CHLORIDE^LN||102|mmol/l|94-105|N||N|F|19850301||199811180700-0800

OBX|4|ST|2028-9^CARBON DIOXIDE^LN||27|mmol/l|24-31|N||N|F|19850301||199811180700-0800

...

Note the use of OBX-14-Date/time of the observation to time the laboratory observations.

20.9.1.3.1 Comprehensive pharmacy information Query Profile (5.9.1.2.1)

The following is a highly experimental approach to establishing a super segment pattern response to a general purpose query structure. It contains all of the pharmacy information segments as possible inclusions in the response. It differs from previously defined segment pattern queries in that it cuts across multiple related standard HL7 messages although there is a logical hierarchy that can be determined.

Query Profile

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

Segment Cardinality Implement Status
RSP^Z86^RSP_Z86
MSH

Message Header

[1..1] SHALL
SFT

Software Segment

 
MSA

Message Acknowledgment

[1..1] SHALL
ERR

Error

[0..1]  
QAK

Query Acknowledgment

[1..1] SHALL
QPD

Query Parameter Definition

[1..1] SHALL
QUERY_RESPONSE [1..*] SHALL
PATIENT [0..1]  
PID

Patient Identification

[1..1] SHALL
PD1

Patient Additional Demographic

[0..1]  
NTE

Notes and Comments

 
AL1

Patient Allergy Information

 
COMMON_ORDER [1..*] SHALL
ORC

Common Order

[1..1] SHALL
TIMING  
TQ1

Timing/Quantity

[1..1] SHALL
TQ2

Timing/Quantity Relationship

 
ORDER_DETAIL [0..1]  
RXO

Pharmacy/Treatment Order

[1..1] SHALL
RXR

Pharmacy/Treatment Route

[1..*] SHALL
RXC

Pharmacy/Treatment Component Order

 
ENCODED_ORDER [0..1]  
RXE

Pharmacy/Treatment Encoded Order

[1..1] SHALL
TIMING_ENCODED  
TQ1

Timing/Quantity

[1..1] SHALL
TQ2

Timing/Quantity Relationship

 
RXR

Pharmacy/Treatment Route

[1..*] SHALL
RXC

Pharmacy/Treatment Component Order

 
DISPENSE [0..1]  
RXD

Pharmacy/Treatment Dispense

[1..1] SHALL
RXR

Pharmacy/Treatment Route

[1..*] SHALL
RXC

Pharmacy/Treatment Component Order

 
GIVE [0..1]  
RXG

Pharmacy/Treatment Give

[1..1] SHALL
RXR

Pharmacy/Treatment Route

[1..*] SHALL
RXC

Pharmacy/Treatment Component Order

 
ADMINISTRATION [0..1]  
RXA

Pharmacy/Treatment Administration

[1..1] SHALL
RXR

Pharmacy/Treatment Route

[1..*] SHALL
RXC

Pharmacy/Treatment Component Order

 
OBSERVATION [1..*] SHALL
OBX

Observation/Result

[0..1]  
NTE

Notes and Comments

 
DSC

Continuation Pointer

[0..1]  

 

RSP_Z86

MSH-15 MSH-16 Immediate ACK Application Ack
We need some ER7 examples...
We need some XML examples...

QPD Input Parameter Specification

QPD Input Parameter Field Description and Commentary

RCP Response Control Parameter Field Description and Commentary

20.9.2 Query using QSC variant / segment pattern response examples (5.9.2)

20.9.2.1 hiddentext (5.9.2.0)

20.9.2.2 Dispense information example and Query Profile (5.9.2.1)

The following example demonstrates that the same results, as shown in the example in 5.9.1.1, can be obtained using the QSC variant. The difference is how the input parameters are expressed.

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 message is generated:

MSH|^~\&|PCR|Gen Hosp|PIMS||199811201300-0800||QBP^Z87^QBP_Q11|8698|P|2.8||||||||

QPD|Z87^Dispense Information^HL7nnnn|Q001|@PID.3^EQ^55544422211^AND|@ORC.1^EQ^RE^ AND|@RXD.3^GE^199805310000-0800^AND|@RXD.3^LE^199905310000-0800

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/99 and returns the following RSP message:

MSH|^~\&|PIMS|Gen Hosp|PCR||199811201300-0800||RSP^Z88^RSP_Z88|8857|P|2.8||||||||

MSA|AA|8698|

QAK|Q001|OK|Z87^Dispense Information^HL7nnnn|4

QPD|Z87^Dispense Information^HL7nnnn|Q001|@PID.3^EQ^55544422211^AND~ORC.1^EQ^RE^ AND~@RXD.3^GE^199805310000-0800^AND~@RXD.3^LE^199905310000-0800

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

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

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

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

RXR|PO||||

ORC|RE||89968665||||||199905291030-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|19990821|||

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

RXR|PO||||

ORC|RE||235134037||||||199809221330-0700|||88^Seven^Henry^^^DR^MD||^^^^^510^ 2673900||||||

RXD|1|00172409660^BACLOFEN 10MG TABS^NDC|199809221415-0700|10|||235134037|5|AS DIRECTED||||||||||||

RXR|PO||||

ORC|RE||235134030||||||199810121030-0700|||99^Assigned^Amanda^^^DR^MD||^^^^^510^ 2673700||||||

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

RXR|PO

20.9.2.2.1 Associated dispense information Query Profile (5.9.2.1.1)

Note that the following Query Profile contains many more input parameters. The user is allowed to populate as many of these as desired.

Query Profile

Segment Cardinality Implement Status
QBP^Z87^QBP_Q11
MSH

Message Header

[1..1] SHALL
ARV

Access Restriction

 
UAC

User Authentication Credential Segment

[0..1]  
QPD

Query Parameter Definition

[1..1] SHALL
QBP [0..1]  
Hxx

any HL7 segment

[0..1]  
RCP

Response Control Parameter

[1..1] SHALL
DSC

Continuation Pointer

[0..1]  

 

QBP_Q11

MSH-15 MSH-16 Immediate ACK Application Ack
Blank Blank - RSP^K11^RSP_K11
Blank Blank - RSP^Znn^RSP_Znn
Blank Blank - RSP^K31^RSP_K31
NE AL - RSP^K11^RSP_K11
NE AL - RSP^Znn^RSP_Znn
NE NE - -
AL, SU, ER AL ACK^Q11^ACK RSP^K11^RSP_K11
AL, SU, ER AL ACK^Znn^ACK RSP^Znn^RSP_Znn
AL, SU, ER NE ACK^Q31^ACK -
NE AL, SU, ER - RSP^K31^RSP_K31
AL, SU, ER AL, SU, ER ACK^Q31^ACK RSP^K31^RSP_K31
We need some ER7 examples...
We need some XML examples...
Segment Cardinality Implement Status
RSP^Z88^RSP_Z88
MSH

Message Header

[1..1] SHALL
SFT

Software Segment

 
MSA

Message Acknowledgment

[1..1] SHALL
ERR

Error

[0..1]  
QAK

Query Acknowledgment

[1..1] SHALL
QPD

Query Parameter Definition

[1..1] SHALL
RCP

Response Control Parameter

[1..1] SHALL
QUERY_RESPONSE [1..*] SHALL
PATIENT [0..1]  
PID

Patient Identification

[1..1] SHALL
PD1

Patient Additional Demographic

[0..1]  
NTE

Notes and Comments

 
ALLERGY [0..1]  
AL1

Patient Allergy Information

[1..*] SHALL
VISIT [0..1]  
PV1

Patient Visit

[1..1] SHALL
PV2

Patient Visit - Additional Information

[0..1]  
COMMON_ORDER [1..*] SHALL
ORC

Common Order

[1..1] SHALL
TIMING  
TQ1

Timing/Quantity

[1..1] SHALL
TQ2

Timing/Quantity Relationship

 
ORDER_DETAIL [0..1]  
RXO

Pharmacy/Treatment Order

[1..1] SHALL
NTE

Notes and Comments

 
RXR

Pharmacy/Treatment Route

[1..*] SHALL
COMPONENT [0..1]  
RXC

Pharmacy/Treatment Component Order

[1..*] SHALL
NTE

Notes and Comments

 
ORDER_ENCODED [0..1]  
RXE

Pharmacy/Treatment Encoded Order

[1..1] SHALL
TIMING_ENCODED  
TQ1

Timing/Quantity

[1..1] SHALL
TQ2

Timing/Quantity Relationship

 
RXR

Pharmacy/Treatment Route

[1..*] SHALL
RXC

Pharmacy/Treatment Component Order

 
RXD

Pharmacy/Treatment Dispense

[1..1] SHALL
RXR

Pharmacy/Treatment Route

[1..*] SHALL
RXC

Pharmacy/Treatment Component Order

 
OBSERVATION [1..*] SHALL
OBX

Observation/Result

[0..1]  
NTE

Notes and Comments

 
DSC

Continuation Pointer

[1..1] SHALL

 

RSP_Z88

MSH-15 MSH-16 Immediate ACK Application Ack
We need some ER7 examples...
We need some XML examples...

QPD Input Parameter Specification

QPD Input Parameter Field Description and Commentary

Input Specification: Virtual Table

Virtual Table Field Description and Commentary

RCP Response Control Parameter Field Description and Commentary

20.9.2.3 Dispense information query showing different instantiation (5.9.2.2)

The following example shows how the same QSC style query can be invoked in a very different way producing very different results.

The user wishes to know all the medications ever dispensed for the patient whose medical record number is "555444222111" prescribed by Dr Lister (provider number 99). The following message is generated. Note that the same Query has been used, but different input specifications were used.

MSH|^~\&|PCR|Gen Hosp|PIMS||199811201300-0800||QBP^Z87^QBP_Q11|8698|P|2.8||||||||

QPD|Q33^Dispense Information^HL7nnnn|Q005| @PID.3^EQ^55544422211^AND|@ORC.1^EQ^RE^AND|@ORC.12.1^EQ^99

RCP|I|999^RD|

The pharmacy system identifies medical record number "555444222111" as belonging to Adam Everyman and locates 2 prescription dispenses as prescribed by Dr. Lister. The response is clearly different than the response to the first query.

MSH|^~\&|PIMS|Gen Hosp|PCR||199811201300-0800||RSP^Z88^RSP_Z88|8857|P|2.8||||||||

MSA|AA|8698|

QAK|Q005|OK|Q33^Dispense Information^HL7nnnn|2|

QPD|Q33^Dispense Information^HL7nnnn|Q005| @PID.3^EQ^55544422211^AND~@ORC.1^EQ^RE^AND~@ORC.12.1^EQ^99

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

ORC|RE||89968665||||||199603121345-0700|||99^Assigned^Amanda^^^DR^MD ||^^^^^510^ 2673600||||||

RXE|1^BID^^19980529|00182196901^VERAPAMIL HCL ER TAB 180MG ER^NDC |120||mgm||||||||||||||||||||||||||

RXD|1|00182196901^VERAPAMIL HCL ER TAB 180MG ER^NDC|199603122000-0700|100|||1331665|3|||||||||||||||||

RXR|PO||||

ORC|RE||235134030||||||199810121030-0700|||88^PRIMARY^PATRICIA^H^III^DR^MD||^^^^^555^ 5551004||||||

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

RXR|PO

20.9.2.4 Lab results history example (5.9.2.3)

The user wishes to know all the lab results for the patient whose medical record is 80302641876 and where the result report date/time is between March 21, 1999 and June 24, 1999 and the Lab department is chemistry. This Query Name might be invoked once with a query tag of 123 in the following manner:

MSH|^~\&| PCR|Gen Hosp|LIS.RMS||199907131030-0800||QBP^Z89^QBP_Q11|4460|P|2.8|

QPD|Z89^Lab Results History^HL7nnnn|123|@PID.3.1.1^EQ^80302641876^AND| @OBR.22^GE^19990321^AND|@OBR.22^LE^19990624^AND|@OBR.24^EQ^"CHEMISTRY"

RCP|I||R|

20.9.2.5 Lab results history Query Profile (5.9.2.4)

The "Lab Results History" query returns laboratory results information in the form of the Segment Pattern Response corresponding to the ORU^R01 - unsolicited transmission of an observation message. It returns all of the results which meet the criteria defined in the QPD - Query Parameter Definition Segment of the RSP^R11 - Segment Pattern Response message.

Query Profile

Segment Cardinality Implement Status
QBP^Z89^QBP_Q11
MSH

Message Header

[1..1] SHALL
ARV

Access Restriction

 
UAC

User Authentication Credential Segment

[0..1]  
QPD

Query Parameter Definition

[1..1] SHALL
QBP [0..1]  
Hxx

any HL7 segment

[0..1]  
RCP

Response Control Parameter

[1..1] SHALL
DSC

Continuation Pointer

[0..1]  

 

QBP_Q11

MSH-15 MSH-16 Immediate ACK Application Ack
Blank Blank - RSP^K11^RSP_K11
Blank Blank - RSP^Znn^RSP_Znn
Blank Blank - RSP^K31^RSP_K31
NE AL - RSP^K11^RSP_K11
NE AL - RSP^Znn^RSP_Znn
NE NE - -
AL, SU, ER AL ACK^Q11^ACK RSP^K11^RSP_K11
AL, SU, ER AL ACK^Znn^ACK RSP^Znn^RSP_Znn
AL, SU, ER NE ACK^Q31^ACK -
NE AL, SU, ER - RSP^K31^RSP_K31
AL, SU, ER AL, SU, ER ACK^Q31^ACK RSP^K31^RSP_K31
We need some ER7 examples...
We need some XML examples...
Segment Cardinality Implement Status
RSP^Z90^RSP_Z90
MSH

Message Header

[1..1] SHALL
SFT

Software Segment

 
MSA

Message Acknowledgment

[1..1] SHALL
ERR

Error

[0..1]  
QAK

Query Acknowledgment

[1..1] SHALL
QPD

Query Parameter Definition

[1..1] SHALL
RCP

Response Control Parameter

[1..1] SHALL
QUERY_RESPONSE [1..*] SHALL
PATIENT [0..1]  
PID

Patient Identification

[1..1] SHALL
PD1

Patient Additional Demographic

[0..1]  
NK1

Next of Kin / Associated Parties

 
NTE

Notes and Comments

 
VISIT [0..1]  
PV1

Patient Visit

[1..1] SHALL
PV2

Patient Visit - Additional Information

[0..1]  
COMMON_ORDER [1..*] SHALL
ORC

Common Order

[1..1] SHALL
TIMING  
TQ1

Timing/Quantity

[1..1] SHALL
TQ2

Timing/Quantity Relationship

 
OBR

Observation Request

[1..1] SHALL
NTE

Notes and Comments

 
CTD

Contact Data

[0..1]  
OBSERVATION [1..*] SHALL
OBX

Observation/Result

[0..1]  
NTE

Notes and Comments

 
SPECIMEN  
SPM

Specimen

[1..1] SHALL
OBX

Observation/Result

 
DSC

Continuation Pointer

[1..1] SHALL

 

RSP_Z90

MSH-15 MSH-16 Immediate ACK Application Ack
We need some ER7 examples...
We need some XML examples...

QPD Input Parameter Specification

QPD Input Parameter Field Description and Commentary

Input Specification: Virtual Table

Input Parameter Field Description and Commentary

RCP Response Control Parameter Field Description and Commentary

If a LOINC code is used as one of the operands of the input specification expression, all of the other OBX segments which are part of the same OBR as the selected OBX will be returned along with the selected OBX. In other words, if an OBX segment that is part of a panel is selected by the query, the entire panel will be returned.

20.9.2.6 Lab example different instantiation (5.9.2.5)

The same Query Name might be invoked with a different query tag (456) as follows:

The user wishes to know all the lab results reported having a LOINC code of 6777-7 between March 21, 1999 and March 23, 1999.

MSH|^~\&|PCR|GenHosp|LIS||199907131040-0800||QBP^Z89^QBP_Z89|4495|D|2.8|

QPD|Z89^LabResultsHistory^HL7nnnn||@OBX.3.4^EQ^6777-7^AND|@OBR.22^GE^19990321^AND|@OBR.22^LE^19990323

RCP|I||R|

The second instance of the "Lab Results for Specified Criteria" query would clearly return quite different results than the first even though both are invocations of the same query.

20.9.3 Query by parameter (QBP) / tabular response (RTB) (5.9.3)

20.9.3.1 hiddentext (5.9.3.0)

20.9.3.2 MPI example (5.9.3.1)

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

MSH|^~\&|PCR|GenHosp|MPI||199811201400-0800||QBP^Z91^QBP_Q13|8699|P|2.8||||||||

QPD|Z91^WhoAmI^HL7nnnn|Q0009|555444222111^^^MPI^MR

RCP|I|999^RD|

RDF|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|^~\&|MPI|GenHosp|PCR||199811201400-0800||RTB^Z92^RTB_K13|8699|P|2.8||||||||

MSA|AA|8699|

QAK|Q0009|OK|Z91^WhoAmI^HL7nnnn|1|

QPD|Z91^WhoAmI^HL7nnnn|Q0009|555444222111^^MPI^MR

RDF|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||

20.9.3.2.1 MPI Query Profile (5.9.3.1.1)

Query Profile

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

Segment Cardinality Implement Status
RTB^Z92^RTB_K13
MSH

Message Header

[1..1] SHALL
SFT

Software Segment

 
MSA

Message Acknowledgment

[1..1] SHALL
ERR

Error

[0..1]  
QAK

Query Acknowledgment

[1..1] SHALL
QPD

Query Parameter Definition

[1..1] SHALL
ROW_DEFINITION [0..1]  
RDF

Table Row Definition

[1..1] SHALL
RDT

Table Row Data

 
DSC

Continuation Pointer

[0..1]  

 

RTB_K13

MSH-15 MSH-16 Immediate ACK Application Ack
Blank Blank - -
Blank Blank - -
NE AL - -
NE AL - -
AL, SU, ER AL ACK^K13^ACK -
AL, SU, ER AL ACK^Znn^ACK -
We need some ER7 examples...
We need some XML examples...

QPD Input Parameter Specification

QPD Input Parameter Field Description and Commentary

RCP Response Control Parameter Field Description and Commentary

Output Specification and Commentary: Virtual Table

20.9.3.3 Pharmacy example: (5.9.3.2)

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|^~\&|PCR|Gen Hosp|PIMS||199811201400-0800||QBP^Q42^QBP_Q13|8699|P|2.8||||||||

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

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

RCP|I|999^RD|

The pharmacy system identifies medical record number "555444222111" as belonging to Adam Everyman and locates 4 prescription dispenses meeting the criteria and returns the following RTB message:

MSH|^~\&|PIMS|Gen Hosp|PCR||199811201400-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

20.9.3.3.1 QBP/RTB dispense history Query Profile (5.9.3.2.1)

Query Profile

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

Segment Cardinality Implement Status
RTB^Z94^RTB_K13
MSH

Message Header

[1..1] SHALL
SFT

Software Segment

 
MSA

Message Acknowledgment

[1..1] SHALL
ERR

Error

[0..1]  
QAK

Query Acknowledgment

[1..1] SHALL
QPD

Query Parameter Definition

[1..1] SHALL
ROW_DEFINITION [0..1]  
RDF

Table Row Definition

[1..1] SHALL
RDT

Table Row Data

 
DSC

Continuation Pointer

[0..1]  

 

RTB_K13

MSH-15 MSH-16 Immediate ACK Application Ack
Blank Blank - -
Blank Blank - -
NE AL - -
NE AL - -
AL, SU, ER AL ACK^K13^ACK -
AL, SU, ER AL ACK^Znn^ACK -
We need some ER7 examples...
We need some XML examples...

QPD Input Parameter Specification

QPD Input Parameter Field Description and Commentary

RCP Response Control Parameter Field Description and Commentary

Output Specification and Commentary: Virtual Table

20.9.4 Query using QSC variant / tabular response (RTB) (5.9.4)

20.9.4.1 hiddentext (5.9.4.0)

20.9.4.2 Pharmacy example (5.9.4.1)

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 message is generated:

MSH|^~\&|PCR|Gen Hosp|PIMS||199811201400-0800||QBP^Z95^QBP_Q13|8699|P|2.8||||||||

QPD|Z95^Dispense Information^HL7nnnn|Q504 |PID.3^EQ^55544422211^AND~RXD.3^GE^19980531^AND~RXD.3^LE^19990531

RDF|3|PatientList^ST^20|PatientName^XPN^48|OrderControlCode^ID^2|OrderingProvider^XCN^120|MedicationDispensed^ST^40|DispenseDate^DTM^24|QuantityDispensed^NM^20|

RCP|I|999^RD|

The pharmacy system identifies medical record number "555444222111" as belonging to Adam Everyman and locates 4 prescription dispenses meeting the criteria and returns the following RTB message:

MSH|^~\&|PIMS|Gen Hosp|PCR||199811201400-0800||RTB^Z96^RTB_K13|8858|P|2.8||||||||

MSA|AA|8699|

QAK|Q001|OK|Z95^Dispense Information^HL7nnnn|4

QPD|Z95^Dispense Information^HL7nnnn|Q504 |PID.3^EQ^55544422211^AND~RXD.3^GE^19980531^AND~RXD.3^LE^19990531

RDF|3|PatientList^ST^20~PatientName^XPN^48~OrderControlCode^ID^2~OrderingProvider^XCN^120~MedicationDispensed^ST^40~DispenseDate^DTM^24~QuantityDispensed^NM^20|

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

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

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

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

20.9.4.2.1 QBP/RTB dispense history Query Profile using QSC variant (5.9.4.1.1)

Note that this Query Profile includes no separate Output Description and Commentary. In the QBP/RTB combination using the QSC variant, the selection criteria in QPD-3-user parameters and the desired return data in RDF-2-column description are constructed from the same Virtual Table, which appears in the Input Specification.

Query Profile

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

Segment Cardinality Implement Status
RTB^Z96^RTB_K13
MSH

Message Header

[1..1] SHALL
SFT

Software Segment

 
MSA

Message Acknowledgment

[1..1] SHALL
ERR

Error

[0..1]  
QAK

Query Acknowledgment

[1..1] SHALL
QPD

Query Parameter Definition

[1..1] SHALL
ROW_DEFINITION [0..1]  
RDF

Table Row Definition

[1..1] SHALL
RDT

Table Row Data

 
DSC

Continuation Pointer

[0..1]  

 

RTB_K13

MSH-15 MSH-16 Immediate ACK Application Ack
Blank Blank - -
Blank Blank - -
NE AL - -
NE AL - -
AL, SU, ER AL ACK^K13^ACK -
AL, SU, ER AL ACK^Znn^ACK -
We need some ER7 examples...
We need some XML examples...

QPD Input Parameter Specification

QPD Input Parameter Field Description and Commentary

Input/Output Specification: Virtual Table

Virtual Table Field Description and Commentary

RCP Response Control Parameter Field Description and Commentary

20.9.5 Query by parameter (QBP) / display response (RDY) (5.9.5)

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|^~\&|PCR|Gen Hosp|PIMS||199909171400-0800||QBP^Z97^QBP_Q15|8699|P|2.8||||||||

QPD|Z97^DispenseHistoryDisplay^HL7nnnn|Q005|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 meeting the criteria and returns the following RDY message:

MSH|^~\&|PIMS|Gen Hosp|PCR||199909171401-0800||RDY^Z98^RDY_K15|8858|P|2.8||||||||

MSA|AA|8699|

QAK|Q005|OK|Z97^DispenseHistoryDisplay|4

QPD|Z97^DispenseHistoryDisplay^HL7nnnn|Q005|555444222111^^^MPI^MR||19980531|19990531|

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 08/21/1998

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

DSP|||555444222111 Everyman,Adam THEOPHYLLINE 80MG/15ML SOL 10/12/1998

DSP||| << END OF REPORT >>

20.9.5.1 hiddentext (5.9.5.0)

20.9.5.2 Dispense history display Query Profile (5.9.5.1)

Note that this Query Profile includes no separate Output Description and Commentary. In Query Profiles that specify an RDY response message, the display format follows the response grammar.

Query Profile

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

Segment Cardinality Implement Status
RDY^Z98^RDY_K15
MSH

Message Header

[1..1] SHALL
SFT

Software Segment

 
MSA

Message Acknowledgment

[1..1] SHALL
ERR

Error

[0..1]  
QAK

Query Acknowledgment

[1..1] SHALL
QPD

Query Parameter Definition

[1..1] SHALL
DSP

Display Data

 
DSC

Continuation Pointer

[0..1]  

 

RDY_K15

MSH-15 MSH-16 Immediate ACK Application Ack
Blank Blank - -
Blank Blank - -
Blank Blank - -
NE AL - -
NE AL - -
NE AL - -
AL, SU, ER AL ACK^K15^ACK -
AL, SU, ER AL ACK^Znn^ACK -
AL, SU, ER AL ACK^Znn^ACK -
We need some ER7 examples...
We need some XML examples...

QPD Input Parameter Specification

QPD Input Parameter Field Description and Commentary

RCP Response Control Parameter Field Description and Commentary

20.9.6 Query using QSC variant (QBP) / display response (RDY) (5.9.6)

The user wishes to know all the medications ever dispensed for the patient whose medical record number is "555444222111" prescribed by Dr Lister (provider number 99). The following message is generated. (Note the similarity between the QPD segment here and that used in the query in Section 5.8.4.)

MSH|^~\&|PCR|Gen Hosp|PIMS||199811201300-0800||QBP^Z79^QBP_Q15|8698|P|2.8||||||||

QPD|Z79^Dispense Information^HL7nnnn|Q503 |PID.3^EQ^55544422211^AND|ORC.1^EQ^RE^AND|ORC.12.1^EQ^99

RCP|I|999^RD|

The pharmacy system identifies medical record number "555444222111" as belonging to Adam Everyman and locates 2 prescription dispenses as prescribed by Dr. Lister. The response is clearly different than the response to the first query.

MSH|^~\&|PIMS|Gen Hosp|PCR||199811201300-0800||RDY^Z80^RDY_K15|8857|P|2.8||||||||

MSA|AA|8698|

QAK|Q003|OK|Z79^Dispense Information^HL7nnnn|2

QPD|Z79^Dispense Information^HL7nnnn|Q503 |@PID.3^EQ^55544422211^AND~ORC.1^EQ^RE^AND~@RXD.3^GE^199711200000-0800^AND~@RXD.3^LE^199811200000-0800

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 THEOPHYLLINE 80MG/15ML SOL 10/12/1998

DSP||| << END OF REPORT >>

20.9.6.1 Dispense history display Query Profile using QSC variant (5.9.6.0)

Note that this Query Profile includes no separate Output Description and Commentary. In Query Profiles that specify an RDY response message, the display format follows the response grammar.

Query Profile

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

Segment Cardinality Implement Status
RDY^Z80^RDY_Z80
MSH

Message Header

[1..1] SHALL
SFT

Software Segment

 
MSA

Message Acknowledgment

[1..1] SHALL
ERR

Error

[0..1]  
QAK

Query Acknowledgment

[1..1] SHALL
QPD

Query Parameter Definition

[1..1] SHALL
DSP

Display Data

 
DSC

Continuation Pointer

[0..1]  

 

RDY_Z80

MSH-15 MSH-16 Immediate ACK Application Ack
We need some ER7 examples...
We need some XML examples...

QPD Input Parameter Specification

QPD Input Parameter Field Description and Commentary

Input Specification: Virtual Table

Virtual Table Field Description and Commentary

RCP Response Control Parameter Field Description and Commentary

20.9.7 Query by example (QBP) / tabular response (RTB) (5.9.7)

This section demonstrates how to use a different syntax for passing query parameters to the query server. This syntactic variant is called "query by example" because, instead of passing query parameter as fields of the QBP segment, they are passed as fields of existing HL7 segments. Nevertheless, the Query Profile will clearly specify which fields of the HL7 segment can carry useful values. Note that both the QBP syntax and the "query by example" syntax have the same expressive power. Also note that when segments are used in the "query by example" variant, the required/optional characteristics of each field should be defined in the Query Profile, and that field optionality in queries may be different from the usual optionality of the segment when used in other HL7 messages.

This sample shows how the "query by example" might be used to find a list of candidates matching a set of demographics. Because demographic data is naturally carried by the existing PID segment, the message designer may, for stylistic or practical reasons, decide to pass the demographic parameters such as patient name or patient age in a PID segment.

The Client wishes to see a list of patients whose demographics are as follows:

The Client wishes to do this using the peekaboo algorithm with an 80% confidence level.

MSH|^~\&|PCR|GenHosp|MPI||199811201400-0800||QBP^Z77^QBP_Q13|8699|P|2.8||||||||

QPD|Z77^find_candidates^HL7nnnn|Q0001|peekaboo|80|

PID|||||Nuclear&Ned||19481211|M

RCP|I|25^RD|

RDF|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|^~\&|MPI|GenHosp|PCR||199811201400-0800||RTB^Z78^RTB_R13|8699|P|2.8||||||||

MSA|AA|8699|

QAK|

QPD|Z77^find_candidates^HL7nnnn|Q0001|peekaboo|80|

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

RDT|555444222111^^^MPI&KP.NCA&L^MR|Nuclear^Ned||19481211|M||

20.9.7.1 hiddentext (5.9.7.0)

20.9.7.2 MPI Query Profile using QBE variant (5.9.7.1)

Query Profile

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

Segment Cardinality Implement Status
RTB^Z78^RTB_K13
MSH

Message Header

[1..1] SHALL
SFT

Software Segment

 
MSA

Message Acknowledgment

[1..1] SHALL
ERR

Error

[0..1]  
QAK

Query Acknowledgment

[1..1] SHALL
QPD

Query Parameter Definition

[1..1] SHALL
ROW_DEFINITION [0..1]  
RDF

Table Row Definition

[1..1] SHALL
RDT

Table Row Data

 
DSC

Continuation Pointer

[0..1]  

 

RTB_K13

MSH-15 MSH-16 Immediate ACK Application Ack
Blank Blank - -
Blank Blank - -
NE AL - -
NE AL - -
AL, SU, ER AL ACK^K13^ACK -
AL, SU, ER AL ACK^Znn^ACK -
We need some ER7 examples...
We need some XML examples...

QPD Input Parameter Specification

QPD Input Parameter Field Description and Commentary

QBE Input Parameter Specification

QBE Input Parameter Field Description and Commentary

RCP Response Control Parameter Field Description and Commentary

Output Specification and Commentary: Virtual Table

The same query as described above could be sent as a pure Query by Parameter query, without the "query by example" variant, as follows.

Notice that the query uses only a single QPD segment to carry all the parameters. The response to the query is the same as for the "query by example" variant above.

Example: the Client wishes to do this using the peekaboo algorithm with an 80% confidence level.

MSH|^~\&|PCR|GenHosp|MPI||199811201400-0800||QBP^Z75^QBP_Q13|8699|P|2.8||||||||

QPD|Z75^find_candidates^HL7nnnn|Q0001|peekaboo|80|Nuclear^Ned|19481211|M

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

RCP|I|999^RD|

The MPI system returns the following RTB message:

MSH|^~\&|MPI|GenHosp|PCR||199811201400-0800||RTB^Z76^RTB_R13|8699|P|2.8||||||||

MSA|AA|8699|

QAK|

QPD|Z75^find_candidates^HL7nnnn|Q0001|peekaboo|80|Nuclear^Ned|19481211|M

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

RDT|555444222111^^^MPI&KP.NCA&L^MR|Nuclear^Ned|19481211|M||

20.9.7.3 MPI Query Profile – Non query by example version (5.9.7.2)

Query Profile

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

Segment Cardinality Implement Status
RTB^Z76^RTB_K13
MSH

Message Header

[1..1] SHALL
SFT

Software Segment

 
MSA

Message Acknowledgment

[1..1] SHALL
ERR

Error

[0..1]  
QAK

Query Acknowledgment

[1..1] SHALL
QPD

Query Parameter Definition

[1..1] SHALL
ROW_DEFINITION [0..1]  
RDF

Table Row Definition

[1..1] SHALL
RDT

Table Row Data

 
DSC

Continuation Pointer

[0..1]  

 

RTB_K13

MSH-15 MSH-16 Immediate ACK Application Ack
Blank Blank - -
Blank Blank - -
NE AL - -
NE AL - -
AL, SU, ER AL ACK^K13^ACK -
AL, SU, ER AL ACK^Znn^ACK -
We need some ER7 examples...
We need some XML examples...

QPD Input Parameter Specification

QPD Input Parameter Field Description and Commentary

RCP Response Control Parameter Field Description and Commentary

Output Specification and Commentary: Virtual Table

20.10 SUPERSEDED QUERY/RESPONSE TRIGGER EVENTS AND MESSAGE PAIRS (5.10)

If the reader is defining a new query, please refer to the new recommended query/response pairs defined in section 5.4, "QUERY/RESPONSE MESSAGE PAIRS." This section is retained for backward compatibility and the framework for the existing functional queries.

20.10.1 Display message (5.10.1)

The UDM message does not have a direct replacement in the new methodology. It is not clear how extensively this message is used.

20.10.1.1 hiddentext (5.10.1.0)

20.10.1.2 Display vs. record-oriented messages (5.10.1.1)

20.10.1.3 UDM/ACK - unsolicited display update message (event Q05) (5.10.1.2)

There is a simple HL7 message that allows for unsolicited display update messages to be sent in HL7 format from one system to another.

Trigger events for the unsolicited update are generally the completion of a particular action (concerning a given patient). For example, a lab test might be completed, generating a STAT unsolicited display message to be sent to the appropriate location.

Segment Cardinality Implement Status
UDM^Q05^UDM_Q05
MSH

Message Header

[1..1] SHALL
SFT

Software Segment

 
URD

withdrawn

[1..1] SHALL
URS

withdrawn

[0..1]  
DSP

Display Data

[1..*] SHALL
DSC

Continuation Pointer

[0..1]  

 

UDM_Q05

MSH-15 MSH-16 Immediate ACK Application Ack
We need some ER7 examples...
We need some XML examples...
Segment Cardinality Implement Status
ACK^Q05^ACK
MSH

Message Header

[1..1] SHALL
SFT

Software Segment

 
MSA

Message Acknowledgment

[1..1] SHALL
ERR

Error

 

 

ACK

We need some ER7 examples...
We need some XML examples...

20.10.1.4 Continuation of unsolicited display update message (5.10.1.3)

Like other types of HL7 messages, the UDM message can be continued by use of the DSC segment and MSH-14-Continuation pointer. Thus if a UDM needs to be continued as three separate UDM messages, the first message would contain:

MSH

(no continuation pointer)

DSC

[{SFT}]

[ UAC ]

URD

[URS]

{DSP}

The second message would contain:

MSH

(continuation pointer (to first message))

[{SFT}]

[ UAC ]

{DSP}

(with continuation pointer)

DSC

The last message would then contain:

MSH

(continuation pointer (to second message))

{DSP}

Note: This scheme works equally well with non-display messages, such as the Unsolicited Update ORU message (see Chapter 7).

Since these are unsolicited messages, intervening messages (from other systems) may be sent to the receiving application while the sections of the particular message are being continued. MSH-14-Continuation pointer enables the receiving system to keep track of extraneous intervening messages.

20.10.2 Original mode queries (5.10.2)

If the reader is defining a new query, please refer to the new recommended query/response pairs defined in section 5.3.3.4. This section is retained for backward compatibility as of v 2.4 and withdrawn as of v 2.7. See section 5.4, "QUERY/RESPONSE MESSAGE PAIRS," for current query/response pairs.

20.11 OUTSTANDING ISSUES (5.11)

It is not clear that there is a good use case for the super segment pattern as described in the example in section 5.9.1.2.1, "Comprehensive pharmacy information Query Profile."

As currently written the usage and naming of segment groups is not clear:

Can a segment group name refer to more than one structure?

Can the same structure have more than one segment group name?

This has implications for table 0391, the segment group table, which is an itemization of the segment group names.