-
Notifications
You must be signed in to change notification settings - Fork 8
nate/fix/LOOP-1927/manual-glucose-entry #256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 12 commits
8a38b70
0997628
f85bf26
e45842d
4f3e896
85ff522
7efb717
188a34a
fefdcb9
2dce93d
2d5d36a
51b99f0
82056ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -544,8 +544,32 @@ extension DeviceDataManager { | |
| return pumpManager?.status | ||
| } | ||
|
|
||
| var sensorState: SensorDisplayable? { | ||
| return cgmManager?.sensorState | ||
| func glucoseDisplay(for glucose: GlucoseSampleValue?) -> GlucoseDisplayable? { | ||
| if let glucose = glucose, glucose.wasUserEntered { | ||
| guard FeatureFlags.cgmManagerCategorizeManualGlucoseRangeEnabled else { | ||
|
||
| // Using Dexcom default glucose thresholds to categories a manual glucose entry | ||
| let urgentLowGlucoseThreshold = HKQuantity(unit: .milligramsPerDeciliter, doubleValue: 55) | ||
| let lowGlucoseThreshold = HKQuantity(unit: .milligramsPerDeciliter, doubleValue: 80) | ||
| let highGlucoseThreshold = HKQuantity(unit: .milligramsPerDeciliter, doubleValue: 200) | ||
|
|
||
| switch glucose.quantity { | ||
| case ...urgentLowGlucoseThreshold: | ||
| return ManualGlucoseDisplayable(glucoseRangeCategory: .urgentLow) | ||
| case urgentLowGlucoseThreshold..<lowGlucoseThreshold: | ||
| return ManualGlucoseDisplayable(glucoseRangeCategory: .low) | ||
| case lowGlucoseThreshold..<highGlucoseThreshold: | ||
| return ManualGlucoseDisplayable(glucoseRangeCategory: .normal) | ||
| default: | ||
| return ManualGlucoseDisplayable(glucoseRangeCategory: .high) | ||
| } | ||
| } | ||
|
|
||
| // the CGM manager needs to determine the glucose range category for a manual glucose based on its managed glucose thresholds | ||
| let glucoseRangeCategory = (cgmManager as? CGMManagerUI)?.glucoseRangeCategory(for: glucose) | ||
| return ManualGlucoseDisplayable(glucoseRangeCategory: glucoseRangeCategory) | ||
| } else { | ||
| return cgmManager?.glucoseDisplay | ||
| } | ||
| } | ||
|
|
||
| func updatePumpManagerBLEHeartbeatPreference() { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit] this responsibility seems odd here in
DeviceDataManager. I would have expected this to live in aViewModelsomewhere (maybeCGMStatusHUDViewModel?)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it's here because of the interaction with cgmManager. And the interaction with cgmManager is the not-great part, imo; we need to eventually make Loop be able to evaluate glucoseRangeCategories independently of a CGM; it's not right that the CGM is evaluating ranges for the fingerstick value. I think once we have resolved that, this can go somewhere that makes more sense.