feat: Add Afrezza (Technosphere) inhaled insulin support#4877
Conversation
Add string resources for Afrezza (Technosphere) inhaled insulin support: - core/interfaces: insulin type label and description - core/ui: navigation label and treatment description - ui: Afrezza quick-log dialog strings
- Add OREF_INHALED_AFREZZA enum entry (peak=40min, DIA=2.5h, value=6) - Add isInhaled property to InsulinType for delivery route identification - Add MIN_DIA_INHALED/MAX_DIA_INHALED to HardLimits (1.5h-4.0h range) - Add minDiaInhaled()/maxDiaInhaled() to HardLimits interface, impl, and test mock Afrezza (Technosphere) pharmacokinetics: onset ~12min, peak ~40min, clinical duration 1.5-3h depending on cartridge size (4U/8U/12U). Conservative DIA of 2.5h covers the majority of insulin activity.
- Add OREF_INHALED_AFREZZA to insulinTemplateList() in InsulinImpl - Update InsulinManagementViewModel to use inhaled DIA limits (1.5-4.0h) when the editor template is an inhaled insulin type - Make diaRange() template-aware so the UI slider shows correct bounds - Subcutaneous insulin DIA limits (5.0-9.0h) remain unchanged
Comprehensive test suite validating the oref bilinear model at Afrezza's short DIA (2.5h) and early peak (40min): - IOB starts near 1.0 at t=0 and reaches 0 at t=DIA - No NaN or negative values across entire curve - Peak activity occurs near configured peak time (40min) - Monotonic IOB decrease after peak - Afrezza IOB decays faster than Fiasp (comparative) - Dose scaling correct for cartridge sizes (4U/8U/12U) - Combined Afrezza+Fiasp IOB sums correctly, with Afrezza dropping to zero while Fiasp remains active
New Compose bottom sheet dialog with three large cartridge-size buttons (4U, 8U, 12U) for rapid Afrezza dose logging: - AfrezzaDialogScreen: Bottom sheet with cartridge selection UI - AfrezzaDialogViewModel: Resolves Afrezza ICfg from InsulinManager, creates record-only bolus with correct per-bolus ICfg - AfrezzaDialogUiState: Minimal state for cartridge selection flow User flow: tap cartridge -> confirm -> done (2 taps total). Bolus is created as record-only with Afrezza ICfg, ensuring the IOB calculator uses the correct short-DIA curve.
- Add ElementType.AFREZZA with TREATMENT category and BOLUS protection - Map Afrezza icon (IcBolus), color (insulin), label, and description - Afrezza appears in global search and treatment action sheets
- Add AppRoute.AfrezzaDialog route definition - Register AfrezzaDialogScreen composable in AppNavGraph - Add ElementType.AFREZZA -> AfrezzaDialog navigation handler - Add QuickLaunchAction.Afrezza static action and to staticActions list - Users can add Afrezza to their quick-launch bar via configuration
- Add showAfrezza to TreatmentUiState - Inject InsulinManager into TreatmentViewModel to detect configured inhaled insulin — Afrezza button appears automatically when an inhaled insulin type exists in the user's insulin list - Thread showAfrezza through TreatmentBottomSheet -> TreatmentSelectionContent - Afrezza item appears between Insulin and Carbs in the treatment sheet - Include showAfrezza in Preview composable - No user preference toggle needed — presence is driven by insulin config
- Add AfrezzaDialog to Sources enum (core/data) - Add AfrezzaDialog to UserEntry.Sources DB enum (database/impl) - Add bidirectional mapping in SourcesExtension (database/persistence) - Add icon and color mappings in UserEntryPresentationHelperImpl - Afrezza doses are now distinguishable from pump boluses in treatment history and UserEntry logs
|
The CircleCI failures are due to "Forked PRs not allowed to run on OSS projects" — not a code issue. SonarCloud passed with no new alerts and Quality Gate passed. Happy to address any changes needed after review. |
8a31f2e to
021f73e
Compare
- Add AfrezzaActivity with cartridge dose selection (4U, 8U, 12U) and confirmation screen for Wear OS - Add ActionAfrezzaPreCheck and ActionAfrezzaConfirmed events to EventData sealed class for watch-phone communication - Register Afrezza as selectable action in ActionSource tile config - Add phone-side handler in DataHandlerMobile that logs Afrezza bolus directly via PersistenceLayer (bypasses pump queue for inhaled insulin) - Inject InsulinManager to look up Afrezza ICfg by peak time - Add ic_afrezza.xml inhaler icon drawable for wear tile - Add wear string resources and AndroidManifest activity registration - Add afrezza_not_configured error string to core/ui
021f73e to
3bd06ef
Compare
|
@MilosKozak @Philoul This plugin should be merged into the dev branch as soon as possible. Please consider the overall control benefits for AAPS users that can access Afrezza Inhaled insulin. It is a remarkable improvement. |
|
@Philoul Thanks for the review you started. I can update the PR without force pushing. No worries with that. |
Thx 👍 I first tried to build your branch with latest dev updates, then without.
|
Welcome to open source development, it's our daily work because you are not alone (and git is here to help us...) Some tips
One example within You included Afrezza and Wear within the same PR...
The bigger your PR are, the more you increase risks to have roadblocks, regressions, side effects... |
…UserEntry diff - Fix merge conflict markers and duplicate MAX_DIA in HardLimits.kt - Fix unused lambda parameter (message -> _) in AppNavGraph.kt - Reset UserEntryPresentationHelperImpl.kt to dev, re-add only 2 Afrezza lines - Remove Wear OS changes (AfrezzaActivity, EventData, DataHandlerMobile, etc.) - Merge latest dev to resolve all conflicts
|
@Philoul Thanks for the detailed review and tips — really helpful. Changes in this update:
SonarCloud |
|



Adds per-bolus IOB tracking for Afrezza inhaled insulin with correct pharmacokinetic curve (peak 40min, DIA 2.5h).
What's included:
InsulinType.OREF_INHALED_AFREZZAwith inhaled DIA limits (1.5–4h)Sources.AfrezzaDialogfor treatment history trackingDesign decisions:
Tested on phone + Wear OS watch with signed release builds.