Skip to content

Architecture / Decision records / ADR-HIS-087

ADR-HIS-087 Merge and unmerge in adm-identity: nothing moved by a merge, append-only merge events, what the index knows of encounters and tasks, the policy scopes of stewardship and cross-reference, and step-up from the token

Status Accepted
Decided 2026-11-27 by session RC-3-S05
Record Drafted 2026-11-27; approved 2026-11-30 by the Enterprise Architecture Board
Where the rule lives services/adm-identity/mod-adm-001 (Merges, Stewardship, CrossReferences, merge/, activity/, review/), its migration V3__stewardship_and_merge.sql; mod-adm-003 IdentifierRegistry.setPreferred; services/adm-identity/README.md

Context

Slice RC-3 gives the unit adm-identity (ADR-HIS-053) the three requirements it still lacked: - identity stewardship work queues (FR-ADM-MPI-004); - reversible merge and unmerge (FR-ADM-MPI-005), a safety-critical function of D01-ADM 11.1 whose hazard is the loss or misattribution of history; - the cross-reference and demographics query services (FR-ADM-XRF-002).

The contract patient-identity.v1 1.2 and ADR-HIS-083 fix what is offered: a merge only through the resolution of a work item, and a post-merge encounter reattributed through correctEncounter. The specification and the contract leave these questions of build open:

  1. What a merge does to the rows of the two persons and of their identifiers, so that an unmerge gives back exactly what was there.
  2. How the merge history stays append-only when an unmerge adds attributions and a sign-off to it.
  3. How the unit knows of encounters and appointments, which other units own. It needs them for an item's priority (part 6.4), for the second approval (both records hold clinical activity, DEC-ADM-002), for the merge warning (WF-ADM-002), and for the records held at an unmerge.
  4. How the work items' assignment and escalation (parts 6.2, 6.5, PR-MPI-004-2) reach the report, when the D10 task service holds the tasks.
  5. Which policy actions carry merge authority, the Head of HIM's unmerge, and the separate scopes of cross-reference and demographics query (AC-04). Also, how an answer to an external consumer is limited to the authorities and elements it may receive (PR-XRF-002-2, part 6.5).
  6. How the sign step (FR-ADM-MPI-005 part 3) and the second person's authentication in place (part 7, CUX-64, DEC-ADM-002) are verified. Both reach the unit only in the executor's request.

Decision

  1. A merge moves and deletes nothing.
  2. The retired person keeps its row, with status merged and a link to the survivor. It also keeps its own identifier assignments in MOD-ADM-003 and its own current demographics.
  3. The survivor answers with its own identifiers followed by those of every person merged into it (PersonStore.identifiersOf, through the merge links). Searches, resolution, cross-reference and the blocking keys therefore see them under the survivor.
  4. The survivor's current demographics take the attribute groups the steward selected from the retired person (AttributeGroups).
  5. The merge event records what an unmerge needs to undo exactly:
    • the survivor's demographics before the merge;
    • which assignments were preferred before and after, where both persons hold an identifier of one authority and type (PR-MPI-005-1). The enterprise identifiers are excluded, because each stays its own person's.
  6. An unmerge clears the link and puts back the selected groups and the preferred flags. Each person then has again exactly its own identifiers (AC-02).
  7. A No. RM of a facility gained by a merge answers assignFacilityIdentifier for the survivor, so no third one is issued.
  8. Merge events are append-only in the database.
  9. merge_event refuses update and delete with a trigger (part 11).
  10. An unmerge is a new row with reverses_merge_id, and reversedByMergeId is read from it.
  11. The attribution of post-merge records and the Head of HIM's sign-off are kept beside the event, in unmerge_attribution and unmerge_sign_off. An unmerge's version counts its attributions and its sign-off.
  12. The unmerge work item (unmerge_request, a D10 task adm.unmerge-request) is either requested by any role or opened by the unmerge itself. It closes at the sign-off.
  13. The index keeps what it needs of encounters and appointments from their events.
  14. known_encounter and known_appointment are kept from his.adm.encounter.v1 (adm-patient-administration) and his.adm.appointment.v1 (adm-scheduling-flow). They hold whom a record names, its state and when it was created.
  15. An event older than what is known changes nothing, so redelivery is harmless.
  16. The records themselves stay with their units. An attribution is a call to correctEncounter with this unit's service identity, made before the attribution is recorded. If the encounter service is down, the request stops with what remains pending, and a repeat finishes it.
  17. An appointment cannot be attributed until scheduling.v1 offers a patient correction. It stays pending, so the sign-off waits for it.
  18. D10 owns the tasks; the unit follows them.
  19. A work item's task is created through the existing local queue (review_task_request), which now also carries the completion of a task when its item is resolved.
  20. A completion names the task it closes, or the creation it waits for, so it never closes a later task of the same item. A deferred item that returns at its review date gets a new task.
  21. Escalation is D10's: the task's due time follows CFG-ADM-006, and the task type's escalation policy adm.identity-review-escalation applies.
  22. The unit follows state, assignee and escalation from TaskStateChanged (his.ess.task.v1) for the report. An item past its threshold is counted as overThreshold from its own due time.
  23. reportIdentityWorkItem answers the task it made. While the task service is down, the item is kept and the answer is 503, and a repeat with the same key answers it.
  24. Policy actions and obligations:
  25. Merge authority is the action merge on adm.Merge, a privilege distinct from update on adm.IdentityMatch, which resolves an item.
  26. The Head of HIM's actions are unmerge (the unmerge) and approve (its sign-off).
  27. The steward's attribution is update on adm.Merge.
  28. Cross-reference and demographics query are the actions cross-reference and demographics-query on adm.Patient, each a scope of its own.
  29. What an answer may carry is limited by obligations: restrict-authorities (with systems), disclose-enterprise-id, and the existing mask, redact and elevated-audit. Without disclose-enterprise-id the enterprise identifier is left out, as part 6.1 requires.
  30. The purpose of use is required for both queries.
  31. The demographics query answers only the high-confidence band. The contract asks for no candidates below the match threshold, and minimum necessary applies.
  32. Authorization comes before existence. The reads and commands on merges, unmerges and work items ask the decision point first. A caller who may not see a merge, a post-merge record, a match or a person is refused the same whether it exists or not.
  33. The sign step and the second person are verified from the identity service's tokens (review round 1). The token profile of contracts/ess README gives acr (aal2 after a second factor) and auth_time, and the step-up window is 5 minutes.
  34. The executor's session. A merge, an unmerge and a sign-off need a session stepped up within the window (StepUp.requireCaller). Otherwise they are refused with 403. The session's acr also goes to the decision point as subjectAssurance. The executor's own signatureId stays a recorded reference.
  35. The second person (CUX-64, "authenticated in place"). Their secondApproval.signatureId is the access token of their own step-up, taken on the executor's screen. The unit validates it like any bearer token of realm his:
    • signature, issuer and expiry;
    • a human, the approver named, and not the executor;
    • aal2 within the window;
    • used once (step_up_use).
  36. The second person's authority. The decision point is asked for the second person: action merge on adm.Merge, with approvalRole: second-approver and the executor as requesterId. A refusal is a 403, audited as adm.identity.merge, and nothing is merged.
  37. What is recorded. The merge records the verified person, the time of their authentication and step-up:<token id>, never the token.
  38. Why this way. It needs no new operation, and no D10 verification service, which does not exist. When IF-ESS-002 offers one, StepUp is the one class to change.

Consequences

  • A merge is reversible by construction: no identifier, demographic value or row is rewritten. TEST-ADM-005 compares both persons before the merge and after the unmerge, identifiers, demographics and authorship included.
  • Reading a survivor follows its merge links (a recursive query, at most 16 hops, as for resolution). A survivor with many merges reads more rows.
  • The identity service must issue acr and auth_time in its tokens, as the token profile says. The realm his and the RC-3 scenario use stepped-up tokens for the stewards' merges, the Head of HIM's unmerges and sign-offs, and the second person's approval.
  • RC-1-S16 registers the actions and obligations of point 5 in the D10 policy, with merge authority recertified (SEC-004). RC-1-S15 registers the task types adm.merge-request and adm.unmerge-request with the escalation policy.
  • The two event subscriptions make adm-identity a consumer of his.adm.encounter.v1, his.adm.appointment.v1 and his.ess.task.v1. The D02 topic register lists it.
  • An open encounter on either record of a merge is a warning by default. The setting his.adm.merge.open-encounter-policy (warn or defer) carries the configured policy of WF-ADM-002, which registration and HIM governance confirm.