-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MHV-57186/add-my-va-health-link (#29961)
* added go to my va health link * removed unnecessary component * updated test, removed margin * updated URL * added ff * Revert "updated URL" This reverts commit caa10f5. * reverted ff changes * reverted ff names file * replaced new line * added bold text
- Loading branch information
1 parent
9d63b10
commit babfb60
Showing
4 changed files
with
282 additions
and
0 deletions.
There are no files selected for viewing
103 changes: 103 additions & 0 deletions
103
src/applications/mhv-medications/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,103 @@ | ||
import React, { useMemo } from 'react'; | ||
import { useSelector } from 'react-redux'; | ||
import { getVamcSystemNameFromVhaId } from 'platform/site-wide/drupal-static-data/source-files/vamc-ehr/utils'; | ||
import { getCernerURL } from 'platform/utilities/cerner'; | ||
import { selectCernerFacilities } from 'platform/site-wide/drupal-static-data/source-files/vamc-ehr/selectors'; | ||
|
||
const CernerFacilityAlert = () => { | ||
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], | ||
); | ||
const detailsText = () => { | ||
if (!cernerFacilitiesNames) return ''; | ||
if (cernerFacilitiesNames?.length > 1) return 'these facilities'; | ||
return cernerFacilitiesNames[0]; | ||
}; | ||
return ( | ||
<va-alert | ||
class={ | ||
cernerFacilitiesNames?.length > 0 ? 'vads-u-margin-bottom--2p5' : '' | ||
} | ||
status="warning" | ||
visible={cernerFacilitiesNames?.length > 0} | ||
data-testid="cerner-facilities-alert" | ||
> | ||
<h2 className="vads-u-font-size--md"> | ||
Make sure you’re in the right health portal | ||
</h2> | ||
<div> | ||
<p data-testid="single-cerner-facility-text"> | ||
To manage medications at{' '} | ||
<span | ||
className={ | ||
cernerFacilitiesNames?.length === 1 | ||
? 'vads-u-font-weight--bold' | ||
: '' | ||
} | ||
> | ||
{detailsText()} | ||
</span> | ||
, go to My VA Health | ||
{cernerFacilitiesNames?.length > 1 ? ':' : '.'} | ||
</p> | ||
{cernerFacilitiesNames?.length > 1 && ( | ||
<ul> | ||
{cernerFacilitiesNames.map((facilityName, i) => ( | ||
<li data-testid="cerner-facility" key={i}> | ||
{facilityName} | ||
</li> | ||
))} | ||
</ul> | ||
)} | ||
<a | ||
className="vads-c-action-link--blue" | ||
href={getCernerURL('/pages/medications/current', true)} | ||
> | ||
Go to My VA Health | ||
</a> | ||
|
||
<va-additional-info | ||
trigger="Having trouble opening My VA Health?" | ||
uswds | ||
class="vads-u-margin-top--2p5 vads-u-margin-bottom--0p5" | ||
> | ||
<div> | ||
<p className="vads-u-margin-top--0">Try these steps:</p> | ||
<ul className="vads-u-margin-top--2 vads-u-margin-bottom--0"> | ||
<li>Disable your browser’s pop-up blocker</li> | ||
<li> | ||
Sign in to My VA Health with the same account you used to sign | ||
in to VA.gov | ||
</li> | ||
</ul> | ||
</div> | ||
</va-additional-info> | ||
</div> | ||
</va-alert> | ||
); | ||
}; | ||
|
||
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
73 changes: 73 additions & 0 deletions
73
src/applications/mhv-medications/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,73 @@ | ||
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, | ||
} from '../../fixtures/cerner-facility-mock-data.json'; | ||
import prescriptions from '../../fixtures/refillablePrescriptionsList.json'; | ||
import CernerFacilityAlert from '../../../components/shared/CernerFacilityAlert'; | ||
|
||
describe('Cerner Facility Alert', () => { | ||
const initialStateMock = { | ||
rx: { | ||
prescriptions, | ||
}, | ||
drupalStaticData, | ||
user: { | ||
profile: { | ||
facilities: [], | ||
}, | ||
}, | ||
featureToggles: [], | ||
}; | ||
|
||
const setup = (state = initialStateMock, facilities = { facilities: [] }) => { | ||
return renderWithStoreAndRouter(<CernerFacilityAlert />, { | ||
initialState: { ...state, user: { ...state.user, profile: facilities } }, | ||
reducers: reducer, | ||
path: '/about', | ||
}); | ||
}; | ||
|
||
it(`does not render CernerFacilityAlert if cernerFacilities is empty`, async () => { | ||
const screen = setup(); | ||
const alert = screen.queryByTestId('cerner-facilities-alert'); | ||
expect(alert).to.have.attribute('visible', 'false'); | ||
}); | ||
|
||
it(`renders CernerFacilityAlert with list of facilities if cernerFacilities.length > 1`, async () => { | ||
const userFacilities = userProfileFacilities.filter( | ||
f => f.isCerner === false, | ||
); | ||
|
||
const screen = setup(initialStateMock, { | ||
facilities: [ | ||
...userFacilities, | ||
{ facilityId: '668', isCerner: true }, | ||
{ facilityId: '687', isCerner: true }, | ||
{ facilityId: '692', isCerner: true }, | ||
], | ||
}); | ||
|
||
expect(screen.queryByTestId('cerner-facilities-alert')).to.exist; | ||
expect(screen.getByText('VA Spokane health care')).to.exist; | ||
expect(screen.getByText('VA Walla Walla 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(initialStateMock, { | ||
facilities: userProfileFacilities.filter(f => f.facilityId === '668'), | ||
}); | ||
|
||
expect(screen.queryByTestId('cerner-facilities-alert')).to.exist; | ||
|
||
expect( | ||
screen.getByTestId('single-cerner-facility-text').textContent, | ||
).to.contain( | ||
'To manage medications at VA Spokane health care, go to My VA Health.', | ||
); | ||
}); | ||
}); |
103 changes: 103 additions & 0 deletions
103
src/applications/mhv-medications/tests/fixtures/cerner-facility-mock-data.json
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,103 @@ | ||
{ | ||
"drupalStaticData": { | ||
"vamcEhrData": { | ||
"data": { | ||
"ehrDataByVhaId": { | ||
"463": { | ||
"vhaId": "463", | ||
"vamcFacilityName": "Colonel Mary Louise Rasmuson Campus of the Alaska VA Healthcare System", | ||
"vamcSystemName": "VA Alaska health care", | ||
"ehr": "vista" | ||
}, | ||
"583": { | ||
"vhaId": "583", | ||
"vamcFacilityName": "Richard L. Roudebush Veterans' Administration Medical Center", | ||
"vamcSystemName": "VA Indiana health care", | ||
"ehr": "vista" | ||
}, | ||
"668": { | ||
"vhaId": "668", | ||
"vamcFacilityName": "Mann-Grandstaff Department of Veterans Affairs Medical Center", | ||
"vamcSystemName": "VA Spokane health care", | ||
"ehr": "cerner" | ||
}, | ||
"687": { | ||
"vhaId": "687", | ||
"vamcFacilityName": "Jonathan M. Wainwright Memorial VA Medical Center", | ||
"vamcSystemName": "VA Walla Walla health care", | ||
"ehr": "cerner" | ||
}, | ||
"692": { | ||
"vhaId": "692", | ||
"vamcFacilityName": "White City VA Medical Center", | ||
"vamcSystemName": "VA Southern Oregon health care", | ||
"ehr": "cerner" | ||
} | ||
}, | ||
"cernerFacilities": [ | ||
{ | ||
"vhaId": "668", | ||
"vamcFacilityName": "Mann-Grandstaff Department of Veterans Affairs Medical Center", | ||
"vamcSystemName": "VA Spokane health care", | ||
"ehr": "cerner" | ||
}, | ||
{ | ||
"vhaId": "687", | ||
"vamcFacilityName": "Jonathan M. Wainwright Memorial VA Medical Center", | ||
"vamcSystemName": "VA Walla Walla health care", | ||
"ehr": "cerner" | ||
}, | ||
{ | ||
"vhaId": "692", | ||
"vamcFacilityName": "White City VA Medical Center", | ||
"vamcSystemName": "VA Southern Oregon health care", | ||
"ehr": "cerner" | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"userProfileFacilities": [ | ||
{ | ||
"facilityId": "463", | ||
"isCerner": true | ||
}, | ||
{ | ||
"facilityId": "583", | ||
"isCerner": true | ||
}, | ||
{ | ||
"facilityId": "589", | ||
"isCerner": false | ||
}, | ||
{ | ||
"facilityId": "668", | ||
"isCerner": true | ||
}, | ||
{ | ||
"facilityId": "983", | ||
"isCerner": false | ||
}, | ||
{ | ||
"facilityId": "987", | ||
"isCerner": false | ||
} | ||
], | ||
"mockResponseData": { | ||
"data": [ | ||
{ | ||
"id": "vha_668", | ||
"type": "facility", | ||
"attributes": { | ||
"activeStatus": "A", | ||
"classification": "VA Medical Center (VAMC)", | ||
"facilityType": "va_health_facility", | ||
"id": "vha_668", | ||
"name": "Mann-Grandstaff Department of Veterans Affairs Medical Center", | ||
"uniqueId": "668", | ||
"website": "https://www.va.gov/spokane-health-care/locations/mann-grandstaff-department-of-veterans-affairs-medical-center/" | ||
} | ||
} | ||
] | ||
} | ||
} |