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.
from zato.hl7v2 import QAK
qak = QAK()
qak.query_tag = 'Q0042'
qak.query_response_status = 'OK'
qak.hit_count_total = '15'How to construct and work with real-world QAK segments.
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'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'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'
)Step-by-step guides for working with HL7 v2 in Zato.
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.
Complete list of fields in the QAK segment, HL7 v2.9.
| # | Python name | Datatype | Usage | Repeatable | Table |
|---|---|---|---|---|---|
| 1 | query_tag | ST | Optional | No | - |
| 2 | query_response_status | ID | Optional | No | HL70208 |
| 3 | message_query_name | CWE | Optional | No | HL70471 |
| 4 | hit_count_total | NM | Optional | No | - |
| 5 | this_payload | NM | Optional | No | - |
| 6 | hits_remaining | NM | Optional | No | - |
Get started with Zato and connect your systems in minutes.