Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add direct scheduling feature flag to appointment creation logic #19961

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions config/features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 22 additions & 5 deletions modules/vaos/app/services/vaos/v2/appointments_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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' &&
Expand All @@ -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
Expand Down
23 changes: 20 additions & 3 deletions modules/vaos/spec/requests/vaos/v2/appointments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions modules/vaos/spec/services/v2/appointment_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading