Copied from https://github.com/nightscout/Trio-dev/issues/325
After we're done with the Swift oref port, we should do two clean ups that will help with the accuracy of the IoB calculation
- Get the actual insulin delivered from LoopKit and feed that, plus non-overlapping pump event histories, to the IoB calculation. This improvement will help simplify the IoB calculation
- We should store insulin type (ie curve) along with each pump event to ensure that each dose is handled correctly even if someone switches between rapid and ultra rapid
Also, there is a lot of overlap with the calculations that are happening with TDD, we should create a pump history utility that does common cleaning / processing that both TDD and IoB need so that we have it in one place.
Finally, the Javascript IoB implementation has a number of small but common bugs that result in it calculating the core algorithm incorrectly. Specifically:
- If a tempBasal is longer than 30 minutes and has a profile basal rate change in the middle, it will miss this split resulting in incorrect insulin calculations.
- When splitting events, it uses minutes instead of seconds or milliseconds to calculate durations, which can lead to incorrect durations.
These seem like small issues, and they are, but I have seen both in my data over a few days of running.
Copied from https://github.com/nightscout/Trio-dev/issues/325
After we're done with the Swift oref port, we should do two clean ups that will help with the accuracy of the IoB calculation
Also, there is a lot of overlap with the calculations that are happening with TDD, we should create a pump history utility that does common cleaning / processing that both TDD and IoB need so that we have it in one place.
Finally, the Javascript IoB implementation has a number of small but common bugs that result in it calculating the core algorithm incorrectly. Specifically:
These seem like small issues, and they are, but I have seen both in my data over a few days of running.