HL7 QCN_J01 Cancel Query

HL7 message structure QCN_J01 groups and segments from HL7 v2.5.1 Hide structure

These are the generated groups and segments for the version selected at the top of the page. The article explains the workflow, and this panel follows the chosen HL7 version.

Message Structure

SegmentNameRequiredRepeatable
Message Header Yes No
Software Segment No Yes
Query Identification Yes No

QCN_J01 cancels an active query. It is most useful when a responder returned a continuation pointer and the requester decides it does not want any more increments. The cancellation lets the responder discard queued result state instead of waiting for it to expire.

This is a small message, but it is operationally important. Without a cancel path, long-running or interactive queries can leave the responder holding data, locks, cache entries, or audit state that nobody will ever ask for again.

A small QCN J01 example

MSH|^~\&|PORTAL|CITYHOSP|MPI|CITYHOSP|20260717112000||QCN^J01^QCN_J01|QCNJ010001|P|2.5.1 QID|Q220001|Q22^Find Candidates^HL7nnn

What workflow it represents

The requester sends QCN_J01 after it has enough data, the user closes the search, or the workflow no longer needs further increments. The receiver should acknowledge the cancel with an ACK and release any state associated with that query if it still has it.

The cancel is best effort in many implementations. If the responder already finished or expired the continuation state, the ACK should make that clear rather than causing the requester to retry forever.

How to read the structure

MSH identifies the cancel as QCN^J01^QCN_J01. Optional SFT can identify software. QID is required and tells the receiver which query to cancel.

QID-1 should echo the query tag, usually the value originally sent in QPD-2 or returned in QAK-1. QID-2 identifies the query name, usually the value from QPD-1. Together they are much safer than patient or account identifiers alone.

Implementation traps

Do not cancel by patient. A user can have several outstanding queries for the same patient, and canceling the wrong one can produce missing data that looks random.

Also do not treat a missing cancel as a fatal protocol error unless the profile requires it. Many old systems rely on responder-side timeout. QCN_J01 is still worth supporting because it makes interactive continuation cleaner and friendlier to the responder.

Reference notes

HL7 Chapter 5 describes QCN/ACK as the cancel query message and notes that the initiating system may explicitly terminate a query by sending QCN_J01. IHE patient demographics profiles use QCN_J01 the same way when a consumer does not want more incremental response data.