feat(core): explainable glucose metrics pack + dashboard patterns - #6
Open
shroominic wants to merge 1 commit into
Open
feat(core): explainable glucose metrics pack + dashboard patterns#6shroominic wants to merge 1 commit into
shroominic wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 tomainafter #4 merges.Analytics (
packages/cgm_core/lib/src/glucose_analytics.dart)Pure-Dart functions over
List<CgmReading>, exported viacgm_core.dart:GlucoseRangeBounds(default 70-180 mg/dL ~ 3.9-10 mmol/L)3.31 + 0.02392 * mean), hedged as a rough self-experimentation value, not a lab resultreadingsInTimeframe,summarize)Dashboard (
openhealth/lib/src/metrics_section.dart)New
MetricsSectionwidget 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 intomain.dartis 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 analyzeclean 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