@@ -15,11 +15,27 @@ specific language governing permissions and limitations under the License.
15
15
#include " bind/HemorrhageData.hxx"
16
16
#include " properties/SEScalarVolumePerTime.h"
17
17
#include " bind/ScalarVolumePerTimeData.hxx"
18
+ #include " bind/IntegerArray.hxx"
19
+ #include " bind/IntegerList.hxx"
18
20
19
21
SEHemorrhage::SEHemorrhage () : SEPatientAction()
20
22
{
21
- m_Compartment = " " ;
22
- m_Rate=nullptr ;
23
+ m_Compartment = " " ; // This is the compartment we use to store information about hemorrhage
24
+ m_MCIS;
25
+ m_BleedName = " " ; // This is the name of the pathway in circuit that will have its resistance changed
26
+
27
+ // Place organs in a map so that we don't get too messy with nested conditionals. Each vector is digits 2-4 of the MCIS code
28
+ organMap[{6 , 4 }] = std::make_pair (" AortaBleed" , " Major Artery" );
29
+ organMap[{6 , 6 }] = std::make_pair (" VenaCavaBleed" , " Vena Cava" );
30
+ organMap[{6 , 5 }] = std::make_pair (" AortaBleed" , " Major Artery" );
31
+ organMap[{7 , 1 }] = std::make_pair (" LungBleed" , " Lungs" );
32
+ organMap[{7 , 2 }] = std::make_pair (" HeartBleed" , " Heart" );
33
+ organMap[{8 , 1 }] = std::make_pair (" LiverBleed" , " Liver" );
34
+ organMap[{8 , 2 }] = std::make_pair (" SpleenBleed" , " Spleen" );
35
+ organMap[{8 , 3 }] = std::make_pair (" SplanchnicBleed" , " Splanchnic" );
36
+ organMap[{8 , 4 }] = std::make_pair (" KidneyBleed" , " Kidney" );
37
+ organMap[{8 , 5 }] = std::make_pair (" SmallIntestineBleed" , " Small Intestine" );
38
+ organMap[{8 , 6 }] = std::make_pair (" LargeIntestineBleed" , " Large Intestine" );
23
39
}
24
40
25
41
SEHemorrhage::~SEHemorrhage ()
@@ -30,25 +46,43 @@ SEHemorrhage::~SEHemorrhage()
30
46
void SEHemorrhage::Clear ()
31
47
{
32
48
SEPatientAction::Clear ();
33
- m_Compartment = " " ;
34
- SAFE_DELETE (m_Rate);
49
+ m_Compartment = " " ;
50
+ m_MCIS.clear ();
51
+ m_BleedName = " " ;
35
52
}
36
53
37
54
bool SEHemorrhage::IsValid () const
38
55
{
39
- return SEPatientAction::IsValid () && HasCompartment () && HasRate ();
56
+ return SEPatientAction::IsValid () && HasCompartment () && HasMCIS () && HasBleedName ();
40
57
}
41
58
42
59
bool SEHemorrhage::IsActive () const
43
60
{
44
- return IsValid () ? !m_Rate-> IsZero () : false ;
61
+ return IsValid () ? !m_MCIS[ 0 ]== 0 : false ;
45
62
}
46
63
47
64
bool SEHemorrhage::Load (const CDM::HemorrhageData& in)
48
65
{
49
66
SEPatientAction::Load (in);
50
- GetRate ().Load (in.Rate ());
51
- m_Compartment=in.Compartment ();
67
+ if (in.MCIS ().present ())
68
+ {
69
+ for (size_t i = 0 ; i < in.MCIS ().get ().IntegerList ().size (); i++)
70
+ {
71
+ m_MCIS.push_back (in.MCIS ().get ().IntegerList ()[i]);
72
+ }
73
+ if ((m_MCIS[0 ] < 0 ) || (m_MCIS[0 ] > 5 )) // check to make sure no one puts in a severity of a million
74
+ {
75
+ SetComment (" Invalid MCIS Code: Severity out of bounds (0-5). Defaulting to 3" );
76
+ m_MCIS[0 ] = 3 ;
77
+ }
78
+ if (m_MCIS.size () != 5 ) // make sure mcis code is proper length
79
+ {
80
+ SetComment (" Invalid MCIS Code: Code must be 5 digits. Defaulting to aorta with bleeding severity = 3" );
81
+ m_MCIS = { 3 ,2 ,6 ,3 ,0 };
82
+ }
83
+ }
84
+ ProcessMCIS ();
85
+
52
86
return true ;
53
87
}
54
88
@@ -62,10 +96,72 @@ CDM::HemorrhageData* SEHemorrhage::Unload() const
62
96
void SEHemorrhage::Unload (CDM::HemorrhageData& data) const
63
97
{
64
98
SEPatientAction::Unload (data);
65
- if (m_Rate!=nullptr )
66
- data.Rate (std::unique_ptr<CDM::ScalarVolumePerTimeData>(m_Rate->Unload ()));
67
- if (HasCompartment ())
68
- data.Compartment (m_Compartment);
99
+ // Create Integer Array that stores Integer List and pass m_MCIS values to it (modeled after GetActiveIndices in electrocardiogram-
100
+ // interpolatorWaveform.cpp)
101
+ data.MCIS (std::unique_ptr<CDM::IntegerArray>(new CDM::IntegerArray ()));
102
+ data.MCIS ().get ().IntegerList (std::unique_ptr<CDM::IntegerList>(new CDM::IntegerList ()));
103
+ for (int i : m_MCIS)
104
+ data.MCIS ().get ().IntegerList ().push_back (i);
105
+ }
106
+
107
+ void SEHemorrhage::ProcessMCIS ()
108
+ {
109
+ switch (m_MCIS[1 ]) {
110
+ case Head:
111
+ // Note that this assumes that the third digit is 6 (for vessels).
112
+ if (m_MCIS[3 ] == 1 ) // If bleeding is intracranial
113
+ {
114
+ SetBleedName (" BrainBleed" );
115
+ SetCompartment (" Head" );
116
+ }
117
+ else
118
+ { // If the bleeding is from the carotid artery/jugular vein
119
+ SetBleedName (" AortaBleed" );
120
+ SetCompartment (" Major Artery" );
121
+ }
122
+ break ;
123
+ case Torso:
124
+ if (organMap.find ({ m_MCIS.begin () + 2 , m_MCIS.end ()-1 }) != organMap.end ()) // extract the two digits that map to an organ
125
+ {
126
+ SetBleedName (organMap[{m_MCIS.begin () + 2 , m_MCIS.end ()-1 }].first );
127
+ SetCompartment (organMap[{m_MCIS.begin () + 2 , m_MCIS.end ()-1 }].second );
128
+ }
129
+ else
130
+ {
131
+ SetComment (" Invalid MCIS Code: Does not map to BioGears compartment. Defaulting to Aorta" );
132
+ SetBleedName (" AortaBleed" );
133
+ SetCompartment (" Major Artery" );
134
+ }
135
+ break ;
136
+ case Arms:
137
+ SetBleedName (" ArmBleed" );
138
+ SetCompartment (" Arm" );
139
+ break ;
140
+ case Legs:
141
+ SetBleedName (" LegBleed" );
142
+ SetCompartment (" Leg" );
143
+ break ;
144
+ default :
145
+ SetComment (" Invalid MCIS Code: Does not map to BioGears compartment. Defaulting to Aorta" );
146
+ SetBleedName (" AortaBleed" );
147
+ SetCompartment (" Major Artery" );
148
+ break ;
149
+ }
150
+ }
151
+
152
+
153
+
154
+ std::string SEHemorrhage::GetBleedName () const
155
+ {
156
+ return m_BleedName;
157
+ }
158
+ void SEHemorrhage::SetBleedName (const std::string& name)
159
+ {
160
+ m_BleedName = name;
161
+ }
162
+ bool SEHemorrhage::HasBleedName () const
163
+ {
164
+ return !m_BleedName.empty ();
69
165
}
70
166
71
167
std::string SEHemorrhage::GetCompartment () const
@@ -88,24 +184,29 @@ void SEHemorrhage::InvalidateCompartment()
88
184
m_Compartment = " " ;
89
185
}
90
186
91
- bool SEHemorrhage::HasRate () const
187
+ bool SEHemorrhage::HasMCIS () const
92
188
{
93
- return m_Rate== nullptr ? false :m_Rate-> IsValid ();
189
+ return !m_MCIS. empty ();
94
190
}
95
191
96
- SEScalarVolumePerTime& SEHemorrhage::GetRate ( )
192
+ void SEHemorrhage::SetMCIS ( const std::vector< unsigned int >& mcisIn )
97
193
{
98
- if (m_Rate==nullptr )
99
- m_Rate=new SEScalarVolumePerTime ();
100
- return *m_Rate;
194
+ if (mcisIn.size () != 5 )
195
+ Error (" MCIS code must be five digits" );
196
+ else
197
+ m_MCIS = mcisIn;
101
198
}
102
199
103
200
void SEHemorrhage::ToString (std::ostream &str) const
104
201
{
105
- str << " Patient Action : Hemorrhage" ;
106
- if (HasComment ())
107
- str<<" \n\t Comment: " <<m_Comment;
108
- str << " \n\t Rate: " ; HasRate () ? str << *m_Rate : str << " NaN" ;
109
- str << " \n\t For Compartment: " ; HasCompartment ()? str << GetCompartment () : str << " No Compartment Set" ;
202
+ str << " Patient Action : Hemorrhage" ;
203
+ if (HasComment ())
204
+ str << " \n\t Comment: " << m_Comment;
205
+ str << " \n\t Injury Code: " ;
206
+ for (int i : m_MCIS)
207
+ str << i;
208
+ str << " \n\t Compartment: " ; HasCompartment () ? str << GetCompartment () : str << " No Compartment Set" ;
209
+ str << " \n\t Severity: " ; str << m_MCIS[0 ];
110
210
str << std::flush;
211
+
111
212
}
0 commit comments