From a242100eb6f44355e4e0c58a60ef8f968df7b6e4 Mon Sep 17 00:00:00 2001 From: Henry Liang Date: Thu, 9 Jan 2025 10:27:02 -0800 Subject: [PATCH 01/39] initial use of formatDatum() method --- .../dashboard/PatientDrawer/CGMStatistics.js | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/app/pages/dashboard/PatientDrawer/CGMStatistics.js b/app/pages/dashboard/PatientDrawer/CGMStatistics.js index 1e8ebfa8c0..089a5681cd 100644 --- a/app/pages/dashboard/PatientDrawer/CGMStatistics.js +++ b/app/pages/dashboard/PatientDrawer/CGMStatistics.js @@ -5,6 +5,7 @@ import { useSelector } from 'react-redux'; import { Flex, Box, Text } from 'theme-ui'; import moment from 'moment'; import { utils as vizUtils } from '@tidepool/viz'; +const { formatDatum } = vizUtils.stat; import utils from '../../../core/utils'; import { MGDL_UNITS } from '../../../core/constants'; @@ -56,7 +57,7 @@ const CGMStatistics = ({ agpCGM }) => { const { timePrefs, - bgPrefs: { bgUnits }, + bgPrefs, data: { current: { endpoints: { days: endpointDays }, @@ -71,18 +72,21 @@ const CGMStatistics = ({ agpCGM }) => { } } = agpCGM; + const { bgUnits } = bgPrefs; + const timezoneName = vizUtils.datetime.getTimezoneFromTimePrefs(timePrefs); - const avgGlucosePrecision = bgUnits === MGDL_UNITS ? 0 : 1; - const avgGlucoseTarget = bgUnits === MGDL_UNITS ? '154' : '8.6'; + const avgGlucoseTarget = bgUnits === MGDL_UNITS ? '154' : '8.6'; const dateRange = formatDateRange(oldestDatum.time, newestDatum.time, timezoneName); const daySpan = endpointDays; const cgmActive = utils.roundToPrecision(sensorUsageAGP, 1); - const avgGlucose = utils.roundToPrecision(averageGlucose, avgGlucosePrecision); - const gmi = utils.roundToPrecision(glucoseManagementIndicatorAGP, 1); + const cov = utils.roundToPrecision(coefficientOfVariation, 1); + const avgGlucose = formatDatum({ value: averageGlucose }, 'bgValue', { bgPrefs, useAGPFormat: true }); + const gmi = formatDatum({ value: glucoseManagementIndicatorAGP }, 'gmi', { bgPrefs, useAGPFormat: true }); + return ( @@ -101,15 +105,15 @@ const CGMStatistics = ({ agpCGM }) => { id="agp-table-avg-glucose" label={t('Average Glucose')} sublabel={t('(Goal <{{avgGlucoseTarget}} {{bgUnits}})', { avgGlucoseTarget, bgUnits })} - value={`${avgGlucose}`} + value={avgGlucose.value} units={` ${bgUnits}`} /> Date: Thu, 9 Jan 2025 10:41:37 -0800 Subject: [PATCH 02/39] abstract out formattingOpts --- app/pages/dashboard/PatientDrawer/CGMStatistics.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/pages/dashboard/PatientDrawer/CGMStatistics.js b/app/pages/dashboard/PatientDrawer/CGMStatistics.js index 089a5681cd..bd06872990 100644 --- a/app/pages/dashboard/PatientDrawer/CGMStatistics.js +++ b/app/pages/dashboard/PatientDrawer/CGMStatistics.js @@ -84,8 +84,10 @@ const CGMStatistics = ({ agpCGM }) => { const cov = utils.roundToPrecision(coefficientOfVariation, 1); - const avgGlucose = formatDatum({ value: averageGlucose }, 'bgValue', { bgPrefs, useAGPFormat: true }); - const gmi = formatDatum({ value: glucoseManagementIndicatorAGP }, 'gmi', { bgPrefs, useAGPFormat: true }); + const formattingOpts = { bgPrefs, useAGPFormat: true } + + const avgGlucose = formatDatum({ value: averageGlucose }, 'bgValue', formattingOpts); + const gmi = formatDatum({ value: glucoseManagementIndicatorAGP }, 'gmi', formattingOpts); return ( From 1a69686295895ff4c49e53a0ee6c19585f4eec5d Mon Sep 17 00:00:00 2001 From: Henry Liang Date: Thu, 9 Jan 2025 23:07:10 -0800 Subject: [PATCH 03/39] use bankersRound for cgmActive --- app/pages/dashboard/PatientDrawer/CGMStatistics.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/pages/dashboard/PatientDrawer/CGMStatistics.js b/app/pages/dashboard/PatientDrawer/CGMStatistics.js index bd06872990..c531082251 100644 --- a/app/pages/dashboard/PatientDrawer/CGMStatistics.js +++ b/app/pages/dashboard/PatientDrawer/CGMStatistics.js @@ -5,7 +5,7 @@ import { useSelector } from 'react-redux'; import { Flex, Box, Text } from 'theme-ui'; import moment from 'moment'; import { utils as vizUtils } from '@tidepool/viz'; -const { formatDatum } = vizUtils.stat; +const { formatDatum, bankersRound } = vizUtils.stat; import utils from '../../../core/utils'; import { MGDL_UNITS } from '../../../core/constants'; @@ -80,14 +80,13 @@ const CGMStatistics = ({ agpCGM }) => { const dateRange = formatDateRange(oldestDatum.time, newestDatum.time, timezoneName); const daySpan = endpointDays; - const cgmActive = utils.roundToPrecision(sensorUsageAGP, 1); - - const cov = utils.roundToPrecision(coefficientOfVariation, 1); const formattingOpts = { bgPrefs, useAGPFormat: true } + const cgmActive = bankersRound(sensorUsageAGP, 1); const avgGlucose = formatDatum({ value: averageGlucose }, 'bgValue', formattingOpts); const gmi = formatDatum({ value: glucoseManagementIndicatorAGP }, 'gmi', formattingOpts); + const cov = formatDatum({ value: coefficientOfVariation }, 'cv', formattingOpts); return ( @@ -121,8 +120,8 @@ const CGMStatistics = ({ agpCGM }) => { id="agp-table-cov" label={t('Glucose Variability')} sublabel={t('(Defined as a percent coefficient of variation. Goal <= 36%)')} - value={`${cov}`} - units="%" + value={cov?.value} + units={cov?.suffix} /> From e4ac1523a2efdc0f23a7c3573951ea045ddf9612 Mon Sep 17 00:00:00 2001 From: Henry Liang Date: Fri, 10 Jan 2025 10:44:17 -0800 Subject: [PATCH 04/39] utilise methods in AGP Report View for report days text --- .../CGMStatistics/getReportDaysText.js | 41 +++++++++++++++++++ .../index.js} | 25 +++-------- 2 files changed, 46 insertions(+), 20 deletions(-) create mode 100644 app/pages/dashboard/PatientDrawer/CGMStatistics/getReportDaysText.js rename app/pages/dashboard/PatientDrawer/{CGMStatistics.js => CGMStatistics/index.js} (80%) diff --git a/app/pages/dashboard/PatientDrawer/CGMStatistics/getReportDaysText.js b/app/pages/dashboard/PatientDrawer/CGMStatistics/getReportDaysText.js new file mode 100644 index 0000000000..c89fc03d06 --- /dev/null +++ b/app/pages/dashboard/PatientDrawer/CGMStatistics/getReportDaysText.js @@ -0,0 +1,41 @@ +import moment from 'moment'; +import { MS_IN_MIN } from '../../../../core/constants'; +import isNumber from 'lodash/isNumber'; +import { utils as vizUtils } from '@tidepool/viz'; +const { getOffset } = vizUtils.datetime; + +export const formatDateRange = (startDate, endDate, dateParseFormat, monthFormat = 'MMM') => { + const start = moment.utc(startDate, dateParseFormat); + const end = moment.utc(endDate, dateParseFormat); + + const isSameYear = start.isSame(end, 'year'); + const isSameDay = start.isSame(end, 'day'); + const startFormat = isSameYear ? start.format(`${monthFormat} D`) : start.format(`${monthFormat} D, YYYY`); + const endFormat = end.format(`${monthFormat} D, YYYY`); + + const formattedRange = isSameDay ? endFormat : `${startFormat} - ${endFormat}`; + + return formattedRange; +}; + +const getDateRange = (startDate, endDate, dateParseFormat, _prefix, monthFormat, timezone) => { + let start = startDate; + let end = endDate; + + if (isNumber(startDate) && isNumber(endDate)) { + start = startDate - getOffset(startDate, timezone) * MS_IN_MIN; + end = endDate - getOffset(endDate, timezone) * MS_IN_MIN; + } + + return formatDateRange(start, end, dateParseFormat, monthFormat); +}; + +const getReportDaysText = (newestDatum, oldestDatum, bgDaysWorn, timezone) => { + const reportDaysText = bgDaysWorn === 1 + ? moment.utc(newestDatum?.time - getOffset(newestDatum?.time, timezone) * MS_IN_MIN).format('MMMM D, YYYY') + : getDateRange(oldestDatum?.time, newestDatum?.time, undefined, '', 'MMMM', timezone); + + return reportDaysText; +}; + +export default getReportDaysText; \ No newline at end of file diff --git a/app/pages/dashboard/PatientDrawer/CGMStatistics.js b/app/pages/dashboard/PatientDrawer/CGMStatistics/index.js similarity index 80% rename from app/pages/dashboard/PatientDrawer/CGMStatistics.js rename to app/pages/dashboard/PatientDrawer/CGMStatistics/index.js index c531082251..d0c108b1c9 100644 --- a/app/pages/dashboard/PatientDrawer/CGMStatistics.js +++ b/app/pages/dashboard/PatientDrawer/CGMStatistics/index.js @@ -1,26 +1,11 @@ import React from 'react'; -import colorPalette from '../../../themes/colorPalette'; +import colorPalette from '../../../../themes/colorPalette'; import { useTranslation } from 'react-i18next'; -import { useSelector } from 'react-redux'; import { Flex, Box, Text } from 'theme-ui'; -import moment from 'moment'; import { utils as vizUtils } from '@tidepool/viz'; const { formatDatum, bankersRound } = vizUtils.stat; -import utils from '../../../core/utils'; -import { MGDL_UNITS } from '../../../core/constants'; - -const formatDateRange = (startEndpoint, endEndpoint, timezoneName) => { - const startDate = moment.utc(startEndpoint).tz(timezoneName); - const endDate = moment.utc(endEndpoint).tz(timezoneName); - const startYear = startDate.year(); - const endYear = endDate.year(); - - if (startYear !== endYear) { - return `${startDate.format('MMMM D, YYYY')} - ${endDate.format('MMMM D, YYYY')}`; - } - - return `${startDate.format('MMMM D')} - ${endDate.format('MMMM D')}, ${endDate.format('YYYY')}`; -} +import { MGDL_UNITS } from '../../../../core/constants'; +import getReportDaysText from './getReportDaysText'; const TableRow = ({ label, sublabel, value, units, id }) => { return ( @@ -62,7 +47,7 @@ const CGMStatistics = ({ agpCGM }) => { current: { endpoints: { days: endpointDays }, stats: { - bgExtents: { newestDatum, oldestDatum }, + bgExtents: { newestDatum, oldestDatum, bgDaysWorn }, sensorUsage: { sensorUsageAGP }, averageGlucose: { averageGlucose }, glucoseManagementIndicator: { glucoseManagementIndicatorAGP }, @@ -78,11 +63,11 @@ const CGMStatistics = ({ agpCGM }) => { const avgGlucoseTarget = bgUnits === MGDL_UNITS ? '154' : '8.6'; - const dateRange = formatDateRange(oldestDatum.time, newestDatum.time, timezoneName); const daySpan = endpointDays; const formattingOpts = { bgPrefs, useAGPFormat: true } + const dateRange = getReportDaysText(newestDatum, oldestDatum, bgDaysWorn, timezoneName); const cgmActive = bankersRound(sensorUsageAGP, 1); const avgGlucose = formatDatum({ value: averageGlucose }, 'bgValue', formattingOpts); const gmi = formatDatum({ value: glucoseManagementIndicatorAGP }, 'gmi', formattingOpts); From 047e759145d8966c6e16262eab445fc63c5fe6cf Mon Sep 17 00:00:00 2001 From: Henry Liang Date: Fri, 10 Jan 2025 10:50:50 -0800 Subject: [PATCH 05/39] cleanup: remove unused destructured vars --- .../CGMStatistics/getReportDaysText.js | 2 +- .../PatientDrawer/CGMStatistics/index.js | 22 ++++++++----------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/app/pages/dashboard/PatientDrawer/CGMStatistics/getReportDaysText.js b/app/pages/dashboard/PatientDrawer/CGMStatistics/getReportDaysText.js index c89fc03d06..f72dddef14 100644 --- a/app/pages/dashboard/PatientDrawer/CGMStatistics/getReportDaysText.js +++ b/app/pages/dashboard/PatientDrawer/CGMStatistics/getReportDaysText.js @@ -4,7 +4,7 @@ import isNumber from 'lodash/isNumber'; import { utils as vizUtils } from '@tidepool/viz'; const { getOffset } = vizUtils.datetime; -export const formatDateRange = (startDate, endDate, dateParseFormat, monthFormat = 'MMM') => { +const formatDateRange = (startDate, endDate, dateParseFormat, monthFormat = 'MMM') => { const start = moment.utc(startDate, dateParseFormat); const end = moment.utc(endDate, dateParseFormat); diff --git a/app/pages/dashboard/PatientDrawer/CGMStatistics/index.js b/app/pages/dashboard/PatientDrawer/CGMStatistics/index.js index d0c108b1c9..6277f62347 100644 --- a/app/pages/dashboard/PatientDrawer/CGMStatistics/index.js +++ b/app/pages/dashboard/PatientDrawer/CGMStatistics/index.js @@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next'; import { Flex, Box, Text } from 'theme-ui'; import { utils as vizUtils } from '@tidepool/viz'; const { formatDatum, bankersRound } = vizUtils.stat; +const { getTimezoneFromTimePrefs } = vizUtils.datetime; import { MGDL_UNITS } from '../../../../core/constants'; import getReportDaysText from './getReportDaysText'; @@ -45,33 +46,28 @@ const CGMStatistics = ({ agpCGM }) => { bgPrefs, data: { current: { - endpoints: { days: endpointDays }, stats: { bgExtents: { newestDatum, oldestDatum, bgDaysWorn }, sensorUsage: { sensorUsageAGP }, averageGlucose: { averageGlucose }, glucoseManagementIndicator: { glucoseManagementIndicatorAGP }, - coefficientOfVariation: { coefficientOfVariation } + coefficientOfVariation: { coefficientOfVariation }, }, } - } + }, } = agpCGM; const { bgUnits } = bgPrefs; - const timezoneName = vizUtils.datetime.getTimezoneFromTimePrefs(timePrefs); + const timezone = getTimezoneFromTimePrefs(timePrefs); const avgGlucoseTarget = bgUnits === MGDL_UNITS ? '154' : '8.6'; - const daySpan = endpointDays; - - const formattingOpts = { bgPrefs, useAGPFormat: true } - - const dateRange = getReportDaysText(newestDatum, oldestDatum, bgDaysWorn, timezoneName); + const dateRange = getReportDaysText(newestDatum, oldestDatum, bgDaysWorn, timezone); const cgmActive = bankersRound(sensorUsageAGP, 1); - const avgGlucose = formatDatum({ value: averageGlucose }, 'bgValue', formattingOpts); - const gmi = formatDatum({ value: glucoseManagementIndicatorAGP }, 'gmi', formattingOpts); - const cov = formatDatum({ value: coefficientOfVariation }, 'cv', formattingOpts); + const avgGlucose = formatDatum({ value: averageGlucose }, 'bgValue', { bgPrefs, useAGPFormat: true }); + const gmi = formatDatum({ value: glucoseManagementIndicatorAGP }, 'gmi', { bgPrefs, useAGPFormat: true }); + const cov = formatDatum({ value: coefficientOfVariation }, 'cv', { bgPrefs, useAGPFormat: true }); return ( @@ -79,7 +75,7 @@ const CGMStatistics = ({ agpCGM }) => { Date: Fri, 10 Jan 2025 20:59:55 +0100 Subject: [PATCH 06/39] fix time zone discrepancy --- .../dashboard/PatientDrawer/useAgpCGM/getOpts.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/pages/dashboard/PatientDrawer/useAgpCGM/getOpts.js b/app/pages/dashboard/PatientDrawer/useAgpCGM/getOpts.js index 13b543dca3..11323d0d5e 100644 --- a/app/pages/dashboard/PatientDrawer/useAgpCGM/getOpts.js +++ b/app/pages/dashboard/PatientDrawer/useAgpCGM/getOpts.js @@ -2,6 +2,7 @@ import moment from 'moment-timezone'; import _ from 'lodash'; import get from 'lodash/get'; import { utils as vizUtils } from '@tidepool/viz'; +import utils from '../../../../core/utils'; const getTimezoneFromTimePrefs = vizUtils.datetime.getTimezoneFromTimePrefs; @@ -39,7 +40,16 @@ const getOpts = ( agpCGM: getMostRecentDatumTimeByChartType(data, 'agpCGM'), }; - const timezoneName = getTimezoneFromTimePrefs(data?.timePrefs); + const timePrefs = (() => { + const latestTimeZone = data?.metaData?.latestTimeZone; + const queryParams = {}; + + const localTimePrefs = utils.getTimePrefsForDataProcessing(latestTimeZone, queryParams); + + return localTimePrefs; + })() + + const timezoneName = getTimezoneFromTimePrefs(timePrefs); const endOfToday = moment.utc().tz(timezoneName).endOf('day').subtract(1, 'ms'); @@ -68,6 +78,8 @@ const getOpts = ( const dates = defaultDates(); + console.log('useAgpCGM dates', dates); + const formatDateEndpoints = ({ startDate, endDate }) => (startDate && endDate ? [ startDate.valueOf(), moment.utc(endDate).tz(timezoneName).add(1, 'day').startOf('day').valueOf(), From 788f6f0e5a0e098ad9782bbb396b92b2e4887b82 Mon Sep 17 00:00:00 2001 From: Henry Liang Date: Fri, 10 Jan 2025 22:11:01 +0100 Subject: [PATCH 07/39] remove console.log --- app/pages/dashboard/PatientDrawer/useAgpCGM/getOpts.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/pages/dashboard/PatientDrawer/useAgpCGM/getOpts.js b/app/pages/dashboard/PatientDrawer/useAgpCGM/getOpts.js index 11323d0d5e..8449ff7ce0 100644 --- a/app/pages/dashboard/PatientDrawer/useAgpCGM/getOpts.js +++ b/app/pages/dashboard/PatientDrawer/useAgpCGM/getOpts.js @@ -78,8 +78,6 @@ const getOpts = ( const dates = defaultDates(); - console.log('useAgpCGM dates', dates); - const formatDateEndpoints = ({ startDate, endDate }) => (startDate && endDate ? [ startDate.valueOf(), moment.utc(endDate).tz(timezoneName).add(1, 'day').startOf('day').valueOf(), From 6c2d6c05ef02b7efdd7334f77419f1c9d6b05ab6 Mon Sep 17 00:00:00 2001 From: Henry Liang Date: Fri, 10 Jan 2025 14:34:37 -0800 Subject: [PATCH 08/39] use safe navigation for avgGlucose.value --- app/pages/dashboard/PatientDrawer/CGMStatistics/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/pages/dashboard/PatientDrawer/CGMStatistics/index.js b/app/pages/dashboard/PatientDrawer/CGMStatistics/index.js index 6277f62347..b99e8b8d59 100644 --- a/app/pages/dashboard/PatientDrawer/CGMStatistics/index.js +++ b/app/pages/dashboard/PatientDrawer/CGMStatistics/index.js @@ -87,7 +87,7 @@ const CGMStatistics = ({ agpCGM }) => { id="agp-table-avg-glucose" label={t('Average Glucose')} sublabel={t('(Goal <{{avgGlucoseTarget}} {{bgUnits}})', { avgGlucoseTarget, bgUnits })} - value={avgGlucose.value} + value={avgGlucose?.value} units={` ${bgUnits}`} /> Date: Mon, 13 Jan 2025 09:01:31 -0800 Subject: [PATCH 09/39] check data sufficiency for clipboard using count * sampleFrequency --- .../MenuBar/CGMClipboardButton.js | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/app/pages/dashboard/PatientDrawer/MenuBar/CGMClipboardButton.js b/app/pages/dashboard/PatientDrawer/MenuBar/CGMClipboardButton.js index 549b454655..f04360f978 100644 --- a/app/pages/dashboard/PatientDrawer/MenuBar/CGMClipboardButton.js +++ b/app/pages/dashboard/PatientDrawer/MenuBar/CGMClipboardButton.js @@ -2,7 +2,7 @@ import React, { useEffect, useState, useMemo } from 'react'; import { useTranslation } from 'react-i18next'; import Button from '../../../../components/elements/Button'; import utils from '../../../../core/utils'; -import { MGDL_UNITS } from '../../../../core/constants'; +import { MGDL_UNITS, MS_IN_HOUR } from '../../../../core/constants'; import { utils as vizUtils } from '@tidepool/viz'; const { TextUtil } = vizUtils.text; import { Box } from 'theme-ui' @@ -19,7 +19,7 @@ const formatDateRange = (startEndpoint, endEndpoint, timezoneName) => { } return `${startDate.format('MMMM D')} - ${endDate.format('MMMM D')}, ${endDate.format('YYYY')}`; -} +}; const getCGMClipboardText = (patient, agpCGM, t) => { if (!agpCGM || !patient) return ''; @@ -36,8 +36,8 @@ const getCGMClipboardText = (patient, agpCGM, t) => { averageGlucose: { averageGlucose }, timeInRange: { counts }, }, - } - } + }, + }, } = agpCGM; const timezoneName = vizUtils.datetime.getTimezoneFromTimePrefs(timePrefs); @@ -74,37 +74,37 @@ const getCGMClipboardText = (patient, agpCGM, t) => { clipboardText += textUtil.buildTextLine(t('Avg. Glucose (CGM): {{avgGlucose}} {{bgUnits}}', { avgGlucose, bgUnits })); return clipboardText; -} +}; const STATE = { DEFAULT: 'DEFAULT', CLICKED: 'CLICKED', -} +}; const CGMClipboardButton = ({ patient, agpCGM }) => { const { t } = useTranslation(); const [buttonState, setButtonState] = useState(STATE.DEFAULT); + const clipboardText = useMemo(() => getCGMClipboardText(patient, agpCGM, t), [patient, agpCGM, t]); useEffect(() => { let buttonTextEffect = setTimeout(() => { - setButtonState(STATE.DEFAULT) + setButtonState(STATE.DEFAULT); }, 1000); return () => { clearTimeout(buttonTextEffect); - } - }, [buttonState]) + }; + }, [buttonState]); - const sensorUsage = agpCGM?.data?.current?.stats?.sensorUsage?.sensorUsage || 0; + const { count, sampleFrequency } = agpCGM?.data?.current?.stats?.sensorUsage || {}; - const isDisabled = !agpCGM || sensorUsage < 86400000; // minimum 24 hours - - const clipboardText = useMemo(() => getCGMClipboardText(patient, agpCGM, t), [patient, agpCGM, t]); + const isDataInsufficient = ((count * sampleFrequency) / MS_IN_HOUR) < 24; // minimum 24 hours + const isDisabled = !agpCGM || isDataInsufficient; const handleCopy = () => { navigator?.clipboard?.writeText(clipboardText); setButtonState(STATE.CLICKED); - } + }; return ( - ) -} + ); +}; export default CGMClipboardButton; \ No newline at end of file From 7e8439d80fec96d5569d382bc6ec32a3631ce748 Mon Sep 17 00:00:00 2001 From: Henry Liang Date: Mon, 13 Jan 2025 09:21:51 -0800 Subject: [PATCH 10/39] clean up clipboard conditions --- .../dashboard/PatientDrawer/MenuBar/CGMClipboardButton.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/pages/dashboard/PatientDrawer/MenuBar/CGMClipboardButton.js b/app/pages/dashboard/PatientDrawer/MenuBar/CGMClipboardButton.js index f04360f978..45bfa21167 100644 --- a/app/pages/dashboard/PatientDrawer/MenuBar/CGMClipboardButton.js +++ b/app/pages/dashboard/PatientDrawer/MenuBar/CGMClipboardButton.js @@ -98,8 +98,9 @@ const CGMClipboardButton = ({ patient, agpCGM }) => { const { count, sampleFrequency } = agpCGM?.data?.current?.stats?.sensorUsage || {}; - const isDataInsufficient = ((count * sampleFrequency) / MS_IN_HOUR) < 24; // minimum 24 hours - const isDisabled = !agpCGM || isDataInsufficient; + const hoursOfCGMData = count * sampleFrequency; + + const isDataInsufficient = !hoursOfCGMData || ((hoursOfCGMData / MS_IN_HOUR) < 24); // minimum 24 hours const handleCopy = () => { navigator?.clipboard?.writeText(clipboardText); @@ -107,7 +108,7 @@ const CGMClipboardButton = ({ patient, agpCGM }) => { }; return ( -