better detect meal bolus

This commit is contained in:
Milos Kozak 2017-01-08 16:57:05 +01:00
parent 68a127d804
commit aa24a592fa

View file

@ -480,8 +480,16 @@ public class DataService extends IntentService {
treatment.created_at = new Date(trJson.getLong("mills")); treatment.created_at = new Date(trJson.getLong("mills"));
if (trJson.has("eventType")) { if (trJson.has("eventType")) {
treatment.mealBolus = true; treatment.mealBolus = true;
if (trJson.get("eventType").equals("Correction Bolus")) treatment.mealBolus = false; if (trJson.get("eventType").equals("Correction Bolus"))
if (trJson.get("eventType").equals("Bolus Wizard") && treatment.carbs <= 0) 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.mealBolus = false;
} }
treatment.setTimeIndex(treatment.getTimeIndex()); treatment.setTimeIndex(treatment.getTimeIndex());
@ -532,8 +540,16 @@ public class DataService extends IntentService {
treatment.created_at = new Date(trJson.getLong("mills")); treatment.created_at = new Date(trJson.getLong("mills"));
if (trJson.has("eventType")) { if (trJson.has("eventType")) {
treatment.mealBolus = true; treatment.mealBolus = true;
if (trJson.get("eventType").equals("Correction Bolus")) treatment.mealBolus = false; if (trJson.get("eventType").equals("Correction Bolus"))
if (trJson.get("eventType").equals("Bolus Wizard") && treatment.carbs <= 0) 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.mealBolus = false;
} }
treatment.setTimeIndex(treatment.getTimeIndex()); treatment.setTimeIndex(treatment.getTimeIndex());