Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ Programming assignment The local medical clinic has decided to automate its

ID: 639232 • Letter: C

Question

C++ Programming assignment

The local medical clinic has decided to automate its scheduling services. You have been assigned to design the initial version of the schedules. The basic functions that the clinic has in mind are doctor check-in and check-out and patient check-in and check-out.

A doctor checks in by telling the scheduler his or her name, an examination room number, and a medical specialty code. Each doctor has a favorite room. The scheduler checks to see whether the room is free. If so, it assigns this doctor to the room; if not, it rejects the request with a message, and the doctor can try again to check in. When a doctor checks out, the examination room is freed.

A patient checking in gives a name, age, specialist code, and emergency indication. The scheduler tries to match up the patient with a doctor according to a set of rules that are described here. If there is a match, the patient is seen by the assigned doctor. If this doctor is currently seeing a patient, the new patient is queued to see the doctor.

The rules for assigning doctors to patients are as follows:

1.       Any patient under age 16 is assigned to see a pediatrician.

2.       Patients age 16 and older are assigned a doctor according to the specialty requested. If there is no doctor in the clinic with the requested specialty, the patient is assigned to a general practitioner (GP). If there is no GP, the patient can be assigned to any doctor.

3.       If there is more than one doctor of the requested specialty, the patient is assigned to the doctor with the shortest waiting list.

When a patient checks out, the doctor he or she was assigned to is available to see the next patient, if there is anyone in the waiting list.

Input

Because this is an interactive system, your program should prompt the users to input the correct information. The initial prompt is

                ' Type D for Doctor or P for Patient: '

The next prompt is

                Type I for check-in or O for checkout:

According to the request, your program should prompt the user for any other needed information, as indicated in the following table:

Action

Additional Information

Doctor check-in

Doctor check-out

Patient check-in

Patient check-out

Doctor's name

Room number

Specialty code

Doctor's name

Patient's name

Age

Specialty (code requested)

Patient's name

Room number

       

You may define the format for the input processed by your program.

Output

The output for each request is in the form of messages to the user, according to the request, as indicated in the following table.

Action

Message

Doctor check-in

Doctor check-out

Patient check-in

Patient check-out

Confirmation that room is available or Error message if room is in use.

Good-bye message

Message telling patient which room to go to and which doctor has been assigned. If no doctor is available, apologetic message.

Good-bye message. At a later time we may add billing information at this point.

In addition to printing the messages on the screen, you should also write the requests and messages to a transaction file (trans.out), to be turned in with your program listing.

Details and Assumptions

There are l 00 examination rooms at the clinic, each with a waiting room attached.

Specialty codes are as follows:

                Pediatrics                                      PED

                General practice                          GEN

                Internal medicine                        INT

                Cardiology                                    CAR

                Surgeon                                         SUR

                Obstetrics                                     OBS

                Psychiatry                                    PSY

                Neurology                                     NEU

                Orthopedics                                 ORT

                Dermatology                                DET

                Ophthalmology                           OPT

                Ear, Nose, and Throat                ENT

You may assume that no patient leaves without checking out. (That is, every doctor becomes free eventually.)

No one leaves before he or she sees the assigned doctor. (That is, no one has to be taken out of the waiting queue.) The clinic is open 24 hours a day, 7 days a week.

If a doctor checks out while there is still a waiting list of patients assigned to him or her, the patients must be reassigned to other doctors.

Data Structures

The basic data structure is a list of examination rooms with waiting lists attached to each. Because the number of rooms is fixed, you may use an array of records to represent it. It is the waiting list attached to each examination room that is of interest to us. We have seen that patients are seen in the order in which they are added to the list (a simple queue).

Deliverables

Your design including CRC cards for each class

A listing of your source program including all included files

A listing of your test plan as input to the program

A listing of your output from the test plan

Action

Additional Information

Doctor check-in

Doctor check-out

Patient check-in

Patient check-out

Doctor's name

Room number

Specialty code

Doctor's name

Patient's name

Age

Specialty (code requested)

Patient's name

Room number

Explanation / Answer

#include "QueueHeader.h"
#include <fstream>
#include <string>
// function prototypes
string Doctors(string [], int);
int Patients();
int checkIn(string [], int);
void sCode();
void checkOut();
// structure for doctors
struct doctors
{
string dName;
int roomNumber;
string code;

};
// structure for patients.
struct patients
{
string pName;
int age;
string sCode;
int roomNum;
};
// main function
int main()
{

const int AGE = 16; // for the age of the patients
const int ROOMS = 100; // number of rooms
string rooms[100]; // array for the rooms
checkIn(rooms, 100);
cout << "To test if I get out of the functions correctly." << endl;
checkOut();
return 0;
}

int checkIn(string rms[], const int SIZE)
{
int sz;
sz = SIZE;
string RMS[100];
cout << "**************************************************************************** " <<
"* Welcome to Adam's Doctors Office * " <<
"**************************************************************************** " << endl;
char doctor = 'D';
char patient = 'P';
char choice;
int num;
cout << "Are you a Doctor(D) or patient (P)?" << endl;
cin >> choice;
if (choice != 'D' && choice != 'P')
{
cout << "Error: you must select D or P, please try again." << endl;
cin >> choice;
}
if (choice == 'D')
Doctors(RMS, 100);
else if (choice == 'P')
Patients();
return 0;
}
void sCode()
{
const int CODES = 12;
string code[CODES] = {"PED Pediatrics ", "GEN General Pratice ", "INT Internal Medicine ",
"CAR Cardiology ", "SUR Surgeon ", "OBS Obstetrics ", "PSY Psychiatry ", "NEU Neurology ",
"ORT Orthopedics ", "DET Dermatology ", "OPT Ophthalmology ", "ENT Ear, Nose, and Throat"};
for (int i = 0; i < CODES; i++)
cout << code << endl;
}
// Doctors function
string Doctors(string roms[], int siz)
{
int size;
string rooms[100];
doctors doc;
cout << "Welcome Doctor what is your name?" << endl;
cin.ignore();
getline(cin, doc.dName);
cout << doc.dName << " What room number would you like today?" << endl;
cin >> doc.roomNumber;
// assign the doctor to the room that they selected.
rooms[doc.roomNumber] == doc.dName;
cout << doc.dName << " What is your specialty code?" << endl;
sCode();
cin.ignore();
getline(cin, doc.code);
// return the doctor's room to the main function
return rooms[doc.roomNumber];
}
// Patients function
int Patients()
{
patients pat;
cout << "Welcome what is your name? " << endl;
cin.ignore();
getline(cin, pat.pName);
cout << pat.pName << " What is your age?" << endl;
cin >> pat.age;
cout << pat.pName << " Please select a code from the list below. " << endl;
sCode();
cin.ignore();
getline(cin, pat.sCode);
Queue<patients> pnts;
pnts.enqueue(pat);
return 0;
}
void checkOut()
{

cout << "**************************************************************************** " <<
"* Welcome to Adam's Doctors Office * " <<
"**************************************************************************** " << endl;
char doctor = 'D';
char patient = 'P';
char choice;
int num;
cout << "Are you a Doctor(D) or patient (P)?" << endl;
cin >> choice;
if (choice != 'D' && choice != 'P')
{
cout << "Error: you must select D or P, please try again." << endl;
cin >> choice;
}
if (choice == 'D')
Doctors(RMS, 100);
else if (choice == 'P'){
patients pat;
cout << "Welcome what is your name? " << endl;
cin.ignore();
getline(cin, pat.pName);
cout << pat.pName << " What is your age?" << endl;
cin >> pat.age;
cout << pat.pName << " Please select a code from the list below. " << endl;
sCode();
cin.ignore();
getline(cin, pat.sCode);
Queue<patients> pnts;
pnts.dequeue(pat);
}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote