fix: rounding cob basal in SMB AMA
This commit is contained in:
parent
479bfc4103
commit
ca0478572a
|
@ -69,10 +69,10 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
|
||||||
if (bg < 39) { //Dexcom is in ??? mode or calibrating
|
if (bg < 39) { //Dexcom is in ??? mode or calibrating
|
||||||
rT.reason = "CGM is calibrating or in ??? state";
|
rT.reason = "CGM is calibrating or in ??? state";
|
||||||
if (basal <= currenttemp.rate * 1.2) { // high temp is running
|
if (basal <= currenttemp.rate * 1.2) { // high temp is running
|
||||||
rT.reason += "; setting current basal of " + basal + " as temp";
|
rT.reason += "; setting current basal of " + round(basal, 2) + " as temp";
|
||||||
return tempBasalFunctions.setTempBasal(basal, 30, profile, rT, currenttemp);
|
return tempBasalFunctions.setTempBasal(basal, 30, profile, rT, currenttemp);
|
||||||
} else { //do nothing.
|
} else { //do nothing.
|
||||||
rT.reason += ", temp " + currenttemp.rate + " <~ current basal " + basal + "U/hr";
|
rT.reason += ", temp " + currenttemp.rate + " <~ current basal " + round(basal, 2) + "U/hr";
|
||||||
return rT;
|
return rT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -291,7 +291,7 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
|
||||||
|
|
||||||
rT.COB=meal_data.mealCOB;
|
rT.COB=meal_data.mealCOB;
|
||||||
rT.IOB=iob_data.iob;
|
rT.IOB=iob_data.iob;
|
||||||
rT.reason="COB: " + meal_data.mealCOB + ", Dev: " + deviation + ", BGI: " + bgi + ", ISF: " + convert_bg(sens, profile) + ", Target: " + convert_bg(target_bg, profile) + "; ";
|
rT.reason="COB: " + round(meal_data.mealCOB, 1) + ", Dev: " + deviation + ", BGI: " + bgi + ", ISF: " + convert_bg(sens, profile) + ", Target: " + convert_bg(target_bg, profile) + "; ";
|
||||||
if (typeof autosens_data !== 'undefined' && profile.autosens_adjust_targets && autosens_data.ratio != 1)
|
if (typeof autosens_data !== 'undefined' && profile.autosens_adjust_targets && autosens_data.ratio != 1)
|
||||||
rT.reason += "Autosens: " + autosens_data.ratio + "; ";
|
rT.reason += "Autosens: " + autosens_data.ratio + "; ";
|
||||||
if (bg < threshold) { // low glucose suspend mode: BG is < ~80
|
if (bg < threshold) { // low glucose suspend mode: BG is < ~80
|
||||||
|
@ -306,10 +306,10 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
|
||||||
rT.reason += ", min delta " + minDelta.toFixed(2) + ">0";
|
rT.reason += ", min delta " + minDelta.toFixed(2) + ">0";
|
||||||
}
|
}
|
||||||
if (currenttemp.duration > 15 && (round_basal(basal, profile) === round_basal(currenttemp.rate, profile))) {
|
if (currenttemp.duration > 15 && (round_basal(basal, profile) === round_basal(currenttemp.rate, profile))) {
|
||||||
rT.reason += ", temp " + currenttemp.rate + " ~ req " + basal + "U/hr";
|
rT.reason += ", temp " + currenttemp.rate + " ~ req " + round(basal, 2) + "U/hr";
|
||||||
return rT;
|
return rT;
|
||||||
} else {
|
} else {
|
||||||
rT.reason += "; setting current basal of " + basal + " as temp";
|
rT.reason += "; setting current basal of " + round(basal, 2) + " as temp";
|
||||||
return tempBasalFunctions.setTempBasal(basal, 30, profile, rT, currenttemp);
|
return tempBasalFunctions.setTempBasal(basal, 30, profile, rT, currenttemp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -327,7 +327,7 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
|
||||||
rT.reason += ", temp " + currenttemp.rate + " ~ req " + basal + "U/hr";
|
rT.reason += ", temp " + currenttemp.rate + " ~ req " + basal + "U/hr";
|
||||||
return rT;
|
return rT;
|
||||||
} else {
|
} else {
|
||||||
rT.reason += "; setting current basal of " + basal + " as temp";
|
rT.reason += "; setting current basal of " + round(basal, 2) + " as temp";
|
||||||
return tempBasalFunctions.setTempBasal(basal, 30, profile, rT, currenttemp);
|
return tempBasalFunctions.setTempBasal(basal, 30, profile, rT, currenttemp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -338,10 +338,10 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
|
||||||
rT.reason += ", bolus snooze: eventual BG range " + convert_bg(eventualBG, profile) + "-" + convert_bg(snoozeBG, profile);
|
rT.reason += ", bolus snooze: eventual BG range " + convert_bg(eventualBG, profile) + "-" + convert_bg(snoozeBG, profile);
|
||||||
//console.error(currenttemp, basal );
|
//console.error(currenttemp, basal );
|
||||||
if (currenttemp.duration > 15 && (round_basal(basal, profile) === round_basal(currenttemp.rate, profile))) {
|
if (currenttemp.duration > 15 && (round_basal(basal, profile) === round_basal(currenttemp.rate, profile))) {
|
||||||
rT.reason += ", temp " + currenttemp.rate + " ~ req " + basal + "U/hr";
|
rT.reason += ", temp " + currenttemp.rate + " ~ req " + round(basal, 2) + "U/hr";
|
||||||
return rT;
|
return rT;
|
||||||
} else {
|
} else {
|
||||||
rT.reason += "; setting current basal of " + basal + " as temp";
|
rT.reason += "; setting current basal of " + round(basal, 2) + " as temp";
|
||||||
return tempBasalFunctions.setTempBasal(basal, 30, profile, rT, currenttemp);
|
return tempBasalFunctions.setTempBasal(basal, 30, profile, rT, currenttemp);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -363,7 +363,7 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
|
||||||
// if required temp < existing temp basal
|
// if required temp < existing temp basal
|
||||||
var insulinScheduled = currenttemp.duration * (currenttemp.rate - basal) / 60;
|
var insulinScheduled = currenttemp.duration * (currenttemp.rate - basal) / 60;
|
||||||
if (insulinScheduled < insulinReq - basal*0.3) { // if current temp would deliver a lot (30% of basal) less than the required insulin, raise the rate
|
if (insulinScheduled < insulinReq - basal*0.3) { // if current temp would deliver a lot (30% of basal) less than the required insulin, raise the rate
|
||||||
rT.reason += ", "+currenttemp.duration + "m@" + (currenttemp.rate - basal).toFixed(3) + " = " + insulinScheduled.toFixed(3) + " < req " + insulinReq + "-" + basal*0.3;
|
rT.reason += ", "+currenttemp.duration + "m@" + (currenttemp.rate - basal).toFixed(3) + " = " + insulinScheduled.toFixed(3) + " < req " + insulinReq + "-" + (basal*0.3).toFixed(2);
|
||||||
return tempBasalFunctions.setTempBasal(rate, 30, profile, rT, currenttemp);
|
return tempBasalFunctions.setTempBasal(rate, 30, profile, rT, currenttemp);
|
||||||
}
|
}
|
||||||
if (typeof currenttemp.rate !== 'undefined' && (currenttemp.duration > 5 && rate >= currenttemp.rate * 0.8)) {
|
if (typeof currenttemp.rate !== 'undefined' && (currenttemp.duration > 5 && rate >= currenttemp.rate * 0.8)) {
|
||||||
|
@ -405,10 +405,10 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
|
||||||
rT.reason += "Eventual BG " + convert_bg(eventualBG, profile) + " > " + convert_bg(min_bg, profile) + " but Min. Delta " + minDelta.toFixed(2) + " < Exp. Delta " + expectedDelta;
|
rT.reason += "Eventual BG " + convert_bg(eventualBG, profile) + " > " + convert_bg(min_bg, profile) + " but Min. Delta " + minDelta.toFixed(2) + " < Exp. Delta " + expectedDelta;
|
||||||
}
|
}
|
||||||
if (currenttemp.duration > 15 && (round_basal(basal, profile) === round_basal(currenttemp.rate, profile))) {
|
if (currenttemp.duration > 15 && (round_basal(basal, profile) === round_basal(currenttemp.rate, profile))) {
|
||||||
rT.reason += ", temp " + currenttemp.rate + " ~ req " + basal + "U/hr";
|
rT.reason += ", temp " + currenttemp.rate + " ~ req " + round(basal, 2) + "U/hr";
|
||||||
return rT;
|
return rT;
|
||||||
} else {
|
} else {
|
||||||
rT.reason += "; setting current basal of " + basal + " as temp";
|
rT.reason += "; setting current basal of " + round(basal, 2) + " as temp";
|
||||||
return tempBasalFunctions.setTempBasal(basal, 30, profile, rT, currenttemp);
|
return tempBasalFunctions.setTempBasal(basal, 30, profile, rT, currenttemp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -422,10 +422,10 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
|
||||||
|
|
||||||
rT.reason += convert_bg(eventualBG, profile)+"-"+convert_bg(snoozeBG, profile)+" in range: no temp required";
|
rT.reason += convert_bg(eventualBG, profile)+"-"+convert_bg(snoozeBG, profile)+" in range: no temp required";
|
||||||
if (currenttemp.duration > 15 && (round_basal(basal, profile) === round_basal(currenttemp.rate, profile))) {
|
if (currenttemp.duration > 15 && (round_basal(basal, profile) === round_basal(currenttemp.rate, profile))) {
|
||||||
rT.reason += ", temp " + currenttemp.rate + " ~ req " + basal + "U/hr";
|
rT.reason += ", temp " + currenttemp.rate + " ~ req " + round(basal, 2) + "U/hr";
|
||||||
return rT;
|
return rT;
|
||||||
} else {
|
} else {
|
||||||
rT.reason += "; setting current basal of " + basal + " as temp";
|
rT.reason += "; setting current basal of " + round(basal, 2) + " as temp";
|
||||||
return tempBasalFunctions.setTempBasal(basal, 30, profile, rT, currenttemp);
|
return tempBasalFunctions.setTempBasal(basal, 30, profile, rT, currenttemp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -439,10 +439,10 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
|
||||||
if (basaliob > max_iob) {
|
if (basaliob > max_iob) {
|
||||||
rT.reason += "basaliob " + round(basaliob,2) + " > max_iob " + max_iob;
|
rT.reason += "basaliob " + round(basaliob,2) + " > max_iob " + max_iob;
|
||||||
if (currenttemp.duration > 15 && (round_basal(basal, profile) === round_basal(currenttemp.rate, profile))) {
|
if (currenttemp.duration > 15 && (round_basal(basal, profile) === round_basal(currenttemp.rate, profile))) {
|
||||||
rT.reason += ", temp " + currenttemp.rate + " ~ req " + basal + "U/hr";
|
rT.reason += ", temp " + currenttemp.rate + " ~ req " + round(basal, 2) + "U/hr";
|
||||||
return rT;
|
return rT;
|
||||||
} else {
|
} else {
|
||||||
rT.reason += "; setting current basal of " + basal + " as temp";
|
rT.reason += "; setting current basal of " + round(basal, 2) + " as temp";
|
||||||
return tempBasalFunctions.setTempBasal(basal, 30, profile, rT, currenttemp);
|
return tempBasalFunctions.setTempBasal(basal, 30, profile, rT, currenttemp);
|
||||||
}
|
}
|
||||||
} else { // otherwise, calculate 30m high-temp required to get projected BG down to target
|
} else { // otherwise, calculate 30m high-temp required to get projected BG down to target
|
||||||
|
|
|
@ -169,7 +169,7 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
|
||||||
return rT;
|
return rT;
|
||||||
//return tempBasalFunctions.setTempBasal(0, 30, profile, rT, currenttemp);
|
//return tempBasalFunctions.setTempBasal(0, 30, profile, rT, currenttemp);
|
||||||
} else { //do nothing.
|
} else { //do nothing.
|
||||||
rT.reason += ". Temp " + currenttemp.rate + " <= current basal " + basal + "U/hr; doing nothing. ";
|
rT.reason += ". Temp " + currenttemp.rate + " <= current basal " + round(basal, 2) + "U/hr; doing nothing. ";
|
||||||
return rT;
|
return rT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -920,10 +920,10 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
|
||||||
rT.reason += ", but Min. Delta " + minDelta.toFixed(2) + " > Exp. Delta " + convert_bg(expectedDelta, profile);
|
rT.reason += ", but Min. Delta " + minDelta.toFixed(2) + " > Exp. Delta " + convert_bg(expectedDelta, profile);
|
||||||
}
|
}
|
||||||
if (currenttemp.duration > 15 && (round_basal(basal, profile) === round_basal(currenttemp.rate, profile))) {
|
if (currenttemp.duration > 15 && (round_basal(basal, profile) === round_basal(currenttemp.rate, profile))) {
|
||||||
rT.reason += ", temp " + currenttemp.rate + " ~ req " + basal + "U/hr. ";
|
rT.reason += ", temp " + currenttemp.rate + " ~ req " + round(basal, 2) + "U/hr. ";
|
||||||
return rT;
|
return rT;
|
||||||
} else {
|
} else {
|
||||||
rT.reason += "; setting current basal of " + basal + " as temp. ";
|
rT.reason += "; setting current basal of " + round(basal, 2) + " as temp. ";
|
||||||
return tempBasalFunctions.setTempBasal(basal, 30, profile, rT, currenttemp);
|
return tempBasalFunctions.setTempBasal(basal, 30, profile, rT, currenttemp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -992,10 +992,10 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
|
||||||
rT.reason += "Eventual BG " + convert_bg(eventualBG, profile) + " > " + convert_bg(min_bg, profile) + " but Min. Delta " + minDelta.toFixed(2) + " < Exp. Delta " + convert_bg(expectedDelta, profile);
|
rT.reason += "Eventual BG " + convert_bg(eventualBG, profile) + " > " + convert_bg(min_bg, profile) + " but Min. Delta " + minDelta.toFixed(2) + " < Exp. Delta " + convert_bg(expectedDelta, profile);
|
||||||
}
|
}
|
||||||
if (currenttemp.duration > 15 && (round_basal(basal, profile) === round_basal(currenttemp.rate, profile))) {
|
if (currenttemp.duration > 15 && (round_basal(basal, profile) === round_basal(currenttemp.rate, profile))) {
|
||||||
rT.reason += ", temp " + currenttemp.rate + " ~ req " + basal + "U/hr. ";
|
rT.reason += ", temp " + currenttemp.rate + " ~ req " + round(basal, 2) + "U/hr. ";
|
||||||
return rT;
|
return rT;
|
||||||
} else {
|
} else {
|
||||||
rT.reason += "; setting current basal of " + basal + " as temp. ";
|
rT.reason += "; setting current basal of " + round(basal, 2) + " as temp. ";
|
||||||
return tempBasalFunctions.setTempBasal(basal, 30, profile, rT, currenttemp);
|
return tempBasalFunctions.setTempBasal(basal, 30, profile, rT, currenttemp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1006,10 +1006,10 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
|
||||||
if (! (microBolusAllowed && enableSMB )) {
|
if (! (microBolusAllowed && enableSMB )) {
|
||||||
rT.reason += convert_bg(eventualBG, profile)+"-"+convert_bg(minPredBG, profile)+" in range: no temp required";
|
rT.reason += convert_bg(eventualBG, profile)+"-"+convert_bg(minPredBG, profile)+" in range: no temp required";
|
||||||
if (currenttemp.duration > 15 && (round_basal(basal, profile) === round_basal(currenttemp.rate, profile))) {
|
if (currenttemp.duration > 15 && (round_basal(basal, profile) === round_basal(currenttemp.rate, profile))) {
|
||||||
rT.reason += ", temp " + currenttemp.rate + " ~ req " + basal + "U/hr. ";
|
rT.reason += ", temp " + currenttemp.rate + " ~ req " + round(basal, 2) + "U/hr. ";
|
||||||
return rT;
|
return rT;
|
||||||
} else {
|
} else {
|
||||||
rT.reason += "; setting current basal of " + basal + " as temp. ";
|
rT.reason += "; setting current basal of " + round(basal, 2) + " as temp. ";
|
||||||
return tempBasalFunctions.setTempBasal(basal, 30, profile, rT, currenttemp);
|
return tempBasalFunctions.setTempBasal(basal, 30, profile, rT, currenttemp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1023,10 +1023,10 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
|
||||||
if (iob_data.iob > max_iob) {
|
if (iob_data.iob > max_iob) {
|
||||||
rT.reason += "IOB " + round(iob_data.iob,2) + " > max_iob " + max_iob;
|
rT.reason += "IOB " + round(iob_data.iob,2) + " > max_iob " + max_iob;
|
||||||
if (currenttemp.duration > 15 && (round_basal(basal, profile) === round_basal(currenttemp.rate, profile))) {
|
if (currenttemp.duration > 15 && (round_basal(basal, profile) === round_basal(currenttemp.rate, profile))) {
|
||||||
rT.reason += ", temp " + currenttemp.rate + " ~ req " + basal + "U/hr. ";
|
rT.reason += ", temp " + currenttemp.rate + " ~ req " + round(basal, 2) + "U/hr. ";
|
||||||
return rT;
|
return rT;
|
||||||
} else {
|
} else {
|
||||||
rT.reason += "; setting current basal of " + basal + " as temp. ";
|
rT.reason += "; setting current basal of " + round(basal, 2) + " as temp. ";
|
||||||
return tempBasalFunctions.setTempBasal(basal, 30, profile, rT, currenttemp);
|
return tempBasalFunctions.setTempBasal(basal, 30, profile, rT, currenttemp);
|
||||||
}
|
}
|
||||||
} else { // otherwise, calculate 30m high-temp required to get projected BG down to target
|
} else { // otherwise, calculate 30m high-temp required to get projected BG down to target
|
||||||
|
|
Loading…
Reference in a new issue