Skip to content

WEB-4654 - CGM Use - #1991

Open
henry-tp wants to merge 24 commits into
WEB-4654-time-in-rangefrom
WEB-4654-cgm-use
Open

WEB-4654 - CGM Use#1991
henry-tp wants to merge 24 commits into
WEB-4654-time-in-rangefrom
WEB-4654-cgm-use

Conversation

@henry-tp

@henry-tp henry-tp commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

@henry-tp
henry-tp changed the base branch from develop to WEB-4654-time-in-range July 15, 2026 21:03
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (4)
  • master
  • main
  • develop
  • release.*

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5c1b0f12-b493-4b53-acf9-dcf5988603fb

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Clinic patient filtering is refactored into reusable dropdowns, filter-state adapters, applied-filter chips, and shared query-state controls. ClinicPatients now composes these components for filter selection, removal, reset actions, and empty-state messaging.

Changes

Clinic patient filtering

Layer / File(s) Summary
Filter state adapters and shared contracts
app/pages/clinicworkspace/FilterBy*.js, app/pages/clinicworkspace/useClinicPatientsFilters.js, app/pages/clinicworkspace/useIsClinicAdmin.js
Filter adapters synchronize dropdown selections with active filters, support clinic-admin edit actions, and define special zero-site and zero-tag states.
Filter dropdown interactions
app/pages/clinicworkspace/components/*FilterDropdown.js
New popover controls provide searchable tag and site selection, radio and checkbox filters, pending selections, apply/clear actions, and interaction tracking.
Applied filters and query-state controls
app/pages/clinicworkspace/AppliedFiltersAdapter.js, app/pages/clinicworkspace/components/AppliedFilters.js, app/pages/clinicworkspace/components/ClearFilterButtons.js
Applied filter chips display removable data, tag, site, CGM, and time-in-range filters; shared buttons handle search clearing and filter resets.
ClinicPatients integration
app/pages/clinicworkspace/ClinicPatients.js, locales/en/translation.json
ClinicPatients composes the extracted controls, computes unified query state, wires empty-state/reset behavior, and uses updated singular/plural translations.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ClinicPatients
  participant FilterByDataRecency
  participant DataRecencyFilterDropdown
  participant FilterState
  ClinicPatients->>FilterByDataRecency: render active filter values
  FilterByDataRecency->>DataRecencyFilterDropdown: pass lastData and lastDataType
  DataRecencyFilterDropdown->>FilterByDataRecency: apply or clear selection
  FilterByDataRecency->>FilterState: setActiveFilters(lastData, lastDataType)
  FilterState->>ClinicPatients: update patient query
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The description only contains the issue key and link, so it does not meaningfully describe the changes. Add a short summary of the main code changes, such as the new CGM Use filter and related clinic patient filter refactor.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title matches the new CGM Use filter work, though the PR also includes broader clinic patient filter refactors.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch WEB-4654-cgm-use

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 11

🧹 Nitpick comments (6)
app/pages/clinicworkspace/useIsClinicAdmin.js (1)

1-4: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Add blank lines between import groups.

As per coding guidelines, **/*.{js,jsx,ts,tsx}: "Group imports in the required order with blank lines between groups: React, PropTypes, Redux, third-party libraries, Lodash specific imports, theme-ui, then local imports." React, Redux, and Lodash imports here run together with no separation.

✏️ Proposed fix
 import React from 'react';
+
 import { useSelector } from 'react-redux';
+
 import get from 'lodash/get';
 import includes from 'lodash/includes';
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/pages/clinicworkspace/useIsClinicAdmin.js` around lines 1 - 4, Group the
imports in useIsClinicAdmin by adding blank lines according to the project
order: keep React first, separate the Redux import, and separate the Lodash
imports as their own group.

Source: Coding guidelines

app/pages/clinicworkspace/components/SiteFilterDropdown.js (2)

1-1: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Missing PropTypes on all new filter components. As per coding guidelines, **/*.{js,jsx,ts,tsx}: "Define PropTypes for all component props," but none of these new components declare PropTypes for their props.

  • app/pages/clinicworkspace/components/SiteFilterDropdown.js#L218-222: add propTypes for SiteFilterDropdown (onChange, clinicSites, onClickEditSites) and for DropdownContent.
  • app/pages/clinicworkspace/FilterByTimeInRange.js#L6-9: add propTypes for activeFilters/setActiveFilters.
  • app/pages/clinicworkspace/components/SummaryPeriodFilterDropdown.js#L111-114: add propTypes for SummaryPeriodFilterDropdown and DropdownContent.
  • app/pages/clinicworkspace/components/TagFilterDropdown.js#L214-218: add propTypes for TagFilterDropdown (onChange, patientTags, onClickEditTags) and for DropdownContent.
  • app/pages/clinicworkspace/components/TimeInRangeFilterDropdown.js#L252-255: add propTypes for TimeInRangeFilterDropdown and DropdownContent.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/pages/clinicworkspace/components/SiteFilterDropdown.js` at line 1, Add
PropTypes declarations for every listed new component: SiteFilterDropdown and
its DropdownContent, FilterByTimeInRange, SummaryPeriodFilterDropdown and its
DropdownContent, TagFilterDropdown and its DropdownContent, and
TimeInRangeFilterDropdown and its DropdownContent. Define each component’s
declarations for all props it consumes, including the explicitly named callbacks
and data props, using the appropriate requiredness and collection/function
types.

Source: Coding guidelines


1-1: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

SiteFilterDropdown.js and TagFilterDropdown.js are near-duplicate implementations. Both files reimplement the same popover/search/checkbox/apply-clear structure differing only by "site" vs "tag" naming; this duplication is likely why the trackMetric stub diverged between them (see the metrics-disabled comment above).

  • app/pages/clinicworkspace/components/SiteFilterDropdown.js#L56-209: extract the shared searchable-checkbox-dropdown logic (search box, sorted/filtered options, zero-selection sentinel handling, clear/apply actions) into a reusable hook or generic component parameterized by entity type.
  • app/pages/clinicworkspace/components/TagFilterDropdown.js#L56-205: consume the same shared abstraction instead of duplicating the logic.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/pages/clinicworkspace/components/SiteFilterDropdown.js` at line 1,
Extract the duplicated searchable checkbox popover behavior from
SiteFilterDropdown and TagFilterDropdown into one reusable hook or generic
component, parameterized for site and tag labels, options, selection state, and
callbacks. Move shared search, sorting/filtering, zero-selection sentinel
handling, and clear/apply actions into that abstraction, then update both
dropdowns to consume it while preserving their entity-specific behavior and
metric handling.
app/pages/clinicworkspace/FilterByTags.js (1)

11-33: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

trackMetric stub silently drops the "Edit clinic tags open" event; call order also deviates from convention.

Same pattern as FilterBySites.js: trackMetric is a local noop stub (TODO: FIX), and the call precedes the dispatch(actions.async.fetchClinicPatientTags(...)) rather than following it. (See consolidated comment.)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/pages/clinicworkspace/FilterByTags.js` around lines 11 - 33, Replace the
local noop trackMetric stub in FilterByTags with the established metric-tracking
implementation used by FilterBySites, and reorder handleClickEditTags so
dispatch(actions.async.fetchClinicPatientTags(...)) runs before recording the
“Clinic - Population Health - Edit clinic tags open” event.

Source: Learnings

app/pages/clinicworkspace/FilterBySites.js (1)

11-33: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

trackMetric stub silently drops the "Edit clinic sites open" event; call order also deviates from convention.

trackMetric is a local noop stub (TODO: FIX), so this metric is never recorded — unlike the sibling dropdown files in this PR that import the real trackMetric from core/metricUtils. Separately, the call precedes dispatch(actions.async.fetchClinicSites(...)), whereas the established convention places trackMetric immediately after dispatching the related action. (See consolidated comment; this repeats identically in FilterByTags.js.)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/pages/clinicworkspace/FilterBySites.js` around lines 11 - 33, Replace the
local trackMetric noop in FilterBySites with the real trackMetric import from
core/metricUtils, and move the “Edit clinic sites open” tracking call in
handleClickEditSites to immediately after
dispatch(actions.async.fetchClinicSites(...)). Apply the same changes to the
corresponding FilterByTags implementation.

Source: Learnings

app/pages/clinicworkspace/FilterByCGMUse.js (1)

6-9: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

None of the new filter adapters/dropdowns declare PropTypes. As per coding guidelines, "Define PropTypes for all component props," but every new component in this cohort omits them.

  • app/pages/clinicworkspace/FilterByCGMUse.js#L6-L9: add PropTypes for activeFilters, setActiveFilters.
  • app/pages/clinicworkspace/FilterByDataRecency.js#L6-L9: add PropTypes for activeFilters, setActiveFilters.
  • app/pages/clinicworkspace/FilterBySites.js#L13-L18: add PropTypes for api, activeFilters, setActiveFilters, setShowClinicSitesDialog.
  • app/pages/clinicworkspace/FilterBySummaryPeriod.js#L6-L9: add PropTypes for activeSummaryPeriod, setActiveSummaryPeriod.
  • app/pages/clinicworkspace/FilterByTags.js#L13-L18: add PropTypes for api, activeFilters, setActiveFilters, setShowClinicPatientTagsDialog.
  • app/pages/clinicworkspace/components/CGMUseFilterDropdown.js#L26-L30: add PropTypes for DropdownContent's onClose, onChange, timeCGMUsePercent.
  • app/pages/clinicworkspace/components/CGMUseFilterDropdown.js#L99-L102: add PropTypes for CGMUseFilterDropdown's onChange, timeCGMUsePercent.
  • app/pages/clinicworkspace/components/DataRecencyFilterDropdown.js#L26-L31: add PropTypes for DropdownContent's onClose, onChange, lastData, lastDataType.
  • app/pages/clinicworkspace/components/DataRecencyFilterDropdown.js#L131-L135: add PropTypes for DataRecencyFilterDropdown's onChange, lastData, lastDataType.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/pages/clinicworkspace/FilterByCGMUse.js` around lines 6 - 9, Declare
PropTypes for every listed component and nested DropdownContent function,
matching each component's existing props: activeFilters/setActiveFilters in
FilterByCGMUse and FilterByDataRecency;
api/activeFilters/setActiveFilters/setShowClinicSitesDialog in FilterBySites;
activeSummaryPeriod/setActiveSummaryPeriod in FilterBySummaryPeriod;
api/activeFilters/setActiveFilters/setShowClinicPatientTagsDialog in
FilterByTags; onClose/onChange/timeCGMUsePercent for CGMUseFilterDropdown's
DropdownContent and onChange/timeCGMUsePercent for CGMUseFilterDropdown; and
onClose/onChange/lastData/lastDataType for DataRecencyFilterDropdown's
DropdownContent and onChange/lastData/lastDataType for
DataRecencyFilterDropdown. Use the appropriate PropTypes validators and preserve
the existing defaults and behavior.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/pages/clinicworkspace/AppliedFiltersAdapter.js`:
- Around line 13-44: Add a timeCGMUsePercent case to handleRemoveFilter,
resetting activeFilters.timeCGMUsePercent to
defaultFilterState.timeCGMUsePercent so removing the CGM Use chip clears its
value.

In `@app/pages/clinicworkspace/ClinicPatients.js`:
- Around line 3233-3249: Update the dependency array of renderPeopleTable’s
useCallback to include patientListSearchTextInput, handleClearSearch, and
handleResetFilters, matching the values used by patientQueryState and the
rendered ClearFilterButtons/EmptyContentNode. Preserve the existing dependencies
and ensure both affected JSX paths stay synchronized with current search and
filter state.

In `@app/pages/clinicworkspace/components/AppliedFilters.js`:
- Around line 166-171: Declare PropTypes for all props in AppliedFilters,
including its internal ChipGroup and Chip components; define activeFilters,
setActiveFilters, and rightContent PropTypes in AppliedFiltersAdapter using the
existing PropTypes import; and add patientQueryState, onClearSearch, and
onResetFilters PropTypes to ClearFilterButtons. Use the specified types and
preserve the current component behavior.

In `@app/pages/clinicworkspace/components/CGMUseFilterDropdown.js`:
- Line 19: The prefixPopHealthMetric function must return the provided metric
name as a string rather than the noop function. Update prefixPopHealthMetric in
app/pages/clinicworkspace/components/CGMUseFilterDropdown.js:19 and
app/pages/clinicworkspace/components/DataRecencyFilterDropdown.js:24, and apply
the same correction to its usages in TimeInRangeFilterDropdown.js and
SummaryPeriodFilterDropdown.js, preserving the existing trackMetric calls.

In `@app/pages/clinicworkspace/components/SiteFilterDropdown.js`:
- Line 1: Replace the local no-op trackMetric stubs in SiteFilterDropdown and
TagFilterDropdown with imports of the real trackMetric implementation from the
established metricUtils module, preserving all existing metric call sites for
open, close, clear, and apply actions.
- Around line 33-34: Replace the local no-op trackMetric declaration in
SiteFilterDropdown with the real trackMetric import from core/metricUtils,
matching SummaryPeriodFilterDropdown and TimeInRangeFilterDropdown. Preserve
prefixPopHealthMetric as-is unless it is also provided by that module, and leave
the existing open, close, clear, and apply tracking calls unchanged.

In `@app/pages/clinicworkspace/components/SummaryPeriodFilterDropdown.js`:
- Line 1: Update the prefixPopHealthMetric helper in both
SummaryPeriodFilterDropdown and TimeInRangeFilterDropdown so it accepts a
metric-name argument and returns the correctly prefixed string instead of the
noop function reference. Preserve the existing prefix format expected by
trackMetric calls.
- Line 19: Replace the placeholder implementation of prefixPopHealthMetric so it
accepts the metric-name string and returns the intended prefixed event-name
string. Preserve the existing trackMetric call sites and ensure they pass
strings rather than the noop function reference.

In `@app/pages/clinicworkspace/components/TagFilterDropdown.js`:
- Around line 33-34: Replace the no-op trackMetric definition in
TagFilterDropdown with the real tracking utility import and use it for the
existing tag-filter interaction events, including open, close, clear, and apply.
Keep prefixPopHealthMetric unchanged unless required by the established tracking
integration.
- Around line 139-158: Update the zero-tags option Box in the tag filter
dropdown to use the tag-specific className and key naming convention, replacing
the leftover clinic-site identifiers while preserving the existing styling,
rendering condition, and checkbox behavior.

In `@app/pages/clinicworkspace/components/TimeInRangeFilterDropdown.js`:
- Line 29: Fix prefixPopHealthMetric in TimeInRangeFilterDropdown.js so it
returns the provided metric name string rather than the noop function reference.
Match the working implementation in SummaryPeriodFilterDropdown.js and preserve
the existing trackMetric calls.

---

Nitpick comments:
In `@app/pages/clinicworkspace/components/SiteFilterDropdown.js`:
- Line 1: Add PropTypes declarations for every listed new component:
SiteFilterDropdown and its DropdownContent, FilterByTimeInRange,
SummaryPeriodFilterDropdown and its DropdownContent, TagFilterDropdown and its
DropdownContent, and TimeInRangeFilterDropdown and its DropdownContent. Define
each component’s declarations for all props it consumes, including the
explicitly named callbacks and data props, using the appropriate requiredness
and collection/function types.
- Line 1: Extract the duplicated searchable checkbox popover behavior from
SiteFilterDropdown and TagFilterDropdown into one reusable hook or generic
component, parameterized for site and tag labels, options, selection state, and
callbacks. Move shared search, sorting/filtering, zero-selection sentinel
handling, and clear/apply actions into that abstraction, then update both
dropdowns to consume it while preserving their entity-specific behavior and
metric handling.

In `@app/pages/clinicworkspace/FilterByCGMUse.js`:
- Around line 6-9: Declare PropTypes for every listed component and nested
DropdownContent function, matching each component's existing props:
activeFilters/setActiveFilters in FilterByCGMUse and FilterByDataRecency;
api/activeFilters/setActiveFilters/setShowClinicSitesDialog in FilterBySites;
activeSummaryPeriod/setActiveSummaryPeriod in FilterBySummaryPeriod;
api/activeFilters/setActiveFilters/setShowClinicPatientTagsDialog in
FilterByTags; onClose/onChange/timeCGMUsePercent for CGMUseFilterDropdown's
DropdownContent and onChange/timeCGMUsePercent for CGMUseFilterDropdown; and
onClose/onChange/lastData/lastDataType for DataRecencyFilterDropdown's
DropdownContent and onChange/lastData/lastDataType for
DataRecencyFilterDropdown. Use the appropriate PropTypes validators and preserve
the existing defaults and behavior.

In `@app/pages/clinicworkspace/FilterBySites.js`:
- Around line 11-33: Replace the local trackMetric noop in FilterBySites with
the real trackMetric import from core/metricUtils, and move the “Edit clinic
sites open” tracking call in handleClickEditSites to immediately after
dispatch(actions.async.fetchClinicSites(...)). Apply the same changes to the
corresponding FilterByTags implementation.

In `@app/pages/clinicworkspace/FilterByTags.js`:
- Around line 11-33: Replace the local noop trackMetric stub in FilterByTags
with the established metric-tracking implementation used by FilterBySites, and
reorder handleClickEditTags so
dispatch(actions.async.fetchClinicPatientTags(...)) runs before recording the
“Clinic - Population Health - Edit clinic tags open” event.

In `@app/pages/clinicworkspace/useIsClinicAdmin.js`:
- Around line 1-4: Group the imports in useIsClinicAdmin by adding blank lines
according to the project order: keep React first, separate the Redux import, and
separate the Lodash imports as their own group.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8814d320-6d27-4896-8edd-a866bacdd540

📥 Commits

Reviewing files that changed from the base of the PR and between 1ea3534 and d5aeef1.

⛔ Files ignored due to path filters (1)
  • app/core/icons/tagIcon.svg is excluded by !**/*.svg
📒 Files selected for processing (19)
  • app/pages/clinicworkspace/AppliedFiltersAdapter.js
  • app/pages/clinicworkspace/ClinicPatients.js
  • app/pages/clinicworkspace/FilterByCGMUse.js
  • app/pages/clinicworkspace/FilterByDataRecency.js
  • app/pages/clinicworkspace/FilterBySites.js
  • app/pages/clinicworkspace/FilterBySummaryPeriod.js
  • app/pages/clinicworkspace/FilterByTags.js
  • app/pages/clinicworkspace/FilterByTimeInRange.js
  • app/pages/clinicworkspace/components/AppliedFilters.js
  • app/pages/clinicworkspace/components/CGMUseFilterDropdown.js
  • app/pages/clinicworkspace/components/ClearFilterButtons.js
  • app/pages/clinicworkspace/components/DataRecencyFilterDropdown.js
  • app/pages/clinicworkspace/components/SiteFilterDropdown.js
  • app/pages/clinicworkspace/components/SummaryPeriodFilterDropdown.js
  • app/pages/clinicworkspace/components/TagFilterDropdown.js
  • app/pages/clinicworkspace/components/TimeInRangeFilterDropdown.js
  • app/pages/clinicworkspace/useClinicPatientsFilters.js
  • app/pages/clinicworkspace/useIsClinicAdmin.js
  • locales/en/translation.json

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 11

🧹 Nitpick comments (6)
app/pages/clinicworkspace/useIsClinicAdmin.js (1)

1-4: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Add blank lines between import groups.

As per coding guidelines, **/*.{js,jsx,ts,tsx}: "Group imports in the required order with blank lines between groups: React, PropTypes, Redux, third-party libraries, Lodash specific imports, theme-ui, then local imports." React, Redux, and Lodash imports here run together with no separation.

✏️ Proposed fix
 import React from 'react';
+
 import { useSelector } from 'react-redux';
+
 import get from 'lodash/get';
 import includes from 'lodash/includes';
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/pages/clinicworkspace/useIsClinicAdmin.js` around lines 1 - 4, Group the
imports in useIsClinicAdmin by adding blank lines according to the project
order: keep React first, separate the Redux import, and separate the Lodash
imports as their own group.

Source: Coding guidelines

app/pages/clinicworkspace/components/SiteFilterDropdown.js (2)

1-1: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Missing PropTypes on all new filter components. As per coding guidelines, **/*.{js,jsx,ts,tsx}: "Define PropTypes for all component props," but none of these new components declare PropTypes for their props.

  • app/pages/clinicworkspace/components/SiteFilterDropdown.js#L218-222: add propTypes for SiteFilterDropdown (onChange, clinicSites, onClickEditSites) and for DropdownContent.
  • app/pages/clinicworkspace/FilterByTimeInRange.js#L6-9: add propTypes for activeFilters/setActiveFilters.
  • app/pages/clinicworkspace/components/SummaryPeriodFilterDropdown.js#L111-114: add propTypes for SummaryPeriodFilterDropdown and DropdownContent.
  • app/pages/clinicworkspace/components/TagFilterDropdown.js#L214-218: add propTypes for TagFilterDropdown (onChange, patientTags, onClickEditTags) and for DropdownContent.
  • app/pages/clinicworkspace/components/TimeInRangeFilterDropdown.js#L252-255: add propTypes for TimeInRangeFilterDropdown and DropdownContent.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/pages/clinicworkspace/components/SiteFilterDropdown.js` at line 1, Add
PropTypes declarations for every listed new component: SiteFilterDropdown and
its DropdownContent, FilterByTimeInRange, SummaryPeriodFilterDropdown and its
DropdownContent, TagFilterDropdown and its DropdownContent, and
TimeInRangeFilterDropdown and its DropdownContent. Define each component’s
declarations for all props it consumes, including the explicitly named callbacks
and data props, using the appropriate requiredness and collection/function
types.

Source: Coding guidelines


1-1: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

SiteFilterDropdown.js and TagFilterDropdown.js are near-duplicate implementations. Both files reimplement the same popover/search/checkbox/apply-clear structure differing only by "site" vs "tag" naming; this duplication is likely why the trackMetric stub diverged between them (see the metrics-disabled comment above).

  • app/pages/clinicworkspace/components/SiteFilterDropdown.js#L56-209: extract the shared searchable-checkbox-dropdown logic (search box, sorted/filtered options, zero-selection sentinel handling, clear/apply actions) into a reusable hook or generic component parameterized by entity type.
  • app/pages/clinicworkspace/components/TagFilterDropdown.js#L56-205: consume the same shared abstraction instead of duplicating the logic.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/pages/clinicworkspace/components/SiteFilterDropdown.js` at line 1,
Extract the duplicated searchable checkbox popover behavior from
SiteFilterDropdown and TagFilterDropdown into one reusable hook or generic
component, parameterized for site and tag labels, options, selection state, and
callbacks. Move shared search, sorting/filtering, zero-selection sentinel
handling, and clear/apply actions into that abstraction, then update both
dropdowns to consume it while preserving their entity-specific behavior and
metric handling.
app/pages/clinicworkspace/FilterByTags.js (1)

11-33: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

trackMetric stub silently drops the "Edit clinic tags open" event; call order also deviates from convention.

Same pattern as FilterBySites.js: trackMetric is a local noop stub (TODO: FIX), and the call precedes the dispatch(actions.async.fetchClinicPatientTags(...)) rather than following it. (See consolidated comment.)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/pages/clinicworkspace/FilterByTags.js` around lines 11 - 33, Replace the
local noop trackMetric stub in FilterByTags with the established metric-tracking
implementation used by FilterBySites, and reorder handleClickEditTags so
dispatch(actions.async.fetchClinicPatientTags(...)) runs before recording the
“Clinic - Population Health - Edit clinic tags open” event.

Source: Learnings

app/pages/clinicworkspace/FilterBySites.js (1)

11-33: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

trackMetric stub silently drops the "Edit clinic sites open" event; call order also deviates from convention.

trackMetric is a local noop stub (TODO: FIX), so this metric is never recorded — unlike the sibling dropdown files in this PR that import the real trackMetric from core/metricUtils. Separately, the call precedes dispatch(actions.async.fetchClinicSites(...)), whereas the established convention places trackMetric immediately after dispatching the related action. (See consolidated comment; this repeats identically in FilterByTags.js.)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/pages/clinicworkspace/FilterBySites.js` around lines 11 - 33, Replace the
local trackMetric noop in FilterBySites with the real trackMetric import from
core/metricUtils, and move the “Edit clinic sites open” tracking call in
handleClickEditSites to immediately after
dispatch(actions.async.fetchClinicSites(...)). Apply the same changes to the
corresponding FilterByTags implementation.

Source: Learnings

app/pages/clinicworkspace/FilterByCGMUse.js (1)

6-9: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

None of the new filter adapters/dropdowns declare PropTypes. As per coding guidelines, "Define PropTypes for all component props," but every new component in this cohort omits them.

  • app/pages/clinicworkspace/FilterByCGMUse.js#L6-L9: add PropTypes for activeFilters, setActiveFilters.
  • app/pages/clinicworkspace/FilterByDataRecency.js#L6-L9: add PropTypes for activeFilters, setActiveFilters.
  • app/pages/clinicworkspace/FilterBySites.js#L13-L18: add PropTypes for api, activeFilters, setActiveFilters, setShowClinicSitesDialog.
  • app/pages/clinicworkspace/FilterBySummaryPeriod.js#L6-L9: add PropTypes for activeSummaryPeriod, setActiveSummaryPeriod.
  • app/pages/clinicworkspace/FilterByTags.js#L13-L18: add PropTypes for api, activeFilters, setActiveFilters, setShowClinicPatientTagsDialog.
  • app/pages/clinicworkspace/components/CGMUseFilterDropdown.js#L26-L30: add PropTypes for DropdownContent's onClose, onChange, timeCGMUsePercent.
  • app/pages/clinicworkspace/components/CGMUseFilterDropdown.js#L99-L102: add PropTypes for CGMUseFilterDropdown's onChange, timeCGMUsePercent.
  • app/pages/clinicworkspace/components/DataRecencyFilterDropdown.js#L26-L31: add PropTypes for DropdownContent's onClose, onChange, lastData, lastDataType.
  • app/pages/clinicworkspace/components/DataRecencyFilterDropdown.js#L131-L135: add PropTypes for DataRecencyFilterDropdown's onChange, lastData, lastDataType.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/pages/clinicworkspace/FilterByCGMUse.js` around lines 6 - 9, Declare
PropTypes for every listed component and nested DropdownContent function,
matching each component's existing props: activeFilters/setActiveFilters in
FilterByCGMUse and FilterByDataRecency;
api/activeFilters/setActiveFilters/setShowClinicSitesDialog in FilterBySites;
activeSummaryPeriod/setActiveSummaryPeriod in FilterBySummaryPeriod;
api/activeFilters/setActiveFilters/setShowClinicPatientTagsDialog in
FilterByTags; onClose/onChange/timeCGMUsePercent for CGMUseFilterDropdown's
DropdownContent and onChange/timeCGMUsePercent for CGMUseFilterDropdown; and
onClose/onChange/lastData/lastDataType for DataRecencyFilterDropdown's
DropdownContent and onChange/lastData/lastDataType for
DataRecencyFilterDropdown. Use the appropriate PropTypes validators and preserve
the existing defaults and behavior.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/pages/clinicworkspace/AppliedFiltersAdapter.js`:
- Around line 13-44: Add a timeCGMUsePercent case to handleRemoveFilter,
resetting activeFilters.timeCGMUsePercent to
defaultFilterState.timeCGMUsePercent so removing the CGM Use chip clears its
value.

In `@app/pages/clinicworkspace/ClinicPatients.js`:
- Around line 3233-3249: Update the dependency array of renderPeopleTable’s
useCallback to include patientListSearchTextInput, handleClearSearch, and
handleResetFilters, matching the values used by patientQueryState and the
rendered ClearFilterButtons/EmptyContentNode. Preserve the existing dependencies
and ensure both affected JSX paths stay synchronized with current search and
filter state.

In `@app/pages/clinicworkspace/components/AppliedFilters.js`:
- Around line 166-171: Declare PropTypes for all props in AppliedFilters,
including its internal ChipGroup and Chip components; define activeFilters,
setActiveFilters, and rightContent PropTypes in AppliedFiltersAdapter using the
existing PropTypes import; and add patientQueryState, onClearSearch, and
onResetFilters PropTypes to ClearFilterButtons. Use the specified types and
preserve the current component behavior.

In `@app/pages/clinicworkspace/components/CGMUseFilterDropdown.js`:
- Line 19: The prefixPopHealthMetric function must return the provided metric
name as a string rather than the noop function. Update prefixPopHealthMetric in
app/pages/clinicworkspace/components/CGMUseFilterDropdown.js:19 and
app/pages/clinicworkspace/components/DataRecencyFilterDropdown.js:24, and apply
the same correction to its usages in TimeInRangeFilterDropdown.js and
SummaryPeriodFilterDropdown.js, preserving the existing trackMetric calls.

In `@app/pages/clinicworkspace/components/SiteFilterDropdown.js`:
- Line 1: Replace the local no-op trackMetric stubs in SiteFilterDropdown and
TagFilterDropdown with imports of the real trackMetric implementation from the
established metricUtils module, preserving all existing metric call sites for
open, close, clear, and apply actions.
- Around line 33-34: Replace the local no-op trackMetric declaration in
SiteFilterDropdown with the real trackMetric import from core/metricUtils,
matching SummaryPeriodFilterDropdown and TimeInRangeFilterDropdown. Preserve
prefixPopHealthMetric as-is unless it is also provided by that module, and leave
the existing open, close, clear, and apply tracking calls unchanged.

In `@app/pages/clinicworkspace/components/SummaryPeriodFilterDropdown.js`:
- Line 1: Update the prefixPopHealthMetric helper in both
SummaryPeriodFilterDropdown and TimeInRangeFilterDropdown so it accepts a
metric-name argument and returns the correctly prefixed string instead of the
noop function reference. Preserve the existing prefix format expected by
trackMetric calls.
- Line 19: Replace the placeholder implementation of prefixPopHealthMetric so it
accepts the metric-name string and returns the intended prefixed event-name
string. Preserve the existing trackMetric call sites and ensure they pass
strings rather than the noop function reference.

In `@app/pages/clinicworkspace/components/TagFilterDropdown.js`:
- Around line 33-34: Replace the no-op trackMetric definition in
TagFilterDropdown with the real tracking utility import and use it for the
existing tag-filter interaction events, including open, close, clear, and apply.
Keep prefixPopHealthMetric unchanged unless required by the established tracking
integration.
- Around line 139-158: Update the zero-tags option Box in the tag filter
dropdown to use the tag-specific className and key naming convention, replacing
the leftover clinic-site identifiers while preserving the existing styling,
rendering condition, and checkbox behavior.

In `@app/pages/clinicworkspace/components/TimeInRangeFilterDropdown.js`:
- Line 29: Fix prefixPopHealthMetric in TimeInRangeFilterDropdown.js so it
returns the provided metric name string rather than the noop function reference.
Match the working implementation in SummaryPeriodFilterDropdown.js and preserve
the existing trackMetric calls.

---

Nitpick comments:
In `@app/pages/clinicworkspace/components/SiteFilterDropdown.js`:
- Line 1: Add PropTypes declarations for every listed new component:
SiteFilterDropdown and its DropdownContent, FilterByTimeInRange,
SummaryPeriodFilterDropdown and its DropdownContent, TagFilterDropdown and its
DropdownContent, and TimeInRangeFilterDropdown and its DropdownContent. Define
each component’s declarations for all props it consumes, including the
explicitly named callbacks and data props, using the appropriate requiredness
and collection/function types.
- Line 1: Extract the duplicated searchable checkbox popover behavior from
SiteFilterDropdown and TagFilterDropdown into one reusable hook or generic
component, parameterized for site and tag labels, options, selection state, and
callbacks. Move shared search, sorting/filtering, zero-selection sentinel
handling, and clear/apply actions into that abstraction, then update both
dropdowns to consume it while preserving their entity-specific behavior and
metric handling.

In `@app/pages/clinicworkspace/FilterByCGMUse.js`:
- Around line 6-9: Declare PropTypes for every listed component and nested
DropdownContent function, matching each component's existing props:
activeFilters/setActiveFilters in FilterByCGMUse and FilterByDataRecency;
api/activeFilters/setActiveFilters/setShowClinicSitesDialog in FilterBySites;
activeSummaryPeriod/setActiveSummaryPeriod in FilterBySummaryPeriod;
api/activeFilters/setActiveFilters/setShowClinicPatientTagsDialog in
FilterByTags; onClose/onChange/timeCGMUsePercent for CGMUseFilterDropdown's
DropdownContent and onChange/timeCGMUsePercent for CGMUseFilterDropdown; and
onClose/onChange/lastData/lastDataType for DataRecencyFilterDropdown's
DropdownContent and onChange/lastData/lastDataType for
DataRecencyFilterDropdown. Use the appropriate PropTypes validators and preserve
the existing defaults and behavior.

In `@app/pages/clinicworkspace/FilterBySites.js`:
- Around line 11-33: Replace the local trackMetric noop in FilterBySites with
the real trackMetric import from core/metricUtils, and move the “Edit clinic
sites open” tracking call in handleClickEditSites to immediately after
dispatch(actions.async.fetchClinicSites(...)). Apply the same changes to the
corresponding FilterByTags implementation.

In `@app/pages/clinicworkspace/FilterByTags.js`:
- Around line 11-33: Replace the local noop trackMetric stub in FilterByTags
with the established metric-tracking implementation used by FilterBySites, and
reorder handleClickEditTags so
dispatch(actions.async.fetchClinicPatientTags(...)) runs before recording the
“Clinic - Population Health - Edit clinic tags open” event.

In `@app/pages/clinicworkspace/useIsClinicAdmin.js`:
- Around line 1-4: Group the imports in useIsClinicAdmin by adding blank lines
according to the project order: keep React first, separate the Redux import, and
separate the Lodash imports as their own group.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8814d320-6d27-4896-8edd-a866bacdd540

📥 Commits

Reviewing files that changed from the base of the PR and between 1ea3534 and d5aeef1.

⛔ Files ignored due to path filters (1)
  • app/core/icons/tagIcon.svg is excluded by !**/*.svg
📒 Files selected for processing (19)
  • app/pages/clinicworkspace/AppliedFiltersAdapter.js
  • app/pages/clinicworkspace/ClinicPatients.js
  • app/pages/clinicworkspace/FilterByCGMUse.js
  • app/pages/clinicworkspace/FilterByDataRecency.js
  • app/pages/clinicworkspace/FilterBySites.js
  • app/pages/clinicworkspace/FilterBySummaryPeriod.js
  • app/pages/clinicworkspace/FilterByTags.js
  • app/pages/clinicworkspace/FilterByTimeInRange.js
  • app/pages/clinicworkspace/components/AppliedFilters.js
  • app/pages/clinicworkspace/components/CGMUseFilterDropdown.js
  • app/pages/clinicworkspace/components/ClearFilterButtons.js
  • app/pages/clinicworkspace/components/DataRecencyFilterDropdown.js
  • app/pages/clinicworkspace/components/SiteFilterDropdown.js
  • app/pages/clinicworkspace/components/SummaryPeriodFilterDropdown.js
  • app/pages/clinicworkspace/components/TagFilterDropdown.js
  • app/pages/clinicworkspace/components/TimeInRangeFilterDropdown.js
  • app/pages/clinicworkspace/useClinicPatientsFilters.js
  • app/pages/clinicworkspace/useIsClinicAdmin.js
  • locales/en/translation.json
🛑 Comments failed to post (11)
app/pages/clinicworkspace/AppliedFiltersAdapter.js (1)

13-44: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

git ls-files 'app/pages/clinicworkspace/*' 'app/pages/clinicworkspace/**' 'components/*' 'hooks/*' | sed -n '1,200p'

Repository: tidepool-org/blip

Length of output: 1351


🏁 Script executed:

python3 - <<'PY'
import os, subprocess, textwrap, json, sys
paths = [
    'app/pages/clinicworkspace/AppliedFiltersAdapter.js',
    'components/AppliedFilters.js',
    'app/pages/clinicworkspace/useClinicPatientsFilters.js',
]
for p in paths:
    print(f'=== {p} ===')
    if os.path.exists(p):
        print(subprocess.check_output(['bash','-lc',f'wc -l < {p}']).decode().strip(), 'lines')
        print(subprocess.check_output(['bash','-lc',f'ast-grep outline {p} --view expanded'], stderr=subprocess.STDOUT).decode())
    else:
        print('missing')
PY

Repository: tidepool-org/blip

Length of output: 653


🏁 Script executed:

sed -n '1,220p' app/pages/clinicworkspace/AppliedFiltersAdapter.js
printf '\n---\n'
sed -n '1,240p' components/AppliedFilters.js
printf '\n---\n'
sed -n '1,260p' app/pages/clinicworkspace/useClinicPatientsFilters.js

Repository: tidepool-org/blip

Length of output: 2787


🏁 Script executed:

rg -n "timeCGMUsePercent|defaultFilterState|handleRemoveFilter|onRemoveFilter|usePrimaryChips|AppliedFilters" app/pages/clinicworkspace components -S

Repository: tidepool-org/blip

Length of output: 5386


🏁 Script executed:

python3 - <<'PY'
import os, subprocess, textwrap, json, sys
checks = [
    "grep -RIn --line-number -E 'timeCGMUsePercent|defaultFilterState|handleRemoveFilter|onRemoveFilter|usePrimaryChips|AppliedFilters' app/pages/clinicworkspace components || true",
]
for cmd in checks:
    print(subprocess.check_output(['bash','-lc',cmd]).decode())
PY

Repository: tidepool-org/blip

Length of output: 5380


Add timeCGMUsePercent handling in app/pages/clinicworkspace/AppliedFiltersAdapter.js:13-44.

The CGM Use chip emits type: 'timeCGMUsePercent', but this switch has no matching case, so removing that chip is a no-op. Reset it to defaultFilterState.timeCGMUsePercent (null).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/pages/clinicworkspace/AppliedFiltersAdapter.js` around lines 13 - 44, Add
a timeCGMUsePercent case to handleRemoveFilter, resetting
activeFilters.timeCGMUsePercent to defaultFilterState.timeCGMUsePercent so
removing the CGM Use chip clears its value.
app/pages/clinicworkspace/ClinicPatients.js (1)

3233-3249: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Missing dependencies in renderPeopleTable's useCallback.

patientQueryState now depends on patientListSearchTextInput (line 3233), and the JSX uses handleClearSearch/handleResetFilters (3245-3246, 3266-3267), but the dependency array only gained activeFilters and setActiveFilters. Until some other listed dependency changes (e.g. patientFetchOptions after the search debounce fires), the memoized callback keeps a stale patientQueryState, so ClearFilterButtons/EmptyContentNode copy can lag behind the actual search/filter state while typing.

🐛 Proposed fix
   }, [
     activeFilters,
     clinic?.fetchedPatientCount,
     columns,
     data,
     defaultPatientFetchOptions.sort,
+    handleClearSearch,
     handlePageChange,
+    handleResetFilters,
     handleSortChange,
     loading,
     patientFetchOptions,
+    patientListSearchTextInput,
     setActiveFilters,
     showSummaryData,
     tableStyle,
   ]);

Note handleClearSearch/handleResetFilters are plain function declarations (not useCallback-wrapped), so adding them will make this memoization recompute every render; if that regresses perf, memoizing those handlers is the more complete fix — but that's a pre-existing pattern beyond this diff's scope.

Also applies to: 3288-3301

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/pages/clinicworkspace/ClinicPatients.js` around lines 3233 - 3249, Update
the dependency array of renderPeopleTable’s useCallback to include
patientListSearchTextInput, handleClearSearch, and handleResetFilters, matching
the values used by patientQueryState and the rendered
ClearFilterButtons/EmptyContentNode. Preserve the existing dependencies and
ensure both affected JSX paths stay synchronized with current search and filter
state.

Source: Coding guidelines

app/pages/clinicworkspace/components/AppliedFilters.js (1)

166-171: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Missing PropTypes across all three new filter-chip/query-state components. None of the newly extracted components declare PropTypes for their props, contrary to the coding guideline "Define PropTypes for all component props."

  • app/pages/clinicworkspace/components/AppliedFilters.js#L166-L171: add PropTypes for AppliedFilters (filters: PropTypes.object, hasSearchActive: PropTypes.bool, onRemoveFilter: PropTypes.func, rightContent: PropTypes.node) and for internal ChipGroup/Chip.
  • app/pages/clinicworkspace/AppliedFiltersAdapter.js#L1-L10: add PropTypes for activeFilters, setActiveFilters, rightContent (the already-imported but unused PropTypes module suggests this was simply forgotten).
  • app/pages/clinicworkspace/components/ClearFilterButtons.js#L25-L25: add PropTypes for patientQueryState, onClearSearch, onResetFilters.
📍 Affects 3 files
  • app/pages/clinicworkspace/components/AppliedFilters.js#L166-L171 (this comment)
  • app/pages/clinicworkspace/AppliedFiltersAdapter.js#L1-L10
  • app/pages/clinicworkspace/components/ClearFilterButtons.js#L25-L25
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/pages/clinicworkspace/components/AppliedFilters.js` around lines 166 -
171, Declare PropTypes for all props in AppliedFilters, including its internal
ChipGroup and Chip components; define activeFilters, setActiveFilters, and
rightContent PropTypes in AppliedFiltersAdapter using the existing PropTypes
import; and add patientQueryState, onClearSearch, and onResetFilters PropTypes
to ClearFilterButtons. Use the specified types and preserve the current
component behavior.

Source: Coding guidelines

app/pages/clinicworkspace/components/CGMUseFilterDropdown.js (1)

19-19: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

git ls-files app/pages/clinicworkspace/components/CGMUseFilterDropdown.js app/pages/clinicworkspace/components/DataRecencyFilterDropdown.js core/metricUtils* core/*metric*

Repository: tidepool-org/blip

Length of output: 282


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== CGMUseFilterDropdown outline ==\n'
ast-grep outline app/pages/clinicworkspace/components/CGMUseFilterDropdown.js --view expanded || true

printf '\n== DataRecencyFilterDropdown outline ==\n'
ast-grep outline app/pages/clinicworkspace/components/DataRecencyFilterDropdown.js --view expanded || true

printf '\n== Search prefixPopHealthMetric and trackMetric ==\n'
rg -n "prefixPopHealthMetric|trackMetric" app/pages/clinicworkspace/components core -S

printf '\n== metricUtils files ==\n'
git ls-files core | rg 'metricUtils|metric'

Repository: tidepool-org/blip

Length of output: 6366


🏁 Script executed:

#!/bin/bash
set -euo pipefail

for f in app/pages/clinicworkspace/components/CGMUseFilterDropdown.js app/pages/clinicworkspace/components/DataRecencyFilterDropdown.js; do
  echo "===== $f ====="
  nl -ba "$f" | sed -n '1,240p'
done

echo "===== core metric utils candidates ====="
git ls-files core | rg 'metricUtils|metric'

Repository: tidepool-org/blip

Length of output: 268


🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n "function trackMetric|const trackMetric|export .*trackMetric|trackMetric\s*=" core app -S

Repository: tidepool-org/blip

Length of output: 8511


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "===== CGMUseFilterDropdown ====="
nl -ba app/pages/clinicworkspace/components/CGMUseFilterDropdown.js | sed -n '1,220p'

echo "===== DataRecencyFilterDropdown ====="
nl -ba app/pages/clinicworkspace/components/DataRecencyFilterDropdown.js | sed -n '1,220p'

echo "===== trackMetric definition ====="
rg -n "trackMetric" app core -S

Repository: tidepool-org/blip

Length of output: 228


🏁 Script executed:

#!/bin/bash
set -euo pipefail

nl -ba core/metricUtils.js 2>/dev/null | sed -n '1,220p' || true
nl -ba core/metricUtils/index.js 2>/dev/null | sed -n '1,220p' || true
rg -n "export .*trackMetric|function trackMetric|const trackMetric" core -S

Repository: tidepool-org/blip

Length of output: 200


🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -A4 -B4 "function trackMetric|const trackMetric|trackMetric\s*=" core app -S

Repository: tidepool-org/blip

Length of output: 50373


🏁 Script executed:

#!/bin/bash
set -euo pipefail

for f in app/core/metricUtils.js app/bootstrap.js app/pages/clinicworkspace/components/CGMUseFilterDropdown.js app/pages/clinicworkspace/components/DataRecencyFilterDropdown.js app/pages/clinicworkspace/components/TimeInRangeFilterDropdown.js; do
  echo "===== $f ====="
  sed -n '1,120p' "$f"
  echo
done

Repository: tidepool-org/blip

Length of output: 16372


Fix prefixPopHealthMetric to return a string

prefixPopHealthMetric ignores its argument and returns noop, so the trackMetric(prefixPopHealthMetric('...'), ...) calls in app/pages/clinicworkspace/components/CGMUseFilterDropdown.js, app/pages/clinicworkspace/components/DataRecencyFilterDropdown.js, app/pages/clinicworkspace/components/TimeInRangeFilterDropdown.js, and app/pages/clinicworkspace/components/SummaryPeriodFilterDropdown.js send a function as the event name instead of a metric string.

📍 Affects 2 files
  • app/pages/clinicworkspace/components/CGMUseFilterDropdown.js#L19-L19 (this comment)
  • app/pages/clinicworkspace/components/DataRecencyFilterDropdown.js#L24-L24
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/pages/clinicworkspace/components/CGMUseFilterDropdown.js` at line 19, The
prefixPopHealthMetric function must return the provided metric name as a string
rather than the noop function. Update prefixPopHealthMetric in
app/pages/clinicworkspace/components/CGMUseFilterDropdown.js:19 and
app/pages/clinicworkspace/components/DataRecencyFilterDropdown.js:24, and apply
the same correction to its usages in TimeInRangeFilterDropdown.js and
SummaryPeriodFilterDropdown.js, preserving the existing trackMetric calls.
app/pages/clinicworkspace/components/SiteFilterDropdown.js (2)

1-1: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Metrics silently disabled for clinic-sites and patient-tags filters. Both files locally stub trackMetric as a no-op instead of importing the real implementation (as SummaryPeriodFilterDropdown.js and TimeInRangeFilterDropdown.js correctly do), so every open/close/clear/apply metric call is dropped.

  • app/pages/clinicworkspace/components/SiteFilterDropdown.js#L33-34: replace the local trackMetric stub with import { trackMetric } from '../../../core/metricUtils';.
  • app/pages/clinicworkspace/components/TagFilterDropdown.js#L33-34: replace the local trackMetric stub with import { trackMetric } from '../../../core/metricUtils';.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/pages/clinicworkspace/components/SiteFilterDropdown.js` at line 1,
Replace the local no-op trackMetric stubs in SiteFilterDropdown and
TagFilterDropdown with imports of the real trackMetric implementation from the
established metricUtils module, preserving all existing metric call sites for
open, close, clear, and apply actions.

33-34: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

trackMetric is stubbed as a no-op — clinic sites filter interactions are not tracked.

Unlike SummaryPeriodFilterDropdown.js and TimeInRangeFilterDropdown.js, which import the real trackMetric from core/metricUtils, this file locally stubs both trackMetric and prefixPopHealthMetric as no-ops. Every trackMetric(...) call below (open/close/clear/apply) silently does nothing.

🐛 Proposed fix
-const trackMetric = () => noop;
-const prefixPopHealthMetric = () => noop;
+import { trackMetric } from '../../../core/metricUtils';
+
+const prefixPopHealthMetric = () => noop; // TODO: FIX
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/pages/clinicworkspace/components/SiteFilterDropdown.js` around lines 33 -
34, Replace the local no-op trackMetric declaration in SiteFilterDropdown with
the real trackMetric import from core/metricUtils, matching
SummaryPeriodFilterDropdown and TimeInRangeFilterDropdown. Preserve
prefixPopHealthMetric as-is unless it is also provided by that module, and leave
the existing open, close, clear, and apply tracking calls unchanged.
app/pages/clinicworkspace/components/SummaryPeriodFilterDropdown.js (2)

1-1: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

prefixPopHealthMetric TODO stub passes a function instead of a string to trackMetric. Both files define prefixPopHealthMetric = () => noop, discarding the metric-name argument, so every real trackMetric(prefixPopHealthMetric('...'), {...}) call sends the noop function reference as the event name.

  • app/pages/clinicworkspace/components/SummaryPeriodFilterDropdown.js#L19-19: implement prefixPopHealthMetric to actually prefix and return the passed-in metric name string.
  • app/pages/clinicworkspace/components/TimeInRangeFilterDropdown.js#L29-29: same fix, implement prefixPopHealthMetric to return the prefixed string.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/pages/clinicworkspace/components/SummaryPeriodFilterDropdown.js` at line
1, Update the prefixPopHealthMetric helper in both SummaryPeriodFilterDropdown
and TimeInRangeFilterDropdown so it accepts a metric-name argument and returns
the correctly prefixed string instead of the noop function reference. Preserve
the existing prefix format expected by trackMetric calls.

19-19: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Address the prefixPopHealthMetric TODO — it currently breaks trackMetric event names.

prefixPopHealthMetric ignores its string argument and returns noop, so every trackMetric(prefixPopHealthMetric('...'), {...}) call passes a function reference instead of the intended prefixed event-name string to the real trackMetric.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/pages/clinicworkspace/components/SummaryPeriodFilterDropdown.js` at line
19, Replace the placeholder implementation of prefixPopHealthMetric so it
accepts the metric-name string and returns the intended prefixed event-name
string. Preserve the existing trackMetric call sites and ensure they pass
strings rather than the noop function reference.
app/pages/clinicworkspace/components/TagFilterDropdown.js (2)

33-34: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

trackMetric is stubbed as a no-op — patient tag filter interactions are not tracked.

Same issue as SiteFilterDropdown.js: the real trackMetric is never imported here, so open/close/clear/apply events for tag filtering are silently dropped.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/pages/clinicworkspace/components/TagFilterDropdown.js` around lines 33 -
34, Replace the no-op trackMetric definition in TagFilterDropdown with the real
tracking utility import and use it for the existing tag-filter interaction
events, including open, close, clear, and apply. Keep prefixPopHealthMetric
unchanged unless required by the established tracking integration.

139-158: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Leftover "clinic-site" className/key on the tags "zero" option.

This <Box> renders the "Patients without any tags" option but keeps className="clinic-site-filter-option" and key="clinic-site-filter-option-PWDS_WITH_ZERO_TAGS" copied from the Sites dropdown, while the sibling id/data-testid correctly use "tag-filter-option". Any styling or selectors targeting .tag-filter-option will miss this element.

🐛 Proposed fix
-          <Box mt={1} pt={3} px={2} sx={{ borderTop: borders.divider }} className="clinic-site-filter-option" key="clinic-site-filter-option-PWDS_WITH_ZERO_TAGS">
+          <Box mt={1} pt={3} px={2} sx={{ borderTop: borders.divider }} className="tag-filter-option" key="tag-filter-option-PWDS_WITH_ZERO_TAGS">
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

        { // Display an option to filter for patients with zero tags
          sortedTagFilterOptions.length > 0 &&
          <Box mt={1} pt={3} px={2} sx={{ borderTop: borders.divider }} className="tag-filter-option" key="tag-filter-option-PWDS_WITH_ZERO_TAGS">
            <Checkbox
              id="tag-filter-option-checkbox-PWDS_WITH_ZERO_TAGS"
              data-testid="tag-filter-option-checkbox-PWDS_WITH_ZERO_TAGS"
              label={<Text sx={{ fontSize: 0, fontWeight: 'normal', fontStyle: 'italic' }}>
                {t('Patients without any tags')}
              </Text>}
              checked={isFilteringForZeroTags}
              onChange={() => {
                if (isFilteringForZeroTags) {
                  setPendingTags([]);
                } else {
                  setPendingTags(SPECIAL_FILTER_STATES.ZERO_TAGS);
                }
              }}
            />
          </Box>
        }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/pages/clinicworkspace/components/TagFilterDropdown.js` around lines 139 -
158, Update the zero-tags option Box in the tag filter dropdown to use the
tag-specific className and key naming convention, replacing the leftover
clinic-site identifiers while preserving the existing styling, rendering
condition, and checkbox behavior.
app/pages/clinicworkspace/components/TimeInRangeFilterDropdown.js (1)

29-29: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Same prefixPopHealthMetric TODO bug as SummaryPeriodFilterDropdown.js.

prefixPopHealthMetric discards its argument and returns noop, so trackMetric calls below receive a function reference instead of the metric name string.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/pages/clinicworkspace/components/TimeInRangeFilterDropdown.js` at line
29, Fix prefixPopHealthMetric in TimeInRangeFilterDropdown.js so it returns the
provided metric name string rather than the noop function reference. Match the
working implementation in SummaryPeriodFilterDropdown.js and preserve the
existing trackMetric calls.

@henry-tp henry-tp changed the title Web 4654 cgm use WEB-4654 - CGM User Filter Jul 17, 2026
@henry-tp henry-tp changed the title WEB-4654 - CGM User Filter WEB-4654 - CGM Use Jul 17, 2026
@henry-tp
henry-tp changed the base branch from WEB-4654-time-in-range to develop July 20, 2026 17:05
@henry-tp
henry-tp changed the base branch from develop to WEB-4654-time-in-range July 20, 2026 17:06
@henry-tp
henry-tp requested a review from clintonium-119 July 21, 2026 21:35
@henry-tp
henry-tp changed the base branch from WEB-4654-time-in-range to develop July 21, 2026 22:06
@henry-tp
henry-tp changed the base branch from develop to WEB-4654-time-in-range July 21, 2026 22:08
@henry-tp

Copy link
Copy Markdown
Contributor Author

/deploy qa2

@tidebot

tidebot commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

henry-tp updated values.yaml file in qa2

@tidebot

tidebot commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

henry-tp updated flux policies file in qa2

@tidebot

tidebot commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

henry-tp deployed blip WEB-4654-cgm-use branch to qa2 namespace

@henry-tp

Copy link
Copy Markdown
Contributor Author

/deploy qa5

@tidebot

tidebot commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

henry-tp updated values.yaml file in qa5

@tidebot

tidebot commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

henry-tp updated flux policies file in qa5

@tidebot

tidebot commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

henry-tp deployed blip WEB-4654-cgm-use branch to qa5 namespace

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