Best effort to handle multiple boluses within the same minute.
(cherry picked from commit cc9094f)
This commit is contained in:
parent
3a95c3c4d9
commit
bd87a893c2
4 changed files with 14 additions and 10 deletions
|
@ -490,10 +490,12 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private PumpEnactResult deliverBolus(final DetailedBolusInfo detailedBolusInfo) {
|
private PumpEnactResult deliverBolus(final DetailedBolusInfo detailedBolusInfo) {
|
||||||
// guard against boluses issued multiple times within a minute
|
// Guard against boluses issued multiple times within two minutes.
|
||||||
|
// Two minutes, so that the resulting timestamp and bolus are different with the Combo
|
||||||
|
// history records which only store with minute-precision
|
||||||
if (lastRequestedBolus != null
|
if (lastRequestedBolus != null
|
||||||
&& Math.abs(lastRequestedBolus.amount - detailedBolusInfo.insulin) < 0.01
|
&& Math.abs(lastRequestedBolus.amount - detailedBolusInfo.insulin) < 0.01
|
||||||
&& lastRequestedBolus.timestamp + 60 * 1000 > System.currentTimeMillis()) {
|
&& lastRequestedBolus.timestamp + 120 * 1000 > System.currentTimeMillis()) {
|
||||||
log.error("Bolus delivery failure at stage 0", new Exception());
|
log.error("Bolus delivery failure at stage 0", new Exception());
|
||||||
return new PumpEnactResult().success(false).enacted(false)
|
return new PumpEnactResult().success(false).enacted(false)
|
||||||
.comment(MainApp.gs(R.string.bolus_frequency_exceeded));
|
.comment(MainApp.gs(R.string.bolus_frequency_exceeded));
|
||||||
|
@ -557,9 +559,9 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
.comment(MainApp.gs(R.string.combo_error_partial_bolus_delivered));
|
.comment(MainApp.gs(R.string.combo_error_partial_bolus_delivered));
|
||||||
}
|
}
|
||||||
|
|
||||||
// seems we actually made it ...
|
// seems we actually made it this far, let's add a treatment record
|
||||||
detailedBolusInfo.date = lastBolus.timestamp;
|
detailedBolusInfo.date = lastBolus.timestamp + (Math.min((int) lastBolus.amount * 10 * 1000, 59 * 1000));
|
||||||
detailedBolusInfo.pumpId = lastBolus.timestamp + ((int) lastBolus.amount * 10);
|
detailedBolusInfo.pumpId = lastBolus.timestamp + (Math.min((int) lastBolus.amount * 10 * 1000, 59 * 1000));
|
||||||
detailedBolusInfo.source = Source.PUMP;
|
detailedBolusInfo.source = Source.PUMP;
|
||||||
detailedBolusInfo.insulin = lastBolus.amount;
|
detailedBolusInfo.insulin = lastBolus.amount;
|
||||||
boolean treatmentCreated = MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
|
boolean treatmentCreated = MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
|
||||||
|
@ -955,8 +957,8 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
// Bolus
|
// Bolus
|
||||||
for (Bolus pumpBolus : history.bolusHistory) {
|
for (Bolus pumpBolus : history.bolusHistory) {
|
||||||
DetailedBolusInfo dbi = new DetailedBolusInfo();
|
DetailedBolusInfo dbi = new DetailedBolusInfo();
|
||||||
dbi.date = pumpBolus.timestamp;
|
dbi.date = pumpBolus.timestamp + (Math.min((int) pumpBolus.amount * 10 * 1000, 59 * 1000));
|
||||||
dbi.pumpId = pumpBolus.timestamp + ((int) pumpBolus.amount * 10);
|
dbi.pumpId = pumpBolus.timestamp + (Math.min((int) pumpBolus.amount * 10 * 1000, 59 * 1000));
|
||||||
dbi.source = Source.PUMP;
|
dbi.source = Source.PUMP;
|
||||||
dbi.insulin = pumpBolus.amount;
|
dbi.insulin = pumpBolus.amount;
|
||||||
dbi.eventType = CareportalEvent.CORRECTIONBOLUS;
|
dbi.eventType = CareportalEvent.CORRECTIONBOLUS;
|
||||||
|
|
|
@ -780,4 +780,6 @@
|
||||||
<string name="openapsama_link_to_preferncejson_doc_txt">Achtung! Normalerweise musst Du diese Werte nicht ändern. Bitte KLICKE HIER und LESE den Text. Verändere Werte erst, wenn Du den Inhalt des Textes verstanden hast.</string>
|
<string name="openapsama_link_to_preferncejson_doc_txt">Achtung! Normalerweise musst Du diese Werte nicht ändern. Bitte KLICKE HIER und LESE den Text. Verändere Werte erst, wenn Du den Inhalt des Textes verstanden hast.</string>
|
||||||
<string name="pump_basebasalrate">%.2f IE/h</string>
|
<string name="pump_basebasalrate">%.2f IE/h</string>
|
||||||
<string name="combo_actvity_reading_basal_profile">Basalratenprofil wird gelesen</string>
|
<string name="combo_actvity_reading_basal_profile">Basalratenprofil wird gelesen</string>
|
||||||
|
<string name="pump_basebasalrate">%.2f IE/h</string>
|
||||||
|
<string name="urgent_alarm">Dringender Alarm</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -229,7 +229,7 @@
|
||||||
<string name="waitingforpumpresult">Esperando resultado</string>
|
<string name="waitingforpumpresult">Esperando resultado</string>
|
||||||
<string name="smscommunicator_allowednumbers">Números de teléfono permitidos</string>
|
<string name="smscommunicator_allowednumbers">Números de teléfono permitidos</string>
|
||||||
<string name="smscommunicator_allowednumbers_summary">XXXXXXXXXX +; + YYYYYYYYYY</string>
|
<string name="smscommunicator_allowednumbers_summary">XXXXXXXXXX +; + YYYYYYYYYY</string>
|
||||||
<string formatted="false" name="smscommunicator_bolusreplywithcode">Para entregar bolo% .2fU responder con código% s</string>
|
<string formatted="false" name="smscommunicator_bolusreplywithcode">Para entregar bolo %.2fU responder con código% s</string>
|
||||||
<string name="smscommunicator_bolusfailed">Bolo falló</string>
|
<string name="smscommunicator_bolusfailed">Bolo falló</string>
|
||||||
<string formatted="false" name="bolusdelivered">Bolo %.2fU entregado con éxito</string>
|
<string formatted="false" name="bolusdelivered">Bolo %.2fU entregado con éxito</string>
|
||||||
<string formatted="false" name="bolusdelivering">Entregando %.2fU</string>
|
<string formatted="false" name="bolusdelivering">Entregando %.2fU</string>
|
||||||
|
|
|
@ -866,7 +866,7 @@
|
||||||
<string name="extendedbolusdeliveryerror">Extended bolus delivery error</string>
|
<string name="extendedbolusdeliveryerror">Extended bolus delivery error</string>
|
||||||
<string name="pump_basebasalrate">%.2f U/h</string>
|
<string name="pump_basebasalrate">%.2f U/h</string>
|
||||||
<string name="combo_actvity_reading_basal_profile">Reading basal profile</string>
|
<string name="combo_actvity_reading_basal_profile">Reading basal profile</string>
|
||||||
<string name="combo_bolus_rejected_due_to_pump_history_change">The pump history has changed after the bolus calculation was performed. The bolus was not delivered. Please recalculate if a bolus is still needed. If the same bolus amount is required, please wait a minute since boluses with the same amount are blocked when requested within the same minute for saftery (regardless of whether they were administered or not).</string>
|
<string name="combo_bolus_rejected_due_to_pump_history_change">The pump history has changed after the bolus calculation was performed. The bolus was not delivered. Please recalculate if a bolus is still needed. If the same bolus amount is required, please wait a minute since boluses with the same amount are blocked when requested with less than tow minutes between them for safety (regardless of whether they were administered or not).</string>
|
||||||
<string name="combo_error_updating_treatment_record">Bolus successfully delivered, but adding the treatment entry failed. This can happen if two small boluses of the same size are administered within the same minute. Please check the pump history and treatment entries and use the Careportal to add missing entries. Make sure not to add any entries for the exact same minute.</string>
|
<string name="combo_error_updating_treatment_record">Bolus successfully delivered, but adding the treatment entry failed. This can happen if two small boluses of the same size are administered within the last two minutes. Please check the pump history and treatment entries and use the Careportal to add missing entries. Make sure not to add any entries for the exact same minute and same amount.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue