Commit 443b0796 authored by Aaron Bray's avatar Aaron Bray
Browse files

Merge branch 'feature/respiratory_disease' into '2.x'

Improved respiratory system and support for new disease states

See merge request !26
parents 8c01131d a4a158dd
......@@ -161,10 +161,6 @@ class SEScalarElectricResistance; class ElectricResistanceUnit;
class SEScalarEnergy; class EnergyUnit;
class SEScalarEnergyPerAmount; class EnergyPerAmountUnit;
class SEScalarEnergyPerMass; class EnergyPerMassUnit;
class SEScalarFlowCompliance; class FlowComplianceUnit;
class SEScalarFlowElastance; class FlowElastanceUnit;
class SEScalarFlowInertance; class FlowInertanceUnit;
class SEScalarFlowResistance; class FlowResistanceUnit;
class SEScalarForce; class ForceUnit;
class SEScalar0To1;
class SEScalarFrequency; class FrequencyUnit;
......@@ -193,8 +189,10 @@ class SEScalarPower; class PowerUnit;
class SEScalarPowerPerAreaTemperatureToTheFourth; class PowerPerAreaTemperatureToTheFourthUnit;
class SEScalarPressure; class PressureUnit;
class SEScalarPressurePerVolume; class PressurePerVolumeUnit;
class SEScalarPressureTimePerVolume; class PressureTimePerVolumeUnit;
class SEScalarPressureTimePerVolumeArea; class PressureTimePerVolumeAreaUnit;
class SEScalarPressureTimePerArea; class PressureTimePerAreaUnit;
class SEScalarPressureTimeSquaredPerVolume; class PressureTimeSquaredPerVolumeUnit;
class SEScalarTime; class TimeUnit;
class SEScalarTemperature; class TemperatureUnit;
class SEScalarVolume; class VolumeUnit;
......
......@@ -7,10 +7,10 @@
#include "properties/SEScalarElectricCurrent.h"
#include "properties/SEScalarElectricInductance.h"
#include "properties/SEScalarElectricResistance.h"
#include "properties/SEScalarFlowCompliance.h"
#include "properties/SEScalarVolumePerPressure.h"
#include "properties/SEScalarVolumePerTime.h"
#include "properties/SEScalarFlowInertance.h"
#include "properties/SEScalarFlowResistance.h"
#include "properties/SEScalarPressureTimeSquaredPerVolume.h"
#include "properties/SEScalarPressureTimePerVolume.h"
#include "properties/SEScalarHeatCapacitance.h"
#include "properties/SEScalarPower.h"
#include "properties/SEScalarHeatInductance.h"
......@@ -19,7 +19,7 @@
#define CIRCUIT_PATH_TEMPLATE typename FluxScalar, typename ResistanceScalar, typename CapacitanceScalar, typename InductanceScalar, typename PotentialScalar, typename QuantityScalar
#define CIRCUIT_PATH_TYPES FluxScalar,ResistanceScalar,CapacitanceScalar,InductanceScalar,PotentialScalar,QuantityScalar
#define ELECTRICAL_CIRCUIT_PATH SEScalarElectricCurrent, SEScalarElectricResistance, SEScalarElectricCapacitance, SEScalarElectricInductance, SEScalarElectricPotential, SEScalarElectricCharge
#define FLUID_CIRCUIT_PATH SEScalarVolumePerTime, SEScalarFlowResistance, SEScalarFlowCompliance, SEScalarFlowInertance, SEScalarPressure, SEScalarVolume
#define FLUID_CIRCUIT_PATH SEScalarVolumePerTime, SEScalarPressureTimePerVolume, SEScalarVolumePerPressure, SEScalarPressureTimeSquaredPerVolume, SEScalarPressure, SEScalarVolume
#define THERMAL_CIRCUIT_PATH SEScalarPower, SEScalarHeatResistance, SEScalarHeatCapacitance, SEScalarHeatInductance, SEScalarTemperature, SEScalarEnergy
template<CIRCUIT_PATH_TEMPLATE>
......
......@@ -5,12 +5,12 @@
#include "circuit/fluid/SEFluidCircuitCalculator.h"
SEFluidCircuitCalculator::SEFluidCircuitCalculator(Logger* logger) : SECircuitCalculator<SEFluidCircuit,SEFluidCircuitNode,SEFluidCircuitPath, FlowComplianceUnit, VolumePerTimeUnit, FlowInertanceUnit, PressureUnit, VolumeUnit, FlowResistanceUnit>(
FlowComplianceUnit::m3_Per_Pa,VolumePerTimeUnit::m3_Per_s, FlowInertanceUnit::Pa_s2_Per_m3,PressureUnit::Pa,VolumeUnit::m3,FlowResistanceUnit::Pa_s_Per_m3,logger)
SEFluidCircuitCalculator::SEFluidCircuitCalculator(Logger* logger) : SECircuitCalculator<SEFluidCircuit,SEFluidCircuitNode,SEFluidCircuitPath, VolumePerPressureUnit, VolumePerTimeUnit, PressureTimeSquaredPerVolumeUnit, PressureUnit, VolumeUnit, PressureTimePerVolumeUnit>(
VolumePerPressureUnit::m3_Per_Pa,VolumePerTimeUnit::m3_Per_s, PressureTimeSquaredPerVolumeUnit::Pa_s2_Per_m3,PressureUnit::Pa,VolumeUnit::m3,PressureTimePerVolumeUnit::Pa_s_Per_m3,logger)
{
}
SEFluidCircuitCalculator::SEFluidCircuitCalculator(const FlowComplianceUnit& c, const VolumePerTimeUnit& f, const FlowInertanceUnit& i, const PressureUnit& p, const VolumeUnit& q, const FlowResistanceUnit& r, Logger* logger) : SECircuitCalculator<SEFluidCircuit, SEFluidCircuitNode, SEFluidCircuitPath, FlowComplianceUnit, VolumePerTimeUnit, FlowInertanceUnit, PressureUnit, VolumeUnit, FlowResistanceUnit>(c, f, i, p, q, r, logger)
SEFluidCircuitCalculator::SEFluidCircuitCalculator(const VolumePerPressureUnit& c, const VolumePerTimeUnit& f, const PressureTimeSquaredPerVolumeUnit& i, const PressureUnit& p, const VolumeUnit& q, const PressureTimePerVolumeUnit& r, Logger* logger) : SECircuitCalculator<SEFluidCircuit, SEFluidCircuitNode, SEFluidCircuitPath, VolumePerPressureUnit, VolumePerTimeUnit, PressureTimeSquaredPerVolumeUnit, PressureUnit, VolumeUnit, PressureTimePerVolumeUnit>(c, f, i, p, q, r, logger)
{
}
......
......@@ -6,11 +6,11 @@
#include "circuit/SECircuitCalculator.h"
#include "circuit/fluid/SEFluidCircuit.h"
class CDM_DECL SEFluidCircuitCalculator : public SECircuitCalculator<SEFluidCircuit, SEFluidCircuitNode, SEFluidCircuitPath, FlowComplianceUnit, VolumePerTimeUnit, FlowInertanceUnit, PressureUnit, VolumeUnit, FlowResistanceUnit>
class CDM_DECL SEFluidCircuitCalculator : public SECircuitCalculator<SEFluidCircuit, SEFluidCircuitNode, SEFluidCircuitPath, VolumePerPressureUnit, VolumePerTimeUnit, PressureTimeSquaredPerVolumeUnit, PressureUnit, VolumeUnit, PressureTimePerVolumeUnit>
{
public:
SEFluidCircuitCalculator(Logger* logger);
SEFluidCircuitCalculator(const FlowComplianceUnit&, const VolumePerTimeUnit&, const FlowInertanceUnit&, const PressureUnit&, const VolumeUnit&, const FlowResistanceUnit&, Logger* logger);
SEFluidCircuitCalculator(const VolumePerPressureUnit&, const VolumePerTimeUnit&, const PressureTimeSquaredPerVolumeUnit&, const PressureUnit&, const VolumeUnit&, const PressureTimePerVolumeUnit&, Logger* logger);
virtual ~SEFluidCircuitCalculator();
};
\ No newline at end of file
......@@ -3,15 +3,15 @@
#include "stdafx.h"
#include "circuit/fluid/SEFluidCircuitPath.h"
#include "properties/SEScalarFlowResistance.h"
#include "properties/SEScalarFlowCompliance.h"
#include "properties/SEScalarFlowInertance.h"
#include "properties/SEScalarPressureTimePerVolume.h"
#include "properties/SEScalarVolumePerPressure.h"
#include "properties/SEScalarPressureTimeSquaredPerVolume.h"
#include "properties/SEScalarVolumePerTime.h"
#include "properties/SEScalarPressure.h"
#include "properties/SEScalarVolume.h"
SEFluidCircuitPath::SEFluidCircuitPath(SEFluidCircuitNode& src, SEFluidCircuitNode& tgt, const std::string& name) :
SECircuitPath<SEScalarVolumePerTime, SEScalarFlowResistance, SEScalarFlowCompliance, SEScalarFlowInertance, SEScalarPressure, SEScalarVolume>(src, tgt, name),
SECircuitPath<SEScalarVolumePerTime, SEScalarPressureTimePerVolume, SEScalarVolumePerPressure, SEScalarPressureTimeSquaredPerVolume, SEScalarPressure, SEScalarVolume>(src, tgt, name),
m_FluidSourceNode(src), m_FluidTargetNode(tgt)
{
......@@ -34,11 +34,11 @@ bool SEFluidCircuitPath::HasResistance() const
{
return SECircuitPath::HasResistance();
}
SEScalarFlowResistance& SEFluidCircuitPath::GetResistance()
SEScalarPressureTimePerVolume& SEFluidCircuitPath::GetResistance()
{
return SECircuitPath::GetResistance();
}
double SEFluidCircuitPath::GetResistance(const FlowResistanceUnit& unit) const
double SEFluidCircuitPath::GetResistance(const PressureTimePerVolumeUnit& unit) const
{
if (m_Resistance == nullptr)
return SEScalar::dNaN();
......@@ -48,11 +48,11 @@ bool SEFluidCircuitPath::HasNextResistance() const
{
return SECircuitPath::HasNextResistance();
}
SEScalarFlowResistance& SEFluidCircuitPath::GetNextResistance()
SEScalarPressureTimePerVolume& SEFluidCircuitPath::GetNextResistance()
{
return SECircuitPath::GetNextResistance();
}
double SEFluidCircuitPath::GetNextResistance(const FlowResistanceUnit& unit) const
double SEFluidCircuitPath::GetNextResistance(const PressureTimePerVolumeUnit& unit) const
{
if (m_NextResistance == nullptr)
return SEScalar::dNaN();
......@@ -62,11 +62,11 @@ bool SEFluidCircuitPath::HasResistanceBaseline() const
{
return SECircuitPath::HasResistanceBaseline();
}
SEScalarFlowResistance& SEFluidCircuitPath::GetResistanceBaseline()
SEScalarPressureTimePerVolume& SEFluidCircuitPath::GetResistanceBaseline()
{
return SECircuitPath::GetResistanceBaseline();
}
double SEFluidCircuitPath::GetResistanceBaseline(const FlowResistanceUnit& unit) const
double SEFluidCircuitPath::GetResistanceBaseline(const PressureTimePerVolumeUnit& unit) const
{
if (m_ResistanceBaseline == nullptr)
return SEScalar::dNaN();
......@@ -81,11 +81,11 @@ bool SEFluidCircuitPath::HasCompliance() const
{
return HasCapacitance();
}
SEScalarFlowCompliance& SEFluidCircuitPath::GetCompliance()
SEScalarVolumePerPressure& SEFluidCircuitPath::GetCompliance()
{
return GetCapacitance();
}
double SEFluidCircuitPath::GetCompliance(const FlowComplianceUnit& unit) const
double SEFluidCircuitPath::GetCompliance(const VolumePerPressureUnit& unit) const
{
if (m_Capacitance == nullptr)
return SEScalar::dNaN();
......@@ -95,11 +95,11 @@ bool SEFluidCircuitPath::HasNextCompliance() const
{
return HasNextCapacitance();
}
SEScalarFlowCompliance& SEFluidCircuitPath::GetNextCompliance()
SEScalarVolumePerPressure& SEFluidCircuitPath::GetNextCompliance()
{
return GetNextCapacitance();
}
double SEFluidCircuitPath::GetNextCompliance(const FlowComplianceUnit& unit) const
double SEFluidCircuitPath::GetNextCompliance(const VolumePerPressureUnit& unit) const
{
if (m_NextCapacitance == nullptr)
return SEScalar::dNaN();
......@@ -109,11 +109,11 @@ bool SEFluidCircuitPath::HasComplianceBaseline() const
{
return HasCapacitanceBaseline();
}
SEScalarFlowCompliance& SEFluidCircuitPath::GetComplianceBaseline()
SEScalarVolumePerPressure& SEFluidCircuitPath::GetComplianceBaseline()
{
return GetCapacitanceBaseline();
}
double SEFluidCircuitPath::GetComplianceBaseline(const FlowComplianceUnit& unit) const
double SEFluidCircuitPath::GetComplianceBaseline(const VolumePerPressureUnit& unit) const
{
if (m_CapacitanceBaseline == nullptr)
return SEScalar::dNaN();
......@@ -128,11 +128,11 @@ bool SEFluidCircuitPath::HasInertance() const
{
return HasInductance();
}
SEScalarFlowInertance& SEFluidCircuitPath::GetInertance()
SEScalarPressureTimeSquaredPerVolume& SEFluidCircuitPath::GetInertance()
{
return GetInductance();
}
double SEFluidCircuitPath::GetInertance(const FlowInertanceUnit& unit) const
double SEFluidCircuitPath::GetInertance(const PressureTimeSquaredPerVolumeUnit& unit) const
{
if (m_Inductance == nullptr)
return SEScalar::dNaN();
......@@ -142,11 +142,11 @@ bool SEFluidCircuitPath::HasNextInertance() const
{
return HasNextInductance();
}
SEScalarFlowInertance& SEFluidCircuitPath::GetNextInertance()
SEScalarPressureTimeSquaredPerVolume& SEFluidCircuitPath::GetNextInertance()
{
return GetNextInductance();
}
double SEFluidCircuitPath::GetNextInertance(const FlowInertanceUnit& unit) const
double SEFluidCircuitPath::GetNextInertance(const PressureTimeSquaredPerVolumeUnit& unit) const
{
if (m_NextInductance == nullptr)
return SEScalar::dNaN();
......@@ -156,11 +156,11 @@ bool SEFluidCircuitPath::HasInertanceBaseline() const
{
return HasInductanceBaseline();
}
SEScalarFlowInertance& SEFluidCircuitPath::GetInertanceBaseline()
SEScalarPressureTimeSquaredPerVolume& SEFluidCircuitPath::GetInertanceBaseline()
{
return GetInductanceBaseline();
}
double SEFluidCircuitPath::GetInertanceBaseline(const FlowInertanceUnit& unit) const
double SEFluidCircuitPath::GetInertanceBaseline(const PressureTimeSquaredPerVolumeUnit& unit) const
{
if (m_InductanceBaseline == nullptr)
return SEScalar::dNaN();
......
......@@ -20,34 +20,34 @@ public:
virtual SEFluidCircuitNode& GetTargetNode() const { return m_FluidTargetNode; }
virtual bool HasResistance() const;
virtual SEScalarFlowResistance& GetResistance();
virtual double GetResistance(const FlowResistanceUnit& unit) const;
virtual SEScalarPressureTimePerVolume& GetResistance();
virtual double GetResistance(const PressureTimePerVolumeUnit& unit) const;
virtual bool HasNextResistance() const;
virtual SEScalarFlowResistance& GetNextResistance();
virtual double GetNextResistance(const FlowResistanceUnit& unit) const;
virtual SEScalarPressureTimePerVolume& GetNextResistance();
virtual double GetNextResistance(const PressureTimePerVolumeUnit& unit) const;
virtual bool HasResistanceBaseline() const;
virtual SEScalarFlowResistance& GetResistanceBaseline();
virtual double GetResistanceBaseline(const FlowResistanceUnit& unit) const;
virtual SEScalarPressureTimePerVolume& GetResistanceBaseline();
virtual double GetResistanceBaseline(const PressureTimePerVolumeUnit& unit) const;
virtual bool HasCompliance() const;
virtual SEScalarFlowCompliance& GetCompliance();
virtual double GetCompliance(const FlowComplianceUnit& unit) const;
virtual SEScalarVolumePerPressure& GetCompliance();
virtual double GetCompliance(const VolumePerPressureUnit& unit) const;
virtual bool HasNextCompliance() const;
virtual SEScalarFlowCompliance& GetNextCompliance();
virtual double GetNextCompliance(const FlowComplianceUnit& unit) const;
virtual SEScalarVolumePerPressure& GetNextCompliance();
virtual double GetNextCompliance(const VolumePerPressureUnit& unit) const;
virtual bool HasComplianceBaseline() const;
virtual SEScalarFlowCompliance& GetComplianceBaseline();
virtual double GetComplianceBaseline(const FlowComplianceUnit& unit) const;
virtual SEScalarVolumePerPressure& GetComplianceBaseline();
virtual double GetComplianceBaseline(const VolumePerPressureUnit& unit) const;
virtual bool HasInertance() const;
virtual SEScalarFlowInertance& GetInertance();
virtual double GetInertance(const FlowInertanceUnit& unit) const;
virtual SEScalarPressureTimeSquaredPerVolume& GetInertance();
virtual double GetInertance(const PressureTimeSquaredPerVolumeUnit& unit) const;
virtual bool HasNextInertance() const;
virtual SEScalarFlowInertance& GetNextInertance();
virtual double GetNextInertance(const FlowInertanceUnit& unit) const;
virtual SEScalarPressureTimeSquaredPerVolume& GetNextInertance();
virtual double GetNextInertance(const PressureTimeSquaredPerVolumeUnit& unit) const;
virtual bool HasInertanceBaseline() const;
virtual SEScalarFlowInertance& GetInertanceBaseline();
virtual double GetInertanceBaseline(const FlowInertanceUnit& unit) const;
virtual SEScalarPressureTimeSquaredPerVolume& GetInertanceBaseline();
virtual double GetInertanceBaseline(const PressureTimeSquaredPerVolumeUnit& unit) const;
virtual bool HasFlow() const;
virtual SEScalarVolumePerTime& GetFlow();
......
......@@ -26,14 +26,14 @@ public:
virtual std::string GetName() const { return m_Name; }
virtual bool HasCompliance() const;
virtual double GetCompliance(const FlowComplianceUnit& unit) const;
virtual double GetCompliance(const VolumePerPressureUnit& unit) const;
virtual bool HasFlow() const;
virtual SEScalarVolumePerTime& GetFlow();
virtual double GetFlow(const VolumePerTimeUnit& unit) const;
virtual bool HasResistance() const;
virtual double GetResistance(const FlowResistanceUnit& unit) const;
virtual double GetResistance(const PressureTimePerVolumeUnit& unit) const;
virtual CompartmentType& GetSourceCompartment() { return m_SourceCmpt; }
virtual CompartmentType& GetTargetCompartment() { return m_TargetCmpt; }
......
......@@ -44,7 +44,7 @@ bool SEFluidCompartmentLink<FLUID_COMPARTMENT_LINK_TYPES>::HasCompliance() const
return false;
}
template<FLUID_COMPARTMENT_LINK_TEMPLATE>
double SEFluidCompartmentLink<FLUID_COMPARTMENT_LINK_TYPES>::GetCompliance(const FlowComplianceUnit& unit) const
double SEFluidCompartmentLink<FLUID_COMPARTMENT_LINK_TYPES>::GetCompliance(const VolumePerPressureUnit& unit) const
{
if (m_Path != nullptr)
return m_Path->GetNextCompliance(unit);
......@@ -86,7 +86,7 @@ bool SEFluidCompartmentLink<FLUID_COMPARTMENT_LINK_TYPES>::HasResistance() const
return false;
}
template<FLUID_COMPARTMENT_LINK_TEMPLATE>
double SEFluidCompartmentLink<FLUID_COMPARTMENT_LINK_TYPES>::GetResistance(const FlowResistanceUnit& unit) const
double SEFluidCompartmentLink<FLUID_COMPARTMENT_LINK_TYPES>::GetResistance(const PressureTimePerVolumeUnit& unit) const
{
if (m_Path != nullptr)
return m_Path->GetNextResistance(unit);
......
......@@ -49,7 +49,7 @@ void SEGasCompartment::Balance(BalanceGasBy by)
else
{
subQ->GetVolumeFraction().SetValue(subQ->GetVolume(VolumeUnit::mL) / totalVolume_mL);
subQ->GetVolume().SetValue(subQ->GetVolumeFraction().GetValue() * GetVolume(VolumeUnit::mL), VolumeUnit::mL);
subQ->GetVolume().SetValue(subQ->GetVolumeFraction().GetValue() * GetVolume(VolumeUnit::mL), VolumeUnit::mL);
if(HasPressure())
GeneralMath::CalculatePartialPressureInGas(subQ->GetVolumeFraction(), GetPressure(), subQ->GetPartialPressure(), m_Logger);
}
......
......@@ -48,8 +48,18 @@ void SEGasSubstanceQuantity::Clear()
void SEGasSubstanceQuantity::SetToZero()
{
GetPartialPressure().SetValue(0, PressureUnit::mmHg);
GetVolume().SetValue(0, VolumeUnit::mL);
auto& pp = GetPartialPressure();
if (pp.HasUnit())
pp.SetValue(0, *pp.GetUnit());
else
pp.SetValue(0, PressureUnit::mmHg);
auto& vol = GetVolume();
if (vol.HasUnit())
vol.SetValue(0, *vol.GetUnit());
else
vol.SetValue(0, VolumeUnit::mL);
GetVolumeFraction().SetValue(0);
}
......
......@@ -85,16 +85,53 @@ void SELiquidSubstanceQuantity::Clear()
void SELiquidSubstanceQuantity::SetToZero()
{
GetConcentration().SetValue(0, MassPerVolumeUnit::mg_Per_mL);
GetMass().SetValue(0, MassUnit::mg);
GetMolarity().SetValue(0, AmountPerVolumeUnit::mmol_Per_mL);
auto& c = GetConcentration();
if (c.HasUnit())
c.SetValue(0, *c.GetUnit());
else
c.SetValue(0, MassPerVolumeUnit::mg_Per_mL);
auto& m = GetMass();
if (m.HasUnit())
m.SetValue(0, *m.GetUnit());
else
m.SetValue(0, MassUnit::mg);
auto& mol = GetMolarity();
if (mol.HasUnit())
mol.SetValue(0, *mol.GetUnit());
else
mol.SetValue(0, AmountPerVolumeUnit::mmol_Per_mL);
if (m_Substance.GetState() == eSubstance_State::Gas)
GetPartialPressure().SetValue(0, PressureUnit::mmHg);
{
auto& pp = GetPartialPressure();
if (pp.HasUnit())
pp.SetValue(0, *pp.GetUnit());
else
pp.SetValue(0, PressureUnit::mmHg);
}
if (m_isO2 || m_isCO || m_isCO2)
GetSaturation().SetValue(0);
GetMassCleared().SetValue(0, MassUnit::mg);
GetMassDeposited().SetValue(0, MassUnit::mg);
GetMassExcreted().SetValue(0, MassUnit::mg);
auto& mc = GetMassCleared();
if (mc.HasUnit())
mc.SetValue(0, *mc.GetUnit());
else
mc.SetValue(0, MassUnit::mg);
auto& md = GetMassDeposited();
if (md.HasUnit())
md.SetValue(0, *md.GetUnit());
else
md.SetValue(0, MassUnit::mg);
auto& me = GetMassExcreted();
if (me.HasUnit())
me.SetValue(0, *me.GetUnit());
else
me.SetValue(0, MassUnit::mg);
}
const SEScalar* SELiquidSubstanceQuantity::GetScalar(const std::string& name)
......@@ -342,7 +379,7 @@ SEScalarAmountPerVolume& SELiquidSubstanceQuantity::GetMolarity()
m_Molarity->Invalidate();
else
{
double molarity_mmol_Per_mL = GetMass(MassUnit::mg) / m_Substance.GetMolarMass(MassPerAmountUnit::mg_Per_mmol) / m_Compartment.GetVolume(VolumeUnit::mL);
double molarity_mmol_Per_mL = GetMass(MassUnit::mg) / m_Substance.GetMolarMass(MassPerAmountUnit::mg_Per_mmol) / m_Compartment.GetVolume(VolumeUnit::mL);
m_Molarity->SetValue(molarity_mmol_Per_mL, AmountPerVolumeUnit::mmol_Per_mL);
}
m_Molarity->SetReadOnly(true);
......
......@@ -4,15 +4,17 @@
#include "stdafx.h"
#include "engine/SEConditionManager.h"
//Patient Conditions
#include "patient/conditions/SEAcuteRespiratoryDistressSyndrome.h"
#include "patient/conditions/SEChronicAnemia.h"
#include "patient/conditions/SEChronicObstructivePulmonaryDisease.h"
#include "patient/conditions/SEChronicHeartFailure.h"
#include "patient/conditions/SEChronicPericardialEffusion.h"
#include "patient/conditions/SEChronicRenalStenosis.h"
#include "patient/conditions/SEChronicVentricularSystolicDysfunction.h"
#include "patient/conditions/SEConsumeMeal.h"
#include "patient/conditions/SELobarPneumonia.h"
#include "patient/conditions/SEChronicPericardialEffusion.h"
#include "patient/conditions/SEImpairedAlveolarExchange.h"
#include "patient/conditions/SELobarPneumonia.h"
#include "patient/conditions/SESepsis.h"
// Environment Conditions
#include "system/environment/conditions/SEInitialEnvironmentConditions.h"
#include "substance/SESubstance.h"
......@@ -21,6 +23,7 @@
SEConditionManager::SEConditionManager(SESubstanceManager& substances) : Loggable(substances.GetLogger()), m_Substances(substances)
{
m_ARDS = nullptr;
m_Anemia = nullptr;
m_COPD = nullptr;
m_ChronicVentricularSystolicDysfunction = nullptr;
......@@ -30,6 +33,7 @@ SEConditionManager::SEConditionManager(SESubstanceManager& substances) : Loggabl
m_PericardialEffusion = nullptr;
m_ImpairedAlveolarExchange = nullptr;
m_InitialEnvironmentConditions = nullptr;
m_Sepsis = nullptr;
}
SEConditionManager::~SEConditionManager()
......@@ -39,6 +43,7 @@ SEConditionManager::~SEConditionManager()
void SEConditionManager::Clear()
{
SAFE_DELETE(m_ARDS);
SAFE_DELETE(m_Anemia);
SAFE_DELETE(m_COPD);
SAFE_DELETE(m_ChronicVentricularSystolicDysfunction);
......@@ -48,6 +53,7 @@ void SEConditionManager::Clear()
SAFE_DELETE(m_PericardialEffusion);
SAFE_DELETE(m_ImpairedAlveolarExchange);
SAFE_DELETE(m_InitialEnvironmentConditions);
SAFE_DELETE(m_Sepsis);
}
void SEConditionManager::Copy(const SEConditionManager& src)
......@@ -94,6 +100,19 @@ bool SEConditionManager::ProcessCondition(const SECondition& condition)
if (dynamic_cast<const SEPatientCondition*>(&condition) != nullptr)
{
const SEAcuteRespiratoryDistressSyndrome* ards = dynamic_cast<const SEAcuteRespiratoryDistressSyndrome*>(&condition);
if (ards != nullptr)
{
if (HasAcuteRespiratoryDistressSyndrome())
{
Error("Cannot have multiple ARDS conditions");
return false;
}
m_ARDS = new SEAcuteRespiratoryDistressSyndrome();
m_ARDS->Copy(*ards);
return true;
}
const SEChronicAnemia* a = dynamic_cast<const SEChronicAnemia*>(&condition);
if (a != nullptr)
{
......@@ -203,6 +222,19 @@ bool SEConditionManager::ProcessCondition(const SECondition& condition)
m_LobarPneumonia->Copy(*lp);
return true;
}
const SESepsis* s = dynamic_cast<const SESepsis*>(&condition);
if (s != nullptr)
{
if (HasSepsis())
{
Error("Cannot have multiple Lobar Pneumonia conditions");
return false;
}
m_Sepsis = new SESepsis();
m_Sepsis->Copy(*s);
return true;
}
}
if (dynamic_cast<const SEEnvironmentCondition*>(&condition) != nullptr)
......@@ -226,6 +258,19 @@ bool SEConditionManager::ProcessCondition(const SECondition& condition)
return false;
}
bool SEConditionManager::HasAcuteRespiratoryDistressSyndrome() const
{
return m_ARDS == nullptr ? false : m_ARDS->IsValid();
}
SEAcuteRespiratoryDistressSyndrome* SEConditionManager::GetAcuteRespiratoryDistressSyndrome()
{
return m_ARDS;
}
const SEAcuteRespiratoryDistressSyndrome* SEConditionManager::GetAcuteRespiratoryDistressSyndrome() const
{
return m_ARDS;
}
bool SEConditionManager::HasChronicAnemia() const
{
return m_Anemia == nullptr ? false : m_Anemia->IsValid();
......@@ -335,6 +380,19 @@ const SELobarPneumonia* SEConditionManager::GetLobarPneumonia() const
return m_LobarPneumonia;
}
bool SEConditionManager::HasSepsis() const
{
return m_Sepsis == nullptr ? false : m_Sepsis->IsValid();
}
SESepsis* SEConditionManager::GetSepsis()
{
return m_Sepsis;
}
const SESepsis* SEConditionManager::GetSepsis() const
{
return m_Sepsis;
}
bool SEConditionManager::HasInitialEnvironmentConditions() const
{
return m_InitialEnvironmentConditions == nullptr ? false : m_InitialEnvironmentConditions->IsValid();
......@@ -350,6 +408,8 @@ const SEInitialEnvironmentConditions* SEConditionManager::GetInitialEnvironmentC
void SEConditionManager::GetAllConditions(std::vector<const SECondition*>& conditions) const
{
if (HasAcuteRespiratoryDistressSyndrome())
conditions.push_back(GetAcuteRespiratoryDistressSyndrome());
if (HasChronicAnemia())
conditions.push_back(GetChronicAnemia());
if (HasChronicObstructivePulmonaryDisease())
......@@ -366,12 +426,17 @@ void SEConditionManager::GetAllConditions(std::vector<const SECondition*>& condi
conditions.push_back(GetImpairedAlveolarExchange());
if (HasLobarPneumonia())
conditions.push_back(GetLobarPneumonia());
if (HasSepsis())
conditions.push_back(GetSepsis());
if (HasInitialEnvironmentConditions())
conditions.push_back(GetInitialEnvironmentConditions());
}
bool SEConditionManager::IsEmpty() const
{
if (HasAcuteRespiratoryDistressSyndrome())
return false;
if (HasChronicAnemia())
return false;
if (HasChronicObstructivePulmonaryDisease())
......@@ -388,6 +453,9 @@ bool SEConditionManager::IsEmpty() const
return false;
if (HasLobarPneumonia())
return false;
if (HasSepsis())
return false;
if (HasInitialEnvironmentConditions())
return false;
return true;
......
......@@ -4,15 +4,17 @@
#pragma once
class SECondition;
//Patient Conditions
class SEAcuteRespiratoryDistressSyndrome;
class SEChronicAnemia;
class SEChronicObstructivePulmonaryDisease;
class SEChronicHeartFailure;
class SEChronicPericardialEffusion;
class SEChronicRenalStenosis;
class SEChronicVentricularSystolicDysfunction;
class SEConsumeMeal;
class SELobarPneumonia;
class SEChronicPericardialEffusion;
class SEImpairedAlveolarExchange;
class SELobarPneumonia;
class SESepsis;
// Environment Conditions