Skip to main content

Registration Service — Sync Contract

Status: populated Owner: TBD Last updated: 2026-04-17 Companion: Service Template · 16 offline-first

1. Per-Aggregate Conflict Policy

Aggregate / ResourceConflict policyRationale
PatientAggregate (demographics)server_authoritative + optimistic lockIdentity is safety-critical; client must hold version and retry with updated values on conflict. Server wins on concurrent edits.
PatientIdentifierserver_authoritativeIdentifier uniqueness is enforced server-side; client cannot merge conflicting identifiers.
PatientNameserver_authoritativeMulti-script name display rules require server validation; client provides intent, server confirms.
NextOfKinEntryappend_only (additions); server_authoritative (removals)New NOK entries accumulate safely; removal requires explicit user action with audit.
ConsentFlagserver_authoritativeConsent state is legal record; requires explicit user action; no client merge.
EncounterAggregateserver_authoritative + optimistic lockStatus machine is enforced server-side; client cannot skip transitions.
PatientPortraitserver_authoritativeBinary with consent/retention policy; always server-resolved.
PatientExtensionInstanceserver_authoritativeJSON Schema validation is server-side; conflicts resolved by server with optimistic lock on version.
MPI merge decisionsserver_authoritativeSafety-critical; human-approved and server-executed; offline merge is prohibited.

2. Offline-first Considerations

ScenarioHandling
Create patient while offlineIdempotent create supported: client sends Idempotency-Key or clientMutationId; server deduplicates on reconnect
Update demographics offlineAllowed with version snapshot; on sync, if version stale → OPTIMISTIC_LOCK_CONFLICT returned; client prompts for re-review
Search patients offlineClients may use local cache (read-only); writes queued for server reconciliation
Encounter status transition offlineplanned→arrived permitted offline; server validates on sync; in-progress→finished requires online confirmation
Merge / unmerge offlineProhibited — safety-critical operation requires real-time server execution
Vital status (deceased) offlineProhibited — legal record; online-only

3. Sync Sequencing

Offline writes are ordered by clientMutationId timestamp. On reconnect, the sync layer replays mutations in order. Server rejects duplicates via idempotency store (24h TTL).