NEWFree ROI Calculators — quantify what prior auth and siloed data are costing your organization.Prior Auth ROI Siloed Data ROI
HL7 v2Message11 min read

HL7 RSP Messages: Segment Pattern Response

HL7 RSP messages return the results of a conformance-based query — the record that a query was received, understood, and answered, and the segment rows that carry the matching data. An RSP message is sent in reply to a QBP query by parameter, typically through a QBP^Q11 / RSP^K11 pair, and is sent from the server that holds the data back to the system that asked for it. This page explains what an RSP message represents, the trigger event that carries it, every segment the message can contain and what each one holds, and how an RSP response relates to FHIR. Sample content is constructed for illustration with fictional identifiers.

What an RSP message represents

An RSP message — RSP stands for Segment Pattern Response — communicates that a query server has processed a conformance-based query and is returning matching data. The RSP is the generic response vehicle in HL7's conformance-based query framework: rather than defining a rigid fixed segment structure for each query type, it carries a free-form segment pattern whose contents are specified by the query profile. The same RSP message structure can therefore return patient demographics, visit information, results, or any other segment arrangement that a given query profile defines.

The sender is the data-holding system — most often a master patient index, an ADT server, or a clinical data repository — and the receiver is the querying application that submitted the original request. RSP sits one step downstream of the query: a QBP query by parameter tells the server what data to find, and the RSP message reports what matched. Because the RSP carries a query acknowledgement in QAK before the data rows, every RSP message is self-describing about whether data was found, not found, or an error occurred — even a zero-hit response carries enough information for the querier to act without inspecting the row group.

When an RSP message is sent

An RSP message is sent immediately after a conformance-based query is received and processed. A single query produces a single RSP, but that RSP can carry multiple row groups — one per matching record — and can include a DSC continuation pointer when the result set is too large to return in one response, directing the querier to send a continuation request for the next page.

Trigger event

The RSP message type is paired with a trigger event that mirrors the query it answers:

  • RSP^K11 — Segment pattern response, returned in reply to a QBP^Q11 query by parameter.

The trigger code K11 in MSH-9 tells the receiver this is a generic segment pattern response, and the query tag in QAK and the echoed parameters in QPD identify exactly which query this response answers.

Integration topology

The diagram shows the querying application sending a QBP query through the integration engine and receiving an RSP response from the data-holding server.

{{diagram: querying application → QBP^Q11 query → integration engine → data server → RSP^K11 response → integration engine → querying application}}

Typical senders: master patient index, ADT server, clinical data repository, health information exchange.

Typical receivers: registration system, clinical workstation, EHR, scheduling application, or any system that submitted a conformance-based query.

Direction: request-response — the querying application initiates with a QBP message, and the data-holding server replies with the RSP.

Segments in an RSP message

The RSP_K11 message opens with a fixed header group (MSH, MSA, optional ERR segments), a query acknowledgement in QAK, and the echoed query parameters in QPD. The variable portion is the repeating ROW_RESPONSE group, whose internal segment pattern is defined entirely by the query profile — a patient demographics query might place PID and PV1 inside each row group, while a different profile might carry results or scheduling data. The message closes with an optional DSC continuation pointer. Cardinality follows HL7 notation: [X] optional, {X} repeating, [{X}] optional and repeating; a bare code is required. Each segment code links to its canonical field-by-field reference.

SegmentDescription
MSHMessage Header. Opens every RSP message. It names the sending and receiving applications and facilities, stamps the creation time, declares the trigger event in MSH-9 (RSP^K11), carries the message control id in MSH-10, and pins the HL7 version. Receivers route on MSH-9 and deduplicate on MSH-10.
MSAMessage Acknowledgement. Acknowledges receipt of the originating QBP query at the transport level. Carries the acknowledgement code (AA, AE, or AR) in MSA-1 and the message control id of the original query in MSA-2, so the querier can correlate the response to its request.
[{ERR}]Error. Carries structured error detail when the MSA acknowledgement code indicates an error condition. Optional and repeating — multiple ERR segments can describe multiple error conditions in a single response.
QAKQuery Acknowledgement. The routing hub of the RSP message. QAK-1 echoes the query tag from the original request, providing a correlation handle. QAK-2 carries the response status: OK (data found), NF (not found — the query was valid but matched no records), AE (application error), or AR (application reject). QAK-3 carries the message query name that identifies the query profile, and QAK-4 optionally reports the total hit count. Downstream systems key on QAK-2 to decide whether to process the row group, log a not-found condition, or raise an error.
QPDQuery Parameter Definition. Echoes back the query parameters exactly as the querier submitted them in the originating QBP message. QPD-1 names the query profile, and QPD-3 and beyond carry the individual query fields in the order the profile defines. The QPD echo allows the querier to confirm which parameters produced this response and supports stateless continuation across paged queries.
[{ROW_RESPONSE}]Row Response Group. Repeating group that holds one matched record per iteration. The internal segment pattern is entirely defined by the query profile declared in QAK-3 and QPD-1. For a patient demographics query (e.g. ITI-21 PDQ), each iteration typically contains a PID and optionally a PV1; another query profile might carry results, scheduling, or financial segments. When QAK-2 is NF, the ROW_RESPONSE group is absent.
[DSC]Continuation Pointer. Present when the result set was too large to return in a single RSP and more rows remain. DSC-1 carries an opaque continuation pointer value, and DSC-2 carries I (interactive continuation). The querier submits a follow-on QBP request containing the continuation pointer to retrieve the next page. Absent when the full result set fits in a single response.

[ ] = optional, { } = repeating

The ROW_RESPONSE group repeats once per matched record, so a single RSP message can return an entire result set in one transmission. When the result set is paginated, the DSC continuation pointer links the pages. The canonical segment pages carry the full field-by-field detail.

Sample RSP message

Note. Constructed for illustration. Patient identifiers, query tags, dates, and names are fictional.

MSH|^~&|MPI|MERCYGEN|EHR|MERCYGEN|20260604093000||RSP^K11^RSP_K11|MSG00087|P|2.5.1
MSA|AA|QRY00042
QAK|QRY00042|OK|Q22^Find Candidates^HL7|1
QPD|Q22^Find Candidates^HL7|QRY00042|DOE^JANE^^^||19750315|F
PID|1||MPI98765^^^MERCYGEN^MR~SS123456789^^^SSA^SS||DOE^JANE^M||19750315|F|||123 MAIN ST^^SPRINGFIELD^IL^62701^USA
PV1|1|O|OUTPT^OC1^01^MERCYGEN||||PROV01^SMITH^CAROL^^^^MD
DSC||

What this sample shows

The RSP^K11 in MSH-9 marks a segment pattern response. MSA acknowledges the originating query QRY00042 with AA. QAK echoes the query tag QRY00042, reports status OK (data found), identifies the query profile Q22 Find Candidates, and states that one record matched. QPD echoes the search parameters — surname DOE, given name JANE, date of birth 19750315, sex F — confirming which input produced this response. The ROW_RESPONSE group contains a single iteration: PID carries the patient identifier list with a medical record number and social security number, the name, date of birth, sex, and address; PV1 carries the current outpatient location and attending provider. The DSC is present but empty, indicating no continuation is needed.

Working with RSP messages

Route on QAK-2, not on MSA

The MSA acknowledgement code reflects transport-level success or failure. The application-level result is in QAK QAK-2: an AA in MSA-1 combined with NF in QAK-2 means the query succeeded but returned no data — that is a valid business outcome, not an error. Build your routing logic on QAK-2 and treat OK, NF, AE, and AR as four distinct conditions rather than collapsing them.

Idempotency and deduplication

Use MSH-10, the message control id, as the deduplication key, and use the query tag in QAK-1 as the correlation handle that ties a response to its original request. Query feeds can be replayed after outages; treating a repeated control id as a duplicate prevents a replayed response from inserting duplicate records or overwriting a more recent version of the same patient row.

Handling paged responses

When DSC is present with a non-empty continuation pointer in DSC-1, the result set is incomplete. Submit a follow-on QBP request with the continuation pointer to retrieve the next page, and continue until a DSC is absent or carries an empty pointer. Sequence the pages by their continuation pointer rather than arrival order, and merge the row groups in order before committing the result.

Know the query profile

The segment pattern inside ROW_RESPONSE is defined entirely by the query profile named in QAK-3 and QPD-1. An RSP carrying Q22 Find Candidates has a different internal structure from one carrying a locally defined profile. Confirm the expected segment pattern against the query profile specification — do not assume a fixed structure from the MSH and QAK alone.

Vendor variance. Some systems populate PV1 in the ROW_RESPONSE group only when the patient has an active visit; others always include an empty PV1. Confirm a partner's field usage and optional-segment behaviour against their interface specification rather than assuming the base standard.

FHIR equivalent

A query response corresponds conceptually to a FHIR Bundle of type searchset, where each matched record is an entry in the Bundle containing the FHIR resources appropriate to the query — for a patient demographics query, a Patient resource per matched record; for a visit query, an Encounter resource; and so on. A MessageHeader at the head of the Bundle represents the messaging envelope.

There is, however, no published mapping to lean on. The HL7 v2-to-FHIR Implementation Guide provides no message map for RSP_K11 — the RSP is a generic container whose content varies by query profile, and no single FHIR ConceptMap can cover the full range of possible row group structures. A FHIR Bundle produced from an RSP message is therefore mapped manually, taking the query status from QAK, the echoed parameters from QPD, and the row content from the profile-specific segments in each ROW_RESPONSE iteration.

Common pitfalls

Pitfall. Assuming data is present when MSA is AA. An AA acknowledgement confirms the query was received and processed — it does not mean records were found. Check QAK-2 for OK before attempting to parse the ROW_RESPONSE group; an NF response has no row group to parse.

Pitfall. Ignoring the continuation pointer. An RSP without a DSC continuation pointer is not necessarily the complete result set — some servers also signal end-of-data through QAK-4 hit count. Implement paging logic that handles both a missing DSC and an explicit end-of-data signal.

Pitfall. Hardcoding the ROW_RESPONSE segment pattern. The segments inside ROW_RESPONSE are defined by the query profile, not by the RSP message type itself. A system that hardcodes a PID+PV1 assumption will silently drop data when a different query profile is in use.

How Vorro handles RSP messages

Vorro receives the RSP over MLLP or another transport, deduplicates on MSH-10, and correlates each response to its originating query using the tag in QAK-1. Vorro reads QAK-2 to classify the response — routing OK responses to the data pipeline, logging NF responses as valid not-found outcomes, and raising alerts on AE and AR — then parses the ROW_RESPONSE group according to the query profile identified in QAK-3. Where paging applies, Vorro manages the continuation loop autonomously, reassembling the full result set before delivering it downstream. Where a FHIR destination is configured, Vorro maps the response rows to a Bundle searchset — composed manually, since the v2-to-FHIR Implementation Guide publishes no map for this message.

  • QBP — the query by parameter message that an RSP message answers.
  • RTB — the tabular response, an alternative to RSP when the query profile returns data in a fixed column structure.
  • QRY — the original v2 query message, superseded by QBP in the conformance-based query framework.

Sources

← Back to HL7 v2 Guide

Ready to Integrate This Into Your Workflow?

Talk to a Vorro expert about implementing HL7 v2 in your specific environment.

Browse HL7 v2 Guides
HL7 RSP Messages: Segment Pattern Response | Vorro Academy | Vorro