Warn when finding multiple boluses in the same minute with same amount.
Not much can be done if the user manages to bolus multiple boluses within the same minute, with the same amount. This should almost never happen, but if it does, at least warn the user one of those boluses isn't accounted for wrt to IOB.
This commit is contained in:
parent
a861afa208
commit
e9f0fa3c04
|
@ -14,6 +14,7 @@ import org.slf4j.LoggerFactory;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import info.nightscout.androidaps.BuildConfig;
|
import info.nightscout.androidaps.BuildConfig;
|
||||||
|
@ -1219,6 +1220,23 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
return historyResult;
|
return historyResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check edge of multiple boluses with the same amount in the same minute being imported.
|
||||||
|
// This is about as edgy-casey as it can get. I'd be surprised of this one actually ever
|
||||||
|
// triggers. It might, so at least give a warning, since a delivered bolus isn't accounted
|
||||||
|
// for.
|
||||||
|
HashSet<Bolus> bolusSet = new HashSet<>(historyResult.history.bolusHistory);
|
||||||
|
if (bolusSet.size() != historyResult.history.bolusHistory.size()) {
|
||||||
|
log.debug("Bolus with same amount within the same minute imported. Only one will make it to the DB.");
|
||||||
|
Answers.getInstance().logCustom(new CustomEvent("ComboBolusToDbError")
|
||||||
|
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
|
||||||
|
.putCustomAttribute("version", BuildConfig.VERSION)
|
||||||
|
.putCustomAttribute("bolus", "")
|
||||||
|
.putCustomAttribute("issue", "multiple pump history records with the same time and amount"));
|
||||||
|
Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.gs(R.string.
|
||||||
|
combo_error_multiple_boluses_with_idential_timestamp), Notification.URGENT);
|
||||||
|
MainApp.bus().post(new EventNewNotification(notification));
|
||||||
|
}
|
||||||
|
|
||||||
pumpHistoryChanged = updateDbFromPumpHistory(historyResult.history);
|
pumpHistoryChanged = updateDbFromPumpHistory(historyResult.history);
|
||||||
if (pumpHistoryChanged) {
|
if (pumpHistoryChanged) {
|
||||||
log.debug("Setting 'pumpHistoryChanged' true");
|
log.debug("Setting 'pumpHistoryChanged' true");
|
||||||
|
|
Loading…
Reference in a new issue