Question I need help with c Simple Classes Assigment i get t
Question: I need help with c++ Simple Classes Assigment. i get this code working but i have to change my setID from numbers in loop{1,2,3,4,5} to setID to *char which it have to start with lastName, then lastName, then year of birth.
c++ Simple Classes Assignment
In this assignment, you will write a struct plus two simple classes and then write a program that uses them all. The first class is a Date class. You are given code for this at the end of this assignment, but you must make some modifications. The other is a Patient class; you are given the class definition and you must write the implementation. The program will keep track of patients at a walk-in clinic. For each patient, the clinic keeps a record of all procedures done. This is a good candidate for a class, but to simplify the assignment, we will make a procedure into a struct. We will assume that the clinic has assigned all care providers (doctors, nurses, lab technicians) with IDs and each procedure (“office visit”, “physical exam”, “blood sample taken”, etc.) also has an ID. Each patient will also have an ID, which is formed by the last name concatenated with the first name and the year of birth. All other IDs (care providers, procedures) will be just integers.
When the user runs the program at the start of the day, it first tries to read in from a binary file called CurrentPatients.dat. It will contain the number of patients(in binary format) followed by binary copies of records for the patients at the clinic . This information should be read and stored in an array of Patient objects. There will be a separate array, initially empty at the start of the program that will store patient records for all patients who are currently checked in at the clinic. It then asks the user to enter the current date and reads it in. It should then presents the user with a simple menu: the letter N to check in a new patient, R for checking in a returning patient, O to check out a patient, I to print out information on a particular patient, P to print the list of patients who have checked in, but not yet checked out, and Q for quitting the program.
The following tasks are done when the appropriate letter is chosen.
N: The new patient’s first name, last name, and birthdate are asked for and entered. The new patient ID will be the last name concatenated with the first name and the year of birth. (Example: SmithJohn1998) The primary doctor’s ID is also entered. The new patient object is placed in both arrays: one keeping all patients, and one keeping the patients who checked in today.
R: The returning patient’s ID is asked for, and the array holding all patients is searched for the patient object. If found, a copy of the patient object is placed in the array for all currently checked in patients. If not found, the user is returned to the main menu after asking them to either try R again, making sure the correct ID was entered, or choose N to enter the patient as a new patient.
O: Using the patient’s ID, the patient object is found in the array holding currently checked in patients. (If not found, the user is returned to the main menu after asking them to either try O again, making sure the correct ID was entered, or choose N or R to check in the patient as a new or returing patient.) The procedure record is updated by entering a new entry, with the current date, procedure ID, and provider ID. The up-dated patient object is then removed from the array of currently checked in patients, and replaces the old patient object in the main array. If the update fails, a message is output.
I: Using the patient’s ID, the main array holding all patients is searched for the patient object. If found the information it holds: the names, birthdate, the primary doctor ID, and a list of all past procedures done (date, procedure ID, procedure provider ID) is printed to the monitor.
P: From the array holding all patients currently checked in, a list is printed in nice readable form, showing the patient ID, first and last names, and the primary doctor ID for each patient.
Q: If the list of patients currently checked in is not empty, the list is printed out and the user asked to keep running the program so they can be checked out. If the list is empty, the program will write the patient objects in the main array to the binary file CurrentPatients.dat. It should overwrite all previous information in the file.
//Date1.h
#ifndef Date_h
#define Date_h
#include <iostream>
#include <string>
using namespace std;
class Date1
{
friend ostream &operator<<(ostream& , const Date1 &);
public:
Date1(int m1 = 1, int d1 = 1, int y1 = 1900);
void setDate1(int, int, int);
bool leapYear1() const;
bool endOfMonth1() const;
int getMonth1() const
{
return month1;
}
int getDay1() const
{
return day1;
}
int getYear1() const
{
return year1;
}
string getMonthString1() const;
void operator+=(int);
Date1& operator=(Date1 other1);
private:
int month1;
int day1;
int year1;
static const int days1[];
static const string monthName1[];
void helpIncrement1();
};
#endif
//Date1.cpp
#include <iostream>
#include \"Date1.h\"
#include <string>
const int Date1::days1[] =
{
0, 31, 28,
31, 30, 31,
30, 31, 31,
30, 31, 30, 31
};
const string Date1::monthName1[] =
{ \"\", \"January\", \"February\", \"March\",
\"April\", \"May\", \"June\", \"July\",
\"August\", \"September\",
\"October\", \"November\", \"December\"
};
Date1::Date1(int m1, int d1, int y1)
{
setDate1(m1, d1, y1);
}
void Date1::setDate1(int mm1, int dd1, int yy1)
{
month1 = (mm1 >= 1 && mm1 <= 12) ? mm1 : 1;
year1 = (yy1 >= 1900 && yy1 <= 2100) ? yy1 : 1900;
if (month1 == 2 && leapYear1())
day1 = (dd1 >= 1&& dd1 <= 29) ? dd1 : 1;
else
day1 = (dd1 >= 1&& dd1 <= days1[month1]) ? dd1 : 1;
}
void Date1::operator+=(int additionalDays1)
{
for (int i1 = 0; i1 < additionalDays1; i1++)
helpIncrement1();
}
bool Date1::leapYear1() const
{
if (year1 % 400 == 0 || (year1 % 100 != 0&& year1 % 4 == 0))
return true;
else
return false;
}
bool Date1::endOfMonth1() const
{
if (month1 == 2 && leapYear1())
return (day1 == 29);
else
return (day1 == days1[month1]);
}
void Date1::helpIncrement1()
{
if (!endOfMonth1())
{
day1++;
}
else if (month1 < 12)
{
day1 = 1;
++month1;
}
else
{
day1 = 1;
month1 = 1;
++year1;
}
}
Date1& Date1::operator=(Date1 other1)
{
day1 = other1.day1;
month1 = other1.month1;
year1 = other1.year1;
return *this;
}
ostream &operator<<(ostream &output1, const Date1& d1)
{
output1 << d1.monthName1[d1.month1]<< \' \' << d1.day1 << \", \" << d1.year1;
return output1;
}
string Date1::getMonthString1() const
{
return monthName1[month1];
}
//Patient1.h
#ifndef Patient_h
#define Patient_h
#include \"Date1.h\"
#include <string>
struct procedure1
{
Date1 dateOfProcedure1;
int procedureID1;
int procedureProviderID1;
};
class Patient1
{
private:
int ID1;
char firstName1[15];
char lastName1[15];
Date1 birthdate1;
int primaryDoctorID1;
procedure1 record1[500];
int currentCountOfProcedures1;
public:
Patient1(int, const char *, const char *, Date1, int);
Patient1() : ID1(0), firstName1{}, lastName1{}, birthdate1(0, 0, 0), primaryDoctorID1(0) {};
void setID1(int);
void setFirstName1(const char *);
void setLastName1(const char *);
void setBirthDate1(Date1);
void setPrimaryDoctorID1(int);
int getID1();
const char * getFirstName1();
const char * getLastName1();
Date1 getBirthDate1();
int getPrimaryDoctorID1();
Patient1& operator=(Patient1 other1);
bool enterProcedure1(Date1 procedureDate1, int procedureID1, int procedureProviderID1);
void printAllProcedures1();
};
#endif
//Patient1.cpp
#include \"Patient1.h\"
#include <iostream>
using namespace std;
Patient1::Patient1(int id1, const char * first1, const char *last1, Date1 birth1, int doctor1)
{
setID1(id1);
setFirstName1(first1);
setLastName1(last1);
setBirthDate1(birth1);
setPrimaryDoctorID1(doctor1);
};
void Patient1::setID1(int id1)
{
ID1 = id1;
}
void Patient1::setFirstName1(const char * first1)
{
if (strlen(first1) > 15)
strncpy_s(firstName1, first1, 14);
else
strcpy_s(firstName1, first1);
}
void Patient1::setLastName1(const char * last1)
{
if (strlen(last1) > 15)
strncpy_s(lastName1, last1, 14);
else
strcpy_s(lastName1, last1);
}
void Patient1::setBirthDate1(Date1 birth1)
{
birthdate1 = birth1;
}
void Patient1::setPrimaryDoctorID1(int doctor1)
{
primaryDoctorID1 = doctor1;
}
int Patient1::getID1()
{
return ID1;
}
const char * Patient1::getFirstName1()
{
return firstName1;
}
const char * Patient1::getLastName1()
{
return lastName1;
}
Date1 Patient1::getBirthDate1()
{
return birthdate1;
}
int Patient1::getPrimaryDoctorID1()
{
return primaryDoctorID1;
}
bool Patient1::enterProcedure1(Date1 procedureDate1, int procedureID1, int procedureProviderID1)
{
if (currentCountOfProcedures1 > 500)
{
cout << \"Can\'t add more procedures\" << endl;
return false;
}
else
{
record1[currentCountOfProcedures1].dateOfProcedure1 = procedureDate1;
record1[currentCountOfProcedures1].procedureID1 = procedureID1;
record1[currentCountOfProcedures1].procedureProviderID1 = procedureProviderID1;
currentCountOfProcedures1++;
return true;
}
}
void Patient1::printAllProcedures1()
{
cout << \"Procedures of the patient\"<< endl;
for (int i1 = 0; i1 < currentCountOfProcedures1; i1++)
{
cout << \"Procedure-Date: \" << record1[i1].dateOfProcedure1 << endl;
cout << \"Procedure-ID: \" << record1[i1].procedureID1 << endl;
cout << \"Provider-ID: \"<< record1[i1].procedureProviderID1 << endl;
}
}
Patient1& Patient1::operator=(Patient1 other1)
{
ID1 = other1.ID1;
strcpy_s(firstName1, other1.firstName1);
strcpy_s(lastName1, other1.lastName1);
birthdate1 = other1.birthdate1;
primaryDoctorID1 = other1.primaryDoctorID1;
for (int i1 = 0; i1 < other1.currentCountOfProcedures1; i1++)
{
record1[i1] = other1.record1[i1];
}
currentCountOfProcedures1 = other1.currentCountOfProcedures1;
return *this;
}
//Menu.cpp
#include <iostream>
#include <fstream>
#include \"Patient1.h\"
#include \"Date1.h\"
using namespace std;
void Menu1();
void Remove1(Patient1 checkIn1[], int& count1, int index1);
int main(int argc, const char * argv[])
{
Patient1 checkIn1[10];
Patient1 patient1[20];
char choice1;
int i1 = 0;
int id1 = 0,
doctor1 = 0,
countAll1 = 0,
count1 = 0;
int day1, month1, year1;
char first1[15], last1[15];
Date1 birthdate1, current1;
bool found1 = false;
ifstream inFile1;
inFile1.open(\"CurrentPatients1.txt\", ios::in | ios::binary);
if (inFile1.is_open())
{
inFile1.read((char*)&countAll1, sizeof(int));
for (int i1 = 0; i1 < countAll1; i1++)
{
inFile1.read((char*)&patient1[i1], sizeof(Patient1));
}
inFile1.close();
}
cout << \"Enter present date\" << endl;
cout << \"Day: \";
cin >> day1;
cout << \"Month: \";
cin >> month1;
cout << \"Year: \";
cin >> year1;
current1.setDate1(month1, day1, year1);
do
{
Menu1();
cin >> choice1;
switch (choice1)
{
case \'A\':
cout<< \"---------------------------\" << endl;
cout<< \"Check-In a new patient\" << endl << endl;
cout<< \"Patient-ID: \";
cout<< countAll1 + 1 << endl;
checkIn1[count1].setID1(countAll1 + 1);
cout<< \"First name: \";
cin>> first1;
checkIn1[count1].setFirstName1(first1);
cout<< \"Last name: \";
cin>> last1;
checkIn1[count1].setLastName1(last1);
cout<< \"Doctor-ID: \";
cin>> doctor1;
checkIn1[count1].setPrimaryDoctorID1(doctor1);
cout<< \"Birthdate \" << endl;
cout<< \"Day: \";
cin>> day1;
cout<< \"Month: \";
cin>> month1;
cout<< \"Year: \";
cin>> year1;
birthdate1.setDate1(month1, day1, year1);
checkIn1[count1].setBirthDate1(birthdate1);
patient1[countAll1] = checkIn1[count1];
count1++;
countAll1++;
break;
case \'B\':
cout<< \"---------------------------\" << endl;
cout<< \"Check-In a returning patient\" << endl << endl;
found1 = false;
i1 = 0;
do
{
cout << \"Enter Patient-ID: \";
cin >> id1;
do
{
if (patient1[i1].getID1() == id1)
{
checkIn1[count1] = patient1[i1];
count1++;
found1 = true;
}
i1++;
} while (!found1 && i1 < countAll1);
if (!found1)
{
cout << \"Not available\"<< endl;
cout << \"Check-In as a new patient? N or Y: \";
cin >> choice1;
}
} while (!found1 && choice1 == \'N\');
break;
case \'C\':
found1 = false;
cout<< \"---------------------------\" << endl;
cout<< \"Check-Out a patient\" << endl;
i1 = 0;
do
{
cout << \"Enter Checked-Out patient-ID: \";
cin >> id1;
do
{
if (checkIn1[i1].getID1() == id1)
{
cout<< \"Provider-ID: \";
cin>> doctor1;
cout<< \"Procedure-ID: \";
cin>> id1;
cout<< checkIn1[i1].enterProcedure1(current1, id1, doctor1);
for (int j = 0; j < countAll1; j++)
if (patient1[j].getID1() == checkIn1[i1].getID1())
{
patient1[j].enterProcedure1(current1, id1, doctor1);
cout << j;
cout << \"Patient-ID: \" << j + 1<< \" Checked-Out\" << endl << endl;
}
Remove1(checkIn1, count1, i1);
found1 = true;
}
i1++;
} while (!found1 && i1 < count1);
if (!found1)
{
cout << \"Not available\"<< endl;
cout << \"Checked-In as a new patient / Checked-In as a returning patient? N or Y: \";
cin >> choice1;
}
} while (!found1 && choice1 == \'N\');
break;
case \'D\':
found1 = false;
cout<< \"---------------------------\" << endl;
cout<< \"Display all info of the patient\" << endl << endl;
cout<< \"Enter Patient-ID: \";
cin>> id1;
i1 = 0;
do
{
if (patient1[i1].getID1() == id1)
{
cout << \"Patient-ID \"<< patient1[i1].getID1() << endl;
cout << \"Name: \"<< patient1[i1].getFirstName1() << \" \" << patient1[i1].getLastName1() << endl;
cout << \"Birthdate: \"<< patient1[i1].getBirthDate1() << endl;
cout << \"Doctor-ID: \"<< patient1[i1].getPrimaryDoctorID1() << endl;
patient1[i1].printAllProcedures1();
found1 = true;
}
i1++;
} while (!found1 && i1 < countAll1);
if (!found1)
cout << \"Not available\" << endl;
break;
case \'E\':
cout<< \"---------------------------\" << endl;
cout<< \"Patient checked-in yet not checked-out\" << endl<< endl;
if (count1> 0)
{
for (int i1 = 0; i1 < count1; i1++)
{
cout << \"Patient-ID \"<< checkIn1[i1].getID1() << endl;
cout << \"Name: \"<< checkIn1[i1].getFirstName1() << \" \" << checkIn1[i1].getLastName1() << endl;
cout << \"Birthdate: \"<< checkIn1[i1].getBirthDate1() << endl;
cout << \"Doctor-ID: \"<< checkIn1[i1].getPrimaryDoctorID1() << endl << endl;
}
}
else
cout << \"All patients checked-out\"<< endl << endl;
break;
case \'F\':
cout<< \"---------------------------\" << endl;
if (count1 == 0)
{
ofstream outFile;
outFile.open(\"CurrentPatients1.txt\", ios::out | ios::binary);
if (outFile.is_open())
{
outFile.write((char*)&countAll1, sizeof(int));
for (int i1 = 0; i1 < countAll1; i1++)
outFile.write((char*)&patient1[i1], sizeof(Patient1));
outFile.close();
cout << \"Finish\"<< endl;
}
}
else
{
for (int i1 = 0; i1 < count1; i1++)
{
cout << checkIn1[i1].getID1() << endl;
cout << checkIn1[i1].getFirstName1() << \" \" << checkIn1[i1].getLastName1() << endl;
cout << checkIn1[i1].getBirthDate1() << endl;
cout << checkIn1[i1].getPrimaryDoctorID1() << endl;
}
choice1 = \'A\';
}
break;
}
} while (choice1 != \'F\' && choice1 != \'f\');
return 0;
}
void Menu1()
{
cout << \"-------------------------------\"<< endl;
cout << \"Menu\" << endl;
cout << \"A : Check-in new patient\"<< endl;
cout << \"B : Check-in returning patient\"<< endl;
cout << \"C : Check-out a patient\" << endl;
cout << \"D : Display info of a patient\"<< endl;
cout << \"E : Display list of patients who checked-in yet not checked-out\" << endl;
cout << \"F : Quit\" << endl;
cout << \"Enter choice (A, B, C, D, E, F): \";
}
void Remove1(Patient1 checkIn1[], int& count1, int index1)
{
for (int i1 = index1; i1 < count1; i1++)
checkIn1[i1] = checkIn1[i1 + 1];
count1--;
}
Solution
#ifndef Date_h
#define Date_h
#include <iostream>
#include <string>
using namespace std;
class Date1
{
friend ostream &operator<<(ostream& , const Date1 &);
public:
Date1(int m1 = 1, int d1 = 1, int y1 = 1900);
void setDate1(int, int, int);
bool leapYear1() const;
bool endOfMonth1() const;
int getMonth1() const
{
return month1;
}
int getDay1() const
{
return day1;
}
int getYear1() const
{
return year1;
}
string getMonthString1() const;
void operator+=(int);
Date1& operator=(Date1 other1);
private:
int month1;
int day1;
int year1;
static const int days1[];
static const string monthName1[];
void helpIncrement1();
};
#endif
//Date1.cpp
#include <iostream>
#include \"Date1.h\"
#include <string>
const int Date1::days1[] =
{
0, 31, 28,
31, 30, 31,
30, 31, 31,
30, 31, 30, 31
};
const string Date1::monthName1[] =
{ \"\", \"January\", \"February\", \"March\",
\"April\", \"May\", \"June\", \"July\",
\"August\", \"September\",
\"October\", \"November\", \"December\"
};
Date1::Date1(int m1, int d1, int y1)
{
setDate1(m1, d1, y1);
}
void Date1::setDate1(int mm1, int dd1, int yy1)
{
month1 = (mm1 >= 1 && mm1 <= 12) ? mm1 : 1;
year1 = (yy1 >= 1900 && yy1 <= 2100) ? yy1 : 1900;
if (month1 == 2 && leapYear1())
day1 = (dd1 >= 1&& dd1 <= 29) ? dd1 : 1;
else
day1 = (dd1 >= 1&& dd1 <= days1[month1]) ? dd1 : 1;
}
void Date1::operator+=(int additionalDays1)
{
for (int i1 = 0; i1 < additionalDays1; i1++)
helpIncrement1();
}
bool Date1::leapYear1() const
{
if (year1 % 400 == 0 || (year1 % 100 != 0&& year1 % 4 == 0))
return true;
else
return false;
}
bool Date1::endOfMonth1() const
{
if (month1 == 2 && leapYear1())
return (day1 == 29);
else
return (day1 == days1[month1]);
}
void Date1::helpIncrement1()
{
if (!endOfMonth1())
{
day1++;
}
else if (month1 < 12)
{
day1 = 1;
++month1;
}
else
{
day1 = 1;
month1 = 1;
++year1;
}
}
Date1& Date1::operator=(Date1 other1)
{
day1 = other1.day1;
month1 = other1.month1;
year1 = other1.year1;
return *this;
}
ostream &operator<<(ostream &output1, const Date1& d1)
{
output1 << d1.monthName1[d1.month1]<< \' \' << d1.day1 << \", \" << d1.year1;
return output1;
}
string Date1::getMonthString1() const
{
return monthName1[month1];
}
//Patient1.h
#ifndef Patient_h
#define Patient_h
#include \"Date1.h\"
#include <string>
struct procedure1
{
Date1 dateOfProcedure1;
int procedureID1;
int procedureProviderID1;
};
class Patient1
{
private:
int ID1;
char firstName1[15];
char lastName1[15];
Date1 birthdate1;
int primaryDoctorID1;
procedure1 record1[500];
int currentCountOfProcedures1;
public:
Patient1(int, const char *, const char *, Date1, int);
Patient1() : ID1(0), firstName1{}, lastName1{}, birthdate1(0, 0, 0), primaryDoctorID1(0) {};
void setID1(int);
void setFirstName1(const char *);
void setLastName1(const char *);
void setBirthDate1(Date1);
void setPrimaryDoctorID1(int);
int getID1();
const char * getFirstName1();
const char * getLastName1();
Date1 getBirthDate1();
int getPrimaryDoctorID1();
Patient1& operator=(Patient1 other1);
bool enterProcedure1(Date1 procedureDate1, int procedureID1, int procedureProviderID1);
void printAllProcedures1();
};
#endif
//Patient1.cpp
#include \"Patient1.h\"
#include <iostream>
using namespace std;
Patient1::Patient1(int id1, const char * first1, const char *last1, Date1 birth1, int doctor1)
{
setID1(id1);
setFirstName1(first1);
setLastName1(last1);
setBirthDate1(birth1);
setPrimaryDoctorID1(doctor1);
};
void Patient1::setID1(int id1)
{
ID1 = id1;
}
void Patient1::setFirstName1(const char * first1)
{
if (strlen(first1) > 15)
strncpy_s(firstName1, first1, 14);
else
strcpy_s(firstName1, first1);
}
void Patient1::setLastName1(const char * last1)
{
if (strlen(last1) > 15)
strncpy_s(lastName1, last1, 14);
else
strcpy_s(lastName1, last1);
}
void Patient1::setBirthDate1(Date1 birth1)
{
birthdate1 = birth1;
}
void Patient1::setPrimaryDoctorID1(int doctor1)
{
primaryDoctorID1 = doctor1;
}
int Patient1::getID1()
{
return ID1;
}
const char * Patient1::getFirstName1()
{
return firstName1;
}
const char * Patient1::getLastName1()
{
return lastName1;
}
Date1 Patient1::getBirthDate1()
{
return birthdate1;
}
int Patient1::getPrimaryDoctorID1()
{
return primaryDoctorID1;
}
bool Patient1::enterProcedure1(Date1 procedureDate1, int procedureID1, int procedureProviderID1)
{
if (currentCountOfProcedures1 > 500)
{
cout << \"Can\'t add more procedures\" << endl;
return false;
}
else
{
record1[currentCountOfProcedures1].dateOfProcedure1 = procedureDate1;
record1[currentCountOfProcedures1].procedureID1 = procedureID1;
record1[currentCountOfProcedures1].procedureProviderID1 = procedureProviderID1;
currentCountOfProcedures1++;
return true;
}
}
void Patient1::printAllProcedures1()
{
cout << \"Procedures of the patient\"<< endl;
for (int i1 = 0; i1 < currentCountOfProcedures1; i1++)
{
cout << \"Procedure-Date: \" << record1[i1].dateOfProcedure1 << endl;
cout << \"Procedure-ID: \" << record1[i1].procedureID1 << endl;
cout << \"Provider-ID: \"<< record1[i1].procedureProviderID1 << endl;
}
}
Patient1& Patient1::operator=(Patient1 other1)
{
ID1 = other1.ID1;
strcpy_s(firstName1, other1.firstName1);
strcpy_s(lastName1, other1.lastName1);
birthdate1 = other1.birthdate1;
primaryDoctorID1 = other1.primaryDoctorID1;
for (int i1 = 0; i1 < other1.currentCountOfProcedures1; i1++)
{
record1[i1] = other1.record1[i1];
}
currentCountOfProcedures1 = other1.currentCountOfProcedures1;
return *this;
}
//Menu.cpp
#include <iostream>
#include <fstream>
#include \"Patient1.h\"
#include \"Date1.h\"
using namespace std;
void Menu1();
void Remove1(Patient1 checkIn1[], int& count1, int index1);
int main(int argc, const char * argv[])
{
Patient1 checkIn1[10];
Patient1 patient1[20];
char choice1;
int i1 = 0;
int id1 = 0,
doctor1 = 0,
countAll1 = 0,
count1 = 0;
int day1, month1, year1;
char first1[15], last1[15];
Date1 birthdate1, current1;
bool found1 = false;
ifstream inFile1;
inFile1.open(\"CurrentPatients1.txt\", ios::in | ios::binary);
if (inFile1.is_open())
{
inFile1.read((char*)&countAll1, sizeof(int));
for (int i1 = 0; i1 < countAll1; i1++)
{
inFile1.read((char*)&patient1[i1], sizeof(Patient1));
}
inFile1.close();
}
cout << \"Enter present date\" << endl;
cout << \"Day: \";
cin >> day1;
cout << \"Month: \";
cin >> month1;
cout << \"Year: \";
cin >> year1;
current1.setDate1(month1, day1, year1);
do
{
Menu1();
cin >> choice1;
switch (choice1)
{
case \'A\':
cout<< \"---------------------------\" << endl;
cout<< \"Check-In a new patient\" << endl << endl;
cout<< \"Patient-ID: \";
cout<< countAll1 + 1 << endl;
checkIn1[count1].setID1(countAll1 + 1);
cout<< \"First name: \";
cin>> first1;
checkIn1[count1].setFirstName1(first1);
cout<< \"Last name: \";
cin>> last1;
checkIn1[count1].setLastName1(last1);
cout<< \"Doctor-ID: \";
cin>> doctor1;
checkIn1[count1].setPrimaryDoctorID1(doctor1);
cout<< \"Birthdate \" << endl;
cout<< \"Day: \";
cin>> day1;
cout<< \"Month: \";
cin>> month1;
cout<< \"Year: \";
cin>> year1;
birthdate1.setDate1(month1, day1, year1);
checkIn1[count1].setBirthDate1(birthdate1);
patient1[countAll1] = checkIn1[count1];
count1++;
countAll1++;
break;
case \'B\':
cout<< \"---------------------------\" << endl;
cout<< \"Check-In a returning patient\" << endl << endl;
found1 = false;
i1 = 0;
do
{
cout << \"Enter Patient-ID: \";
cin >> id1;
do
{
if (patient1[i1].getID1() == id1)
{
checkIn1[count1] = patient1[i1];
count1++;
found1 = true;
}
i1++;
} while (!found1 && i1 < countAll1);
if (!found1)
{
cout << \"Not available\"<< endl;
cout << \"Check-In as a new patient? N or Y: \";
cin >> choice1;
}
} while (!found1 && choice1 == \'N\');
break;
case \'C\':
found1 = false;
cout<< \"---------------------------\" << endl;
cout<< \"Check-Out a patient\" << endl;
i1 = 0;
do
{
cout << \"Enter Checked-Out patient-ID: \";
cin >> id1;
do
{
if (checkIn1[i1].getID1() == id1)
{
cout<< \"Provider-ID: \";
cin>> doctor1;
cout<< \"Procedure-ID: \";
cin>> id1;
cout<< checkIn1[i1].enterProcedure1(current1, id1, doctor1);
for (int j = 0; j < countAll1; j++)
if (patient1[j].getID1() == checkIn1[i1].getID1())
{
patient1[j].enterProcedure1(current1, id1, doctor1);
cout << j;
cout << \"Patient-ID: \" << j + 1<< \" Checked-Out\" << endl << endl;
}
Remove1(checkIn1, count1, i1);
found1 = true;
}
i1++;
} while (!found1 && i1 < count1);
if (!found1)
{
cout << \"Not available\"<< endl;
cout << \"Checked-In as a new patient / Checked-In as a returning patient? N or Y: \";
cin >> choice1;
}
} while (!found1 && choice1 == \'N\');
break;
case \'D\':
found1 = false;
cout<< \"---------------------------\" << endl;
cout<< \"Display all info of the patient\" << endl << endl;
cout<< \"Enter Patient-ID: \";
cin>> id1;
i1 = 0;
do
{
if (patient1[i1].getID1() == id1)
{
cout << \"Patient-ID \"<< patient1[i1].getID1() << endl;
cout << \"Name: \"<< patient1[i1].getFirstName1() << \" \" << patient1[i1].getLastName1() << endl;
cout << \"Birthdate: \"<< patient1[i1].getBirthDate1() << endl;
cout << \"Doctor-ID: \"<< patient1[i1].getPrimaryDoctorID1() << endl;
patient1[i1].printAllProcedures1();
found1 = true;
}
i1++;
} while (!found1 && i1 < countAll1);
if (!found1)
cout << \"Not available\" << endl;
break;
case \'E\':
cout<< \"---------------------------\" << endl;
cout<< \"Patient checked-in yet not checked-out\" << endl<< endl;
if (count1> 0)
{
for (int i1 = 0; i1 < count1; i1++)
{
cout << \"Patient-ID \"<< checkIn1[i1].getID1() << endl;
cout << \"Name: \"<< checkIn1[i1].getFirstName1() << \" \" << checkIn1[i1].getLastName1() << endl;
cout << \"Birthdate: \"<< checkIn1[i1].getBirthDate1() << endl;
cout << \"Doctor-ID: \"<< checkIn1[i1].getPrimaryDoctorID1() << endl << endl;
}
}
else
cout << \"All patients checked-out\"<< endl << endl;
break;
case \'F\':
cout<< \"---------------------------\" << endl;
if (count1 == 0)
{
ofstream outFile;
outFile.open(\"CurrentPatients1.txt\", ios::out | ios::binary);
if (outFile.is_open())
{
outFile.write((char*)&countAll1, sizeof(int));
for (int i1 = 0; i1 < countAll1; i1++)
outFile.write((char*)&patient1[i1], sizeof(Patient1));
outFile.close();
cout << \"Finish\"<< endl;
}
}
else
{
for (int i1 = 0; i1 < count1; i1++)
{
cout << checkIn1[i1].getID1() << endl;
cout << checkIn1[i1].getFirstName1() << \" \" << checkIn1[i1].getLastName1() << endl;
cout << checkIn1[i1].getBirthDate1() << endl;
cout << checkIn1[i1].getPrimaryDoctorID1() << endl;
}
choice1 = \'A\';
}
break;
}
} while (choice1 != \'F\' && choice1 != \'f\');
return 0;
}
void Menu1()
{
cout << \"-------------------------------\"<< endl;
cout << \"Menu\" << endl;
cout << \"A : Check-in new patient\"<< endl;
cout << \"B : Check-in returning patient\"<< endl;
cout << \"C : Check-out a patient\" << endl;
cout << \"D : Display info of a patient\"<< endl;
cout << \"E : Display list of patients who checked-in yet not checked-out\" << endl;
cout << \"F : Quit\" << endl;
cout << \"Enter choice (A, B, C, D, E, F): \";
}
void Remove1(Patient1 checkIn1[], int& count1, int index1)
{
for (int i1 = index1; i1 < count1; i1++)
checkIn1[i1] = checkIn1[i1 + 1];
count1--;
}

















