Fix adding a partial bolus to treatments.
This commit is contained in:
parent
b32351145a
commit
c62ca89931
|
@ -538,7 +538,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
// a connection problem, ruffyscripter tried to recover and we can just check the
|
// a connection problem, ruffyscripter tried to recover and we can just check the
|
||||||
// history below to see what was actually delivered
|
// history below to see what was actually delivered
|
||||||
|
|
||||||
// get last bolus from pump histqry for verification
|
// get last bolus from pump history for verification
|
||||||
CommandResult postBolusStateResult = runCommand(null, 3, ruffyScripter::readQuickInfo);
|
CommandResult postBolusStateResult = runCommand(null, 3, ruffyScripter::readQuickInfo);
|
||||||
if (!postBolusStateResult.success) {
|
if (!postBolusStateResult.success) {
|
||||||
return new PumpEnactResult().success(false).enacted(false)
|
return new PumpEnactResult().success(false).enacted(false)
|
||||||
|
@ -571,7 +571,8 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
return new PumpEnactResult().success(true).enacted(true);
|
return new PumpEnactResult().success(true).enacted(true);
|
||||||
}
|
}
|
||||||
return new PumpEnactResult().success(false).enacted(true)
|
return new PumpEnactResult().success(false).enacted(true)
|
||||||
.comment(MainApp.gs(R.string.combo_error_partial_bolus_delivered));
|
.comment(MainApp.gs(R.string.combo_error_partial_bolus_delivered,
|
||||||
|
lastPumpBolus.amount, detailedBolusInfo.insulin));
|
||||||
}
|
}
|
||||||
|
|
||||||
// full bolus was delivered successfully
|
// full bolus was delivered successfully
|
||||||
|
@ -594,15 +595,16 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
* but if they do, the user should be warned since a bolus will be missing from calculations.
|
* but if they do, the user should be warned since a bolus will be missing from calculations.
|
||||||
*/
|
*/
|
||||||
private boolean addBolusToTreatments(DetailedBolusInfo detailedBolusInfo, Bolus lastPumpBolus) {
|
private boolean addBolusToTreatments(DetailedBolusInfo detailedBolusInfo, Bolus lastPumpBolus) {
|
||||||
detailedBolusInfo.date = calculateFakeBolusDate(lastPumpBolus);
|
DetailedBolusInfo dbi = detailedBolusInfo.copy();
|
||||||
detailedBolusInfo.pumpId = calculateFakeBolusDate(lastPumpBolus);
|
dbi.date = calculateFakeBolusDate(lastPumpBolus);
|
||||||
detailedBolusInfo.source = Source.PUMP;
|
dbi.pumpId = calculateFakeBolusDate(lastPumpBolus);
|
||||||
detailedBolusInfo.insulin = lastPumpBolus.amount;
|
dbi.source = Source.PUMP;
|
||||||
|
dbi.insulin = lastPumpBolus.amount;
|
||||||
try {
|
try {
|
||||||
boolean treatmentCreated = MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
|
boolean treatmentCreated = MainApp.getConfigBuilder().addToHistoryTreatment(dbi);
|
||||||
if (!treatmentCreated) {
|
if (!treatmentCreated) {
|
||||||
log.error("Adding treatment record overrode an existing necord: " + detailedBolusInfo);
|
log.error("Adding treatment record overrode an existing record: " + dbi);
|
||||||
if (detailedBolusInfo.isSMB) {
|
if (dbi.isSMB) {
|
||||||
Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.sResources.getString(R.string.combo_error_updating_treatment_record), Notification.URGENT);
|
Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.sResources.getString(R.string.combo_error_updating_treatment_record), Notification.URGENT);
|
||||||
MainApp.bus().post(new EventNewNotification(notification));
|
MainApp.bus().post(new EventNewNotification(notification));
|
||||||
}
|
}
|
||||||
|
@ -610,7 +612,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Adding treatment record failed", e);
|
log.error("Adding treatment record failed", e);
|
||||||
if (detailedBolusInfo.isSMB) {
|
if (dbi.isSMB) {
|
||||||
Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.sResources.getString(R.string.combo_error_updating_treatment_record), Notification.URGENT);
|
Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, MainApp.sResources.getString(R.string.combo_error_updating_treatment_record), Notification.URGENT);
|
||||||
MainApp.bus().post(new EventNewNotification(notification));
|
MainApp.bus().post(new EventNewNotification(notification));
|
||||||
}
|
}
|
||||||
|
|
|
@ -834,7 +834,7 @@
|
||||||
<string name="combo_pump_unsupported_operation">Requested operation not supported by pump</string>
|
<string name="combo_pump_unsupported_operation">Requested operation not supported by pump</string>
|
||||||
<string name="combo_low_suspend_forced_notification">Unsafe usage: extended or multiwave boluses are active. Loop mode has been set to low-suspend only 6 hours. Only normal boluses are supported in loop mode</string>
|
<string name="combo_low_suspend_forced_notification">Unsafe usage: extended or multiwave boluses are active. Loop mode has been set to low-suspend only 6 hours. Only normal boluses are supported in loop mode</string>
|
||||||
<string name="combo_force_disabled_notification">Unsafe usage: the pump uses a different basal rate profile than the first. The loop has been disabled. Select the first profile on the pump and refresh.</string>
|
<string name="combo_force_disabled_notification">Unsafe usage: the pump uses a different basal rate profile than the first. The loop has been disabled. Select the first profile on the pump and refresh.</string>
|
||||||
<string name="bolus_frequency_exceeded">A bolus with the same amount was requested within the last minute. To prevent accidental double boluses and to guard against bugs this is disallowed.</string>
|
<string name="bolus_frequency_exceeded">A bolus with the same amount was requested within the last two minutes. To prevent accidental double boluses and to guard against bugs this is disallowed.</string>
|
||||||
<string name="combo_pump_connected_now">Now</string>
|
<string name="combo_pump_connected_now">Now</string>
|
||||||
<string name="combo_activity_reading_pump_history">Reading pump history</string>
|
<string name="combo_activity_reading_pump_history">Reading pump history</string>
|
||||||
<string name="danar_history">pump history</string>
|
<string name="danar_history">pump history</string>
|
||||||
|
|
Loading…
Reference in a new issue