From 86adc19010d7ca9c4efa618e82c00cc385a9e01b Mon Sep 17 00:00:00 2001 From: Andy Rozman Date: Tue, 24 Dec 2019 17:52:28 +0100 Subject: [PATCH] - added code to remove Treatment entries, without any insulin (for syncing PH Bolus entries with Treatments) --- .../medtronic/data/MedtronicHistoryData.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryData.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryData.java index 2e23d2a955..11d1bad3d9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryData.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/MedtronicHistoryData.java @@ -32,6 +32,7 @@ import info.nightscout.androidaps.db.TemporaryBasal; import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.general.nsclient.NSUpload; import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage; +import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil; import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil; import info.nightscout.androidaps.plugins.pump.common.utils.StringUtil; import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.MedtronicPumpHistoryDecoder; @@ -613,6 +614,8 @@ public class MedtronicHistoryData { return; } + filterOutNonInsulinEntries(entriesFromHistory); + if (doubleBolusDebug) LOG.debug("DoubleBolusDebug: List (after filter): {}, FromDb={}", gson.toJson(entryList), gsonCore.toJson(entriesFromHistory)); @@ -640,6 +643,23 @@ public class MedtronicHistoryData { } + private void filterOutNonInsulinEntries(List entriesFromHistory) { + // when we try to pair PumpHistory with AAPS treatments, we need to ignore all non-insulin entries + List removeList = new ArrayList<>(); + + for (DbObjectBase dbObjectBase : entriesFromHistory) { + + Treatment treatment = (Treatment)dbObjectBase; + + if (RileyLinkUtil.isSame(treatment.insulin, 0d)) { + removeList.add(dbObjectBase); + } + } + + entriesFromHistory.removeAll(removeList); + } + + private void processTBREntries(List entryList) { Collections.reverse(entryList);