Class Diagram for Hospital Management System: Full UML Example
Table of Contents
Hospital management systems are one of the most commonly requested class diagram examples — they appear in textbooks, university assignments, and system design discussions because they have a rich set of real-world relationships to model.
This post provides a complete, realistic UML class diagram for a hospital management system, broken into subsystems. All examples use Mermaid syntax so you can paste them directly into the free Badger tool and export PNG or SVG.
Core Entities: Patient, Doctor, and Appointment
classDiagram
class Person {
<<abstract>>
+String personId
+String firstName
+String lastName
+Date dateOfBirth
+String phone
+String email
+getFullName() String
+getAge() int
}
class Patient {
+String patientId
+String bloodType
+MedicalHistory history
+registerPatient() void
+getActiveAdmissions() List
}
class Doctor {
+String doctorId
+String specialization
+String licenseNumber
+List schedule
+getAvailableSlots() List
+prescribe(medicine) Prescription
}
class Appointment {
+String appointmentId
+DateTime scheduledTime
+String status
+String notes
+confirm() void
+cancel() void
+reschedule(newTime) void
}
Person <|-- Patient
Person <|-- Doctor
Patient "1" --> "0..*" Appointment : books
Doctor "1" --> "0..*" Appointment : attends
Ward and Bed Management
classDiagram
class Ward {
+String wardId
+String wardName
+String wardType
+int totalBeds
+getAvailableBeds() int
+getOccupancyRate() float
}
class Bed {
+String bedId
+String bedType
+bool isOccupied
+assignPatient(patient) void
+discharge() void
}
class Admission {
+String admissionId
+Date admittedOn
+Date dischargedOn
+String diagnosis
+String status
+discharge() void
}
Ward *-- Bed
Bed "1" --> "0..1" Admission : hosts
Patient "1" --> "0..*" Admission : has
Ward owns Beds (composition — no Bed exists without a Ward). An Admission links a specific Patient to a specific Bed during their hospital stay.
Sell Custom Apparel — We Handle Printing & Free ShippingPrescription and Medication
classDiagram
class Prescription {
+String prescriptionId
+Date issuedDate
+Date expiryDate
+String instructions
+isValid() bool
+getPrescribedItems() List
}
class PrescriptionItem {
+String medicineId
+int dosage
+String frequency
+int durationDays
}
class Medicine {
+String medicineId
+String name
+String genericName
+float stockLevel
+reorder() void
}
Doctor "1" --> "0..*" Prescription : issues
Prescription *-- PrescriptionItem
PrescriptionItem --> Medicine
Prescriptions own their items (composition). Each item references a Medicine from the inventory — an association, not composition, since Medicine exists independently of any prescription.
Billing and Insurance
classDiagram
class Bill {
+String billId
+Date generatedDate
+float totalAmount
+float paidAmount
+String status
+generateBill() void
+processPayment(amount) void
+getBalance() float
}
class BillItem {
+String description
+float amount
+String itemType
}
class Insurance {
+String insuranceId
+String provider
+String policyNumber
+float coverageLimit
+float coveragePercent
+validateCoverage(amount) bool
}
Admission --> Bill : generates
Bill *-- BillItem
Patient "0..1" --> "1" Insurance : covered by
Staff and Department Structure
classDiagram
class Department {
+String departmentId
+String name
+String location
+getStaffCount() int
}
class Staff {
+String staffId
+String role
+String shift
+Date hireDate
+clockIn() void
+clockOut() void
}
class Nurse {
+String nurseId
+String certifications
+assignToWard(ward) void
}
Department *-- Staff
Staff <|-- Doctor
Staff <|-- Nurse
Department "1" --> "1..*" Ward : manages
This shows that Doctors and Nurses are both Staff (inheritance), Staff belong to Departments (composition), and Departments manage Wards (association with cardinality).
Try It Free — No Signup Required
Runs 100% in your browser. No data is collected, stored, or sent anywhere.
Open Free Class Diagram ToolFrequently Asked Questions
Is this class diagram suitable for a university assignment on hospital management?
Yes, with adjustments to match your course requirements. The structure covers the main entities and relationships typically expected. You can add or remove classes and attributes based on your specific system scope.
Why is Ward to Bed shown as composition but Patient to Admission as association?
Beds are owned by Wards — if a Ward is deleted, the beds cease to exist. But an Admission record can be kept after a Ward or Bed changes. The Patient-to-Admission relationship is a directed association because the Admission has its own lifecycle beyond the Patient.
How do I draw this diagram in the free online tool?
Copy any of the Mermaid code blocks above and paste them into the Badger Class Diagram tool. The diagram renders live. Click Export PNG to download or Export SVG for a vector file.
Can I combine all the subsystems into one diagram?
You can, but readability suffers above about 15 classes. Consider keeping the subsystems separate and cross-referencing with notes, or showing only the core entities (Patient, Doctor, Appointment, Admission) in a single overview diagram.

