This is a console-based Hospital Patient Management System implemented in C++.
It manages:
- Patient registration (admission)
- Room allocation (General / ICU)
- Tracking critical patients
- Discharge with automatic bill calculation
- Patient stay duration
- Persistent storage in a text file (hospital_records.txt)
The system uses a doubly linked list (DLL) to store patients in memory and saves/loads all data to/from a file.
-
Add Patient
- Assigns a unique Patient ID automatically.
- Stores:
- Name
- Age
- Gender
- Disease
- Critical status (priority: 1 = Critical, 0 = Normal)
- Automatically sets:
- Admission date & time (current system time)
- Status = Admitted
- Patient is inserted in the linked list:
- Critical patients → near the head
- Normal patients → near the tail
-
Discharge Patient
- Marks the patient as discharged.
- Stores discharge date & time.
- Calculates:
- Number of days stayed (based on admission & discharge timestamps)
- Total bill = days * room charge
- Room charge:
- General Ward → ₹1000 per day
- ICU → ₹5000 per day
-
Search Patient
- Search by Patient ID.
- Shows:
- Personal details (name, age, gender, disease)
- Priority (Critical / Normal)
- Room & ward type
- Admission & discharge time
- Status (Admitted / Discharged)
- Total bill (if discharged)
-
Display All Patients
- Lists every patient in the system in current DLL order:
- ID, Name, Age, Gender, Disease
- Priority, Room No, Ward Type
- Status
- Lists every patient in the system in current DLL order:
-
Room Allocation System
- Automatically allocates rooms based on priority:
- Normal patients → General Ward (rooms: 101, 102, 103, …)
- Critical patients → ICU (rooms: 201, 202, 203, …)
- Prevents:
- Allocating rooms to discharged patients
- Allocating again if room is already assigned
- Automatically allocates rooms based on priority:
-
Track Critical Patients
- Submenu:
- Show all critical patients
- Mark a patient as critical & move to head of DLL
- Remove critical status & move to tail of DLL
- Demonstrates priority management using doubly linked list operations.
- Submenu:
-
Patient Stay Duration
- Shows approximate days stayed in hospital for a given patient:
- Uses admission time and:
- Discharge time, if already discharged
- Current time, if still admitted
- Uses admission time and:
- Shows approximate days stayed in hospital for a given patient:
-
Bill Menu
- Displays detailed bill for discharged patients:
- Name, Ward Type, Room No
- Admission & Discharge time
- Days stayed
- Room charge per day
- Total bill
- Displays detailed bill for discharged patients:
-
Data Persistence
- All data is stored in hospital_records.txt.
- On program start → loads data from file.
- On updates → saves data to file.
Each patient is stored as a struct Patient node in a doubly linked list:
struct Patient {
int id;
string name;
int age;
string gender;
string disease;
int priority; // 1 = critical, 0 = normal
int roomNo;
string wardType; // "General", "ICU", or "NA"
int status; // 0 = admitted, 1 = discharged
long long admissionEpoch;
long long dischargeEpoch;
string admissionDateTime;
string dischargeDateTime;
double totalBill;
Patient* prev;
Patient* next;
};