Reference·HL7 v2·QPD
HL7 v2 Reference

HL7 v2 QPD Segment Guide: Fields, Format, and Testing Gotchas

Jul 28, 2026 · 6 min read

QPD is where a query message actually says what it wants — everything else in a QBP is routing and formatting, but QPD is the segment carrying the patient identifier or search criteria the requester is trying to find, and it is the segment most test suites populate with exactly one hardcoded example.

Quick answer

QPD (Query Parameter Definition) is the segment in HL7 v2 query messages, most often QBP, that specifies which predefined query is being invoked and supplies the actual parameter values being searched on. It names the query by ID in QPD-1, carries a requester-assigned tag in QPD-2 so the eventual response can be matched back to this specific request, and holds the search parameters themselves — such as a patient identifier — starting in QPD-3. The exact shape of QPD-3 and beyond depends entirely on which query is named in QPD-1, since each defined query specifies its own parameter list.

The fields that actually matter in practice

QPD-1 →
Message Query Name — identifies which defined query this message is invoking, such as a patient demographic lookup, and effectively determines how every later field in QPD should be interpreted
QPD-2 →
Query Tag — a requester-assigned identifier that has nothing to do with the message control ID — it exists purely so the response, via QAK, can be matched back to this exact query
QPD-3 →
User Parameters — the first and usually primary search value, commonly a patient identifier, though its structure and the fields that follow it vary by which query QPD-1 names

Example

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

A synthetic QPD segment for a patient demographic query, with a fabricated query tag and a made-up medical record number used as the search parameter.

Where this trips people up

A lot of generated test messages hardcode a single query type and never vary QPD-1, so parsing logic that is supposed to branch on which query is running only ever gets exercised against one code path — the moment a second query type shows up in production, the field-mapping assumptions baked in for the first one quietly misapply to the second. The other frequent miss is treating QPD-2 as disposable: if a test generator invents a fresh query tag on the response side instead of echoing the value the requester sent, correlation between the outbound query and the inbound QAK/response pair breaks in a way that looks fine until something tries to match them programmatically.

HL7 ADT Messages: A01 through A08 Explained
How to Write EDI Test Cases That Actually Catch Go-Live Failures
Generate query messages with parameters that actually vary
Synthibase produces synthetic QBP/QPD messages across multiple query types and search parameters, so the branching logic in your query handler gets tested against more than one hardcoded lookup.
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.