Skip to content

Conversation

@nhamming
Copy link

https://tidepool.atlassian.net/browse/LOOP-1927

allow manual glucose entry without carb entry

Copy link

@rickpasetto rickpasetto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! (I can't wait until I write some unit tests for this 🤷 )

@nhamming nhamming requested a review from ps2 September 18, 2020 14:12
@nhamming
Copy link
Author

@ps2 I made a slight modification to the DeviceDataManager when it retrieves a glucose sensorState. Love to get your initial thoughts on this.

Also see tidepool-org/LoopKit#244

Copy link

@ps2 ps2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I have several suggestions in here, that I think would improve things, but none of them are critical.


if view.bounds.width < 375 {
// need to adjust for narrow display
hudView.adjustViewsForNarrowDisplay = true
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't the hud adjust its view itself if it's not given enough room? Adjust views depending on the size given would seem to be the view's responsibility, not a user of the view.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overlooked this comment. Will do.

import Foundation
import LoopKit

struct ManualGlucoseState: SensorDisplayable {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ManualGlucoseState -> ManualGlucoseDisplayable? And SensorDisplayable -> GlucoseDisplayable? The latter is LoopKit, I know, and maybe we do it later, but if this protocol is used to display both sensor and manual glucose data, the name could use updating.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll definitely update GlucoseDisplayable now. I was confused when writing the code and happy to take this suggestion.

func sensorState(for glucose: GlucoseSampleValue?) -> SensorDisplayable? {
if let glucose = glucose, glucose.wasUserEntered {
// the CGM manager needs to determine the glucoseValueType for a manual glucose based on its managed glucose thresholds
let glucoseValueType = (cgmManager as? CGMManagerUI)?.glucoseValueType(for: glucose)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably not right that we're asking the CGM to categorize the manual glucose value. It suggest that maybe glucose categorization should be a Loop concern. What do we do if we don't have a CGM? If this is too big, let's not tackle it here, but I think this is a sign we need to refactor glucose range categorization.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ps2 The scenario when the CGM is not available was reported to design. They agree that ideally Loop manages the user glucose thresholds. However, they don't have a big concern with the style of the manually entered glucose being normal in the scenario when no CGM is setup. However, they would like to confirm there is no risk in a build at some point.


var sensorState: SensorDisplayable? {
return cgmManager?.sensorState
func sensorState(for glucose: GlucoseSampleValue?) -> SensorDisplayable? {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sensorState -> glucoseDisplay?


glucoseValueTintColor = sensor?.glucoseValueType?.glucoseColor ?? .label
glucoseTrendTintColor = sensor?.glucoseValueType?.trendColor ?? .glucoseTintColor
glucoseTrendTintColor = isManualGlucose ? .destructive : sensor?.glucoseValueType?.trendColor ?? .glucoseTintColor
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, when the sensor is in a warmup state, and the user enters a manual glucose value, there is not really any "error" that needs attending to. I guess this is a question for design/product. It seems like communicating the value as a manual entry is important, but painting it in error/warning colors when everything is operating as expected and user attention is not required is not great.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that when the CGM is failing in some way, we don't want to paint over the failing state with a manual glucose entry that makes everything look ok.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ps2 yes, I'm working with Matt to determine all the possible states. Currently the known states include a red !, red or glucose colour +, and glucose colour <clock>, but we are still exploring.

@nhamming
Copy link
Author

nhamming commented Sep 21, 2020

@ps2 Ready for a formal review. With the naming update and the expanded use cases to consider how to display a manual glucose entry, this has become a much larger than expected PR.

As for the logic when displaying a manual glucose entry, the value displays as expected, but the associated icon displays the current status highlight icon instead of a trend. If there is no status highlight (possible in development, but should never occur in prod), the icon displays ?.

@nhamming nhamming requested review from ps2 and rickpasetto September 21, 2020 17:53
Copy link

@rickpasetto rickpasetto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly nits, but other than that LGTM 💭


if view.bounds.width < 375 {
// need to adjust for narrow display
hudView.adjustViewsForNarrowDisplay = true

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1


var sensorState: SensorDisplayable? {
return cgmManager?.sensorState
func glucoseDisplay(for glucose: GlucoseSampleValue?) -> GlucoseDisplayable? {

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 a ViewModel somewhere (maybe CGMStatusHUDViewModel?)

Copy link

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.

Copy link

@ps2 ps2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; just have the one comment about making the view adjust itself rather than the client, which seems natural to me, but I won't hold this up for. And the other comment about glucose range thresholding not really belonging to the CGM, but that's probably best addressed later.


var sensorState: SensorDisplayable? {
return cgmManager?.sensorState
func glucoseDisplay(for glucose: GlucoseSampleValue?) -> GlucoseDisplayable? {
Copy link

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.

@nhamming nhamming requested a review from ps2 September 22, 2020 15:31
@nhamming
Copy link
Author

@ps2 I added the feature flag and switch for DIY to allow Loop to categorize the glucose range instead of the CGM Manager.

Copy link

@ps2 ps2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I do think the (currently hardcoded) categorizer for DIY Loop should be used for both CGM and Fingerstick glucose values, but I can tackle this on the DIY side as well, later, if you want to get this in.

return cgmManager?.sensorState
func glucoseDisplay(for glucose: GlucoseSampleValue?) -> GlucoseDisplayable? {
if let glucose = glucose, glucose.wasUserEntered {
guard FeatureFlags.cgmManagerCategorizeManualGlucoseRangeEnabled else {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think categorization would differ based on manual/cgm values, so we should have one categorization routine for each. In this case, we are splitting between Tidepool Loop, which uses the Dexcom CGMManager categorization routine, and DIY Loop, which will use a hardcoded categorization routine for now. But eventually, they will use the same routine in Loop (which might coordinate with the CGMManager in some ways, but the settings and config will be in Loop).

In essence, I'm suggesting that this temporary hardcoded categorization be used for both cgm and fingerstick glucose values if the flag is turned on.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know. I'll add this now.

@nhamming nhamming merged commit 97f6c73 into dev Sep 22, 2020
@nhamming nhamming deleted the nate/fix/LOOP-1927/manual-glucose-entry branch September 22, 2020 21:06
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.

4 participants