Skip to content

Commit

Permalink
Merge 8646889 into 55aecfb
Browse files Browse the repository at this point in the history
  • Loading branch information
scottleibrand committed Aug 4, 2017
2 parents 55aecfb + 8646889 commit ac84cae
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions lib/iob/calculate.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,22 +136,12 @@ function iobCalc(treatment, time, dia, profile) {

activityContrib = treatment.insulin * (S / Math.pow(tau, 2)) * t * (1 - t / td) * Math.exp(-t / tau);
iobContrib = treatment.insulin * (1 - S * (1 - a) * ((Math.pow(t, 2) / (tau * td * (1 - a)) - t / tau - 1) * Math.exp(-t / tau) + 1));
// calculate bolus snooze insulin in the same pass
t = t * profile.bolussnooze_dia_divisor;
var biobContrib = treatment.insulin * (1 - S * (1 - a) * ((Math.pow(t, 2) / (tau * td * (1 - a)) - t / tau - 1) * Math.exp(-t / tau) + 1));

//console.error('DIA: ' + dia + ' t: ' + t + ' td: ' + td + ' tp: ' + tp + ' tau: ' + tau + ' a: ' + a + ' S: ' + S + ' activityContrib: ' + activityContrib + ' iobContrib: ' + iobContrib);

// calculate bolus snooze insulin in the same pass

td = td / profile.bolussnooze_dia_divisor;
if (t > td) {
t = td;
}
if (tp > (td / 2.5)) {
tp = Math.floor(td / 2.5);
}
tau = tp * (1 - tp / td) / (1 - 2 * tp / td);
a = 2 * tau / td;
S = 1 / (1 - a + (1 + a) * Math.exp(-td / tau));
var biobContrib = treatment.insulin * (1 - S * (1 - a) * ((Math.pow(t, 2) / (tau * td * (1 - a)) - t / tau - 1) * Math.exp(-t / tau) + 1));
}

results = {
Expand All @@ -163,4 +153,4 @@ function iobCalc(treatment, time, dia, profile) {
return results;
}

exports = module.exports = iobCalc;
exports = module.exports = iobCalc;

0 comments on commit ac84cae

Please sign in to comment.