SlideShare a Scribd company logo
1 of 31
Download to read offline
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
#include
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
#include "Date1.h"
#include
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
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
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
#include
#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
#include
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
#include "Date1.h"
#include
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
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
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
#include
#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--;
}

More Related Content

Similar to Question I need help with c++ Simple Classes Assigment. i get this .pdf

HQR Framework optimization for predicting patient treatment time in big data
HQR Framework optimization for predicting patient treatment time in big dataHQR Framework optimization for predicting patient treatment time in big data
HQR Framework optimization for predicting patient treatment time in big datadbpublications
 
HQR Framework optimization for predicting patient treatment time in big data
HQR Framework optimization for predicting patient treatment time in big dataHQR Framework optimization for predicting patient treatment time in big data
HQR Framework optimization for predicting patient treatment time in big datadbpublications
 
Conway Regional Hospital has recently hired you to help them.pdf
Conway Regional Hospital has recently hired you to help them.pdfConway Regional Hospital has recently hired you to help them.pdf
Conway Regional Hospital has recently hired you to help them.pdfabhijitakolkar1
 
Insurance Optimization
Insurance OptimizationInsurance Optimization
Insurance OptimizationAlbert Chu
 
Hospital management project_BY RITIKA SAHU.
Hospital management project_BY RITIKA SAHU.Hospital management project_BY RITIKA SAHU.
Hospital management project_BY RITIKA SAHU.Ritika sahu
 
ECE 263264                     Fall 2016 Final Project  .docx
ECE 263264                     Fall 2016 Final Project  .docxECE 263264                     Fall 2016 Final Project  .docx
ECE 263264                     Fall 2016 Final Project  .docxSALU18
 
Hello. Im creating a class called Bill. I need to design the class.pdf
Hello. Im creating a class called Bill. I need to design the class.pdfHello. Im creating a class called Bill. I need to design the class.pdf
Hello. Im creating a class called Bill. I need to design the class.pdfbarristeressaseren71
 
In C++ 154 Define a base class called Person The .pdf
In C++ 154   Define a base class called Person The .pdfIn C++ 154   Define a base class called Person The .pdf
In C++ 154 Define a base class called Person The .pdfaayushmaany2k14
 
Kupdf.com 292609858 computer-science-c-project-on-hospital-management-system-...
Kupdf.com 292609858 computer-science-c-project-on-hospital-management-system-...Kupdf.com 292609858 computer-science-c-project-on-hospital-management-system-...
Kupdf.com 292609858 computer-science-c-project-on-hospital-management-system-...Manjeet Maan
 
Programming code in C must be C loops reque.pdf
Programming code in C  must be C loops reque.pdfProgramming code in C  must be C loops reque.pdf
Programming code in C must be C loops reque.pdfarchanadesignfashion
 
Hello. Im working on an assignment that tests inheritance and comp.pdf
Hello. Im working on an assignment that tests inheritance and comp.pdfHello. Im working on an assignment that tests inheritance and comp.pdf
Hello. Im working on an assignment that tests inheritance and comp.pdfduttakajal70
 
How to manage your Experimental Protocol with Basic Statistics
How to manage your Experimental Protocol with Basic StatisticsHow to manage your Experimental Protocol with Basic Statistics
How to manage your Experimental Protocol with Basic StatisticsYoann Pageaud
 
Computer Science class 12
Computer Science  class 12Computer Science  class 12
Computer Science class 12Abhishek Sinha
 
Creating Equal Cost Groups for Trauma Patients in Hospitals in Israel
Creating Equal Cost Groups for Trauma Patients in Hospitals in Israel Creating Equal Cost Groups for Trauma Patients in Hospitals in Israel
Creating Equal Cost Groups for Trauma Patients in Hospitals in Israel Salford Systems
 
Project presentation sowjanya_132
Project presentation sowjanya_132Project presentation sowjanya_132
Project presentation sowjanya_132SowjanyaBojja1
 
Hospital Managment System Project Proposal
Hospital Managment System Project ProposalHospital Managment System Project Proposal
Hospital Managment System Project ProposalAzeemaj101
 
Medical Billing Database
Medical Billing DatabaseMedical Billing Database
Medical Billing DatabaseNoelle Vaughn
 

Similar to Question I need help with c++ Simple Classes Assigment. i get this .pdf (20)

HQR Framework optimization for predicting patient treatment time in big data
HQR Framework optimization for predicting patient treatment time in big dataHQR Framework optimization for predicting patient treatment time in big data
HQR Framework optimization for predicting patient treatment time in big data
 
HQR Framework optimization for predicting patient treatment time in big data
HQR Framework optimization for predicting patient treatment time in big dataHQR Framework optimization for predicting patient treatment time in big data
HQR Framework optimization for predicting patient treatment time in big data
 
Conway Regional Hospital has recently hired you to help them.pdf
Conway Regional Hospital has recently hired you to help them.pdfConway Regional Hospital has recently hired you to help them.pdf
Conway Regional Hospital has recently hired you to help them.pdf
 
Insurance Optimization
Insurance OptimizationInsurance Optimization
Insurance Optimization
 
Hospital management project_BY RITIKA SAHU.
Hospital management project_BY RITIKA SAHU.Hospital management project_BY RITIKA SAHU.
Hospital management project_BY RITIKA SAHU.
 
ECE 263264                     Fall 2016 Final Project  .docx
ECE 263264                     Fall 2016 Final Project  .docxECE 263264                     Fall 2016 Final Project  .docx
ECE 263264                     Fall 2016 Final Project  .docx
 
Hello. Im creating a class called Bill. I need to design the class.pdf
Hello. Im creating a class called Bill. I need to design the class.pdfHello. Im creating a class called Bill. I need to design the class.pdf
Hello. Im creating a class called Bill. I need to design the class.pdf
 
In C++ 154 Define a base class called Person The .pdf
In C++ 154   Define a base class called Person The .pdfIn C++ 154   Define a base class called Person The .pdf
In C++ 154 Define a base class called Person The .pdf
 
Kupdf.com 292609858 computer-science-c-project-on-hospital-management-system-...
Kupdf.com 292609858 computer-science-c-project-on-hospital-management-system-...Kupdf.com 292609858 computer-science-c-project-on-hospital-management-system-...
Kupdf.com 292609858 computer-science-c-project-on-hospital-management-system-...
 
Programming code in C must be C loops reque.pdf
Programming code in C  must be C loops reque.pdfProgramming code in C  must be C loops reque.pdf
Programming code in C must be C loops reque.pdf
 
Hello. Im working on an assignment that tests inheritance and comp.pdf
Hello. Im working on an assignment that tests inheritance and comp.pdfHello. Im working on an assignment that tests inheritance and comp.pdf
Hello. Im working on an assignment that tests inheritance and comp.pdf
 
How to manage your Experimental Protocol with Basic Statistics
How to manage your Experimental Protocol with Basic StatisticsHow to manage your Experimental Protocol with Basic Statistics
How to manage your Experimental Protocol with Basic Statistics
 
Computer Science class 12
Computer Science  class 12Computer Science  class 12
Computer Science class 12
 
Creating Equal Cost Groups for Trauma Patients in Hospitals in Israel
Creating Equal Cost Groups for Trauma Patients in Hospitals in Israel Creating Equal Cost Groups for Trauma Patients in Hospitals in Israel
Creating Equal Cost Groups for Trauma Patients in Hospitals in Israel
 
Portfolio Three
Portfolio ThreePortfolio Three
Portfolio Three
 
Project presentation sowjanya_132
Project presentation sowjanya_132Project presentation sowjanya_132
Project presentation sowjanya_132
 
Portfolio3
Portfolio3Portfolio3
Portfolio3
 
Hospital Managment System Project Proposal
Hospital Managment System Project ProposalHospital Managment System Project Proposal
Hospital Managment System Project Proposal
 
Medical Billing Database
Medical Billing DatabaseMedical Billing Database
Medical Billing Database
 
L6 m256 block2_unit6
L6 m256 block2_unit6L6 m256 block2_unit6
L6 m256 block2_unit6
 

More from exxonzone

An employee is assigned to one department and a department may have m.pdf
An employee is assigned to one department and a department may have m.pdfAn employee is assigned to one department and a department may have m.pdf
An employee is assigned to one department and a department may have m.pdfexxonzone
 
10 Points ntilfy cach of the the contour signatures shown on the map .pdf
10 Points ntilfy cach of the the contour signatures shown on the map .pdf10 Points ntilfy cach of the the contour signatures shown on the map .pdf
10 Points ntilfy cach of the the contour signatures shown on the map .pdfexxonzone
 
Describe the principal cash transfer tools-Wire Transfer-EDT-E.pdf
Describe the principal cash transfer tools-Wire Transfer-EDT-E.pdfDescribe the principal cash transfer tools-Wire Transfer-EDT-E.pdf
Describe the principal cash transfer tools-Wire Transfer-EDT-E.pdfexxonzone
 
Which sentence contains an infinitive AWill you take the package to.pdf
Which sentence contains an infinitive AWill you take the package to.pdfWhich sentence contains an infinitive AWill you take the package to.pdf
Which sentence contains an infinitive AWill you take the package to.pdfexxonzone
 
Whats the Schema Table Column Row Attribute Entity Pri.pdf
Whats the Schema  Table  Column  Row  Attribute  Entity  Pri.pdfWhats the Schema  Table  Column  Row  Attribute  Entity  Pri.pdf
Whats the Schema Table Column Row Attribute Entity Pri.pdfexxonzone
 
Which of the following groups produce sporangia on leaves (Mark all.pdf
Which of the following groups produce sporangia on leaves (Mark all.pdfWhich of the following groups produce sporangia on leaves (Mark all.pdf
Which of the following groups produce sporangia on leaves (Mark all.pdfexxonzone
 
What is tax research What is the purpose of conducting tax research.pdf
What is tax research What is the purpose of conducting tax research.pdfWhat is tax research What is the purpose of conducting tax research.pdf
What is tax research What is the purpose of conducting tax research.pdfexxonzone
 
What is a social networking analysisa) represents the interconnec.pdf
What is a social networking analysisa) represents the interconnec.pdfWhat is a social networking analysisa) represents the interconnec.pdf
What is a social networking analysisa) represents the interconnec.pdfexxonzone
 
BiopsychologyWhy sleep (psychology) is interestingSolutionS.pdf
BiopsychologyWhy sleep (psychology) is interestingSolutionS.pdfBiopsychologyWhy sleep (psychology) is interestingSolutionS.pdf
BiopsychologyWhy sleep (psychology) is interestingSolutionS.pdfexxonzone
 
The following question does not require any knowledge of statistics t.pdf
The following question does not require any knowledge of statistics t.pdfThe following question does not require any knowledge of statistics t.pdf
The following question does not require any knowledge of statistics t.pdfexxonzone
 
Do antidepressants help A researcher studied the effect of an an.pdf
Do antidepressants help A researcher studied the effect of an an.pdfDo antidepressants help A researcher studied the effect of an an.pdf
Do antidepressants help A researcher studied the effect of an an.pdfexxonzone
 
Shensen and colleagues were interested in studying older adults.pdf
Shensen and colleagues were interested in studying older adults.pdfShensen and colleagues were interested in studying older adults.pdf
Shensen and colleagues were interested in studying older adults.pdfexxonzone
 
Much of the heat that drives convection in the mantlea. Is generat.pdf
Much of the heat that drives convection in the mantlea. Is generat.pdfMuch of the heat that drives convection in the mantlea. Is generat.pdf
Much of the heat that drives convection in the mantlea. Is generat.pdfexxonzone
 
In explaining what we now call evolution, Darwin often used the phra.pdf
In explaining what we now call evolution, Darwin often used the phra.pdfIn explaining what we now call evolution, Darwin often used the phra.pdf
In explaining what we now call evolution, Darwin often used the phra.pdfexxonzone
 
Las Homework 4 Spotlight Figure 27.18 Diagnosis of Acid-Base Disorde.pdf
Las Homework 4 Spotlight Figure 27.18 Diagnosis of Acid-Base Disorde.pdfLas Homework 4 Spotlight Figure 27.18 Diagnosis of Acid-Base Disorde.pdf
Las Homework 4 Spotlight Figure 27.18 Diagnosis of Acid-Base Disorde.pdfexxonzone
 
Check all that are characteristics of cardiac muscle. Cells are .pdf
Check all that are characteristics of cardiac muscle.  Cells are .pdfCheck all that are characteristics of cardiac muscle.  Cells are .pdf
Check all that are characteristics of cardiac muscle. Cells are .pdfexxonzone
 
How electrical devices produce complex waveforms. Describe.Solut.pdf
How electrical devices produce complex waveforms. Describe.Solut.pdfHow electrical devices produce complex waveforms. Describe.Solut.pdf
How electrical devices produce complex waveforms. Describe.Solut.pdfexxonzone
 
#ifndef RATIONAL_H   if this compiler macro is not defined #def.pdf
#ifndef RATIONAL_H    if this compiler macro is not defined #def.pdf#ifndef RATIONAL_H    if this compiler macro is not defined #def.pdf
#ifndef RATIONAL_H   if this compiler macro is not defined #def.pdfexxonzone
 
Goldstein and brown were lucky. If they had used the JD allele to co.pdf
Goldstein and brown were lucky. If they had used the JD allele to co.pdfGoldstein and brown were lucky. If they had used the JD allele to co.pdf
Goldstein and brown were lucky. If they had used the JD allele to co.pdfexxonzone
 

More from exxonzone (19)

An employee is assigned to one department and a department may have m.pdf
An employee is assigned to one department and a department may have m.pdfAn employee is assigned to one department and a department may have m.pdf
An employee is assigned to one department and a department may have m.pdf
 
10 Points ntilfy cach of the the contour signatures shown on the map .pdf
10 Points ntilfy cach of the the contour signatures shown on the map .pdf10 Points ntilfy cach of the the contour signatures shown on the map .pdf
10 Points ntilfy cach of the the contour signatures shown on the map .pdf
 
Describe the principal cash transfer tools-Wire Transfer-EDT-E.pdf
Describe the principal cash transfer tools-Wire Transfer-EDT-E.pdfDescribe the principal cash transfer tools-Wire Transfer-EDT-E.pdf
Describe the principal cash transfer tools-Wire Transfer-EDT-E.pdf
 
Which sentence contains an infinitive AWill you take the package to.pdf
Which sentence contains an infinitive AWill you take the package to.pdfWhich sentence contains an infinitive AWill you take the package to.pdf
Which sentence contains an infinitive AWill you take the package to.pdf
 
Whats the Schema Table Column Row Attribute Entity Pri.pdf
Whats the Schema  Table  Column  Row  Attribute  Entity  Pri.pdfWhats the Schema  Table  Column  Row  Attribute  Entity  Pri.pdf
Whats the Schema Table Column Row Attribute Entity Pri.pdf
 
Which of the following groups produce sporangia on leaves (Mark all.pdf
Which of the following groups produce sporangia on leaves (Mark all.pdfWhich of the following groups produce sporangia on leaves (Mark all.pdf
Which of the following groups produce sporangia on leaves (Mark all.pdf
 
What is tax research What is the purpose of conducting tax research.pdf
What is tax research What is the purpose of conducting tax research.pdfWhat is tax research What is the purpose of conducting tax research.pdf
What is tax research What is the purpose of conducting tax research.pdf
 
What is a social networking analysisa) represents the interconnec.pdf
What is a social networking analysisa) represents the interconnec.pdfWhat is a social networking analysisa) represents the interconnec.pdf
What is a social networking analysisa) represents the interconnec.pdf
 
BiopsychologyWhy sleep (psychology) is interestingSolutionS.pdf
BiopsychologyWhy sleep (psychology) is interestingSolutionS.pdfBiopsychologyWhy sleep (psychology) is interestingSolutionS.pdf
BiopsychologyWhy sleep (psychology) is interestingSolutionS.pdf
 
The following question does not require any knowledge of statistics t.pdf
The following question does not require any knowledge of statistics t.pdfThe following question does not require any knowledge of statistics t.pdf
The following question does not require any knowledge of statistics t.pdf
 
Do antidepressants help A researcher studied the effect of an an.pdf
Do antidepressants help A researcher studied the effect of an an.pdfDo antidepressants help A researcher studied the effect of an an.pdf
Do antidepressants help A researcher studied the effect of an an.pdf
 
Shensen and colleagues were interested in studying older adults.pdf
Shensen and colleagues were interested in studying older adults.pdfShensen and colleagues were interested in studying older adults.pdf
Shensen and colleagues were interested in studying older adults.pdf
 
Much of the heat that drives convection in the mantlea. Is generat.pdf
Much of the heat that drives convection in the mantlea. Is generat.pdfMuch of the heat that drives convection in the mantlea. Is generat.pdf
Much of the heat that drives convection in the mantlea. Is generat.pdf
 
In explaining what we now call evolution, Darwin often used the phra.pdf
In explaining what we now call evolution, Darwin often used the phra.pdfIn explaining what we now call evolution, Darwin often used the phra.pdf
In explaining what we now call evolution, Darwin often used the phra.pdf
 
Las Homework 4 Spotlight Figure 27.18 Diagnosis of Acid-Base Disorde.pdf
Las Homework 4 Spotlight Figure 27.18 Diagnosis of Acid-Base Disorde.pdfLas Homework 4 Spotlight Figure 27.18 Diagnosis of Acid-Base Disorde.pdf
Las Homework 4 Spotlight Figure 27.18 Diagnosis of Acid-Base Disorde.pdf
 
Check all that are characteristics of cardiac muscle. Cells are .pdf
Check all that are characteristics of cardiac muscle.  Cells are .pdfCheck all that are characteristics of cardiac muscle.  Cells are .pdf
Check all that are characteristics of cardiac muscle. Cells are .pdf
 
How electrical devices produce complex waveforms. Describe.Solut.pdf
How electrical devices produce complex waveforms. Describe.Solut.pdfHow electrical devices produce complex waveforms. Describe.Solut.pdf
How electrical devices produce complex waveforms. Describe.Solut.pdf
 
#ifndef RATIONAL_H   if this compiler macro is not defined #def.pdf
#ifndef RATIONAL_H    if this compiler macro is not defined #def.pdf#ifndef RATIONAL_H    if this compiler macro is not defined #def.pdf
#ifndef RATIONAL_H   if this compiler macro is not defined #def.pdf
 
Goldstein and brown were lucky. If they had used the JD allele to co.pdf
Goldstein and brown were lucky. If they had used the JD allele to co.pdfGoldstein and brown were lucky. If they had used the JD allele to co.pdf
Goldstein and brown were lucky. If they had used the JD allele to co.pdf
 

Recently uploaded

OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsSandeep D Chaudhary
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsNbelano25
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...Gary Wood
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaEADTU
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxAdelaideRefugio
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Celine George
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
Michaelis Menten Equation and Estimation Of Vmax and Tmax.pptx
Michaelis Menten Equation and Estimation Of Vmax and Tmax.pptxMichaelis Menten Equation and Estimation Of Vmax and Tmax.pptx
Michaelis Menten Equation and Estimation Of Vmax and Tmax.pptxRugvedSathawane
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code ExamplesPeter Brusilovsky
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfUGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfNirmal Dwivedi
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonhttgc7rh9c
 
Play hard learn harder: The Serious Business of Play
Play hard learn harder:  The Serious Business of PlayPlay hard learn harder:  The Serious Business of Play
Play hard learn harder: The Serious Business of PlayPooky Knightsmith
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 

Recently uploaded (20)

OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
Michaelis Menten Equation and Estimation Of Vmax and Tmax.pptx
Michaelis Menten Equation and Estimation Of Vmax and Tmax.pptxMichaelis Menten Equation and Estimation Of Vmax and Tmax.pptx
Michaelis Menten Equation and Estimation Of Vmax and Tmax.pptx
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfUGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
 
OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
 
Play hard learn harder: The Serious Business of Play
Play hard learn harder:  The Serious Business of PlayPlay hard learn harder:  The Serious Business of Play
Play hard learn harder: The Serious Business of Play
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 

Question I need help with c++ Simple Classes Assigment. i get this .pdf

  • 1. 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
  • 2. 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 #include 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;
  • 3. } 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 #include "Date1.h" #include 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"
  • 4. }; 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);
  • 5. 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; }
  • 6. string Date1::getMonthString1() const { return monthName1[month1]; } //Patient1.h #ifndef Patient_h #define Patient_h #include "Date1.h" #include 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 *);
  • 7. 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 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
  • 8. 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()
  • 9. { 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);
  • 10. 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 #include #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);
  • 11. 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);
  • 12. 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)
  • 13. { 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++;
  • 14. } 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;
  • 15. 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() <<
  • 16. 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
  • 17. #include 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
  • 18. #include #include "Date1.h" #include 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)
  • 19. { 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;
  • 20. ++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 struct procedure1 { Date1 dateOfProcedure1; int procedureID1; int procedureProviderID1; };
  • 21. 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 using namespace std; Patient1::Patient1(int id1, const char * first1, const char *last1, Date1 birth1, int doctor1) {
  • 22. 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; }
  • 23. 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;
  • 24. } } 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 #include #include "Patient1.h" #include "Date1.h" using namespace std; void Menu1(); void Remove1(Patient1 checkIn1[], int& count1, int index1);
  • 25. 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
  • 26. { 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;
  • 27. 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)
  • 28. { 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 {
  • 29. 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) {
  • 30. 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;
  • 31. 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--; }