From c454ecd84e35832ef42d49bef3db89ddb97ce08a Mon Sep 17 00:00:00 2001 From: Kyrylo Chekanov Date: Sat, 18 Dec 2021 05:57:36 +0200 Subject: [PATCH] per #1401 set highest sensitivity on low TT and halfBasal (#1403) getting multiplication less or equal to 0 means that we have a really low target with a really low halfBasalTarget with low TT and lowTTlowersSensitivity we need autosens_max as a value we use multiplication instead of the division to avoid "division by zero error" --- lib/determine-basal/determine-basal.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/determine-basal/determine-basal.js b/lib/determine-basal/determine-basal.js index ce37b04b2..93eebec9b 100644 --- a/lib/determine-basal/determine-basal.js +++ b/lib/determine-basal/determine-basal.js @@ -244,7 +244,15 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ // e.g.: Sensitivity ratio set to 0.8 based on temp target of 120; Adjusting basal from 1.65 to 1.35; ISF from 58.9 to 73.6 //sensitivityRatio = 2/(2+(target_bg-normalTarget)/40); var c = halfBasalTarget - normalTarget; - sensitivityRatio = c/(c+target_bg-normalTarget); + // getting multiplication less or equal to 0 means that we have a really low target with a really low halfBasalTarget + // with low TT and lowTTlowersSensitivity we need autosens_max as a value + // we use multiplication instead of the division to avoid "division by zero error" + if (c * (c + target_bg-normalTarget) <= 0.0) { + sensitivityRatio = profile.autosens_max; + } + else { + sensitivityRatio = c/(c+target_bg-normalTarget); + } // limit sensitivityRatio to profile.autosens_max (1.2x by default) sensitivityRatio = Math.min(sensitivityRatio, profile.autosens_max); sensitivityRatio = round(sensitivityRatio,2);