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

DRAFT: add safety features: maxCarbEntry, maxAutoIOB #1870

Closed
wants to merge 1 commit into from
Closed

DRAFT: add safety features: maxCarbEntry, maxAutoIOB #1870

wants to merge 1 commit into from

Conversation

marionbarker
Copy link
Contributor

This draft PR addresses

Safety Features added with this draft design:

  • Prevents a single entry of carbs > maxCarbEntry amount
  • Prevents automatic increase of insulin delivery above a user selected maxAutoIOB value

Rather than focusing on how to add new user adjustable settings to Loop and then implementing the functional code that uses them, I took the short-cut of adding them to a Settings Bundle for this Draft PR.

These two settings can be adjusted under iOS->Settings->Loop:

  • maxCarbEntry
  • maxAutoIOB

This code has been tested and does what I expect.

For example:

  1. If user selects maxCarbEntry of 99g, Loop provides the modal message that it cannot accept larger values when attempting to add or edit carbs of 100g or larger.
  2. If user selects maxAutoIOB of 4.0 U, Loop:
    • Does not automatically increase delivery of insulin above 4.0 U, but
    • Allows user to manually enter insulin delivery resulting in an IOB > maxAutoIOB, and
    • Recommended bolus shown to user is not limited by maxAutoIOB

I wasn't sure how to implement logging in DoseMath, so I added some print statements.

Example debug output when a correction would cause IOB to exceed maxAutoIOB:

*** maxAutoIOB Feature enacted in aboveRange
***  Initial minCorrectionUnits  3.73
***  maxAutoIOB, insulinOnBoard, checkMaxAutoIOB  4.0 1.68 -1.41
***  Adjusted minCorrectionUnits  2.32

Code Modifications

  • CarbEntryViewController was modified to read maxCarbEntry from settings and apply it to carb entry/edit action
  • LoopDataManager was modified to read the maxAutoIOB from settings and to pass new optional arguments to functions in DoseMath
  • DoseMath private func insulinCorrection was modified to use new optional arguments
    • Check for maxAutoIOB was added to the aboveRange section
    • Tested for both automatic bolus and temp basal only dosing strategy
  • The other code modifications, i.e., Loop.xcodeproj/project.pbxproj and Settings.bundle folder, will be discarded - these enable the shortcut of targeting the new settings inside the functions that need them

Copy link
Collaborator

@ps2 ps2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These settings should be introduced to the user during onboarding, and available for the user to change in therapy settings along with the other limits.

@marionbarker
Copy link
Contributor Author

I may need help in doing this, but will give it a try.

@ps2
Copy link
Collaborator

ps2 commented Dec 15, 2022

Discussed on zulip. I think this should be split into two different parts. The carb input warning level could be a new configuration item. Max IOB is very strongly related to Max Bolus & Max TB, and it might be possible to simplify there.

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

Successfully merging this pull request may close these issues.

2 participants