From ffd1fc050a35f966e673671f061d8b02e8f25483 Mon Sep 17 00:00:00 2001 From: "Jon B.M" Date: Thu, 18 Apr 2024 14:50:48 +0200 Subject: [PATCH 1/2] 2 new variables Introduces 2 new variables. --- lib/determine-basal/determine-basal.js | 19 +++++++++++++++++-- lib/profile/index.js | 2 ++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/determine-basal/determine-basal.js b/lib/determine-basal/determine-basal.js index 54f9b986e..15cc755fe 100644 --- a/lib/determine-basal/determine-basal.js +++ b/lib/determine-basal/determine-basal.js @@ -326,7 +326,14 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ } // min_bg of 90 -> threshold of 65, 100 -> 70 110 -> 75, and 130 -> 85 - var threshold = min_bg - 0.5*(min_bg-40); + + // But if profile.threshold_setting is over 65 increase the very minimum glucose threshold + var minimum_threshold = 65; + if (profile.threshold_setting) { + minimum_threshold = profile.threshold_setting; + } + var threshold = Math.max(min_bg - 0.5*(min_bg-40), minimum_threshold); + process.stderr.write("Glucose threshold: " + convert_bg(threshold,profile)); // If iob_data or its required properties are missing, return. // This has to be checked after checking that we're not in one of the CGM-data-related error conditions handled above, @@ -1094,10 +1101,18 @@ var maxDelta_bg_threshold; maxBolus = round( profile.current_basal * profile.maxSMBBasalMinutes / 60 ,1); } // bolus 1/2 the insulinReq, up to maxBolus, rounding down to nearest bolus increment + + // New smb_delivery_ratio setting. Default is 1/2 the insulinReq (0.5), like before. + var smb_delivery_ratio = 0.5; + if (profile.smb_delivery_ratio) { + smb_delivery_ratio = Math.min(Math.max(profile.smb_delivery_ratio, 0.1), 1); + process.stderr.write("SMB Ratio: " + smb_delivery_ratio); + } + bolusIncrement = 0.1; if (profile.bolus_increment) { bolusIncrement=profile.bolus_increment }; var roundSMBTo = 1 / bolusIncrement; - var microBolus = Math.floor(Math.min(insulinReq/2,maxBolus)*roundSMBTo)/roundSMBTo; + var microBolus = Math.floor(Math.min(insulinReq*smb_delivery_ratio,maxBolus)*roundSMBTo)/roundSMBTo; // calculate a long enough zero temp to eventually correct back up to target var smbTarget = target_bg; worstCaseInsulinReq = (smbTarget - (naive_eventualBG + minIOBPredBG)/2 ) / sens; diff --git a/lib/profile/index.js b/lib/profile/index.js index 8ede7f428..db7751bd9 100644 --- a/lib/profile/index.js +++ b/lib/profile/index.js @@ -75,6 +75,8 @@ function defaults ( ) { , target_bg: false // set to an integer value in mg/dL to override pump min_bg , edison_battery_shutdown_voltage: 3050 , pi_battery_shutdown_percent: 2 + , threshold_setting: 65 // The minimum glucose threshold + , smb_delivery_ratio: 0.5 // Ratio of insulinReq, up to maxBolus, to deliver as SMB, when enabled. Default is 1/2 of insulinReq (0.5) } } From 5489f04b49ad8822bee6c6f45038fbb360f2c615 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20M=C3=A5rtensson?= Date: Tue, 7 May 2024 12:59:47 +0200 Subject: [PATCH 2/2] Adjust value --- lib/determine-basal/determine-basal.js | 2 +- lib/profile/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/determine-basal/determine-basal.js b/lib/determine-basal/determine-basal.js index 15cc755fe..171694eca 100644 --- a/lib/determine-basal/determine-basal.js +++ b/lib/determine-basal/determine-basal.js @@ -328,7 +328,7 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ // min_bg of 90 -> threshold of 65, 100 -> 70 110 -> 75, and 130 -> 85 // But if profile.threshold_setting is over 65 increase the very minimum glucose threshold - var minimum_threshold = 65; + var minimum_threshold = 60; if (profile.threshold_setting) { minimum_threshold = profile.threshold_setting; } diff --git a/lib/profile/index.js b/lib/profile/index.js index db7751bd9..2180b0329 100644 --- a/lib/profile/index.js +++ b/lib/profile/index.js @@ -75,7 +75,7 @@ function defaults ( ) { , target_bg: false // set to an integer value in mg/dL to override pump min_bg , edison_battery_shutdown_voltage: 3050 , pi_battery_shutdown_percent: 2 - , threshold_setting: 65 // The minimum glucose threshold + , threshold_setting: 60 // The minimum glucose threshold , smb_delivery_ratio: 0.5 // Ratio of insulinReq, up to maxBolus, to deliver as SMB, when enabled. Default is 1/2 of insulinReq (0.5) } }