nightscout / Trio

Trio - an automated insulin delivery system for iOS based on the OpenAPS algorithm with adaptations.
https://docs.diy-trio.org/en/latest/
MIT License
95 stars 484 forks source link

Utilize max bolus limit in Bolus module #73

Closed MikePlante1 closed 6 months ago

MikePlante1 commented 7 months ago

In the bolus module, if bolus amount is set over the Max Bolus set in Pump Settings, disable the Enact bolus button, change it's text to Max Bolus exceeded!, and change alert dialog for external insulin.

If bolus amount is set over 3x Max Bolus, disable the external insulin button as well.

Max Bolus is set to 10U for this test:

underMax1 underMax2 overMax1 overMax2 3xOverMax

Cherry-picked from https://github.com/Artificial-Pancreas/iAPS/commit/581e3e2838f7ee461df8f86c17db06450d49850e and https://github.com/Artificial-Pancreas/iAPS/commit/7c7cafecf2c10b377d329559b851e417c02ebe96 but had to refactor the alert to get it to build

dnzxy commented 7 months ago

Great job.

What do you think about maybe adding a small hint in pump settings (where max bolus is set) that explains the magic number that is 3 x max bolus = max external insulin entry?

@Sjoerd-Bo3 is currently working on adding the external insulin dialog that is found in iAPS 3.x (so not sure if it should be added now or later or not at all).

MikePlante1 commented 6 months ago

What do you think about maybe adding a small hint in pump settings (where max bolus is set) that explains the magic number that is 3 x max bolus = max external insulin entry?

Since popups haven't been implemented in Pump Settings, how about this instead?

Max Bolus exceeded x3!
avouspierre commented 6 months ago

Just the "i" in the suggested insulin could perhaps indicate the maxBolus constraint. Here, 7,76 * 0,7 % = 5.432

CleanShot 2024-04-10 at 08 18 26@2x

avouspierre commented 6 months ago

What do you think about maybe adding a small hint in pump settings (where max bolus is set) that explains the magic number that is 3 x max bolus = max external insulin entry?

Since popups haven't been implemented in Pump Settings, how about this instead?

Max Bolus exceeded x3!

Perhaps to display a read-only text field with "Max delivery insulin" in pump settings with the calculation of *3 ?

Perhaps create a variable in maxDeliveryBolus in pumpSettings object directly defined as 3 of maxBolus avoided to have the magic variable everywhere... like this in pumpsettings struct (not tested) : `extension PumpSettings { var maxDeliveryBolus: Decimal? { return 3.0 self.maxBolus } } `

MikePlante1 commented 6 months ago

Perhaps to display a read-only text field with "Max delivery insulin" in pump settings with the calculation of *3 ?

Perhaps create a variable in maxDeliveryBolus in pumpSettings object directly defined as 3 of maxBolus avoided to have the magic variable everywhere... like this in pumpsettings struct (not tested) : `extension PumpSettings { var maxDeliveryBolus: Decimal? { return 3.0 self.maxBolus } } `

It seems out of place to put external bolus settings into pump settings. What about Preferences > OPENAPS OTHER SETTINGS?

MikePlante1 commented 6 months ago

Accidentally closed this PR, so I reopened it in #100