Data and states
What changes to medication order must apply jointly, and what remains protected after completion?
The contracts require a authoritative datastore for medication order M-26. The prescription revision identifies content, the aggregate version protects workflow state, and the documentation event records a reported action. A scan alone proves neither the actual action nor clinical suitability. The state is stored together with its command result; this keeps the same change task visible after restart. Dispensing record A-26 records the confirmed dispensing event and its reference to the verified prescription revision.
Starting point Dispensing requires the revision and verification evidence.
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.
Authoritative data and permitted state transitions
Revision, status of processing and action
The prescription revision identifies content, the aggregate version protects workflow state, and the documentation event records a reported action.
Domain entities and relationships
| Entity | Authoritative attributes | Relationship |
|---|---|---|
| Medication order | M-26; ownership and aggregate version | Contains exactly one currently valid prescription revision. |
| Prescription revision | R-26; immutable prescription content | A new revision requires verification of that revision. |
| Evidence of verification and dispensing | Revision, acting professional, time | Verification and dispensing are separate records for the same revision. |
| Documentation event | D-26; actual action or omission | References the order and dispensing record; corrections are appended separately with a traceable history. |
Medication order
- Authoritative attributes
- M-26; ownership and aggregate version
- Relationship
- Contains exactly one currently valid prescription revision.
Prescription revision
- Authoritative attributes
- R-26; immutable prescription content
- Relationship
- A new revision requires verification of that revision.
Evidence of verification and dispensing
- Authoritative attributes
- Revision, acting professional, time
- Relationship
- Verification and dispensing are separate records for the same revision.
Documentation event
- Authoritative attributes
- D-26; actual action or omission
- Relationship
- References the order and dispensing record; corrections are appended separately with a traceable history.
Permitted state transitions
| Starting point | Target | Precondition |
|---|---|---|
| Verified | entwurf | New prescription revision before issuance; previous verification record only applies historically. |
| entwurf | Verified | Verifying professional confirms exactly the current prescription revision. |
| Verified | ausgegeben | The dispensing professional confirms the same verified revision. |
| entwurf or geprüft | storniert | Prescriber cancels before dispensing. |
| ausgegeben | dokumentiert | Actual action or justified omission shall be documented. |
| ausgegeben | klärfall | A change request after dispensing requires domain review and evidence of the actual outcome before completion. |
| klärfall | dokumentiert | The actual outcome is evidenced and domain review is confirmed. |
| dokumentiert or storniert | terminal | New dispensing is blocked; corrections use a separate traceable revision. |
Verified
- Target
- entwurf
- Precondition
- New prescription revision before issuance; previous verification record only applies historically.
entwurf
- Target
- Verified
- Precondition
- Verifying professional confirms exactly the current prescription revision.
Verified
- Target
- ausgegeben
- Precondition
- The dispensing professional confirms the same verified revision.
entwurf or geprüft
- Target
- storniert
- Precondition
- Prescriber cancels before dispensing.
ausgegeben
- Target
- dokumentiert
- Precondition
- Actual action or justified omission shall be documented.
ausgegeben
- Target
- klärfall
- Precondition
- A change request after dispensing requires domain review and evidence of the actual outcome before completion.
klärfall
- Target
- dokumentiert
- Precondition
- The actual outcome is evidenced and domain review is confirmed.
dokumentiert or storniert
- Target
- terminal
- Precondition
- New dispensing is blocked; corrections use a separate traceable revision.
Atomic changes and versions
- Content reference
- The prescription revision identifies content, the aggregate version protects workflow state, and the documentation event records a reported action. A scan alone proves neither the actual action nor clinical suitability.
- Shared commit
- Medication Documentation API reviews order, current prescription revision, review document, dispensing event and writes domain change, command result and, if applicable, pending work in a transaction. Commit means that these changes become permanently visible together. Before commit, a rollback ends the attempt without partial effect.
- Concurrency
- Change and dispensing both expect version 7. If the change wins, dispensing loses the old approval. If dispensing wins, the change is rejected and, after a fresh read, handled as an investigation case; dispensing that already occurred remains recorded.
- Terminal completion
- In dokumentiert and storniert, new dispensing creates a conflict. Cancellation does not retroactively undo an action already documented.
Cover the full scope of the case
- Concrete rule
- A investigation case ends only when the documenting professional proves the actual outcome and the prescribing professional confirms the clarification in the appropriate procedure. The platform operations has no substitute authorization for this.
Derive storage needs from access patterns
- Authoritative relational datastore
- Contains exactly one currently valid prescription revision. A new revision requires verification of that revision. The draft therefore selects a relational metadata store with uniqueness constraints and short transactions. Historical versions remain referenceable; a rebuildable read model must not overwrite the authoritative state.
- Large content and measurement series
- Derived views and extensive measurement or event histories are read separately according to their access patterns. Binding state decisions remain in the authoritative datastore.
The actual action retains its own evidence
The actual action retains its own evidence.
Change and dispensing both expect version 7. If the change wins, dispensing loses the old approval. If dispensing wins, the change is rejected and, after a fresh read, handled as an investigation case; dispensing that already occurred remains recorded.
In dokumentiert and storniert, new dispensing creates a conflict. Cancellation does not retroactively undo an action already documented. The exercise specifies the input and expected result.
- Alternative considered
- Separate unversioned changes allow an older state to overwrite the newer one.
- Trade-off
- Changes to medication order M-26 are briefly serialized.
- Reassess
- Measurable waiting times for two specialists to process the same order in a revision justify a check of the transaction duration.
Try it yourself
Explain the two possible winner orders in the case contract. Also determine the behaviour after terminal completion.
A hint for your attempt
Content revision and aggregate version have different tasks.
Compare with a possible solution
- Concurrency
- Change and dispensing both expect version 7. If the change wins, dispensing loses the old approval. If dispensing wins, the change is rejected and, after a fresh read, handled as an investigation case; dispensing that already occurred remains recorded.
- Completion
- In dokumentiert and storniert, new dispensing creates a conflict. Cancellation does not retroactively undo an action already documented.
Apply to your project
Which states must remain protected in your model against late replay?