Skip to content

Enable Time-In-Range calculation in TherapyMetricsCard#148

Merged
jwoglom merged 1 commit into
devfrom
claude/add-tir-display-fgMYo
Jun 2, 2026
Merged

Enable Time-In-Range calculation in TherapyMetricsCard#148
jwoglom merged 1 commit into
devfrom
claude/add-tir-display-fgMYo

Conversation

@jwoglom

@jwoglom jwoglom commented May 17, 2026

Copy link
Copy Markdown
Owner

Summary

This PR enables the Time-In-Range (TIR) metric calculation in the TherapyMetricsCard component by implementing CGM history log reading and processing.

Key Changes

  • Uncommented and refactored TIR calculation logic: Activated the previously commented-out code that calculates 24-hour Time-In-Range (70–180 mg/dL) from CGM history logs
  • Simplified CGM data extraction: Replaced inline type checking with new helper functions CgmReadingHistoryLogs and toCgmDataPoint() for cleaner code
  • Removed unused imports and code: Cleaned up imports for unused history log types and removed incomplete COB (Carbs On Board) calculation code that was marked as "NOT READY YET"
  • Updated function documentation: Clarified that TherapyMetricsCardFromDataStore now reads IOB from DataStore and computes 24h TIR from CGM history
  • Removed unused parameters: Eliminated showCOB and showTIR boolean parameters that were not being utilized

Implementation Details

  • TIR is calculated by querying the last 288 CGM readings (~24 hours at 5-minute intervals)
  • Valid glucose readings are extracted using the new toCgmDataPoint() helper function
  • The percentage of readings within the 70–180 mg/dL range is computed and passed to the TherapyMetricsCard
  • COB calculation remains disabled pending further development

https://claude.ai/code/session_011pBoh7DKJz78xNjzaACouH

Computes TIR (70-180 mg/dL) over the last ~24h of CGM history via
the shared CgmReadingHistoryLogs/toCgmDataPoint helpers, so the
metric works across G6, G7, Gx, FSL2, and FSL3 sensors. Removes
the half-finished COB stub and its unused show* flags.
@jwoglom jwoglom merged commit 1e7de21 into dev Jun 2, 2026
1 check passed
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