Documente Academic
Documente Profesional
Documente Cultură
Description:
The program simulates the creation of a patient bill for procedures incurred during visit. The patient
class holds the data for a patient which includes name, address, phone number and emergency. The
procedure class hold the data regarding a procedure which includes procedure name, date of service,
practitioner, and the charge for the procedure.
Patient Class:
The Patient Class creates a patient object.
setEmergencyContact Takes two arguments to set the name of the patient’s emergency contact.
#ifndef PATIENT_H
#define PATIENT_H
#include <iostream>
#include <string>
#include <iomanip>
class Patient
{
private:
string firstName;
string middleName;
string lastName;
string address;
string city;
string state;
int zipCode;
string phoneNumber;
string emergencyName;
string emergencyNumber;
public:
Patient();
Patient(string, string, string, string, string, string, int, string, string,
string);
void setPatientName(string, string, string);
string getPatientName() const;
void setPatientAddress(string, string, string, int);
string getPatientAddress() const;
void setPatientPhone(string);
string getPatientPhone() const;
void setEmergencyContact(string, string);
string getEmergencyContact() const;
void displayAllPatientInfo();
};
#endif
#include <iostream>
#include <iomanip>
#include <string>
#include "Patient.h"
using namespace std;
//Patient Constructor - no args
Patient::Patient() {
firstName = " ";
middleName = " ";
lastName = " ";
address = " ";
city = " ";
state = " ";
zipCode = 0;
phoneNumber = " ";
emergencyName = " ";
emergencyNumber = " ";
}
//Patient Constructor
Patient::Patient(string fName, string mName, string lName, string pAddress, string
pCity,
string pState, int pZip, string pPhone, string emerName, string emerPhone) {
firstName = fName;
middleName = mName;
lastName = lName;
address = pAddress;
city = pCity;
state = pState;
zipCode = pZip;
phoneNumber = pPhone;
emergencyName = emerName;
emergencyNumber = emerPhone;
}
Patient Information:
Doe, Mary Jane
123 River Rd
Atlanta, GA 30054
404-555-3333
Emergency Contact:
John Doe -- 404-333-5555
Procedure Class:
The procedure class creates a procedure object.
practitioner A string that holds the practitioner that completed the procedure.
Constructor Takes arguments to set procedure name, date, the practitioner name and charge.
#include <iostream>
#include <string>
#include <iomanip>
class Procedure {
private:
string procedureName;
string procedureDate;
string practitioner;
float charge;
public:
Procedure();
Procedure(string, string, string, float);
void setProcedureName(string);
string getProcedureName() const;
void setProcedureDate(string);
string getProcedureDate() const;
void setPractitioner(string);
string getPractitioner() const;
void setProcedureCharge(float);
float getProcedureCharge() const;
void displayAllProcedureInfo();
};
#endif
The Class Implementation
The class implementation file (Procedure.cpp) contains the definitions for the public functions of the
Procedure class.
#include <iostream>
#include <iomanip>
#include <string>
#include "Procedure.h"
using namespace std;
Date: 09/08/2019
Charge: $ 250.00
Programming Strategy:
In this program, a patient object is defined and initialized with data hold information for each private
member variable. Next an array of procedure object is created to hold the three procedures for the
patient. The procedure objects are defined and initialized with data for each private member. The
procedure objects are assigned to an in the patientCharges array. The array is sent a function to
calculate the total charges. The total charge is returned to the main function. The program then calls a
function to display all the results.
Main Functions
Function Description
showIntro Takes no arguments, displays an introduction.
calcTotalCharges Takes a pointer to the patient charges array and the integer constant SIZE.
Takes a pointer to the patient object, a pointer to the procedure object, the integer
displayResults
constant SIZE and the total of charges.
Function main
The main function contains the variable definitions. The main function initializes the patient object and
the procedure objects. The main function also calls the showIntro function, the calcTotalCharges
function, and the display results.
Pseudocode for main
do
{
create and initialize patient object
create and initialize 3 procedure objects
display results
input do again
}
while user want to continue
Pseudocode
for count is set to the values 0 through the number of procedures
{
total = total + charge of current element
}
Pseudocode
Display header
Display Patient Info
#include <iostream>
#include <string>
#include <iomanip>
#include "Patient.h"
#include "Procedure.h"
//function prototypes
void showIntro();
float calcTotalCharges(Procedure*, int);
void displayResults(Patient*, Procedure*, int, float);
int main() {
char again; //variable for again loop
const int SIZE = 3; //size of patient charge array
Procedure patientCharges[SIZE]; //patient charges array
float totalCharge; //total patient charge
//display introduction
showIntro();
do
{
//create patient and initialize with data
Patient* patient = new Patient("Mary", "Jane", "Doe", "123 River Rd",
"Atlanta", "GA", 30054, "404-555-3333", "John Doe", "404-333-5555");
patientCharges[1] = *procedure2;
patientCharges[2] = *procedure3;
//display results
displayResults(patient, patientCharges, SIZE, totalCharge);
return 0;
}
return total;
}
//display results
void displayResults(Patient* p, Procedure* charges, int size, float total) {
//display header
cout << "Patient Charges Summary" << endl;
cout << "**************************************************" << endl;
//display header
cout << "\nProcedure Details:" << endl;
//display procedures
for (int index = 0; index < size; index++)
{
cout << "--------------------------------------------------";
cout << "\nProcedure " << index + 1 << endl;
cout << "--------------------------------------------------" << endl;
charges[index].displayAllProcedureInfo();
}