Skip to content
This repository was archived by the owner on Jan 25, 2024. It is now read-only.

Commit 8e75629

Browse files
committed
Updates for new 6.2 engine release, see README for modeling details
1 parent 3570769 commit 8e75629

File tree

69 files changed

+4085
-1376
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+4085
-1376
lines changed

src/cdm/cpp/engine/PhysiologyEngineDynamicStabilization.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ bool PhysiologyEngineDynamicStabilization::Merge()
365365
return true;
366366
}
367367

368-
// This basically tests the current property with the target proptry and if they are in a window of acceptance
368+
// This basically tests the current property with the target property and if they are in a window of acceptance
369369
bool PropertyConvergence::Test(double time_s)
370370
{
371371
double v = !m_DataRequestScalar.HasUnit() ?

src/cdm/cpp/patient/SEPatient.cpp

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,12 @@ void SEPatient::SetEvent(CDM::enumPatientEvent::value type, bool active, const S
420420
case CDM::enumPatientEvent::Hypoglycemia:
421421
m_ss << " Patient has Hypoglycemia";
422422
break;
423+
case CDM::enumPatientEvent::HypoglycemicShock:
424+
m_ss << " Patient is in Hypoglycemic Shock";
425+
break;
426+
case CDM::enumPatientEvent::HypoglycemicComa:
427+
m_ss << " Patient has fallen into Hypoglycemic Coma";
428+
break;
423429
case CDM::enumPatientEvent::Hypothermia:
424430
m_ss << " Patient is Hypothermic";
425431
break;
@@ -442,8 +448,11 @@ void SEPatient::SetEvent(CDM::enumPatientEvent::value type, bool active, const S
442448
m_ss << " Patient has Ketoacidosis";
443449
break;
444450
case CDM::enumPatientEvent::LacticAcidosis:
445-
m_ss << " Patient has LacticAcidosis";
451+
m_ss << " Patient has Lactic Acidosis";
446452
break;
453+
case CDM::enumPatientEvent::LiverGlycogenDepleted:
454+
m_ss << " Patient's liver glycogen is depleted";
455+
break;
447456
case CDM::enumPatientEvent::MaximumPulmonaryVentilationRate:
448457
m_ss << " Patient's Respiratory Driver has exceeded the maximum target pulmonary ventilation rate, setting value to the maximum allowable rate";
449458
break;
@@ -459,6 +468,9 @@ void SEPatient::SetEvent(CDM::enumPatientEvent::value type, bool active, const S
459468
case CDM::enumPatientEvent::ModerateAcuteRespiratoryDistress:
460469
m_ss << " The patient has Moderate Acute Respiratory Distress";
461470
break;
471+
case CDM::enumPatientEvent::MuscleGlycogenDepleted:
472+
m_ss << " Patient's muscle glycogen is depleted";
473+
break;
462474
case CDM::enumPatientEvent::MyocardiumOxygenDeficit:
463475
m_ss << " The patient's heart is not receiving enough oxygen";
464476
break;
@@ -547,6 +559,12 @@ void SEPatient::SetEvent(CDM::enumPatientEvent::value type, bool active, const S
547559
case CDM::enumPatientEvent::Hypoglycemia:
548560
m_ss << " Patient no longer has Hypoglycemia";
549561
break;
562+
case CDM::enumPatientEvent::HypoglycemicShock:
563+
m_ss << " Patient is no longer in Hypoglycemic Shock";
564+
break;
565+
case CDM::enumPatientEvent::HypoglycemicComa:
566+
m_ss << " Patient is no longer in a Hypoglycemic Coma";
567+
break;
550568
case CDM::enumPatientEvent::Hypothermia:
551569
m_ss << " Patient is no longer has Hypothermic";
552570
break;
@@ -569,8 +587,11 @@ void SEPatient::SetEvent(CDM::enumPatientEvent::value type, bool active, const S
569587
m_ss << " Patient no longer has Ketoacidosis";
570588
break;
571589
case CDM::enumPatientEvent::LacticAcidosis:
572-
m_ss << " Patient no longer has LacticAcidosis";
590+
m_ss << " Patient no longer has Lactic Acidosis";
573591
break;
592+
case CDM::enumPatientEvent::LiverGlycogenDepleted:
593+
m_ss << " Patient's liver glycogen is no longer depleted";
594+
break;
574595
case CDM::enumPatientEvent::MaximumPulmonaryVentilationRate:
575596
m_ss << " Patient's Respiratory Driver is no longer exceeding the maximum target pulmonary ventilation rate";
576597
break;
@@ -586,6 +607,9 @@ void SEPatient::SetEvent(CDM::enumPatientEvent::value type, bool active, const S
586607
case CDM::enumPatientEvent::ModerateAcuteRespiratoryDistress:
587608
m_ss << " Patient no longer has a Moderate Acute Respiratory Distress";
588609
break;
610+
case CDM::enumPatientEvent::MuscleGlycogenDepleted:
611+
m_ss << " Patient's muscle glycogen is no longer depleted";
612+
break;
589613
case CDM::enumPatientEvent::MyocardiumOxygenDeficit:
590614
m_ss << " Patient no longer has a Myocardium Oxygen Deficit";
591615
break;

src/cdm/cpp/patient/actions/SEHemorrhage.cpp

Lines changed: 124 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,27 @@ specific language governing permissions and limitations under the License.
1515
#include "bind/HemorrhageData.hxx"
1616
#include "properties/SEScalarVolumePerTime.h"
1717
#include "bind/ScalarVolumePerTimeData.hxx"
18+
#include "bind/IntegerArray.hxx"
19+
#include "bind/IntegerList.hxx"
1820

1921
SEHemorrhage::SEHemorrhage() : SEPatientAction()
2022
{
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");
2339
}
2440

2541
SEHemorrhage::~SEHemorrhage()
@@ -30,25 +46,43 @@ SEHemorrhage::~SEHemorrhage()
3046
void SEHemorrhage::Clear()
3147
{
3248
SEPatientAction::Clear();
33-
m_Compartment = "";
34-
SAFE_DELETE(m_Rate);
49+
m_Compartment = "";
50+
m_MCIS.clear();
51+
m_BleedName = "";
3552
}
3653

3754
bool SEHemorrhage::IsValid() const
3855
{
39-
return SEPatientAction::IsValid() && HasCompartment() && HasRate();
56+
return SEPatientAction::IsValid() && HasCompartment() && HasMCIS() && HasBleedName();
4057
}
4158

4259
bool SEHemorrhage::IsActive() const
4360
{
44-
return IsValid() ? !m_Rate->IsZero() : false;
61+
return IsValid() ? !m_MCIS[0]==0 : false;
4562
}
4663

4764
bool SEHemorrhage::Load(const CDM::HemorrhageData& in)
4865
{
4966
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+
5286
return true;
5387
}
5488

@@ -62,10 +96,72 @@ CDM::HemorrhageData* SEHemorrhage::Unload() const
6296
void SEHemorrhage::Unload(CDM::HemorrhageData& data) const
6397
{
6498
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();
69165
}
70166

71167
std::string SEHemorrhage::GetCompartment() const
@@ -88,24 +184,29 @@ void SEHemorrhage::InvalidateCompartment()
88184
m_Compartment = "";
89185
}
90186

91-
bool SEHemorrhage::HasRate() const
187+
bool SEHemorrhage::HasMCIS() const
92188
{
93-
return m_Rate==nullptr?false:m_Rate->IsValid();
189+
return !m_MCIS.empty();
94190
}
95191

96-
SEScalarVolumePerTime& SEHemorrhage::GetRate()
192+
void SEHemorrhage::SetMCIS(const std::vector<unsigned int>& mcisIn)
97193
{
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;
101198
}
102199

103200
void SEHemorrhage::ToString(std::ostream &str) const
104201
{
105-
str << "Patient Action : Hemorrhage";
106-
if(HasComment())
107-
str<<"\n\tComment: "<<m_Comment;
108-
str << "\n\tRate: "; HasRate() ? str << *m_Rate : str << "NaN";
109-
str << "\n\tFor Compartment: "; HasCompartment()? str << GetCompartment() : str << "No Compartment Set";
202+
str << "Patient Action : Hemorrhage";
203+
if (HasComment())
204+
str << "\n\tComment: " << m_Comment;
205+
str << "\n\tInjury Code: ";
206+
for (int i : m_MCIS)
207+
str << i;
208+
str << "\n\tCompartment: "; HasCompartment() ? str << GetCompartment() : str << "No Compartment Set";
209+
str << "\n\tSeverity: "; str << m_MCIS[0];
110210
str << std::flush;
211+
111212
}

src/cdm/cpp/patient/actions/SEHemorrhage.h

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ specific language governing permissions and limitations under the License.
1414
#include "patient/actions/SEPatientAction.h"
1515
#include "bind/HemorrhageData.hxx"
1616

17+
18+
19+
20+
21+
22+
1723
class DLL_DECL SEHemorrhage : public SEPatientAction
1824
{
1925
public:
@@ -37,14 +43,24 @@ class DLL_DECL SEHemorrhage : public SEPatientAction
3743
virtual void SetCompartment(const std::string& name);
3844
virtual bool HasCompartment() const;
3945
virtual void InvalidateCompartment();
46+
virtual void ProcessMCIS();
47+
48+
virtual bool HasMCIS() const;
49+
virtual std::vector<unsigned int>& GetMCIS() { return m_MCIS; }
50+
virtual void SetMCIS(const std::vector<unsigned int>& mcisIn);
4051

41-
virtual bool HasRate() const;
42-
virtual SEScalarVolumePerTime& GetRate();
52+
virtual bool HasBleedName() const;
53+
virtual std::string GetBleedName() const;
54+
virtual void SetBleedName(const std::string& name);
4355

56+
4457
virtual void ToString(std::ostream &str) const;
4558

4659
protected:
47-
std::string m_Compartment;
48-
SEScalarVolumePerTime* m_Rate;
49-
60+
std::string m_Compartment;
61+
std::vector<unsigned int> m_MCIS;
62+
std::string m_BleedName;
63+
std::map<std::vector<int>, std::pair<std::string, std::string>> organMap;
64+
65+
enum region { Head = 1, Torso = 2, Arms = 3, Legs = 4 }; //mcis digit 2
5066
};

src/cdm/cpp/scenario/SEPatientActionCollection.cpp

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -387,18 +387,29 @@ bool SEPatientActionCollection::ProcessAction(const CDM::PatientActionData& acti
387387
const CDM::HemorrhageData* hem = dynamic_cast<const CDM::HemorrhageData*>(&action);
388388
if(hem!=nullptr)
389389
{
390-
SEHemorrhage* myHem = m_Hemorrhages[hem->Compartment()];
391-
if (myHem == nullptr)
390+
//We only store the MCIS on the CDM (so that our input is just one code and nothing else). But we need the compartment information to
391+
//check if hemorrhage already exists in m_Hemorrhages map. Thus we use a temporary variable to check.
392+
SEHemorrhage* myHem;
393+
SEHemorrhage* temp = new SEHemorrhage;
394+
temp->Load(*hem);
395+
if (m_Hemorrhages.find(temp->GetCompartment()) == m_Hemorrhages.end())
392396
{
393-
myHem = new SEHemorrhage();
394-
m_Hemorrhages[hem->Compartment()] = myHem;
397+
myHem = new SEHemorrhage;
398+
m_Hemorrhages[temp->GetCompartment()] = myHem;
399+
myHem->Load(*hem);
395400
}
396-
myHem->Load(*hem);
401+
else
402+
{
403+
myHem = m_Hemorrhages[temp->GetCompartment()];
404+
myHem->Load(*hem);
405+
}
397406
if (!myHem->IsActive())
398407
{
399-
RemoveHemorrhage(hem->Compartment());
408+
RemoveHemorrhage(myHem->GetCompartment());
409+
SAFE_DELETE(temp);
400410
return true;
401411
}
412+
SAFE_DELETE(temp);
402413
return IsValid(*myHem);
403414
}
404415

0 commit comments

Comments
 (0)