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

Remove aCOBpredBGs (accelerated carbohydrate absorption) as it is not used anymore. #1319

Merged
merged 1 commit into from
Nov 15, 2019
Merged
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
17 changes: 1 addition & 16 deletions lib/determine-basal/determine-basal.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,12 +414,10 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
// generate predicted future BGs based on IOB, COB, and current absorption rate

var COBpredBGs = [];
var aCOBpredBGs = [];
var IOBpredBGs = [];
var UAMpredBGs = [];
var ZTpredBGs = [];
COBpredBGs.push(bg);
aCOBpredBGs.push(bg);
IOBpredBGs.push(bg);
ZTpredBGs.push(bg);
UAMpredBGs.push(bg);
Expand Down Expand Up @@ -527,10 +525,9 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
} else {
cid = Math.min(remainingCATime*60/5/2,Math.max(0, meal_data.mealCOB * csf / ci ));
}
var acid = Math.max(0, meal_data.mealCOB * csf / aci );
// duration (hours) = duration (5m) * 5 / 60 * 2 (to account for linear decay)
console.error("Carb Impact:",ci,"mg/dL per 5m; CI Duration:",round(cid*5/60*2,1),"hours; remaining CI (~2h peak):",round(remainingCIpeak,1),"mg/dL per 5m");
//console.error("Accel. Carb Impact:",aci,"mg/dL per 5m; ACI Duration:",round(acid*5/60*2,1),"hours");
//console.error("Accel. Carb Impact:",aci,"mg/dL per 5m; ACI Duration:",round(aci*5/60*2,1),"hours");
var minIOBPredBG = 999;
var minCOBPredBG = 999;
var minUAMPredBG = 999;
Expand Down Expand Up @@ -569,7 +566,6 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
// for COBpredBGs, predicted carb impact drops linearly from current carb impact down to zero
// eventually accounting for all carbs (if they can be absorbed over DIA)
var predCI = Math.max(0, Math.max(0,ci) * ( 1 - COBpredBGs.length/Math.max(cid*2,1) ) );
var predACI = Math.max(0, Math.max(0,aci) * ( 1 - COBpredBGs.length/Math.max(acid*2,1) ) );
// if any carbs aren't absorbed after remainingCATime hours, assume they'll absorb in a /\ shaped
// bilinear curve peaking at remainingCIpeak at remainingCATime/2 hours (remainingCATime/2*12 * 5m)
// and ending at remainingCATime h (remainingCATime*12 * 5m intervals)
Expand All @@ -580,7 +576,6 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
predCIs.push(round(predCI,0));
//process.stderr.write(round(predCI,1)+"+"+round(remainingCI,1)+" ");
COBpredBG = COBpredBGs[COBpredBGs.length-1] + predBGI + Math.min(0,predDev) + predCI + remainingCI;
var aCOBpredBG = aCOBpredBGs[aCOBpredBGs.length-1] + predBGI + Math.min(0,predDev) + predACI;
// for UAMpredBGs, predicted carb impact drops at slopeFromDeviations
// calculate predicted CI from UAM based on slopeFromDeviations
var predUCIslope = Math.max(0, uci + ( UAMpredBGs.length*slopeFromDeviations ) );
Expand All @@ -599,7 +594,6 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
// truncate all BG predictions at 4 hours
if ( IOBpredBGs.length < 48) { IOBpredBGs.push(IOBpredBG); }
if ( COBpredBGs.length < 48) { COBpredBGs.push(COBpredBG); }
if ( aCOBpredBGs.length < 48) { aCOBpredBGs.push(aCOBpredBG); }
if ( UAMpredBGs.length < 48) { UAMpredBGs.push(UAMpredBG); }
if ( ZTpredBGs.length < 48) { ZTpredBGs.push(ZTpredBG); }
// calculate minGuardBGs without a wait from COB, UAM, IOB predBGs
Expand Down Expand Up @@ -654,15 +648,6 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
}
rT.predBGs.ZT = ZTpredBGs;
lastZTpredBG=round(ZTpredBGs[ZTpredBGs.length-1]);
if (meal_data.mealCOB > 0) {
aCOBpredBGs.forEach(function(p, i, theArray) {
theArray[i] = round(Math.min(401,Math.max(39,p)));
});
for (i=aCOBpredBGs.length-1; i > 12; i--) {
if (aCOBpredBGs[i-1] !== aCOBpredBGs[i]) { break; }
else { aCOBpredBGs.pop(); }
}
}
if (meal_data.mealCOB > 0 && ( ci > 0 || remainingCIpeak > 0 )) {
COBpredBGs.forEach(function(p, i, theArray) {
theArray[i] = round(Math.min(401,Math.max(39,p)));
Expand Down