24BCY70135 Hospital Management Case Study
24BCY70135 Hospital Management Case Study
using C++
Prepared by: Soumyadeep Sarkar
UID: 24BCY70135
Section&Group: 117-B
Subject: BASIC DATA STRUCTURES
USING C++
Subject Code: 24CSH-103
Table of Contents
1. Introduction
2. Objectives
3. Problem Statement
4. System Requirements
5. Proposed Solution
6. System Design
7. Code Explanation
8. Program Code
9. Output
10. Conclusion
11. Recommendations
12. References
Introduction
The healthcare sector is increasingly
dependent on efficient data management
systems. A Hospital Management System is a
software solution designed to manage and
streamline hospital operations like patient
information, staff records, appointments, and
medical records. This case study showcases a
simple implementation of such a system
using C++.
Objectives
- To build a basic Hospital Management System in
C++.
- To demonstrate the use of simple C++ constructs
such as loops, arrays, conditionals, and switch-
case.
- To allow basic functionalities like adding,
displaying, and modifying patient information.
Problem Statement
Manual handling of hospital records can be time-
consuming and error-prone. This project aims to
automate the basic functionalities of patient
management, thereby improving efficiency and
accuracy.
System Requirements
Software Requirements:
C++ Compiler (e.g., GCC, Turbo C++)
Text Editor or IDE (e.g., Code::Blocks, Dev C+
+)
Hardware Requirements:
Minimum 1GB RAM
Minimum 1 GHz Processor
Keyboard and Monitor
Proposed Solution
The proposed solution is a C++ program that can
store, display, and manage patient information. It
is a console-based program and uses arrays to
store data in memory without using file handling.
The interface is menu-driven and uses only `cin`
and `cout` for I/O.
System Design
Algorithm:
1. Start the program.
2. Declare arrays to store ID, name, age, gender,
and disease.
3. Initialize a variable `patientCount` to 0.
4. Display a menu with the following options:
- Add Patient
- Show Patients
- Edit Patient
- Delete Patient
- Exit
5. Use `cin` to get user's choice.
6. Use a `switch` statement to handle each case:
- Case 1 (Add Patient):
- Check if `patientCount` is less than maximum
allowed.
- Ask user to enter ID, Name, Age, Gender, and
Disease.
- Store the details in corresponding arrays.
- Increment `patientCount`.
- Case 2 (Show Patients):
- Loop through arrays up to `patientCount`.
- Display patient details.
- Case 3 (Edit Patient):
- Ask for patient ID to edit.
- Search for the ID in the array.
- If found, ask for new details and update
arrays.
- Case 4 (Delete Patient):
- Ask for patient ID to delete.
- Search and remove the patient by shifting all
later entries up.
- Decrease `patientCount` by 1.
- Case 5 (Exit):
- Display exit message.
- Break loop and terminate program.
- Default: Display "Invalid choice".
7. Loop the menu until the user chooses Exit.
8. End the program.
Code Explanation
- The program uses arrays to store patient ID,
name, age, gender, and disease.
- `cin` and `cout` handle user input/output.
- A switch statement is used for menu navigation.
- New functions added: editPatient, deletePatient.
void addPatient() {
if (patientCount < MAX) {
cout << "Enter Patient ID: ";
cin >> idList[patientCount];
cout << "Enter Name (use underscores for
spaces): ";
cin >> nameList[patientCount];
cout << "Enter Age: ";
cin >> ageList[patientCount];
cout << "Enter Gender: ";
cin >> genderList[patientCount];
cout << "Enter Disease (use underscores): ";
cin >> diseaseList[patientCount];
patientCount++;
cout << "Patient added successfully.\n";
} else {
cout << "Patient limit reached.\n";
}
}
void showPatients() {
if (patientCount == 0) {
cout << "No patient records available.\n";
return;
}
cout << "\n--- Patient List ---\n";
for (int i = 0; i < patientCount; i++) {
cout << "ID: " << idList[i]
<< ", Name: " << nameList[i]
<< ", Age: " << ageList[i]
<< ", Gender: " << genderList[i]
<< ", Disease: " << diseaseList[i] << "\n";
}
}
void editPatient() {
int id;
cout << "Enter ID to edit: ";
cin >> id;
for (int i = 0; i < patientCount; i++) {
if (idList[i] == id) {
cout << "Enter new Name: ";
cin >> nameList[i];
cout << "Enter new Age: ";
cin >> ageList[i];
cout << "Enter new Gender: ";
cin >> genderList[i];
cout << "Enter new Disease: ";
cin >> diseaseList[i];
cout << "Record updated.\n";
return;
}
}
cout << "Patient ID not found.\n";
}
void deletePatient() {
int id;
cout << "Enter ID to delete: ";
cin >> id;
for (int i = 0; i < patientCount; i++) {
if (idList[i] == id) {
for (int j = i; j < patientCount - 1; j++) {
idList[j] = idList[j + 1];
nameList[j] = nameList[j + 1];
ageList[j] = ageList[j + 1];
genderList[j] = genderList[j + 1];
diseaseList[j] = diseaseList[j + 1];
}
patientCount--;
cout << "Record deleted.\n";
return;
}
}
cout << "Patient ID not found.\n";
}
int main() {
int choice;
do {
cout << "\nHospital Management System\n";
cout << "1. Add Patient\n";
cout << "2. Show Patients\n";
cout << "3. Edit Patient\n";
cout << "4. Delete Patient\n";
cout << "5. Exit\n";
cout << "Enter choice: ";
cin >> choice;
switch (choice) {
case 1: addPatient(); break;
case 2: showPatients(); break;
case 3: editPatient(); break;
case 4: deletePatient(); break;
case 5: cout << "Goodbye!\n"; break;
default: cout << "Invalid choice.\n";
}
} while (choice != 5);
return 0;
}
Output:
Hospital Management System
1. Add Patient
2. Show Patients
3. Edit Patient
4. Delete Patient
5. Exit
Enter choice: 1
Enter Patient ID: 01
Enter Name (use underscores for spaces):
Soumyadeep
Enter Age: 20
Enter Gender: Male
Enter Disease (use underscores):
Acute_Depression
Patient added successfully.
Conclusion
This project successfully demonstrates a simple hospital
management system using only basic C++ features. It
includes CRUD (Create, Read, Update, Delete)
operations for patient data, making it a foundational
system that could be extended further with databases
or GUI.
Recommendations
- Use file handling to store patient records permanently.
- Add more modules like doctor scheduling, billing, and
medicine inventory.
- Introduce GUI using frameworks like Qt or console UI
libraries.
References
1. C++ Documentation - http://www.cplusplus.com
2. Programming Tutorials -
https://www.geeksforgeeks.org
3. C++ For Beginners -
https://www.w3schools.com/cpp