Skip to content

Commit

Permalink
fix to allow request flow when flag is true
Browse files Browse the repository at this point in the history
  • Loading branch information
vbahinwillit committed Oct 4, 2024
1 parent 2afc72c commit a7d7387
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { scrollAndFocus } from '../../../utils/scrollAndFocus';
import { isCernerLocation } from '../../../services/location';
import NoAddressNote from '../NoAddressNote';
import { useOHDirectScheduling } from '../../hooks/useOHDirectScheduling';
import { useOHRequestScheduling } from '../../hooks/useOHRequestScheduling';

const INITIAL_FACILITY_DISPLAY_COUNT = 5;
/*
Expand Down Expand Up @@ -67,6 +68,7 @@ export default function FacilitiesRadioWidget({
});

const useOHDirectSchedule = useOHDirectScheduling();
const useOHRequestSchedule = useOHRequestScheduling();

useEffect(
() => {
Expand Down Expand Up @@ -164,7 +166,7 @@ export default function FacilitiesRadioWidget({
</span>
)}
{isCerner &&
useOHDirectSchedule && (
(!useOHDirectSchedule && !useOHRequestSchedule) && (
<a href={getCernerURL('/pages/scheduling/upcoming')}>
Schedule online at <strong>My VA Health</strong>
</a>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { shallowEqual, useSelector } from 'react-redux';
import { getFacilityPageV2Info } from '../redux/selectors';
import { selectFeatureOHRequest } from '../../redux/selectors';

const OH_REQUEST_SCHEDULE_ENABLED_TYPES_OF_CARE = ['foodAndNutrition'];

export function useOHRequestScheduling() {
const featureOHRequest = useSelector(selectFeatureOHRequest);

const { typeOfCare } = useSelector(
state => getFacilityPageV2Info(state),
shallowEqual,
);

return (
featureOHRequest &&
OH_REQUEST_SCHEDULE_ENABLED_TYPES_OF_CARE.includes(typeOfCare.idV2)
);
}
6 changes: 5 additions & 1 deletion src/applications/vaos/new-appointment/newAppointmentFlow.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { recordEvent } from '@department-of-veterans-affairs/platform-monitoring/exports';
import {
selectFeatureBreadcrumbUrlUpdate,
selectFeatureOHDirectSchedule,
selectFeatureOHRequest,
selectRegisteredCernerFacilityIds,
} from '../redux/selectors';
import {
Expand Down Expand Up @@ -81,8 +83,10 @@ async function vaFacilityNext(state, dispatch) {
const location = getChosenFacilityInfo(state);
const cernerSiteIds = selectRegisteredCernerFacilityIds(state);
const isCerner = isCernerLocation(location?.id, cernerSiteIds);
const featureOHDirectSchedule = selectFeatureOHDirectSchedule(state);
const featureOHRequest = selectFeatureOHRequest(state);

if (isCerner) {
if (isCerner && !featureOHDirectSchedule && !featureOHRequest) {
return 'scheduleCerner';
}

Expand Down
6 changes: 5 additions & 1 deletion src/applications/vaos/redux/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ import {
selectCernerFacilityIds,
selectEhrDataByVhaId,
} from 'platform/site-wide/drupal-static-data/source-files/vamc-ehr/selectors';
import { getRealFacilityId } from '../utils/appointment';

export const selectRegisteredCernerFacilityIds = state => {
const patientFacilities = selectPatientFacilities(state);
const cernerFacilityIds = selectCernerFacilityIds(state);

return (
patientFacilities?.reduce((accumulator, current) => {
if (cernerFacilityIds.includes(current.facilityId) || current.isCerner)
if (
cernerFacilityIds.includes(getRealFacilityId(current.facilityId)) ||
current.isCerner
)
return [...accumulator, current.facilityId];
return accumulator;
}, []) || []
Expand Down

0 comments on commit a7d7387

Please sign in to comment.