Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2 new variables #1465

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions lib/determine-basal/determine-basal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = 60;
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,
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions lib/profile/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: 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)
}
}

Expand Down