From f6b56f1665630948adf245235edbf469975ac6de Mon Sep 17 00:00:00 2001 From: mdewey <1793923+mdewey@users.noreply.github.com> Date: Mon, 2 Dec 2024 16:29:55 -0500 Subject: [PATCH 1/4] (bug) added the fix for the loading bug --- .../containers/LandingPage.jsx | 777 +++++++++--------- .../hooks/useAcceleratedData.js | 10 +- ...loading-hook.oracle-health.cypress.spec.js | 26 + 3 files changed, 428 insertions(+), 385 deletions(-) create mode 100644 src/applications/mhv-medical-records/tests/e2e/accelerated/vitals-loading-hook.oracle-health.cypress.spec.js diff --git a/src/applications/mhv-medical-records/containers/LandingPage.jsx b/src/applications/mhv-medical-records/containers/LandingPage.jsx index 3a966cfe7279..7182c16e1962 100644 --- a/src/applications/mhv-medical-records/containers/LandingPage.jsx +++ b/src/applications/mhv-medical-records/containers/LandingPage.jsx @@ -47,6 +47,7 @@ const LandingPage = () => { state => state.featureToggles.mhv_integration_medical_records_to_phase_1, ); const { + isLoading, isAcceleratingAllergies, isAcceleratingVitals, } = useAcceleratedData(); @@ -89,434 +90,442 @@ const LandingPage = () => {

- {displayLabsAndTest && ( -
-

- Lab and test results -

-

- Get results of your VA medical tests. This includes blood tests, - X-rays, and other imaging tests. -

- {isAcceleratingEnabled ? ( - - View your labs and tests on My VA Health (opens in new tab) - - ) : ( - - Go to your lab and test results - + {!isLoading && ( + <> + {displayLabsAndTest && ( +
+

+ Lab and test results +

+

+ Get results of your VA medical tests. This includes blood tests, + X-rays, and other imaging tests. +

+ {isAcceleratingEnabled ? ( + + View your labs and tests on My VA Health (opens in new tab) + + ) : ( + + Go to your lab and test results + + )} +
)} -
- )} - {displayNotes && ( -
-

- Care summaries and notes -

-

- Get notes from your VA providers about your health and health care. - This includes summaries of your stays in health facilities (called - admission and discharge summaries). -

- {isAcceleratingEnabled ? ( - <> + {displayNotes && ( +
+

+ Care summaries and notes +

+

+ Get notes from your VA providers about your health and health + care. This includes summaries of your stays in health facilities + (called admission and discharge summaries). +

+ {isAcceleratingEnabled ? ( + <> + + View your care summaries and notes on My VA Health (opens in + new window) + + + ) : ( + <> + + Go to your care summaries and notes + + + )} +
+ )} + {displayVaccines && ( +
+

+ Vaccines +

+

+ Get a list of all vaccines (immunizations) in your VA medical + records. +

+ {isAcceleratingEnabled ? ( + + View your vaccines on My VA Health (opens in new tab) + + ) : ( + + Go to your vaccines + + )} +
+ )} +
+

+ Allergies and reactions +

+

+ Get a list of all allergies, reactions, and side effects in your + VA medical records. This includes medication side effects (also + called adverse drug reactions). +

+ {isAcceleratingEnabled && !isAcceleratingAllergies ? ( - View your care summaries and notes on My VA Health (opens in new - window) + View your allergies on My VA Health (opens in new tab) - - ) : ( - <> + ) : ( - Go to your care summaries and notes + Go to your allergies and reactions - - )} -
- )} - {displayVaccines && ( -
-

- Vaccines -

-

- Get a list of all vaccines (immunizations) in your VA medical - records. -

- {isAcceleratingEnabled ? ( - + {displayConditions && ( +
+

+ Health conditions +

+

+ Get a list of health conditions your VA providers are helping + you manage. +

+ {isAcceleratingEnabled ? ( +
+ View your health conditions on My VA Health (opens in new tab) + + ) : ( + + Go to your health conditions + )} - target="_blank" - rel="noopener noreferrer" - data-testid="vaccines-oh-landing-page-link" - > - View your vaccines on My VA Health (opens in new tab) - - ) : ( - - Go to your vaccines - +
)} -
- )} -
-

- Allergies and reactions -

-

- Get a list of all allergies, reactions, and side effects in your VA - medical records. This includes medication side effects (also called - adverse drug reactions). -

- {isAcceleratingEnabled && !isAcceleratingAllergies ? ( - - View your allergies on My VA Health (opens in new tab) - - ) : ( - - Go to your allergies and reactions - - )} -
- {displayConditions && ( -
-

- Health conditions -

-

- Get a list of health conditions your VA providers are helping you - manage. -

- {isAcceleratingEnabled ? ( - - View your health conditions on My VA Health (opens in new tab) - - ) : ( - - Go to your health conditions - + {displayVitals && ( +
+

+ Vitals +

+

+ Get records of these basic health numbers your providers check + at appointments: +

+
    +
  • Blood pressure and blood oxygen level
  • +
  • Breathing rate and heart rate
  • +
  • Height and weight
  • +
  • Temperature
  • +
+ {isAcceleratingEnabled && !isAcceleratingVitals ? ( + + View your vitals on My VA Health (opens in new tab) + + ) : ( + + Go to your vitals + + )} +
)} -
- )} - {displayVitals && ( -
-

- Vitals -

-

- Get records of these basic health numbers your providers check at - appointments: -

- - {isAcceleratingEnabled && !isAcceleratingVitals ? ( - - View your vitals on My VA Health (opens in new tab) - - ) : ( - - Go to your vitals - + {displayMedicalRecordsSettings && ( +
+

+ Manage your medical records settings +

+

+ Review and update your medical records sharing and notification + settings. +

+ + Go to your medical records settings + +
)} -
- )} - {displayMedicalRecordsSettings && ( -
-

- Manage your medical records settings -

-

- Review and update your medical records sharing and notification - settings. -

- - Go to your medical records settings - -
- )} -
-

- Download your Blue Button report or health summary -

-

- We’re working on a way to download all your medical records here as a - single file or a summary. -

-

- For now, you can continue to download your VA Blue Button® report or - your VA Health Summary on the previous version of My HealtheVet. -

-

- -

-
-
-

- What to know as you try out this tool -

-

- We’re giving the trusted My HealtheVet medical records tool a new home - here on VA.gov. And we need your feedback to help us keep making this - tool better for you and all Veterans. -

-

- Send us your feedback and questions using the feedback button on this - page. -

-

- Note: You still have - access to your medical records on the My HealtheVet website. You can - go back to that site at any time.{' '} - -

-
-
-

Questions about this medical records tool

- - -

- Where can I find health information I entered myself? -

+
+

+ Download your Blue Button report or health summary +

- Right now, your records on VA.gov only include health information - your VA providers have entered. + We’re working on a way to download all your medical records here + as a single file or a summary.

- To find health information you entered yourself, go to your - medical records on the My HealtheVet website. + For now, you can continue to download your VA Blue Button® report + or your VA Health Summary on the previous version of My + HealtheVet.

-

+

- - -

- How can I tell my care team that my health information has - changed? -

- -

- If you need to add or change health information in your records, - you can tell your provider at your next appointment. -

-

- Or you can send a secure message to your care team and ask them to - update your records. -

+
+
+

+ What to know as you try out this tool +

- {phase0p5Flag ? ( - - ) : ( - - )} + We’re giving the trusted My HealtheVet medical records tool a new + home here on VA.gov. And we need your feedback to help us keep + making this tool better for you and all Veterans.

- - -

- Will VA protect my personal health information? -

- Yes. This is a secure website. We follow strict security policies - and practices to protect your personal health information. Only - you and your VA care team will have access to your records. + Send us your feedback and questions using the feedback button on + this page.

- If you print or download any records, you’ll need to take - responsibility for protecting that information. If you’re on a - public or shared computer, remember that downloading will save a - copy of your records to the computer you’re using. -

-
- -

- What if I have more questions? -

-

- - For questions about health information in your records,{' '} - - send a secure message to your care team. + Note: You still + have access to your medical records on the My HealtheVet website. + You can go back to that site at any time.{' '} +

+
+
+

Questions about this medical records tool

+ + +

+ Where can I find health information I entered myself? +

+

+ Right now, your records on VA.gov only include health + information your VA providers have entered. +

+

+ To find health information you entered yourself, go to your + medical records on the My HealtheVet website. +

+

+ +

+
+ +

+ How can I tell my care team that my health information has + changed? +

-

- {phase0p5Flag ? ( - - ) : ( - + If you need to add or change health information in your + records, you can tell your provider at your next appointment. +

+

+ Or you can send a secure message to your care team and ask + them to update your records. +

+

+ {phase0p5Flag ? ( + + ) : ( + )} - text="Start a new message" - /> - )} -

-

- Only use messages for non-urgent needs. Your care team may take up - to{' '} - 3 business days{' '} - to reply. -

-

- If you need help sooner, use one of these urgent communication - options: -

-
    -
  • - - If you’re in crisis or having thoughts of suicide, - {' '} - connect with our Veterans Crisis Line. We offer confidential - support anytime, day or night. -
    - {} : openCrisisModal} - /> -
    -
  • -
  • - - If you think your life or health is in danger, - {' '} - call 911 or go to the nearest emergency room. -
  • -
- {!killExternalLinks && ( - <> +

+
+ +

+ Will VA protect my personal health information? +

+

+ Yes. This is a secure website. We follow strict security + policies and practices to protect your personal health + information. Only you and your VA care team will have access + to your records. +

+

+ If you print or download any records, you’ll need to take + responsibility for protecting that information. If you’re on a + public or shared computer, remember that downloading will save + a copy of your records to the computer you’re using. +

+
+ +

+ What if I have more questions? +

- For questions about how to use this tool,{' '} + For questions about health information in your records,{' '} + send a secure message to your care team. +

+ +

{phase0p5Flag ? ( - - call us at{' '} - ( - - ). We’re here Monday through Friday, 8:00 a.m. to 8:00 - p.m. ET. - + ) : ( - - email us at . - + )}

- - )} -
-
-
+

+ Only use messages for non-urgent needs. Your care team may + take up to{' '} + + 3 business days + {' '} + to reply. +

+

+ If you need help sooner, use one of these urgent communication + options: +

+
    +
  • + + If you’re in crisis or having thoughts of suicide, + {' '} + connect with our Veterans Crisis Line. We offer confidential + support anytime, day or night. +
    + {} : openCrisisModal} + /> +
    +
  • +
  • + + If you think your life or health is in danger, + {' '} + call 911 or go to the nearest emergency room. +
  • +
+ {!killExternalLinks && ( + <> +

+ + For questions about how to use this tool,{' '} + + {phase0p5Flag ? ( + + call us at{' '} + ( + + ). We’re here Monday through Friday, 8:00 a.m. to 8:00 + p.m. ET. + + ) : ( + + email us at . + + )} +

+ + )} +
+
+
+ + )} ); }; diff --git a/src/applications/mhv-medical-records/hooks/useAcceleratedData.js b/src/applications/mhv-medical-records/hooks/useAcceleratedData.js index 261cf4aa9153..e3afad8b7e70 100644 --- a/src/applications/mhv-medical-records/hooks/useAcceleratedData.js +++ b/src/applications/mhv-medical-records/hooks/useAcceleratedData.js @@ -31,9 +31,16 @@ const useAcceleratedData = () => { }, [dispatch], ); - const isCerner = useSelector(selectIsCernerPatient); + const { featureToggles, drupalStaticData } = useSelector(state => state); + const isLoading = useMemo( + () => { + return featureToggles.loading || drupalStaticData?.vamcEhrData?.loading; + }, + [drupalStaticData, featureToggles], + ); + const isAcceleratingAllergies = useMemo( () => { return ( @@ -55,6 +62,7 @@ const useAcceleratedData = () => { ); return { + isLoading, isAcceleratingAllergies, isAcceleratingVitals, }; diff --git a/src/applications/mhv-medical-records/tests/e2e/accelerated/vitals-loading-hook.oracle-health.cypress.spec.js b/src/applications/mhv-medical-records/tests/e2e/accelerated/vitals-loading-hook.oracle-health.cypress.spec.js new file mode 100644 index 000000000000..fd06768d1caf --- /dev/null +++ b/src/applications/mhv-medical-records/tests/e2e/accelerated/vitals-loading-hook.oracle-health.cypress.spec.js @@ -0,0 +1,26 @@ +import MedicalRecordsSite from '../mr_site/MedicalRecordsSite'; +import Vitals from './pages/Vitals'; +import oracleHealthUser from '../fixtures/user/oracle-health.json'; +import vitalsData from '../fixtures/vitals/blood-oxygen.json'; + +describe('Medical Records Loading screen', () => { + const site = new MedicalRecordsSite(); + + beforeEach(() => { + site.login(oracleHealthUser, false); + site.mockFeatureToggles({ + isAcceleratingEnabled: true, + isAcceleratingVitals: true, + }); + Vitals.setIntercepts({ vitalData: vitalsData }); + cy.visit('my-health/medical-records'); + }); + + it('Loading Visits View Vitals List', () => { + // There was a bug that only happen when the redux state was in a loading state, but the page was still shown. + // This caused the experience to be wonky and cause the page to jump and display wrong information. + Vitals.goToVitalPage(); + + cy.injectAxeThenAxeCheck(); + }); +}); From 47bc8ec4330d161701a9a1a96a3b3982617d3e51 Mon Sep 17 00:00:00 2001 From: mdewey <1793923+mdewey@users.noreply.github.com> Date: Tue, 3 Dec 2024 09:01:28 -0500 Subject: [PATCH 2/4] (UI) added the loader --- .../mhv-medical-records/containers/LandingPage.jsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/applications/mhv-medical-records/containers/LandingPage.jsx b/src/applications/mhv-medical-records/containers/LandingPage.jsx index 7182c16e1962..36fbf0c4b8e0 100644 --- a/src/applications/mhv-medical-records/containers/LandingPage.jsx +++ b/src/applications/mhv-medical-records/containers/LandingPage.jsx @@ -90,6 +90,15 @@ const LandingPage = () => {

+ {isLoading && ( +
+ +
+ )} + {!isLoading && ( <> {displayLabsAndTest && ( From d3b9cdaa5e5e22c73ddfd71514cdf34d542ef2b1 Mon Sep 17 00:00:00 2001 From: mdewey <1793923+mdewey@users.noreply.github.com> Date: Wed, 4 Dec 2024 15:00:11 -0500 Subject: [PATCH 3/4] (test) fixed broken unit tests --- .../hooks/useAcceleratedData.js | 11 +++++--- .../containers/LandingPage.unit.spec.jsx | 27 +++++++++++++++++-- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/src/applications/mhv-medical-records/hooks/useAcceleratedData.js b/src/applications/mhv-medical-records/hooks/useAcceleratedData.js index e3afad8b7e70..7c0bbb992d9d 100644 --- a/src/applications/mhv-medical-records/hooks/useAcceleratedData.js +++ b/src/applications/mhv-medical-records/hooks/useAcceleratedData.js @@ -1,9 +1,10 @@ import FEATURE_FLAG_NAMES from '@department-of-veterans-affairs/platform-utilities/featureFlagNames'; import { selectIsCernerPatient } from '~/platform/user/cerner-dsot/selectors'; -import { connectDrupalSourceOfTruthCerner } from '~/platform/utilities/cerner/dsot'; import { useSelector, useDispatch } from 'react-redux'; import { useMemo, useEffect } from 'react'; +import { connectDrupalSourceOfTruthCerner } from '~/platform/utilities/cerner/dsot'; + const useAcceleratedData = () => { const dispatch = useDispatch(); @@ -26,8 +27,12 @@ const useAcceleratedData = () => { useEffect( () => { - // use Drupal based Cerner facility data - connectDrupalSourceOfTruthCerner(dispatch); + // TECH DEBT: Do not trigger the connection when uniting tests because + // the connection is not mocked and will cause the test to fail + if (!window.Mocha) { + // use Drupal based Cerner facility data + connectDrupalSourceOfTruthCerner(dispatch); + } }, [dispatch], ); diff --git a/src/applications/mhv-medical-records/tests/containers/LandingPage.unit.spec.jsx b/src/applications/mhv-medical-records/tests/containers/LandingPage.unit.spec.jsx index fca1855f48eb..d0d5c3339cc8 100644 --- a/src/applications/mhv-medical-records/tests/containers/LandingPage.unit.spec.jsx +++ b/src/applications/mhv-medical-records/tests/containers/LandingPage.unit.spec.jsx @@ -3,11 +3,20 @@ import React from 'react'; import { renderWithStoreAndRouter } from '@department-of-veterans-affairs/platform-testing/react-testing-library-helpers'; import { createServiceMap } from '@department-of-veterans-affairs/platform-monitoring'; import { addHours, format } from 'date-fns'; +import sinon from 'sinon'; import LandingPage from '../../containers/LandingPage'; import reducer from '../../reducers'; describe('Landing Page', () => { const initialState = { + featureToggles: { + loading: false, + }, + drupalStaticData: { + vamcEhrData: { + loading: false, + }, + }, user: { login: { currentlyLoggedIn: true, @@ -44,7 +53,19 @@ describe('Landing Page', () => { }); it('displays a section linking to My HealtheVet classic to download all records', () => { - const screen = renderWithStoreAndRouter(, {}); + const connectDrupalSourceOfTruthCernerSpy = sinon.spy(); + + const customState = { + ...initialState, + }; + const screen = renderWithStoreAndRouter( + , + { + initialState: customState, + }, + ); expect( screen.getByText('Download your Blue Button report or health summary', { selector: 'h2', @@ -70,7 +91,9 @@ describe('Landing Page', () => { it('displays downtimeNotification when downtimeApproaching is true', () => { const customState = { - featureToggles: {}, + featureToggles: { + loading: false, + }, scheduledDowntime: { globalDowntime: null, isReady: true, From 245a3464658ca179adc35bfca01531835531df99 Mon Sep 17 00:00:00 2001 From: mdewey <1793923+mdewey@users.noreply.github.com> Date: Wed, 4 Dec 2024 16:15:49 -0500 Subject: [PATCH 4/4] (fixed) added state in the correct place --- .../containers/LandingPage.unit.spec.jsx | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/src/applications/mhv-medical-records/tests/containers/LandingPage.unit.spec.jsx b/src/applications/mhv-medical-records/tests/containers/LandingPage.unit.spec.jsx index d0d5c3339cc8..e270c980ad2e 100644 --- a/src/applications/mhv-medical-records/tests/containers/LandingPage.unit.spec.jsx +++ b/src/applications/mhv-medical-records/tests/containers/LandingPage.unit.spec.jsx @@ -3,20 +3,11 @@ import React from 'react'; import { renderWithStoreAndRouter } from '@department-of-veterans-affairs/platform-testing/react-testing-library-helpers'; import { createServiceMap } from '@department-of-veterans-affairs/platform-monitoring'; import { addHours, format } from 'date-fns'; -import sinon from 'sinon'; import LandingPage from '../../containers/LandingPage'; import reducer from '../../reducers'; describe('Landing Page', () => { const initialState = { - featureToggles: { - loading: false, - }, - drupalStaticData: { - vamcEhrData: { - loading: false, - }, - }, user: { login: { currentlyLoggedIn: true, @@ -53,19 +44,20 @@ describe('Landing Page', () => { }); it('displays a section linking to My HealtheVet classic to download all records', () => { - const connectDrupalSourceOfTruthCernerSpy = sinon.spy(); - const customState = { + featureToggles: { + loading: false, + }, + drupalStaticData: { + vamcEhrData: { + loading: false, + }, + }, ...initialState, }; - const screen = renderWithStoreAndRouter( - , - { - initialState: customState, - }, - ); + const screen = renderWithStoreAndRouter(, { + initialState: customState, + }); expect( screen.getByText('Download your Blue Button report or health summary', { selector: 'h2', @@ -94,6 +86,11 @@ describe('Landing Page', () => { featureToggles: { loading: false, }, + drupalStaticData: { + vamcEhrData: { + loading: false, + }, + }, scheduledDowntime: { globalDowntime: null, isReady: true, @@ -127,7 +124,13 @@ describe('Landing Page', () => { it('displays features as h2s with links below when feature flags are true', () => { const customState = { + drupalStaticData: { + vamcEhrData: { + loading: false, + }, + }, featureToggles: { + loading: false, // eslint-disable-next-line camelcase mhv_medical_records_display_conditions: true, // eslint-disable-next-line camelcase