Skip to content

Pending Bolus calculation heuristic is potentially dangerous #273

Closed

Description

@trixing

In LoopDataManager.swift

Afaict from the code, lastBolus is set if a Bolus has been successfully enacted. In insulinEffect, didSet the lastBolus var is cleared if it is older than 5 minutes.

There seems to be no mechanism which makes sure the Bolus has actually been read from the pump event history (or reservoir data). Hence if this doesn't happen and the user Bolus again there is a potential for going low.

Second issue I see is that if a user bolus' again within the 5 minute window, the last one is silently overwritten. So if let's say the first one is 3 Units, the second one 1 Unit, and the user enters another Carb-Meal, it will only substract the 1 Unit, not 4 Units from the calculated amount.

I'd think there are at least two different ways of fixing this:

  • don't allow Bolus until the full eventHistory (or reservoir state) has been read back again, and a full loop has been completed (most safe probably)
  • record bolus directly in doseStore and replace later, when the pump history has been synced beyond this point.

In any case, this should probably be addressed rather soon if someone can confirm this is actually a problem.

Activity

  1. ruess commented on Nov 22, 2016

    @ruess

    I like the first resolution personally

  2. ps2 commented on Nov 22, 2016

    @ps2
    Collaborator

    It's a bit complicated by the fact that on older (x22) pumps, the record isn't added to the history until the delivery is finished. Add in that older pumps deliver insulin slowly, and you have quite a long time before a bolus is added to the history (tops out at 16minutes on x22 @25u).

    We may need to maintain a list of 'unconfirmed boluses', along with their expected delivery times, to be able to clear them out reliably.

  3. ps2 commented on Nov 22, 2016

    @ps2
    Collaborator

    If we track bolus confirmation more accurately, it should apply to #131

  4. trixing commented on Nov 22, 2016

    @trixing
    Author

    I personally also like the 2nd solution ("unconfirmed bolus'") more because it allows to do accurate additional corrections in the mean time and doesn't block the interface for very long.

  5. ruess commented on Nov 22, 2016

    @ruess

    Makes sense @ps2

  6. elnjensen commented on Aug 8, 2017

    @elnjensen
    Contributor

    Just ran into this (or something quite like it) today. Running Loop v1.4.0. Entered carbs for part of my breakfast, then accepted the bolus recommendation, which delivered successfully. A few minutes later (after bolus was completed, but before it was pulled from pump into history), I entered more carbs, and the bolus recommendation was the amount needed for both sets of carbs, i.e. it was bigger than it should have been by an amount equal to the previous bolus. I noticed it and manually subtracted, but it would be easy for a user to make a mistake here.

    Not sure about the best resolution - one option would be just tracking pending boluses as @ps2 suggested, and either subtract that from recommended bolus, or at least provide that info to the user on the bolus screen.

    If this isn't the same issue, let me know and I'll open a separate one.

  7. loudestnoise commented on Aug 8, 2017

    @loudestnoise

    I actually saw the same thing today. Did a bolus for my main meal, but a few minutes later added more carbs for a cookie and it recommended a bolus that seemed way too big. I ignored it, and decided to bolus a much smaller dose, and thought I should write up an Issue, but yeah +1 for what @elnjensen said

  8. trixing commented on Aug 8, 2017

    @trixing
    Author
  9. elnjensen commented on Nov 11, 2017

    @elnjensen
    Contributor

    Just ran into this again tonight. Entered 30 g carbs, accepted bolus recommendation of 2.15u, saw that bolus was starting. About 7 minutes later, I decided the carb count was a bit low, so I entered 10 g more carbs. (New carb entry, not edit of the old one.) Recommended bolus was 2.75u, and "Active insulin" showed as 0.17u. (I didn't deliver the bolus.) My carb ratio for this period is 10g/u, so that bolus recommendation was clearly for all the carbs, not just the new 10g. About 2 minutes later, the recommended bolus was down to 0.575u, and then showed the active insulin from the previous bolus. So the risk window isn't super long, but it's there.

    I've attached an issue report, plus screenshots of the two bolus recommendations. Let me know if more info is useful.

    Issue report Nov 10, 7 35 51 PM.txt

    img-2472

    img-2473

  10. Kdisimone commented on Oct 19, 2018

    @Kdisimone
    Collaborator

    has anyone had an issue with larger bolus recommendations as described in this issue since updated Loop versions? We have not seen any issues like this for quite a long time...i think the pending boluses have been tracked well for us. Just checking if this issue needs to remain open or is ready to close?

  11. elnjensen commented on Oct 21, 2018

    @elnjensen
    Contributor

    I haven't seen this for a long time either.

  12. Kdisimone commented on Nov 29, 2018

    @Kdisimone
    Collaborator

    Closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions