Commit c69d9eb4 authored by Jeff Webb's avatar Jeff Webb
Browse files

Added base excess as blood chemistry system data.

parent e0164529
......@@ -7,6 +7,7 @@ PROTO_PUSH
#include "bind/cdm/Properties.pb.h"
PROTO_POP
AmountPerVolumeUnit AmountPerVolumeUnit::meq_Per_L("meq/L");
AmountPerVolumeUnit AmountPerVolumeUnit::mol_Per_L("mol/L");
AmountPerVolumeUnit AmountPerVolumeUnit::mol_Per_mL("mol/mL");
AmountPerVolumeUnit AmountPerVolumeUnit::mmol_Per_L("mmol/L");
......@@ -16,6 +17,8 @@ AmountPerVolumeUnit AmountPerVolumeUnit::ct_Per_uL("ct/uL");
bool AmountPerVolumeUnit::IsValidUnit(const std::string& unit)
{
if (meq_Per_L.GetString().compare(unit) == 0)
return true;
if (mol_Per_L.GetString().compare(unit) == 0)
return true;
if (mol_Per_mL.GetString().compare(unit) == 0)
......@@ -33,6 +36,8 @@ bool AmountPerVolumeUnit::IsValidUnit(const std::string& unit)
const AmountPerVolumeUnit& AmountPerVolumeUnit::GetCompoundUnit(const std::string& unit)
{
if (meq_Per_L.GetString().compare(unit) == 0)
return meq_Per_L;
if (mol_Per_L.GetString().compare(unit) == 0)
return mol_Per_L;
if (mol_Per_mL.GetString().compare(unit) == 0)
......
......@@ -14,6 +14,7 @@ public:
static bool IsValidUnit(const std::string& unit);
static const AmountPerVolumeUnit& GetCompoundUnit(const std::string& unit);
static AmountPerVolumeUnit meq_Per_L;
static AmountPerVolumeUnit mol_Per_L;
static AmountPerVolumeUnit mol_Per_mL;
static AmountPerVolumeUnit mmol_Per_L;
......
......@@ -18,6 +18,7 @@ SEBloodChemistrySystem::SEBloodChemistrySystem(Logger* logger) : SESystem(logger
{
m_BloodDensity = nullptr;
m_BaseExcess = nullptr;
m_BloodPH = nullptr;
m_BloodSpecificHeat = nullptr;
m_BloodUreaNitrogenConcentration = nullptr;
......@@ -56,6 +57,7 @@ void SEBloodChemistrySystem::Clear()
{
SESystem::Clear();
SAFE_DELETE(m_BaseExcess);
SAFE_DELETE(m_BloodDensity);
SAFE_DELETE(m_BloodPH);
SAFE_DELETE(m_BloodSpecificHeat);
......@@ -88,6 +90,8 @@ void SEBloodChemistrySystem::Clear()
const SEScalar* SEBloodChemistrySystem::GetScalar(const std::string& name)
{
if (name.compare("BaseExcess") == 0)
return &GetBaseExcess();
if (name.compare("BloodDensity") == 0)
return &GetBloodDensity();
if (name.compare("BloodPH") == 0)
......@@ -153,6 +157,8 @@ void SEBloodChemistrySystem::Load(const cdm::BloodChemistrySystemData& src, SEBl
void SEBloodChemistrySystem::Serialize(const cdm::BloodChemistrySystemData& src, SEBloodChemistrySystem& dst)
{
dst.Clear();
if (src.has_baseexcess())
SEScalarAmountPerVolume::Load(src.baseexcess(), dst.GetBaseExcess());
if (src.has_blooddensity())
SEScalarMassPerVolume::Load(src.blooddensity(), dst.GetBloodDensity());
if (src.has_bloodph())
......@@ -218,6 +224,8 @@ cdm::BloodChemistrySystemData* SEBloodChemistrySystem::Unload(const SEBloodChemi
}
void SEBloodChemistrySystem::Serialize(const SEBloodChemistrySystem& src, cdm::BloodChemistrySystemData& dst)
{
if (src.HasBaseExcess())
dst.set_allocated_baseexcess(SEScalarAmountPerVolume::Unload(*src.m_BaseExcess));
if (src.HasBloodDensity())
dst.set_allocated_blooddensity(SEScalarMassPerVolume::Unload(*src.m_BloodDensity));
if (src.HasBloodPH())
......@@ -275,6 +283,23 @@ void SEBloodChemistrySystem::Serialize(const SEBloodChemistrySystem& src, cdm::B
dst.set_allocated_venousoxygenpressure(SEScalarPressure::Unload(*src.m_VenousOxygenPressure));
}
bool SEBloodChemistrySystem::HasBaseExcess() const
{
return m_BaseExcess == nullptr ? false : m_BaseExcess->IsValid();
}
SEScalarAmountPerVolume& SEBloodChemistrySystem::GetBaseExcess()
{
if (m_BaseExcess == nullptr)
m_BaseExcess = new SEScalarAmountPerVolume();
return *m_BaseExcess;
}
double SEBloodChemistrySystem::GetBaseExcess(const AmountPerVolumeUnit& unit) const
{
if (m_BaseExcess == nullptr)
return SEScalar::dNaN();
return m_BaseExcess->GetValue(unit);
}
bool SEBloodChemistrySystem::HasBloodDensity() const
{
return m_BloodDensity == nullptr ? false : m_BloodDensity->IsValid();
......
......@@ -26,6 +26,16 @@ protected:
static void Serialize(const SEBloodChemistrySystem& src, cdm::BloodChemistrySystemData& dst); /**< @copydoc DOXY_CDM_SERIALIZE_OUT *///@}
public:
/** @name BaseExcess
* @brief @copybrief Physiology_BloodChemistrySystemData_BaseExcess
* @{*/
/// %Test if member has been allocated
virtual bool HasBaseExcess() const;
/// Get member class, allocate if nullptr
virtual SEScalarAmountPerVolume& GetBaseExcess();
virtual double GetBaseExcess(AmountPerVolumeUnit& unit) const;
//@}
/** @name BloodDensity *///@{ @copybrief Physiology_BloodChemistrySystemData_BloodDensity
virtual bool HasBloodDensity() const; /**< @copydoc DOXY_CDM_HAS */
virtual SEScalarMassPerVolume& GetBloodDensity(); /**< @copydoc DOXY_CDM_GET */
......@@ -293,6 +303,7 @@ public:
protected:
SEScalarAmountPerVolume * m_BaseExcess;
SEScalarMassPerVolume* m_BloodDensity;
SEScalar* m_BloodPH;
SEScalarHeatCapacitancePerMass* m_BloodSpecificHeat;
......
......@@ -9,6 +9,7 @@ import mil.tatrc.physiology.datamodel.system.SESystem;
public class SEBloodChemistrySystem extends SEPhysiologySystem implements SESystem
{
protected SEScalarAmountPerVolume baseExcess;
protected SEScalarMassPerVolume bloodDensity;
protected SEScalar bloodPH;
protected SEScalarHeatCapacitancePerMass bloodSpecificHeat;
......@@ -40,7 +41,8 @@ public class SEBloodChemistrySystem extends SEPhysiologySystem implements SESyst
public SEBloodChemistrySystem()
{
bloodDensity = null;
baseExcess = null;
bloodDensity = null;
bloodPH = null;
bloodSpecificHeat = null;
bloodUreaNitrogenConcentration = null;
......@@ -72,6 +74,8 @@ public class SEBloodChemistrySystem extends SEPhysiologySystem implements SESyst
public void reset()
{
if (baseExcess != null)
baseExcess.invalidate();
if (bloodDensity != null)
bloodDensity.invalidate();
if (bloodPH != null)
......@@ -131,6 +135,8 @@ public class SEBloodChemistrySystem extends SEPhysiologySystem implements SESyst
public static void load(BloodChemistrySystemData src, SEBloodChemistrySystem dst)
{
if (src.hasBaseExcess())
SEScalarAmountPerVolume.load(src.getBaseExcess(),dst.getBaseExcess());
if (src.hasBloodDensity())
SEScalarMassPerVolume.load(src.getBloodDensity(),dst.getBloodDensity());
if (src.hasBloodPH())
......@@ -197,6 +203,8 @@ public class SEBloodChemistrySystem extends SEPhysiologySystem implements SESyst
protected static void unload(SEBloodChemistrySystem src, BloodChemistrySystemData.Builder dst)
{
if (src.hasBaseExcess())
dst.setBaseExcess(SEScalarAmountPerVolume.unload(src.getBaseExcess()));
if (src.hasBloodDensity())
dst.setBloodDensity(SEScalarMassPerVolume.unload(src.getBloodDensity()));
if (src.hasBloodPH())
......@@ -254,6 +262,17 @@ public class SEBloodChemistrySystem extends SEPhysiologySystem implements SESyst
dst.setVenousCarbonDioxidePressure(SEScalarPressure.unload(src.getVenousCarbonDioxidePressure()));
}
public boolean hasBaseExcess()
{
return baseExcess == null ? false : baseExcess.isValid();
}
public SEScalarAmountPerVolume getBaseExcess()
{
if (baseExcess == null)
baseExcess = new SEScalarAmountPerVolume();
return baseExcess;
}
public boolean hasBloodDensity()
{
return bloodDensity == null ? false : bloodDensity.isValid();
......
......@@ -296,6 +296,10 @@ void BloodChemistry::Process()
/// \todo Change system data so that we have ArterialBloodPH (from aorta) and VenousBloodPH (from vena cava)
GetBloodPH().Set(m_aorta->GetPH());
// Calculate Base Excess
double HCO3_mEq_Per_L = m_aortaBicarbonate->GetMolarity(AmountPerVolumeUnit::mmol_Per_L);
GetBaseExcess().SetValue(0.93 * HCO3_mEq_Per_L + 13.77 * m_aorta->GetPH().GetValue() - 124.58, AmountPerVolumeUnit::meq_Per_L);
// Pressures
// arterial gas partial pressures -
GetArterialOxygenPressure().Set(m_aortaO2->GetPartialPressure());
......
......@@ -22,6 +22,7 @@ message PupillaryResponseData
and will be improved in future releases to include more substances that can provide clinician level details and assessments, such as a CBC and blood panel.*/
message BloodChemistrySystemData
{
ScalarAmountPerVolumeData BaseExcess = 28;/**<< @brief Excess or deficit, respectively, in the amount of base present in the blood. */
ScalarMassPerVolumeData BloodDensity = 1; /**<< @brief Mass per unit volume of the blood. */
ScalarData BloodPH = 2; /**<< @brief Measure of acidity or basicity of the blood. */
ScalarHeatCapacitancePerMassData BloodSpecificHeat = 3; /**<< @brief The amount of energy required to raise one kilogram of blood by one degree Celsius. */
......
Supports Markdown
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