Changes between Version 14 and Version 15 of ERModel


Ignore:
Timestamp:
09/22/26 10:53:38 (26 hours ago)
Author:
236021
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ERModel

    v14 v15  
    6363
    6464=== Doctors ===
    65 Doctors is the central entity for doctors who use the system to see patients, record diagnoses, order tests and perform procedures. Level, specialization and department are FKs to lookup entities rather than free text to prevent inconsistent values and allow filtering.
     65Doctors is the central entity for doctors who use the system to see patients, record diagnoses, order tests and perform procedures. Level, specialization and department are FKs to lookup entities rather than free text to prevent inconsistent values and allow filtering. A Doctors row optionally carries a `user_id` FK back to Users, linking the doctor to their login account.
    6666
    6767* '''Candidate keys:'''
     
    8989  department_id (FK, bigint) — required, references Departments
    9090
     91  user_id (FK, bigint, UNIQUE) — required, references Users
     92
    9193=== Patients ===
    92 Patients represents the people receiving care, it is the anchor entity for almost all clinical data like appointments, diagnoses, medical records, tests, procedures, billing.
     94Patients represents the people receiving care, it is the anchor entity for almost all clinical data like appointments, diagnoses, medical records, tests, procedures, billing. A Patients row optionally carries a `user_id` FK back to Users, linking the patient to their login account.
    9395
    9496* '''Candidate keys:'''
     
    120122  embg (text) — required, unique, 13-digit format
    121123
     124  user_id (FK, bigint, UNIQUE) — required, references Users
     125
    122126=== Admin ===
    123 Represents clinic administrative staff who manage billing and back-office operations. Kept separate from Doctors and Lab_Technician since admins have no clinical attributes.
     127Represents clinic administrative staff who manage billing and back-office operations. Kept separate from Doctors and Lab_Technician since admins have no clinical attributes. An Admin row optionally carries a `user_id` FK back to Users, linking the admin to their login account.
    124128
    125129* '''Candidate keys:'''
     
    145149  email (text) — required, unique, must contain "@adminmedora" (`LIKE '%@adminmedora%'` - restricts admins to the internal admin email domain)
    146150
     151  user_id (FK, bigint, UNIQUE) — required, references Users
     152
    147153=== Lab_Technician ===
    148 Lab Technician entity is the lab staff who conduct the tests ordered by doctors and record results in Performed_Lab_Tests. Modeled separately from Doctors since technicians don't diagnose or prescribe.
     154Lab Technician entity is the lab staff who conduct the tests ordered by doctors and record results in Performed_Lab_Tests. Modeled separately from Doctors since technicians don't diagnose or prescribe. A Lab_Technician row optionally carries a `user_id` FK back to Users, linking the technician to their login account.
    149155
    150156* '''Candidate keys:'''
     
    168174  email (text) — required, unique, must contain "@labmedora" (`LIKE '%@labmedora%'` - restricts technicians email domain)
    169175
     176  user_id (FK, bigint, UNIQUE) — required, references Users
     177
    170178=== Users ===
    171 Users is the authentication and login entity implementing role based access. A Users row is meant to serve exactly one of Patients, Doctors, Admin or Lab_Technician via whichever of the four nullable FKs is populated.
     179Users is the authentication and login entity implementing role based access. Each of Patients, Doctors, Admin and Lab_Technician optionally carries a `user_id` FK back to a Users row, so a Users row is served by exactly one row among those four role tables, whichever one references it.
    172180
    173181* '''Candidate keys:'''
     
    192200
    193201  last_name (varchar(100)) — optional
    194 
    195   patient_id (FK, bigint, nullable) — references Patients
    196 
    197   doctor_id (FK, bigint, nullable) — references Doctors
    198 
    199   admin_id (FK, bigint, nullable) — references Admin
    200 
    201   technician_id (FK, bigint, nullable) — references Lab_Technician
    202202
    203203  is_active (boolean) — optional, defaults to true
     
    584584each doctor belongs to one department, a department employs many doctors.
    585585
    586 === identifies_patient (Users ↔ Patients, 1:1) ===
    587 a Users row optionally links to one Patients row, when the account belongs to a patient.
    588 
    589 === identifies_doctor (Users ↔ Doctors, 1:1) ===
    590 a Users row optionally links to one Doctors row, when the account belongs to a doctor.
    591 
    592 === identifies_admin (Users ↔ Admin, 1:1) ===
    593 a Users row optionally links to one Admin row, when the account belongs to an administrator.
    594 
    595 === identifies_lab_technician (Users ↔ Lab_Technician, 1:1) ===
    596 a Users row optionally links to one Lab_Technician row, when the account belongs to a lab technician.
    597 
    598 Constraint for identifies relations: Exactly one of the four relationships above must be populated for a given Users row, depending on its role.
     586=== identifies_patient (Patients ↔ Users, 1:1) ===
     587a Patients row carries a user_id FK referencing exactly one Users row.
     588
     589=== identifies_doctor (Doctors ↔ Users, 1:1) ===
     590a Doctors row carries a user_id FK referencing exactly one Users row.
     591
     592=== identifies_admin (Admin ↔ Users, 1:1) ===
     593an Admin row carries a user_id FK referencing exactly one Users row.
     594
     595=== identifies_lab_technician (Lab_Technician ↔ Users, 1:1) ===
     596a Lab_Technician row carries a user_id FK referencing exactly one Users row.
    599597
    600598=== has_allergies (Patients ↔ Allergies, M:N via Patient_Allergies) ===