diff --git a/modules/mobile/app/controllers/mobile/v0/appointments_controller.rb b/modules/mobile/app/controllers/mobile/v0/appointments_controller.rb index a3c9c19205a..adff7bb4ea5 100644 --- a/modules/mobile/app/controllers/mobile/v0/appointments_controller.rb +++ b/modules/mobile/app/controllers/mobile/v0/appointments_controller.rb @@ -87,9 +87,7 @@ def fetch_appointments # The mobile app does not distinguish between VA and CC errors so we are only indicating that there are errors # If we ever want to distinguish be VA and CC errors, it will require coordination with the front-end team def partial_errors(failures) - if failures.any? - Rails.logger.info('Mobile Appointment Partial Error', errors: failures) - + if appointment_errors?(failures) { errors: [{ source: 'VA Service' }] } @@ -97,7 +95,11 @@ def partial_errors(failures) end def get_response_status(failures) - failures.any? ? :multi_status : :ok + appointment_errors?(failures) ? :multi_status : :ok + end + + def appointment_errors?(failures) + failures.any? { |failure| failure[:appointment_errors].present? } end def filter_by_date_range(appointments) diff --git a/modules/mobile/app/services/mobile/v2/appointments/proxy.rb b/modules/mobile/app/services/mobile/v2/appointments/proxy.rb index 2ecac525a3b..4fa4ed8ee02 100644 --- a/modules/mobile/app/services/mobile/v2/appointments/proxy.rb +++ b/modules/mobile/app/services/mobile/v2/appointments/proxy.rb @@ -36,6 +36,7 @@ def get_appointments(start_date:, end_date:, include_pending:, pagination_params { missing_providers: } ] failures.reject! { |failure| failure.values.first&.empty? } + Rails.logger.info('Mobile Appointment Partial Error', errors: failures) if failures.any? [appointments.sort_by(&:start_date_utc), failures] end diff --git a/modules/mobile/spec/request/appointments_vaos_v2_list_request_spec.rb b/modules/mobile/spec/request/appointments_vaos_v2_list_request_spec.rb index 92fb906f6d4..42149d33ca9 100644 --- a/modules/mobile/spec/request/appointments_vaos_v2_list_request_spec.rb +++ b/modules/mobile/spec/request/appointments_vaos_v2_list_request_spec.rb @@ -107,7 +107,7 @@ end end end - expect(response).to have_http_status(:multi_status) + expect(response).to have_http_status(:ok) expect(Rails.logger).to have_received(:info).with('Mobile Appointment Partial Error', errors: [{ missing_facilities: ['983'] }]) expect(response.body).to match_json_schema('VAOS_v2_appointments') @@ -168,7 +168,7 @@ end end end - expect(response).to have_http_status(:multi_status) + expect(response).to have_http_status(:ok) expect(Rails.logger).to have_received(:info).with('Mobile Appointment Partial Error', errors: [{ missing_facilities: ['999AA'] }, { missing_clinics: ['999'] }]) @@ -310,7 +310,7 @@ def fetch_appointments end end end - expect(response).to have_http_status(:multi_status) + expect(response).to have_http_status(:ok) expect(appointment['attributes']['healthcareProvider']).to be_nil expect(Rails.logger).to have_received(:info).with('Mobile Appointment Partial Error', errors: [{ missing_providers: ['1407938061'] }]) @@ -329,7 +329,7 @@ def fetch_appointments end end end - expect(response).to have_http_status(:multi_status) + expect(response).to have_http_status(:ok) expect(appointment['attributes']['healthcareProvider']).to be_nil expect(Rails.logger).to have_received(:info).with('Mobile Appointment Partial Error', errors: [{ missing_providers: ['1407938061'] }])