department-of-veterans-affairs / va.gov-team

Public resources for building on and in support of VA.gov. Visit complete Knowledge Hub:
https://depo-platform-documentation.scrollhelp.site/index.html
281 stars 201 forks source link

[Spike]- Determine FE logic for choose a location page. #86953

Closed simiadebowale closed 2 months ago

simiadebowale commented 3 months ago

Description

This is spike is to document the current business/FE logic for the choose a location page.

Screenshot 2024-06-25 at 4.10.25 PM.png

Tasks

Timebox 12 hours

vbahinwillit commented 3 months ago

Question: What is the current business/FE logic for determining what facilities support the selected Type of Care. (What configuration/facility checks take place?)

Answer: The process of determining which facilites support a given type of care starts when the next button is clicked on the 'Schedule an appointment' page. The user then selects where they want to receive care, 'VA medical center or clinic'. When the next button is clicked, a call is trigger to get all user registered facilities and the 'Choose a VA Location' page is opened. This page dispatches a call to 'openFacilityPageV2' on initialization. The filtering of the facilities is actually done in the reducer for the 'FORM_PAGE_FACILITY_V2_OPEN_SUCCEEDED' action with the following code snippet.

const typeOfCareFacilities = facilities.filter(facility =>
        isTypeOfCareSupported(facility, typeOfCareId, cernerSiteIds),
      );

and the actual function to do the filtering:

/**
 * Returns true if location supports the given type of care
 *
 * @export
 * @param {Location} location The location to check
 * @param {string} typeOfCareId The type of care id to check against
 * @param {Array<string>} [cernerSiteIds=[]] The list of Cerner sites, because Cerner sites
 *   are active for all types of care
 * @returns {Boolean} True if the location supports the type of care (or is a Cerner site)
 */
export function isTypeOfCareSupported(
  location,
  typeOfCareId,
  cernerSiteIds = [],
) {
  return (
    location.legacyVAR.settings[typeOfCareId]?.direct.enabled ||
    location.legacyVAR.settings[typeOfCareId]?.request.enabled ||
    isCernerLocation(location.id, cernerSiteIds)
  );
}

To trace this in Chrome do the following:

Set breakpoint in VAFacilityPageV2.jsx:95 Set breakpoint in vaos/new-appointment/redux/actions.js:337 Set breakpoint in vaos/new-appointment/redux/reducer.js325

This action is updating the Redux state (specifically, the page schema information) to the following:

newAppointment {
  pages: {
    vaFacilityV2: {
      properties: {
        vaFacility: { enum: [filtered facility ids here], enumNames: [filtered facility info here] }
      }
    }
  },
}
Bren22va commented 3 months ago

@ldelacosta Ready for review

ldelacosta commented 3 months ago

@simiadebowale - does this ticket have enough information for the team to move forward to create the work in vets-api?

simiadebowale commented 3 months ago

@vbahinwillit - please, can you list the endpoints called to get the facilities info

vbahinwillit commented 2 months ago

This call returns the facility/location information for the user's registered facilities. getFacilities: http://localhost:3000/vaos/v2/facilities?children=true&ids[]=556&ids[]=984&ids[]=983

This call returns the facility/location configuration information which is used to determine if scheduling for the user's selected type of care is supported. getLocationSettings: http://localhost:3000/vaos/v2/scheduling/configurations?facility_ids[]=983&facility_ids[]=984&cc_enabled=true

vbahinwillit commented 2 months ago

@simiadebowale - I think these are all of the api calls made for determining which facilities to display. The eligibility checks are made after the user has selected a facility and clinics are displayed.

ldelacosta commented 2 months ago

@Bren22va - please check with @simiadebowale tomorrow if the ticket can be closed.