From a1bbf292308ff19d5862012e106aa408288c987e Mon Sep 17 00:00:00 2001 From: Andy Rozman Date: Mon, 12 Aug 2019 17:20:38 +0100 Subject: [PATCH] - added check before bolus is attempted, if we have enough in reservoir (from local info, we don't query the pump, while this might not always be 100% correct, it is updated every hour (if under 50 U and every 4h if over 50U and every 15 minutes if under 20U, so it should be accurate, information is not accurate only if you cancel bolus midway... --- .../plugins/pump/medtronic/MedtronicPumpPlugin.java | 11 +++++++++++ app/src/main/res/values/strings.xml | 1 + 2 files changed, 12 insertions(+) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java index 064ad3b1e0..1e46fecf61 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java @@ -791,6 +791,17 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter setRefreshButtonEnabled(false); + MedtronicPumpStatus mdtPumpStatus = getMDTPumpStatus(); + + if (detailedBolusInfo.insulin > mdtPumpStatus.reservoirRemainingUnits) { + return new PumpEnactResult() // + .success(false) // + .enacted(false) // + .comment(MainApp.gs(R.string.medtronic_cmd_bolus_could_not_be_delivered_no_insulin, + mdtPumpStatus.reservoirRemainingUnits, + detailedBolusInfo.insulin)); + } + bolusDeliveryType = BolusDeliveryType.DeliveryPrepared; if (isPumpNotReachable()) { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0c03b2d54b..c2cf9a9c0f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1637,6 +1637,7 @@ Could not cancel current TBR. Stopping operation. Profile set failed, because following patterns, have too big basal rate: %1$s Bolus could not be delivered. + Bolus could not be delivered, because available amount (%1$d) is less than Bolus required (%2$d). TBR could not be set. Could not cancel current TBR. Basal profile could not be set.