(Computerization of Health Records) A health care issue that has been in the news lately is the computerization of health records. This possibility is being approached cautiously because of sensitive privacy and security concerns, among others. [We address such concerns in later exercises.] Computerizing health records could make it easier for patients to share their health profiles and his-
tories among their various health care professionals. This could improve the quality of health care, help avoid drug conflicts and erroneous drug prescriptions, reduce costs and in emergencies, could save lives. In this exercise, you’ll design a “starter” HealthProfile class for a person. The class attri- butes should include the person’s first name, last name, gender, date of birth (consisting of separate attributes for the month, day and year of birth), height (in inches) and weight (in pounds). Your class should have a constructor that receives this data. For each attribute, provide set and get functions. The class also should include functions that calculate and return the user’s age in years, maximum heart rate and target-heart-rate range (see Exercise 9.25), and body mass index (BMI; see Exercise 2.30). Write an application that prompts for the person’s information, instantiates an object of class HealthProfile for that person and prints the information from that object—including the person’s first name, last name, gender, date of birth, height and weight—then calculates and prints the per- son’s age in years, BMI, maximum heart rate and target-heart-rate range. It should also display the “BMI values” chart from Exercise 2.30. Use the same technique as Exercise 9.25 to calculate the per- son’s age.
What will be an ideal response?
```
// HealthProfile class for storing medical data.
#include
using namespace std;
class HealthProfile
{
public:
// Constructor
HealthProfile( string first, string last, char g,
int m, int d, int y, int h, int w )
{
setFirstName( first ); // set first name
setLastName( last ); // set last name
setGender( g ); // set gender
setBirthMonth( m ); // set month
setBirthDay( d ); // set day
setBirthYear( y ); // set year
setHeight( h ); // set height
setWeight( w ); // set weight
} // end constructor
// set first name
void setFirstName( string first )
{
firstName = first;
} // end function setFirstName
// get first name
string getFirstName()
{
return firstName;
} // end function getFirstName
// set last name
void setLastName( string last )
{
lastName = last;
} // end function setLastName
// get last name
string getLastName()
{
return lastName;
} // end function getLastName
// set gender
void setGender( char g )
{
gender = g;
} // end function setGender
// get gender
char getGender()
{
return gender;
} // end function getGender
// set birth month
void setBirthMonth( int m )
{
birthMonth = m;
} // end function setBirthMonth
// get birth month
int getBirthMonth()
{
return birthMonth;
} // end function getBirthMonth
// set birth day
void setBirthDay( int d )
{
birthDay = d;
} // end function setBirthDay
// get birth day
int getBirthDay()
{
return birthDay;
} // end function getBirthDay
// set birth year
void setBirthYear( int y )
{
birthYear = y;
} // end function setBirthYear
// get birth year
int getBirthYear()
{
return birthYear;
} // end function getBirthYear
// set height
void setHeight( int h )
{
height = h;
} // end function setHeight
// get height
int getHeight()
{
return height;
} // end function getHeight
// set weight
void setWeight( int w )
{
weight = w;
} // end function setWeight
// get weight
int getWeight()
{
return weight;
} // end function getWeight
// calculate age
int getAge()
{
// if current date has not yet been set, get it from user
if ( currentYear == 0 )
{
cout << "Please enter today's month, day, and year:" << endl;
cin >> currentMonth >> currentDay >> currentYear;
} // end if
if ( currentMonth >= birthMonth )
if ( currentDay >= birthDay )
return currentYear - birthYear;
return currentYear - birthYear - 1;
} // end function getAge
// get maximum heart rate
int getMaximumHeartRate()
{
return 220 - getAge();
} // end function getMaximumHeartRate
// calculate minimum target heart rate
int getMinimumTargetHeartRate()
{
return 50 * getMaximumHeartRate() / 100;
} // end function getMinimumTargetHeartRate
// calculate maximum target heart rate
int getMaximumTargetHeartRate()
{
return 85 * getMaximumHeartRate() / 100;
} // end function getMaximumTargetHeartRate
// calculate body mass index
int getBodyMassIndex()
{
return getWeight() * 703 / ( getHeight() * getHeight() );
} // end function getBMI
private:
string firstName; // person's first name
string lastName; // person's last name
char gender; // person's gender
int birthMonth; // person's birth month
int birthDay; // person's birth day
int birthYear; // person's birth year
int height; // person's height in inches
int weight; // person's weight in pounds
int currentMonth; // current month
int currentDay; // current day
int currentYear; // current year
}; // end class HealthProfile
```
```
// Driver program for HealthProfile class
#include
#include
#include "HealthProfile.h"
using namespace std;
int main()
{
string first, last; // first name, last name
int month, day, year; // birth month, day, year
int height, weight; // height (inches) and weight (pounds)
char gender; // gender (M or F)
// get user input
cout << "Please enter first and last name:\n";
cin >> first >> last;
cout << "Please enter gender (M or F):\n";
cin >> gender;
cout << "Please enter month, day, and year of birth:\n";
cin >> month >> day >> year;
cout << "Please enter height (in inches) and weight (in pounds):\n";
cin >> height >> weight;
// create a HealthProfile object
HealthProfile profile( first, last, gender,
month, day, year, height, weight );
// display user information
cout << "First Name: " << profile.getFirstName() << "\n";
cout << "Last Name: " << profile.getLastName() << "\n";
cout << "Gender: " << profile.getGender() << "\n";
cout << "Date of Birth: " << profile.getBirthMonth() << "/"
<< profile.getBirthDay() << "/"
<< profile.getBirthYear() << "\n";
cout << "Height (inches): " << profile.getHeight() << "\n";
cout << "Weight (pounds): " << profile.getWeight() << "\n";
cout << "Age: " << profile.getAge() << "\n";
cout << "Maximum Heart Rate: "
<< profile.getMaximumHeartRate() << "\n";
cout << "Target Heart Rate: "
<< profile.getMinimumTargetHeartRate() << "-"
<< profile.getMaximumTargetHeartRate() << "\n";
cout << "Body Mass Index: " << profile.getBodyMassIndex() << "\n\n";
// display BMI information table
cout << "BMI VALUES \n";
cout << "Underweight: less than 18.5 \n";
cout << "Normal: between 18.5 and 24.9\n";
cout << "Overweight: between 25 and 29.9 \n";
cout << "Obese: 30 or greater \n";
} // end main
```
You might also like to view...
Excel's ____________________ view helps you refine the appearance of a worksheet before you print it.
Fill in the blank(s) with the appropriate word(s).
Explain what a descendant selector is and give an example of its use.
What will be an ideal response?
The box that identifies the patterns or colors assigned to the data series in a chart is called a:
A) Dialog box B) Message box C) Legend
What is the interframe gap?
What will be an ideal response?