The entity-relationship diagram below summarises the core healthcare data model introduced in V1__initial_schema.sql. Relationships are cardinality annotated so engineers can visualise the lifecycle of encounters, notes, and coding artefacts.
โโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโ
โ organizations โโโโโโโบโ users โ
โโโโโโโโโโฌโโโโโโโโ โโโโโโโโโโฌโโโโโโโโโโโโ
โ โ โฒ
โ โ โ
โผ โผ โ
โโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโ
โ patients โโโโโโโบโ encounters โ
โโโโโโโโโโฌโโโโโโโโ โโโโโโโโโฌโโโโโฌโโโโโโโโ
โ โ โ
โ โ โโโโโโโโโโโโโโโ
โ โ โผ
โ โ โโโโโโโโโโโโโโโโโ
โผ โผ โ audio_record- โ
โโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโ โ ings โ
โ clinical_notes โโโโโโโบโ diagnoses โ โโโโโโฌโโโโโโโโโโโ
โโโโโโโโโฌโโโโโโโโโ โโโโโโฌโโโโโโโโโโโ โ
โ โ โผ
โ โ โโโโโโโโโโโโโโโโโโ
โผ โผ โ transcripts โ
โโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโ โโโโโโฌโโโโโโโโโโโโ
โ note_sections โ โ procedures โ โ
โโโโโโโโโโโโโโโโโ โโโโโโฌโโโโโโโโ โผ
โ โโโโโโโโโโโโโโโโโโโโโโ
โ โ transcript_segmentsโ
โผ โโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโ
โ icd10_codes โ
โโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโ
โ cpt_codes โ
โโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโ
โ audit_logs โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโ โ
โ
โโโโโโโโโโโโโโโโโโ โ
โ helper funcs โ (set context, RLS, triggers) โ
โโโโโโโโโโโโโโโโโโ โ
Key takeaways:
- Every
userbelongs to exactly oneorganization. Organization settings drive RLS policies. patientsare scoped to organisations and can experience manyencounters.- Each
encountercan have oneaudio_recording, multipletranscripts, one or moreclinical_notes, and billing artefacts (diagnoses,procedures). clinical_notesoptionally decompose into granularnote_sectionsfor subject/objective/etc sections.- Coding reference data (
icd10_codes,cpt_codes) remains independent but links to encounter artefacts via foreign keys. - All PHI tables are protected by audit triggers writing to
audit_logs, which is range-partitioned by month.