alarm on failure to add treatment to db.
This commit is contained in:
parent
658af4bcfd
commit
6ebb13d28d
17 changed files with 34 additions and 22 deletions
|
@ -50,7 +50,7 @@ public interface TreatmentsInterface {
|
|||
|
||||
boolean addToHistoryExtendedBolus(ExtendedBolus extendedBolus);
|
||||
|
||||
boolean addToHistoryTreatment(DetailedBolusInfo detailedBolusInfo);
|
||||
boolean addToHistoryTreatment(DetailedBolusInfo detailedBolusInfo, boolean allowUpdate);
|
||||
|
||||
TempTarget getTempTargetFromHistory();
|
||||
TempTarget getTempTargetFromHistory(long time);
|
||||
|
|
|
@ -270,7 +270,7 @@ public class NewInsulinDialog extends DialogFragment implements OnClickListener
|
|||
detailedBolusInfo.notes = notes;
|
||||
if (recordOnlyCheckbox.isChecked()) {
|
||||
detailedBolusInfo.date = time;
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo);
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false);
|
||||
} else {
|
||||
detailedBolusInfo.date = now();
|
||||
ConfigBuilderPlugin.getCommandQueue().bolus(detailedBolusInfo, new Callback() {
|
||||
|
|
|
@ -25,7 +25,6 @@ import org.slf4j.LoggerFactory;
|
|||
import java.text.DecimalFormat;
|
||||
import java.util.Objects;
|
||||
|
||||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||
|
@ -187,7 +186,7 @@ public class NewTreatmentDialog extends DialogFragment implements OnClickListene
|
|||
}
|
||||
});
|
||||
} else {
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo);
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false);
|
||||
}
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("Bolus"));
|
||||
}
|
||||
|
|
|
@ -389,7 +389,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
|||
}
|
||||
});
|
||||
} else {
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo);
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false);
|
||||
}
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("Wizard"));
|
||||
}
|
||||
|
|
|
@ -878,7 +878,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
}
|
||||
});
|
||||
} else {
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo);
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false);
|
||||
}
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("QuickWizard"));
|
||||
}
|
||||
|
|
|
@ -199,7 +199,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
|
|||
log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered);
|
||||
detailedBolusInfo.insulin = t.insulin;
|
||||
detailedBolusInfo.date = System.currentTimeMillis();
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo);
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false);
|
||||
return result;
|
||||
} else {
|
||||
PumpEnactResult result = new PumpEnactResult();
|
||||
|
|
|
@ -202,7 +202,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
|
|||
log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered);
|
||||
detailedBolusInfo.insulin = t.insulin;
|
||||
detailedBolusInfo.date = System.currentTimeMillis();
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo);
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false);
|
||||
return result;
|
||||
} else {
|
||||
PumpEnactResult result = new PumpEnactResult();
|
||||
|
|
|
@ -133,14 +133,14 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
|
|||
break;
|
||||
case DanaRPump.BOLUS:
|
||||
detailedBolusInfo.insulin = param1 / 100d;
|
||||
boolean newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo);
|
||||
boolean newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false);
|
||||
log.debug((newRecord ? "**NEW** " : "") + "EVENT BOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min");
|
||||
DetailedBolusInfoStorage.remove(detailedBolusInfo.date);
|
||||
status = "BOLUS " + DateUtil.timeString(datetime);
|
||||
break;
|
||||
case DanaRPump.DUALBOLUS:
|
||||
detailedBolusInfo.insulin = param1 / 100d;
|
||||
newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo);
|
||||
newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false);
|
||||
log.debug((newRecord ? "**NEW** " : "") + "EVENT DUALBOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min");
|
||||
DetailedBolusInfoStorage.remove(detailedBolusInfo.date);
|
||||
status = "DUALBOLUS " + DateUtil.timeString(datetime);
|
||||
|
@ -183,7 +183,7 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
|
|||
emptyCarbsInfo.date = datetime.getTime();
|
||||
emptyCarbsInfo.source = Source.PUMP;
|
||||
emptyCarbsInfo.pumpId = datetime.getTime();
|
||||
newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(emptyCarbsInfo);
|
||||
newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(emptyCarbsInfo, false);
|
||||
log.debug((newRecord ? "**NEW** " : "") + "EVENT CARBS (" + recordCode + ") " + datetime.toLocaleString() + " Carbs: " + param1 + "g");
|
||||
status = "CARBS " + DateUtil.timeString(datetime);
|
||||
break;
|
||||
|
|
|
@ -107,14 +107,14 @@ public class MsgHistoryEvents_v2 extends MessageBase {
|
|||
break;
|
||||
case DanaRPump.BOLUS:
|
||||
detailedBolusInfo.insulin = param1 / 100d;
|
||||
boolean newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo);
|
||||
boolean newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false);
|
||||
log.debug((newRecord ? "**NEW** " : "") + "EVENT BOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min");
|
||||
DetailedBolusInfoStorage.remove(detailedBolusInfo.date);
|
||||
status = "BOLUS " + DateUtil.timeString(datetime);
|
||||
break;
|
||||
case DanaRPump.DUALBOLUS:
|
||||
detailedBolusInfo.insulin = param1 / 100d;
|
||||
newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo);
|
||||
newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false);
|
||||
log.debug((newRecord ? "**NEW** " : "") + "EVENT DUALBOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min");
|
||||
DetailedBolusInfoStorage.remove(detailedBolusInfo.date);
|
||||
status = "DUALBOLUS " + DateUtil.timeString(datetime);
|
||||
|
@ -157,7 +157,7 @@ public class MsgHistoryEvents_v2 extends MessageBase {
|
|||
emptyCarbsInfo.date = datetime.getTime();
|
||||
emptyCarbsInfo.source = Source.PUMP;
|
||||
emptyCarbsInfo.pumpId = datetime.getTime();
|
||||
newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(emptyCarbsInfo);
|
||||
newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(emptyCarbsInfo, false);
|
||||
log.debug((newRecord ? "**NEW** " : "") + "EVENT CARBS (" + recordCode + ") " + datetime.toLocaleString() + " Carbs: " + param1 + "g");
|
||||
status = "CARBS " + DateUtil.timeString(datetime);
|
||||
break;
|
||||
|
|
|
@ -61,7 +61,6 @@ import sugar.free.sightparser.applayer.descriptors.configuration_blocks.BRProfil
|
|||
import sugar.free.sightparser.applayer.messages.AppLayerMessage;
|
||||
import sugar.free.sightparser.applayer.messages.remote_control.BolusMessage;
|
||||
import sugar.free.sightparser.applayer.messages.remote_control.CancelBolusMessage;
|
||||
import sugar.free.sightparser.applayer.messages.remote_control.CancelTBRMessage;
|
||||
import sugar.free.sightparser.applayer.messages.remote_control.ExtendedBolusMessage;
|
||||
import sugar.free.sightparser.applayer.messages.remote_control.StandardBolusMessage;
|
||||
import sugar.free.sightparser.applayer.messages.status.ActiveBolusesMessage;
|
||||
|
@ -456,7 +455,7 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
|
|||
bolusingEvent.bolusId = bolusId;
|
||||
bolusingEvent.percent = 0;
|
||||
MainApp.bus().post(bolusingEvent);
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo);
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false);
|
||||
} else {
|
||||
log.debug("Failure to deliver treatment");
|
||||
}
|
||||
|
|
|
@ -83,6 +83,6 @@ class HistoryLogAdapter {
|
|||
detailedBolusInfo.source = Source.PUMP;
|
||||
detailedBolusInfo.pumpId = record_id;
|
||||
detailedBolusInfo.insulin = insulin;
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo);
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -136,7 +136,7 @@ public class MDIPlugin extends PluginBase implements PumpInterface {
|
|||
result.bolusDelivered = detailedBolusInfo.insulin;
|
||||
result.carbsDelivered = detailedBolusInfo.carbs;
|
||||
result.comment = MainApp.gs(R.string.virtualpump_resultok);
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo);
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -226,7 +226,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
|||
log.debug("Delivering treatment insulin: " + detailedBolusInfo.insulin + "U carbs: " + detailedBolusInfo.carbs + "g " + result);
|
||||
MainApp.bus().post(new EventVirtualPumpUpdateGui());
|
||||
lastDataTime = new Date();
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo);
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ public class CarbsGenerator {
|
|||
}
|
||||
});
|
||||
} else {
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(carbInfo);
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(carbInfo, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package info.nightscout.androidaps.plugins.Treatments;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
@ -38,6 +39,7 @@ import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
|||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||
import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
||||
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||
import info.nightscout.androidaps.plugins.Sensitivity.SensitivityAAPSPlugin;
|
||||
|
@ -465,7 +467,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
|||
|
||||
// return true if new record is created
|
||||
@Override
|
||||
public boolean addToHistoryTreatment(DetailedBolusInfo detailedBolusInfo) {
|
||||
public boolean addToHistoryTreatment(DetailedBolusInfo detailedBolusInfo, boolean allowUpdate) {
|
||||
Treatment treatment = new Treatment();
|
||||
treatment.date = detailedBolusInfo.date;
|
||||
treatment.source = detailedBolusInfo.source;
|
||||
|
@ -491,6 +493,16 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
|||
}
|
||||
if (newRecordCreated && detailedBolusInfo.isValid)
|
||||
NSUpload.uploadTreatmentRecord(detailedBolusInfo);
|
||||
|
||||
if (!allowUpdate && !newRecordCreated) {
|
||||
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
|
||||
i.putExtra("soundid", R.raw.error);
|
||||
i.putExtra("status", MainApp.gs(R.string.error_adding_treatment_message));
|
||||
i.putExtra("title", MainApp.gs(R.string.error_adding_treatment_title));
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
MainApp.instance().startActivity(i);
|
||||
}
|
||||
|
||||
return newRecordCreated;
|
||||
}
|
||||
|
||||
|
|
|
@ -719,7 +719,7 @@ public class ActionStringHandler {
|
|||
}
|
||||
});
|
||||
} else {
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo);
|
||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1179,6 +1179,8 @@
|
|||
<string name="careportal_removestartedevents">Clean AndroidAPS started</string>
|
||||
<string name="storedsettingsfound">Stored settings found</string>
|
||||
<string name="allow_hardware_pump_text">Attention: If you activate and connect to a hardware pump, AndroidAPS will copy the basal settings from the profile to the pump, overwriting the existing basal rate stored on the pump. Make sure you have the correct basal setting in AndroidAPS. If you are not sure or don\'t want to overwrite the basal settings on your pump, press cancel and repeat switching to the pump at a later time.</string>
|
||||
<string name="error_adding_treatment_message">Treatment data incomplete</string>
|
||||
<string name="error_adding_treatment_title">A treatment (insulin:%0.2f, carbs: %2) couldn\'t not be added to treatments. Please check and manually add a record as appropriate.</string>
|
||||
|
||||
<plurals name="objective_days">
|
||||
<item quantity="one">%d day</item>
|
||||
|
|
Loading…
Reference in a new issue