Basic database schema HMS (1)
Basic database schema HMS (1)
Patient Table
Columns:
o PatientID (PK)
o Name
o DateOfBirth
o Gender
o ContactInfo
o Address
o RegistrationDate
2. Staff Table
Columns:
o StaffID (PK)
o Name
o Position
o Department
o ContactInfo
o RoleID (FK to UserRoles Table)
3. Appointments Table
Columns:
o AppointmentID (PK)
o PatientID (FK to Patient Table)
o StaffID (FK to Staff Table, assuming staff members like doctors handle
appointments)
o AppointmentDate
o AppointmentTime
o Status (e.g., Scheduled, Completed, Canceled)
4. MedicalRecords Table
Columns:
o RecordID (PK)
o PatientID (FK to Patient Table)
o StaffID (FK to Staff Table, to track who created the record)
o Diagnosis
o Treatment
o DateCreated
5. Billing Table
Columns:
o BillingID (PK)
o PatientID (FK to Patient Table)
o AppointmentID (FK to Appointments Table, if billing is appointment-based)
o TotalAmount
o BillingDate
o Status (e.g., Paid, Pending)
6. Payment Table
Columns:
o PaymentID (PK)
o BillingID (FK to Billing Table)
o PaymentAmount
o PaymentDate
o PaymentMethod (e.g., Cash, Credit, Insurance)
7. DischargeManagement Table
Columns:
o DischargeID (PK)
o PatientID (FK to Patient Table)
o StaffID (FK to Staff Table, staff member managing the discharge)
o DischargeDate
o DischargeNotes
8. Pharmacy Table
Columns:
o PharmacyID (PK)
o MedicineName
o Stock
o Price
o ExpiryDate
9. Inventory Table
Columns:
o InventoryID (PK)
o ItemName
o Quantity
o ItemCategory (e.g., Equipment, Medicines, Supplies)
o LastUpdated
Columns:
o RoleID (PK)
o RoleName (e.g., Doctor, Nurse, Pharmacist, Admin)
o Permissions
Relationships Overview
One-to-Many:
o Patient to Appointments (One patient can have multiple appointments).
o Patient to MedicalRecords (One patient can have multiple medical records).
o Patient to Billing (One patient can have multiple billing entries).
o Billing to Payment (One billing entry can have multiple payments).
o Staff to DischargeManagement (One staff can handle multiple discharges).
Many-to-Many:
o Staff to UserRoles (handled by StaffPermissions table).
Would you like me to further refine any specific part of this model?
4o
You said:
continue
ChatGPT said:
ChatGPT
To further elaborate on the physical database model, let’s add more details to the tables and
relationships, focusing on constraints, possible indexes, and additional columns that may be
useful for an efficient Hospital Management System (HMS).
Purpose: Logs important actions in the system for security and auditing purposes.
Columns:
o LogID (PK)
o Action (e.g., "Create", "Update", "Delete")
o TableName (name of the table where the action occurred)
o RecordID (ID of the record affected)
o Timestamp
o PerformedBy (FK to StaffID in Staff Table)
Here are example SQL statements for creating some of the tables with primary keys, foreign
keys, and constraints:
sql
Copy code
CREATE TABLE Patient (
PatientID INT PRIMARY KEY,
Name VARCHAR(100),
DateOfBirth DATE,
Gender CHAR(1),
ContactInfo VARCHAR(100),
Address TEXT,
RegistrationDate DATE
);
Many-to-Many Relationships
The UserRoles and RolePermissions tables create a flexible system for managing permissions,
allowing multiple staff members to be assigned roles with specific permissions.
Summary of Relationships
One-to-Many:
o Patient ↔ Appointments
o Patient ↔ MedicalRecords
o Patient ↔ Billing
o Billing ↔ Payment
o Staff ↔ DischargeManagement
o UserRoles ↔ Staff
o Pharmacy ↔ Inventory (if managing stock levels of each medicine individually)
Many-to-Many:
o Staff ↔ Permissions (via RolePermissions table)