- added code to remove Treatment entries, without any insulin (for syncing PH Bolus entries with Treatments)

This commit is contained in:
Andy Rozman 2019-12-24 17:52:28 +01:00
parent c4602e980b
commit 86adc19010

View file

@ -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<? extends DbObjectBase> entriesFromHistory) {
// when we try to pair PumpHistory with AAPS treatments, we need to ignore all non-insulin entries
List<DbObjectBase> 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<PumpHistoryEntry> entryList) {
Collections.reverse(entryList);