Merge pull request #1813 from Andries-Smit/rounding-rate-reason
fix: rounding rate in SMB, AMA, Dyn ISF reason
This commit is contained in:
commit
6d7bc53de1
|
@ -324,7 +324,7 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
|
||||||
rT.reason += ", but Min. Delta " + minDelta.toFixed(2) + " > Exp. Delta " + expectedDelta;
|
rT.reason += ", 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 " + round(basal, 2) + " as temp";
|
rT.reason += "; setting current basal of " + round(basal, 2) + " as temp";
|
||||||
|
@ -367,10 +367,10 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
|
||||||
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)) {
|
||||||
rT.reason += ", temp " + currenttemp.rate + " ~< req " + rate + "U/hr";
|
rT.reason += ", temp " + (currenttemp.rate).toFixed(3) + " ~< req " + round(rate, 2) + "U/hr";
|
||||||
return rT;
|
return rT;
|
||||||
} else {
|
} else {
|
||||||
rT.reason += ", setting " + rate + "U/hr";
|
rT.reason += ", setting " + round(rate, 2) + "U/hr";
|
||||||
return tempBasalFunctions.setTempBasal(rate, 30, profile, rT, currenttemp);
|
return tempBasalFunctions.setTempBasal(rate, 30, profile, rT, currenttemp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -476,22 +476,22 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
|
||||||
|
|
||||||
var insulinScheduled = currenttemp.duration * (currenttemp.rate - basal) / 60;
|
var insulinScheduled = currenttemp.duration * (currenttemp.rate - basal) / 60;
|
||||||
if (insulinScheduled >= insulinReq * 2) { // if current temp would deliver >2x more than the required insulin, lower the rate
|
if (insulinScheduled >= insulinReq * 2) { // if current temp would deliver >2x more than the required insulin, lower the rate
|
||||||
rT.reason += currenttemp.duration + "m@" + (currenttemp.rate - basal).toFixed(3) + " = " + insulinScheduled.toFixed(3) + " > 2 * req " + insulinReq + ". Setting temp basal of " + rate + "U/hr";
|
rT.reason += currenttemp.duration + "m@" + (currenttemp.rate - basal).toFixed(3) + " = " + insulinScheduled.toFixed(3) + " > 2 * req " + insulinReq + ". Setting temp basal of " + round(rate, 2) + "U/hr";
|
||||||
return tempBasalFunctions.setTempBasal(rate, 30, profile, rT, currenttemp);
|
return tempBasalFunctions.setTempBasal(rate, 30, profile, rT, currenttemp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof currenttemp.duration == 'undefined' || currenttemp.duration == 0) { // no temp is set
|
if (typeof currenttemp.duration == 'undefined' || currenttemp.duration == 0) { // no temp is set
|
||||||
rT.reason += "no temp, setting " + rate + "U/hr";
|
rT.reason += "no temp, setting " + round(rate, 2) + "U/hr";
|
||||||
return tempBasalFunctions.setTempBasal(rate, 30, profile, rT, currenttemp);
|
return tempBasalFunctions.setTempBasal(rate, 30, profile, rT, currenttemp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currenttemp.duration > 5 && (round_basal(rate, profile) <= round_basal(currenttemp.rate, profile))) { // if required temp <~ existing temp basal
|
if (currenttemp.duration > 5 && (round_basal(rate, profile) <= round_basal(currenttemp.rate, profile))) { // if required temp <~ existing temp basal
|
||||||
rT.reason += "temp " + currenttemp.rate + " >~ req " + rate + "U/hr";
|
rT.reason += "temp " + (currenttemp.rate).toFixed(3) + " >~ req " + round(rate, 2) + "U/hr";
|
||||||
return rT;
|
return rT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// required temp > existing temp basal
|
// required temp > existing temp basal
|
||||||
rT.reason += "temp " + currenttemp.rate + "<" + rate + "U/hr";
|
rT.reason += "temp " + (currenttemp.rate).toFixed(3) + " < " + round(rate, 2) + "U/hr";
|
||||||
return tempBasalFunctions.setTempBasal(rate, 30, profile, rT, currenttemp);
|
return tempBasalFunctions.setTempBasal(rate, 30, profile, rT, currenttemp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -955,7 +955,7 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
|
||||||
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)) {
|
||||||
rT.reason += ", temp " + currenttemp.rate + " ~< req " + rate + "U/hr. ";
|
rT.reason += ", temp " + currenttemp.rate + " ~< req " + round(rate, 2) + "U/hr. ";
|
||||||
return rT;
|
return rT;
|
||||||
} else {
|
} else {
|
||||||
// calculate a long enough zero temp to eventually correct back up to target
|
// calculate a long enough zero temp to eventually correct back up to target
|
||||||
|
@ -976,7 +976,7 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
|
||||||
return tempBasalFunctions.setTempBasal(rate, durationReq, profile, rT, currenttemp);
|
return tempBasalFunctions.setTempBasal(rate, durationReq, profile, rT, currenttemp);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
rT.reason += ", setting " + rate + "U/hr. ";
|
rT.reason += ", setting " + round(rate, 2) + "U/hr. ";
|
||||||
}
|
}
|
||||||
return tempBasalFunctions.setTempBasal(rate, 30, profile, rT, currenttemp);
|
return tempBasalFunctions.setTempBasal(rate, 30, profile, rT, currenttemp);
|
||||||
}
|
}
|
||||||
|
@ -1143,22 +1143,22 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
|
||||||
|
|
||||||
insulinScheduled = currenttemp.duration * (currenttemp.rate - basal) / 60;
|
insulinScheduled = currenttemp.duration * (currenttemp.rate - basal) / 60;
|
||||||
if (insulinScheduled >= insulinReq * 2) { // if current temp would deliver >2x more than the required insulin, lower the rate
|
if (insulinScheduled >= insulinReq * 2) { // if current temp would deliver >2x more than the required insulin, lower the rate
|
||||||
rT.reason += currenttemp.duration + "m@" + (currenttemp.rate).toFixed(2) + " > 2 * insulinReq. Setting temp basal of " + rate + "U/hr. ";
|
rT.reason += currenttemp.duration + "m@" + (currenttemp.rate).toFixed(2) + " > 2 * insulinReq. Setting temp basal of " + round(rate, 2) + "U/hr. ";
|
||||||
return tempBasalFunctions.setTempBasal(rate, 30, profile, rT, currenttemp);
|
return tempBasalFunctions.setTempBasal(rate, 30, profile, rT, currenttemp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof currenttemp.duration === 'undefined' || currenttemp.duration === 0) { // no temp is set
|
if (typeof currenttemp.duration === 'undefined' || currenttemp.duration === 0) { // no temp is set
|
||||||
rT.reason += "no temp, setting " + rate + "U/hr. ";
|
rT.reason += "no temp, setting " + round(rate, 2) + "U/hr. ";
|
||||||
return tempBasalFunctions.setTempBasal(rate, 30, profile, rT, currenttemp);
|
return tempBasalFunctions.setTempBasal(rate, 30, profile, rT, currenttemp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currenttemp.duration > 5 && (round_basal(rate, profile) <= round_basal(currenttemp.rate, profile))) { // if required temp <~ existing temp basal
|
if (currenttemp.duration > 5 && (round_basal(rate, profile) <= round_basal(currenttemp.rate, profile))) { // if required temp <~ existing temp basal
|
||||||
rT.reason += "temp " + currenttemp.rate + " >~ req " + rate + "U/hr. ";
|
rT.reason += "temp " + (currenttemp.rate).toFixed(2) + " >~ req " + round(rate, 2) + "U/hr. ";
|
||||||
return rT;
|
return rT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// required temp > existing temp basal
|
// required temp > existing temp basal
|
||||||
rT.reason += "temp " + currenttemp.rate + "<" + rate + "U/hr. ";
|
rT.reason += "temp " + (currenttemp.rate).toFixed(2) + " < " + round(rate, 2) + "U/hr. ";
|
||||||
return tempBasalFunctions.setTempBasal(rate, 30, profile, rT, currenttemp);
|
return tempBasalFunctions.setTempBasal(rate, 30, profile, rT, currenttemp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1085,7 +1085,7 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
|
||||||
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)) {
|
||||||
rT.reason += ", temp " + currenttemp.rate + " ~< req " + rate + "U/hr. ";
|
rT.reason += ", temp " + currenttemp.rate + " ~< req " + round(rate, 2) + "U/hr. ";
|
||||||
return rT;
|
return rT;
|
||||||
} else {
|
} else {
|
||||||
// calculate a long enough zero temp to eventually correct back up to target
|
// calculate a long enough zero temp to eventually correct back up to target
|
||||||
|
@ -1106,7 +1106,7 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
|
||||||
return tempBasalFunctions.setTempBasal(rate, durationReq, profile, rT, currenttemp);
|
return tempBasalFunctions.setTempBasal(rate, durationReq, profile, rT, currenttemp);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
rT.reason += ", setting " + rate + "U/hr. ";
|
rT.reason += ", setting " + round(rate, 2) + "U/hr. ";
|
||||||
}
|
}
|
||||||
return tempBasalFunctions.setTempBasal(rate, 30, profile, rT, currenttemp);
|
return tempBasalFunctions.setTempBasal(rate, 30, profile, rT, currenttemp);
|
||||||
}
|
}
|
||||||
|
@ -1273,22 +1273,22 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
|
||||||
|
|
||||||
insulinScheduled = currenttemp.duration * (currenttemp.rate - basal) / 60;
|
insulinScheduled = currenttemp.duration * (currenttemp.rate - basal) / 60;
|
||||||
if (insulinScheduled >= insulinReq * 2) { // if current temp would deliver >2x more than the required insulin, lower the rate
|
if (insulinScheduled >= insulinReq * 2) { // if current temp would deliver >2x more than the required insulin, lower the rate
|
||||||
rT.reason += currenttemp.duration + "m@" + (currenttemp.rate).toFixed(2) + " > 2 * insulinReq. Setting temp basal of " + rate + "U/hr. ";
|
rT.reason += currenttemp.duration + "m@" + (currenttemp.rate).toFixed(2) + " > 2 * insulinReq. Setting temp basal of " + round(rate, 2) + "U/hr. ";
|
||||||
return tempBasalFunctions.setTempBasal(rate, 30, profile, rT, currenttemp);
|
return tempBasalFunctions.setTempBasal(rate, 30, profile, rT, currenttemp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof currenttemp.duration === 'undefined' || currenttemp.duration === 0) { // no temp is set
|
if (typeof currenttemp.duration === 'undefined' || currenttemp.duration === 0) { // no temp is set
|
||||||
rT.reason += "no temp, setting " + rate + "U/hr. ";
|
rT.reason += "no temp, setting " + round(rate, 2) + "U/hr. ";
|
||||||
return tempBasalFunctions.setTempBasal(rate, 30, profile, rT, currenttemp);
|
return tempBasalFunctions.setTempBasal(rate, 30, profile, rT, currenttemp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currenttemp.duration > 5 && (round_basal(rate, profile) <= round_basal(currenttemp.rate, profile))) { // if required temp <~ existing temp basal
|
if (currenttemp.duration > 5 && (round_basal(rate, profile) <= round_basal(currenttemp.rate, profile))) { // if required temp <~ existing temp basal
|
||||||
rT.reason += "temp " + currenttemp.rate + " >~ req " + rate + "U/hr. ";
|
rT.reason += "temp " + (currenttemp.rate).toFixed(2) + " >~ req " + round(rate, 2) + "U/hr. ";
|
||||||
return rT;
|
return rT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// required temp > existing temp basal
|
// required temp > existing temp basal
|
||||||
rT.reason += "temp " + currenttemp.rate + "<" + rate + "U/hr. ";
|
rT.reason += "temp " + (currenttemp.rate).toFixed(2) + " < " + round(rate, 2) + "U/hr. ";
|
||||||
return tempBasalFunctions.setTempBasal(rate, 30, profile, rT, currenttemp);
|
return tempBasalFunctions.setTempBasal(rate, 30, profile, rT, currenttemp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue