From 09a986540f014e600d81aaaa74a2e627d60df27f Mon Sep 17 00:00:00 2001 From: Devin McCurdy <41960449+devin-mccurdy@users.noreply.github.com> Date: Wed, 18 Dec 2024 19:35:16 -0500 Subject: [PATCH] Add direct scheduling feature flag to appointment creation logic --- config/features.yml | 4 --- .../mobile/v0/appointments/create_spec.rb | 16 +++++------ .../vaos/v2/appointments_controller.rb | 2 +- .../services/vaos/v2/appointments_service.rb | 27 +++++++++++++++---- .../requests/vaos/v2/appointments_spec.rb | 23 +++++++++++++--- .../services/v2/appointment_service_spec.rb | 4 +-- 6 files changed, 53 insertions(+), 23 deletions(-) diff --git a/config/features.yml b/config/features.yml index c4d42a7791a..f8f4b8109ed 100644 --- a/config/features.yml +++ b/config/features.yml @@ -1493,10 +1493,6 @@ features: actor_type: user enable_in_development: true description: Toggle for routing eligibility requests to the VetsAPI Gateway Service(VPG) instead of vaos-service - va_online_scheduling_enable_OH_requests: - actor_type: user - enable_in_development: true - description: Toggle for routing new appointment requests to the VetsAPI Gateway Service(VPG) instead of vaos-service va_online_scheduling_enable_OH_slots_search: actor_type: user enable_in_development: true diff --git a/modules/mobile/spec/requests/mobile/v0/appointments/create_spec.rb b/modules/mobile/spec/requests/mobile/v0/appointments/create_spec.rb index 0ee78bc0a97..b8982e73cdd 100644 --- a/modules/mobile/spec/requests/mobile/v0/appointments/create_spec.rb +++ b/modules/mobile/spec/requests/mobile/v0/appointments/create_spec.rb @@ -54,7 +54,7 @@ context 'using VAOS' do before do Flipper.disable(:va_online_scheduling_use_vpg) - Flipper.disable(:va_online_scheduling_enable_OH_requests) + Flipper.disable(:va_online_scheduling_OH_request) end it 'returns created' do @@ -71,7 +71,7 @@ context 'using VPG' do before do Flipper.enable(:va_online_scheduling_use_vpg) - Flipper.enable(:va_online_scheduling_enable_OH_requests) + Flipper.enable(:va_online_scheduling_OH_request) end it 'returns created' do @@ -90,7 +90,7 @@ context 'using VAOS' do before do Flipper.disable(:va_online_scheduling_use_vpg) - Flipper.disable(:va_online_scheduling_enable_OH_requests) + Flipper.disable(:va_online_scheduling_OH_request) end it 'clears the cache' do @@ -117,7 +117,7 @@ context 'using VPG' do before do Flipper.enable(:va_online_scheduling_use_vpg) - Flipper.enable(:va_online_scheduling_enable_OH_requests) + Flipper.enable(:va_online_scheduling_OH_request) end it 'clears the cache' do @@ -145,7 +145,7 @@ context 'for VAOS' do before do Flipper.disable(:va_online_scheduling_use_vpg) - Flipper.disable(:va_online_scheduling_enable_OH_requests) + Flipper.disable(:va_online_scheduling_OH_request) end it 'creates the cc appointment' do @@ -162,7 +162,7 @@ context 'for VPG' do before do Flipper.enable(:va_online_scheduling_use_vpg) - Flipper.enable(:va_online_scheduling_enable_OH_requests) + Flipper.enable(:va_online_scheduling_OH_request) end it 'creates the cc appointment' do @@ -182,7 +182,7 @@ context 'using VAOS' do before do Flipper.disable(:va_online_scheduling_use_vpg) - Flipper.disable(:va_online_scheduling_enable_OH_requests) + Flipper.disable(:va_online_scheduling_OH_request) end it 'creates the va appointment - proposed' do @@ -209,7 +209,7 @@ context 'using VPG' do before do Flipper.enable(:va_online_scheduling_use_vpg) - Flipper.enable(:va_online_scheduling_enable_OH_requests) + Flipper.enable(:va_online_scheduling_OH_request) end it 'creates the va appointment - proposed' do diff --git a/modules/vaos/app/controllers/vaos/v2/appointments_controller.rb b/modules/vaos/app/controllers/vaos/v2/appointments_controller.rb index 8c9c0509260..f3ac7d9787c 100644 --- a/modules/vaos/app/controllers/vaos/v2/appointments_controller.rb +++ b/modules/vaos/app/controllers/vaos/v2/appointments_controller.rb @@ -317,7 +317,7 @@ def show_method_logging_name end def create_method_logging_name - if Flipper.enabled?(:va_online_scheduling_use_vpg) && Flipper.enabled?(:va_online_scheduling_enable_OH_requests) + if Flipper.enabled?(:va_online_scheduling_use_vpg) && Flipper.enabled?(:va_online_scheduling_OH_request) APPT_CREATE_VPG else APPT_CREATE_VAOS diff --git a/modules/vaos/app/services/vaos/v2/appointments_service.rb b/modules/vaos/app/services/vaos/v2/appointments_service.rb index db640ff117d..a970dffddec 100644 --- a/modules/vaos/app/services/vaos/v2/appointments_service.rb +++ b/modules/vaos/app/services/vaos/v2/appointments_service.rb @@ -17,7 +17,8 @@ class AppointmentsService < VAOS::SessionService # rubocop:disable Metrics/Class ORACLE_HEALTH_CANCELLATIONS = :va_online_scheduling_enable_OH_cancellations APPOINTMENTS_USE_VPG = :va_online_scheduling_use_vpg - APPOINTMENTS_ENABLE_OH_REQUESTS = :va_online_scheduling_enable_OH_requests + APPOINTMENTS_OH_REQUESTS = :va_online_scheduling_OH_request + APPOINTMENTS_OH_DIRECT_SCHEDULE_REQUESTS = :va_online_scheduling_OH_direct_schedule APPOINTMENT_TYPES = { va: 'VA', cc_appointment: 'COMMUNITY_CARE_APPOINTMENT', @@ -97,11 +98,10 @@ def post_appointment(request_object_body) params = VAOS::V2::AppointmentForm.new(user, request_object_body).params.with_indifferent_access params.compact_blank! with_monitoring do - response = if Flipper.enabled?(APPOINTMENTS_USE_VPG, user) && - Flipper.enabled?(APPOINTMENTS_ENABLE_OH_REQUESTS) - perform(:post, appointments_base_path_vpg, params, headers) + response = if params[:status] == 'proposed' + create_appointment_request(params) else - perform(:post, appointments_base_path_vaos, params, headers) + create_direct_scheduling_appointment(params) end if request_object_body[:kind] == 'clinic' && @@ -123,6 +123,23 @@ def post_appointment(request_object_body) end end + def create_direct_scheduling_appointment(params) + if Flipper.enabled?(APPOINTMENTS_USE_VPG, user) && + Flipper.enabled?(APPOINTMENTS_OH_DIRECT_SCHEDULE_REQUESTS, user) + perform(:post, appointments_base_path_vpg, params, headers) + else + perform(:post, appointments_base_path_vaos, params, headers) + end + end + + def create_appointment_request(params) + if Flipper.enabled?(APPOINTMENTS_USE_VPG, user) && Flipper.enabled?(APPOINTMENTS_OH_REQUESTS, user) + perform(:post, appointments_base_path_vpg, params, headers) + else + perform(:post, appointments_base_path_vaos, params, headers) + end + end + # rubocop:enable Metrics/MethodLength def update_appointment(appt_id, status) with_monitoring do diff --git a/modules/vaos/spec/requests/vaos/v2/appointments_spec.rb b/modules/vaos/spec/requests/vaos/v2/appointments_spec.rb index 892aed35ad1..7c372a919b0 100644 --- a/modules/vaos/spec/requests/vaos/v2/appointments_spec.rb +++ b/modules/vaos/spec/requests/vaos/v2/appointments_spec.rb @@ -112,7 +112,7 @@ def stub_clinics context 'with VAOS' do before do Flipper.disable(:va_online_scheduling_use_vpg) - Flipper.disable(:va_online_scheduling_enable_OH_requests) + Flipper.disable(:va_online_scheduling_OH_request) end describe 'CREATE cc appointment' do @@ -213,7 +213,8 @@ def stub_clinics context 'using VPG' do before do Flipper.enable(:va_online_scheduling_use_vpg) - Flipper.enable(:va_online_scheduling_enable_OH_requests) + Flipper.enable(:va_online_scheduling_OH_request) + Flipper.enable(:va_online_scheduling_OH_direct_schedule) end describe 'CREATE cc appointment' do @@ -276,7 +277,7 @@ def stub_clinics end end - it 'creates the va appointment - booked' do + it 'creates the booked va appointment using VPG' do stub_clinics VCR.use_cassette('vaos/v2/appointments/post_appointments_va_booked_200_JACQUELINE_M_vpg', match_requests_on: %i[method path query]) do @@ -291,6 +292,22 @@ def stub_clinics end end + it 'creates the booked va appointment using VAOS' do + Flipper.disable(:va_online_scheduling_OH_direct_schedule) + stub_clinics + VCR.use_cassette('vaos/v2/appointments/post_appointments_va_booked_200_JACQUELINE_M', + match_requests_on: %i[method path query]) do + VCR.use_cassette('vaos/v2/mobile_facility_service/get_facility_200', + match_requests_on: %i[method path query]) do + post '/vaos/v2/appointments', params: va_booked_request_body, headers: inflection_header + expect(response).to have_http_status(:created) + json_body = json_body_for(response) + expect(json_body).to match_camelized_schema('vaos/v2/appointment', { strict: false }) + expect(json_body['attributes']['localStartTime']).to eq('2022-11-30T13:45:00.000-07:00') + end + end + end + it 'creates the va appointment and logs appointment details when there is a PAP COMPLIANCE comment' do stub_clinics VCR.use_cassette('vaos/v2/appointments/post_appointments_va_booked_200_and_log_facility_vpg', diff --git a/modules/vaos/spec/services/v2/appointment_service_spec.rb b/modules/vaos/spec/services/v2/appointment_service_spec.rb index 54ca8a13f7f..c19e47c1129 100644 --- a/modules/vaos/spec/services/v2/appointment_service_spec.rb +++ b/modules/vaos/spec/services/v2/appointment_service_spec.rb @@ -84,7 +84,7 @@ context 'using VAOS' do before do Flipper.disable(:va_online_scheduling_use_vpg) - Flipper.disable(:va_online_scheduling_enable_OH_requests) + Flipper.disable(:va_online_scheduling_OH_request) end context 'when va appointment create request is valid' do @@ -190,7 +190,7 @@ context 'using VPG' do before do Flipper.enable(:va_online_scheduling_use_vpg) - Flipper.enable(:va_online_scheduling_enable_OH_requests) + Flipper.enable(:va_online_scheduling_OH_request) end context 'when va appointment create request is valid' do