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

78648 do not call refresh_appts for OH claims #16073

Merged
merged 1 commit into from
Mar 25, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ class PatientCheckInsController < CheckIn::ApplicationController
after_action :after_logger, only: %i[show create]

def show
check_in_session = CheckIn::V2::Session.build(data: { uuid: params[:id], handoff: handoff? },
check_in_session = CheckIn::V2::Session.build(data: { uuid: params[:id], handoff: handoff?,
facility_type: params[:facilityType] },
jwt: low_auth_token)

unless check_in_session.authorized?
Expand Down
3 changes: 2 additions & 1 deletion modules/check_in/app/models/check_in/v2/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Session
DOB_REGEX = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/
LAST_NAME_REGEX = /^.{1,600}$/

attr_reader :uuid, :dob, :last_name, :settings, :jwt, :check_in_type, :handoff
attr_reader :uuid, :dob, :last_name, :settings, :jwt, :check_in_type, :handoff, :facility_type

def_delegators :settings, :redis_session_prefix

Expand All @@ -46,6 +46,7 @@ def initialize(opts)
@last_name = opts.dig(:data, :last_name)
@check_in_type = opts.dig(:data, :check_in_type)
@handoff = opts.dig(:data, :handoff)
@facility_type = opts.dig(:data, :facility_type)
end

#
Expand Down
11 changes: 6 additions & 5 deletions modules/check_in/app/services/v2/lorota/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def check_in_data

raw_data =
if token.present?
chip_service.refresh_appointments if appointment_identifiers.present?
chip_service.refresh_appointments if refresh_appointments?

lorota_client.data(token:)
end
Expand All @@ -101,15 +101,16 @@ def check_in_data
patient_check_in.approved
end

def appointment_identifiers
Rails.cache.read(
private

def refresh_appointments?
appointment_identifiers = Rails.cache.read(
"check_in_lorota_v2_appointment_identifiers_#{check_in.uuid}",
namespace: 'check-in-lorota-v2-cache'
)
appointment_identifiers.present? && !'oh'.casecmp?(check_in.facility_type)
end

private

def error_message_handler(e)
case Oj.load(e.original_body).fetch('error').strip.downcase
when *LOROTA_401_ERROR_MESSAGES
Expand Down
4 changes: 4 additions & 0 deletions modules/check_in/spec/models/check_in/v2/session_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
it 'responds to handoff' do
expect(subject.build({}).respond_to?(:handoff)).to be(true)
end

it 'responds to facility_type' do
expect(subject.build({}).respond_to?(:facility_type)).to be(true)
end
end

describe '#valid?' do
Expand Down
30 changes: 28 additions & 2 deletions modules/check_in/spec/services/v2/lorota/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,10 @@
.and_return(Faraday::Response.new(response_body: appointment_data.to_json, status: 200))
end

it 'returns approved data' do
expect(subject.build(check_in: valid_check_in).check_in_data).to eq(approved_response)
end

context 'when check_in_type is preCheckIn' do
let(:opts) { { data: { check_in_type: 'preCheckIn' } } }
let(:pre_check_in) { CheckIn::V2::Session.build(opts) }
Expand All @@ -702,8 +706,30 @@
end
end

it 'returns approved data' do
expect(subject.build(check_in: valid_check_in).check_in_data).to eq(approved_response)
context 'when appt identifiers are not present' do
it 'does not call refresh_appts' do
expect_any_instance_of(::V2::Chip::Service).not_to receive(:refresh_appointments)

expect(subject.build(check_in: valid_check_in).check_in_data).to eq(approved_response)
end
end

context 'when appt identifiers are present and facility type is OH' do
let(:valid_check_in_oh) { CheckIn::V2::Session.build(opts.deep_merge!({ data: { facility_type: 'oh' } })) }

before do
Rails.cache.write(
"check_in_lorota_v2_appointment_identifiers_#{id}",
'123',
namespace: 'check-in-lorota-v2-cache'
)
end

it 'does not call refresh_appts' do
expect_any_instance_of(::V2::Chip::Service).not_to receive(:refresh_appointments)

expect(subject.build(check_in: valid_check_in_oh).check_in_data).to eq(approved_response)
end
end
end
end
Loading