Loop icon indicating copy to clipboard operation
Loop copied to clipboard

Modify handling of carbs entered at the same Hour and Minute

Open marionbarker opened this issue 1 year ago • 4 comments

Is your feature request related to a problem? Please describe.

  • If more than one carb entry has the same time-stamp in HH:mm, the ordering in Loop depends on the sec and msec at which the entry was entered.
  • When uploading to Nightscout, if more than one entry has the same HH:mm:ss timestamp, only one is saved in Nightscout, the other is removed.
  • The odds of a remote carb entry with the same HH:mm selection vanishing from Nightscout is 1 in 1 if the Nightscout Careportal is used and 1 in 60 if the LoopCaregiver UI is used.
  • Similarly, the odds of a Loop UI entered carb entry vanishing from Nightscout is 1 in 60 when the same HH:mm time is selected in the time picker.

Describe the solution you'd like Possible solution:

  • For each new carb entry, determine if an existing entry has the same HH:mm time, if so, modify the time of the new entry to be one sec later than the latest existing entry in the HH:mm interval
    • Nightscout will then report every carb entry as a treatment instead of possibly discarding one
  • Another advantage of this proposed solution is that if someone choses to make 2 (or more entries) for the same meal with different absorption times, the order of the displayed carbs will match order of entry

Additional context This issue with the way Nightscout handles carb entries (see https://github.com/nightscout/cgm-remote-monitor/issues/8185) was discovered by someone using remote carb entries, but it also happens when entering carbs in Loop UI itself.

Test Case:

  1. Enter carb values repeatedly in the Loop UI with different values and absorptions times.
    • First add a 10 U non-pump bolus so no bolus is recommended after each carb entry
    • Then add 1, 2, 3, 4 and 5 U entries with 3 hours absorption using the same entry time of 13:00 on the time picker
    • Repeat the 1-5 for 30 min absorption, then 5 hour absorption and then 1 hour absorption times
  2. Twenty entries was enough to hit the 1 in 60 chance two times

The display order of the entries does not match the entry order because of different seconds in the 13:00 saved timestamp.

  • Loop has all 20 entries (left side of graphic)
  • Nightscout has only 18 entries (right side of graphic)

carb-order-and-ns-issue

marionbarker avatar Feb 20 '24 22:02 marionbarker