diff --git a/modules/check_in/app/controllers/check_in/v0/travel_claims_controller.rb b/modules/check_in/app/controllers/check_in/v0/travel_claims_controller.rb index 18e4a57b119..694bfcb5e16 100644 --- a/modules/check_in/app/controllers/check_in/v0/travel_claims_controller.rb +++ b/modules/check_in/app/controllers/check_in/v0/travel_claims_controller.rb @@ -3,6 +3,9 @@ module CheckIn module V0 class TravelClaimsController < CheckIn::ApplicationController + before_action :before_logger, only: %i[show create] + after_action :after_logger, only: %i[show create] + def create check_in_session = CheckIn::V2::Session.build(data: { uuid: permitted_params[:uuid] }, jwt: low_auth_token) diff --git a/modules/check_in/lib/check_in/utils/logger.rb b/modules/check_in/lib/check_in/utils/logger.rb index 6cd8648f308..bf3bf5723e5 100644 --- a/modules/check_in/lib/check_in/utils/logger.rb +++ b/modules/check_in/lib/check_in/utils/logger.rb @@ -29,7 +29,8 @@ def common uuid:, controller: ctrl_name, action: ctrl_action, - initiated_by: + initiated_by:, + facility_type: } end @@ -73,6 +74,11 @@ def initiated_by '' end end + + def facility_type + ctrl.params[:facility_type] || ctrl.params.dig(:session, :facility_type) || + ctrl.params.dig(:travel_claims, :facility_type) + end end end end diff --git a/modules/check_in/spec/lib/utils/logger_spec.rb b/modules/check_in/spec/lib/utils/logger_spec.rb index c61aa1c5af5..328a9f9f4da 100644 --- a/modules/check_in/spec/lib/utils/logger_spec.rb +++ b/modules/check_in/spec/lib/utils/logger_spec.rb @@ -12,27 +12,56 @@ end describe '#before' do - let(:controller) do - double('FooController', - controller_name: 'sessions', - action_name: 'show', - response: { body: '' }, - params: { id: '123' }, - permitted_params: {}) - end - let(:resp) do - { - workflow: 'Min-Auth', - uuid: '123', - controller: 'sessions', - action: 'show', - initiated_by: '', - filter: :before_action - } + context 'when endpoint called without facility_type' do + let(:controller) do + double('FooController', + controller_name: 'sessions', + action_name: 'show', + response: { body: '' }, + params: { id: '123' }, + permitted_params: {}) + end + let(:resp) do + { + workflow: 'Min-Auth', + uuid: '123', + controller: 'sessions', + action: 'show', + initiated_by: '', + facility_type: nil, + filter: :before_action + } + end + + it 'returns the before info hash with nil facility_type' do + expect(described_class.build(controller).before).to eq(resp) + end end - it 'returns the before info hash' do - expect(described_class.build(controller).before).to eq(resp) + context 'when endpoint called with facility_type' do + let(:controller) do + double('FooController', + controller_name: 'sessions', + action_name: 'show', + response: { body: '' }, + params: { id: '123', facility_type: 'oh' }, + permitted_params: {}) + end + let(:resp) do + { + workflow: 'Min-Auth', + uuid: '123', + controller: 'sessions', + action: 'show', + initiated_by: '', + facility_type: 'oh', + filter: :before_action + } + end + + it 'returns the before info hash with nil facility_type' do + expect(described_class.build(controller).before).to eq(resp) + end end end @@ -49,7 +78,7 @@ } end - context 'when set_e_checkin_started_called = false' do + context 'when set_e_checkin_started_called = false without facility_type' do let(:controller) do double('FooController', controller_name: 'patient_check_ins', @@ -59,7 +88,7 @@ permitted_params: { uuid: '345' }) end let(:resp_with_initiated_by_vetext) do - resp.merge(initiated_by: 'vetext') + resp.merge(initiated_by: 'vetext', facility_type: nil) end it 'returns the after info hash with initiated_by set with vetext' do @@ -67,7 +96,7 @@ end end - context 'when set_e_checkin_started_called = true' do + context 'when set_e_checkin_started_called = true without facility_type' do let(:controller) do double('FooController', controller_name: 'patient_check_ins', @@ -77,7 +106,25 @@ permitted_params: { uuid: '123' }) end let(:resp_with_initiated_by_veteran) do - resp.merge(initiated_by: 'veteran') + resp.merge(initiated_by: 'veteran', facility_type: nil) + end + + it 'returns the after info hash with initiated_by set with vetext' do + expect(described_class.build(controller).after).to eq(resp_with_initiated_by_veteran) + end + end + + context 'when set_e_checkin_started_called = true with oh facility_type' do + let(:controller) do + double('FooController', + controller_name: 'patient_check_ins', + action_name: 'show', + response: double('ResponseBody', body: '{"a":"b", "status":"success 200", "c":"d"}'), + params: { id: '123', set_e_checkin_started_called: true, facility_type: 'oh' }, + permitted_params: { uuid: '123' }) + end + let(:resp_with_initiated_by_veteran) do + resp.merge(initiated_by: 'veteran', facility_type: 'oh') end it 'returns the after info hash with initiated_by set with vetext' do @@ -94,6 +141,7 @@ controller: 'patient_check_ins', action: 'create', api_status: 'success 200', + facility_type: nil, filter: :after_action } end