Reference·QPD Segment·QPD-2
HL7 v2 Reference

QPD-2 in HL7 v2: A Field Guide to Query Tag

Jul 28, 2026 · 4 min read
← QPD-1 QPD-3 →

QPD-2 is the requester's own bookkeeping value, separate from the message control ID, and it is the field that makes it possible to tell which response answers which of several queries in flight at once.

Quick answer

QPD-2 is the Query Tag field. The system sending a query assigns it freely, and it exists so that once a response comes back — carrying the same tag in the corresponding QAK segment — the requester can match that response to this specific outbound query, independent of the message control ID and independent of whatever else may be in flight at the same time.

What this field contains

Format
String, requester-defined — no fixed structure is imposed — the requesting system just needs a value it can recognize later
Scope
Unique per outstanding query — matters most when a requester can have multiple queries in flight simultaneously and needs to tell their responses apart
Common failure
Reused or omitted tags — a blank or duplicated query tag makes it impossible to reliably pair a response with the request that triggered it

Example

Synthetic example Generated by Synthibase
QPD|Q22^Find Candidates^HL70471|SYNTHIBQ00019|9284471^^^SYNTHIBMRN^MR

QPD-2 (SYNTHIBQ00019) is a fabricated query tag standing in for the value a requesting system would assign to this synthetic query.

Where this trips people up

It's easy to build a test harness that generates a fresh, effectively random query tag for every message without checking that the responding side's QAK actually echoes it back, since a single query fired in isolation looks correct either way. The gap only shows up once a test scenario fires several queries close together, at which point response-matching logic that was never really tested against concurrent queries starts pairing answers with the wrong requests, or failing to pair them at all.

HL7 v2 QPD Segment Guide: Fields, Format, and Testing Gotchas
HL7 ADT Messages: A01 through A08 Explained
How to Write EDI Test Cases That Actually Catch Go-Live Failures
Test concurrent queries, not just one at a time
Synthibase generates synthetic query sets with distinct, correctly threaded query tags across multiple in-flight requests, so your response-matching logic gets tested the way production concurrency actually stresses it.
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.