SlideShare a Scribd company logo
#include<iostream>
#include<conio.h>
#include<fstream>
#include<cstring>
#include<stdlib.h>
using namespace std;
class password
{
string code;
public:
void get_password();
int verify_password(string);
};
void password::get_password()
{
cout << "Setting Up The P10 Hospital Management System.....n";
cout << "nPlease Choose A Password For Your System :";
START:
code.clear();
char ch;
int count = 0;
ch = _getch();
while (ch != 13)
{
if (ch == 8)
{
cout << "b b";
// code.pop_back();
}
if (ch != 8)
{
cout << "*";
code.push_back(ch);
}
ch = _getch();
count++;
}
if (count < 5)
{
cout << "nnYour Password Should Have Minimum Of 5
Characters!!!n";
cout << "n Please Choose A Password For Your System :";
goto START;
}
}
int password::verify_password(string pass)
{
if (pass == code)
return(1);
}
class doctor
{
int id;
int code;
char name[50];
int age;
char qualification[10];
char specilization[10];
int experience;
char state[50];
char city[50];
public:
//int id;
int get_ID();
void get_info();
void get_name();
void get_age();
void get_code();
void get_qualification();
void get_specilization();
void get_experience();
void get_state();
void get_city();
int verify_specilization(int opt,int flag);
void display_all(doctor d);
void display_info(doctor d);
void modify_info(doctor d, int number,int size);
};
void add_doctor_data();
int verify_alphabet(char* arr,int size);
void modify_doctor_data();
void delete_contents();
void delete_contents1();
void display();
void delete_doctor_data();
int display_doctor_data();
int doctor_number();
long int get_size_of_the_file();
int verify_alphabet(char* arr, int size)
{
int i = 0;
for (i = 0; i < size; i++)
{
if (isdigit(arr[i]))
{
return(1);
}
}
}
int doctor_number()
{
long int size;
size = get_size_of_the_file();
doctor d;
size = size / (sizeof(d));
return(size);
}
int doctor::verify_specilization(int opt,int flag)
{
if (opt == code)
{
flag++;
cout <<"n"<<"ID------------->t"<< get_ID();
return(flag);
}
else
{
return(flag);
}
}
int doctor::get_ID()
{
return(id);
}
void doctor::get_info()
{
cout << "nEnter Doctor's ID :";
cin >> id;
NAME:
cout << "nEnter Doctor's Name :";
cin.ignore();
cin.getline(name, 50);
int flag;
int size=strlen(name);
flag=verify_alphabet(name,size);
if (flag == 1)
{
cout << "nnName should consist of only alphabets or min of three
alphabets!!!n";
cout << "n";
system("PAUSE");
//goto NAME;
}
cout << "nEnter Doctor's Age :";
cin >> age;
QUALIFICATION:
cout << "nEnter Doctor's Qualification :";
cin.ignore();
cin.getline(qualification, 50);
size = strlen(qualification);
flag = verify_alphabet(qualification, size);
if (flag == 1)
{
cout << "nQualification should consist of only alphabets or min of
three alphabets!!!n";
cout << "n";
system("PAUSE");
goto QUALIFICATION;
}
SPECILIZATION:
cout << "nEnter Doctor's Specialization :";
cin.getline(specilization, 50);
size = strlen(specilization);
flag = verify_alphabet(specilization, size);
if (flag == 1)
{
cout << "nSpecilization should consist of only alphabets or min of
three alphabets!!!n";
cout << "n";
system("PAUSE");
goto SPECILIZATION;
}
cout <<
"*******************************************************************************
*";
cout << "ntttCodes For Various Specilizationsn";
cout <<
"*******************************************************************************
*";
cout << "n1.General Medicinen2.Cardiologyn3.Neurologyn4.ENTn";
cout <<
"*******************************************************************************
*";
cout << "nSelect The Code Basing On The Specilization :";
cin >> code;
cout <<
"*******************************************************************************
*";
cout << "nEnter Doctor's Experience :";
cin >> experience;
STATE:
cout << "nEnter Doctor's State :";
cin.ignore();
cin.getline(state, 30);
size = strlen(state);
flag = verify_alphabet(state, size);
if (flag == 1)
{
cout << "nState should consist of only alphabets or min of three
alphabets!!!n";
cout << "n";
system("PAUSE");
goto STATE;
}
CITY:
cout << "nEnter Doctor's City :";
cin.getline(city, 30);
size = strlen(city);
flag = verify_alphabet(city, size);
if (flag == 1)
{
cout << "nCity should consist of only alphabets!!! or min of three
alphabetsn";
cout << "n";
system("PAUSE");
goto CITY;
}
}
void doctor::get_name()
{
NAME:
cin.ignore();
cout << "nEnter New Name :";
cin >> name;
int flag;
int size = strlen(name);
flag = verify_alphabet(name, size);
if (flag == 1)
{
cout << "nName should consist of only alphabets or min of three
alphabets!!!n";
cout << "n";
system("PAUSE");
goto NAME;
}
}
void doctor::get_age()
{
cin.ignore();
cout << "nEnter New Age :";
cin >> age;
}
void doctor::get_qualification()
{
QUALIFICATION:
cin.ignore();
cout << "nEnter New Qualification :";
cin >> specilization;
int flag;
int size = strlen(qualification);
flag = verify_alphabet(qualification, size);
if (flag == 1)
{
cout << "nQualification should consist of only alphabets or min of
three alphabets!!!n";
cout << "n";
system("PAUSE");
goto QUALIFICATION;
}
}
void doctor::get_specilization()
{
SPECILIZATION:
cin.ignore();
cout << "nEnter New Specilization :";
cin >> specilization;
int flag;
int size = strlen(specilization);
flag = verify_alphabet(specilization, size);
if (flag == 1)
{
cout << "nSpecilization should consist of only alphabets or min of
three alphabets!!!n";
cout << "n";
system("PAUSE");
goto SPECILIZATION;
}
cout <<
"*******************************************************************************
*";
cout << "nCodes For Various Specilizationsn";
cout <<
"*******************************************************************************
*";
cout << "n1.General Medicinen2.Cardiologyn3.Neurologyn4.ENTn";
cout <<
"*******************************************************************************
*";
cout << "nSelect The Code Basing On The Specilization ";
cin >> code;
}
void doctor::get_experience()
{
cin.ignore();
cout << "nEnter New Experience :";
cin >> experience;
}
void doctor::get_state()
{
STATE:
cin.ignore();
cout << "nEnter New State :";
cin >> state;
int flag;
int size = strlen(state);
flag = verify_alphabet(state, size);
if (flag == 1)
{
cout << "nState should consist of only alphabets or min of three
alphabets!!!n";
cout << "n";
system("PAUSE");
goto STATE;
}
}
void doctor::get_city()
{
CITY:
cin.ignore();
cout << "nEnter New City :";
cin >> city;
int flag;
int size = strlen(city);
flag = verify_alphabet(city, size);
if (flag == 1)
{
cout << "nCity should consist of only alphabets(or)min of three
alphabets!!!n";
cout << "n";
system("PAUSE");
goto CITY;
}
}
void doctor::display_info(doctor d)
{
cout << "nDoctor's ID :t "<< d.id;
cout << "nDoctor's Name :t" << d.name;
cout << "nDoctor's Age :t" << d.age;
cout << "nDoctor's Qualification :t" << d.qualification;
cout << "nDoctor's Specilization :t" << d.specilization;
cout << "nDoctor's Experience :t" << d.experience;
cout << "nDoctor's State :t" << d.state;
cout << "nDoctor's City :t" << d.city;
}
void doctor::display_all(doctor d)
{
cout <<"t"<< d.id << "tt" << d.specilization << "ttt" <<
d.qualification << "ttt" << d.age<<"n";
}
void doctor::modify_info(doctor d, int number,int size)
{
if (number == 1)
{
fstream myfile6("doctor8.txt",ios::in|ios::out);
doctor d1 = d;
d1.get_name();
myfile6.seekp(size, ios::beg);
myfile6.write((char*)&d1, sizeof(d1));
cout << "n";
cout << "n";
system("PAUSE");
system("CLS");
cout << "nData Successfully Modifiedn";
myfile6.close();
cout << " n";
system("PAUSE");
}
else if (number == 2)
{
fstream myfile6("doctor8",ios::in|ios::out);
doctor d1 = d;
d1.get_age();
myfile6.seekp(size,ios::beg);
myfile6.write((char*)&d1, sizeof(d1));
system("PAUSE");
system("CLS");
cout << "nData Successfully Modifiedn";
myfile6.close();
cout << "n";
system("PAUSE");
}
else if (number == 3)
{
fstream myfile6("doctor8.txt", ios::in | ios::out);
doctor d1 = d;
d1.get_qualification();
myfile6.seekp(size, ios::beg);
myfile6.write((char*)&d1, sizeof(d1));
system("PAUSE");
system("CLS");
cout << "nData Successfully Modifiedn";
myfile6.close();
cout << "n";
system("PAUSE");
}
else if (number == 4)
{
fstream myfile6("doctor8.txt", ios::in | ios::out);
doctor d1 = d;
d1.get_specilization();
myfile6.seekp(size, ios::beg);
myfile6.write((char*)&d1, sizeof(d1));
system("PAUSE");
system("CLS");
cout << "nData Successfully Modifiedn";
myfile6.close();
cout << "n";
system("PAUSE");
}
else if (number == 5)
{
fstream myfile6("doctor8.txt", ios::in | ios::out);
doctor d1 = d;
d1.get_experience();
myfile6.seekp(size, ios::beg);
myfile6.write((char*)&d1, sizeof(d1));
system("PAUSE");
system("CLS");
cout << "nData Successfully Modifiedn";
myfile6.close();
cout << "n";
system("PAUSE");
}
else if (number == 6)
{
fstream myfile6("doctor8.txt", ios::in | ios::out);
doctor d1 = d;
d1.get_state();
myfile6.seekp(size, ios::beg);
myfile6.write((char*)&d1, sizeof(d1));
system("PAUSE");
system("CLS");
cout << "nData Successfully Modifiedn";
myfile6.close();
cout << "n";
system("PAUSE");
}
else if (number == 7)
{
fstream myfile6("doctor8.txt", ios::in | ios::out);
doctor d1 = d;
d1.get_city();
myfile6.seekp(size, ios::beg);
myfile6.write((char*)&d1, sizeof(d1));
system("PAUSE");
system("CLS");
cout << "nData Successfully Modifiedn";
myfile6.close();
cout << "n";
system("PAUSE");
}
}
class patient
{
int id;
int doc_id;
char name[50];
int age;
char occupation[30];
char state[10];
char symptoms[70];
char disease[50];
char city[10];
char consultation_date[30];
char nationality[20];
char phone_no[20];
char street[30];
char door_no[20];
char condition[30];
char date_admitted[20];
char date_discharged[20];
char discharge_condition[50];
int bill;
public:
int get_ID();
void set_doc_ID();
void get_info();
void get_name();
void get_age();
void get_occupation();
void get_state();
void get_city();
void get_phone_no();
void get_nationality();
void get_street();
void get_door_no();
void get_condition();
void report1(patient);
void get_discharge_condition();
void get_date_admitted();
void get_date_discharged();
void get_bill();
void bill1(patient);
void assign_patient_to_doctor(patient p, int size);
void display_all(patient p);
void display_info(patient p);
void modify_info(patient p, int number, int size);
};
void add_patient_data();
void modify_patient_data();
void delete_patient_data();
void assign_patient();
void display1();
void report();
void bill();
int display_patient_data();
int number();
long int get_size_of_the_file1();
void patient::bill1(patient p)
{
system("CLS");
int total;
cout <<
"*******************************************************************************
*";
cout << "nnttttPatient Fee Chargenn ";
cout <<
"*******************************************************************************
";
cout << "nHospital Room Charges :t 1000";
cout << "nHospital Care Charges :t 500";
cout << "nHospital Maintaince Charges :t 500";
cout << "nPatient Individual Charges :t " << p.bill;
total = 1000 + 500 + 500 + p.bill;
cout << "nTotal Fee Charge :t" <<
total<<"n";
cout <<
"*******************************************************************************
*";
}
void patient::report1(patient p)
{
system("CLS");
cout <<
"*******************************************************************************
*";
cout << "ntttPatient Reportn";
cout <<
"*******************************************************************************
*";
cout << "nPatient Name :"
<< p.name;
cout << "nPatient Age :"
<< p.age;
cout << "nPatient Symptoms :"
<< p.symptoms;
cout << "nPatient Disease :"
<< p.disease;
cout << "nPatient Admission Date :"
<< p.date_admitted;
cout << "nPatient Discharge Date :"
<< p.date_discharged;
cout << "nPatient Condition At The Time Of Discharge :"
<< p.discharge_condition;
cout << "npatient Consulation Date :"
<< p.consultation_date;
cout << "n";
cout <<
"*******************************************************************************
*";
}
int patient::get_ID()
{
return(id);
}
void patient::set_doc_ID()
{
cout << "nPlease Select Your Choice :";
cin >> doc_id;
}
void patient::get_info()
{
cout << "nEnter Patient's ID :";
cin >> id;
NAME:
cout << "nEnter Patient's Name :";
cin.ignore();
cin.getline(name, 50);
int flag;
int size = strlen(name);
flag = verify_alphabet(name, size);
if (flag == 1)
{
cout << "nnName should consist of only alphabets or min of three
alphabets!!!n";
cout << "n";
system("PAUSE");
goto NAME;
}
cout << "nEnter Patient's Age :";
cin >> age;
OCCUPATION:
cout << "nEnter Patient's Occupation :";
cin.ignore();
cin.getline(occupation, 30);
size = strlen(occupation);
flag = verify_alphabet(occupation, size);
if (flag == 1)
{
cout << "nnOccupation should consist of only alphabets or min of
three alphabets!!!n";
cout << "n";
system("PAUSE");
goto OCCUPATION;
}
STATE:
cout << "nEnter Patient's state :";
cin.getline(state, 30);
size = strlen(state);
flag = verify_alphabet(state, size);
if (flag == 1)
{
cout << "nnState should consist of only alphabets or min of three
alphabets!!!n";
cout << "n";
system("PAUSE");
goto STATE;
}
CITY:
cout << "nEnter Patient's City :";
cin.getline(city, 30);
size = strlen(city);
flag = verify_alphabet(city, size);
if (flag == 1)
{
cout << "nnCity should consist of only alphabets or min of three
alphabets!!!n";
cout << "n";
system("PAUSE");
goto CITY;
}
NATIONALITY:
cout << "nEnter Patient's Nationality :";
cin.getline(nationality, 30);
size = strlen(nationality);
flag = verify_alphabet(nationality, size);
if (flag == 1)
{
cout << "nnNationality should consist of only alphabets or min of
three alphabets!!!n";
cout << "n";
system("PAUSE");
goto NATIONALITY;
}
cout << "nEnter Patient's Phone Number :";
cin.getline(phone_no, 20);
cout << "nEnter Patient's Street Name :";
cin.getline(street, 30);
cout << "nEnter Patient's Symptoms :";
cin.getline(symptoms, 70);
cout << "nEnter Patient's Disease :";
cin.getline(disease, 30);
cout << "nEnter Patient's Door Number :";
cin.getline(door_no, 20);
cout << "nEnter Patient's Condition :";
cin.getline(condition, 30);
cout << "nEnter Admission Date Of The Patient :";
cin.getline(date_admitted, 20);
cout << "nEnter Discharge Date Of The Patient :";
cin.getline(date_discharged, 20);
cout << "nEnter Condition Of The Patient At The Time Of The Discharge :";
cin.getline(discharge_condition, 50);
cout << "nEnter The Patient's Next Consultation Date :";
cin.getline(consultation_date, 30);
cout << "nEnter The Patient's Bill
Charges :";
cin >> bill;
}
void patient::assign_patient_to_doctor(patient p, int size)
{
long int size1 = size;
ifstream myfile1("doctor8.txt");
size = get_size_of_the_file();
doctor d;
size = size / (sizeof(d));
cout <<
"*******************************************************************************
*";
cout << "nt The Following Are The Specilizations Available In The
Hospitaln";
cout <<
"*******************************************************************************
*";
cout << "n1.General Medicinen2.Cardiologyn3.Neurologyn4.ENTn";
cout <<
"*******************************************************************************
*";
cout << "nnPlease Select Your Choice :";
int opt,flag=0;
int cho;
cin >> opt;
myfile1.seekg(0);
switch (opt)
{
case 1:
system("CLS");
cout <<
"*******************************************************************************
*";
cout << "nttID's Of The Doctors With The General Medicine
Specilizationn";
cout <<
"*******************************************************************************
*";
for (int i = 0; i < size; i++)
{
cout << "n";
myfile1.read((char*)&d, sizeof(d));
flag = d.verify_specilization(opt,flag);
}
myfile1.close();
if (flag == 0)
{
system("CLS");
cout <<
"*******************************************************************************
*";
cout << "nSorry!No Doctors Are Available With The Required
Specilizationn";
cout <<
"*******************************************************************************
*";
cout << "nn";
system("PAUSE");
}
else
{
cout << "n";
cout <<
"*******************************************************************************
****";
fstream myfile6("patient11.txt", ios::in | ios::out);
patient p1 = p;
myfile6.seekp(0);
myfile6.seekg(0);
p1.set_doc_ID();
myfile6.seekp(size1, ios::beg);
myfile6.write((char*)&p1, sizeof(p1));
system("CLS");
cout << "nPatient Has Been Assigned A Doctor Successfully";
cout << "n";
cout <<
"n*****************************************************************************
";
cout << "nn";
system("PAUSE");
}
break;
case 2:
system("CLS");
cout <<
"*******************************************************************************
*";
cout << "nttID's Of The Doctors With The Cardiology
Specilizationn";
cout <<
"*******************************************************************************
*";
for (int i = 0; i < size; i++)
{
cout << "n";
myfile1.read((char*)&d, sizeof(d));
flag = d.verify_specilization(opt,flag);
}
if (flag == 0)
{
system("CLS");
cout <<
"*******************************************************************************
*";
cout << "nSorry!No Doctors Are Available With The Required
Specilizationn";
cout <<
"*******************************************************************************
*";
cout << "nn";
system("PAUSE");
}
else
{
cout << "n";
cout <<
"*******************************************************************************
*";
fstream myfile6("patient11.txt", ios::in | ios::out);
patient p1 = p;
myfile6.seekp(0);
myfile6.seekg(0);
p1.set_doc_ID();
myfile6.seekp(size1, ios::beg);
myfile6.write((char*)&p1, sizeof(p1));
system("CLS");
cout << "nPatient Has Been Assigned A Doctor Successfully";
cout << "n";
cout <<
"n*****************************************************************************
";
cout << "nn";
system("PAUSE");
}
break;
case 3:
system("CLS");
cout <<
"*******************************************************************************
*";
cout << "nttID's Of The Doctors With The Neurology
Specilizationn";
cout <<
"*******************************************************************************
*";
for (int i = 0; i < size; i++)
{
cout << "n";
myfile1.read((char*)&d, sizeof(d));
flag = d.verify_specilization(opt,flag);
}
if (flag == 0)
{
system("CLS");
cout <<
"*******************************************************************************
*";
cout << "nSorry!No Doctors Are Available With The Required
Specilizationn";
cout <<
"*******************************************************************************
*";
cout << "nn";
system("PAUSE");
}
else
{
cout << "n";
cout <<
"*******************************************************************************
*";
fstream myfile6("patient11.txt", ios::in | ios::out);
patient p1 = p;
myfile6.seekp(0);
myfile6.seekg(0);
p1.set_doc_ID();
myfile6.seekp(size1, ios::beg);
myfile6.write((char*)&p1, sizeof(p1));
system("CLS");
cout << "nPatient Has Been Assigned A Doctor Successfully";
cout << "n";
cout <<
"n*****************************************************************************
";
cout << "nn";
system("PAUSE");
}
break;
case 4:
system("CLS");
cout <<
"*******************************************************************************
*";
cout << "nttID's Of The Doctors With The ENT Specilizationn";
cout <<
"*******************************************************************************
*";
for (int i = 0; i < size; i++)
{
cout << "n";
myfile1.read((char*)&d, sizeof(d));
flag = d.verify_specilization(opt,flag);
}
if (flag == 0)
{
system("CLS");
cout <<
"*******************************************************************************
*";
cout << "nSorry!No Doctors Are Available With The Required
Specilizationn";
cout <<
"*******************************************************************************
*";
cout << "nn";
system("PAUSE");
}
else
{
cout << "n";
cout <<
"*******************************************************************************
*";
fstream myfile6("patient11.txt", ios::in | ios::out);
patient p1 = p;
myfile6.seekp(0);
myfile6.seekg(0);
p1.set_doc_ID();
myfile6.seekp(size1, ios::beg);
myfile6.write((char*)&p1, sizeof(p1));
system("CLS");
cout << "nPatient Has Been Assigned A Doctor Successfully";
cout << "n";
cout <<
"n*****************************************************************************
";
cout << "nn";
system("PAUSE");
}
break;
default:
cout << "nWrong Choice!!!";
}
}
void patient::get_name()
{
cout << "nEnter New Name :";
cin.ignore();
cin.getline(name, 50);
}
void patient::get_age()
{
cout << "nEnter New Age :";
cin.ignore();
cin >> age;
}
void patient::get_occupation()
{
cout << "nEnter New Occupation :";
cin.ignore();
cin.getline(occupation, 50);
}
void patient::get_state()
{
cin.ignore();
cout << "nEnter New State :";
cin.getline(state, 20);
}
void patient::get_city()
{
cin.ignore();
cout << "nEnter New City :";
cin.getline(city, 20);
}
void patient::get_phone_no()
{
cin.ignore();
cout << "nEnter New Phone Number :";
cin.getline(phone_no, 30);
}
void patient::get_nationality()
{
cin.ignore();
cout << "nEnter New Nationality :";
cin.getline(nationality, 30);
}
void patient::get_street()
{
cin.ignore();
cout << "nEnter New Street :";
cin.getline(street, 50);
}
void patient::get_door_no()
{
cin.ignore();
cout << "nEnter New Door Number :";
cin.getline(door_no, 30);
}
void patient::get_condition()
{
cin.ignore();
cout << "nEnter New Condition :";
cin.getline(condition, 50);
}
void patient::get_discharge_condition()
{
cin.ignore();
cout << "nEnter New Condition Of The Patient At The Time Of Discharge :";
cin.getline(discharge_condition, 50);
}
void patient::get_date_admitted()
{
cin.ignore();
cout << "nEnter New Admission Date Of The Patient :";
cin.getline(date_admitted, 30);
}
void patient::get_date_discharged()
{
cin.ignore();
cout << "nEnter New Discharge Date Of The Patient :";
cin.getline(date_discharged, 30);
}void patient::get_bill()
{
cin.ignore();
cout << "nEnter New Bill Charge Of The Patient :";
cin >> bill;
}
void patient::display_all(patient p)
{
cout << p.id << "t" << p.age << "t" << p.symptoms << "t" <<
p.date_admitted << "ttt"<<p.doc_id<<"n";
}
void patient::display_info(patient p)
{
cout << "nPatient's ID :" << p.id;
cout << "nPatient's Name :" <<
p.name;
cout << "nPatient's Age :" << p.age;
cout << "nPatient's Occupation :" <<
p.occupation;
cout << "nPatient's State :" <<
p.state;
cout << "nPatient's City :" <<
p.city;
cout << "nPatient's Phone Number :" <<
p.phone_no;
cout << "nPatient's Nationality :" <<
p.nationality;
cout << "nPatient's Street :" <<
p.street;
cout << "nPatient's Door Number :" <<
p.door_no;
cout << "nPatient's Condtion :" <<
p.condition;
cout << "nPatient's Condition At The Time Of Discharge :" <<
p.discharge_condition;
cout << "nPatient's Admission Date :" <<
p.date_admitted;
cout << "nPatient's Discharge Date :" <<
p.date_discharged;
cout << "nID Of The Doctor Who Is Treating The Patient :" <<
p.doc_id;
}
void patient::modify_info(patient p, int number, int size)
{
if (number == 1)
{
fstream myfile6("patient11.txt", ios::in | ios::out);
patient p1 = p;
p1.get_name();
myfile6.seekp(size, ios::beg);
myfile6.write((char*)&p1, sizeof(p1));
int total = myfile6.tellp();
total /= sizeof(p1);
cout << "nn";
system("PAUSE");
system("CLS");
cout << "nData Successfully Modifiedn";
myfile6.close();
cout << "n";
system("PAUSE");
}
else if (number == 2)
{
fstream myfile6("patient11.txt", ios::in | ios::out);
patient p1 = p;
p1.get_age();
myfile6.seekp(size, ios::beg);
myfile6.write((char*)&p1, sizeof(p1));
int total = myfile6.tellp();
total /= sizeof(p1);
cout << "nn";
system("PAUSE");
system("CLS");
cout << "nData Successfully Modifiedn";
myfile6.close();
cout << "n";
system("PAUSE");
}
else if (number == 3)
{
fstream myfile6("patient11.txt", ios::in | ios::out);
patient p1 = p;
p1.get_occupation();
myfile6.seekp(size, ios::beg);
myfile6.write((char*)&p1, sizeof(p1));
int total = myfile6.tellp();
total /= sizeof(p1);
cout << "nn";
system("PAUSE");
system("CLS");
cout << "nData Successfully Modifiedn";
myfile6.close();
cout << "n";
system("PAUSE");
}
else if (number == 4)
{
fstream myfile6("patient11.txt", ios::in | ios::out);
patient p1 = p;
p1.get_state();
myfile6.seekp(size, ios::beg);
myfile6.write((char*)&p1, sizeof(p1));
int total = myfile6.tellp();
total /= sizeof(p1);
cout << "nn";
system("PAUSE");
system("CLS");
cout << "nData Successfully Modifiedn";
myfile6.close();
cout << "n";
system("PAUSE");
}
else if (number == 5)
{
fstream myfile6("patient11.txt", ios::in | ios::out);
patient p1 = p;
p1.get_city();
myfile6.seekp(size, ios::beg);
myfile6.write((char*)&p1, sizeof(p1));
int total = myfile6.tellp();
total /= sizeof(p1);
cout << "nn";
system("PAUSE");
system("CLS");
cout << "nData Successfully Modifiedn";
myfile6.close();
cout << "n";
system("PAUSE");
}
else if (number == 6)
{
fstream myfile6("patient11.txt", ios::in | ios::out);
patient p1 = p;
p1.get_phone_no();
myfile6.seekp(size, ios::beg);
myfile6.write((char*)&p1, sizeof(p1));
int total = myfile6.tellp();
total /= sizeof(p1);
cout << "nn";
system("PAUSE");
system("CLS");
cout << "nData Successfully Modifiedn";
myfile6.close();
cout << "n";
system("PAUSE");
}
else if (number == 7)
{
fstream myfile6("patient11.txt", ios::in | ios::out);
patient p1 = p;
p1.get_nationality();
myfile6.seekp(size, ios::beg);
myfile6.write((char*)&p1, sizeof(p1));
int total = myfile6.tellp();
total /= sizeof(p1);
cout << "nn";
system("PAUSE");
system("CLS");
cout << "nData Successfully Modifiedn";
myfile6.close();
cout << "n";
system("PAUSE");
}
else if (number == 8)
{
fstream myfile6("patient11.txt", ios::in | ios::out);
patient p1 = p;
p1.get_street();
myfile6.seekp(size, ios::beg);
myfile6.write((char*)&p1, sizeof(p1));
int total = myfile6.tellp();
total /= sizeof(p1);
cout << "nn";
system("PAUSE");
system("CLS");
cout << "nData Successfully Modifiedn";
myfile6.close();
cout << "n";
system("PAUSE");
}
else if (number == 9)
{
fstream myfile6("patient11.txt", ios::in | ios::out);
patient p1 = p;
p1.get_door_no();
myfile6.seekp(size, ios::beg);
myfile6.write((char*)&p1, sizeof(p1));
int total = myfile6.tellp();
total /= sizeof(p1);
cout << "nn";
system("PAUSE");
system("CLS");
cout << "nData Successfully Modifiedn";
myfile6.close();
cout << "n";
system("PAUSE");
}
else if (number == 10)
{
fstream myfile6("patient11.txt", ios::in | ios::out);
patient p1 = p;
p1.get_condition();
myfile6.seekp(size, ios::beg);
myfile6.write((char*)&p1, sizeof(p1));
int total = myfile6.tellp();
total /= sizeof(p1);
cout << "nn";
system("PAUSE");
system("CLS");
cout << "nData Successfully Modifiedn";
myfile6.close();
cout << "n";
system("PAUSE");
}
else if (number == 11)
{
fstream myfile6("patient11.txt", ios::in | ios::out);
patient p1 = p;
p1.get_discharge_condition();
myfile6.seekp(size, ios::beg);
myfile6.write((char*)&p1, sizeof(p1));
int total = myfile6.tellp();
total /= sizeof(p1);
cout << "nn";
system("PAUSE");
system("CLS");
cout << "nData Successfully Modifiedn";
myfile6.close();
cout << "n";
system("PAUSE");
}
else if (number == 12)
{
fstream myfile6("patient11.txt", ios::in | ios::out);
patient p1 = p;
p1.get_date_admitted();
myfile6.seekp(size, ios::beg);
myfile6.write((char*)&p1, sizeof(p1));
int total = myfile6.tellp();
total /= sizeof(p1);
cout << "nn";
system("PAUSE");
system("CLS");
cout << "nData Successfully Modifiedn";
myfile6.close();
cout << "n";
system("PAUSE");
}
else if (number == 13)
{
fstream myfile6("patient11.txt", ios::in | ios::out);
patient p1 = p;
p1.get_date_discharged();
myfile6.seekp(size, ios::beg);
myfile6.write((char*)&p1, sizeof(p1));
int total = myfile6.tellp();
total /= sizeof(p1);
cout << "nn";
system("PAUSE");
system("CLS");
cout << "nData Successfully Modifiedn";
myfile6.close();
cout << "n";
system("PAUSE");
}
else if (number == 14)
{
fstream myfile6("patient11.txt", ios::in | ios::out);
patient p1 = p;
p1.get_bill();
myfile6.seekp(size, ios::beg);
myfile6.write((char*)&p1, sizeof(p1));
int total = myfile6.tellp();
total /= sizeof(p1);
cout << "nn";
system("PAUSE");
system("CLS");
cout << "nData Successfully Modifiedn";
myfile6.close();
cout << "n";
system("PAUSE");
}
}
int main()
{
int counter = 0,y=0;
password p;
p.get_password();
system("CLS");
START1:
system("CLS");
cout <<
"*******************************************************************************
*n";
cout << "nttWELCOME TO P10 HOSPITAL MANAGEMENT SYSTEMnn";
cout <<
"*******************************************************************************
*n";
cout << "ntttt1.Main Menun";
cout << "ntttt2.Shut Downnn";
cout <<
"*******************************************************************************
*n";
int op,ch,count=0,x;
char c;
string pass;
cout << "nPlease Enter Your Choice :";
cin >> op;
cout << "nn";
system("PAUSE");
START3:
switch (op)
{
case 1:
system("CLS");
cout <<
"*******************************************************************************
*n";
cout << "ttttMain Menunn";
cout <<
"*******************************************************************************
*n";
cout << "nntt1.Enter Into Doctor's Databasen";
cout << "ntt2.Enter into Patient's Databasen";
cout << "ntt3.Generate Patient's Reportn";
cout << "ntt4.Generate Patient's Billsn";
cout << "ntt5.Exitnn";
cout <<
"*******************************************************************************
*";
cout << "nntPlease Choose Your Choice :";
cin >> ch;
switch (ch)
{
case 1:
system("CLS");
START2:
count++;
cout << "nPlease Enter Your Password To Enter Into This
Database :";
pass.clear();
c = _getch();
while (c != 13)
{
if (c == 8)
cout << "b b";
if (c != 8)
{
cout << "*";
pass.push_back(c);
}
c = _getch();
}
x = p.verify_password(pass);
if (x == 1)
{
cout << "nnAccess Granted ";
cout << "nn";
system("PAUSE");
system("CLS");
while (1)
{
system("CLS");
cout <<
"*******************************************************************************
*n";
cout << "ntttWelcome to Doctor's Databasen";
cout <<
"n*****************************************************************************
***n";
cout << "ntt1.Add New Doctor's Informationn";
cout << "ntt2.Edit Doctor's Informationn";
cout << "ntt3.Display Doctor's Informationn";
cout << "ntt4.Delete Doctor's Informationn";
cout << "ntt5.Number Of Doctors In The
Hospitaln";
cout << "ntt6.Clear All The Information In The
Databasen";
cout << "ntt7.Display The Details Of All The
Doctorsn";
cout << "ntt8.Exitn";
cout <<
"n*****************************************************************************
***n";
int opt;
cout << "Please Choose Your Choice :";
cin >> opt;
int y;
switch (opt)
{
case 1:
system("CLS");
add_doctor_data();
break;
case 2:
system("CLS");
modify_doctor_data();
break;
case 3:
system("CLS");
y = display_doctor_data();
if (y != 1)
{
cout << "nNo Record To
Display!!!n";
cout << "n";
system("PAUSE");
}
break;
case 4:
system("CLS");
delete_doctor_data();
cout << "n";
system("PAUSE");
break;
case 5:
system("CLS");
cout << "nNumber Of Doctors In The Hospital
are :" << doctor_number();
cout << "nn";
system("PAUSE");
break;
case 6:
system("CLS");
delete_contents();
cout << "nAll The Contents Of The Database
Are Deleted ";
cout << "nn";
system("PAUSE");
break;
case 7:
system("CLS");
display();
cout << "nn";
system("PAUSE");
break;
case 8:
system("CLS");
goto START3;
_getch();
break;
}
}
}
else
{
if (count >= 3)
{
system("CLS");
cout << "nnAccess Denied!!!You Have Entered
Wrong Password Too Many Timesn";
cout << "nThis System Will Shut Down.Please Come
Back Againn";
cout << "nThank Youn";
cout << "n";
system("PAUSE");
exit(0);
}
cout << "nnWrong Password.Access Denied!!!n";
goto START2;
}
case 2:
system("CLS");
START4:
count++;
cout << "nPlease Enter Your Password To Enter Into This
Database :";
pass.clear();
c = _getch();
while (c != 13)
{
if (c == 8)
{
cout << "b b";
//pass.pop_back(c);
}
if (c != 8)
{
cout << "*";
pass.push_back(c);
}
c = _getch();
}
x = p.verify_password(pass);
if (x == 1)
{
cout << "nnAccess Granted ";
cout << "nn";
system("PAUSE");
system("CLS");
while (1)
{
system("CLS");
cout <<
"*******************************************************************************
*n";
cout << "ntttWelcome To Patient's
Databasenn";
cout <<
"*******************************************************************************
*n";
cout << "ntt1.Add Patient's Informationn";
cout << "ntt2.Assign A Patient To A Doctorn";
cout << "ntt3.Edit Patient's Informationn";
cout << "ntt4.Display Patient's Informationn";
cout << "ntt5.Delete Patient's Informationn";
cout << "ntt6.No.Of Patients In The
Hospitaln";
cout << "ntt7.Delete All The Contents In The
Databasen";
cout << "ntt8.Display The Details Of All The
Patients In The Hospitaln";
cout << "ntt9.Exitnn";
cout <<
"*******************************************************************************
*n";
int opt;
cout << "nPlease Choose Your Choice :";
cin >> opt;
int y;
switch (opt)
{
case 1:
system("CLS");
add_patient_data();
break;
case 2:
system("CLS");
assign_patient();
break;
case 3:
system("CLS");
modify_patient_data();
break;
case 4:
system("CLS");
y = display_patient_data();
if (y != 1)
{
cout << "nNo Record To Display!!!n";
cout << "n";
system("PAUSE");
}
break;
case 5:
system("CLS");
delete_patient_data();
cout << "n";
system("PAUSE");
break;
case 6:
system("CLS");
cout << "nNo.Of Patient's In The Hospital
are :" << number();
cout << "nn";
system("PAUSE");
break;
case 7:
system("CLS");
delete_contents1();
cout << "nAll The Contents Of The Database
Are Deleted";
cout << "nn";
system("PAUSE");
break;
case 8:
system("CLS");
display1();
cout << "nn";
system("PAUSE");
break;
case 9:
system("CLS");
goto START3;
_getch();
}
}
}
else
{
if (count >= 3)
{
system("CLS");
cout << "nnAccess Denied!!!You Have Entered
Wrong Password Too Many Timesn";
cout << "nThis System Will Shut Down.Please Come
Back Againn";
cout << "nThank Youn";
cout << "n";
system("PAUSE");
exit(0);
}
cout << "nnWrong Password.Access Denied!!!n";
goto START4;
}
case 3:
system("CLS");
cout << "nn";
report();
cout << "nn";
system("PAUSE");
goto START3;
break;
case 4:
system("CLS");
bill();
cout << "nn";
system("PAUSE");
system("CLS");
goto START3;
break;
case 5:
cout << "n";
cout << "n";
goto START1;
default:
cout << "nWrong Choice ";
}
break;
case 2:
cout << "nn";
exit(0);
break;
default:
cout << "nWrong Choice ";
}
_getch();
}
void add_doctor_data()
{
doctor d;
ofstream myfile("doctor8.txt",ios::in|ios::app);
d.get_info();
myfile.write((char*)&d, sizeof(d));
myfile.close();
}
void display()
{
long int size = 0;
size = get_size_of_the_file();
int i = 0;
doctor d;
size = size / (sizeof(d));
if (size == 0)
{
cout << "nDatabase Empty!!!";
cout << "n";
}
else
{
cout << "n" ;
cout <<
"*******************************************************************************
*";
cout << "ntttDetails Of All The Doctors In The
Hospitaln";
cout <<
"*******************************************************************************
*";
cout <<"nt"<< "ID" << "tt" << "Specilization" << "tt" <<
"Qualification" << "tt" << "Age" << "n";
ifstream myfile("doctor8.txt");
myfile.seekg(0);
for (i = 0; i < size; i++)
{
cout << "nn";
myfile.read((char*)&d, sizeof(d));
d.display_all(d);
}
cout <<
"*******************************************************************************
*";
}
}
int display_doctor_data()
{
long int size = 0;
size = get_size_of_the_file();
int i = 0, id, id1, count = 0;
doctor d1;
size = size / (sizeof(d1));
if (size == 0)
{
cout << "nDatabase Empty!!!";
cout << "n";
}
else
{
cout << "nEnter The ID Of the Doctor You require :";
cin >> id;
ifstream myfile1("doctor8.txt");
for (i = 0; i < size; i++)
{
myfile1.clear();
myfile1.read((char*)&d1, sizeof(d1));
id1 = d1.get_ID();
if (id == id1)
{
count = 1;
d1.display_info(d1);
cout << "n";
cout << "n";
system("PAUSE");
cout << "n";
break;
}
}
myfile1.close();
return(count);
}
}
void modify_doctor_data()
{
int id1;
long int size = 0;
size = get_size_of_the_file();
int i = 0, count = 0, id;
doctor d2;
size = size / (sizeof(d2));
if (size == 0)
{
cout << "nDatabase Empty!!!n";
cout << "nNo Record To Modify!!!";
cout << "nn";
system("PAUSE");
}
else
{
cout << "nEnter The ID Of The Doctor To Modify Data :";
cin >> id1;
ifstream myfile2("doctor8.txt");
for (i = 0; i < size; i++)
{
myfile2.clear();
myfile2.read((char*)&d2, sizeof(d2));
id = d2.get_ID();
if (id == id1)
{
size = myfile2.tellg();
size = size - sizeof(d2);
count = 1;
d2.display_info(d2);
cout << "nn";
system("PAUSE");
cout << "n";
cout << "nField's Which Can Be Modifiedn";
cout << "n1.Namen2.Agen3.Qualificationn";
cout <<
"4.Specilizationn5.Experiencen6.Staten";
cout << "7.Cityn";
int opt2;
cout << "nSelect The Field Which You Want To
Modify :";
cin >> opt2;
switch (opt2)
{
case 1:
d2.modify_info(d2, opt2, size);
break;
case 2:
d2.modify_info(d2, opt2, size);
break;
case 3:
d2.modify_info(d2, opt2, size);
break;
case 4:
d2.modify_info(d2, opt2, size);
break;
case 5:
d2.modify_info(d2, opt2, size);
break;
case 6:
d2.modify_info(d2, opt2, size);
break;
case 7:
d2.modify_info(d2, opt2, size);
break;
default:
cout << "nWrong Choice ";
}
break;
}
}
myfile2.close();
if (count == 0)
{
cout << "nRecord Does'nt Exist!!!";
cout << "n";
system("PAUSE");
}
}
}
void delete_contents()
{
ofstream myfile("doctor8.txt");
myfile.close();
}
void delete_contents1()
{
ofstream myfile("patient11.txt");
myfile.close();
}
void delete_doctor_data()
{
long int size;
size = get_size_of_the_file();
doctor d;
size = size / (sizeof(d));
if (size == 0)
{
cout << "nDatabase Empty!!!";
cout << "nnNo Record To Delete!!!";
cout << "n";
}
else
{
ifstream myfile6("doctor8.txt");
ofstream myfile7("temp1.txt");
int id, count = 0, id1, i;
cout << "nEnter The ID Of The Doctor Whose Data You Want To
Delete :";
cin >> id;
for (i = 0; i < size; i++)
{
myfile6.read((char*)&d, sizeof(d));
id1 = d.get_ID();
if (id != id1)
{
myfile7.write((char*)&d, sizeof(d));
}
else
{
count = 1;
}
}
myfile6.close();
myfile7.close();
ofstream myfile9("doctor8.txt");
ifstream myfile8("temp1.txt");
for (i = 0; i < size - 1; i++)
{
myfile8.read((char*)&d, sizeof(d));
myfile9.write((char*)&d, sizeof(d));
}
if (count == 0)
{
cout << "nNo Data Found ";
cout << "nn";
system("PAUSE");
}
else
{
cout << "nData Successfully Deletedn";
}
}
}
long int get_size_of_the_file()
{
long int size=0;
ifstream ifile("doctor8.txt");
ifile.seekg(0, ios::end);
size = ifile.tellg();
ifile.close();
return(size);
}
void add_patient_data()
{
patient p;
ofstream myfile("patient11.txt", ios::in | ios::app);
p.get_info();
myfile.write((char*)&p, sizeof(p));
myfile.close();
}
void display1()
{
long int size = 0;
size = get_size_of_the_file1();
int i = 0;
patient p;
size = size / (sizeof(p));
if (size == 0)
{
cout << "nDatabase Empty!!!";
cout << "n";
}
else
{
cout << "n";
cout <<
"*******************************************************************************
*";
cout << "ntttDetails Of All The Patients In The
Hospitaln";
cout <<
"*******************************************************************************
*";
cout <<"n" "ID" << "t" << "Age" << "t" << "Illness" <<
"tt" << "Date Admitted" << "tt"<<"Doctor's ID"<<"n";
ifstream myfile("patient11.txt");
myfile.seekg(0);
for (i = 0; i < size; i++)
{
cout << "nn";
myfile.read((char*)&p, sizeof(p));
p.display_all(p);
}
cout <<
"*******************************************************************************
*";
}
}
int display_patient_data()
{
long int size = 0;
size = get_size_of_the_file1();
int i = 0, id, id1, count1 = 0;
patient p1;
size = size / (sizeof(p1));
if (size == 0)
{
cout << "nDatabase Empty!!!";
cout << "n";
}
else
{
cout << "nEnter The ID Of The Patient You Require :";
cin >> id;
ifstream myfile1("patient11.txt");
for (i = 0; i < size; i++)
{
myfile1.clear();
myfile1.read((char*)&p1, sizeof(p1));
id1 = p1.get_ID();
if (id == id1)
{
count1 = 1;
p1.display_info(p1);
cout << "nn";
system("PAUSE");
cout << "n";
break;
}
}
myfile1.close();
return(count1);
}
}
void assign_patient()
{
patient p;
int id;
long int size;
size = get_size_of_the_file1();
int i = 0, count = 0, id1;
size = size / (sizeof(p));
if (size == 0)
{
cout << "n Database Empty!!!n";
cout << "nYou Need To Add Patient's Information First!!!";
cout << "nn";
system("PAUSE");
}
else
{
cout << "nEnter ID Of The Patient :";
cin >> id;
ifstream myfile("patient11.txt");
myfile.seekg(0);
for (i = 0; i < size; i++)
{
myfile.read((char*)&p, sizeof(p));
id1 = p.get_ID();
if (id == id1)
{
count = 1;
size = myfile.tellg();
size = size - sizeof(p);
p.assign_patient_to_doctor( p, size);
break;
}
}
if (count == 0)
{
system("CLS");
cout <<
"*******************************************************************************
*";
cout << "nSorry!No Data Is Available Related To The
Given IDn";
cout <<
"*******************************************************************************
*";
cout << "nn";
system("PAUSE");
}
}
}
void modify_patient_data()
{
int id1;
long int size = 0;
size = get_size_of_the_file1();
int i = 0, count = 0, id;
patient p2;
size = size / (sizeof(p2));
if (size == 0)
{
cout << "nDatabase Empty!!!n";
cout << "nNo Record To Modify!!!";
cout << "nn";
system("PAUSE");
}
else
{
cout << "nEnter The ID Of The Patient To Modify Data :";
cin >> id1;
ifstream myfile2("patient11.txt");
myfile2.seekg(0);
for (i = 0; i < size; i++)
{
myfile2.read((char*)&p2, sizeof(p2));
id = p2.get_ID();
if (id == id1)
{
size = myfile2.tellg();
size = size - sizeof(p2);
count = 1;
p2.display_info(p2);
cout << "n";
system("PAUSE");
cout << "n";
cout << "nField's Which Can Be Modifiedn";
cout <<
"n1.Namen2.Agen3.Occupationn4.Staten";
cout << "5.Cityn6.Phone Numbern7.Nationalityn";
cout << "n8.Streetn9.Door
Numbern10.Conditionn";
cout << "11.Discharge Conditionn12.Date
Admittedn";
cout << "13.Date Dischargedn14.Patient Bill";
int opt2;
cout << "nSelect The Field Which You Want To
Modify :";
cin >> opt2;
switch (opt2)
{
case 1:
p2.modify_info(p2, opt2, size);
break;
case 2:
p2.modify_info(p2, opt2, size);
break;
case 3:
p2.modify_info(p2, opt2, size);
break;
case 4:
p2.modify_info(p2, opt2, size);
break;
case 5:
p2.modify_info(p2, opt2, size);
break;
case 6:
p2.modify_info(p2, opt2, size);
break;
case 7:
p2.modify_info(p2, opt2, size);
break;
case 8:
p2.modify_info(p2, opt2, size);
break;
case 9:
p2.modify_info(p2, opt2, size);
break;
case 10:
p2.modify_info(p2, opt2, size);
break;
case 11:
p2.modify_info(p2, opt2, size);
break;
case 12:
p2.modify_info(p2, opt2, size);
break;
case 13:
p2.modify_info(p2, opt2, size);
break;
case 14:
p2.modify_info(p2, opt2, size);
break;
default:
cout << "nWrong Choice ";
}
break;
}
}
myfile2.close();
if (count == 0)
{
cout << "nRecord Does'nt Exist!!!";
cout << "n";
system("PAUSE");
}
}
}
void delete_patient_data()
{
long int size;
size = get_size_of_the_file1();
patient p;
size = size / (sizeof(p));
if (size == 0)
{
cout << "nDatabase Empty!!!";
cout << "nnNo Record To Delete!!!";
cout << "n";
}
else
{
ifstream myfile6("patient11.txt");
ofstream myfile7("temp4.txt");
int id, count = 0, id1, i;
cout << "nEnter The ID Of The Patient Whose Data You Want To
Delete :";
cin >> id;
for (i = 0; i < size; i++)
{
myfile6.read((char*)&p, sizeof(p));
id1 = p.get_ID();
if (id != id1)
{
myfile7.write((char*)&p, sizeof(p));
}
else
{
count = 1;
}
}
myfile6.close();
myfile7.close();
ofstream myfile9("patient11.txt");
ifstream myfile8("temp4.txt");
for (i = 0; i < size - 1; i++)
{
myfile8.read((char*)&p, sizeof(p));
myfile9.write((char*)&p, sizeof(p));
}
if (count == 0)
{
cout << "nNo Data Found ";
cout << "nn";
}
else
{
cout << "nData Successfully Deleted ";
cout << "nn";
}
}
}
long int get_size_of_the_file1()
{
long int size = 0;
ifstream ifile("patient11.txt");
ifile.seekg(0,ios::end);
size = ifile.tellg();
ifile.close();
return(size);
}
int number()
{
long int size;
patient p;
size = get_size_of_the_file1();
size = size / (sizeof(p));
return(size);
}
void report()
{
patient p;
int id, id1, count = 0;
long int size;
size = get_size_of_the_file1();
size = size / (sizeof(p));
if (size == 0)
{
cout << "nPatient Database Empty!!!";
cout << "nAdd Some Patient's Info First!!!";
cout << "nn";
system("PAUSE");
}
else
{
cout << "nEnter The ID Of The Patient You Require :";
cin >> id;
ifstream myfile1("patient11.txt");
for (int i = 0; i < size; i++)
{
myfile1.clear();
myfile1.read((char*)&p, sizeof(p));
id1 = p.get_ID();
if (id == id1)
{
count = 1;
p.report1(p);
break;
}
}
if (count == 0)
{
cout << "nData Not Available!!!";
}
}
}
void bill()
{
long int size = 0;
size = get_size_of_the_file1();
int i = 0, id, id1, count1 = 0;
patient p1;
size = size / (sizeof(p1));
if (size == 0)
{
cout << "nDatabase Empty!!!";
cout << "n";
}
else
{
cout << "nEnter The ID Of The Patient You Require :";
cin >> id;
ifstream myfile1("patient11.txt");
for (i = 0; i < size; i++)
{
myfile1.clear();
myfile1.read((char*)&p1, sizeof(p1));
id1 = p1.get_ID();
if (id == id1)
{
count1 = 1;
p1.bill1(p1);
break;
}
}
if (count1 == 0)
{
cout << "nData Not Found!!!";
}
myfile1.close();
}
}
Hospital management

More Related Content

TXT
c++ program for Canteen management
PPTX
A Test of Strength
PPTX
Why Sifu
TXT
c++ project on restaurant billing
DOCX
Student Data Base Using C/C++ Final Project
PPTX
JavaScript - i och utanför webbläsaren (2010-03-03)
PDF
寫程式?那些老師沒教的事 (Git 部分節錄)
PDF
寫程式?那些老師沒教的事
c++ program for Canteen management
A Test of Strength
Why Sifu
c++ project on restaurant billing
Student Data Base Using C/C++ Final Project
JavaScript - i och utanför webbläsaren (2010-03-03)
寫程式?那些老師沒教的事 (Git 部分節錄)
寫程式?那些老師沒教的事

What's hot (18)

PDF
To Err Is Human
PPT
TDD per Webapps
TXT
Railwaynew
TXT
New text document
PPTX
Cnam azure 2014 mobile services
DOCX
Travel management
PDF
Numerical Methods with Computer Programming
PDF
Обзор фреймворка Twisted
PDF
생산적인 개발을 위한 지속적인 테스트
PDF
Tugas 2
PDF
T3chFest2016 - Uso del API JavaScript de Photoshop para obtener fotos HDTR
DOCX
Fia fabila
PDF
201913001 khairunnisa progres_harian
PDF
Internet Technology (Practical Questions Paper) [CBSGS - 75:25 Pattern] {Mast...
DOC
Ip project
PDF
HDTR images with Photoshop Javascript Scripting
PPTX
Security: Odoo Code Hardening
To Err Is Human
TDD per Webapps
Railwaynew
New text document
Cnam azure 2014 mobile services
Travel management
Numerical Methods with Computer Programming
Обзор фреймворка Twisted
생산적인 개발을 위한 지속적인 테스트
Tugas 2
T3chFest2016 - Uso del API JavaScript de Photoshop para obtener fotos HDTR
Fia fabila
201913001 khairunnisa progres_harian
Internet Technology (Practical Questions Paper) [CBSGS - 75:25 Pattern] {Mast...
Ip project
HDTR images with Photoshop Javascript Scripting
Security: Odoo Code Hardening
Ad

Viewers also liked (12)

TXT
Hospital management
PDF
Hospital Management System Project
PDF
09.project hospital management system
DOC
C programming project by navin thapa
DOC
Project report
DOCX
Hotel Management system in C++
PDF
School Management (c++)
PPT
Hospital Management System
ODT
PROJECT-HOSPITAL MANAGEMENT SYSTEM CHAP. 1 TO 4
DOCX
Computer science project work
DOC
Hospital management system
DOCX
Hospital management system project
Hospital management
Hospital Management System Project
09.project hospital management system
C programming project by navin thapa
Project report
Hotel Management system in C++
School Management (c++)
Hospital Management System
PROJECT-HOSPITAL MANAGEMENT SYSTEM CHAP. 1 TO 4
Computer science project work
Hospital management system
Hospital management system project
Ad

Similar to Hospital management (20)

PPTX
Project in programming
DOCX
Laporan pd kelompok 6
PDF
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
DOCX
simple-movie-ticket-booking-system-1
DOCX
RAILWAY RESERWATION PROJECT PROGRAM
DOCX
Programa Sumar y Multiplicar
PDF
Bangun datar dan bangun ruang
DOC
Atm machine using c++
DOC
Atm machine using c++
DOC
Atm machine using c++
PPT
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
PDF
g++ -o simpleVector.exe simpleVector.cpp #include stdio.h #i.pdf
PPTX
ONLINE STUDENT MANAGEMENT SYSTEM
TXT
Programación de C++, Función Case
PDF
Unit 1 ocs752 introduction to c programming
DOCX
DOC
Atm machine using c++
DOCX
Tugas praktikukm pemrograman c++
PPT
C++ programming
Project in programming
Laporan pd kelompok 6
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
simple-movie-ticket-booking-system-1
RAILWAY RESERWATION PROJECT PROGRAM
Programa Sumar y Multiplicar
Bangun datar dan bangun ruang
Atm machine using c++
Atm machine using c++
Atm machine using c++
DATASTRUCTURES PPTS PREPARED BY M V BRAHMANANDA REDDY
g++ -o simpleVector.exe simpleVector.cpp #include stdio.h #i.pdf
ONLINE STUDENT MANAGEMENT SYSTEM
Programación de C++, Función Case
Unit 1 ocs752 introduction to c programming
Atm machine using c++
Tugas praktikukm pemrograman c++
C++ programming

Recently uploaded (20)

PPTX
Glazing at Facade, functions, types of glazing
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PPTX
TE-AI-Unit VI notes using planning model
PPT
Drone Technology Electronics components_1
PDF
MCAD-Guidelines. Modernization of command Area Development, Guideines
PPTX
Fluid Mechanics, Module 3: Basics of Fluid Mechanics
PDF
오픈소스 LLM, vLLM으로 Production까지 (Instruct.KR Summer Meetup, 2025)
PDF
ETO & MEO Certificate of Competency Questions and Answers
PDF
Structs to JSON How Go Powers REST APIs.pdf
PDF
Chad Ayach - A Versatile Aerospace Professional
PPTX
anatomy of limbus and anterior chamber .pptx
PPTX
Ship’s Structural Components.pptx 7.7 Mb
PPTX
Internship_Presentation_Final engineering.pptx
PDF
B.Tech (Electrical Engineering ) 2024 syllabus.pdf
PDF
A Framework for Securing Personal Data Shared by Users on the Digital Platforms
PDF
flutter Launcher Icons, Splash Screens & Fonts
PDF
classification of cubic lattice structure
PPTX
metal cuttingmechancial metalcutting.pptx
PDF
Queuing formulas to evaluate throughputs and servers
PPT
Chapter 6 Design in software Engineeing.ppt
Glazing at Facade, functions, types of glazing
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
TE-AI-Unit VI notes using planning model
Drone Technology Electronics components_1
MCAD-Guidelines. Modernization of command Area Development, Guideines
Fluid Mechanics, Module 3: Basics of Fluid Mechanics
오픈소스 LLM, vLLM으로 Production까지 (Instruct.KR Summer Meetup, 2025)
ETO & MEO Certificate of Competency Questions and Answers
Structs to JSON How Go Powers REST APIs.pdf
Chad Ayach - A Versatile Aerospace Professional
anatomy of limbus and anterior chamber .pptx
Ship’s Structural Components.pptx 7.7 Mb
Internship_Presentation_Final engineering.pptx
B.Tech (Electrical Engineering ) 2024 syllabus.pdf
A Framework for Securing Personal Data Shared by Users on the Digital Platforms
flutter Launcher Icons, Splash Screens & Fonts
classification of cubic lattice structure
metal cuttingmechancial metalcutting.pptx
Queuing formulas to evaluate throughputs and servers
Chapter 6 Design in software Engineeing.ppt

Hospital management

  • 1. #include<iostream> #include<conio.h> #include<fstream> #include<cstring> #include<stdlib.h> using namespace std; class password { string code; public: void get_password(); int verify_password(string); }; void password::get_password() { cout << "Setting Up The P10 Hospital Management System.....n"; cout << "nPlease Choose A Password For Your System :"; START: code.clear(); char ch; int count = 0; ch = _getch(); while (ch != 13) { if (ch == 8) { cout << "b b"; // code.pop_back(); } if (ch != 8) { cout << "*"; code.push_back(ch); } ch = _getch(); count++; } if (count < 5) { cout << "nnYour Password Should Have Minimum Of 5 Characters!!!n"; cout << "n Please Choose A Password For Your System :"; goto START; } } int password::verify_password(string pass) { if (pass == code) return(1); } class doctor { int id; int code; char name[50]; int age; char qualification[10]; char specilization[10]; int experience; char state[50];
  • 2. char city[50]; public: //int id; int get_ID(); void get_info(); void get_name(); void get_age(); void get_code(); void get_qualification(); void get_specilization(); void get_experience(); void get_state(); void get_city(); int verify_specilization(int opt,int flag); void display_all(doctor d); void display_info(doctor d); void modify_info(doctor d, int number,int size); }; void add_doctor_data(); int verify_alphabet(char* arr,int size); void modify_doctor_data(); void delete_contents(); void delete_contents1(); void display(); void delete_doctor_data(); int display_doctor_data(); int doctor_number(); long int get_size_of_the_file(); int verify_alphabet(char* arr, int size) { int i = 0; for (i = 0; i < size; i++) { if (isdigit(arr[i])) { return(1); } } } int doctor_number() { long int size; size = get_size_of_the_file(); doctor d; size = size / (sizeof(d)); return(size); } int doctor::verify_specilization(int opt,int flag) { if (opt == code) { flag++; cout <<"n"<<"ID------------->t"<< get_ID(); return(flag); } else { return(flag); } } int doctor::get_ID()
  • 3. { return(id); } void doctor::get_info() { cout << "nEnter Doctor's ID :"; cin >> id; NAME: cout << "nEnter Doctor's Name :"; cin.ignore(); cin.getline(name, 50); int flag; int size=strlen(name); flag=verify_alphabet(name,size); if (flag == 1) { cout << "nnName should consist of only alphabets or min of three alphabets!!!n"; cout << "n"; system("PAUSE"); //goto NAME; } cout << "nEnter Doctor's Age :"; cin >> age; QUALIFICATION: cout << "nEnter Doctor's Qualification :"; cin.ignore(); cin.getline(qualification, 50); size = strlen(qualification); flag = verify_alphabet(qualification, size); if (flag == 1) { cout << "nQualification should consist of only alphabets or min of three alphabets!!!n"; cout << "n"; system("PAUSE"); goto QUALIFICATION; } SPECILIZATION: cout << "nEnter Doctor's Specialization :"; cin.getline(specilization, 50); size = strlen(specilization); flag = verify_alphabet(specilization, size); if (flag == 1) { cout << "nSpecilization should consist of only alphabets or min of three alphabets!!!n"; cout << "n"; system("PAUSE"); goto SPECILIZATION; } cout << "******************************************************************************* *"; cout << "ntttCodes For Various Specilizationsn"; cout << "******************************************************************************* *"; cout << "n1.General Medicinen2.Cardiologyn3.Neurologyn4.ENTn"; cout << "******************************************************************************* *";
  • 4. cout << "nSelect The Code Basing On The Specilization :"; cin >> code; cout << "******************************************************************************* *"; cout << "nEnter Doctor's Experience :"; cin >> experience; STATE: cout << "nEnter Doctor's State :"; cin.ignore(); cin.getline(state, 30); size = strlen(state); flag = verify_alphabet(state, size); if (flag == 1) { cout << "nState should consist of only alphabets or min of three alphabets!!!n"; cout << "n"; system("PAUSE"); goto STATE; } CITY: cout << "nEnter Doctor's City :"; cin.getline(city, 30); size = strlen(city); flag = verify_alphabet(city, size); if (flag == 1) { cout << "nCity should consist of only alphabets!!! or min of three alphabetsn"; cout << "n"; system("PAUSE"); goto CITY; } } void doctor::get_name() { NAME: cin.ignore(); cout << "nEnter New Name :"; cin >> name; int flag; int size = strlen(name); flag = verify_alphabet(name, size); if (flag == 1) { cout << "nName should consist of only alphabets or min of three alphabets!!!n"; cout << "n"; system("PAUSE"); goto NAME; } } void doctor::get_age() { cin.ignore(); cout << "nEnter New Age :"; cin >> age; } void doctor::get_qualification() { QUALIFICATION:
  • 5. cin.ignore(); cout << "nEnter New Qualification :"; cin >> specilization; int flag; int size = strlen(qualification); flag = verify_alphabet(qualification, size); if (flag == 1) { cout << "nQualification should consist of only alphabets or min of three alphabets!!!n"; cout << "n"; system("PAUSE"); goto QUALIFICATION; } } void doctor::get_specilization() { SPECILIZATION: cin.ignore(); cout << "nEnter New Specilization :"; cin >> specilization; int flag; int size = strlen(specilization); flag = verify_alphabet(specilization, size); if (flag == 1) { cout << "nSpecilization should consist of only alphabets or min of three alphabets!!!n"; cout << "n"; system("PAUSE"); goto SPECILIZATION; } cout << "******************************************************************************* *"; cout << "nCodes For Various Specilizationsn"; cout << "******************************************************************************* *"; cout << "n1.General Medicinen2.Cardiologyn3.Neurologyn4.ENTn"; cout << "******************************************************************************* *"; cout << "nSelect The Code Basing On The Specilization "; cin >> code; } void doctor::get_experience() { cin.ignore(); cout << "nEnter New Experience :"; cin >> experience; } void doctor::get_state() { STATE: cin.ignore(); cout << "nEnter New State :"; cin >> state; int flag; int size = strlen(state); flag = verify_alphabet(state, size); if (flag == 1) { cout << "nState should consist of only alphabets or min of three
  • 6. alphabets!!!n"; cout << "n"; system("PAUSE"); goto STATE; } } void doctor::get_city() { CITY: cin.ignore(); cout << "nEnter New City :"; cin >> city; int flag; int size = strlen(city); flag = verify_alphabet(city, size); if (flag == 1) { cout << "nCity should consist of only alphabets(or)min of three alphabets!!!n"; cout << "n"; system("PAUSE"); goto CITY; } } void doctor::display_info(doctor d) { cout << "nDoctor's ID :t "<< d.id; cout << "nDoctor's Name :t" << d.name; cout << "nDoctor's Age :t" << d.age; cout << "nDoctor's Qualification :t" << d.qualification; cout << "nDoctor's Specilization :t" << d.specilization; cout << "nDoctor's Experience :t" << d.experience; cout << "nDoctor's State :t" << d.state; cout << "nDoctor's City :t" << d.city; } void doctor::display_all(doctor d) { cout <<"t"<< d.id << "tt" << d.specilization << "ttt" << d.qualification << "ttt" << d.age<<"n"; } void doctor::modify_info(doctor d, int number,int size) { if (number == 1) { fstream myfile6("doctor8.txt",ios::in|ios::out); doctor d1 = d; d1.get_name(); myfile6.seekp(size, ios::beg); myfile6.write((char*)&d1, sizeof(d1)); cout << "n"; cout << "n"; system("PAUSE"); system("CLS"); cout << "nData Successfully Modifiedn"; myfile6.close(); cout << " n"; system("PAUSE"); } else if (number == 2) { fstream myfile6("doctor8",ios::in|ios::out); doctor d1 = d; d1.get_age(); myfile6.seekp(size,ios::beg);
  • 7. myfile6.write((char*)&d1, sizeof(d1)); system("PAUSE"); system("CLS"); cout << "nData Successfully Modifiedn"; myfile6.close(); cout << "n"; system("PAUSE"); } else if (number == 3) { fstream myfile6("doctor8.txt", ios::in | ios::out); doctor d1 = d; d1.get_qualification(); myfile6.seekp(size, ios::beg); myfile6.write((char*)&d1, sizeof(d1)); system("PAUSE"); system("CLS"); cout << "nData Successfully Modifiedn"; myfile6.close(); cout << "n"; system("PAUSE"); } else if (number == 4) { fstream myfile6("doctor8.txt", ios::in | ios::out); doctor d1 = d; d1.get_specilization(); myfile6.seekp(size, ios::beg); myfile6.write((char*)&d1, sizeof(d1)); system("PAUSE"); system("CLS"); cout << "nData Successfully Modifiedn"; myfile6.close(); cout << "n"; system("PAUSE"); } else if (number == 5) { fstream myfile6("doctor8.txt", ios::in | ios::out); doctor d1 = d; d1.get_experience(); myfile6.seekp(size, ios::beg); myfile6.write((char*)&d1, sizeof(d1)); system("PAUSE"); system("CLS"); cout << "nData Successfully Modifiedn"; myfile6.close(); cout << "n"; system("PAUSE"); } else if (number == 6) { fstream myfile6("doctor8.txt", ios::in | ios::out); doctor d1 = d; d1.get_state(); myfile6.seekp(size, ios::beg); myfile6.write((char*)&d1, sizeof(d1)); system("PAUSE"); system("CLS"); cout << "nData Successfully Modifiedn"; myfile6.close(); cout << "n"; system("PAUSE");
  • 8. } else if (number == 7) { fstream myfile6("doctor8.txt", ios::in | ios::out); doctor d1 = d; d1.get_city(); myfile6.seekp(size, ios::beg); myfile6.write((char*)&d1, sizeof(d1)); system("PAUSE"); system("CLS"); cout << "nData Successfully Modifiedn"; myfile6.close(); cout << "n"; system("PAUSE"); } } class patient { int id; int doc_id; char name[50]; int age; char occupation[30]; char state[10]; char symptoms[70]; char disease[50]; char city[10]; char consultation_date[30]; char nationality[20]; char phone_no[20]; char street[30]; char door_no[20]; char condition[30]; char date_admitted[20]; char date_discharged[20]; char discharge_condition[50]; int bill; public: int get_ID(); void set_doc_ID(); void get_info(); void get_name(); void get_age(); void get_occupation(); void get_state(); void get_city(); void get_phone_no(); void get_nationality(); void get_street(); void get_door_no(); void get_condition(); void report1(patient); void get_discharge_condition(); void get_date_admitted(); void get_date_discharged(); void get_bill(); void bill1(patient); void assign_patient_to_doctor(patient p, int size); void display_all(patient p); void display_info(patient p); void modify_info(patient p, int number, int size); };
  • 9. void add_patient_data(); void modify_patient_data(); void delete_patient_data(); void assign_patient(); void display1(); void report(); void bill(); int display_patient_data(); int number(); long int get_size_of_the_file1(); void patient::bill1(patient p) { system("CLS"); int total; cout << "******************************************************************************* *"; cout << "nnttttPatient Fee Chargenn "; cout << "******************************************************************************* "; cout << "nHospital Room Charges :t 1000"; cout << "nHospital Care Charges :t 500"; cout << "nHospital Maintaince Charges :t 500"; cout << "nPatient Individual Charges :t " << p.bill; total = 1000 + 500 + 500 + p.bill; cout << "nTotal Fee Charge :t" << total<<"n"; cout << "******************************************************************************* *"; } void patient::report1(patient p) { system("CLS"); cout << "******************************************************************************* *"; cout << "ntttPatient Reportn"; cout << "******************************************************************************* *"; cout << "nPatient Name :" << p.name; cout << "nPatient Age :" << p.age; cout << "nPatient Symptoms :" << p.symptoms; cout << "nPatient Disease :" << p.disease; cout << "nPatient Admission Date :" << p.date_admitted; cout << "nPatient Discharge Date :" << p.date_discharged; cout << "nPatient Condition At The Time Of Discharge :" << p.discharge_condition; cout << "npatient Consulation Date :" << p.consultation_date; cout << "n"; cout << "******************************************************************************* *"; } int patient::get_ID()
  • 10. { return(id); } void patient::set_doc_ID() { cout << "nPlease Select Your Choice :"; cin >> doc_id; } void patient::get_info() { cout << "nEnter Patient's ID :"; cin >> id; NAME: cout << "nEnter Patient's Name :"; cin.ignore(); cin.getline(name, 50); int flag; int size = strlen(name); flag = verify_alphabet(name, size); if (flag == 1) { cout << "nnName should consist of only alphabets or min of three alphabets!!!n"; cout << "n"; system("PAUSE"); goto NAME; } cout << "nEnter Patient's Age :"; cin >> age; OCCUPATION: cout << "nEnter Patient's Occupation :"; cin.ignore(); cin.getline(occupation, 30); size = strlen(occupation); flag = verify_alphabet(occupation, size); if (flag == 1) { cout << "nnOccupation should consist of only alphabets or min of three alphabets!!!n"; cout << "n"; system("PAUSE"); goto OCCUPATION; } STATE: cout << "nEnter Patient's state :"; cin.getline(state, 30); size = strlen(state); flag = verify_alphabet(state, size); if (flag == 1) { cout << "nnState should consist of only alphabets or min of three alphabets!!!n"; cout << "n"; system("PAUSE"); goto STATE; } CITY: cout << "nEnter Patient's City :"; cin.getline(city, 30); size = strlen(city); flag = verify_alphabet(city, size); if (flag == 1) {
  • 11. cout << "nnCity should consist of only alphabets or min of three alphabets!!!n"; cout << "n"; system("PAUSE"); goto CITY; } NATIONALITY: cout << "nEnter Patient's Nationality :"; cin.getline(nationality, 30); size = strlen(nationality); flag = verify_alphabet(nationality, size); if (flag == 1) { cout << "nnNationality should consist of only alphabets or min of three alphabets!!!n"; cout << "n"; system("PAUSE"); goto NATIONALITY; } cout << "nEnter Patient's Phone Number :"; cin.getline(phone_no, 20); cout << "nEnter Patient's Street Name :"; cin.getline(street, 30); cout << "nEnter Patient's Symptoms :"; cin.getline(symptoms, 70); cout << "nEnter Patient's Disease :"; cin.getline(disease, 30); cout << "nEnter Patient's Door Number :"; cin.getline(door_no, 20); cout << "nEnter Patient's Condition :"; cin.getline(condition, 30); cout << "nEnter Admission Date Of The Patient :"; cin.getline(date_admitted, 20); cout << "nEnter Discharge Date Of The Patient :"; cin.getline(date_discharged, 20); cout << "nEnter Condition Of The Patient At The Time Of The Discharge :"; cin.getline(discharge_condition, 50); cout << "nEnter The Patient's Next Consultation Date :"; cin.getline(consultation_date, 30); cout << "nEnter The Patient's Bill Charges :"; cin >> bill; } void patient::assign_patient_to_doctor(patient p, int size) { long int size1 = size; ifstream myfile1("doctor8.txt"); size = get_size_of_the_file(); doctor d; size = size / (sizeof(d)); cout << "******************************************************************************* *"; cout << "nt The Following Are The Specilizations Available In The Hospitaln"; cout << "******************************************************************************* *"; cout << "n1.General Medicinen2.Cardiologyn3.Neurologyn4.ENTn"; cout << "******************************************************************************* *"; cout << "nnPlease Select Your Choice :";
  • 12. int opt,flag=0; int cho; cin >> opt; myfile1.seekg(0); switch (opt) { case 1: system("CLS"); cout << "******************************************************************************* *"; cout << "nttID's Of The Doctors With The General Medicine Specilizationn"; cout << "******************************************************************************* *"; for (int i = 0; i < size; i++) { cout << "n"; myfile1.read((char*)&d, sizeof(d)); flag = d.verify_specilization(opt,flag); } myfile1.close(); if (flag == 0) { system("CLS"); cout << "******************************************************************************* *"; cout << "nSorry!No Doctors Are Available With The Required Specilizationn"; cout << "******************************************************************************* *"; cout << "nn"; system("PAUSE"); } else { cout << "n"; cout << "******************************************************************************* ****"; fstream myfile6("patient11.txt", ios::in | ios::out); patient p1 = p; myfile6.seekp(0); myfile6.seekg(0); p1.set_doc_ID(); myfile6.seekp(size1, ios::beg); myfile6.write((char*)&p1, sizeof(p1)); system("CLS"); cout << "nPatient Has Been Assigned A Doctor Successfully"; cout << "n"; cout << "n***************************************************************************** "; cout << "nn"; system("PAUSE"); } break; case 2: system("CLS"); cout <<
  • 13. "******************************************************************************* *"; cout << "nttID's Of The Doctors With The Cardiology Specilizationn"; cout << "******************************************************************************* *"; for (int i = 0; i < size; i++) { cout << "n"; myfile1.read((char*)&d, sizeof(d)); flag = d.verify_specilization(opt,flag); } if (flag == 0) { system("CLS"); cout << "******************************************************************************* *"; cout << "nSorry!No Doctors Are Available With The Required Specilizationn"; cout << "******************************************************************************* *"; cout << "nn"; system("PAUSE"); } else { cout << "n"; cout << "******************************************************************************* *"; fstream myfile6("patient11.txt", ios::in | ios::out); patient p1 = p; myfile6.seekp(0); myfile6.seekg(0); p1.set_doc_ID(); myfile6.seekp(size1, ios::beg); myfile6.write((char*)&p1, sizeof(p1)); system("CLS"); cout << "nPatient Has Been Assigned A Doctor Successfully"; cout << "n"; cout << "n***************************************************************************** "; cout << "nn"; system("PAUSE"); } break; case 3: system("CLS"); cout << "******************************************************************************* *"; cout << "nttID's Of The Doctors With The Neurology Specilizationn"; cout << "******************************************************************************* *"; for (int i = 0; i < size; i++) { cout << "n"; myfile1.read((char*)&d, sizeof(d));
  • 14. flag = d.verify_specilization(opt,flag); } if (flag == 0) { system("CLS"); cout << "******************************************************************************* *"; cout << "nSorry!No Doctors Are Available With The Required Specilizationn"; cout << "******************************************************************************* *"; cout << "nn"; system("PAUSE"); } else { cout << "n"; cout << "******************************************************************************* *"; fstream myfile6("patient11.txt", ios::in | ios::out); patient p1 = p; myfile6.seekp(0); myfile6.seekg(0); p1.set_doc_ID(); myfile6.seekp(size1, ios::beg); myfile6.write((char*)&p1, sizeof(p1)); system("CLS"); cout << "nPatient Has Been Assigned A Doctor Successfully"; cout << "n"; cout << "n***************************************************************************** "; cout << "nn"; system("PAUSE"); } break; case 4: system("CLS"); cout << "******************************************************************************* *"; cout << "nttID's Of The Doctors With The ENT Specilizationn"; cout << "******************************************************************************* *"; for (int i = 0; i < size; i++) { cout << "n"; myfile1.read((char*)&d, sizeof(d)); flag = d.verify_specilization(opt,flag); } if (flag == 0) { system("CLS"); cout << "******************************************************************************* *"; cout << "nSorry!No Doctors Are Available With The Required Specilizationn"; cout <<
  • 15. "******************************************************************************* *"; cout << "nn"; system("PAUSE"); } else { cout << "n"; cout << "******************************************************************************* *"; fstream myfile6("patient11.txt", ios::in | ios::out); patient p1 = p; myfile6.seekp(0); myfile6.seekg(0); p1.set_doc_ID(); myfile6.seekp(size1, ios::beg); myfile6.write((char*)&p1, sizeof(p1)); system("CLS"); cout << "nPatient Has Been Assigned A Doctor Successfully"; cout << "n"; cout << "n***************************************************************************** "; cout << "nn"; system("PAUSE"); } break; default: cout << "nWrong Choice!!!"; } } void patient::get_name() { cout << "nEnter New Name :"; cin.ignore(); cin.getline(name, 50); } void patient::get_age() { cout << "nEnter New Age :"; cin.ignore(); cin >> age; } void patient::get_occupation() { cout << "nEnter New Occupation :"; cin.ignore(); cin.getline(occupation, 50); } void patient::get_state() { cin.ignore(); cout << "nEnter New State :"; cin.getline(state, 20); } void patient::get_city() { cin.ignore(); cout << "nEnter New City :"; cin.getline(city, 20); }
  • 16. void patient::get_phone_no() { cin.ignore(); cout << "nEnter New Phone Number :"; cin.getline(phone_no, 30); } void patient::get_nationality() { cin.ignore(); cout << "nEnter New Nationality :"; cin.getline(nationality, 30); } void patient::get_street() { cin.ignore(); cout << "nEnter New Street :"; cin.getline(street, 50); } void patient::get_door_no() { cin.ignore(); cout << "nEnter New Door Number :"; cin.getline(door_no, 30); } void patient::get_condition() { cin.ignore(); cout << "nEnter New Condition :"; cin.getline(condition, 50); } void patient::get_discharge_condition() { cin.ignore(); cout << "nEnter New Condition Of The Patient At The Time Of Discharge :"; cin.getline(discharge_condition, 50); } void patient::get_date_admitted() { cin.ignore(); cout << "nEnter New Admission Date Of The Patient :"; cin.getline(date_admitted, 30); } void patient::get_date_discharged() { cin.ignore(); cout << "nEnter New Discharge Date Of The Patient :"; cin.getline(date_discharged, 30); }void patient::get_bill() { cin.ignore(); cout << "nEnter New Bill Charge Of The Patient :"; cin >> bill; } void patient::display_all(patient p) { cout << p.id << "t" << p.age << "t" << p.symptoms << "t" << p.date_admitted << "ttt"<<p.doc_id<<"n"; } void patient::display_info(patient p) { cout << "nPatient's ID :" << p.id; cout << "nPatient's Name :" << p.name; cout << "nPatient's Age :" << p.age;
  • 17. cout << "nPatient's Occupation :" << p.occupation; cout << "nPatient's State :" << p.state; cout << "nPatient's City :" << p.city; cout << "nPatient's Phone Number :" << p.phone_no; cout << "nPatient's Nationality :" << p.nationality; cout << "nPatient's Street :" << p.street; cout << "nPatient's Door Number :" << p.door_no; cout << "nPatient's Condtion :" << p.condition; cout << "nPatient's Condition At The Time Of Discharge :" << p.discharge_condition; cout << "nPatient's Admission Date :" << p.date_admitted; cout << "nPatient's Discharge Date :" << p.date_discharged; cout << "nID Of The Doctor Who Is Treating The Patient :" << p.doc_id; } void patient::modify_info(patient p, int number, int size) { if (number == 1) { fstream myfile6("patient11.txt", ios::in | ios::out); patient p1 = p; p1.get_name(); myfile6.seekp(size, ios::beg); myfile6.write((char*)&p1, sizeof(p1)); int total = myfile6.tellp(); total /= sizeof(p1); cout << "nn"; system("PAUSE"); system("CLS"); cout << "nData Successfully Modifiedn"; myfile6.close(); cout << "n"; system("PAUSE"); } else if (number == 2) { fstream myfile6("patient11.txt", ios::in | ios::out); patient p1 = p; p1.get_age(); myfile6.seekp(size, ios::beg); myfile6.write((char*)&p1, sizeof(p1)); int total = myfile6.tellp(); total /= sizeof(p1); cout << "nn"; system("PAUSE"); system("CLS"); cout << "nData Successfully Modifiedn"; myfile6.close(); cout << "n"; system("PAUSE"); } else if (number == 3) { fstream myfile6("patient11.txt", ios::in | ios::out);
  • 18. patient p1 = p; p1.get_occupation(); myfile6.seekp(size, ios::beg); myfile6.write((char*)&p1, sizeof(p1)); int total = myfile6.tellp(); total /= sizeof(p1); cout << "nn"; system("PAUSE"); system("CLS"); cout << "nData Successfully Modifiedn"; myfile6.close(); cout << "n"; system("PAUSE"); } else if (number == 4) { fstream myfile6("patient11.txt", ios::in | ios::out); patient p1 = p; p1.get_state(); myfile6.seekp(size, ios::beg); myfile6.write((char*)&p1, sizeof(p1)); int total = myfile6.tellp(); total /= sizeof(p1); cout << "nn"; system("PAUSE"); system("CLS"); cout << "nData Successfully Modifiedn"; myfile6.close(); cout << "n"; system("PAUSE"); } else if (number == 5) { fstream myfile6("patient11.txt", ios::in | ios::out); patient p1 = p; p1.get_city(); myfile6.seekp(size, ios::beg); myfile6.write((char*)&p1, sizeof(p1)); int total = myfile6.tellp(); total /= sizeof(p1); cout << "nn"; system("PAUSE"); system("CLS"); cout << "nData Successfully Modifiedn"; myfile6.close(); cout << "n"; system("PAUSE"); } else if (number == 6) { fstream myfile6("patient11.txt", ios::in | ios::out); patient p1 = p; p1.get_phone_no(); myfile6.seekp(size, ios::beg); myfile6.write((char*)&p1, sizeof(p1)); int total = myfile6.tellp(); total /= sizeof(p1); cout << "nn"; system("PAUSE"); system("CLS"); cout << "nData Successfully Modifiedn"; myfile6.close(); cout << "n"; system("PAUSE");
  • 19. } else if (number == 7) { fstream myfile6("patient11.txt", ios::in | ios::out); patient p1 = p; p1.get_nationality(); myfile6.seekp(size, ios::beg); myfile6.write((char*)&p1, sizeof(p1)); int total = myfile6.tellp(); total /= sizeof(p1); cout << "nn"; system("PAUSE"); system("CLS"); cout << "nData Successfully Modifiedn"; myfile6.close(); cout << "n"; system("PAUSE"); } else if (number == 8) { fstream myfile6("patient11.txt", ios::in | ios::out); patient p1 = p; p1.get_street(); myfile6.seekp(size, ios::beg); myfile6.write((char*)&p1, sizeof(p1)); int total = myfile6.tellp(); total /= sizeof(p1); cout << "nn"; system("PAUSE"); system("CLS"); cout << "nData Successfully Modifiedn"; myfile6.close(); cout << "n"; system("PAUSE"); } else if (number == 9) { fstream myfile6("patient11.txt", ios::in | ios::out); patient p1 = p; p1.get_door_no(); myfile6.seekp(size, ios::beg); myfile6.write((char*)&p1, sizeof(p1)); int total = myfile6.tellp(); total /= sizeof(p1); cout << "nn"; system("PAUSE"); system("CLS"); cout << "nData Successfully Modifiedn"; myfile6.close(); cout << "n"; system("PAUSE"); } else if (number == 10) { fstream myfile6("patient11.txt", ios::in | ios::out); patient p1 = p; p1.get_condition(); myfile6.seekp(size, ios::beg); myfile6.write((char*)&p1, sizeof(p1)); int total = myfile6.tellp(); total /= sizeof(p1); cout << "nn"; system("PAUSE"); system("CLS");
  • 20. cout << "nData Successfully Modifiedn"; myfile6.close(); cout << "n"; system("PAUSE"); } else if (number == 11) { fstream myfile6("patient11.txt", ios::in | ios::out); patient p1 = p; p1.get_discharge_condition(); myfile6.seekp(size, ios::beg); myfile6.write((char*)&p1, sizeof(p1)); int total = myfile6.tellp(); total /= sizeof(p1); cout << "nn"; system("PAUSE"); system("CLS"); cout << "nData Successfully Modifiedn"; myfile6.close(); cout << "n"; system("PAUSE"); } else if (number == 12) { fstream myfile6("patient11.txt", ios::in | ios::out); patient p1 = p; p1.get_date_admitted(); myfile6.seekp(size, ios::beg); myfile6.write((char*)&p1, sizeof(p1)); int total = myfile6.tellp(); total /= sizeof(p1); cout << "nn"; system("PAUSE"); system("CLS"); cout << "nData Successfully Modifiedn"; myfile6.close(); cout << "n"; system("PAUSE"); } else if (number == 13) { fstream myfile6("patient11.txt", ios::in | ios::out); patient p1 = p; p1.get_date_discharged(); myfile6.seekp(size, ios::beg); myfile6.write((char*)&p1, sizeof(p1)); int total = myfile6.tellp(); total /= sizeof(p1); cout << "nn"; system("PAUSE"); system("CLS"); cout << "nData Successfully Modifiedn"; myfile6.close(); cout << "n"; system("PAUSE"); } else if (number == 14) { fstream myfile6("patient11.txt", ios::in | ios::out); patient p1 = p; p1.get_bill(); myfile6.seekp(size, ios::beg); myfile6.write((char*)&p1, sizeof(p1)); int total = myfile6.tellp();
  • 21. total /= sizeof(p1); cout << "nn"; system("PAUSE"); system("CLS"); cout << "nData Successfully Modifiedn"; myfile6.close(); cout << "n"; system("PAUSE"); } } int main() { int counter = 0,y=0; password p; p.get_password(); system("CLS"); START1: system("CLS"); cout << "******************************************************************************* *n"; cout << "nttWELCOME TO P10 HOSPITAL MANAGEMENT SYSTEMnn"; cout << "******************************************************************************* *n"; cout << "ntttt1.Main Menun"; cout << "ntttt2.Shut Downnn"; cout << "******************************************************************************* *n"; int op,ch,count=0,x; char c; string pass; cout << "nPlease Enter Your Choice :"; cin >> op; cout << "nn"; system("PAUSE"); START3: switch (op) { case 1: system("CLS"); cout << "******************************************************************************* *n"; cout << "ttttMain Menunn"; cout << "******************************************************************************* *n"; cout << "nntt1.Enter Into Doctor's Databasen"; cout << "ntt2.Enter into Patient's Databasen"; cout << "ntt3.Generate Patient's Reportn"; cout << "ntt4.Generate Patient's Billsn"; cout << "ntt5.Exitnn"; cout << "******************************************************************************* *"; cout << "nntPlease Choose Your Choice :"; cin >> ch; switch (ch) { case 1: system("CLS");
  • 22. START2: count++; cout << "nPlease Enter Your Password To Enter Into This Database :"; pass.clear(); c = _getch(); while (c != 13) { if (c == 8) cout << "b b"; if (c != 8) { cout << "*"; pass.push_back(c); } c = _getch(); } x = p.verify_password(pass); if (x == 1) { cout << "nnAccess Granted "; cout << "nn"; system("PAUSE"); system("CLS"); while (1) { system("CLS"); cout << "******************************************************************************* *n"; cout << "ntttWelcome to Doctor's Databasen"; cout << "n***************************************************************************** ***n"; cout << "ntt1.Add New Doctor's Informationn"; cout << "ntt2.Edit Doctor's Informationn"; cout << "ntt3.Display Doctor's Informationn"; cout << "ntt4.Delete Doctor's Informationn"; cout << "ntt5.Number Of Doctors In The Hospitaln"; cout << "ntt6.Clear All The Information In The Databasen"; cout << "ntt7.Display The Details Of All The Doctorsn"; cout << "ntt8.Exitn"; cout << "n***************************************************************************** ***n"; int opt; cout << "Please Choose Your Choice :"; cin >> opt; int y; switch (opt) { case 1: system("CLS"); add_doctor_data(); break; case 2: system("CLS"); modify_doctor_data();
  • 23. break; case 3: system("CLS"); y = display_doctor_data(); if (y != 1) { cout << "nNo Record To Display!!!n"; cout << "n"; system("PAUSE"); } break; case 4: system("CLS"); delete_doctor_data(); cout << "n"; system("PAUSE"); break; case 5: system("CLS"); cout << "nNumber Of Doctors In The Hospital are :" << doctor_number(); cout << "nn"; system("PAUSE"); break; case 6: system("CLS"); delete_contents(); cout << "nAll The Contents Of The Database Are Deleted "; cout << "nn"; system("PAUSE"); break; case 7: system("CLS"); display(); cout << "nn"; system("PAUSE"); break; case 8: system("CLS"); goto START3; _getch(); break; } } } else { if (count >= 3) { system("CLS"); cout << "nnAccess Denied!!!You Have Entered Wrong Password Too Many Timesn"; cout << "nThis System Will Shut Down.Please Come Back Againn"; cout << "nThank Youn"; cout << "n"; system("PAUSE"); exit(0); }
  • 24. cout << "nnWrong Password.Access Denied!!!n"; goto START2; } case 2: system("CLS"); START4: count++; cout << "nPlease Enter Your Password To Enter Into This Database :"; pass.clear(); c = _getch(); while (c != 13) { if (c == 8) { cout << "b b"; //pass.pop_back(c); } if (c != 8) { cout << "*"; pass.push_back(c); } c = _getch(); } x = p.verify_password(pass); if (x == 1) { cout << "nnAccess Granted "; cout << "nn"; system("PAUSE"); system("CLS"); while (1) { system("CLS"); cout << "******************************************************************************* *n"; cout << "ntttWelcome To Patient's Databasenn"; cout << "******************************************************************************* *n"; cout << "ntt1.Add Patient's Informationn"; cout << "ntt2.Assign A Patient To A Doctorn"; cout << "ntt3.Edit Patient's Informationn"; cout << "ntt4.Display Patient's Informationn"; cout << "ntt5.Delete Patient's Informationn"; cout << "ntt6.No.Of Patients In The Hospitaln"; cout << "ntt7.Delete All The Contents In The Databasen"; cout << "ntt8.Display The Details Of All The Patients In The Hospitaln"; cout << "ntt9.Exitnn"; cout << "******************************************************************************* *n"; int opt; cout << "nPlease Choose Your Choice :"; cin >> opt; int y; switch (opt) {
  • 25. case 1: system("CLS"); add_patient_data(); break; case 2: system("CLS"); assign_patient(); break; case 3: system("CLS"); modify_patient_data(); break; case 4: system("CLS"); y = display_patient_data(); if (y != 1) { cout << "nNo Record To Display!!!n"; cout << "n"; system("PAUSE"); } break; case 5: system("CLS"); delete_patient_data(); cout << "n"; system("PAUSE"); break; case 6: system("CLS"); cout << "nNo.Of Patient's In The Hospital are :" << number(); cout << "nn"; system("PAUSE"); break; case 7: system("CLS"); delete_contents1(); cout << "nAll The Contents Of The Database Are Deleted"; cout << "nn"; system("PAUSE"); break; case 8: system("CLS"); display1(); cout << "nn"; system("PAUSE"); break; case 9: system("CLS"); goto START3; _getch(); } } } else { if (count >= 3) { system("CLS"); cout << "nnAccess Denied!!!You Have Entered Wrong Password Too Many Timesn";
  • 26. cout << "nThis System Will Shut Down.Please Come Back Againn"; cout << "nThank Youn"; cout << "n"; system("PAUSE"); exit(0); } cout << "nnWrong Password.Access Denied!!!n"; goto START4; } case 3: system("CLS"); cout << "nn"; report(); cout << "nn"; system("PAUSE"); goto START3; break; case 4: system("CLS"); bill(); cout << "nn"; system("PAUSE"); system("CLS"); goto START3; break; case 5: cout << "n"; cout << "n"; goto START1; default: cout << "nWrong Choice "; } break; case 2: cout << "nn"; exit(0); break; default: cout << "nWrong Choice "; } _getch(); } void add_doctor_data() { doctor d; ofstream myfile("doctor8.txt",ios::in|ios::app); d.get_info(); myfile.write((char*)&d, sizeof(d)); myfile.close(); } void display() { long int size = 0; size = get_size_of_the_file(); int i = 0; doctor d; size = size / (sizeof(d)); if (size == 0) { cout << "nDatabase Empty!!!"; cout << "n";
  • 27. } else { cout << "n" ; cout << "******************************************************************************* *"; cout << "ntttDetails Of All The Doctors In The Hospitaln"; cout << "******************************************************************************* *"; cout <<"nt"<< "ID" << "tt" << "Specilization" << "tt" << "Qualification" << "tt" << "Age" << "n"; ifstream myfile("doctor8.txt"); myfile.seekg(0); for (i = 0; i < size; i++) { cout << "nn"; myfile.read((char*)&d, sizeof(d)); d.display_all(d); } cout << "******************************************************************************* *"; } } int display_doctor_data() { long int size = 0; size = get_size_of_the_file(); int i = 0, id, id1, count = 0; doctor d1; size = size / (sizeof(d1)); if (size == 0) { cout << "nDatabase Empty!!!"; cout << "n"; } else { cout << "nEnter The ID Of the Doctor You require :"; cin >> id; ifstream myfile1("doctor8.txt"); for (i = 0; i < size; i++) { myfile1.clear(); myfile1.read((char*)&d1, sizeof(d1)); id1 = d1.get_ID(); if (id == id1) { count = 1; d1.display_info(d1); cout << "n"; cout << "n"; system("PAUSE"); cout << "n"; break; } } myfile1.close();
  • 28. return(count); } } void modify_doctor_data() { int id1; long int size = 0; size = get_size_of_the_file(); int i = 0, count = 0, id; doctor d2; size = size / (sizeof(d2)); if (size == 0) { cout << "nDatabase Empty!!!n"; cout << "nNo Record To Modify!!!"; cout << "nn"; system("PAUSE"); } else { cout << "nEnter The ID Of The Doctor To Modify Data :"; cin >> id1; ifstream myfile2("doctor8.txt"); for (i = 0; i < size; i++) { myfile2.clear(); myfile2.read((char*)&d2, sizeof(d2)); id = d2.get_ID(); if (id == id1) { size = myfile2.tellg(); size = size - sizeof(d2); count = 1; d2.display_info(d2); cout << "nn"; system("PAUSE"); cout << "n"; cout << "nField's Which Can Be Modifiedn"; cout << "n1.Namen2.Agen3.Qualificationn"; cout << "4.Specilizationn5.Experiencen6.Staten"; cout << "7.Cityn"; int opt2; cout << "nSelect The Field Which You Want To Modify :"; cin >> opt2; switch (opt2) { case 1: d2.modify_info(d2, opt2, size); break; case 2: d2.modify_info(d2, opt2, size); break; case 3: d2.modify_info(d2, opt2, size); break; case 4: d2.modify_info(d2, opt2, size); break; case 5: d2.modify_info(d2, opt2, size); break;
  • 29. case 6: d2.modify_info(d2, opt2, size); break; case 7: d2.modify_info(d2, opt2, size); break; default: cout << "nWrong Choice "; } break; } } myfile2.close(); if (count == 0) { cout << "nRecord Does'nt Exist!!!"; cout << "n"; system("PAUSE"); } } } void delete_contents() { ofstream myfile("doctor8.txt"); myfile.close(); } void delete_contents1() { ofstream myfile("patient11.txt"); myfile.close(); } void delete_doctor_data() { long int size; size = get_size_of_the_file(); doctor d; size = size / (sizeof(d)); if (size == 0) { cout << "nDatabase Empty!!!"; cout << "nnNo Record To Delete!!!"; cout << "n"; } else { ifstream myfile6("doctor8.txt"); ofstream myfile7("temp1.txt"); int id, count = 0, id1, i; cout << "nEnter The ID Of The Doctor Whose Data You Want To Delete :"; cin >> id; for (i = 0; i < size; i++) { myfile6.read((char*)&d, sizeof(d)); id1 = d.get_ID(); if (id != id1) { myfile7.write((char*)&d, sizeof(d)); } else {
  • 30. count = 1; } } myfile6.close(); myfile7.close(); ofstream myfile9("doctor8.txt"); ifstream myfile8("temp1.txt"); for (i = 0; i < size - 1; i++) { myfile8.read((char*)&d, sizeof(d)); myfile9.write((char*)&d, sizeof(d)); } if (count == 0) { cout << "nNo Data Found "; cout << "nn"; system("PAUSE"); } else { cout << "nData Successfully Deletedn"; } } } long int get_size_of_the_file() { long int size=0; ifstream ifile("doctor8.txt"); ifile.seekg(0, ios::end); size = ifile.tellg(); ifile.close(); return(size); } void add_patient_data() { patient p; ofstream myfile("patient11.txt", ios::in | ios::app); p.get_info(); myfile.write((char*)&p, sizeof(p)); myfile.close(); } void display1() { long int size = 0; size = get_size_of_the_file1(); int i = 0; patient p; size = size / (sizeof(p)); if (size == 0) { cout << "nDatabase Empty!!!"; cout << "n"; } else { cout << "n"; cout << "******************************************************************************* *";
  • 31. cout << "ntttDetails Of All The Patients In The Hospitaln"; cout << "******************************************************************************* *"; cout <<"n" "ID" << "t" << "Age" << "t" << "Illness" << "tt" << "Date Admitted" << "tt"<<"Doctor's ID"<<"n"; ifstream myfile("patient11.txt"); myfile.seekg(0); for (i = 0; i < size; i++) { cout << "nn"; myfile.read((char*)&p, sizeof(p)); p.display_all(p); } cout << "******************************************************************************* *"; } } int display_patient_data() { long int size = 0; size = get_size_of_the_file1(); int i = 0, id, id1, count1 = 0; patient p1; size = size / (sizeof(p1)); if (size == 0) { cout << "nDatabase Empty!!!"; cout << "n"; } else { cout << "nEnter The ID Of The Patient You Require :"; cin >> id; ifstream myfile1("patient11.txt"); for (i = 0; i < size; i++) { myfile1.clear(); myfile1.read((char*)&p1, sizeof(p1)); id1 = p1.get_ID(); if (id == id1) { count1 = 1; p1.display_info(p1); cout << "nn"; system("PAUSE"); cout << "n"; break; } } myfile1.close(); return(count1); } } void assign_patient() {
  • 32. patient p; int id; long int size; size = get_size_of_the_file1(); int i = 0, count = 0, id1; size = size / (sizeof(p)); if (size == 0) { cout << "n Database Empty!!!n"; cout << "nYou Need To Add Patient's Information First!!!"; cout << "nn"; system("PAUSE"); } else { cout << "nEnter ID Of The Patient :"; cin >> id; ifstream myfile("patient11.txt"); myfile.seekg(0); for (i = 0; i < size; i++) { myfile.read((char*)&p, sizeof(p)); id1 = p.get_ID(); if (id == id1) { count = 1; size = myfile.tellg(); size = size - sizeof(p); p.assign_patient_to_doctor( p, size); break; } } if (count == 0) { system("CLS"); cout << "******************************************************************************* *"; cout << "nSorry!No Data Is Available Related To The Given IDn"; cout << "******************************************************************************* *"; cout << "nn"; system("PAUSE"); } } } void modify_patient_data() { int id1; long int size = 0; size = get_size_of_the_file1(); int i = 0, count = 0, id; patient p2; size = size / (sizeof(p2)); if (size == 0) { cout << "nDatabase Empty!!!n"; cout << "nNo Record To Modify!!!"; cout << "nn"; system("PAUSE");
  • 33. } else { cout << "nEnter The ID Of The Patient To Modify Data :"; cin >> id1; ifstream myfile2("patient11.txt"); myfile2.seekg(0); for (i = 0; i < size; i++) { myfile2.read((char*)&p2, sizeof(p2)); id = p2.get_ID(); if (id == id1) { size = myfile2.tellg(); size = size - sizeof(p2); count = 1; p2.display_info(p2); cout << "n"; system("PAUSE"); cout << "n"; cout << "nField's Which Can Be Modifiedn"; cout << "n1.Namen2.Agen3.Occupationn4.Staten"; cout << "5.Cityn6.Phone Numbern7.Nationalityn"; cout << "n8.Streetn9.Door Numbern10.Conditionn"; cout << "11.Discharge Conditionn12.Date Admittedn"; cout << "13.Date Dischargedn14.Patient Bill"; int opt2; cout << "nSelect The Field Which You Want To Modify :"; cin >> opt2; switch (opt2) { case 1: p2.modify_info(p2, opt2, size); break; case 2: p2.modify_info(p2, opt2, size); break; case 3: p2.modify_info(p2, opt2, size); break; case 4: p2.modify_info(p2, opt2, size); break; case 5: p2.modify_info(p2, opt2, size); break; case 6: p2.modify_info(p2, opt2, size); break; case 7: p2.modify_info(p2, opt2, size); break; case 8: p2.modify_info(p2, opt2, size); break; case 9: p2.modify_info(p2, opt2, size); break; case 10: p2.modify_info(p2, opt2, size);
  • 34. break; case 11: p2.modify_info(p2, opt2, size); break; case 12: p2.modify_info(p2, opt2, size); break; case 13: p2.modify_info(p2, opt2, size); break; case 14: p2.modify_info(p2, opt2, size); break; default: cout << "nWrong Choice "; } break; } } myfile2.close(); if (count == 0) { cout << "nRecord Does'nt Exist!!!"; cout << "n"; system("PAUSE"); } } } void delete_patient_data() { long int size; size = get_size_of_the_file1(); patient p; size = size / (sizeof(p)); if (size == 0) { cout << "nDatabase Empty!!!"; cout << "nnNo Record To Delete!!!"; cout << "n"; } else { ifstream myfile6("patient11.txt"); ofstream myfile7("temp4.txt"); int id, count = 0, id1, i; cout << "nEnter The ID Of The Patient Whose Data You Want To Delete :"; cin >> id; for (i = 0; i < size; i++) { myfile6.read((char*)&p, sizeof(p)); id1 = p.get_ID(); if (id != id1) { myfile7.write((char*)&p, sizeof(p)); } else { count = 1; } }
  • 35. myfile6.close(); myfile7.close(); ofstream myfile9("patient11.txt"); ifstream myfile8("temp4.txt"); for (i = 0; i < size - 1; i++) { myfile8.read((char*)&p, sizeof(p)); myfile9.write((char*)&p, sizeof(p)); } if (count == 0) { cout << "nNo Data Found "; cout << "nn"; } else { cout << "nData Successfully Deleted "; cout << "nn"; } } } long int get_size_of_the_file1() { long int size = 0; ifstream ifile("patient11.txt"); ifile.seekg(0,ios::end); size = ifile.tellg(); ifile.close(); return(size); } int number() { long int size; patient p; size = get_size_of_the_file1(); size = size / (sizeof(p)); return(size); } void report() { patient p; int id, id1, count = 0; long int size; size = get_size_of_the_file1(); size = size / (sizeof(p)); if (size == 0) { cout << "nPatient Database Empty!!!"; cout << "nAdd Some Patient's Info First!!!"; cout << "nn"; system("PAUSE"); } else {
  • 36. cout << "nEnter The ID Of The Patient You Require :"; cin >> id; ifstream myfile1("patient11.txt"); for (int i = 0; i < size; i++) { myfile1.clear(); myfile1.read((char*)&p, sizeof(p)); id1 = p.get_ID(); if (id == id1) { count = 1; p.report1(p); break; } } if (count == 0) { cout << "nData Not Available!!!"; } } } void bill() { long int size = 0; size = get_size_of_the_file1(); int i = 0, id, id1, count1 = 0; patient p1; size = size / (sizeof(p1)); if (size == 0) { cout << "nDatabase Empty!!!"; cout << "n"; } else { cout << "nEnter The ID Of The Patient You Require :"; cin >> id; ifstream myfile1("patient11.txt"); for (i = 0; i < size; i++) { myfile1.clear(); myfile1.read((char*)&p1, sizeof(p1)); id1 = p1.get_ID(); if (id == id1) { count1 = 1; p1.bill1(p1); break; } } if (count1 == 0) { cout << "nData Not Found!!!"; } myfile1.close(); } }