Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pending Bolus calculation heuristic is potentially dangerous #273

Closed
trixing opened this issue Nov 21, 2016 · 12 comments
Closed

Pending Bolus calculation heuristic is potentially dangerous #273

trixing opened this issue Nov 21, 2016 · 12 comments

Comments

@trixing
Copy link

trixing commented Nov 21, 2016

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.

@ruess
Copy link

ruess commented Nov 22, 2016

I like the first resolution personally

@ps2
Copy link
Collaborator

ps2 commented Nov 22, 2016

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.

@ps2
Copy link
Collaborator

ps2 commented Nov 22, 2016

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

@trixing
Copy link
Author

trixing commented Nov 22, 2016

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.

@ruess
Copy link

ruess commented Nov 22, 2016

Makes sense @ps2

@elnjensen
Copy link
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.

@loudestnoise
Copy link

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

@trixing
Copy link
Author

trixing commented Aug 8, 2017 via email

@ps2 ps2 mentioned this issue Sep 20, 2017
@elnjensen
Copy link
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

@Kdisimone
Copy link
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?

@elnjensen
Copy link
Contributor

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

@Kdisimone
Copy link
Collaborator

Closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants