From dfa3bfe184f3c57e9c7449fe9b1a25eafeb1ca6c Mon Sep 17 00:00:00 2001 From: clintonium-119 Date: Thu, 15 Aug 2024 17:05:13 -0400 Subject: [PATCH 1/3] Skip device selection if only one pump and cgm option available --- app/pages/prescription/PrescriptionForm.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/app/pages/prescription/PrescriptionForm.js b/app/pages/prescription/PrescriptionForm.js index dc96d4c501..d916b72b1d 100644 --- a/app/pages/prescription/PrescriptionForm.js +++ b/app/pages/prescription/PrescriptionForm.js @@ -53,6 +53,7 @@ import * as actions from '../../redux/actions'; import { components as vizComponents } from '@tidepool/viz'; import { + cgmDeviceOptions, defaultUnits, deviceIdMap, prescriptionStateOptions, @@ -335,7 +336,7 @@ export const PrescriptionForm = props => { const [singleStepEditValues, setSingleStepEditValues] = useState(values); const isSingleStepEdit = !!pendingStep.length; const validationFields = [ ...stepValidationFields ]; - const isLastStep = activeStep === validationFields.length - 1; + const isLastStep = () => activeStep === validationFields.length - 1; const isNewPrescription = isEmpty(get(values, 'id')); const handlers = { @@ -379,7 +380,7 @@ export const PrescriptionForm = props => { // We can't simply delete all future steps, as the clinician may have returned to the current // step via 'Back' button navigation and we don't want to lose existing data previously // entered in the later steps. - if (!isLastStep) { + if (!isLastStep()) { const emptyFieldsInFutureSteps = remove( flattenDeep(slice(validationFields, activeStep + 1)), fieldPath => { @@ -415,7 +416,7 @@ export const PrescriptionForm = props => { prescriptionAttributes.createdUserId = loggedInUserId; prescriptionAttributes.prescriberTermsAccepted = isPrescriber && get(values, 'therapySettingsReviewed'); - if (isLastStep) prescriptionAttributes.state = isPrescriber ? 'submitted' : 'pending'; + if (isLastStep()) prescriptionAttributes.state = isPrescriber ? 'submitted' : 'pending'; setFieldValue('state', prescriptionAttributes.state); prescriptionAttributes.revisionHash = await sha512( @@ -480,8 +481,19 @@ export const PrescriptionForm = props => { }, ]; - // Remove calculator step if selected pump, or all available pump options are set to skip aace calculator const pumpDevices = pumpDeviceOptions(devices); + const cgmDevices = cgmDeviceOptions(devices); + + // Skip device selection substep and set default pump and cgm IDs if there aren't multiple choices available + const skipDeviceSelection = cgmDevices.length === 1 && pumpDevices.length === 1; + if (skipDeviceSelection) { + if (!values.initialSettings?.cgmId) setFieldValue('initialSettings.cgmId', cgmDevices[0].value); + if (!values.initialSettings?.pumpId) setFieldValue('initialSettings.pumpId', pumpDevices[0].value); + validationFields[1].splice(2, 1); + steps[1].subSteps.splice(3, 1); + } + + // Skip calculator step if selected pump, or all available pump options are set to skip aace calculator const skipCalculator = !!(pumpDevices.length && every(pumpDevices, { skipCalculator: true })) || !!find(devices, { value: pumpId })?.skipCalculator; if (skipCalculator) { validationFields.splice(2, 1); @@ -552,7 +564,7 @@ export const PrescriptionForm = props => { if (!isFirstRender && !inProgress) { if (completed) { setStepAsyncState(asyncStates.completed); - if (isLastStep) { + if (isLastStep()) { let messageAction = isRevision ? t('updated') : t('created'); if (isPrescriber) messageAction = t('finalized and sent'); From d53624300ec371a6bff8ae070eb7b0df5c52a02c Mon Sep 17 00:00:00 2001 From: clintonium-119 Date: Fri, 16 Aug 2024 13:27:11 -0400 Subject: [PATCH 2/3] Add html ids to rx flow steps to ease testing efforts --- app/pages/prescription/accountFormSteps.js | 6 +++--- app/pages/prescription/profileFormSteps.js | 8 ++++---- app/pages/prescription/reviewFormStep.js | 1 + app/pages/prescription/settingsCalculatorFormSteps.js | 4 ++-- app/pages/prescription/therapySettingsFormStep.js | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/app/pages/prescription/accountFormSteps.js b/app/pages/prescription/accountFormSteps.js index 487347514a..b4b6dab917 100644 --- a/app/pages/prescription/accountFormSteps.js +++ b/app/pages/prescription/accountFormSteps.js @@ -24,7 +24,7 @@ export const AccountType = withTranslation()(props => { const formikContext = useFormikContext(); return ( - + {t('Who are you creating an account for?')} { const maskFormat = dateInputFormat.replace(/[A-Z]/g, '9'); return ( - + {t('Please enter the patient\'s name and birthdate')} { }, []); return ( - + {headline} {isCaregiverAccount && ( { const initialFocusedInputRef = useInitialFocusedInput(); return ( - + {t('What is the mobile phone number {{patientName}} will use with Tidepool Loop?', { patientName })} ( @@ -90,7 +90,7 @@ export const PatientMRN = withTranslation()(props => { const initialFocusedInputRef = useInitialFocusedInput(); return ( - + {t('What is {{patientName}}\'s Medical Record Number?', { patientName })} { const initialFocusedInputRef = useInitialFocusedInput(); return ( - + {t('What is {{patientName}}\'s gender?', { patientName })} { const [hasInitialFocus, setHasInitialFocus] = React.useState(true); return ( - + {t('Does {{patientName}} have the necessary prescriptions for Tidepool Loop compatible devices?', { patientName })} {map(pumpDeviceOptions(devices), device => ( diff --git a/app/pages/prescription/reviewFormStep.js b/app/pages/prescription/reviewFormStep.js index 45da7e5228..f5d33467d3 100644 --- a/app/pages/prescription/reviewFormStep.js +++ b/app/pages/prescription/reviewFormStep.js @@ -529,6 +529,7 @@ export const PrescriptionReview = withTranslation()(props => { return ( { }, [method]); return ( - + {t('Optional Therapy Settings Calculator')} @@ -97,7 +97,7 @@ export const CalculatorInputs = withTranslation()(props => { const showWeight = includes(['weight', 'totalDailyDoseAndWeight'], method); return ( - + {t('Optional Therapy Settings Calculator')} diff --git a/app/pages/prescription/therapySettingsFormStep.js b/app/pages/prescription/therapySettingsFormStep.js index 965d749d28..84569cbdef 100644 --- a/app/pages/prescription/therapySettingsFormStep.js +++ b/app/pages/prescription/therapySettingsFormStep.js @@ -644,7 +644,7 @@ export const TherapySettings = withTranslation()(props => { }); return ( - + {hasCalculatorResults(values) && } From b1272ac1ff1b9844920cfc8b0d6028d62b3208b4 Mon Sep 17 00:00:00 2001 From: clintonium-119 Date: Fri, 16 Aug 2024 13:27:31 -0400 Subject: [PATCH 3/3] v1.81.0-web-3068-default-device-selection.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 52fb373369..54acc3f590 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "node": "20.8.0" }, "packageManager": "yarn@3.6.4", - "version": "1.81.0-web-3020-disable-ace-calculator-palmtree.1", + "version": "1.81.0-web-3068-default-device-selection.1", "private": true, "scripts": { "test": "TZ=UTC NODE_ENV=test NODE_OPTIONS='--max-old-space-size=4096' yarn karma start",