C++ Hospital System Simulation: Patient Management and Surgical Waiting Lists
This C++ code serves as a comprehensive simulation of a hospital system, featuring patient registration, record-keeping, and surgery waiting list management. The structured use of classes such as Patient and PatientRegister demonstrates an object-oriented approach to healthcare data management. It showcases fundamental principles of C++ programming through the creation of patient instances, historical records, and dynamic waiting lists. For students seeking assistance with their C++ assignments, this code offers a practical example of how to organize and manipulate healthcare-related data within a program. The simulated scenario provides insights into real-world applications of C++ in managing patient information and surgical queues, making it a valuable resource for those grappling with similar programming challenges.
Block 1: Patient Initialization
// new patient
Patient med;
med.name = "Med Smith";
med.dob = "10-2-1965";
med.registration_number = 1234567;
Admission john_admission;
john_admission.admission_date = "01-01-2023";
john_admission.discharge_date = "05-01-2023";
john_admission.admitted_ward = "General";
med.history.push_back(john_admission);
This block initializes a new patient named "Med Smith" with a specific date of birth and registration number. It also creates an admission record for this patient, setting admission and discharge dates along with the admitted ward. The admission record is then added to the patient's history.
Block 2: Another Patient Initialization
// creating another patient
Patient sara;
sara.name = "Sara Soars";
sara.dob = "10-2-1970";
sara.registration_number = 1234568;
Admission jane_admission;
jane_admission.admission_date = "01-02-2023";
jane_admission.discharge_date = "05-02-2023";
jane_admission.admitted_ward = "General";
sara.history.push_back(jane_admission);
Similar to Block 1, this block initializes another patient named "Sara Soars" with different details and an admission record.
Block 3: Patient Register
// Patient Register
PatientRegister hospital_register;
hospital_register.add_patient(med);
hospital_register.add_patient(sara);
This block creates a PatientRegister object and adds the previously initialized patients ("Med Smith" and "Sara Soars") to the register.
Block 4: Displaying a Patient from Register
// displaying a patient
std::cout << hospital_register[1234567] << std::endl;
This block demonstrates accessing a patient from the register using their registration number and displaying the information.
Block 5: Waiting List Initialization
// Waiting List
WaitingList surgery_list;
surgery_list.add_patient(med);
surgery_list.add_patient(sara);
Here, a WaitingList object is created, and the two patients are added to the surgery waiting list.
Block 6: Getting Next Patient for Surgery
// next patient for surgery
std::cout << "Next patient for surgery: " << surgery_list.get_next_patient().name << std::endl;
This block prints the name of the next patient for surgery from the waiting list.
Block 7: Removing Patient from Surgery Queue
// Removing patient from surgery queue after surgery
surgery_list.remove_patient();
This simulates the removal of a patient from the surgery queue after they have undergone surgery.
Block 8: Displaying Next Patient for Surgery After Removal
// Displaying next patient for surgery after removing one
std::cout << "Next patient for surgery: " << surgery_list.get_next_patient().name << std::endl;
Finally, this block prints the name of the next patient for surgery after one patient has been removed from the waiting list.