microbolus calculation

This commit is contained in:
Milos Kozak 2017-08-10 17:28:41 +02:00
parent 57f5e5a92d
commit f703c82ca7
2 changed files with 19 additions and 2 deletions

View file

@ -16,6 +16,10 @@ public class IobTotal {
public double netbasalinsulin; public double netbasalinsulin;
public double hightempinsulin; public double hightempinsulin;
// oref1
public double microBolusInsulin;
public double microBolusIOB;
public double netInsulin = 0d; // for calculations from temp basals only public double netInsulin = 0d; // for calculations from temp basals only
public double netRatio = 0d; // net ratio at start of temp basal public double netRatio = 0d; // net ratio at start of temp basal
@ -30,6 +34,8 @@ public class IobTotal {
this.basaliob = 0d; this.basaliob = 0d;
this.netbasalinsulin = 0d; this.netbasalinsulin = 0d;
this.hightempinsulin = 0d; this.hightempinsulin = 0d;
this.microBolusInsulin = 0d;
this.microBolusIOB = 0d;
this.time = time; this.time = time;
} }
@ -42,6 +48,8 @@ public class IobTotal {
hightempinsulin += other.hightempinsulin; hightempinsulin += other.hightempinsulin;
netInsulin += other.netInsulin; netInsulin += other.netInsulin;
extendedBolusInsulin += other.extendedBolusInsulin; extendedBolusInsulin += other.extendedBolusInsulin;
microBolusInsulin += other.microBolusInsulin;
microBolusIOB += other.microBolusIOB;
return this; return this;
} }
@ -53,6 +61,8 @@ public class IobTotal {
result.basaliob = basalIob.basaliob; result.basaliob = basalIob.basaliob;
result.netbasalinsulin = basalIob.netbasalinsulin; result.netbasalinsulin = basalIob.netbasalinsulin;
result.hightempinsulin = basalIob.hightempinsulin; result.hightempinsulin = basalIob.hightempinsulin;
result.microBolusInsulin = bolusIOB.microBolusInsulin + basalIob.microBolusInsulin;
result.microBolusIOB = bolusIOB.microBolusIOB + basalIob.microBolusIOB;
return result; return result;
} }
@ -63,6 +73,8 @@ public class IobTotal {
this.basaliob = Round.roundTo(this.basaliob, 0.001); this.basaliob = Round.roundTo(this.basaliob, 0.001);
this.netbasalinsulin = Round.roundTo(this.netbasalinsulin, 0.001); this.netbasalinsulin = Round.roundTo(this.netbasalinsulin, 0.001);
this.hightempinsulin = Round.roundTo(this.hightempinsulin, 0.001); this.hightempinsulin = Round.roundTo(this.hightempinsulin, 0.001);
this.microBolusInsulin = Round.roundTo(this.microBolusInsulin, 0.001);
this.microBolusIOB = Round.roundTo(this.microBolusIOB, 0.001);
return this; return this;
} }

View file

@ -183,8 +183,13 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
Iob tIOB = t.iobCalc(time, dia); Iob tIOB = t.iobCalc(time, dia);
total.iob += tIOB.iobContrib; total.iob += tIOB.iobContrib;
total.activity += tIOB.activityContrib; total.activity += tIOB.activityContrib;
Iob bIOB = t.iobCalc(time, dia / SP.getDouble("openapsama_bolussnooze_dia_divisor", 2.0)); if (!t.isSMB) {
total.bolussnooze += bIOB.iobContrib; Iob bIOB = t.iobCalc(time, dia / SP.getDouble("openapsama_bolussnooze_dia_divisor", 2.0));
total.bolussnooze += bIOB.iobContrib;
} else {
total.basaliob += t.insulin;
total.microBolusIOB += tIOB.iobContrib;
}
} }
if (!MainApp.getConfigBuilder().isFakingTempsByExtendedBoluses()) if (!MainApp.getConfigBuilder().isFakingTempsByExtendedBoluses())