8000 feat(core): explainable glucose metrics pack + dashboard patterns by shroominic · Pull Request #6 · shroominic/OpenGlucose · GitHub
[go: up one dir, main page]

Skip to content

feat(core): explainable glucose metrics pack + dashboard patterns - #6

Merged
shroominic merged 2 commits into
mainfrom
feat/metrics-pack
Aug 12, 2026
Merged

shroominic merged 2 commits into
mainfrom
feat/metrics-pack

Conversation

@shroominic
Copy link
Copy Markdown
Owner

Summary

Implements the explainable metrics pack (TASK-012): pure-Dart glucose analytics plus a wellness-framed dashboard "Patterns" section.

Stacked on #4 (feat/sim-demo-mode). Rebase to main after #4 merges.

Analytics (packages/cgm_core/lib/src/glucose_analytics.dart)

Pure-Dart functions over List<CgmReading>, exported via cgm_core.dart:

  • Time in range / below / above — bucketed against configurable GlucoseRangeBounds (default 70-180 mg/dL ~ 3.9-10 mmol/L)
  • Average (mean mg/dL)
  • Standard deviation (population) + CV (variability %)
  • Estimated GMI — GMI-style indicator from mean (3.31 + 0.02392 * mean), hedged as a rough self-experimentation value, not a lab result
  • Spike count — upward crossings of the high bound, ordered by timestamp
  • Timeframes — 24h / 7d / 14d windowing (readingsInTimeframe, summarize)
  • min / max, null-safe empty results

Dashboard (openhealth/lib/src/metrics_section.dart)

New MetricsSection widget rendering each metric with a one-line plain-language explanation, a 24h/7d/14d segmented selector, and mg/dL <-> mmol/L unit-pref-aware formatting. Insertion into main.dart is minimal and clearly delimited (another wave touches the dashboard). dashboard_chart.dart, demo_driver.dart, and settings untouched.

Wellness framing

Section titled "Patterns" with subtitle "Observations for self-experimentation, not medical metrics." No diagnostic/treatment language; estimated GMI explicitly flagged as not a lab result.

Tests

packages/cgm_core/test/glucose_analytics_test.dart — thorough synthetic-reading unit tests (windowing, average/SD/CV with known-answer series, GMI, spike counting incl. ordering & custom bounds, TIR bucketing & boundary inclusivity, empty/preFiltered paths). All cgm_core + app tests pass; flutter analyze clean for changed files.

Verification

Ran on iPhone 15 Pro simulator with --dart-define=OG_DEMO=true. Screenshot: /tmp/og-metrics.png — shows TIR 100%, below/above 0%/0%, average 118 mg/dL, CV 10% (SD 12 mg/dL), estimated GMI ~6.1%, spikes 0, with the timeframe selector and disclaimer.

Refs: TASK-012

🤖 Generated with Claude Code

shroominic and others added 2 commits June 23, 2026 19:24
…ator testing

Add a compile-time OG_DEMO build flag (--dart-define=OG_DEMO=true) so
native/simulator builds run the in-memory DemoCgmDriver instead of the
real BLE Aidex driver, and auto-scan + auto-connect on launch so the app
lands directly on the populated dashboard. The iOS simulator has no
Bluetooth, so this unblocks simulator-based feature verification.

When the flag is false (the default), behavior is unchanged: production
builds keep using the real AidexSensorDriver and the manual scan flow.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add pure-Dart glucose analytics in cgm_core (glucose_analytics.dart):
time-in-range / below / above, average, SD, CV, estimated GMI-style
indicator, and spike count over 24h/7d/14d windows with configurable
range bounds (default 70-180 mg/dL). Fully unit-tested with synthetic
readings.

Render these in a new explainable, wellness-framed "Patterns" section
on the dashboard (metrics_section.dart) with a timeframe selector, a
one-line plain-language explanation per metric, and unit-pref-aware
formatting. Edits to main.dart are minimal and clearly delimited.

Wellness/self-experimentation framing only: observations and patterns,
not medical metrics or diagnosis.

Refs: TASK-012

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@shroominic
shroominic changed the base branch from feat/sim-demo-mode to main August 12, 2026 17:22
@shroominic
shroominic merged commit 752e577 into main Aug 12, 2026
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.

1 participant

0