-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added cerner facility alert, constants, imported on each mr page (#33458
) * added cerner facility alert, constants, imported on each mr page * added unit tests for new CernerFacilityAlert
- Loading branch information
1 parent
b22b388
commit d291390
Showing
11 changed files
with
343 additions
and
3 deletions.
There are no files selected for viewing
107 changes: 107 additions & 0 deletions
107
src/applications/mhv-medical-records/components/shared/CernerFacilityAlert.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
...pplications/mhv-medical-records/tests/components/shared/CernerFacilityAlert.unit.spec.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.', | ||
); | ||
}); | ||
}); |
Oops, something went wrong.