Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/bundler/rubocop-1.69.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rjohnson2011 authored Nov 29, 2024
2 parents 91d81e1 + 3400fb3 commit 8e16abd
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ GEM
openssl (3.2.0-java)
jruby-openssl (~> 0.14)
operating_hours (0.1.0)
optimist (3.1.0)
optimist (3.2.0)
os (1.1.4)
ostruct (0.6.1)
ox (2.14.18)
Expand Down Expand Up @@ -1041,7 +1041,7 @@ GEM
stringio (3.1.2)
strong_migrations (2.0.2)
activerecord (>= 6.1)
super_diff (0.13.0)
super_diff (0.14.0)
attr_extras (>= 6.2.4)
diff-lcs
patience_diff
Expand Down
4 changes: 4 additions & 0 deletions config/features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,10 @@ features:
actor_type: user
description: Enables/disables filter feature for medications list
enable_in_development: true
mhv_medications_display_grouping:
actor_type: user
description: Enables/disables grouping medications related work
enable_in_development: true
mobile_allergy_intolerance_model:
actor_type: user
description: For mobile app, enalbes use of strict models for parsing allergy intolerance
Expand Down
3 changes: 2 additions & 1 deletion config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1847,6 +1847,7 @@ vaos:
client_assertion_type: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer"
audience_claim_url: "https://login.wellhive.com/oauth2/default/v1/token"
access_token_url: "https://login.wellhive.com/oauth2/default/v1/token"
api_url: "https://api.wellhive.com/care-navigation/v1"
api_url: "https://api.wellhive.com"
base_path: "care-navigation/v1"
scopes: "care-nav"

16 changes: 16 additions & 0 deletions modules/vaos/app/services/eps/appointment_service.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

module Eps
class AppointmentService < BaseService
##
# Get appointments data from EPS
#
# @return OpenStruct response from EPS appointments endpoint
#
def get_appointments(patient_id:)
response = perform(:get, "/#{config.base_path}/appointments?patientId=#{patient_id}",
{}, headers)
OpenStruct.new(response.body)
end
end
end
2 changes: 1 addition & 1 deletion modules/vaos/app/services/eps/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Eps
class Configuration < Common::Client::Configuration::REST
delegate :access_token_url, :api_url, :grant_type, :scopes, :client_assertion_type, to: :settings
delegate :access_token_url, :api_url, :base_path, :grant_type, :scopes, :client_assertion_type, to: :settings

def settings
Settings.vaos.eps
Expand Down
59 changes: 59 additions & 0 deletions modules/vaos/spec/services/eps/appointment_service_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# frozen_string_literal: true

require 'rails_helper'

describe Eps::AppointmentService do
subject(:service) { described_class.new(user) }

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

describe 'get_appointments' do
before do
allow(Rails.cache).to receive(:fetch).and_return(memory_store)
Rails.cache.clear
end

context 'when requesting appointments for a given patient_id' do
before do
allow_any_instance_of(VAOS::SessionService).to receive(:perform).and_return(successful_appt_response)
end

it 'returns the appointments scheduled' do
exp_response = OpenStruct.new(successful_appt_response.body)

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

context 'when the endpoint fails to return appointments' do
let(:failed_appt_response) do
double('Response', status: 500, body: 'Unknown service exception')
end
let(:exception) do
Common::Exceptions::BackendServiceException.new(nil, {}, failed_appt_response.status,
failed_appt_response.body)
end

before do
allow_any_instance_of(VAOS::SessionService).to receive(:perform).and_raise(exception)
end

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

0 comments on commit 8e16abd

Please sign in to comment.