Sunteți pe pagina 1din 13

Patient Charges -- Design Document

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.

Private Member Variables


Variable Description
firstName A string that holds the patient’s first name.

middleName A string that holds the patient’s middle name.

lastName A string that holds the patient’s last name.

address A string that holds the patient’s street address.

city A string that holds the patient’s city.

state A string that holds the patient’s state.

zipCode An integer that holds the patient’s zip code.

phoneNumber A string that holds the patient’s phone number.

emergencyName A string that holds the patient’s emergency contact’s name.

emergencyNumber A string that holds the patient’s emergency contact’s phone.

Public Member Functions


Function Description
Constructor – No Args Takes no arguments, sets all variable to null
Takes arguments to set firstName, middleName, lastName, address, city, state,
Constructor
zipCode, phoneNumber, emergencyName, emergencyNumber.
setPatientName Takes three arguments to set firstName, middleName, and lastName.

getPatientName Returns a string of the patient’s full name.

setPatientAddress Takes four arguments to set the address of the patient.

getPatientAddress Returns a string of the patients address.

setPatientPhone Takes one argument to set the patient’s phone number

getPatientPhone Returns a string of the patient’s phone number.

setEmergencyContact Takes two arguments to set the name of the patient’s emergency contact.

getEmergencyContact Returns a string of the patient’s emergency contact.

displayAllPatientInfo Displays all the patient information.


The Class Declaration
The class specification file (Patient.h) contains the declaration statements for the variables and functions
that are members are of the class.

#ifndef PATIENT_H
#define PATIENT_H

#include <iostream>
#include <string>
#include <iomanip>

using namespace std;

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

The Class Implementation


The class implementation file (Patient.cpp) contains the definitions for the public functions of the
Patient class.

#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;
}

//set Patient Name


void Patient::setPatientName(string f, string m, string l) {
firstName = f;
middleName = m;
lastName = l;
}

//get patient full name


string Patient::getPatientName() const
{
string fullName;
fullName = lastName + ", " + firstName + " " + middleName;
return fullName;
}

//set Patient Address


void Patient::setPatientAddress(string a, string c, string s, int zip)
{
address = a;
city = c;
state = s;
zipCode = zip;
}

//get patient address


string Patient::getPatientAddress() const
{
string fullAddress;
fullAddress = address + "\n" + city + ", " + state + " " + to_string(zipCode);
return fullAddress;
}
//set Patient Phone
void Patient::setPatientPhone(string p) {
phoneNumber = p;
}

//get patient phone


string Patient::getPatientPhone() const
{
return phoneNumber;
}

//set Emergency Contact


void Patient::setEmergencyContact(string n, string p) {
emergencyName = n;
emergencyNumber = p;
}

//get Emergency Contact


string Patient::getEmergencyContact() const
{
string emergencyContact;
emergencyContact = emergencyName + " -- " + emergencyNumber;
return emergencyContact;
}

//display all Patient info


void Patient::displayAllPatientInfo() {
cout << "Patient Information:" << endl;
cout << getPatientName() << endl;
cout << getPatientAddress() << endl;
cout << getPatientPhone() << endl;
cout << "\nEmergency Contact:" << endl;
cout << getEmergencyContact() << endl;
}

The Constructor-No Args Function


The Constructor function creates an object with no arguments received from main.

The Constructor Function


The Constructor function accepts parameters representing the firstName, middleName, lastName, address,
city, state, zipCode, phoneNumber, emergencyName, emergencyNumber from the main function to create a new
patient object.

The setPatientName Member Function


The setPatientName function accepts parameters representing the firstName, middleName, and lastName.
It can be used to set the private member variables if the object is created with the no-args constructor.

The getPatientName Member Function


The getPatientName function returns the firstName, middleName, and lastName of the patient
formatted Last, First Middle.

The setPatientAddress Member Function


The setPatientName function accepts parameters representing the address, city, state and zipCode. It can
be used to set the private member variables if the object is created with the no-args constructor.
The getPatientAddress Member Function
The getPatientAddress function returns the address, city, state, and zipCode of the patient formatted as
follows:
Address
City, State ZipCode

The setPatientPhone Member Function


The setPatientPhone function accepts parameters representing the patient’s Phone Number. It can be used
to set the private member variables if the object is created with the no-args constructor.

The getPatientPhone Member Function


The getPatientPhone function returns the patient’s phone number.

The setEmergencyContact Member Function


The setEmergencyContact function accepts parameters representing the emergency contact’s name and
phone number. It can be used to set the private member variables if the object is created with the no-args
constructor.

The getEmergencyContact Member Function


The getPatientName function returns the emergencyName and emergencyNumber formatted
emergencyName – emergencyNumber.

The displayAllPatientInfo Member Functions


The displayAllPatientInfo function returns all the class members formatted as follows:

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.

Private Member Variables


Variable Description
procedureName A string that holds the procedure name.

procedureDate A string that holds the procedure date.

practitioner A string that holds the practitioner that completed the procedure.

charge A float that holds the charge for the procedure.


Public Member Functions
Function Description
Constructor – No Args Takes no arguments, sets all variable to null

Constructor Takes arguments to set procedure name, date, the practitioner name and charge.

setProcedureName Takes one argument to set the procedure name.

getProcedureName Returns a string of the procedure name.

setProcedureDate Takes one argument to set the procedure date.

getProcedureDate Returns a string of the procedure date.

setPractitioner Takes one argument to set the procedure practitioner.

getPractitioner Returns a string of the patient’s procedure practitioner.

setProcedureCharge Takes one argument to set the procedure charge.

getProcedureCharge Returns a string of the procedure charge.

displayAllProcedureInfo Displays all procedure information.

The Class Declaration


The class specification file (Procedure.h) contains the declaration statements for the variables and
functions that are members are of the class.
#ifndef PROCEDURE_H
#define PROCEDURE_H

#include <iostream>
#include <string>
#include <iomanip>

using namespace std;

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;

//no args procedure constructor


Procedure::Procedure() {
procedureName = " ";
procedureDate = " ";
practitioner = " ";
charge = 0.00;
}

//Procedure Contructor with parameters


Procedure::Procedure(string name, string date, string prac, float cost) {
procedureName = name;
procedureDate = date;
practitioner = prac;
charge = cost;
}

//set Procedure Name


void Procedure::setProcedureName(string name) {
procedureName = name;
}

//get Procedure Name


string Procedure::getProcedureName() const {
return procedureName;
}

// set Procedure Date


void Procedure::setProcedureDate(string date) {
procedureDate = date;
}

//get Procedure Date


string Procedure::getProcedureDate() const {
return procedureDate;
}

//set Procedure Practitioner


void Procedure::setPractitioner(string prac) {
practitioner = prac;
}

//get Procedure Practitioner


string Procedure::getPractitioner() const {
return practitioner;
}

//set Procedure Charge


void Procedure::setProcedureCharge(float cost) {
charge = cost;
}
//get Procedure Charge
float Procedure::getProcedureCharge() const {
return charge;
}

//display all procedure Information


void Procedure::displayAllProcedureInfo() {
cout << setw(20) << left << "Type:" << getProcedureName() << endl;
cout << setw(20) << left << "Date:" << getProcedureDate() << endl;
cout << setw(20) << left << "Practitioner:" << getPractitioner() << endl;
cout << setw(35) << left << "Charge:";
cout << "$" << setw(10) << right << setprecision(2) << fixed;
cout << getProcedureCharge() << endl;
}

The Constructor-No Args Function


The Constructor function creates an object with no arguments received from main.

The Constructor Function


The Constructor function accepts parameters representing the firstName, middleName, lastName, address,
city, state, zipCode, phoneNumber, emergencyName, emergencyNumber from the main function to create a new
patient object.

The setProcedureName Member Function


The setProcedureName function accepts a parameter representing the procedure name. It can be used to
set the private variables if the object is created with the no-args constructor.

The getProcedureName Member Function


The getProcedureName function returns the procedure name.

The setProcedureDate Member Function


The setProcedureDate function accepts a parameter representing the date of the procedure. It can be used
to set the private member variables if the object is created with the no-args constructor.

The getProcedureDate Member Function


The getProcedureDate function returns the procedure name.

The setPractitioner Member Function


The setPractitioner function accepts a parameter representing the procedure’s practitioner. It can be
used to set the private member variables if the object is created with the no-args constructor.

The getPractitioner Member Function


The getPractitioner function returns the procedure’s practitioner.

The setProcedureCharge Member Function


The setProcedureCharge function accepts a parameter representing the procedure cost. It can be used to
set the private member variables if the object is created with the no-args constructor.

The getProcedureCharge Member Function


The getPatientName function returns the procedure cost
The displayAllProcedureInfo Member Functions
The displayAllProcedureInfo function returns all the class members formatted as follows:
Type: Physical Exam

Date: 09/08/2019

Practitioner: Dr. Irvine

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.

The Main Function:


Main Variables
Variable Description
again A string that the user response to repeat the program.
A constant integer that holds the number of procedures in the patient charges
SIZE
array.
patientCharges An array that hold procedure objects.

totalCharge A float that holds the total for all procedures.

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

Procedure 1 is assigned to element 1


Procedure 2 is assigned to element 2
Procedure 3 is assigned to element 3
call function to calculate total charge

display results

input do again
}
while user want to continue

The showIntro Function


The showIntro Function displays a brief description of the program.

The calcTotalCharges Function


The calcTotalCharges uses a loop to keep a running total of all the objects in the array using a count-
controlled loop.
Main code to call function.

totalCharge = calcTotalCharges(patientCharges, SIZE);

Pseudocode
for count is set to the values 0 through the number of procedures
{
total = total + charge of current element
}

The displayResults Function


The displayResults Function receives a pointer to the patient object, a pointer to the patient charges
array, the size of the array and the total of the charges.
Main code to call function.

displayResults(patient, patientCharges, SIZE, totalCharge);

Pseudocode
Display header
Display Patient Info

for count is set to the values 0 through the number of procedures


{
Display Procedure Information
}

Display Total Charges


The Entire Program
//Mickie Blair
//Program Lab 4
//Patient Charges

#include <iostream>
#include <string>
#include <iomanip>
#include "Patient.h"
#include "Procedure.h"

using namespace std;

//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");

//create and intialize three procedures


Procedure* procedure1 = new Procedure("Physical Exam", "09/08/2019", "Dr.
Irvine", 250.00);

Procedure* procedure2 = new Procedure("X-Ray", "09/08/2019", "Dr. Jamison",


500.00);

Procedure* procedure3 = new Procedure("Blood Test", "09/08/2019", "Dr.


Smith", 200.00);

//assign the procedures to the array


patientCharges[0] = *procedure1;

patientCharges[1] = *procedure2;

patientCharges[2] = *procedure3;

//get total charges


totalCharge = calcTotalCharges(patientCharges, SIZE);

//display results
displayResults(patient, patientCharges, SIZE, totalCharge);

//ask user if they would like to go again


cout << "\nWould you like to run the program again? (Enter Y or N) ";
cin >> again;

while (toupper(again) != 'Y' && toupper(again) != 'N')


{
cout << "\nInvalid entry:" << endl;
cout << "Would you like to run the program again? (Enter Y or N) ";
cin >> again;
}

cout << endl;

while (toupper(again) == 'Y');

return 0;
}

//function to show introduction


void showIntro() {
cout << "Patient Charges Program\n" << endl;
cout << "The program display charges for a patient using " << endl;
cout << "an array of Procedure Objects created with a class." << endl;
cout << "The patient information and total charges for the" << endl;
cout << "visit will be display at the end of the program.\n" << endl;
}

//function to calculate total charges


float calcTotalCharges(Procedure* charges, int size) {
float total = 0; //accumulator

for (int index = 0; index < size; index++)


{
total += charges[index].getProcedureCharge();
}

return total;
}

//display results
void displayResults(Patient* p, Procedure* charges, int size, float total) {
//display header
cout << "Patient Charges Summary" << endl;
cout << "**************************************************" << endl;

//display patient information


p->displayAllPatientInfo();
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();
}

cout << "\n**************************************************" << endl;


cout << setw(36) << left << "\nTotal Charges:";
cout << "$" << setw(10) << right << setprecision(2) << fixed;
cout << total << endl;

S-ar putea să vă placă și