Identifies a previously submitted query for cancellation or status-check purposes in HL7 v2 conformance-based messaging. It carries the query tag that was assigned when the query was first issued and the message query name that classifies the query type. QID appears in QCN (cancel query) messages so the responding system can locate and stop processing the referenced query.
from zato.hl7v2 import QID
qid = QID()
qid.query_tag = 'Q0042'How to construct and work with real-world QID segments.
Identifies a query by tag and name for cancellation
from zato.hl7v2.v2_9 import QID
from zato.hl7v2.v2_9 import CWE
qid = QID()
qid.query_tag = 'Q0042'
qid.message_query_name = CWE(
identifier='Q22',
text='Find candidates',
name_of_coding_system='HL70471'
)References a pharmacy dispense query for cancellation
from zato.hl7v2.v2_9 import QID
from zato.hl7v2.v2_9 import CWE
qid = QID()
qid.query_tag = 'RX-0088'
qid.message_query_name = CWE(
identifier='Q31',
text='Dispense history',
name_of_coding_system='HL70471'
)Minimal identification with just the query tag and coded name
from zato.hl7v2.v2_9 import QID
from zato.hl7v2.v2_9 import CWE
qid = QID()
qid.query_tag = 'LAB-501'
qid.message_query_name = CWE(
identifier='Q04',
text='Lab results',
name_of_coding_system='HL70471'
)Step-by-step guides for working with HL7 v2 in Zato.
QID identifies a previously submitted query so it can be cancelled or its status checked. It appears in QCN (cancel query) messages and carries the query tag and query name that the responding system needs to locate the original request.
QPD defines the full query parameters for a new request, while QID is a lightweight reference used only to identify an existing query by its tag and name. QID is for cancellation; QPD is for submission.
Set the query_tag to match the original query and include the query name:
from zato.hl7v2.v2_9 import QID, CWE
qid = QID()
qid.query_tag = 'Q0042'
qid.message_query_name = CWE(
identifier='Q22',
text='Find candidates',
name_of_coding_system='HL70471'
)It uses the CWE datatype with HL7 table 0471, which lists standardized query names such as Q22 (Find Candidates) and Q31 (Dispense History):
from zato.hl7v2.v2_9 import QID, CWE
qid = QID()
qid.query_tag = 'RX-0088'
qid.message_query_name = CWE(
identifier='Q31',
text='Dispense history',
name_of_coding_system='HL70471'
)Yes, query_tag is required (usage R). It is the unique identifier assigned by the querying system when the original query was submitted, and the responding system uses it to locate the query to cancel.
Zato connects to any system that speaks HL7v2 over MLLP or FHIR over REST. This includes Epic, Cerner, Meditech, Allscripts, and other EHR platforms.
Yes, Zato has built-in MLLP support for sending and receiving HL7v2 messages. MLLP channels handle the framing protocol automatically.
Zato supports HL7 v2.9, which is backward compatible with earlier versions including v2.3, v2.5, and v2.7. Standard segments and datatypes are available as typed Python classes.
Yes. Zato handles both HL7v2 and FHIR natively, so you can parse v2 messages and build FHIR resources with IG-specific extensions in the same service. Typed Python classes are available for both protocols, including extensions from US Core, UK Core, Da Vinci, and other Implementation Guides.
Complete list of fields in the QID segment, HL7 v2.9.
| # | Python name | Datatype | Usage | Repeatable | Table |
|---|---|---|---|---|---|
| 1 | query_tag | ST | Required | No | - |
| 2 | message_query_name | CWE | Required | No | HL70471 |
Get started with Zato and connect your systems in minutes.