HowTo-CreateAPatient.cpp 2.9 KB
Newer Older
Aaron Bray's avatar
Aaron Bray committed
1 2
/* Distributed under the Apache License, Version 2.0.
   See accompanying NOTICE file for details.*/
Aaron Bray's avatar
Aaron Bray committed
3

4
#include "EngineHowTo.h"
Aaron Bray's avatar
Aaron Bray committed
5 6 7 8 9 10 11 12 13 14 15

// Include the various types you will be using in your code
#include "patient/SEPatient.h"
#include "patient/assessments/SEPulmonaryFunctionTest.h"
#include "compartment/SECompartmentManager.h"
#include "system/physiology/SEBloodChemistrySystem.h"
#include "system/physiology/SECardiovascularSystem.h"
#include "system/physiology/SEEnergySystem.h"
#include "system/physiology/SERespiratorySystem.h"
#include "substance/SESubstanceManager.h"
#include "substance/SESubstance.h"
16
#include "engine/SEEngineTracker.h"
17
#include "engine/SEPatientConfiguration.h"
18
#include "properties/SEScalar0To1.h"
Aaron Bray's avatar
Aaron Bray committed
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
#include "properties/SEScalarFrequency.h"
#include "properties/SEScalarMassPerVolume.h"
#include "properties/SEScalarPressure.h"
#include "properties/SEScalarTemperature.h"
#include "properties/SEScalarTime.h"
#include "properties/SEScalarVolume.h"
#include "properties/SEScalarVolumePerTime.h"
#include "properties/SEFunctionVolumeVsTime.h"
#include "properties/SEScalarMass.h"
#include "properties/SEScalarLength.h"

//--------------------------------------------------------------------------------------------------
/// \brief
/// Creating a patient
///
/// \details
35
/// Creating a customized patient in Pulse
Aaron Bray's avatar
Aaron Bray committed
36 37 38
//--------------------------------------------------------------------------------------------------
void HowToCreateAPatient()
{
39 40
  std::unique_ptr<PhysiologyEngine> pe = CreatePulseEngine();
  pe->GetLogger()->SetLogFile("./test_results/HowTo_CreateAPatient.log");
Aaron Bray's avatar
Aaron Bray committed
41
  pe->GetLogger()->Info("HowTo_CreateAPatient");
Aaron Bray's avatar
Aaron Bray committed
42

43
  SEPatientConfiguration pc;
44
  SEPatient& patient = pc.GetPatient();
Aaron Bray's avatar
Aaron Bray committed
45 46 47 48
  patient.SetName("HowToCreateAPatient");
  //Patient sex is the only thing that is absolutely required to be set.
  //All value not explicitly set based or standard values or calculations.
  //If you do something out of bounds or set something you're not allowed to, it will alert you with a warning/error.
49
  patient.SetSex(ePatient_Sex::Male);
Aaron Bray's avatar
Aaron Bray committed
50 51 52 53 54 55 56 57 58 59
  patient.GetAge().SetValue(44, TimeUnit::yr);
  patient.GetWeight().SetValue(170, MassUnit::lb);
  patient.GetHeight().SetValue(71, LengthUnit::in);
  patient.GetBodyFatFraction().SetValue(0.21);
  patient.GetDiastolicArterialPressureBaseline().SetValue(74, PressureUnit::mmHg);
  patient.GetHeartRateBaseline().SetValue(72, FrequencyUnit::Per_min);
  patient.GetRespirationRateBaseline().SetValue(16, FrequencyUnit::Per_min);
  patient.GetSystolicArterialPressureBaseline().SetValue(114, PressureUnit::mmHg);

  // You can save off the patient if you want to use it later
60
  patient.SerializeToFile("./patients/HowToCreateAPatient.json");
Aaron Bray's avatar
Aaron Bray committed
61

62 63

  if (!pe->InitializeEngine(pc))
Aaron Bray's avatar
Aaron Bray committed
64
  {
65
    pe->GetLogger()->Error("Could not load state, check the error");
Aaron Bray's avatar
Aaron Bray committed
66 67 68 69
    return;
  }

  // You can save off the initial patient state if you want to use it later
70
  pe->SerializeToFile("./states/HowToCreateAPatient@0s.json");
Aaron Bray's avatar
Aaron Bray committed
71
}