Reference·HL7 v2·QAK
HL7 v2 Reference

Testing HL7 v2 QAK: The Fields Your System Actually Needs to Handle

Jul 28, 2026 · 6 min read

QAK is the segment that tells a querying system whether it should expect data in the rest of the response, expect nothing, or expect trouble — and it is the segment most query test suites forget to vary, because the happy path where data always comes back is the easiest one to fake.

Quick answer

QAK is the Query Acknowledgment segment in HL7 v2. It shows up at the top of a response to a query message, such as a QBP, and tells the requesting system what happened on the other end: whether matching data was found, whether the query ran fine but turned up nothing, or whether something went wrong processing it. It also echoes back an identifying tag the requester attached to the original query, and names which query definition was actually answered.

The fields that actually matter in practice

QAK-1 →
Query Tag — an identifier the requesting system assigned to this particular query so it can match this response to the right outstanding request
QAK-2 →
Query Response Status — the outcome verdict for the query — whether data was found, none matched, or the receiving application couldn't process the request
QAK-3 →
Message Query Name — identifies which named query definition the receiving system actually executed, which matters most on systems that support several similar lookups

Example

Synthetic example Generated by Synthibase
QAK|Q1042|OK|Q11^EligibilityInquiryByPatient^SYNTHIB0001

A synthetic QAK segment for a successful eligibility lookup — the query tag, status, and query name are all fabricated for this example.

Where this trips people up

Most query test fixtures are built by capturing one real response and cloning it, which means every test case comes back with a QAK-2 of OK and a populated result set. That leaves NF and AE completely unexercised, so a querying system's empty-result handling and error-handling paths never get a real workout until a production query legitimately comes back empty or fails. The other recurring miss is treating QAK-1 as optional filler: if a test generator doesn't actually carry the query tag through from the original request into the response, a system running several queries in parallel has no reliable way to match responses back to the request that triggered them, and results start getting attributed to the wrong query.

EDI 999 vs 997: What's the Difference and Why It Matters
How to Write EDI Test Cases That Actually Catch Go-Live Failures
Generate query responses that cover every outcome, not just found
Synthibase produces synthetic query responses spanning found, not-found, and error outcomes with correctly threaded query tags, so your correlation and empty-result logic gets tested against every branch before go-live.
Start free trial →
This page is written independently by Synthibase for testing and informational purposes. It is not an official publication of HL7 International or X12/Washington Publishing Company, and is not a substitute for reviewing the official standard or your trading partner's companion guide. See our Terms of Service for full legal terms.