Schedule a demo
Segment

Query parameter definition

Carries the input parameters for a conformance-based (enhanced) query in HL7 v2. It identifies the query by name, assigns a unique tag for correlation, and provides user-defined parameter fields whose meaning is determined by the specific query profile. QPD appears in QBP (query by parameter) messages and is echoed back in RSP responses so both sides can match request to result.

3fields
1required
v2.9HL7 version
qpd.py
from zato.hl7v2 import QPD

qpd = QPD()
qpd.query_tag = 'Q0042'

Build QPD segments in Python

How to construct and work with real-world QPD segments.

1

Patient search query

Submits a find-candidates query with a patient name parameter

from zato.hl7v2.v2_9 import QPD
from zato.hl7v2.v2_9 import CWE

qpd = QPD()
qpd.message_query_name = CWE(
    identifier='Q22',
    text='Find candidates',
    name_of_coding_system='HL70471'
)
qpd.query_tag = 'Q0042'
2

Pharmacy dispense query

Queries dispense history using a patient identifier parameter

from zato.hl7v2.v2_9 import QPD
from zato.hl7v2.v2_9 import CWE

qpd = QPD()
qpd.message_query_name = CWE(
    identifier='Q31',
    text='Dispense history',
    name_of_coding_system='HL70471'
)
qpd.query_tag = 'RX-0088'
3

Lab result query

Queries lab results with a tag and no additional user parameters

from zato.hl7v2.v2_9 import QPD
from zato.hl7v2.v2_9 import CWE

qpd = QPD()
qpd.message_query_name = CWE(
    identifier='Q04',
    text='Lab results',
    name_of_coding_system='HL70471'
)
qpd.query_tag = 'LAB-501'

Learn by building

Step-by-step guides for working with HL7 v2 in Zato.

Frequently asked questions

QPD carries the input parameters for a conformance-based query. It names the query type, assigns a unique tag for correlation, and holds any user-defined search parameters. It appears in QBP request messages and is echoed in RSP responses.

Use the CWE datatype with HL7 table 0471:

from zato.hl7v2.v2_9 import QPD, CWE

qpd = QPD()
qpd.message_query_name = CWE(
    identifier='Q22',
    text='Find candidates',
    name_of_coding_system='HL70471'
)

Field 3 (user_parameters_in_successive_fields) has a varies datatype, meaning its structure depends on the query profile. Each query type defines its own parameter layout in successive fields starting at position 3.

QPD defines the query in the request message, and QAK acknowledges the result in the response. Both share the same query_tag value so the requester can correlate the answer to the original question:

from zato.hl7v2.v2_9 import QPD, CWE

qpd = QPD()
qpd.query_tag = 'Q0042'
qpd.message_query_name = CWE(
    identifier='Q22',
    text='Find candidates',
    name_of_coding_system='HL70471'
)

Yes, query_tag is optional (usage O), but it is strongly recommended. Without it, the querying system cannot correlate a response to the original request when multiple queries are in flight.

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.

QPD field reference

Complete list of fields in the QPD segment, HL7 v2.9.

#Python nameDatatypeUsageRepeatableTable
1message_query_nameCWERequiredNoHL70471
2query_tagSTOptionalNo-
3user_parameters_in_successive_fieldsvariesOptionalNo-

Ready to build integrations?

Get started with Zato and connect your systems in minutes.

Open source In Python