Schedule a demo
Segment

Query acknowledgment

Reports the outcome of a query request in HL7 v2 conformance-based (enhanced) query messages. It carries the original query tag, a response status indicating whether data was found, the query name, and optional hit-count fields showing the total matches, how many are in the current payload, and how many remain. QAK appears in RSP and RTB response messages to let the querying system know the disposition of its request.

6fields
0required
v2.9HL7 version
qak.py
from zato.hl7v2 import QAK

qak = QAK()
qak.query_tag = 'Q0042'
qak.query_response_status = 'OK'
qak.hit_count_total = '15'

Build QAK segments in Python

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

1

Successful query response

Acknowledges a query with data found, hit counts, and query name

from zato.hl7v2.v2_9 import QAK
from zato.hl7v2.v2_9 import CWE

qak = QAK()
qak.query_tag = 'Q0042'
qak.query_response_status = 'OK'
qak.message_query_name = CWE(
    identifier='Q22',
    text='Find candidates',
    name_of_coding_system='HL70471'
)
qak.hit_count_total = '15'
qak.this_payload = '10'
qak.hits_remaining = '5'
2

No data found

Query completed but returned zero matching records

from zato.hl7v2.v2_9 import QAK
from zato.hl7v2.v2_9 import CWE

qak = QAK()
qak.query_tag = 'Q0099'
qak.query_response_status = 'NF'
qak.message_query_name = CWE(
    identifier='Q22',
    text='Find candidates',
    name_of_coding_system='HL70471'
)
qak.hit_count_total = '0'
qak.this_payload = '0'
qak.hits_remaining = '0'
3

Application error

Query could not be processed due to an application-level error

from zato.hl7v2.v2_9 import QAK
from zato.hl7v2.v2_9 import CWE

qak = QAK()
qak.query_tag = 'Q0077'
qak.query_response_status = 'AE'
qak.message_query_name = CWE(
    identifier='Q22',
    text='Find candidates',
    name_of_coding_system='HL70471'
)

Learn by building

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

Frequently asked questions

QAK reports the outcome of a conformance-based query. It echoes the query tag, provides a response status (OK, NF, AE, AR), and optionally includes hit counts so the querying system knows how many records matched and how many remain.

The field uses HL7 table 0208. Common values are OK (data found), NF (no data found), AE (application error), and AR (application reject):

from zato.hl7v2.v2_9 import QAK

qak = QAK()
qak.query_tag = 'Q001'

# OK = data found
qak.query_response_status = 'OK'

# NF = no data found
qak.query_response_status = 'NF'

hit_count_total is the total matches, this_payload is how many are in the current response, and hits_remaining is the remainder for continuation:

from zato.hl7v2.v2_9 import QAK

qak = QAK()
qak.query_tag = 'Q001'
qak.query_response_status = 'OK'
qak.hit_count_total = '50'
qak.this_payload = '10'
qak.hits_remaining = '40'

Use the CWE datatype with HL7 table 0471:

from zato.hl7v2.v2_9 import QAK, CWE

qak = QAK()
qak.message_query_name = CWE(
    identifier='Q22',
    text='Find candidates',
    name_of_coding_system='HL70471'
)

QPD defines the query parameters sent by the requester, and QAK is the acknowledgment in the response. The query_tag in both segments matches them together, so the requester can correlate the response to the original request.

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.

QAK field reference

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

#Python nameDatatypeUsageRepeatableTable
1query_tagSTOptionalNo-
2query_response_statusIDOptionalNoHL70208
3message_query_nameCWEOptionalNoHL70471
4hit_count_totalNMOptionalNo-
5this_payloadNMOptionalNo-
6hits_remainingNMOptionalNo-

Ready to build integrations?

Get started with Zato and connect your systems in minutes.

Open source In Python