Skip to content

Commit

Permalink
MHV-65985 Added a check to block BBInternal client init threads if IC…
Browse files Browse the repository at this point in the history
…N is not set (#20191)

* MHV-65985 Added a check to block client init threads if ICN is not set

* MHV-65985 Fixed/added unit tests

* MHV-65985 Fixed some unit tests
  • Loading branch information
mmoyer-va authored Jan 10, 2025
1 parent d45c222 commit 7a375b6
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/medical_records/bb_internal/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,10 @@ def map_study_ids(data)
end

##
# Overriding MHVSessionBasedClient's method to ensure the thread blocks if patient ID is not yet set.
# Overriding MHVSessionBasedClient's method to ensure the thread blocks if ICN or patient ID are not yet set.
#
def invalid?(session)
super(session) || session.patient_id.blank?
super(session) || session.icn.blank? || session.patient_id.blank?
end

##
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
bb_internal_client = BBInternal::Client.new(
session: {
user_id: 11_375_034,
icn: '1000000000V000000',
patient_id: '11382904',
expires_at: 1.hour.from_now,
token: 'SESSION_TOKEN'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
bb_internal_client = BBInternal::Client.new(
session: {
user_id: 11_375_034,
icn: '1000000000V000000',
patient_id: '11382904',
expires_at: 1.hour.from_now,
token: 'SESSION_TOKEN'
Expand Down
15 changes: 14 additions & 1 deletion spec/lib/medical_records/bb_internal/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -439,10 +439,21 @@
end

describe '#invalid?' do
let(:session_data) { OpenStruct.new(patient_id: patient_id, expired?: session_expired) }
let(:session_data) { OpenStruct.new(icn: icn, patient_id: patient_id, expired?: session_expired) }

context 'when session is expired' do
let(:session_expired) { true }
let(:icn) { '1000000000V000000' }
let(:patient_id) { '12345' }

it 'returns true' do
expect(client.send(:invalid?, session_data)).to be true
end
end

context 'when session has no icn' do
let(:session_expired) { false }
let(:icn) { nil }
let(:patient_id) { '12345' }

it 'returns true' do
Expand All @@ -452,6 +463,7 @@

context 'when session has no patient_id' do
let(:session_expired) { false }
let(:icn) { '1000000000V000000' }
let(:patient_id) { nil }

it 'returns true' do
Expand All @@ -461,6 +473,7 @@

context 'when session is valid' do
let(:session_expired) { false }
let(:icn) { '1000000000V000000' }
let(:patient_id) { '12345' }

it 'returns false' do
Expand Down

0 comments on commit 7a375b6

Please sign in to comment.