Architecture / Decision records / ADR-HIS-057
ADR-HIS-057 The patient administration unit: its calls to adm-identity, demographic versions, field sets, source trust and the CIN¶
| Status | Accepted |
| Decided | 2026-11-25 by session RC-1-S09 |
| Record | Drafted 2026-11-25; approved 2026-11-25 by the Enterprise Architecture Board; amended 2026-11-25 (the "same person" review item, open as Q-S09-4), amendment approved 2026-11-25 by the Enterprise Architecture Board; amended 2026-11-26 (review items and the handoff through patient-identity.v1 1.1, answer A to Q-S09-4), amendment approved 2026-11-26 by the Enterprise Architecture Board |
| Where the rule lives | services/adm-patient-administration/ (its README.md; mod-adm-002/, mod-adm-004/, service-kit/.../client/) |
Context¶
RC-1-S09 builds services/adm-patient-administration with MOD-ADM-002 (registration and demographics) and MOD-ADM-004 (encounters). It serves registration.v1 and encounters.v1 (ADR-HIS-049) for FR-ADM-REG-001 to 003 and FR-ADM-ENC-001. The next sessions on this unit add MOD-ADM-005, 006, 009 and 010 to it.
The person index belongs to another unit, adm-identity (ADR-HIS-053). A registration therefore has to create or change a person over HTTP, and the specification and the contract leave these points open: - how a registration stays consistent with the person it creates in the other unit; - how the demographic versions are kept, and what "as at" a time means; - the D10 services the unit has no client for yet: the configuration of field sets (CFG-ADM-004), source trust (CFG-ADM-007) and the CIN format (CFG-ADM-008), the terminology service, the master data registries and the task service; - how the CIN is allocated.
Options considered¶
- Consistency with adm-identity.
- One distributed transaction: rejected, since units share no database and there is no transaction manager across them.
- An event-driven creation: rejected, since the clerk needs the person and the No. RM in the answer.
- Chosen: the calls to adm-identity come first, each with an Idempotency-Key derived from the request's own. Then one local transaction records the registration, its versions, audit and event. A request repeated after a failure finds the same person and the same No. RM.
- Demographic versions.
- Keep the current values and an audit trail: rejected, since BR-ADM-006 and FR-ADM-REG-002 part 11 make the versions themselves the history.
- Chosen: append-only versions per attribute group, each with a validity interval.
- As at.
- By effective date: rejected, since a fact recorded late would rewrite what the record showed at the time.
- Chosen: by the recording interval of each version, which reconstructs who changed what and when (part 6.5). Each version still carries its effective date.
- D10 configuration.
- Stop until the D10 clients exist: rejected, since session rule 12 says to build against contracts and stubs.
- Chosen: one class each, holding the values the specification gives, easy to replace with a client.
- CIN sequence.
- A PostgreSQL sequence: rejected, since the number is per facility and day.
- Chosen: a row per facility and day, taken under its lock.
Decision¶
- Clients. Every call to another unit goes through the kit's
client/Downstreamwith a client-credentials token (client/ServiceTokens, clientadm-patient-administration). The answer is mapped like this: - 400, 403 and 412 become this unit's refusal, keeping the other unit's field pointers. Those pointers are the same as this unit's where a field is passed on unchanged.
- 404 is "not found".
- Anything else is "unavailable", answered as 503, never as a refusal or an empty result.
One client per contract:
- HttpPersonIndex: patient-identity.v1, at his.adm.identity.url;
- HttpTerminologyClient: terminology.v1 validateCode;
- HttpTaskServiceClient: workflow.v1 createTask;
- HttpRegistry: master-data.v1, the facility, service, location and practitioner reads.
Each is checked against the stub of its contract (ConsumerContractTest).
- Registration (Registrations):
1. Checks, the field set and the coded values.
2. The policy decision.
3. createPerson, or addPersonIdentifier for a selected person.
4. assignFacilityIdentifier.
5. One transaction with the registration record, the versions, the verification, the related persons, the audit event and PatientRegistered.
The keys passed on are UUID(facility | key | part), and the registration's own identifier is derived the same way, so a repeated request names the same registration to adm-identity. A "same person" answer (PR-REG-003-4, GAP-ADM-011) selects that person:
- no person is created;
- a high-risk pair is refused;
- differing matching data is held on the review item, not written onto the person.
A new person is never blocked by an ambiguity: it is the temporary identity that FR-ADM-REG-003 part 10 tells the clerk to use. A selected person with an open high-risk ambiguity is refused (BR-ADM-007).
- Review items of a pair (IdentityReviews, amended 2026-11-26, answer A to Q-S09-4). They are adm-identity's: the unit calls recordIdentityReview of patient-identity.v1 1.1 and never makes a task adm.duplicate-review itself (ADR-HIS-067 decision 8). It is called:
- after "same person" at registration, with the held demographics and identifiers;
- when a change of an existing person prompted candidates, at registration, completion or updateDemographics (PR-REG-003-3), without held data, since the change is written onto the person.
The call comes after every local check and before any other change, with a derived Idempotency-Key. The answer's items are the registration's reviewItems; completion adds its own. When adm-identity answers the ambiguity flag (a high-risk pair, BR-ADM-007), routine registration is refused, and the item it recorded stays. "Same person" on a change is refused here, since every candidate of a change is another person and the contract takes "same" only for the person the registration continues against.
- Demographics (DemographicStore, DemographicChanges):
- one version per changed group;
- a group's fields that the request does not carry keep their values;
- the person's version, the ETag, is raised once per change under the person's row lock, so a stale If-Match is refused (PR-REG-002-1);
- a reason is required only where a recorded name, date of birth or sex changes.
A change of a matching-relevant value runs the duplicate check of adm-identity again. The user must answer only when it prompts someone.
- Source trust (SourceTrust, CFG-ADM-007):
- only a person, with source user-entry or steward, may set a verified level;
- interfaces and the portal may change contact points;
- any other interface change to a verified group is held as a reconciliation item;
- a patient-reported change waits for staff review;
- no source but a steward lowers a verified value. For a clerk, this protects the identity attributes taken from a document and compared by matching: name and aliases, birth, sex, mother's name and citizenship. A clerk's lower-level change to one of these is held for a steward. A clerk records a new address, contact or social attribute at the level they checked. The value it replaces stays in the history with its own level (GAP-ADM-014: in Indonesia the KTP address and the current address, domisili, often differ).
A held change is a task adm.demographic-reconciliation in the D10 task service, queued locally while the service is down.
- Handoff to adm-identity (IdentityHandoff, amended 2026-11-26). Every applied change of a person's demographics is a row of identity_handoff, written in the change's transaction and delivered with recordDemographicChange (INT-ADM-001):
- demographicsVersion is the place of the change in the person's sequence here: 1, 2, and so on without gaps. A new person's first versions are delivered too; adm-identity answers a version it already has unchanged;
- each row carries the versions the change created with their provenance, the new values of those groups only, the verification of the same request, and the author;
- it is delivered right after the commit and by a relay (his.adm.identity.relay-enabled, poll-interval), oldest first per person under an advisory lock, with the row's identifier as Idempotency-Key. While adm-identity is unavailable the rows wait, with backoff;
- a 412 sends the person's earlier rows again, in order. A refusal marks the row failed and stops the person's queue, so no later version overtakes it.
The operation needs a changed group, so a verification recorded without a change of demographics waits and goes with the person's next change.
- Field sets (FieldSets, CFG-ADM-004@1, Indonesia profile):
- planned: every mandatory field of part 7, no deferral;
- planned-inpatient: the same, plus the responsible person;
- emergency: the CFG-ADM-027 minimum, the rest deferrable.
The responsible person is also mandatory for a minor: under 18 (GAP-ADM-015: a child under UU 35/2014). Which encounter type uses which set is the setting his.adm.registration.field-sets. The codes are those of GAP-ADM-016: outpatient-visit, day-care, pre-admission, inpatient-admission and emergency-visit, the services of an Indonesian hospital (rawat jalan, one day care, pra-rawat inap, rawat inap, IGD), each with the encounter class SATUSEHAT uses (AMB, IMP or EMER of v3-ActCode).
- Codes (CachingCodeChecker). Every coded value is validated through terminology, and the last answer per code is cached. While terminology is unavailable, the cache decides: an inactive or unknown code is still refused, an unseen one is accepted. The registration is then marked revalidationPending.
- CIN (CinAllocator, CFG-ADM-008): the facility's 2-character code (setting his.adm.encounters.cin-facility-codes, RC-1-S03 Q1), the facility-zone date YYMMDD and a 6-digit daily sequence below 900000. It is unique by a database constraint and immutable by a trigger.
- Encounter creation for one patient at one facility takes an advisory lock. The identical-registration rule (CUX-37), the concurrent-encounter rule (CFG-ADM-010, warn by default) and a repeated Idempotency-Key are then decided without a race.
- Every encounter has a care episode, its own encounter identifier until a continuation joins an earlier one.
- Tier. The unit is Tier 1 (NFR-ADM-003, DEC-ADM-014): when the audit buffer is full it carries on, with its outbox as the local log.
Consequences¶
- Not atomic. A registration that fails after adm-identity answered leaves a person, and perhaps a No. RM, with no registration. Repeating the request with the same key completes it. A request never repeated leaves a person in the index that no facility registered; the stewardship reports of RC-3 can find them.
- Two copies of the demographics. The index learns of a change after its commit, so for a short time, or while adm-identity is down, it matches on the earlier values. Until adm-identity serves version 1.1 (the RC-1-S08 fix of the RC-1 gate), the rows wait in
identity_handoff, and a registration or change that needs a review item cannot complete. - A verification alone waits. A person's verification status in the index follows a verification recorded without a change of demographics only at the person's next change. A contract follow-up could take it on its own.
- Stand-ins. The field sets, source trust and the CIN codes are configuration of this unit until the D10 configuration service has a client. A governance change is a change of the unit's settings.
- No HL7 v2. EncounterOpened and PatientRegistered are thin events. The HL7 v2 ADT messages are made from them by the D02 adapters.