From aa24a592fa4599b4a0708e6c8d5ee9d2d9b63baf Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 8 Jan 2017 16:57:05 +0100 Subject: [PATCH] better detect meal bolus --- .../androidaps/Services/DataService.java | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/Services/DataService.java b/app/src/main/java/info/nightscout/androidaps/Services/DataService.java index 7ba381f130..0d809bb6d9 100644 --- a/app/src/main/java/info/nightscout/androidaps/Services/DataService.java +++ b/app/src/main/java/info/nightscout/androidaps/Services/DataService.java @@ -480,8 +480,16 @@ public class DataService extends IntentService { treatment.created_at = new Date(trJson.getLong("mills")); if (trJson.has("eventType")) { treatment.mealBolus = true; - if (trJson.get("eventType").equals("Correction Bolus")) treatment.mealBolus = false; - if (trJson.get("eventType").equals("Bolus Wizard") && treatment.carbs <= 0) + if (trJson.get("eventType").equals("Correction Bolus")) + treatment.mealBolus = false; + double carbs = treatment.carbs; + if (trJson.has("boluscalc")) { + JSONObject boluscalc = trJson.getJSONObject("boluscalc"); + if (boluscalc.has("carbs")) { + carbs = Math.max(boluscalc.getDouble("carbs"), carbs); + } + } + if (carbs <= 0) treatment.mealBolus = false; } treatment.setTimeIndex(treatment.getTimeIndex()); @@ -532,8 +540,16 @@ public class DataService extends IntentService { treatment.created_at = new Date(trJson.getLong("mills")); if (trJson.has("eventType")) { treatment.mealBolus = true; - if (trJson.get("eventType").equals("Correction Bolus")) treatment.mealBolus = false; - if (trJson.get("eventType").equals("Bolus Wizard") && treatment.carbs <= 0) + if (trJson.get("eventType").equals("Correction Bolus")) + treatment.mealBolus = false; + double carbs = treatment.carbs; + if (trJson.has("boluscalc")) { + JSONObject boluscalc = trJson.getJSONObject("boluscalc"); + if (boluscalc.has("carbs")) { + carbs = Math.max(boluscalc.getDouble("carbs"), carbs); + } + } + if (carbs <= 0) treatment.mealBolus = false; } treatment.setTimeIndex(treatment.getTimeIndex());