The VTQ segment is used to define queries that are responded to with the Tabular Data Message (TBR). The VTQ query message is an alternate method to the EQQ query message that some systems may find easier to implement, due to its use of HL7 delimiters that separate components of the selection definition, and its limited selection criteria. Queries involving complex selection criteria (nested operators, etc.) may need to be formatted as an EQL segment.
As with the other query methods, the functional chapters define specific queries supported as VTQ messages. Refer to these functional chapters for the lists of HL7-defined virtual tables, selection lists and criteria.
SEQ |
LEN |
DT |
OPT |
RP/# |
TBL# |
ITEM# |
ELEMENT NAME |
1 |
32 |
ST |
O |
00696 |
Query Tag |
||
2 |
1 |
ID |
R |
0106 |
00697 |
Query/Response Format Code |
|
3 |
60 |
CE |
R |
00698 |
VT Query Name |
||
4 |
60 |
CE |
R |
00699 |
Virtual Table Name |
||
5 |
256 |
QSC
|
O |
Y |
00700 |
Selection Criteria |
2.24.17.0 VTQ field definitions
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.
Definition: This field refers to HL7 table 0106 - Query/response format code for valid values.
Components: <identifier (ST)> ^ <text (ST)> ^ <name of coding system (ST)> ^ <alternate identifier (ST)> ^ <alternate text (ST)> ^ <name of alternate coding system (ST)>
Definition: This field contains the name of the virtual table query. These names are assigned by the function-specific chapters of this specification. Site-specific VT query names begin with the letter "Z."
Components: <identifier (ST)> ^ <text (ST)> ^ <name of coding system (ST)> ^ <alternate identifier (ST)> ^ <alternate text (ST)> ^ <name of alternate coding system (ST)>
Definition: This field contains the name of the virtual table being referenced. This table name may refer to an HL7-defined segment, an HL7 virtual table (refer to the functional chapters), or a site-specific "Z table."
Components: <name of field (ST)> ^ <relational operator (ID)> ^ <value (ST)> ^ <relational conjunction (ID)>
Definition: Each repetition of this field defines a column in the RDT segment: the first repetition defines the first column of the RDT segment; the second repetition defines the second column of the RDT segments, etc.
This field indicates the conditions that qualify the rows to be returned in the query response. (This field conveys the same information as the "WHERE" clause in the corresponding SQL expression of the query, but is formatted differently.) It is comprised of the following components:
The name of the field that is participating as a qualifier (usually the "key"). Refer to Section 2.24.16.4, "EQL - embedded query language segment," for field naming conventions.
A relational operator, refer to HL7 table 0209 - Relational operator for valid values.
Table 0209 - Relational operator
Relational operator |
Value |
EQ |
Equal |
NE |
Not Equal |
LT |
Less than |
GT |
Greater than |
LE |
Less than or equal |
GE |
Greater than or equal |
CT |
Contains |
GN |
Generic |
The value to which the field will be compared.
If more than one comparison is to be made to select qualifying rows, a conjunction (defined by HL7 table 0210 - Relational conjunction) relating this repetition of the field to the next:
Table 0210 - Relational conjunction
Relational conjunction |
Note |
AND |
Default |
OR |
Hence, the segment
VTQ|TAG001|T|VT_QUERY_NAME|PID|@00108.1^EQ^EVANS^AND~@00108.2^EQ^CAROLYN <CR>
causes a response to be generated from the virtual table defined by the PID segment. All rows containing the name field subcomponents defined in the selection criteria field (last name = "Evans," first name = "Carolyn") will be selected for the response. The columns returned from each selected row will be defined by the RDF segment (see Section 2.24.18, "RDF - table row definition segment").
Notes:
As previously stated, the VTQ segment does not, and is not intended to provide as robust selection function as native EQQ query. It is offered as a simpler alternative.
When applied to strings, the relational operators LT, GT, LE, and GE imply an alphabetic comparison.
A "generic" comparison selects a record for inclusion in the response if the beginning of the designated field matches the select string.
Where a repeating field is specified as an operand, a match on any instance of that field qualifies the row for inclusion in the response message.
AND takes precedence over OR. More sophisticated precedence rules require that the query be expressed as an SQL message, or a stored procedure for the query may be written and referenced with the SPR segment.