Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ project("AMM_Physiology_Manager")
set(VERSION_TYPE "beta" CACHE STRING "version type" FORCE)
set(PROJECT_VERSION_MAJOR 1)
set(PROJECT_VERSION_MINOR 2)
set(PROJECT_VERSION_PATCH 1)
set(PROJECT_VERSION_PATCH 3)
site_name(VERSION_HOST) # read hostname to VERSION_HOST
set(VERSION_HOST "${VERSION_HOST}" CACHE STRING "host of build" FORCE)

Expand Down
29 changes: 28 additions & 1 deletion src/AMM/BiogearsThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ class EventHandler : public SEEventHandler {
bool paralyzedSent = false;
bool irreversible = false;
bool irreversibleSent = false;
bool tachypnea = false;
bool tachypneaSent = false;
bool tachycardia = false;
bool tachycardiaSent = false;
bool startOfExhale = false;
bool startOfInhale = false;
bool pneumothoraxLClosed = false;
Expand Down Expand Up @@ -49,9 +53,17 @@ class EventHandler : public SEEventHandler {
if (active) {
switch (type) {
case CDM::enumPatientEvent::IrreversibleState:
LOG_INFO << " Patient has entered irreversible state";
LOG_INFO << " Patient has entered irreversible state.";
irreversible = true;
break;
case CDM::enumPatientEvent::Tachypnea:
LOG_INFO << " Patient has entered state: Tachypnea.";
tachypnea = true;
break;
case CDM::enumPatientEvent::Tachycardia:
LOG_INFO << " Patient has entered state: Tachycardia.";
tachycardia = true;
break;
case CDM::enumPatientEvent::StartOfCardiacCycle:
break;
case CDM::enumPatientEvent::StartOfExhale:
Expand Down Expand Up @@ -607,6 +619,8 @@ void BiogearsThread::AdvanceTimeTick()
irreversible = true;
}

tachypnea = myEventHandler->tachypnea;
tachycardia = myEventHandler->tachycardia;
startOfInhale = myEventHandler->startOfInhale;
startOfExhale = myEventHandler->startOfExhale;
}
Expand Down Expand Up @@ -1709,6 +1723,19 @@ void BiogearsThread::SetHemorrhage(const std::string& location, double flow)
}
}

void BiogearsThread::SetNasalCannula(double flowRate, const std::string& unit)
{
try {
biogears::SENasalCannula nasalcannula;
if (unit == "L/min") {
nasalcannula.GetFlowRate().SetValue(flowRate, biogears::VolumePerTimeUnit::L_Per_min);
m_pe->ProcessAction(nasalcannula);
}
} catch (std::exception& e) {
LOG_ERROR << "Error processing nasal cannula action: " << e.what();
}
}

void BiogearsThread::SetNeedleDecompression(const std::string& state, const std::string& side)
{
try {
Expand Down
7 changes: 7 additions & 0 deletions src/AMM/BiogearsThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#include <biogears/cdm/patient/actions/SEPainStimulus.h>
#include <biogears/cdm/patient/actions/SEPupillaryResponse.h>
#include <biogears/cdm/patient/actions/SESubstanceBolus.h>
#include <biogears/cdm/patient/actions/SENasalCannula.h>

#include <biogears/cdm/substance/SESubstanceManager.h>
#include <biogears/cdm/system/physiology/SEBloodChemistrySystem.h>
Expand Down Expand Up @@ -217,6 +218,8 @@ class BiogearsThread {

void SetMechanicalVentilation(const std::string& actionSettings);

void SetNasalCannula(double flowRate, const std::string& unit);

void SetNeedleDecompression(const std::string& state, const std::string& side);

void SetPain(const std::string& location, double severity);
Expand Down Expand Up @@ -270,6 +273,10 @@ class BiogearsThread {
bool paralyzedSent = false;
bool irreversible = false;
bool irreversibleSent = false;
bool tachypnea = false;
bool tachypneaSent = false;
bool tachycardia = false;
bool tachycardiaSent = false;
bool startOfExhale = false;
bool startOfInhale = false;
bool pneumothoraxLClosed = false;
Expand Down
54 changes: 52 additions & 2 deletions src/AMM/PhysiologyEngineManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,18 @@ void PhysiologyEngineManager::
} else if (pmType == "infection") {
} else if (pmType == "intubation") {
} else if (pmType == "mechanicalventilation") {
} else if (pmType == "nasalcannula") {
tinyxml2::XMLElement* pRate = pRoot->FirstChildElement("Rate")->ToElement();
double rate;
if (pRate->Attribute("value") != NULL) {
rate = stod(pRate->Attribute("value"));
} else {
rate = stod(pRate->GetText());
}
std::string pUnit = pRate->Attribute("unit");

m_pe->SetNasalCannula(rate, pUnit);
return;
} else if (pmType == "needledecompression") {
std::string pState = pRoot->FirstChildElement("State")->ToElement()->GetText();
std::string pSide = pRoot->FirstChildElement("Side")->ToElement()->GetText();
Expand Down Expand Up @@ -466,6 +478,32 @@ void PhysiologyEngineManager::StartSimulation() { m_pe->StartSimulation(); }

void PhysiologyEngineManager::StopSimulation() { m_pe->StopSimulation(); }

/**
* @brief send patient states rendermod
*
*/

void PhysiologyEngineManager::SendPatientStateRendMod(std::string rendModType)
{
AMM::UUID erID;
erID.id(m_mgr->GenerateUuidString());
FMA_Location fma;
AMM::UUID agentID;

AMM::EventRecord er;
er.id(erID);
er.location(fma);
er.agent_id(agentID);
er.type(rendModType);
m_mgr->WriteEventRecord(er);

AMM::RenderModification renderMod;
renderMod.event_id(erID);
renderMod.type(rendModType);
renderMod.data("<RenderModification type='" + rendModType + "'/>");
m_mgr->WriteRenderModification(renderMod);
}

/**
* @brief processes patient states in biogears (defined by the biogears physiology)
*
Expand Down Expand Up @@ -511,8 +549,20 @@ void PhysiologyEngineManager::ProcessStates()
m_pe->irreversibleSent = true;
}

if (m_pe->tachypnea && !m_pe->tachypneaSent) {
LOG_DEBUG << "Patient has entered state Tachypnea, sending render mod.";
SendPatientStateRendMod("PATIENT_STATE_TACHYPNEA");
m_pe->tachypneaSent = true;
}

if (m_pe->tachycardia && !m_pe->tachycardiaSent) {
LOG_DEBUG << "Patient has entered state Tachycardia, sending render mod.";
SendPatientStateRendMod("PATIENT_STATE_TACHYCARDIA");
m_pe->tachycardiaSent = true;
}

if (m_pe->paralyzed && !m_pe->paralyzedSent) {
LOG_DEBUG << "Patient is paralyzed but we haven't sent the render mod.";
LOG_DEBUG << "Patient is paralyzed, sending render mod.";
AMM::UUID erID;
erID.id(m_mgr->GenerateUuidString());
FMA_Location fma;
Expand Down Expand Up @@ -569,7 +619,7 @@ void PhysiologyEngineManager::ProcessStates()
er.id(erID);
er.location(fma);
er.agent_id(agentID);
er.type("PATIENT_STATE_IRREVERSIBLE");
er.type("PNEUMOTHORAX_OPEN_L_SEVERE");
m_mgr->WriteEventRecord(er);

AMM::RenderModification renderMod;
Expand Down
2 changes: 2 additions & 0 deletions src/AMM/PhysiologyEngineManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ namespace AMM {

void InitializeBiogears();

void SendPatientStateRendMod(std::string rendModType);

void ProcessStates();

bool paused = false;
Expand Down