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:
- 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.
- How the merge history stays append-only when an unmerge adds attributions and a sign-off to it.
- 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.
- 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.
- 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).
- 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¶
- A merge moves and deletes nothing.
- The retired person keeps its row, with status
mergedand a link to the survivor. It also keeps its own identifier assignments in MOD-ADM-003 and its own current demographics. - 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. - The survivor's current demographics take the attribute groups the steward selected from the retired person (
AttributeGroups). - 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.
- 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).
- A No. RM of a facility gained by a merge answers
assignFacilityIdentifierfor the survivor, so no third one is issued. - Merge events are append-only in the database.
merge_eventrefuses update and delete with a trigger (part 11).- An unmerge is a new row with
reverses_merge_id, andreversedByMergeIdis read from it. - The attribution of post-merge records and the Head of HIM's sign-off are kept beside the event, in
unmerge_attributionandunmerge_sign_off. An unmerge's version counts its attributions and its sign-off. - The unmerge work item (
unmerge_request, a D10 taskadm.unmerge-request) is either requested by any role or opened by the unmerge itself. It closes at the sign-off. - The index keeps what it needs of encounters and appointments from their events.
known_encounterandknown_appointmentare kept fromhis.adm.encounter.v1(adm-patient-administration) andhis.adm.appointment.v1(adm-scheduling-flow). They hold whom a record names, its state and when it was created.- An event older than what is known changes nothing, so redelivery is harmless.
- The records themselves stay with their units. An attribution is a call to
correctEncounterwith 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. - An appointment cannot be attributed until
scheduling.v1offers a patient correction. It stays pending, so the sign-off waits for it. - D10 owns the tasks; the unit follows them.
- 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. - 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.
- Escalation is D10's: the task's due time follows CFG-ADM-006, and the task type's escalation policy
adm.identity-review-escalationapplies. - The unit follows state, assignee and escalation from TaskStateChanged (
his.ess.task.v1) for the report. An item past its threshold is counted asoverThresholdfrom its own due time. reportIdentityWorkItemanswers 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.- Policy actions and obligations:
- Merge authority is the action
mergeonadm.Merge, a privilege distinct fromupdateonadm.IdentityMatch, which resolves an item. - The Head of HIM's actions are
unmerge(the unmerge) andapprove(its sign-off). - The steward's attribution is
updateonadm.Merge. - Cross-reference and demographics query are the actions
cross-referenceanddemographics-queryonadm.Patient, each a scope of its own. - What an answer may carry is limited by obligations:
restrict-authorities(withsystems),disclose-enterprise-id, and the existingmask,redactandelevated-audit. Withoutdisclose-enterprise-idthe enterprise identifier is left out, as part 6.1 requires. - The purpose of use is required for both queries.
- The demographics query answers only the high-confidence band. The contract asks for no candidates below the match threshold, and minimum necessary applies.
- 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.
- The sign step and the second person are verified from the identity service's tokens (review round 1). The token profile of
contracts/essREADME givesacr(aal2 after a second factor) andauth_time, and the step-up window is 5 minutes. - 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'sacralso goes to the decision point assubjectAssurance. The executor's ownsignatureIdstays a recorded reference. - The second person (CUX-64, "authenticated in place"). Their
secondApproval.signatureIdis the access token of their own step-up, taken on the executor's screen. The unit validates it like any bearer token of realmhis:- signature, issuer and expiry;
- a human, the approver named, and not the executor;
- aal2 within the window;
- used once (
step_up_use).
- The second person's authority. The decision point is asked for the second person: action
mergeonadm.Merge, withapprovalRole: second-approverand the executor asrequesterId. A refusal is a 403, audited as adm.identity.merge, and nothing is merged. - What is recorded. The merge records the verified person, the time of their authentication and
step-up:<token id>, never the token. - Why this way. It needs no new operation, and no D10 verification service, which does not exist. When IF-ESS-002 offers one,
StepUpis 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
acrandauth_timein its tokens, as the token profile says. The realmhisand 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-requestandadm.unmerge-requestwith the escalation policy. - The two event subscriptions make adm-identity a consumer of
his.adm.encounter.v1,his.adm.appointment.v1andhis.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(warnordefer) carries the configured policy of WF-ADM-002, which registration and HIM governance confirm.