Generic anesthesia machine for positive pressure ventilation. More...

#include <AnesthesiaMachine.h>

Inheritance diagram for biogears::AnesthesiaMachine:

Public Member Functions

virtual ~AnesthesiaMachine ()
 
const char * classname () const override
 
size_t hash_code () const override
 
void Clear () override
 
void Initialize () override
 Initializes system properties to valid homeostatic values. More...
 
virtual bool Load (const CDM::BioGearsAnesthesiaMachineData &in)
 
virtual CDM::BioGearsAnesthesiaMachineDataUnload () const override
 
void StateChange () override
 
void PreProcess () override
 Anesthesia machine preprocess function. More...
 
void Process () override
 Anesthesia machine process function. More...
 
void PostProcess () override
 Anesthesia machine postprocess function. More...
 
void CalculateScrubber ()
 Calculates the carbon dioxide removed by the scrubber. More...
 
void SetConnection (CDM::enumAnesthesiaMachineConnection::value c) override
 Connect to the patient via the ventilator mask, an endotracheal tube, or no connection. More...
 
void InvalidateConnection () override
 Removes the connection to the patient. More...
 
- Public Member Functions inherited from biogears::SEAnesthesiaMachine
 SEAnesthesiaMachine (SESubstanceManager &substances)
 
 ~SEAnesthesiaMachine () override
 
bool Load (const CDM::AnesthesiaMachineData &in)
 
Tree< const char * > GetPhysiologyRequestGraph () const override
 
void ForwardEvents (SEEventHandler *handler)
 
virtual CDM::enumAnesthesiaMachineConnection::value GetConnection () const
 
virtual bool HasConnection () const
 
bool HasInletFlow () const
 
SEScalarVolumePerTimeGetInletFlow ()
 
double GetInletFlow (const VolumePerTimeUnit &unit) const
 
bool HasInspiratoryExpiratoryRatio () const
 
SEScalarGetInspiratoryExpiratoryRatio ()
 
double GetInspiratoryExpiratoryRatio () const
 
bool HasOxygenFraction () const
 
SEScalarFractionGetOxygenFraction ()
 
double GetOxygenFraction () const
 
CDM::enumAnesthesiaMachineOxygenSource::value GetOxygenSource () const
 
void SetOxygenSource (CDM::enumAnesthesiaMachineOxygenSource::value name)
 
bool HasOxygenSource () const
 
void InvalidateOxygenSource ()
 
bool HasPositiveEndExpiredPressure () const
 
SEScalarPressureGetPositiveEndExpiredPressure ()
 
double GetPositiveEndExpiredPressure (const PressureUnit &unit) const
 
CDM::enumAnesthesiaMachinePrimaryGas::value GetPrimaryGas () const
 
void SetPrimaryGas (CDM::enumAnesthesiaMachinePrimaryGas::value name)
 
bool HasPrimaryGas () const
 
void InvalidatePrimaryGas ()
 
bool HasRespiratoryRate () const
 
SEScalarFrequencyGetRespiratoryRate ()
 
double GetRespiratoryRate (const FrequencyUnit &unit) const
 
bool HasReliefValvePressure () const
 
SEScalarPressureGetReliefValvePressure ()
 
double GetReliefValvePressure (const PressureUnit &unit) const
 
bool HasVentilatorPressure () const
 
SEScalarPressureGetVentilatorPressure ()
 
double GetVentilatorPressure (const PressureUnit &unit) const
 
bool HasLeftChamber () const
 
SEAnesthesiaMachineChamberGetLeftChamber ()
 
const SEAnesthesiaMachineChamberGetLeftChamber () const
 
void RemoveLeftChamber ()
 
bool HasRightChamber () const
 
SEAnesthesiaMachineChamberGetRightChamber ()
 
const SEAnesthesiaMachineChamberGetRightChamber () const
 
void RemoveRightChamber ()
 
bool HasOxygenBottleOne () const
 
SEAnesthesiaMachineOxygenBottleGetOxygenBottleOne ()
 
const SEAnesthesiaMachineOxygenBottleGetOxygenBottleOne () const
 
void RemoveOxygenBottleOne ()
 
bool HasOxygenBottleTwo () const
 
SEAnesthesiaMachineOxygenBottleGetOxygenBottleTwo ()
 
const SEAnesthesiaMachineOxygenBottleGetOxygenBottleTwo () const
 
void RemoveOxygenBottleTwo ()
 
bool Load (const std::string &file)
 
const SEScalarGetScalar (const char *name) override
 
const SEScalarGetScalar (const std::string &name) override
 
const std::map< CDM::enumAnesthesiaMachineEvent::value, bool > & GetEventStates () const
 
void SetEvent (CDM::enumAnesthesiaMachineEvent::value state, bool active, const SEScalarTime &time)
 
bool IsEventActive (CDM::enumAnesthesiaMachineEvent::value state) const
 
double GetEventDuration (CDM::enumAnesthesiaMachineEvent::value type, const TimeUnit &unit) const
 
void UpdateEvents (const SEScalarTime &timeStep)
 
- Public Member Functions inherited from biogears::SESystem
 SESystem (Logger *logger)
 
virtual ~SESystem ()
 
bool Load (const CDM::SystemData &in)
 
- Public Member Functions inherited from biogears::Loggable
 Loggable ()
 
 Loggable (Logger *log)
 
virtual ~Loggable ()
 
virtual LoggerGetLogger () const
 
- Public Member Functions inherited from biogears::BioGearsSystem
virtual void AtSteadyState ()
 Notify systems that steady state has been achieved. More...
 

Static Public Member Functions

static size_t TypeHash ()
 
static constexpr char const *const TypeTag ()
 
- Static Public Member Functions inherited from biogears::SEAnesthesiaMachine
static size_t TypeHash ()
 
static constexpr char const *const TypeTag ()
 
- Static Public Member Functions inherited from biogears::SESystem
static const SEScalarGetScalar (const char *name, std::vector< SESystem * > *systems)
 
static const SEScalarGetScalar (const std::string &name, std::vector< SESystem * > *systems)
 

Protected Member Functions

 AnesthesiaMachine (BioGears &bg)
 
virtual void Unload (CDM::BioGearsAnesthesiaMachineData &data) const
 
void SetUp () override
 Initializes parameters for the anesthesia machine class. More...
 
- Protected Member Functions inherited from biogears::SEAnesthesiaMachine
void Unload (CDM::AnesthesiaMachineData &data) const
 
void Merge (const SEAnesthesiaMachine &from)
 
void ProcessConfiguration (const SEAnesthesiaMachineConfiguration &config)
 
- Protected Member Functions inherited from biogears::SESystem
void Unload (CDM::SystemData &data) const
 
- Protected Member Functions inherited from biogears::Loggable
virtual void Debug (const char *msg, const char *origin="") const
 
virtual void Debug (const std::string &msg, const std::string &origin=empty) const
 
virtual void Debug (std::ostream &msg, const std::string &origin=empty) const
 
virtual void Info (const char *msg, const char *origin="") const
 
virtual void Info (const std::string &msg, const std::string &origin=empty) const
 
virtual void Info (std::ostream &msg, const std::string &origin=empty) const
 
virtual void Warning (const char *msg, const char *origin="") const
 
virtual void Warning (const std::string &msg, const std::string &origin=empty) const
 
virtual void Warning (std::ostream &msg, const std::string &origin=empty) const
 
virtual void Error (const char *msg, const char *origin="") const
 
virtual void Error (const std::string msg, const std::string origin=empty) const
 
virtual void Error (std::ostream &msg, const std::string &origin=empty) const
 
virtual void Fatal (const char *msg, const char *origin="") const
 
virtual void Fatal (const std::string &msg, const std::string &origin=empty) const
 
virtual void Fatal (std::ostream &msg, const std::string &origin=empty) const
 
- Protected Member Functions inherited from biogears::BioGearsSystem
virtual void LoadState ()
 

Static Protected Member Functions

static auto make_unique (BioGears &bg) -> std::unique_ptr< AnesthesiaMachine >
 

Protected Attributes

BioGearsm_data
 
- Protected Attributes inherited from biogears::SEAnesthesiaMachine
friend SEAnesthesiaMachineConfiguration
 
std::stringstream m_ss
 
SEEventHandlerm_EventHandler
 
std::map< CDM::enumAnesthesiaMachineEvent::value, bool > m_EventState
 
std::map< CDM::enumAnesthesiaMachineEvent::value, double > m_EventDuration_s
 
CDM::enumAnesthesiaMachineConnection::value m_Connection
 
SEScalarVolumePerTimem_InletFlow
 
SEScalarm_InspiratoryExpiratoryRatio
 
SEScalarFractionm_OxygenFraction
 
CDM::enumAnesthesiaMachineOxygenSource::value m_OxygenSource
 
SEScalarPressurem_PositiveEndExpiredPressure
 
CDM::enumAnesthesiaMachinePrimaryGas::value m_PrimaryGas
 
SEScalarFrequencym_RespiratoryRate
 
SEScalarPressurem_ReliefValvePressure
 
SEScalarPressurem_VentilatorPressure
 
SEAnesthesiaMachineChamberm_LeftChamber
 
SEAnesthesiaMachineChamberm_RightChamber
 
SEAnesthesiaMachineOxygenBottlem_OxygenBottleOne
 
SEAnesthesiaMachineOxygenBottlem_OxygenBottleTwo
 
SESubstanceManagerm_Substances
 
- Protected Attributes inherited from biogears::SESystem
std::stringstream m_ss
 
- Protected Attributes inherited from biogears::Loggable
Loggerm_Logger
 

Private Member Functions

void CalculateSourceStatus ()
 Checks the status of the oxygen source. More...
 
void CalculateEquipmentLeak ()
 Scales the resistance of anesthesia machine equipment in the presence of a leak. More...
 
void SetConnection ()
 Initializes gas volumes and volume fractions supplied by the anesthesia machine depending on the airway mode. More...
 
void CalculateValveResistances ()
 Valve resistance calculation. More...
 
void CalculateVentilator ()
 Calculates ventilator pressure. More...
 
void CalculateGasSource ()
 Updates the volume fractions for the gas inlet node. More...
 
void CalculateCyclePhase ()
 Calculates respiration cycle. More...
 
void CheckReliefValve ()
 Checks Relief Valve Pressure. More...
 

Private Attributes

friend BioGears
 
bool m_inhaling
 
SEScalarTime m_inspirationTime
 
SEScalar m_O2InletVolumeFraction
 
SEScalarTime m_currentbreathingCycleTime
 
SEScalarTime m_totalBreathingCycleTime
 
double m_dt_s
 
double m_dValveOpenResistance_cmH2O_s_Per_L
 
double m_dValveClosedResistance_cmH2O_s_Per_L
 
double m_dSwitchOpenResistance_cmH2O_s_Per_L
 
double m_dSwitchClosedResistance_cmH2O_s_Per_L
 
SEAnesthesiaMachineActionCollectionm_actions
 
SEGasCompartmentm_ambient
 
SEGasSubstanceQuantitym_ambientCO2
 
SEGasSubstanceQuantitym_ambientN2
 
SEGasSubstanceQuantitym_ambientO2
 
SEGasCompartmentm_gasSource
 
SEGasSubstanceQuantitym_gasSourceCO2
 
SEGasSubstanceQuantitym_gasSourceN2
 
SEGasSubstanceQuantitym_gasSourceO2
 
SEGasCompartmentm_scrubber
 
SEGasSubstanceQuantitym_scubberCO2
 
SEGasSubstanceQuantitym_scrubberN2
 
SEFluidCircuitNodem_nVentilator
 
SEFluidCircuitNodem_nSelector
 
SEFluidCircuitPathm_pAnesthesiaConnectionToEnvironment
 
SEFluidCircuitPathm_pYPieceToExpiratoryLimb
 
SEFluidCircuitPathm_pGasSourceToGasInlet
 
SEFluidCircuitPathm_pInspiratoryLimbToYPiece
 
SEFluidCircuitPathm_pSelectorToReliefValve
 
SEFluidCircuitPathm_pEnvironmentToReliefValve
 
SEFluidCircuitPathm_pSelectorToEnvironment
 
SEFluidCircuitPathm_pEnvironmentToVentilator
 
SEFluidCircuitPathm_pExpiratoryLimbToSelector
 
SEFluidCircuitPathm_pSelectorToScrubber
 

Friends

class BioGearsEngineTest
 

Additional Inherited Members

- Static Public Attributes inherited from biogears::Loggable
static const std::string empty
 
static const char * empty_cStr
 

Detailed Description

Generic anesthesia machine for positive pressure ventilation.

Constructor & Destructor Documentation

biogears::AnesthesiaMachine::AnesthesiaMachine ( BioGears bg)
protected
biogears::AnesthesiaMachine::~AnesthesiaMachine ( )
virtual

Member Function Documentation

void biogears::AnesthesiaMachine::CalculateCyclePhase ( )
private

Calculates respiration cycle.

The inspiratory and expiratory phase times are calculated based on a pre-set respiration rate and inspiration-expiration ratio parameters. These parameters are selected as input parameters for the anesthesia machine configurations.

void biogears::AnesthesiaMachine::CalculateEquipmentLeak ( )
private

Scales the resistance of anesthesia machine equipment in the presence of a leak.

The resistance of the mask, tube, and y piece are scaled based on the presence and severity of a leak. This will influence the circuit analyis and will effect the flow and gas mixture provided by the anesthesia machine. This occurs during preprocess.

Error:
Error: Invalid Airway Mode Encountered in Compute Equipment Leak function
void biogears::AnesthesiaMachine::CalculateGasSource ( )
private

Updates the volume fractions for the gas inlet node.

The final step of the anesthesia machine preprocess is to update the volume fractions for the gas inlet node. The gas mixture is determined based on the right and left chamber activity and specified substances and the oxygen percent setting on the anesthesia machine. The oxygen source (bottle and wall) are checked to ensure no equipment failures exist. The volume fractions are adjusted according to gas composition, the sources, and any failures present. All of the gases enter the anesthesia machine from a single source. The volume fractions of vapor (two vaporizor chambers) and oxygen can be specified. If the sum of the specified fractions is greater than one an error is logged and all substance volume fractions are scaled according the specified proportions. If the sum of the fractions specified is less than one then the remaining will be either nitrogen or the ambient gas substance, depending on whether nitrogen or air is specified as the primary gas.

Todo:
put these messages into a verbose for debugging
Todo:
loop over all ambient substances and set each volume fraction
void biogears::AnesthesiaMachine::CalculateScrubber ( )

Calculates the carbon dioxide removed by the scrubber.

Calculates the amount of carbon dioxide removed from the anesthesia machine by the scrubber. If a soda lime failure is present, the full amount of carbon dioxide is not removed. The amount removed is dependent on the severity of the failure. The substance volume in the scrubber node is decremented based on the amount of carbon dioxide removed. This function occurs during anesthesia machine preprocess.

void biogears::AnesthesiaMachine::CalculateSourceStatus ( )
private

Checks the status of the oxygen source.

Checks the status of the oxygen source. If an oxygen bottle is in use, ensures that the bottle still has oxygen. If the oxygen bottle no longer has oxygen, then an event is sent to the log notifying the user.

Event:
AnesthesiaMachine: Oxygen bottle 1 is exhausted. There is no longer any oxygen to provide via the anesthesia machine.
Event:
AnesthesiaMachine: Oxygen bottle 2 is exhausted. There is no longer any oxygen to provide via the anesthesia machine.
void biogears::AnesthesiaMachine::CalculateValveResistances ( )
private

Valve resistance calculation.

The method checks for the breathing cycle and sets the inspiratory or expiratory valves as open or closed by adjusting the corresponding valve resistances. The method also changes valve resistances to simulate equipment failures that correspond to valve leak and obstructions

void biogears::AnesthesiaMachine::CalculateVentilator ( )
private

Calculates ventilator pressure.

The Anesthesia machine employs pressure-control ventilation mode. This method calculates the control ventilator pressure that drives the gas flow in the breathing circle. During inspiration, the ventilator pressure is set to pre-defined constant value to serve as an input pressure source. This causes gas to flow into the inspiratory limb path. The pressure is dropped to much low pressure during the expiration phase to allow gas return to the ventilator.

void biogears::AnesthesiaMachine::CheckReliefValve ( )
private

Checks Relief Valve Pressure.

Assigns relief valve pressure as a pressure source based on the pressure setting and checks if the status of the relief valve is open or closed.

Event:
AnesthesiaMachine: Relief Valve is active. The pressure setting has been exceeded.
const char* biogears::AnesthesiaMachine::classname ( ) const
inlineoverridevirtual

Reimplemented from biogears::SEAnesthesiaMachine.

void biogears::AnesthesiaMachine::Clear ( )
overridevirtual

Reimplemented from biogears::SEAnesthesiaMachine.

size_t biogears::AnesthesiaMachine::hash_code ( ) const
inlineoverridevirtual

Reimplemented from biogears::SEAnesthesiaMachine.

void biogears::AnesthesiaMachine::Initialize ( )
overridevirtual

Initializes system properties to valid homeostatic values.

Reimplemented from biogears::BioGearsSystem.

void biogears::AnesthesiaMachine::InvalidateConnection ( )
overridevirtual

Removes the connection to the patient.

If the mask is on or the tube is connected, it is removed and the airway mode is set to free. The action is then removed from the action manager.

Reimplemented from biogears::SEAnesthesiaMachine.

bool biogears::AnesthesiaMachine::Load ( const CDM::BioGearsAnesthesiaMachineData in)
virtual
auto biogears::AnesthesiaMachine::make_unique ( BioGears bg) -> std::unique_ptr<AnesthesiaMachine>
staticprotected
void biogears::AnesthesiaMachine::PostProcess ( )
overridevirtual

Anesthesia machine postprocess function.

The substance volumes and the volume fractions are updated for all of the nodes in the anesthesia machine circuit during post process. The ventilator volumes are updated based on the previously calculated nodal analysis.

Implements biogears::BioGearsSystem.

void biogears::AnesthesiaMachine::PreProcess ( )
overridevirtual

Anesthesia machine preprocess function.

Checks the anesthesia machine settings to ensure all are within the acceptable ranges. Processes all equipment failures. Verifies the oxygen source. Processes any failures with the oxygen source. Calculates the gas inlet volume fractions based on equipment failures and gas sources.

Implements biogears::BioGearsSystem.

void biogears::AnesthesiaMachine::Process ( )
overridevirtual

Anesthesia machine process function.

The current BioGears implementation has no specific process functionality for the anesthesia machine. Anesthesia machine processing is currently done in the Respiratory System with the combined circuit methodology.

Implements biogears::BioGearsSystem.

void biogears::AnesthesiaMachine::SetConnection ( CDM::enumAnesthesiaMachineConnection::value  c)
overridevirtual

Connect to the patient via the ventilator mask, an endotracheal tube, or no connection.

Parameters
enumAnesthesiaMachineConnectionConnectoin type : Mask, tube, or off

If the enum is set to mask, then the mask is applied to the face If the enum is set to tube, then the machine is connected to the tube If the enum is set to off, the airway mode is set to free.

Reimplemented from biogears::SEAnesthesiaMachine.

void biogears::AnesthesiaMachine::SetConnection ( )
private

Initializes gas volumes and volume fractions supplied by the anesthesia machine depending on the airway mode.

The gas volumes and volume fractions are initialized and updated based on the airway mode (mask, free, or tube) and the volume associated with each airway mode.

void biogears::AnesthesiaMachine::SetUp ( )
overrideprotectedvirtual

Initializes parameters for the anesthesia machine class.

Initializes member variables and system level values on the common data model.

Implements biogears::BioGearsSystem.

void biogears::AnesthesiaMachine::StateChange ( )
overridevirtual

Reimplemented from biogears::SEAnesthesiaMachine.

static size_t biogears::AnesthesiaMachine::TypeHash ( )
inlinestatic
static constexpr char const* const biogears::AnesthesiaMachine::TypeTag ( )
inlinestatic
CDM::BioGearsAnesthesiaMachineData * biogears::AnesthesiaMachine::Unload ( ) const
overridevirtual

Reimplemented from biogears::SEAnesthesiaMachine.

void biogears::AnesthesiaMachine::Unload ( CDM::BioGearsAnesthesiaMachineData data) const
protectedvirtual

Friends And Related Function Documentation

friend class BioGearsEngineTest
friend

Member Data Documentation

friend biogears::AnesthesiaMachine::BioGears
private
SEAnesthesiaMachineActionCollection* biogears::AnesthesiaMachine::m_actions
private
SEGasCompartment* biogears::AnesthesiaMachine::m_ambient
private
SEGasSubstanceQuantity* biogears::AnesthesiaMachine::m_ambientCO2
private
SEGasSubstanceQuantity* biogears::AnesthesiaMachine::m_ambientN2
private
SEGasSubstanceQuantity* biogears::AnesthesiaMachine::m_ambientO2
private
SEScalarTime biogears::AnesthesiaMachine::m_currentbreathingCycleTime
private
BioGears& biogears::AnesthesiaMachine::m_data
protected
double biogears::AnesthesiaMachine::m_dSwitchClosedResistance_cmH2O_s_Per_L
private
double biogears::AnesthesiaMachine::m_dSwitchOpenResistance_cmH2O_s_Per_L
private
double biogears::AnesthesiaMachine::m_dt_s
private
double biogears::AnesthesiaMachine::m_dValveClosedResistance_cmH2O_s_Per_L
private
double biogears::AnesthesiaMachine::m_dValveOpenResistance_cmH2O_s_Per_L
private
SEGasCompartment* biogears::AnesthesiaMachine::m_gasSource
private
SEGasSubstanceQuantity* biogears::AnesthesiaMachine::m_gasSourceCO2
private
SEGasSubstanceQuantity* biogears::AnesthesiaMachine::m_gasSourceN2
private
SEGasSubstanceQuantity* biogears::AnesthesiaMachine::m_gasSourceO2
private
bool biogears::AnesthesiaMachine::m_inhaling
private
SEScalarTime biogears::AnesthesiaMachine::m_inspirationTime
private
SEFluidCircuitNode* biogears::AnesthesiaMachine::m_nSelector
private
SEFluidCircuitNode* biogears::AnesthesiaMachine::m_nVentilator
private
SEScalar biogears::AnesthesiaMachine::m_O2InletVolumeFraction
private
SEFluidCircuitPath* biogears::AnesthesiaMachine::m_pAnesthesiaConnectionToEnvironment
private
SEFluidCircuitPath* biogears::AnesthesiaMachine::m_pEnvironmentToReliefValve
private
SEFluidCircuitPath* biogears::AnesthesiaMachine::m_pEnvironmentToVentilator
private
SEFluidCircuitPath* biogears::AnesthesiaMachine::m_pExpiratoryLimbToSelector
private
SEFluidCircuitPath* biogears::AnesthesiaMachine::m_pGasSourceToGasInlet
private
SEFluidCircuitPath* biogears::AnesthesiaMachine::m_pInspiratoryLimbToYPiece
private
SEFluidCircuitPath* biogears::AnesthesiaMachine::m_pSelectorToEnvironment
private
SEFluidCircuitPath* biogears::AnesthesiaMachine::m_pSelectorToReliefValve
private
SEFluidCircuitPath* biogears::AnesthesiaMachine::m_pSelectorToScrubber
private
SEFluidCircuitPath* biogears::AnesthesiaMachine::m_pYPieceToExpiratoryLimb
private
SEGasCompartment* biogears::AnesthesiaMachine::m_scrubber
private
SEGasSubstanceQuantity* biogears::AnesthesiaMachine::m_scrubberN2
private
SEGasSubstanceQuantity* biogears::AnesthesiaMachine::m_scubberCO2
private
SEScalarTime biogears::AnesthesiaMachine::m_totalBreathingCycleTime
private