Architectural Decisions Register

Key architectural decisions for REV.health, including IC rule deviations, rationale, and consequences.

DEC-RH-001: Users & Patients Are Global (No OrganizationID)

Date: 2026-03-15 · IC Rule Deviation: Rule #11 exception · Status: Accepted

Choice: User and Patient entities have no OrganizationID column. They exist once globally across the platform.

Rationale: A patient is a person, not an organizational asset. Multi-org patients (e.g., referred between practices) must not be duplicated. This matches real-world identity: one person, one record, many care relationships.

Affected Modules: All modules — every module references User/Patient.

Consequences:

DEC-RH-002: Clinical Facts Are Global with SourceOrganizationID

Date: 2026-03-15 · IC Rule Deviation: Rule #11 exception · Status: Accepted

Choice: Clinical facts (Allergy, Medication, Condition, Vital, LabResult, Imaging, Immunization, CarePlan, Surgery, Problem, Diagnosis, Procedure, Prescription, PatientDocument) are global entities partitioned by PatientID with a SourceOrganizationID for provenance.

Rationale: Clinical facts belong to the patient, not the org. A medication prescribed by Org A is still the patient's medication when seen at Org B. SourceOrganizationID preserves the chain of custody without org-locking the data.

Affected Modules: Clinical Documentation, Labs, Imaging, eRx, Patient Portal, Referrals.

Consequences:

DEC-RH-003: Short GUID Encoding (Base62, 22 chars)

Date: 2026-03-18 · IC Rule Deviation: None · Status: Accepted

Choice: All primary keys are UUID v4 values encoded as 22-character Base62 strings. The encoding is deterministic and reversible.

Rationale: Standard UUIDs (36 chars with hyphens) are verbose in URLs, JSON payloads, and Cosmos partition keys. Base62 is URL-safe, case-sensitive, and compresses 128 bits into 22 characters with no information loss.

Affected Modules: All modules (every entity uses ShortGUID PKs).

Consequences:

DEC-RH-004: Read-Access Audit with Authorization Chains

Date: 2026-03-20 · IC Rule Deviation: None · Status: Accepted

Choice: Every clinical data read generates a hash-chained audit entry that records the full authorization chain (CareOrgMember, FamilyProxy, ExternalSpecialist, TEFCA, BreakTheGlass, Researcher).

Rationale: HIPAA requires accounting of disclosures. Patients need to see who accessed their data and why. Hash-chaining prevents tampering. The authorization chain captures the legal basis for access, not just the actor.

Affected Modules: All modules with clinical data access, Patient Portal (patient-facing audit view).

Consequences:

DEC-RH-005: Patient = User Identity (PatientID = UserID)

Date: 2026-03-15 · IC Rule Deviation: Rule #11 · Status: Accepted

Choice: PatientID is a foreign key to User.UserID with the same value. Every patient is a user; there is no separate identity for patients vs. staff vs. providers — they are all Users with different roles.

Rationale: Clinicians are also patients. A single identity model eliminates duplicate records, simplifies SSO, and enables a provider to view their own patient record with the same Patient Portal experience.

Affected Modules: IAM, Patient Portal, all clinical modules.

Consequences:

DEC-RH-006: PostgreSQL as Primary OLTP

Date: 2026-03-10 · IC Rule Deviation: None · Status: Superseded by DEC-RH-008

Choice: Use PostgreSQL (Azure Database for PostgreSQL Flexible Server) as the primary OLTP store with row-level security for multi-tenancy.

Rationale: Mature relational model, strong ACID guarantees, row-level security for tenant isolation, rich ecosystem.

Affected Modules: All modules (data layer).

Consequences:

DEC-RH-007: Read-Access Audit Scoped to Patient Across Orgs

Date: 2026-03-22 · IC Rule Deviation: None · Status: Accepted

Choice: Audit log entries are partitioned by PatientID, not OrganizationID. This means a patient's complete access history is queryable in one partition regardless of which org performed the access.

Rationale: The patient is the data subject. Regulatory queries ("who accessed my data?") are patient-centric. Partitioning by patient makes these queries single-partition reads in Cosmos, which is fast and cheap.

Affected Modules: Audit subsystem, Patient Portal, compliance reporting.

Consequences:

DEC-RH-008: Azure Cosmos DB as Primary OLTP

Date: 2026-04-01 · IC Rule Deviation: None · Status: Accepted (supersedes DEC-RH-006)

Choice: Use Azure Cosmos DB (NoSQL API) as the primary OLTP store. Multi-tenancy is achieved via partition keys (T1), dedicated databases (T2), or dedicated accounts (T3).

Rationale: Cosmos provides single-digit-ms latency at any scale, native partition-key isolation, tunable consistency, global distribution for multi-region DR, and a 99.999% SLA. Healthcare workloads need elastic throughput (flu season spikes) and geographic compliance (data residency).

Affected Modules: All modules (data layer).

Consequences:

Global Containers

ContainerPartition KeyPrimary Entities
global-patient/PatientIDPatient, Allergy, Medication, Condition, Vital, LabResult, Imaging, Immunization, CarePlan, FamilyHistory, Surgery, Problem, ProblemList, Diagnosis, Procedure, Prescription, PatientDocument, SensitiveClassGating
global-provider/ProviderIDProvider, Credential, Specialty, License
global-practice/PracticeIDPractice, Location, Department
global-pharmacy/PharmacyIDPharmacy, PharmacyNetwork
global-specialty/SpecialtyCodeSpecialty taxonomy, sub-specialties
global-user/UserIDUser, UserRole, UserPreference
global-clinical-facts/PatientIDCross-org clinical fact aggregation view

Org-Scoped Containers

ContainerPartition KeyPrimary Entities
org-encounter/OrganizationIDEncounter, CareRelationship, PatientOrgMembership
org-order/OrganizationIDOrderSet, LabOrder, ImagingOrder, RxOrder
org-reminder/OrganizationIDReminder, RecallList, OutreachCampaign
org-referral/OrganizationIDReferral, ReferralResponse
org-message/OrganizationIDPortalMessage, InternalMessage
org-external-interop/OrganizationIDTEFCA queries, HIE documents, C-CDA imports
org-rules/OrganizationIDCdsRule, CdsHookEvent, AlertRule
org-audit/PatientIDAuditLog (partitioned by patient within org context)
org-eligibility/OrganizationIDEligibilityCheck, BenefitDetail, PriorAuth, Coverage
org-scheduling/OrganizationIDSchedule, Slot, Appointment, WaitlistEntry, VisitType, VisitStage
org-rcm/OrganizationIDClaim, ClaimLine, Remittance, Denial, PatientStatement, Payment
org-task/OrganizationIDTask, WorkTask
org-payer-opt/OrganizationIDPayerRule, FormularyCheck, ControlledSubstanceAuth, PdmpQuery