Commit c69cbbcb authored by fmg005's avatar fmg005

To handle simulation actions i.e. infusions

parent 64050d8c
#include "Action.h"
using namespace CLA;
Action::Action(std::shared_ptr<CLA::LOGGER>& logger) : m_logger(logger) {
NorepiConcentration = 16;
bpdrug_prev_rate = 0;
saline_prev_rate = 0;
SalineBagVolume = 500;
}
void Action::initialize(std::unique_ptr<PhysiologyEngine>& engine, const string&
substance) {
if (substance == "Norepinephrine") {
m_bpdrug = engine->GetSubstanceManager().GetSubstance(substance);
m_bpdrug_infusion = new SESubstanceInfusion(*m_bpdrug);
m_bpdrug_infusion->GetConcentration().SetValue(NorepiConcentration, MassPerVolumeUnit::ug_Per_mL);
}
else if (substance == "Saline") {
m_saline = engine->GetSubstanceManager().GetCompound(substance);
m_infusion = new SESubstanceCompoundInfusion(*m_saline);
m_infusion->GetBagVolume().SetValue(SalineBagVolume, VolumeUnit::mL);
}
}
void Action::infuse_drug(std::unique_ptr<PhysiologyEngine>& engine, const string&
substance, double new_rate) {
if (substance == "Norepinephrine") {
if (bpdrug_prev_rate != new_rate && new_rate > 0) {
m_bpdrug_infusion->GetRate().SetValue(new_rate, VolumePerTimeUnit::mL_Per_hr);
engine->ProcessAction(*m_bpdrug_infusion);
bpdrug_prev_rate = new_rate;
m_logger->info("currently "+substance+" infusing patient at rate a of "+to_string(int(new_rate))+" mL/hr");
}
}
else if (substance == "Saline") {
if (saline_prev_rate != new_rate && new_rate > 0) {
m_infusion->GetRate().SetValue(new_rate, VolumePerTimeUnit::mL_Per_hr);
engine->ProcessAction(*m_infusion);
saline_prev_rate = new_rate;
m_logger->info("currently "+substance+" infusing patient at rate a of "+to_string(int(new_rate))+" mL/hr");
}
}
}
void Action::clear() {
m_bpdrug = nullptr;
m_bpdrug_infusion = nullptr;
m_infusion = nullptr;
m_saline = nullptr;
}
Action::~Action() {
clear();
delete m_bpdrug;
delete m_bpdrug_infusion;
delete m_infusion;
delete m_saline;
}
#ifndef ACTION_H
#define ACTION_H
#include <iostream>
#include <string>
#include <map>
#include "CLA_Logger.h"
/* pulse stuff */
#include "PulsePhysiologyEngine.h"
#include "patient/actions/SESubstanceCompoundInfusion.h"
#include "patient/actions/SESubstanceInfusion.h"
#include "substance/SESubstanceManager.h"
#include "substance/SESubstanceCompound.h"
#include "properties/SEScalarMassPerVolume.h"
#include "substance/SESubstance.h"
#include "properties/SEScalarVolume.h"
#include "properties/SEScalarVolumePerTime.h"
using namespace std;
namespace CLA {
class Action {
private:
SESubstance* m_bpdrug;
SESubstanceInfusion* m_bpdrug_infusion;
SESubstanceCompoundInfusion* m_infusion;
SESubstanceCompound* m_saline;
double bpdrug_prev_rate; /* cache the last received rate */
double saline_prev_rate; /* cache the last received rate */
double NorepiConcentration;
double SalineBagVolume;
std::shared_ptr<CLA::LOGGER> m_logger;
public:
Action(std::shared_ptr<CLA::LOGGER>&);
~Action();
void infuse_drug(std::unique_ptr<PhysiologyEngine>&, const string&, double);
void initialize(std::unique_ptr<PhysiologyEngine>&, const string&);
void clear();
};
}
#endif
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