forked from Jon-b-m/middleware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dISF_autosensRatio.json
18 lines (15 loc) · 1015 Bytes
/
dISF_autosensRatio.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
function middleware(iob, currenttemp, glucose, profile, autosens, meal, reservoir, clock, pumphistory, preferences) {
// This middleware only works with Ivan’s FAX and uses Chris Formula for Dynamic ISF based on autosens factor.
//define variables
const BG = glucose[0].glucose;
var chrisFormula = true;
var autosensRatio = autosens.ratio;
//Note: adjustmentFactor default value=1. Lower number = milder dISF profile
var adjustmentFactor = 1;
//Chris' formula with added adjustmentFactor for tuning:
if (chrisFormula == true) {
const newRatio = profile.sens / (277700 / (25 * adjustmentFactor * autosensRatio * BG));
autosens.ratio = newRatio;
return "autosensRatio changed using Chris' formula from " + autosensRatio + " to: " + newRatio.toPrecision(4) + " with new ISF: " + (profile.sens / newRatio).toPrecision(4) + " (" + ((profile.sens / newRatio) * 0.0555).toPrecision(4) + " mmol/L/U)";
} else { return "Chris' formula is off. autosensRatio is: " + autosensRatio; }
}