System Design Atlas

Hospital medication orders

04 / 10Worked example

Interfaces

How does the contract for “confirm dispensing” distinguish a repetition from a new intention?

The load profile meets the specific change request “confirm dispensing”. Its content consists of order, current prescription revision, verification record, dispensing event. An idempotency key detects the same intention after a loss of response; an aggregate version protects the changed business state. The examination document P-26 documents the examination of the specifically bound prescription revision.

Starting point Test concurrency on an individual order.

Assumptions for the example case

Own fictitious example design. A fictional documentation workflow for a single medication order whose clinical decisions have already been made, without recommendations on substances, doses or treatment. Technical feedback is marked for clarification from age 60 seconds onwards; this threshold does not provide medical clearance. All figures and test goals are illustrative assumptions.

Commands, retries and current state

Command and historical result

CommandOrder M-26 · Prescription revision R-26 · Verification record P-26
Command → Medikationsdokumentation-APICheck content and expected version
Medication documentation APIAccept the command or recognise a replay
Medikationsdokumentation-API → ErgebnisjournalCommit the result before responding
Result journalFingerprint + stored record
identicalHistorical result
ModifiedConflict without effect
Response lossReplay after commit

The key binds the full content; identical repetition provides the stored receipt.

Confirm dispensing binds order, current prescription revision, verification record, dispensing event. Same key points back to saved result; altered content branches to conflict.

Proposed API for this example

  1. POST/medikationsauftrag/{id}/commands

    Confirm dispensing

    Input
    Order, current prescription revision, verification record, dispensing event; expected aggregate version, authorized role and stable command key.
    Result
    Durably stored business result and new version; version or content conflicts produce no partial effects. An accepted external request receives an open status.
    Retry behaviour
    The key is scoped to the actor, operation and business object. After authentication, first compare the existing result and canonical content: identical content returns the stored evidence; changed content produces a conflict. Only new keys trigger validation of the current version.
  2. GET/medikationsauftrag/{id}

    Read the current business state and reason for investigation.

    Input
    Authorised identity and business object.
    Result
    Medication order with its current version, evidence and reason for any unresolved work.
    Retry behaviour
    Repeating a read creates no business change; access is checked again.

Additional state changes

OperationInputResult and protection
Amend the prescriptionPrescriber, current version, new content revisionBefore dispensing, return to draft and invalidate the old verification; after dispensing, open an investigation case.
Confirm verificationVerifying professional and the exact current prescription revisionDraft → reviewed; no global clearance for later revisions.
Documentation of the actionDocumenting professional, dispensing record, actual outcome and timeDispensed or resolved investigation case → documented; an omitted action remains explicitly recorded.
Cancel a work orderPrescriber, version, reasonBefore dispensing → cancelled; afterwards, an investigation case with the dispensing record preserved.

Amend the prescription

Input
Prescriber, current version, new content revision
Result and protection
Before dispensing, return to draft and invalidate the old verification; after dispensing, open an investigation case.

Confirm verification

Input
Verifying professional and the exact current prescription revision
Result and protection
Draft → reviewed; no global clearance for later revisions.

Documentation of the action

Input
Documenting professional, dispensing record, actual outcome and time
Result and protection
Dispensed or resolved investigation case → documented; an omitted action remains explicitly recorded.

Cancel a work order

Input
Prescriber, version, reason
Result and protection
Before dispensing → cancelled; afterwards, an investigation case with the dispensing record preserved.

Messages across the external boundary

Source contract
FHIR distinguishes orders, dispensing and administration events. The state rules of this learning case are its own limited design and not a clinical work instruction.
System responsibility
Dispensing is recorded with verification evidence in a local transaction. The response is lost after commit. A retry returns the same dispensing record. A prescription change received in the meantime requires domain review after dispensing and must preserve that record.

Dispensing requires the revision and verification evidence

Dispensing requires the revision and verification evidence

Dispensing requires the revision and verification evidence.

Confirm dispensing can re-arrive after a lost response.

Order, current prescription revision, verification record, dispensing event must remain the same at Replay. The exercise specifies the input and expected result.

Alternative considered
A key stored only in volatile memory loses its evidence on restart.
Trade-off
The Journal for Confirm dispensing requires permanent retention and protected access.
Reassess
The documented retry window and journal volume determine the future archiving strategy.

Try it yourself

For identical repetition, predict the results of “confirm dispensing,” the same key with a different prescription revision, and a new key with an old version.

A hint for your attempt

Retry identity and current state require separate checks.

Compare with a possible solution
Identical
The saved result for medication order M-26 is returned; the effect is not repeated.
Changed
The same key with altered canonical content results in conflict.
New intent with a stale version
A new key with a stale version is rejected before any business change. The interface reloads the current state and asks the user to confirm the decision again.

Apply to your project

Which input fields make two change intentions different in your project?

Next: Actual action remains its own proof.