Skip to content

Commit

Permalink
96412 use current user's icn for calling EPS methods (#19835)
Browse files Browse the repository at this point in the history
* 96412 use user icn calling eps methods

* 96412 rubocop fix - minor alignment change
  • Loading branch information
randomsync authored Dec 11, 2024
1 parent 354ddfc commit aa573ea
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion modules/vaos/app/services/eps/appointment_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class AppointmentService < BaseService
#
# @return OpenStruct response from EPS appointments endpoint
#
def get_appointments(patient_id:)
def get_appointments
response = perform(:get, "/#{config.base_path}/appointments?patientId=#{patient_id}",
{}, headers)
OpenStruct.new(response.body)
Expand Down
4 changes: 4 additions & 0 deletions modules/vaos/app/services/eps/base_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ def token_headers
{ 'Content-Type' => 'application/x-www-form-urlencoded' }
end

def patient_id
@patient_id ||= user.icn
end

class TokenError < StandardError; end
end
end
12 changes: 6 additions & 6 deletions modules/vaos/spec/services/eps/appointment_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
describe Eps::AppointmentService do
subject(:service) { described_class.new(user) }

let(:user) { double('User', account_uuid: '1234') }
let(:icn) { '123ICN' }
let(:user) { double('User', account_uuid: '1234', icn:) }
let(:successful_appt_response) do
double('Response', status: 200, body: { 'count' => 1,
'appointments' => [
{
'id' => 'test-id',
'state' => 'booked',
'patientId' => patient_id
'patientId' => icn
}
] })
end
let(:patient_id) { 'test-patient-id' }
let(:memory_store) { ActiveSupport::Cache.lookup_store(:memory_store) }

describe 'get_appointments' do
Expand All @@ -33,7 +33,7 @@
it 'returns the appointments scheduled' do
exp_response = OpenStruct.new(successful_appt_response.body)

expect(service.get_appointments(patient_id:)).to eq(exp_response)
expect(service.get_appointments).to eq(exp_response)
end
end

Expand All @@ -51,8 +51,8 @@
end

it 'throws exception' do
expect { service.get_appointments(patient_id:) }.to raise_error(Common::Exceptions::BackendServiceException,
/VA900/)
expect { service.get_appointments }.to raise_error(Common::Exceptions::BackendServiceException,
/VA900/)
end
end
end
Expand Down

0 comments on commit aa573ea

Please sign in to comment.