@@ -100,7 +100,7 @@ BurnThread::BurnThread(const std::string logFile, double tbsa)
100100 // Create the engine and load patient state
101101 m_bg = CreateBioGearsEngine (logFile);
102102 m_bg->GetLogger ()->Info (asprintf (" Initiating %f %s" , tbsa, " % TBSA burn wound" ));
103- if (!m_bg->LoadState (" ./states/StandardMale @0s.xml" )) {
103+ if (!m_bg->LoadState (" ./states/Bob @0s.xml" )) {
104104 m_bg->GetLogger ()->Error (" Could not load state, check the error" );
105105 return ;
106106 }
@@ -242,7 +242,7 @@ void BurnThread::AdvanceTimeFluidsAlbumin()
242242void BurnThread::Status ()
243243{
244244 m_mutex.lock ();
245- m_bg->GetLogger ()->Info (asprintf (" The patient suffered a burn wound %f %s" , m_bg->GetSimulationTime (TimeUnit::min), " min ago" ));
245+ /* m_bg->GetLogger()->Info(asprintf("The patient suffered a burn wound %f %s", m_bg->GetSimulationTime(TimeUnit::min), " min ago"));
246246 m_bg->GetLogger()->Info(asprintf("Tidal Volume : %f %s", m_bg->GetRespiratorySystem()->GetTidalVolume(VolumeUnit::mL), "mL"));
247247 m_bg->GetLogger()->Info(asprintf("Systolic Pressure : %f %s", m_bg->GetCardiovascularSystem()->GetSystolicArterialPressure(PressureUnit::mmHg), "mmHg"));
248248 m_bg->GetLogger()->Info(asprintf("Diastolic Pressure : %f %s", m_bg->GetCardiovascularSystem()->GetDiastolicArterialPressure(PressureUnit::mmHg), "mmHg"));
@@ -254,7 +254,7 @@ void BurnThread::Status()
254254 m_bg->GetLogger()->Info(asprintf("Mean Urine Output : %f %s", m_bg->GetRenalSystem()->GetMeanUrineOutput(VolumePerTimeUnit::mL_Per_hr), "mL_Per_hr"));
255255 if (m_ringers->HasBagVolume()) {
256256 m_bg->GetLogger()->Info(asprintf("Remaining LR Volume : %f %s", m_ivBagVolume_mL, "mL"));
257- }
257+ }*/
258258
259259 std::cout << std::endl;
260260 m_mutex.unlock ();
@@ -269,7 +269,7 @@ void BurnThread::FluidLoading(double tbsa)
269269 // double tbsa = tbsa;
270270 double urineProduction = 0.0 ;
271271 int checkTime_s = 3600 ;
272- int stateTime_s = 900 ; // 15 mins
272+ int stateTime_s = 3600 ; // 60 mins
273273 double ringersVolume_mL = 500.0 ;
274274 double volume = 0.0 ;
275275 double titrate = 0.25 ; // how much to adjust each hour
@@ -282,9 +282,12 @@ void BurnThread::FluidLoading(double tbsa)
282282 double targetLowUrineProduction_mL_Per_Hr = 0.5 * weight_kg;
283283 double targetHighUrineProduction_mL_Per_Hr = 0.75 * weight_kg; // average of around 50ml/hr
284284 double DayLimit_mL = 4.0 * weight_kg * tbsa;
285- double initialInfustion_mL_Per_hr = tbsa * 10.0 ; // Should start at 10*tbsa // (DayLimit_mL / 0.5) / 8.0; //half of the fluid should be loaded in the first 8 hours;
286- double DayLimit_Hr = DayLimit_mL / 24.0 ;
285+ double initialInfustion_mL_Per_hr = 0.0 ; // tbsa * 10.0; // Should start at 10*tbsa // (DayLimit_mL / 0.5) / 8.0; //half of the fluid should be loaded in the first 8 hours;
286+ double hrsBeforeIntervention = 1.0 ;
287+ double DayLimit_Hr = DayLimit_mL / 25.0 ;
287288 double temp = 0.0 ;
289+ bool saveState = true ;
290+ bool fluidOn = true ;
288291
289292 // set fluid infusion rate, using ringers lactate:
290293 if (fluid == ringers) {
@@ -297,13 +300,13 @@ void BurnThread::FluidLoading(double tbsa)
297300
298301 while (m_runThread) {
299302 // Generate State Every X amount of time
300- if (((int )m_bg->GetSimulationTime (TimeUnit::s) + 1 ) % stateTime_s == 0 ) {
303+ if (((int )m_bg->GetSimulationTime (TimeUnit::s) + 1 ) % stateTime_s == 0 && saveState == true ) {
301304 int intTBSA = (int )tbsa;
302305 std::string stringTBSA = std::to_string (intTBSA);
303- std::string fname = " ./states/ BurnWoundStates/" ;
306+ std::string fname = " ./BurnWoundStates/" ;
304307 fname.append (stringTBSA);
305308 fname.append (" Burn@" );
306- int simTime_min = (((int )m_bg->GetSimulationTime (TimeUnit::s) + 1 ) / stateTime_s) * 15 ;
309+ int simTime_min = (((int )m_bg->GetSimulationTime (TimeUnit::s) + 1 ) / stateTime_s) * 60 ;
307310 fname.append (std::to_string (simTime_min));
308311 fname.append (" min_" );
309312 int ringersRate_mL_Per_hr = 0 ;
@@ -323,21 +326,28 @@ void BurnThread::FluidLoading(double tbsa)
323326 // check urine every hour, reset the volume while we are at it
324327 if (((int )m_bg->GetSimulationTime (TimeUnit::s) + 1 ) % checkTime_s == 0 ) {
325328 Status ();
326- m_bg->GetLogger ()->Info (asprintf (" Checking urine production %f %s" , m_bg->GetRenalSystem ()->GetMeanUrineOutput (VolumePerTimeUnit::mL_Per_hr ), " mL_Per_hr" ));
329+ // m_bg->GetLogger()->Info(asprintf("Checking urine production %f %s", m_bg->GetRenalSystem()->GetMeanUrineOutput(VolumePerTimeUnit::mL_Per_hr), "mL_Per_hr"));
327330 urineProduction = m_bg->GetRenalSystem ()->GetMeanUrineOutput (VolumePerTimeUnit::mL_Per_hr );
328- if (fluid == ringers) {
329- if (urineProduction < targetLowUrineProduction_mL_Per_Hr) {
330- m_bg->GetLogger ()->Info (asprintf (" Urine production is too low at %f %s" , urineProduction, " mL_Per_hr" ));
331- m_ringers->GetRate ().SetValue ((m_ringers->GetRate ().GetValue (VolumePerTimeUnit::mL_Per_hr )) * (1 + titrate), VolumePerTimeUnit::mL_Per_hr );
332- m_bg->ProcessAction (*m_ringers);
333- }
334- if ((m_bg->GetRenalSystem ()->GetMeanUrineOutput (VolumePerTimeUnit::mL_Per_hr ) > targetHighUrineProduction_mL_Per_Hr)) {
335- m_bg->GetLogger ()->Info (asprintf (" Urine production is too high at %f %s" , urineProduction, " mL_Per_hr" ));
336- m_ringers->GetRate ().SetValue ((m_ringers->GetRate ().GetValue (VolumePerTimeUnit::mL_Per_hr )) * (1 - titrate), VolumePerTimeUnit::mL_Per_hr );
331+ if (fluid == ringers && fluidOn == true ) {
332+ if (((int )m_bg->GetSimulationTime (TimeUnit::s) + 1 ) == ((int )hrsBeforeIntervention*3600 )) {
333+ double beginningInfusion_mL_Per_hr = 10.0 * tbsa;
334+ m_bg->GetLogger ()->Info (asprintf (" Beginning Intervention with infusion at %f %s" , beginningInfusion_mL_Per_hr, " mL_Per_hr" ));
335+ m_ringers->GetRate ().SetValue (beginningInfusion_mL_Per_hr, VolumePerTimeUnit::mL_Per_hr );
337336 m_bg->ProcessAction (*m_ringers);
337+ } else {
338+ if (urineProduction < targetLowUrineProduction_mL_Per_Hr) {
339+ m_bg->GetLogger ()->Info (asprintf (" Urine production is too low at %f %s" , urineProduction, " mL_Per_hr" ));
340+ m_ringers->GetRate ().SetValue ((m_ringers->GetRate ().GetValue (VolumePerTimeUnit::mL_Per_hr )) * (1 + titrate), VolumePerTimeUnit::mL_Per_hr );
341+ m_bg->ProcessAction (*m_ringers);
342+ }
343+ if ((m_bg->GetRenalSystem ()->GetMeanUrineOutput (VolumePerTimeUnit::mL_Per_hr ) > targetHighUrineProduction_mL_Per_Hr)) {
344+ m_bg->GetLogger ()->Info (asprintf (" Urine production is too high at %f %s" , urineProduction, " mL_Per_hr" ));
345+ m_ringers->GetRate ().SetValue ((m_ringers->GetRate ().GetValue (VolumePerTimeUnit::mL_Per_hr )) * (1 - titrate), VolumePerTimeUnit::mL_Per_hr );
346+ m_bg->ProcessAction (*m_ringers);
347+ }
338348 }
339349 }
340- if (fluid == albumin) {
350+ if (fluid == albumin && fluidOn == true ) {
341351 if (urineProduction < targetLowUrineProduction_mL_Per_Hr) {
342352 m_bg->GetLogger ()->Info (asprintf (" Urine production is too low at %f %s" , urineProduction, " mL_Per_hr" ));
343353 m_albumex->GetRate ().SetValue ((m_albumex->GetRate ().GetValue (VolumePerTimeUnit::mL_Per_hr )) * (1 + titrate), VolumePerTimeUnit::mL_Per_hr );
@@ -351,7 +361,7 @@ void BurnThread::FluidLoading(double tbsa)
351361 }
352362 }
353363 // escharotomy
354- if (m_bg->GetPatient ().IsEventActive (CDM::enumPatientEvent::CompartmentSyndrome_Abdominal)
364+ /* if (m_bg->GetPatient().IsEventActive(CDM::enumPatientEvent::CompartmentSyndrome_Abdominal)
355365 || m_bg->GetPatient().IsEventActive(CDM::enumPatientEvent::CompartmentSyndrome_LeftArm)
356366 || m_bg->GetPatient().IsEventActive(CDM::enumPatientEvent::CompartmentSyndrome_LeftLeg)
357367 || m_bg->GetPatient().IsEventActive(CDM::enumPatientEvent::CompartmentSyndrome_RightArm)
@@ -370,7 +380,7 @@ void BurnThread::FluidLoading(double tbsa)
370380 return;
371381 }
372382 m_bg->ProcessAction(*m_escharotomy);
373- }
383+ }*/
374384 if (fluid == ringers) {
375385 if (m_ivBagVolume_mL < 1.0 ) {
376386 m_ringers->GetBagVolume ().SetValue (ringersVolume_mL, VolumeUnit::mL );
@@ -401,6 +411,7 @@ void BurnThread::FluidLoading(double tbsa)
401411 // exit checks:
402412 if (m_bg->GetPatient ().IsEventActive (CDM::enumPatientEvent::IrreversibleState)) {
403413 // m_bg->GetLogger()->Info(std::stringstream() << "oh no!");
414+ m_bg->GetLogger ()->Info (" ///////////////////////////////////////////////////////////////" );
404415 m_runThread = false ;
405416 }
406417
0 commit comments