combo: don't attempt to add a bolus record if it already exists in db.

This commit is contained in:
Johannes Mockenhaupt 2018-07-01 17:19:53 +02:00
parent f12db81f96
commit 658af4bcfd
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1

View file

@ -60,10 +60,7 @@ import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.Bolus;
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.PumpHistory; import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.PumpHistory;
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.PumpHistoryRequest; import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.PumpHistoryRequest;
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.Tdd; import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.Tdd;
import info.nightscout.androidaps.plugins.Treatments.Treatment;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.androidaps.queue.Callback;
import info.nightscout.androidaps.queue.CommandQueue;
import info.nightscout.utils.DateUtil; import info.nightscout.utils.DateUtil;
import info.nightscout.utils.FabricPrivacy; import info.nightscout.utils.FabricPrivacy;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
@ -498,7 +495,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
return deliverBolus(detailedBolusInfo); return deliverBolus(detailedBolusInfo);
} else { } else {
// no bolus required, carb only treatment // no bolus required, carb only treatment
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo); TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false);
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance(); EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
bolusingEvent.t = new Treatment(); bolusingEvent.t = new Treatment();
@ -689,7 +686,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
dbi.source = Source.PUMP; dbi.source = Source.PUMP;
dbi.insulin = lastPumpBolus.amount; dbi.insulin = lastPumpBolus.amount;
try { try {
boolean treatmentCreated = TreatmentsPlugin.getPlugin().addToHistoryTreatment(dbi); boolean treatmentCreated = TreatmentsPlugin.getPlugin().addToHistoryTreatment(dbi, false);
if (!treatmentCreated) { if (!treatmentCreated) {
log.error("Adding treatment record overrode an existing record: " + dbi); log.error("Adding treatment record overrode an existing record: " + dbi);
if (dbi.isSMB) { if (dbi.isSMB) {
@ -1188,7 +1185,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
dbi.source = Source.PUMP; dbi.source = Source.PUMP;
dbi.insulin = pumpBolus.amount; dbi.insulin = pumpBolus.amount;
dbi.eventType = CareportalEvent.CORRECTIONBOLUS; dbi.eventType = CareportalEvent.CORRECTIONBOLUS;
if (TreatmentsPlugin.getPlugin().addToHistoryTreatment(dbi)) { if (TreatmentsPlugin.getPlugin().getService().getPumpRecordById(dbi.pumpId) != null) {
TreatmentsPlugin.getPlugin().addToHistoryTreatment(dbi, false);
updated = true; updated = true;
} }
} }