Skip to content

Commit

Permalink
added cerner facility alert, constants, imported on each mr page (#33458
Browse files Browse the repository at this point in the history
)

* added cerner facility alert, constants, imported on each mr page

* added unit tests for new CernerFacilityAlert
  • Loading branch information
KyleCardwell authored Dec 16, 2024
1 parent b22b388 commit d291390
Show file tree
Hide file tree
Showing 11 changed files with 343 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import React, { useMemo } from 'react';
import PropTypes from 'prop-types';
import { useSelector } from 'react-redux';
import { getVamcSystemNameFromVhaId } from 'platform/site-wide/drupal-static-data/source-files/vamc-ehr/utils';
import { selectCernerFacilities } from 'platform/site-wide/drupal-static-data/source-files/vamc-ehr/selectors';
import { getCernerURL } from 'platform/utilities/cerner';

const CernerFacilityAlert = ({ linkPath, pageName }) => {
const ehrDataByVhaId = useSelector(
state => state?.drupalStaticData?.vamcEhrData?.data?.ehrDataByVhaId,
);
const userFacilities = useSelector(state => state?.user?.profile?.facilities);

const drupalCernerFacilities = useSelector(selectCernerFacilities);

const cernerFacilities = useMemo(
() => {
return userFacilities?.filter(facility =>
drupalCernerFacilities?.some(
f => f.vhaId === facility.facilityId && f.ehr === 'cerner',
),
);
},
[userFacilities, drupalCernerFacilities],
);

const cernerFacilitiesNames = useMemo(
() => {
if (ehrDataByVhaId) {
return cernerFacilities?.map(facility =>
getVamcSystemNameFromVhaId(ehrDataByVhaId, facility.facilityId),
);
}
return [];
},
[cernerFacilities, ehrDataByVhaId],
);

return (
<>
{cernerFacilitiesNames?.length > 0 && (
<va-alert
className="vads-u-margin-bottom--2"
status="warning"
background-only
close-btn-aria-label="Close notification"
visible
data-testid="cerner-facilities-alert"
>
<h2 className="vads-u-font-size--md">
{`To get your ${pageName} from ${
cernerFacilitiesNames.length > 1
? 'these facilities'
: 'this facility'
}, go to My VA Health`}
</h2>
<div>
{cernerFacilitiesNames?.length > 1 && (
<>
<p>
{`Some of your medical records may be in a different portal. To
get your ${pageName} from these facilities, go to My VA Health:`}
</p>
<ul>
{cernerFacilitiesNames.map((facilityName, i) => (
<li data-testid="cerner-facility" key={i}>
{facilityName}
</li>
))}
</ul>
</>
)}
{cernerFacilitiesNames?.length === 1 && (
<p data-testId="single-cerner-facility-text">
{`Some of your medical records may be in a different portal. To
get your ${pageName} from`}{' '}
<strong>{cernerFacilitiesNames[0]}</strong>, go to My VA Health.
</p>
)}

<a
className="vads-c-action-link--blue vads-u-margin-bottom--0p5"
href={getCernerURL(linkPath, true)}
target="_blank"
rel="noopener noreferrer"
>
Go to My VA Health (opens in new tab)
</a>
<p>
<strong>Note:</strong> Having trouble opening up My VA Health? Try
disabling your browser’s pop-up blocker or signing in to My VA
Health with the same account you used to sign in to VA.gov.
</p>
</div>
</va-alert>
)}
</>
);
};

CernerFacilityAlert.propTypes = {
cernerFacilities: PropTypes.arrayOf(PropTypes.object),
linkPath: PropTypes.string,
pageName: PropTypes.string,
};

export default CernerFacilityAlert;
5 changes: 5 additions & 0 deletions src/applications/mhv-medical-records/containers/Allergies.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
pageTitles,
accessAlertTypes,
refreshExtractTypes,
CernerAlertContent,
} from '../util/constants';
import { getAllergiesList, reloadRecords } from '../actions/allergies';
import PrintHeader from '../components/shared/PrintHeader';
Expand All @@ -42,6 +43,7 @@ import DownloadSuccessAlert from '../components/shared/DownloadSuccessAlert';
import NewRecordsIndicator from '../components/shared/NewRecordsIndicator';

import useAcceleratedData from '../hooks/useAcceleratedData';
import CernerFacilityAlert from '../components/shared/CernerFacilityAlert';

const Allergies = props => {
const { runningUnitTest } = props;
Expand Down Expand Up @@ -185,6 +187,9 @@ ${allergies.map(entry => generateAllergyListItemTxt(entry)).join('')}`;
If you have allergies that are missing from this list, tell your care
team at your next appointment.
</p>

<CernerFacilityAlert {...CernerAlertContent.ALLERGIES} />

{downloadStarted && <DownloadSuccessAlert />}
<RecordListSection
accessAlert={activeAlert && activeAlert.type === ALERT_TYPE_ERROR}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
import useListRefresh from '../hooks/useListRefresh';
import {
ALERT_TYPE_ERROR,
CernerAlertContent,
accessAlertTypes,
pageTitles,
recordType,
Expand All @@ -18,6 +19,7 @@ import {
import useAlerts from '../hooks/use-alerts';
import RecordListSection from '../components/shared/RecordListSection';
import NewRecordsIndicator from '../components/shared/NewRecordsIndicator';
import CernerFacilityAlert from '../components/shared/CernerFacilityAlert';

const CareSummariesAndNotes = () => {
const dispatch = useDispatch();
Expand Down Expand Up @@ -76,6 +78,9 @@ const CareSummariesAndNotes = () => {
providers sign them. This list doesn’t include care summaries from
before 2013.
</p>

<CernerFacilityAlert {...CernerAlertContent.CARE_SUMMARIES_AND_NOTES} />

<RecordListSection
accessAlert={activeAlert && activeAlert.type === ALERT_TYPE_ERROR}
accessAlertType={accessAlertTypes.CARE_SUMMARIES_AND_NOTES}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ import {
ALERT_TYPE_ERROR,
accessAlertTypes,
refreshExtractTypes,
CernerAlertContent,
} from '../util/constants';
import RecordListSection from '../components/shared/RecordListSection';
import useAlerts from '../hooks/use-alerts';
import useListRefresh from '../hooks/useListRefresh';
import NewRecordsIndicator from '../components/shared/NewRecordsIndicator';
import CernerFacilityAlert from '../components/shared/CernerFacilityAlert';

const HealthConditions = () => {
const ABOUT_THE_CODES_LABEL = 'About the codes in some condition names';
Expand Down Expand Up @@ -69,6 +71,9 @@ const HealthConditions = () => {
<span className="vads-u-font-weight--bold">36 hours</span> after your
providers enter them.
</p>

<CernerFacilityAlert {...CernerAlertContent.HEALTH_CONDITIONS} />

<RecordListSection
accessAlert={activeAlert && activeAlert.type === ALERT_TYPE_ERROR}
accessAlertType={accessAlertTypes.HEALTH_CONDITIONS}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import RecordList from '../components/RecordList/RecordList';
import { getLabsAndTestsList, reloadRecords } from '../actions/labsAndTests';
import {
ALERT_TYPE_ERROR,
CernerAlertContent,
accessAlertTypes,
pageTitles,
recordType,
Expand All @@ -15,6 +16,7 @@ import RecordListSection from '../components/shared/RecordListSection';
import useAlerts from '../hooks/use-alerts';
import useListRefresh from '../hooks/useListRefresh';
import NewRecordsIndicator from '../components/shared/NewRecordsIndicator';
import CernerFacilityAlert from '../components/shared/CernerFacilityAlert';

const LabsAndTests = () => {
const dispatch = useDispatch();
Expand Down Expand Up @@ -73,6 +75,9 @@ const LabsAndTests = () => {
<span className="vads-u-font-weight--bold">14 days</span> or longer to
confirm.{' '}
</p>

<CernerFacilityAlert {...CernerAlertContent.LABS_AND_TESTS} />

<RecordListSection
accessAlert={activeAlert && activeAlert.type === ALERT_TYPE_ERROR}
accessAlertType={accessAlertTypes.LABS_AND_TESTS}
Expand Down
12 changes: 9 additions & 3 deletions src/applications/mhv-medical-records/containers/LandingPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ import { isAuthenticatedWithSSOe } from '~/platform/user/authentication/selector
import { CONTACTS } from '@department-of-veterans-affairs/component-library/contacts';

import { getCernerURL } from 'platform/utilities/cerner';
import { downtimeNotificationParams, pageTitles } from '../util/constants';
import {
CernerAlertContent,
downtimeNotificationParams,
pageTitles,
} from '../util/constants';
import { createSession } from '../api/MrApi';
import {
selectConditionsFlag,
Expand All @@ -27,8 +31,8 @@ import {
} from '../util/selectors';
import ExternalLink from '../components/shared/ExternalLink';
import FeedbackEmail from '../components/shared/FeedbackEmail';

import useAcceleratedData from '../hooks/useAcceleratedData';
import CernerFacilityAlert from '../components/shared/CernerFacilityAlert';
import { sendDataDogAction } from '../util/helpers';

const LAB_TEST_RESULTS_LABEL = 'Go to your lab and test results';
Expand Down Expand Up @@ -98,7 +102,7 @@ const LandingPage = () => {

return (
<div className="landing-page">
<section>
<section className="vads-u-margin-bottom--2">
<h1
className="vads-u-margin-top--0 vads-u-margin-bottom--1"
data-testid="mr-landing-page-title"
Expand All @@ -119,6 +123,8 @@ const LandingPage = () => {
</p>
</section>

<CernerFacilityAlert {...CernerAlertContent.MR_LANDING_PAGE} />

{isLoading && (
<section>
<va-loading-indicator
Expand Down
5 changes: 5 additions & 0 deletions src/applications/mhv-medical-records/containers/Vaccines.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
pageTitles,
accessAlertTypes,
refreshExtractTypes,
CernerAlertContent,
} from '../util/constants';
import PrintDownload from '../components/shared/PrintDownload';
import DownloadingRecordsInfo from '../components/shared/DownloadingRecordsInfo';
Expand All @@ -44,6 +45,7 @@ import {
} from '../util/pdfHelpers/vaccines';
import DownloadSuccessAlert from '../components/shared/DownloadSuccessAlert';
import NewRecordsIndicator from '../components/shared/NewRecordsIndicator';
import CernerFacilityAlert from '../components/shared/CernerFacilityAlert';

const Vaccines = props => {
const { runningUnitTest } = props;
Expand Down Expand Up @@ -166,6 +168,9 @@ ${vaccines.map(entry => generateVaccineListItemTxt(entry)).join('')}`;
Go to your allergy records
</Link>
</div>

<CernerFacilityAlert {...CernerAlertContent.VACCINES} />

{downloadStarted && <DownloadSuccessAlert />}
<RecordListSection
accessAlert={activeAlert && activeAlert.type === ALERT_TYPE_ERROR}
Expand Down
4 changes: 4 additions & 0 deletions src/applications/mhv-medical-records/containers/Vitals.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import PrintHeader from '../components/shared/PrintHeader';
import useListRefresh from '../hooks/useListRefresh';
import NewRecordsIndicator from '../components/shared/NewRecordsIndicator';
import useAcceleratedData from '../hooks/useAcceleratedData';
import CernerFacilityAlert from '../components/shared/CernerFacilityAlert';

const Vitals = () => {
const dispatch = useDispatch();
Expand Down Expand Up @@ -261,6 +262,9 @@ const Vitals = () => {
{`Vitals are basic health numbers your providers check at your
appointments.`}
</p>

<CernerFacilityAlert {...Constants.CernerAlertContent.VITALS} />

{isLoading && (
<div className="vads-u-margin-y--8">
<va-loading-indicator
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import React from 'react';
import { renderWithStoreAndRouter } from '@department-of-veterans-affairs/platform-testing/react-testing-library-helpers';
import { expect } from 'chai';
import reducer from '../../../reducers';
import {
drupalStaticData,
userProfileFacilities,
userProfileMultipleCernerFacilities,
} from '../../fixtures/cerner-facility-mock-data.json';
import CernerFacilityAlert from '../../../components/shared/CernerFacilityAlert';
import { CernerAlertContent } from '../../../util/constants';

describe('Cerner Facility Alert', () => {
const initialState = {
drupalStaticData,
user: {
profile: {
facilities: [],
},
},
featureToggles: [],
};

const setup = (
state = initialState,
facilities = { facilities: [] },
alertLocation = CernerAlertContent.MR_LANDING_PAGE,
) => {
return renderWithStoreAndRouter(
<CernerFacilityAlert {...alertLocation} />,
{
initialState: {
...state,
user: { ...state.user, profile: facilities },
},
reducers: reducer,
},
);
};

it('renders without errors', () => {
const screen = setup(undefined, {
facilities: userProfileFacilities,
});
expect(screen).to.exist;
});

it(`does not render CernerFacilityAlert if cernerFacilities is empty`, async () => {
const screen = setup();

expect(screen.queryByTestId('cerner-facilities-alert')).to.not.exist;
});

it(`renders CernerFacilityAlert with list of facilities if cernerFacilities.length > 1`, async () => {
const screen = setup(undefined, {
facilities: userProfileMultipleCernerFacilities,
});

expect(screen.queryByTestId('cerner-facilities-alert')).to.exist;
expect(
screen.getByText(
'Some of your medical records may be in a different portal. To get your medical records from these facilities, go to My VA Health:',
),
).to.exist;
const facilityList = screen.getAllByTestId('cerner-facility');
expect(facilityList.length).to.equal(2);
expect(screen.getByText('VA Spokane health care')).to.exist;
expect(screen.getByText('VA Southern Oregon health care')).to.exist;
});

it(`renders CernerFacilityAlert with 1 facility if cernerFacilities.length === 1`, async () => {
const screen = setup(
undefined,
{
facilities: userProfileFacilities,
},
CernerAlertContent.VACCINES,
);

expect(screen.queryByTestId('cerner-facilities-alert')).to.exist;

expect(
screen.getByTestId('single-cerner-facility-text').textContent,
).to.contain(
'get your vaccines from VA Spokane health care, go to My VA Health.',
);
});
});
Loading

0 comments on commit d291390

Please sign in to comment.