Skip to content

Commit

Permalink
Enable SMB when BG greater than specified value (#1365)
Browse files Browse the repository at this point in the history
* Add high_bg enable SMB toggle

Still need to implement UTs, but this is an initial commit to get eyes on and daytime testing.

* Add logging

Also move the enableSMB_always at the end as it originally was

* Implement enableSMB_high_bg with dev

* Update determine-basal.js

Fix profile variable name for high bg target

Co-authored-by: Steven Bell <[email protected]>
  • Loading branch information
stevebell117 and Steven Bell authored Dec 18, 2021
1 parent fe6e492 commit d15d8d4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
26 changes: 23 additions & 3 deletions lib/determine-basal/determine-basal.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ function enable_smb(
profile,
microBolusAllowed,
meal_data,
target_bg
bg,
target_bg,
high_bg
) {
// disable SMB when a high temptarget is set
if (! microBolusAllowed) {
Expand Down Expand Up @@ -105,7 +107,19 @@ function enable_smb(
console.error("SMB enabled for temptarget of",convert_bg(target_bg, profile));
}
return true;
}
}

// enable SMB if high bg is found
if (profile.enableSMB_high_bg === true && high_bg !== null && bg >= high_bg) {
console.error("Checking BG to see if High for SMB enablement.");
console.error("Current BG", bg, " | High BG ", high_bg);
if (meal_data.bwFound) {
console.error("Warning: High BG SMB enabled within 6h of using Bolus Wizard: be sure to easy bolus 30s before using Bolus Wizard");
} else {
console.error("High BG detected. Enabling SMB.");
}
return true;
}

console.error("SMB disabled (no enableSMB preferences active or no condition satisfied)");
return false;
Expand Down Expand Up @@ -215,12 +229,16 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
var target_bg;
var min_bg;
var max_bg;
var high_bg;
if (typeof profile.min_bg !== 'undefined') {
min_bg = profile.min_bg;
}
if (typeof profile.max_bg !== 'undefined') {
max_bg = profile.max_bg;
}
if (typeof profile.enableSMB_high_bg_target !== 'undefined') {
high_bg = profile.enableSMB_high_bg_target;
}
if (typeof profile.min_bg !== 'undefined' && typeof profile.max_bg !== 'undefined') {
target_bg = (profile.min_bg + profile.max_bg) / 2;
} else {
Expand Down Expand Up @@ -434,7 +452,9 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
profile,
microBolusAllowed,
meal_data,
target_bg
bg,
target_bg,
high_bg
);

// enable UAM (if enabled in preferences)
Expand Down
2 changes: 2 additions & 0 deletions lib/profile/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ function defaults ( ) {
// if the CGM sensor reads falsely high and doesn't come down as actual BG does
, enableSMB_always: false // always enable supermicrobolus (unless disabled by high temptarget)
, enableSMB_after_carbs: false // enable supermicrobolus for 6h after carbs, even with 0 COB
, enableSMB_high_bg: false // enable SMBs when a high BG is detected, based on the high BG target (adjusted or profile)
, enableSMB_high_bg_target: 110 // set the value enableSMB_high_bg will compare against to enable SMB. If BG > than this value, SMBs should enable.
// *** WARNING *** DO NOT USE enableSMB_always or enableSMB_after_carbs with Libre or similar.
, allowSMB_with_high_temptarget: false // allow supermicrobolus (if otherwise enabled) even with high temp targets
, maxSMBBasalMinutes: 30 // maximum minutes of basal that can be delivered as a single SMB with uncovered COB
Expand Down

0 comments on commit d15d8d4

Please sign in to comment.