Skip to content

Commit

Permalink
Cleanup #2
Browse files Browse the repository at this point in the history
  • Loading branch information
MilosKozak committed Jun 17, 2022
1 parent 2d6de19 commit 8f36b4a
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions app/src/main/assets/OpenAPSSMBDynamicISF/determine-basal.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,13 +270,15 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
//console.log("Initial insulin value for ISF: "+ins_val+"; ");
//console.log("Current value for insulin: "+insulin+"; ");

var ins_val = 75; // Lyumjev peak: 75
if (profile.insulinPeak > 65) { // lyumjev peak: 45
ins_val = 55;
} else if (profile.insulinPeak > 50 ){ // ultra rapid peak: 55
ins_val = 65;
}
console.log("For "+profile.insulinType+" (insulin peak: "+profile.insulinPeak+") divisor is: "+ins_val+"; ");
var ins_val;
if (profile.insulinPeak > 65) { // lyumjev peak: 45
ins_val = 55;
} else if (profile.insulinPeak > 50 ){ // ultra rapid peak: 55
ins_val = 65;
} else {
ins_val = 75; // rapid peak: 75
}
console.log("For "+profile.insulinType+" (insulin peak: "+profile.insulinPeak+") divisor is: "+ins_val+"; ");

console.log("Insulin value for ISF based on profile: "+ins_val+"; ");

Expand Down Expand Up @@ -824,25 +826,25 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_

if (bg > target_bg && glucose_status.delta < 3 && glucose_status.delta > -3 && glucose_status.short_avgdelta > -3 && glucose_status.short_avgdelta < 3 && eventualBG > target_bg && eventualBG < bg ) {
var future_sens = ( 1800 / (Math.log((((eventualBG * 0.5) + (bg * 0.5))/ins_val)+1)*TDD));
var future_sens_old = ( 277700 / (TDD * ((bg * 0.5) + (eventualBG * 0.5 ))));
console.log("Future state sensitivity is " +future_sens+" based on eventual and current bg due to flat glucose level above target");
rT.reason += "Dosing sensitivity: " +future_sens+" using eventual BG;";
//var future_sens_old = ( 277700 / (TDD * ((bg * 0.5) + (eventualBG * 0.5 ))));
console.log("Future state sensitivity is " +future_sens+" based on eventual and current bg due to flat glucose level above target");
rT.reason += "Dosing sensitivity: " +future_sens+" using eventual BG;";
}

else if( glucose_status.delta > 0 && eventualBG > target_bg ) {
var future_sens = ( 1800 / (Math.log((bg/ins_val)+1)*TDD));
var future_sens_old = ( 277700 / (TDD * bg));
//var future_sens_old = ( 277700 / (TDD * bg));
console.log("Future state sensitivity is " +future_sens+" using current bg due to small delta or variation");
rT.reason += "Dosing sensitivity: " +future_sens+" using current BG;";
}

else {
var future_sens = ( 1800 / (Math.log((eventualBG/ins_val)+1)*TDD));
var future_sens_old = ( 277700 / (TDD * eventualBG));
console.log("Future state sensitivity is " +future_sens+" based on eventual bg due to -ve delta");
rT.reason += "Dosing sensitivity: " +future_sens+" using eventual BG;";
var future_sens = ( 1800 / (Math.log((eventualBG/ins_val)+1)*TDD));
//var future_sens_old = ( 277700 / (TDD * eventualBG));
console.log("Future state sensitivity is " +future_sens+" based on eventual bg due to -ve delta");
rT.reason += "Dosing sensitivity: " +future_sens+" using eventual BG;";
}
var future_sens = round(future_sens,1);
future_sens = round(future_sens,1);



Expand Down

0 comments on commit 8f36b4a

Please sign in to comment.