Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //This program is hospital management system using object-oriented programming.
- #include<iostream>
- #include<fstream>
- #include <limits>
- #ifdef _WIN32
- #include <Windows.h>
- #else
- #include <unistd.h>
- #endif
- #include <string>
- #include <stdio.h>
- #include <conio.h>
- #include <vector>
- #include <ctime>
- #include <filesystem>
- using namespace std;
- class Menu {
- string data[10] = {};
- int size = 10;
- public:
- Menu(string st[], int z)
- {
- for (int i = 0; i < z; i++)
- {
- cout << st[i] << endl;
- data[i] = st[i];
- }
- size = z;
- }
- Menu(string one, int z)
- {
- cout << one << endl;
- cout << z << endl;
- for (int i = 0; i < z; i++)
- data[i] = one;
- }
- /* {
- int i = 0;
- int c = 0;
- int j = 0;
- while (one[i] != 0)
- {
- data[c][j] = one[i];
- if (one[i] == '\n')
- {
- data[c][j] = 0;
- c++;
- j = 0;
- }
- i++;
- j++;
- }
- size = z;
- } */
- void show(string title) {
- cout << endl << "========= " << title << " MENU =============";
- cout << size;
- for (int i = 0; i < size; i++)
- {
- cout << endl << i + 1 << " - " << data[i];
- //cout << endl << data[i];
- }
- cout << endl << "===================================";
- }
- int choice()
- {
- int c;
- cout << endl << "Enter your choice number: ";
- cin >> c;
- return c;
- }
- };
- class Person
- {
- public:
- // write the data for class person
- int id;
- string name;
- char gender;
- int dob;
- string address;
- public:
- // define constructors
- Person()
- {
- id = 1;
- name = "person_name";
- gender = 'm';
- dob = 12345678;
- address = "qwerty";
- }
- Person(const Person& p)
- {
- }
- Person(int id, string name, char gender, int dob, string address)
- {
- }
- void print()
- {
- }
- };
- // use inheritance to make Patient class based on Person class
- class Patient :public Person
- {
- public:
- string illness;
- string admission_date;
- Patient() :Person()
- {
- }
- Patient(int id, string name, char gender, int dob, string address,
- string illness, string admission_date)
- : Person(id, name, gender, dob, address)
- {
- }
- Patient(const Patient& p) : Person(p.id, p.name, p.gender, p.dob, p.address)
- {
- }
- void print()
- {
- Person::print();
- }
- };
- // use inheritance to make Personel class based on Person class
- class Personnel :public Person
- {
- public:
- string staff_post;
- string staff_expertise;
- Personnel() :Person()
- {}
- Personnel(int id, string name, char gender, int dob, string address,
- string staff_post, string staff_expertise)
- : Person(id, name, gender, dob, address)
- {
- }
- Personnel(const Personnel& p) : Person(p.id, p.name, p.gender, p.dob, p.address)
- {
- }
- void print()
- {
- Person::print();
- }
- };
- class Hospital_Class
- {
- public:
- vector < Patient> pList;
- vector < Personnel> staffList;
- // adds a Patient to Plist
- void add(Patient p)
- {
- pList.push_back(p);
- cout << "Patient added to list" << endl;
- Sleep(900);
- }
- //adds a Personnel to stafflist
- void add(Personnel p2)
- {
- staffList.push_back(p2);
- }
- // saves personnel list into file
- void save(vector < Personnel> list)
- {
- ofstream personnelFile;
- }
- // saves patient list into file
- void save(vector < Patient> list)
- {
- }
- // update Patient list
- void update(vector <Patient> list)
- {
- }
- // update Personnel list
- void update(vector <Personnel> list)
- {
- }
- // display all data of patient list
- void display(vector< Patient> plist)
- {
- for (int i = 0; i < pList.size(); i++)
- {
- cout << "id = " << pList[i].id << endl;
- cout << "name = " << pList[i].name << endl;
- /* cout << "gender = " << pList[i].gender << endl;
- cout << "date of birth = " << pList[i].dob << endl;
- cout << "address = " << pList[i].address << endl;
- cout << "illness = " << pList[i].illness << endl;
- cout << "admission date = " << pList[i].admission_date << endl;*/
- }
- }
- // display all data of personnel list
- void display(vector< Personnel> list)
- {
- for (int i = 0; i < staffList.size(); i++)
- {
- cout << staffList[i].name << endl;
- }
- }
- // read an id and delete its information from both memory and database of patients
- void remove(vector <Patient> list)
- {
- }
- // read an id and delete its information from both memory and database of personnel
- void remove(vector <Personnel> list)
- {
- }
- // sets information of the Hopspital
- void ourinfoset()
- {
- }
- // displays information of the hospital
- void displayInfo()
- {
- }
- // reads information of patients and personnel from file and stores them in memory
- void initialize()
- {
- ifstream patientFile, personnelFile;
- Patient p;
- patientFile.open("Patient.txt");
- personnelFile.open("Personnel.txt");
- while (!patientFile.eof())
- {
- if (!(patientFile >> p.id)) break;
- if (!(patientFile >> p.name)) break;
- if (!(patientFile >> p.gender))break;
- if (!(patientFile >> p.dob))break;
- if (!(patientFile >> p.address))break;
- if (!(patientFile >> p.illness))break;
- if (!(patientFile >> p.admission_date))break;
- pList.push_back(p);
- }
- patientFile.close();
- Personnel p2;
- while (!personnelFile.eof())
- {
- if (!(personnelFile >> p2.id)) break;
- if (!(personnelFile >> p2.name))break;
- if (!(personnelFile >> p2.gender))break;
- if (!(personnelFile >> p2.dob)) break;
- if (!(personnelFile >> p2.address)) break;
- if (!(personnelFile >> p2.staff_post)) break;
- if (!(personnelFile >> p2.staff_expertise)) break;
- staffList.push_back(p2);
- }
- personnelFile.close();
- }
- // read data for a personnel from keyboard
- Personnel read(Personnel p)
- {
- cout << "Enter personnel id: ";
- cin >> p.id;
- cout << "Enter personnel name: ";
- cin >> p.name;
- /* cout << "Enter personnel gender: ";
- cin >> p.gender;
- cout << "Enter personnel date of birth (DDMMYYYY): ";
- cin >> p.dob;
- cout << "Enter personnel address: ";
- cin >> p.address;
- cout << "Enter personnel post: ";
- cin >> p.staff_post;
- cout << p.staff_post << endl;
- cout << "Enter personnel expertise: ";
- cin >> p.staff_expertise;
- cout << p.staff_expertise << endl;*/
- add(p);
- return p;
- }
- // read data for a patient from keyboard
- Patient read(Patient p)
- {
- cout << "Enter patient id: ";
- cin >> p.id;
- cout << p.id << endl;
- cout << "Enter patient name: ";
- cin >> p.name;
- cout << p.name << endl;
- /* cout << "Enter patient gender: ";
- cin >> p.gender;
- cout << p.gender << endl;
- cout << "Enter patient date of birth (DDMMYYYY): ";
- cin >> p.dob;
- cout << p.dob << endl;
- cout << "Enter patient address: ";
- cin >> p.address;
- cout << p.address << endl;
- cout << "Enter patient illness: ";
- cin >> p.illness;
- cout << p.illness << endl;
- cout << "Enter patient admission date (DDMMYYYY): ";
- cin >> p.admission_date;
- cout << p.admission_date << endl;*/
- add(p);
- return p;
- }
- void main_menu()
- {
- int Selection;
- string arr[] = { "Patient Management", "Personnel Management", "Display Information", "Setting", "Shutdown" };
- int size = sizeof(arr) / sizeof(arr[0]);
- Menu mainMenu(arr, size);
- do
- {
- clearScreen();
- mainMenu.show("HOSPITAL MANAGEMENT SYSTEM MAIN");
- Selection = mainMenu.choice();
- switch (Selection)
- {
- case 1: patientManagemnt(); break;
- case 2: personnelManegment(); break;
- case 3: displayInfo(); break;
- case 4: setting(); break;
- case 5: shutdown(0);
- default:
- cout << "Invalid input!\nPlease select correct option. \n";
- Sleep(900);
- cin.clear();
- cin.ignore(100, '\n');
- break;
- }
- } while (1);
- }
- void personnelManegment()
- {
- int Selection;
- string arr[] = { "Add", "Update", "Delete", "Display", "Back to Main Menu" };
- int size = sizeof(arr) / sizeof(arr[0]);
- Menu pMenu(arr, size);
- Personnel p;
- do {
- clearScreen();
- pMenu.show("PERSONEL MANAGEMENT PATIENT");
- Selection = pMenu.choice();
- switch (Selection)
- {
- case 1:
- read(p);
- break;
- case 2:
- update(staffList);
- break;
- case 3:
- remove(staffList);
- break;
- case 4:
- display(staffList);
- _getch();
- break;
- case 5: return;
- default:
- cout << "Invalid input!\nPlease select correct option. \n";
- Sleep(900);
- cin.clear();
- cin.ignore(100, '\n');
- break;
- }
- } while (1);
- }
- void patientManagemnt()
- {
- int Selection;
- string arr[] = { "Add", "Update", "Delete", "Display", "Back to Main Menu" };
- int size = sizeof(arr) / sizeof(arr[0]);
- Menu pMenu(arr, size);
- Patient p;
- do
- {
- clearScreen();
- pMenu.show("PATIENT MANAGEMENT");
- Selection = pMenu.choice();
- switch (Selection)
- {
- case 1:
- read(p);
- break;
- case 2:
- update(pList);
- break;
- case 3:
- remove(pList);
- break;
- case 4:
- display(pList);
- _getch();
- break;
- case 5: return;
- default:
- cout << "Invalid input!\nPlease select correct option. \n";
- Sleep(600);
- cin.clear();
- cin.ignore(100, '\n');
- break;
- }
- } while (1);
- }
- void setting()
- {
- int Selection;
- string arr[] = { "Set Hospital Information", "Back to Main Menu" };
- int size = sizeof(arr) / sizeof(arr[0]);
- Menu pMenu(arr, size);
- do {
- clearScreen();
- pMenu.show("HOSPITAL SETTIENG");
- Selection = pMenu.choice();
- switch (Selection)
- {
- case 1:
- ourinfoset();
- break;
- case 2: return;
- default:
- cout << "Invalid input!\nPlease select correct option. \n";
- Sleep(600);
- cin.clear();
- cin.ignore(100, '\n');
- break;
- }
- } while (1);
- }
- void clearScreen()
- {
- //system("CLS");
- };
- void shutdown(int x)
- {
- exit(x);
- }
- };
- int main()
- {
- Hospital_Class hospital;
- hospital.initialize();
- hospital.main_menu();
- }
Advertisement
Add Comment
Please, Sign In to add comment