nightscout / Trio

MIT License
45 stars 125 forks source link

Afrezza patch for logging external afrezza in real time #324

Open cwrussellgithub opened 2 weeks ago

cwrussellgithub commented 2 weeks ago

Could a Trio “patch” or “update” be developed, that would allow logging Afrezza (inhaled ultra rapid insulin) in real time?

I really like a previous Loop Dev version wherein I could easily note 4 units Afrezza, and the prediction line was relatively accurate as was the duration of Afrezza in my system. But I LOVE, how forgiving iAPS/Trio is of missed carb entries and generally just relaxing management a bit more… Surely the technology could combine these two things? 🤞😅

Afrezza goes into and out of one’s system a lot more rapidly than any injectables, so I find it extremely helpful for high carb and high glycemic index meals or frustrating highs. But this means that it would need a different insulin model (DIA, insulin activity curve, decay rate, etc.) -but it is such a valuable tool in the diabetes arsenal.

My current technique for attempting to log Afrezza insulin is to log it immediately when I inhale, but change the time stamp to about 30min in the past. This rough approach seems to help iaps anticipate/understand what’s happening… I’ve also read on Facebook that others just don’t log Afrezza doses if they’re for covering meals, but that that could throw off TDD calculations.

I think that adding such a feature would have a drastically beneficial impact for users of Afrezza while being negligible for those who don’t use Afrezza.

MikePlante1 commented 2 weeks ago

This is a tough one because oref is only designed to use a single insulin model. I think Loop 3 rewrote a lot of code so an insulin model is attached to every insulin dose.

Since I think it’ll take a long while before that’s implemented, to keep TDD accurate, I think an easier (but not as good) solution might be automating it so entering a dose of Afrezza into Trio would wait your DIA time before entering the equivalent dose at the time it was taken.

bjornoleh commented 2 weeks ago

@cwrussellgithub , I think just predating the dose as you did is probably a quite good way to handle it for now. We will soon have support for iOS shortcuts in Trio, so then you could easily create a specific shortcut for afreezza that sets the time 30 minutes or so before the time of entry.

Wel, there is no specific shortcut or adding external insulin planned just yet, but it should be possible to add this. Perhaps you will remember to write a specific feature request for that when shortcuts are available?

Tagging @avouspierre for a hint about this 😊

MikePlante1 commented 2 weeks ago

I don't think pre-dating the Afrezza dose by 30 mins works well. I put together a graph using Rapid-acting (360 DIA, 75 peak). Red is normal and blue is pre-dating by 30 minutes. I think this makes way too much IOB remain around for far too long which could cause Trio to under dose after the Afrezza has actually cleared your system in an hour or two.

Screenshot 2024-06-18 at 12 16 15 PM

For reference, Loop uses 300 DIA and 29 peak for Afrezza:

Screenshot 2024-06-18 at 12 22 49 PM
bjornoleh commented 2 weeks ago

Yes I imagine it is not ideal, but perhaps it would work better with a much longer predate? I guess there are not too many other options right now.

cwrussellgithub commented 2 weeks ago

Thank you both for your input and feedback. Can you dispel my ignorance: If I put in a longer/larger predate, such as 1 hour before I inhale, would there be any risk/complications from the algorithm not “detecting” any insulin (BG impact) for another 15-30 min, thus “1hr 15-30min ‘after bolus’”? -Or would the nature of the oref algorithm nullify such concerns?

@MikePlante1, Am I interpreting the the idea of “automating it so entering a dose of Afrezza into Trio would wait your DIA time before entering the equivalent dose at the time it was taken.” as a potential programming/patch development idea for the possible, distant future, or is that something that I could try to do now?

bjornoleh commented 2 weeks ago

I don't think there is much risk in predating something like an hour. The COB/meal history might be impacted, but not so much IOB. With one hour predate, the algorithm would expect the peak effect right now, but the tail of the insulin model would still be longer than the actual Afrezza effect.

I think Mike just suggested that you simply don't enter anything until DIA hours later (6 or more hours), so that there is no insuling effect from the model when you enter it. You could probably make a shortcut for this once there is a possibility of entering external insulin this way.