Question

In: Computer Science

"Health Data has the power to inform, excite, and influence behavior that leads to improved health...

"Health Data has the power to inform, excite, and influence behavior that leads to improved health at the individual and population level." - The Beauty of Health Data Design an application that provides health information to the user. The application should include: 1) loops 2) files 3) methods (pass by value/pass by reference, overloading methods) 4) global / local variables / static variables coding language c++ an example of health data would be checking someone blood oxygen, temp, etc.the output needs to tell if the person is healthy or not

Solutions

Expert Solution

code in c++ which includes

  • loops
  • files
  • methods pass by value/reference
  • overloading methods
  • global/local variables

code to copy

#include<bits/stdc++.h>
using namespace std;
int healthyMinBloodOxygenLevel=97;//example of global variables
int healthyMaxBloodSugarLevel=100;//example of global variables
int healthyMinBodyTemperature=36;//example of global variables
int healthyMaxBodyTemperature=38;//example of global variables
class PatientData{
        private:
                string patientName;
                int bloodOxygenLevel;
                int bodyTemperatureInDegreeCelcius;
                int bloodSugarLevel;
        public:
                //example of overloaded methods (in this case these are overloaded constructors)
                PatientData(string name){
                        patientName=name;
                }
                PatientData(string name,int bloodoxygen, int temp, int bloodSugar){
                        patientName=name;
                        bloodOxygenLevel=bloodoxygen;
                        bodyTemperatureInDegreeCelcius=temp;
                        bloodSugarLevel=bloodSugar;
                }
                void healthy(bool &isHealthy){//example of pass by reference
                        if(bloodOxygenLevel>=healthyMinBloodOxygenLevel && bloodSugarLevel<=healthyMaxBloodSugarLevel && bodyTemperatureInDegreeCelcius>=healthyMinBodyTemperature && 
                        bodyTemperatureInDegreeCelcius<=healthyMaxBodyTemperature){
                                isHealthy = true;
                        }else{
                                isHealthy = false;
                        }
                }
                //this includes file writing operations
                bool saveData(string filename){//returns if savinf was complete
                        ofstream outfile(filename);
                        if(!outfile){
                                return false;
                        }
                        outfile<<patientName<<" "<<bloodOxygenLevel<<" "<<bodyTemperatureInDegreeCelcius<<" "<<bloodSugarLevel<<endl;
                        outfile.close();
                        return true;
                }
                //this includes file reading operations
                bool loadData(string filename){
                        ifstream infile(filename);
                        if(!infile){
                                return false;
                        }
                        string buffer;
                        while(infile>>buffer){
                                if(buffer==patientName){
                                        infile>>bloodOxygenLevel;
                                        infile>>bodyTemperatureInDegreeCelcius;
                                        infile>>bloodSugarLevel;
                                        infile.close();
                                        return true;
                                }
                        }
                        return false;
                }
};
int main()
{
        string filename = "patientData.txt";
        while(true){
                int choice;
                cout<<"Enter 1 to add patient data\nEnter 2 to get patient data\nEnter 3 to exit"<<endl;
                cin>>choice;
                switch(choice){
                        case 1: {
                                //declare variables to take input;
                                string patientName;
                                int bloodOxygenLevel;
                                int bodyTemperatureInDegreeCelcius;
                                int bloodSugarLevel;
                                cout<<"Enter Patient Name: ";
                                cin>>patientName;
                                cout<<"Enter Patient blood oxygen level: ";
                                cin>>bloodOxygenLevel;
                                cout<<"Enter Patient body temperatire ";
                                cin>>bodyTemperatureInDegreeCelcius;
                                cout<<"Enter Patient blood sugar level: ";
                                cin>>bloodSugarLevel;
                                PatientData p(patientName, bloodOxygenLevel, bodyTemperatureInDegreeCelcius, bloodSugarLevel);
                                p.saveData(filename);
                                bool isHealthy;
                                p.healthy(isHealthy);
                                if(isHealthy){
                                        cout<<patientName<<" is Healthy"<<endl;
                                }else{
                                        cout<<patientName<<" is Healthy"<<endl;
                                }
                                break;
                        }
                        case 2:{
                                string patientName;
                                cout<<"Enter Patient Name: ";
                                cin>>patientName;
                                PatientData p(patientName);
                                if(p.loadData(filename)){
                                        bool isHealthy;
                                        p.healthy(isHealthy);
                                        if(isHealthy){
                                                cout<<patientName<<" is Healthy"<<endl;
                                        }else{
                                                cout<<patientName<<" is Healthy"<<endl;
                                        }
                                }else{
                                        cout<<"Patient "<<patientName<<" not found in database."<<endl;
                                }
                                break;
                        }
                        case 3: exit(0);
                }
        }
}

code screenshot

output screenshot


Related Solutions

Compare ways in which the focus on ‘population’ health has improved the health status of certain...
Compare ways in which the focus on ‘population’ health has improved the health status of certain groups. Provide 2 (two) examples, explaining how these interventions have resulted in improved health outcomes.
Do you think that The Health Insurance Portability and Accountability Act has improved the quality of...
Do you think that The Health Insurance Portability and Accountability Act has improved the quality of patient care provided? What additional impacts could the selected policy have on healthcare?
. Influence Tactics identify how individuals manipulate the power bases. Research has identified nine power tactics...
. Influence Tactics identify how individuals manipulate the power bases. Research has identified nine power tactics managers and employees use to increase their power. List and briefly explain them
How do marketers use data from consumer activities on social media to influence purchase behavior?
How do marketers use data from consumer activities on social media to influence purchase behavior?
In monopolistic competition A. each firm has limited power to influence the price of its product....
In monopolistic competition A. each firm has limited power to influence the price of its product. B. each firm has a large market share. C. a single firm can dictate market conditions. D. collusion is possible.
How does technology impact public health practices? What are the different ways that technology has improved...
How does technology impact public health practices? What are the different ways that technology has improved public health? List and discuss 3 ways.
In the context of communication theory and health behavior change, how has media been used to...
In the context of communication theory and health behavior change, how has media been used to positively affect health care and discuss how media can (or has) negatively affected health care?
Inappropriate Client Behavior The management of Peak Performance Health and Wellness Club has received several emails...
Inappropriate Client Behavior The management of Peak Performance Health and Wellness Club has received several emails and verbal complaints about an unidentified male club member allegedly masturbating while using the equipment in the club. The only description they have of the accused is that he is an older, white male with glasses. Jim Roberts is a personal trainer and is just about to start a morning session with a client. A young woman he knows and trusts comes up to...
CASE 11: Inappropriate Client Behavior The management of Peak Performance Health and Wellness Club has received...
CASE 11: Inappropriate Client Behavior The management of Peak Performance Health and Wellness Club has received several emails and verbal complaints about an unidentified male club member allegedly masturbating while using the equipment in the club. The only description they have of the accused is that he is an older, white male with glasses. Jim Roberts is a personal trainer and is just about to start a morning session with a client. A young woman he knows and trusts comes...
Think of someone you know who has successfully changed their health behavior (ex. becoming a vegetarian,...
Think of someone you know who has successfully changed their health behavior (ex. becoming a vegetarian, eating less fat, stopped smoking, etc.). What health psychology concepts, based on the module readings or from your own research, contributed towards their success in changing their health behavior?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT