Skip to content

Commit

Permalink
VAOS: Migrate MFS Clinics Search Call Over to VAOS Service (#12863)
Browse files Browse the repository at this point in the history
* refactor(vaos): update MobileFacilityService to use VAOS Service instead of MFS to get clinic data
   refactor(vaos): update friendly_name field to use service_name
   test(vaos): updated VAOS rspec tests work with the changes

* test(mobile): update get clinic vcr cassettes due to change from mfs to vaos service endpoints
  • Loading branch information
ajmagdub authored Jun 6, 2023
1 parent b3d79f4 commit 6078929
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 124 deletions.
13 changes: 7 additions & 6 deletions modules/vaos/app/controllers/vaos/v2/appointments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def show
clinic = get_clinic(appointment[:location_id], appointment[:clinic])
appointment[:service_name] = clinic&.[](:service_name)
appointment[:physical_location] = clinic&.[](:physical_location) if clinic&.[](:physical_location)
appointment[:friendly_name] = clinic&.[](:friendly_name) if clinic&.[](:friendly_name)
appointment[:friendly_name] = clinic&.[](:service_name) if clinic&.[](:service_name)
end

appointment[:location] = get_facility(appointment[:location_id]) unless appointment[:location_id].nil?
Expand All @@ -81,7 +81,7 @@ def create
clinic = get_clinic(new_appointment[:location_id], new_appointment[:clinic])
new_appointment[:service_name] = clinic&.[](:service_name)
new_appointment[:physical_location] = clinic&.[](:physical_location) if clinic&.[](:physical_location)
new_appointment[:friendly_name] = clinic&.[](:friendly_name) if clinic&.[](:friendly_name)
new_appointment[:friendly_name] = clinic&.[](:service_name) if clinic&.[](:service_name)
end

unless new_appointment[:location_id].nil?
Expand All @@ -103,7 +103,7 @@ def update
clinic = get_clinic(updated_appointment[:location_id], updated_appointment[:clinic])
updated_appointment[:service_name] = clinic&.[](:service_name)
updated_appointment[:physical_location] = clinic&.[](:physical_location) if clinic&.[](:physical_location)
updated_appointment[:friendly_name] = clinic&.[](:friendly_name) if clinic&.[](:friendly_name)
updated_appointment[:friendly_name] = clinic&.[](:service_name) if clinic&.[](:service_name)
end

unless updated_appointment[:location_id].nil?
Expand Down Expand Up @@ -263,13 +263,14 @@ def merge_clinics(appointments)
end
if cached_clinics[appt[:clinic]]&.[](:service_name)
appt[:service_name] = cached_clinics[appt[:clinic]][:service_name]
# In VAOS Service there is no dedicated clinic friendlyName field.
# If the clinic is configured with a patient-friendly name then that will be the value
# in the clinic service name; otherwise it will be the internal clinic name.
appt[:friendly_name] = cached_clinics[appt[:clinic]][:service_name]
end
if cached_clinics[appt[:clinic]]&.[](:physical_location)
appt[:physical_location] = cached_clinics[appt[:clinic]][:physical_location]
end
if cached_clinics[appt[:clinic]]&.[](:friendly_name)
appt[:friendly_name] = cached_clinics[appt[:clinic]][:friendly_name]
end
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions modules/vaos/app/services/vaos/v2/mobile_facility_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ class MobileFacilityService < VAOS::SessionService
# @return [OpenStruct] An OpenStruct object containing information about the clinic.
#
def get_clinic(station_id:, clinic_id:)
params = {}
params = { clinicIds: clinic_id }
parent_site_id = station_id[0, 3]
clinic_path = "/facilities/v2/facilities/#{parent_site_id}/clinics/#{clinic_id}"
clinic_path = "/vaos/v1/locations/#{parent_site_id}/clinics"
with_monitoring do
response = perform(:get, clinic_path, params, headers)
OpenStruct.new(response[:body][:data])
OpenStruct.new(response[:body][:data]&.first) # only one clinic is returned
end
end

Expand Down
5 changes: 2 additions & 3 deletions modules/vaos/spec/request/v2/appointments_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
include SchemaMatchers
mock_clinic = {
'service_name': 'service_name',
'physical_location': 'physical_location',
'friendly_name': 'friendly_name'
'physical_location': 'physical_location'
}

mock_clinic_without_physical_location = {
Expand Down Expand Up @@ -137,7 +136,7 @@
expect(data.size).to eq(16)
expect(data[0]['attributes']['serviceName']).to eq('service_name')
expect(data[0]['attributes']['physicalLocation']).to eq('physical_location')
expect(data[0]['attributes']['friendlyName']).to eq('friendly_name')
expect(data[0]['attributes']['friendlyName']).to eq('service_name')
expect(data[0]['attributes']['location']).to eq(mock_facility)
expect(response).to match_camelized_response_schema('vaos/v2/appointments', { strict: false })
end
Expand Down
6 changes: 3 additions & 3 deletions modules/vaos/spec/services/v2/mobile_facility_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
match_requests_on: %i[method path query]) do
clinic = subject.get_clinic(station_id: '983', clinic_id: '455')
expect(clinic[:station_id]).to eq('983')
expect(clinic[:clinic_id]).to eq('455')
expect(clinic[:id]).to eq('455')
end
end
end
Expand All @@ -129,7 +129,7 @@
match_requests_on: %i[method path query]) do
clinic = subject.get_clinic(station_id: '983GB', clinic_id: '1053')
expect(clinic[:station_id]).to eq('983GB')
expect(clinic[:clinic_id]).to eq('1053')
expect(clinic[:id]).to eq('1053')
end
end
end
Expand All @@ -154,7 +154,7 @@
expect(Rails.cache.exist?('vaos_clinic_983_455')).to eq(false)
clinic = subject.get_clinic_with_cache(station_id: '983', clinic_id: '455')
expect(clinic[:station_id]).to eq('983')
expect(clinic[:clinic_id]).to eq('455')
expect(clinic[:id]).to eq('455')
expect(Rails.cache.exist?('vaos_clinic_983_455')).to eq(true)
end
end
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6078929

Please sign in to comment.