Commit acca001e authored by Aaron Bray's avatar Aaron Bray
Browse files

Clean up hemorrhage logic

Fix issues with some equipment actions
parent ab985575
......@@ -31,4 +31,4 @@ Macro EngineUnitTest=EngineUnitTestDriver FastPlot Baseline=unit_tests/pulse/ Co
Macro EngineUnitTestFull=EngineUnitTestDriver FullPlot Baseline=unit_tests/pulse/ Computed=./test_results/unit_tests/pulse
Macro ScenarioTest=ScenarioTestDriver FastPlot Baseline=scenarios/ Computed=./test_results/scenarios
patient/BasicStandard.json =
patient/BasicStandard.json = ScenarioTest
......@@ -97,7 +97,7 @@
"Compartment": "LeftLegVasculature",
"Severity": {
"Scalar0To1": {
"Value": 0.05
"Value": 0.0
}
}
}
......
......@@ -22,6 +22,13 @@ public:
virtual void StateChange(); //analyze and cache for optimization
virtual bool HasMapping() const { return !m_AllNodes.empty(); }
virtual bool HasMapping(const NodeType& n) const
{
for (auto mine : m_AllNodes)
if (&n == mine)
return true;
return false;
}
virtual const std::vector<NodeType*>& GetNodes() const { return m_AllNodes; }
virtual const std::vector<NodeType*>& GetQuantityNodes() const { return m_QuantityNodes; }
virtual void RemoveNode(NodeType& node);
......
......@@ -269,7 +269,7 @@ void SEEquipmentActionCollection::RemoveAnesthesiaMachineConfiguration()
bool SEEquipmentActionCollection::HasAnesthesiaMachineOxygenTankPressureLoss() const
{
return m_AnesthesiaMachineOxygenTankPressureLoss == nullptr ? false : true;
return m_AnesthesiaMachineOxygenTankPressureLoss == nullptr ? false : m_AnesthesiaMachineOxygenTankPressureLoss->IsActive();
}
SEAnesthesiaMachineOxygenTankPressureLoss& SEEquipmentActionCollection::GetAnesthesiaMachineOxygenTankPressureLoss()
{
......@@ -289,7 +289,7 @@ void SEEquipmentActionCollection::RemoveAnesthesiaMachineOxygenTankPressureLoss(
bool SEEquipmentActionCollection::HasAnesthesiaMachineOxygenWallPortPressureLoss() const
{
return m_AnesthesiaMachineOxygenWallPortPressureLoss == nullptr ? false : true;
return m_AnesthesiaMachineOxygenWallPortPressureLoss == nullptr ? false : m_AnesthesiaMachineOxygenWallPortPressureLoss->IsActive();
}
SEAnesthesiaMachineOxygenWallPortPressureLoss& SEEquipmentActionCollection::GetAnesthesiaMachineOxygenWallPortPressureLoss()
{
......@@ -309,7 +309,7 @@ void SEEquipmentActionCollection::RemoveAnesthesiaMachineOxygenWallPortPressureL
bool SEEquipmentActionCollection::HasAnesthesiaMachineExpiratoryValveLeak() const
{
return m_AnesthesiaMachineExpiratoryValveLeak == nullptr ? false : true;
return m_AnesthesiaMachineExpiratoryValveLeak == nullptr ? false : m_AnesthesiaMachineExpiratoryValveLeak->IsActive();
}
SEAnesthesiaMachineExpiratoryValveLeak& SEEquipmentActionCollection::GetAnesthesiaMachineExpiratoryValveLeak()
{
......@@ -329,7 +329,7 @@ void SEEquipmentActionCollection::RemoveAnesthesiaMachineExpiratoryValveLeak()
bool SEEquipmentActionCollection::HasAnesthesiaMachineExpiratoryValveObstruction() const
{
return m_AnesthesiaMachineExpiratoryValveObstruction == nullptr ? false : true;
return m_AnesthesiaMachineExpiratoryValveObstruction == nullptr ? false : m_AnesthesiaMachineExpiratoryValveObstruction->IsActive();
}
SEAnesthesiaMachineExpiratoryValveObstruction& SEEquipmentActionCollection::GetAnesthesiaMachineExpiratoryValveObstruction()
{
......@@ -349,7 +349,7 @@ void SEEquipmentActionCollection::RemoveAnesthesiaMachineExpiratoryValveObstruct
bool SEEquipmentActionCollection::HasAnesthesiaMachineInspiratoryValveLeak() const
{
return m_AnesthesiaMachineInspiratoryValveLeak == nullptr ? false : true;
return m_AnesthesiaMachineInspiratoryValveLeak == nullptr ? false : m_AnesthesiaMachineInspiratoryValveLeak->IsActive();
}
SEAnesthesiaMachineInspiratoryValveLeak& SEEquipmentActionCollection::GetAnesthesiaMachineInspiratoryValveLeak()
{
......@@ -369,7 +369,7 @@ void SEEquipmentActionCollection::RemoveAnesthesiaMachineInspiratoryValveLeak()
bool SEEquipmentActionCollection::HasAnesthesiaMachineInspiratoryValveObstruction() const
{
return m_AnesthesiaMachineInspiratoryValveObstruction == nullptr ? false : true;
return m_AnesthesiaMachineInspiratoryValveObstruction == nullptr ? false : m_AnesthesiaMachineInspiratoryValveObstruction->IsActive();
}
SEAnesthesiaMachineInspiratoryValveObstruction& SEEquipmentActionCollection::GetAnesthesiaMachineInspiratoryValveObstruction()
{
......@@ -389,7 +389,7 @@ void SEEquipmentActionCollection::RemoveAnesthesiaMachineInspiratoryValveObstruc
bool SEEquipmentActionCollection::HasAnesthesiaMachineMaskLeak() const
{
return m_AnesthesiaMachineMaskLeak == nullptr ? false : true;
return m_AnesthesiaMachineMaskLeak == nullptr ? false : m_AnesthesiaMachineMaskLeak->IsActive();
}
SEAnesthesiaMachineMaskLeak& SEEquipmentActionCollection::GetAnesthesiaMachineMaskLeak()
{
......@@ -409,7 +409,7 @@ void SEEquipmentActionCollection::RemoveAnesthesiaMachineMaskLeak()
bool SEEquipmentActionCollection::HasAnesthesiaMachineSodaLimeFailure() const
{
return m_AnesthesiaMachineSodaLimeFailure == nullptr ? false : true;
return m_AnesthesiaMachineSodaLimeFailure == nullptr ? false : m_AnesthesiaMachineSodaLimeFailure->IsActive();
}
SEAnesthesiaMachineSodaLimeFailure& SEEquipmentActionCollection::GetAnesthesiaMachineSodaLimeFailure()
{
......@@ -429,7 +429,7 @@ void SEEquipmentActionCollection::RemoveAnesthesiaMachineSodaLimeFailure()
bool SEEquipmentActionCollection::HasAnesthesiaMachineTubeCuffLeak() const
{
return m_AnesthesiaMachineTubeCuffLeak == nullptr ? false : true;
return m_AnesthesiaMachineTubeCuffLeak == nullptr ? false : m_AnesthesiaMachineTubeCuffLeak->IsActive();
}
SEAnesthesiaMachineTubeCuffLeak& SEEquipmentActionCollection::GetAnesthesiaMachineTubeCuffLeak()
{
......@@ -449,7 +449,7 @@ void SEEquipmentActionCollection::RemoveAnesthesiaMachineTubeCuffLeak()
bool SEEquipmentActionCollection::HasAnesthesiaMachineVaporizerFailure() const
{
return m_AnesthesiaMachineVaporizerFailure == nullptr ? false : true;
return m_AnesthesiaMachineVaporizerFailure == nullptr ? false : m_AnesthesiaMachineVaporizerFailure->IsActive();
}
SEAnesthesiaMachineVaporizerFailure& SEEquipmentActionCollection::GetAnesthesiaMachineVaporizerFailure()
{
......@@ -469,7 +469,7 @@ void SEEquipmentActionCollection::RemoveAnesthesiaMachineVaporizerFailure()
bool SEEquipmentActionCollection::HasAnesthesiaMachineVentilatorPressureLoss() const
{
return m_AnesthesiaMachineVentilatorPressureLoss == nullptr ? false : true;
return m_AnesthesiaMachineVentilatorPressureLoss == nullptr ? false : m_AnesthesiaMachineVentilatorPressureLoss->IsActive();
}
SEAnesthesiaMachineVentilatorPressureLoss& SEEquipmentActionCollection::GetAnesthesiaMachineVentilatorPressureLoss()
{
......@@ -489,7 +489,7 @@ void SEEquipmentActionCollection::RemoveAnesthesiaMachineVentilatorPressureLoss(
bool SEEquipmentActionCollection::HasAnesthesiaMachineYPieceDisconnect() const
{
return m_AnesthesiaMachineYPieceDisconnect == nullptr ? false : true;
return m_AnesthesiaMachineYPieceDisconnect == nullptr ? false : m_AnesthesiaMachineYPieceDisconnect->IsActive();
}
SEAnesthesiaMachineYPieceDisconnect& SEEquipmentActionCollection::GetAnesthesiaMachineYPieceDisconnect()
{
......
......@@ -45,7 +45,8 @@ bool SESupplementalOxygen::IsActive() const
{
if (!SEPatientAction::IsActive())
return false;
return m_Device != eSupplementalOxygen_Device::None && (HasFlow() || HasVolume());
return m_Device != eSupplementalOxygen_Device::None;
// Defaults will be used if no flow/volume supplied
}
void SESupplementalOxygen::Deactivate()
{
......
......@@ -95,33 +95,6 @@ void PBPulsePhysiology::Serialize(const PULSE_BIND::CardiovascularData& src, Car
PBProperty::Load(src.cardiaccyclepulmonaryarterypressure_mmhg(), *dst.m_CardiacCyclePulmonaryArteryPressure_mmHg);
PBProperty::Load(src.cardiaccyclecentralvenouspressure_mmhg(), *dst.m_CardiacCycleCentralVenousPressure_mmHg);
PBProperty::Load(src.cardiaccycleskinflow_ml_per_s(), *dst.m_CardiacCycleSkinFlow_mL_Per_s);
// As these are dynamically added to the system during run time,
// We will need to make the association within the system here
// Currently, there is no PulseCompartmentManager Load/Unload to do that for us
// It looks for the static cmpt/circuit memebers and adds those to the associated system
// As these were dynamically created, these will not be handled in that code
// (It probably should)
// But, anything that is dynamically created needs to be associated by the System Load
// So we are doing that here.
// Also, Internal Hemorrhage is a subset of Hemorrhage, so internal is associated via
// This regular hemorrhage links/paths getting associated properly
for (auto name : src.hemorrhagelinks())
{
SELiquidCompartmentLink* hLink = dst.m_data.GetCompartments().GetLiquidLink(name);
dst.m_data.GetCompartments().GetCardiovascularGraph().AddLink(*hLink);
dst.m_HemorrhageLinks.push_back(hLink);
}
if(!dst.m_HemorrhageLinks.empty())
dst.m_data.GetCompartments().GetCardiovascularGraph().StateChange();
for (auto name : src.hemorrhagepaths())
{
SEFluidCircuitPath* hPath = dst.m_data.GetCircuits().GetFluidPath(name);
dst.m_data.GetCircuits().GetCardiovascularCircuit().AddPath(*hPath);
dst.m_HemorrhagePaths.push_back(hPath);
}
if (!dst.m_HemorrhagePaths.empty())
dst.m_data.GetCircuits().GetCardiovascularCircuit().StateChange();
}
PULSE_BIND::CardiovascularData* PBPulsePhysiology::Unload(const Cardiovascular& src)
{
......@@ -166,12 +139,6 @@ void PBPulsePhysiology::Serialize(const Cardiovascular& src, PULSE_BIND::Cardiov
dst.set_allocated_cardiaccyclepulmonaryarterypressure_mmhg(PBProperty::Unload(*src.m_CardiacCyclePulmonaryArteryPressure_mmHg));
dst.set_allocated_cardiaccyclecentralvenouspressure_mmhg(PBProperty::Unload(*src.m_CardiacCycleCentralVenousPressure_mmHg));
dst.set_allocated_cardiaccycleskinflow_ml_per_s(PBProperty::Unload(*src.m_CardiacCycleSkinFlow_mL_Per_s));
for (auto* l : src.m_HemorrhageLinks)
dst.add_hemorrhagelinks(l->GetName());
for (auto* p : src.m_HemorrhagePaths)
dst.add_hemorrhagepaths(p->GetName());
}
void PBPulsePhysiology::Load(const PULSE_BIND::DrugData& src, Drugs& dst)
......
This diff is collapsed.
......@@ -6,6 +6,7 @@
#include "system/physiology/SECardiovascularSystem.h"
#include "substance/SESubstanceTransport.h"
class SEPatient;
class SEHemorrhage;
class SELiquidCompartment;
class SEGasCompartment;
class SELiquidSubstanceQuantity;
......@@ -106,9 +107,6 @@ protected:
double m_CompressionTime_s;
double m_CompressionRatio;
double m_CompressionPeriod_s;
//Hemorrhage
std::vector<SELiquidCompartmentLink*> m_HemorrhageLinks;
std::vector<SEFluidCircuitPath*> m_HemorrhagePaths;
// Vitals and Averages
double m_CurrentCardiacCycleTime_s;
double m_CardiacCycleDiastolicVolume_mL; // Maximum left heart volume for the current cardiac cycle
......@@ -132,7 +130,17 @@ protected:
bool m_TuneCircuit = true;
std::string m_TuningFile;
double m_minIndividialSystemicResistance__mmHg_s_Per_mL;
// Hemorrhage
struct HemorrhageTrack
{
SELiquidCompartment* Compartment=nullptr;
std::vector<SEFluidCircuitNode*> Nodes;
std::map<SEFluidCircuitPath*, SELiquidCompartmentLink*> Paths2Links;
short NumNodesWithVolume=0;
};
std::map<SEHemorrhage*, HemorrhageTrack*>m_HemorrhageTrack;
double m_minIndividialSystemicResistance_mmHg_s_Per_mL;
SEFluidCircuitCalculator* m_circuitCalculator;
SELiquidTransporter* m_transporter;
......
......@@ -52,9 +52,6 @@ message CardiovascularData
pulse.cdm.bind.RunningAverageData CardiacCyclePulmonaryArteryPressure_mmHg = 30;
pulse.cdm.bind.RunningAverageData CardiacCycleCentralVenousPressure_mmHg = 31;
pulse.cdm.bind.RunningAverageData CardiacCycleSkinFlow_mL_Per_s = 32;
repeated string HemorrhageLinks = 33;
repeated string HemorrhagePaths = 34;
}
message DrugData
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment