HL7 RSP_K31 Dispense History Response
RSP_K31 is a dispense history response. It is the answer side of a pharmacy query where the requester needs historical dispense details for a patient, medication, or pharmacy workflow. Compared with simple query responses, it carries a full patient/order/pharmacy shape.
The message can be dense because dispense history has to connect patient identity, order identifiers, timing, medication details, route, actual dispense information, components, and optional observations. That is exactly why it deserves a careful implementation guide rather than a quick "response with RXD" note.
A small RSP K31 example
What workflow it represents
A requester asks for pharmacy dispense history and the pharmacy or medication record system returns one or more response groups. The requester may use it for medication reconciliation, clinical review, refill support, audit, or a downstream medication history display.
This is not the same as an order message. An order says what was requested or authorized. RSP_K31 is about the response to a query for dispense history, so the important question is what the pharmacy says actually happened.
How to read the structure
The top of the message combines response control and query correlation: MSH, MSA, optional ERR, QAK, QPD, and RCP. Those segments tell the requester what query was answered and whether the answer is complete or limited.
Each response contains an optional patient group with PID, optional PD1, notes, allergies, and visit details. The required order group starts with ORC and can include timing, order detail, encoded order, dispense, route, component, and observation information.
Pharmacy detail that receivers care about
RXD is the practical center of dispense history. It carries the dispensed drug, dispense date/time, quantity, units, dispense number, and related dispense details. RXR gives route, which matters when a medication name alone is not enough. RXC can describe components when the product is compound or needs component-level detail.
Optional OBX segments are useful for status, clinical notes, adherence indicators, or local facts that do not fit cleanly in the RX segments. Use them carefully and code OBX-3 well, because pharmacy history quickly becomes hard to reconcile when every site invents different observation names.
Implementation traps
Do not collapse order identifiers and dispense identifiers into one local field. ORC placer and filler IDs, RXD dispense numbers, and pharmacy transaction IDs answer different questions during reconciliation and support calls.
Also be clear about what counts as "history." Some responders return only completed dispenses. Others include partial fills, canceled fills, transferred prescriptions, or administrations. QAK may say the query worked while the business meaning still differs from what the requester expected.
Reference notes
The HL7 v2+ refactored RSP_K31 structure shows a required repeating response group with optional patient details and required pharmacy order detail, including ORC, timing, RXO/RXE/RXD, RXR, RXC, OBX, and DSC for continuation.