Skip to content

Pending Bolus calculation heuristic is potentially dangerous #273

@trixing

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.

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