Documentation Index
Fetch the complete documentation index at: https://docs.encoreos.io/llms.txt
Use this file to discover all available pages before exploring further.
ADR-005: Cross-Core Foreign Keys to pm_patients
Status: AcceptedDate: 2026-04-10
Decision Makers: Platform Architecture Team
Context
Several cores reference the PM patient record (pm_patients.id) for demographics, portal linkage, and clinical–PM alignment. Constitution §5.2.7 defaults to UUID-only cross-core references unless an ADR authorizes a database FK.
Existing patterns include:
- CL — e.g.
cl_intake_assessments,cl_diagnoses,cl_peer_encounters(patient linkage). - CE — e.g.
ce_lead_conversions→pm_patients. - PF — e.g.
pf_profiles.portal_patient_id→pm_patients.
pm_encounters only).
Decision
-
Database FKs to
pm_patients.idare permitted where a spec explicitly requires tight referential integrity for the patient master record, withON DELETE RESTRICTso PM cannot delete a patient row that is still referenced by downstream clinical or engagement data without an explicit remediation path. (NO ACTIONis acceptable only where it provides identical semantics—i.e., the FK constraint prevents deletion when references exist—butRESTRICTis preferred for clarity.) - New references should prefer UUID columns + application validation unless a spec documents the need for an FK; when an FK is added, it must be listed in migration notes and this ADR.
- Tenant isolation remains enforced by RLS on all participating tables; the FK does not bypass RLS.
Rationale
- The patient identity is a shared anchor across CL, PM, CE, and portal (PF) surfaces; orphan UUIDs create higher operational risk than for generic cross-core links.
- RESTRICT preserves auditability and prevents silent cascades inconsistent with HIPAA-aligned chart retention.
Consequences
Positive
- Stronger integrity for patient-scoped data shared across cores.
- Clear precedent distinct from encounter-only ADR-002.
Negative
- Deployment ordering: PM patient migrations must be coherent before dependent FKs.
- Additional review burden for any new
pm_patientsFK.
Related Documents
- ADR-002: CL-PM Cross-Core Foreign Keys — encounter entity only
- Constitution §5.2.7 — Cross-core database references
- PLATFORM_INTEGRATION_LAYERS.md