forked from venu-shastri/cleancodeforcpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparamchecker.cpp
92 lines (75 loc) · 1.64 KB
/
paramchecker.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include "paramchecker.h"
using namespace std;
class Vital
{
float minRange;
float maxRange;
public:
Vital() {minRange=0; maxRange=0;}
virtual ~Vital(){}
bool isVitalOk(float vital)
{
return !((vital < getMinRange()) || (vital > getMaxRange()));
}
float getMinRange() { return minRange; }
float getMaxRange() { return maxRange; }
void setMinRange(float min) { minRange = min; }
void setMaxRange(float max) { maxRange = max; }
};
class BPM:public Vital{
public:
BPM(){
setMinRange(70);
setMaxRange(150);
}
virtual ~BPM(){}
};
class SPO2:public Vital{
public:
SPO2(){
setMinRange(80);
setMaxRange(100);
}
virtual ~SPO2(){}
};
class RESP:public Vital{
public:
RESP(){
setMinRange(30);
setMaxRange(60);
}
virtual ~RESP(){}
};
class ParamChecker
{
std::vector<Vital*> vitalList;
public:
ParamChecker()
{
Vital *bpmVital = new BPM();
Vital *SPO2Vital = new SPO2();
Vital *RESPVital = new RESP();
vitalList.push_back(bpmVital);
vitalList.push_back(SPO2Vital);
vitalList.push_back(RESPVital);
}
bool checkIfVitalOutOfRange(std::vector<float> patientVitals)
{
std::vector<Vital*>::iterator vitalItr = vitalList.begin();
std::vector<float>::iterator patientVitalItr = patientVitals.begin();
bool isVitalOutOfRange = false;
for (; vitalItr!=vitalList.end() ; ++vitalItr, ++patientVitalItr)
{
if(!(*vitalItr)->isVitalOk(*patientVitalItr))
{
isVitalOutOfRange = true;
break;
}
}
return isVitalOutOfRange;
}
};
bool vitalsAreOk(std::vector<float> inputVitals) {
ParamChecker paramchecker;
return !paramchecker.checkIfVitalOutOfRange(inputVitals);
}