Write a program that computes a patient\'s bill for a hospital stay. This includ
ID: 3592846 • Letter: W
Question
Write a program that computes a patient's bill for a hospital stay. This includes designing several classes: HospitalCharges, Surgery, Medication, PatientAccount, and Date class. Al class attributes must be private and accessed through public member functions The attributes of each class are summarized below: HospitalCharges class has the following private attributes vector surgeries; vector medications; vector patientsAccounts. Surgery class has the following private attributes: int surgeryCode; string surgeryDescription; double surgeryCharge; Medication class has the following private attributes int medicationCode; string medicationDescription; double medicationCharge; PatientAccount class has at least the following private attributes: const long patientAccountNum; //-nextPatientAccountNum string firstName; string lastName; long SSN; char gender; int age double dailyRate; Date admittDate; Date dischargeDate; vector patientSurgeries; vector patientMedications; static long nextPatientAccountNum; // initialize it to 1000 and increment it by 1 // as vou create a new obiect Date class has the following private attributes int month int day; int year,Explanation / Answer
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
// define maximum number of patients in a queue
#define MAXPATIENTS 100
// define structure for patient data
struct patient
{
char FirstName[50];
char LastName[50];
char ID[20];
};
// define class for queue
class queue
{
public:
queue (void);
int AddPatientAtEnd (patient p);
int AddPatientAtBeginning (patient p);
patient GetNextPatient (void);
int RemoveDeadPatient (patient * p);
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)
{
// adds a normal patient to the end of the queue.
// returns 1 if successful, 0 if queue is full.
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;
}
// 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;
}
int queue::RemoveDeadPatient (patient * p)
{
// removes a patient from queue.
// returns 1 if successful, 0 if patient not found
int i, j, found = 0;
// 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;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.