fix adding basals to database in danar driver

This commit is contained in:
Milos Kozak 2017-06-08 22:26:32 +02:00
parent 74268675af
commit 96d760ba62
2 changed files with 8 additions and 6 deletions

View file

@ -74,14 +74,15 @@ public class MsgStatusBolusExtended extends MessageBase {
if (pump.isExtendedInProgress) { if (pump.isExtendedInProgress) {
if (extendedBolus.absoluteRate() != pump.extendedBolusAbsoluteRate) { if (extendedBolus.absoluteRate() != pump.extendedBolusAbsoluteRate) {
// Close current extended // Close current extended
ExtendedBolus exStop = new ExtendedBolus(now - 1000); ExtendedBolus exStop = new ExtendedBolus(pump.extendedBolusStart.getTime() - 1000);
exStop.source = Source.USER; exStop.source = Source.USER;
treatmentsInterface.addToHistoryExtendedBolus(exStop); treatmentsInterface.addToHistoryExtendedBolus(exStop);
// Create new // Create new
ExtendedBolus newExtended = new ExtendedBolus(); ExtendedBolus newExtended = new ExtendedBolus();
newExtended.date = new Date(now).getTime(); newExtended.date = pump.extendedBolusStart.getTime();
newExtended.insulin = pump.extendedBolusAmount; newExtended.insulin = pump.extendedBolusAmount;
newExtended.durationInMinutes = pump.extendedBolusMinutes; newExtended.durationInMinutes = pump.extendedBolusMinutes;
newExtended.source = Source.USER;
treatmentsInterface.addToHistoryExtendedBolus(newExtended); treatmentsInterface.addToHistoryExtendedBolus(newExtended);
} }
} else { } else {
@ -94,9 +95,10 @@ public class MsgStatusBolusExtended extends MessageBase {
if (pump.isExtendedInProgress) { if (pump.isExtendedInProgress) {
// Create new // Create new
ExtendedBolus newExtended = new ExtendedBolus(); ExtendedBolus newExtended = new ExtendedBolus();
newExtended.date = new Date(now).getTime(); newExtended.date = pump.extendedBolusStart.getTime();
newExtended.insulin = pump.extendedBolusAmount; newExtended.insulin = pump.extendedBolusAmount;
newExtended.durationInMinutes = pump.extendedBolusMinutes; newExtended.durationInMinutes = pump.extendedBolusMinutes;
newExtended.source = Source.USER;
treatmentsInterface.addToHistoryExtendedBolus(newExtended); treatmentsInterface.addToHistoryExtendedBolus(newExtended);
} }
} }

View file

@ -68,12 +68,12 @@ public class MsgStatusTempBasal extends MessageBase {
if (danaRPump.isTempBasalInProgress) { if (danaRPump.isTempBasalInProgress) {
if (tempBasal.percentRate != danaRPump.tempBasalPercent) { if (tempBasal.percentRate != danaRPump.tempBasalPercent) {
// Close current temp basal // Close current temp basal
TemporaryBasal tempStop = new TemporaryBasal(now - 1000); TemporaryBasal tempStop = new TemporaryBasal(danaRPump.tempBasalStart.getTime() - 1000);
tempStop.source = Source.USER; tempStop.source = Source.USER;
treatmentsInterface.addToHistoryTempBasal(tempStop); treatmentsInterface.addToHistoryTempBasal(tempStop);
// Create new // Create new
TemporaryBasal newTempBasal = new TemporaryBasal(); TemporaryBasal newTempBasal = new TemporaryBasal();
newTempBasal.date = new Date(now).getTime(); newTempBasal.date = danaRPump.tempBasalStart.getTime();
newTempBasal.percentRate = danaRPump.tempBasalPercent; newTempBasal.percentRate = danaRPump.tempBasalPercent;
newTempBasal.isAbsolute = false; newTempBasal.isAbsolute = false;
newTempBasal.durationInMinutes = danaRPump.tempBasalTotalSec / 60; newTempBasal.durationInMinutes = danaRPump.tempBasalTotalSec / 60;
@ -90,7 +90,7 @@ public class MsgStatusTempBasal extends MessageBase {
if (danaRPump.isTempBasalInProgress) { if (danaRPump.isTempBasalInProgress) {
// Create new // Create new
TemporaryBasal newTempBasal = new TemporaryBasal(); TemporaryBasal newTempBasal = new TemporaryBasal();
newTempBasal.date = new Date(now).getTime(); newTempBasal.date = danaRPump.tempBasalStart.getTime();
newTempBasal.percentRate = danaRPump.tempBasalPercent; newTempBasal.percentRate = danaRPump.tempBasalPercent;
newTempBasal.isAbsolute = false; newTempBasal.isAbsolute = false;
newTempBasal.durationInMinutes = danaRPump.tempBasalTotalSec / 60; newTempBasal.durationInMinutes = danaRPump.tempBasalTotalSec / 60;