In: Computer Science
urgent!!! code in c++
- cannot use vector
- please use inheritance
-please identify the .h and .cpp files and add tester program and screenshot of output!
-please complete all parts I will upvote thank you!!!
Define the following classes to manage the booking of patients in a medical clinic.
a) Define a class Date that has the following integer data
members: month, day and year.
b) Define a class AppointmentTime that has the following data
members: day (string), hour (int) and minute (int).
c) Define a class Patient with the following data members:
The name of the patient as a standard library string.
The date of birth of the patient (from part a).
Medical insurance number of the patient as a standard library string.
Name of the doctor for the appointment.
Day and time of the appointment (from part b).
A patient may have a single doctor’s appointment each week.
The name of the doctor as a standard library string.
The date of birth of the doctor (from part a).
A two-dimensional string pointer array of 12-by-5 that shows the appointments of that doctor. The appointment durations are 30 mins and they always begin on the hour or half hour. Doctors see patients Monday to Friday during 9.00-12.00 and 14.00-17.00. This array is initialized to empty strings to indicate that at the beginning all the appointments are available. When an appointment is given a pointer to the medical insurance of the patient is stored at that location.
A Patient object from part (b).
Doctor’s name.
The day that appointment is requested as a standard library string (Monday to Friday).
f) Define a class ClinicManager with the following data members:
An array of pointers to the Patient objects of size 200.
An array of pointers to the Doctor objects of size 20.
An integer variable that counts total number of patient
appointments given by the clinic in a week.
At least the following member functions should be provided,
A member function that receives a patient object and inserts it
to the Patient pointer array. It will check if the patient is
already in the array to prevent multiple copies of the patient
object in the array.
A member function that receives a doctor object and inserts to the
Doctor pointer array.
A member function that processes appointment requests. The function
will receive an AppointmentRequest object, then will check the
requested doctor’s schedule to determine if the appointment can be
made. If the appointment can be scheduled it will store the medical
insurance of the patient in the appointment array of that doctor.
It will create an AppointmentTime object from part b). Then, it
will find the patient in the Patient pointer array and store the
doctor’s name and AppointmentTime object in the patient object in
the Patient pointer array. Finally, the member function will return
the AppointmentTime object. If the doctor is already fully booked
on that day this object should should return zeros for the
appointment time.
A member function that cancels an appointment, receives doctor’s
name and medical insurance of the patient. Then it removes the
appointment both from the doctor’s schedule and from the
patient.
A member function that receives a doctor’s name as a parameter and
prints name and medical insurance number of all the patients that
have booked an appointment with that doctor.
g) Write a driver program that demonstrate the functionality of your program including:
- Creates a ClinicManager object
- Creates doctor objects and calls to the doctor insert member function.
- Creates Patient and AppointmentRequest objects and calls to the member functions that
processes the appointments, then outputs the time of the appointment.
§ You must enforce encapsulation by keeping all data members private.
§ You need to make sure that your classes are well defined using the various concepts
seen in the class.
§ Provide needed set/get functions for the data members.
§ Objects should be created dynamically and must be deleted when no longer needed. There should be an output statement confirming the deletion of an object from the destructor function.
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
//define class date
#define class
int month[]; int date[]; int day[];
//define appointment time
#define appointment
string(day);hour(int);minute(int);
struct patient
{
char FirstName[50];
char LastName[50];
char ID[20];
};
class date
{
public:
queue(void);
int(month,day,year)
// define class for queue
class queue
{
public:
queue (void);
int AddPatientAtEnd (patient p);
int AddPatientAtBeginning (patient p);
int AddMeducalInsurenceOfTheNumber(int i);
patient GetNextPatient (void);
i
void OutputList (void);
char DepartmentName[50];
private:
int NumberOfPatients;
patient List[MAXPATIENTS];
};
// declare member functions for queue
queue::queue ()
{
// constructor
NumberOfPatients = 0;
}
int queue::AddPatientAtEnd (patient p)
{
if (NumberOfPatients >= MAXPATIENTS)
{
// queue is full
return 0;
}
// put in new patient
else
List[NumberOfPatients] = p; NumberOfPatients++;
return 1;
}
int queue::AddPatientAtBeginning (patient p)
{
// adds a critically ill patient to the beginning of the
queue.
// returns 1 if successful, 0 if queue is full.
int i;
if (NumberOfPatients >= MAXPATIENTS)
{
// queue is full
return 0;
}int queue::AddMedicalInsurenceOfTheNumber(int i){
//adds a medical insurence of the numberto the patient
//retuens 1 if successful,0 if queue is full.
int i;if(number of patients>=medical insurence number){
return 0;}
// move all patients one position back in queue
for (i = NumberOfPatients-1; i >= 0; i--)
{
List[i+1] = List[i];
}
// put in new patient
List[0] = p; NumberOfPatients++;
return 1;
}
patient queue::GetNextPatient (void)
{
// gets the patient that is first in the queue.
// returns patient with no ID if queue is empty
int i; patient p;
if (NumberOfPatients == 0) {
// queue is empty
strcpy(p.ID,"");
return p;}
// get first patient
p = List[0];
// move all remaining patients one position forward in queue
NumberOfPatients--;
for (i=0; i<NumberOfPatients; i++)
{
List[i] = List[i+1];
}
// return patient
return p;
}
// search for patient
for (i=0; i<NumberOfPatients; i++)
{
if (stricmp(List[i].ID, p->ID) == 0)
// patient found in queue
*p = List[i]; found = 1;
// move all following patients one position forward in queue
NumberOfPatients--;
for (j=i; j<NumberOfPatients; j++)
{
List[j] = List[j+1];
}
}
}
return found;
}
void queue::OutputList (void)
{
// lists entire queue on screen
int i;
if (NumberOfPatients == 0)
{
cout << "Queue is empty";
}
else
{
for (i=0; i<NumberOfPatients; i++)
{
cout << "" << List[i].FirstName;
cout << " " << List[i].LastName;
cout << " " << List[i].ID;
}
}
}
// declare functions used by main:
patient InputPatient (void)
{
// this function asks user for patient data.
patient p;
cout << "Please enter data for new patient First name:
";
cin.getline(p.FirstName, sizeof(p.FirstName));
cout << "Last name: ";
cin.getline(p.LastName, sizeof(p.LastName));
cout << "Social security number: ";
cin.getline(p.ID, sizeof(p.ID));
// check if data valid
if (p.FirstName[0]==0 || p.LastName[0]==0 || p.ID[0]==0)
{
// rejected
strcpy(p.ID,"");
cout << "Error: Data not valid. Operation cancelled.";
getch();
}
return p;
}
void OutputPatient (patient * p)
{
// this function outputs patient data to the screen
if (p == NULL || p->ID[0]==0)
{
cout << "No patient";
return;
}
else
cout << "Patient data:";
cout << "First name: " << p->FirstName;
cout << "Last name: " << p->LastName;
cout << "Social security number: " << p->ID;
}
int ReadNumber()
{
// this function reads an integer number from the keyboard.
// it is used because input with cin >> doesn't work
properly!
char buffer[20];
cin.getline(buffer, sizeof(buffer));
return atoi(buffer);
}
void DepartmentMenu (queue * q)
{
// this function defines the user interface with menu for one
department
int choice = 0, success;
patient p;
while (choice != 6)
{
// clear screen
clrscr();
// print menu
cout << "Welcome to department: " <<
q->DepartmentName;
cout << "Please enter your choice:";
cout << "1: Add normal patient\n";
cout << "2: Add critically ill patient\n";
cout << "3: Take out patient for operation\n";
cout << "4: Remove dead patient from queue\n";
cout << "5: List queue\n";
cout << "6: Change department or exit\n";
// get user choice
choice = ReadNumber();
// do indicated action
switch (choice)
{
case 1: // Add normal patient
p = InputPatient();
if (p.ID[0])
{
success = q->AddPatientAtEnd(p);
clrscr();
if (success)
{
cout << "Patient added:";
}
else
{
// error
cout << "Error: The queue is full. Cannot add
patient:";
}
OutputPatient(&p);
cout << "Press any key";
getch();
}
break;
case 2: // Add critically ill patient
p = InputPatient();
if (p.ID[0])
{
success = q->AddPatientAtBeginning(p);
clrscr();
if (success)
{
cout << "Patient added:";
}
else
{
// error
cout << "Error: The queue is full. Cannot add
patient:";
}
OutputPatient(&p);
cout << "Press any key";
getch();
}
break;
case 3: // Take out patient for operation
p = q->GetNextPatient();
clrscr();
if (p.ID[0])
{
cout << "Patient to operate:";
OutputPatient(&p);}
else
{
cout << "There is no patient to operate.";
}
cout << "Press any key";
getch();
break;
OutputPatient(&p);
cout << "Press any key";
getch();
}
break;
case 5: // List queue
clrscr();
q->OutputList();
cout << "Press any key";
getch(); break;
}
}
}
// main function defining queues and main menu
void main ()
{
int i, MenuChoice = 0;
// define three queues
while (MenuChoice != 4)
{
// clear screen
clrscr();
// print menu
cout << "Welcome to Software City Hospital";
cout << "Please enter your choice:";
for (i = 0; i < 3; i++)
{
cout << "4: Exit";
// get user choice
MenuChoice = ReadNumber();
// is it a department name?
if (MenuChoice >= 1 && MenuChoice <= 3)
{
// call submenu for department
// (using pointer arithmetics here:)
DepartmentMenu (departments + (MenuChoice-1));
}
}
}