diff --git a/app/services/sign_in/attribute_validator.rb b/app/services/sign_in/attribute_validator.rb index f1e3ad3b2db..93ace517b5a 100644 --- a/app/services/sign_in/attribute_validator.rb +++ b/app/services/sign_in/attribute_validator.rb @@ -176,7 +176,10 @@ def handle_error(error_message, error_code, error: nil) def mpi_response_profile @mpi_response_profile ||= - if idme_uuid + if mhv_correlation_id + mpi_service.find_profile_by_identifier(identifier: mhv_correlation_id, + identifier_type: MPI::Constants::MHV_UUID)&.profile + elsif idme_uuid mpi_service.find_profile_by_identifier(identifier: idme_uuid, identifier_type: MPI::Constants::IDME_UUID)&.profile elsif logingov_uuid diff --git a/lib/mpi/constants.rb b/lib/mpi/constants.rb index 194d904ed8b..e312971942a 100644 --- a/lib/mpi/constants.rb +++ b/lib/mpi/constants.rb @@ -23,6 +23,7 @@ module Constants IDME_FULL_IDENTIFIER = 'PN^200VIDM^USDVA^A' LOGINGOV_FULL_IDENTIFIER = 'PN^200VLGN^USDVA^A' + MHV_FULL_IDENTIFIER = 'PI^200MHS^USVHA^A' DSLOGON_FULL_IDENTIFIER = 'NI^200DOD^USDOD^A' ACTIVE_VHA_IDENTIFIER = 'USVHA^A' @@ -42,6 +43,6 @@ module Constants FIND_PROFILE_BY_ATTRIBUTES_ORCH_SEARCH_TYPE = 'find_profile_by_attributes_orch_search' FIND_PROFILE_BY_FACILITY_TYPE = 'find_profile_by_facility' - QUERY_IDENTIFIERS = [ICN = 'ICN', IDME_UUID = 'idme', LOGINGOV_UUID = 'logingov'].freeze + QUERY_IDENTIFIERS = [ICN = 'ICN', IDME_UUID = 'idme', LOGINGOV_UUID = 'logingov', MHV_UUID = 'mhv'].freeze end end diff --git a/lib/mpi/messages/find_profile_by_identifier.rb b/lib/mpi/messages/find_profile_by_identifier.rb index 426f4ab22f8..157efe37caa 100644 --- a/lib/mpi/messages/find_profile_by_identifier.rb +++ b/lib/mpi/messages/find_profile_by_identifier.rb @@ -39,6 +39,8 @@ def correlation_identifier "#{identifier}^#{Constants::IDME_FULL_IDENTIFIER}" when Constants::LOGINGOV_UUID "#{identifier}^#{Constants::LOGINGOV_FULL_IDENTIFIER}" + when Constants::MHV_UUID + "#{identifier}^#{Constants::MHV_FULL_IDENTIFIER}" end end diff --git a/spec/lib/mpi/messages/find_profile_by_identifier_spec.rb b/spec/lib/mpi/messages/find_profile_by_identifier_spec.rb index 32bcdc822c1..716250df50f 100644 --- a/spec/lib/mpi/messages/find_profile_by_identifier_spec.rb +++ b/spec/lib/mpi/messages/find_profile_by_identifier_spec.rb @@ -72,6 +72,13 @@ it_behaves_like 'successfully built request' end + context 'when identifier type is MHV_UUID' do + let(:identifier_type) { MPI::Constants::MHV_UUID } + let(:expected_identifier) { "#{identifier}^#{MPI::Constants::MHV_FULL_IDENTIFIER}" } + + it_behaves_like 'successfully built request' + end + context 'when identifier type is an arbitrary value' do let(:identifier_type) { 'some-identifier-type' } let(:expected_error_message) { "Identifier type is not supported, identifier_type=#{identifier_type}" } diff --git a/spec/services/sign_in/attribute_validator_spec.rb b/spec/services/sign_in/attribute_validator_spec.rb index e3de8457ad3..d5fa9af27b5 100644 --- a/spec/services/sign_in/attribute_validator_spec.rb +++ b/spec/services/sign_in/attribute_validator_spec.rb @@ -67,10 +67,15 @@ let(:add_person_response) { 'some-add-person-response' } let(:find_profile_response) { 'some-find-profile-response' } let(:update_profile_response) { 'some-update-profile-response' } + let(:identifier) { idme_uuid } + let(:identifier_type) { MPI::Constants::IDME_UUID } before do allow_any_instance_of(MPI::Service).to receive(:add_person_implicit_search).and_return(add_person_response) - allow_any_instance_of(MPI::Service).to receive(:find_profile_by_identifier).and_return(find_profile_response) + allow_any_instance_of(MPI::Service) + .to receive(:find_profile_by_identifier) + .with(identifier:, identifier_type:) + .and_return(find_profile_response) allow_any_instance_of(MPI::Service).to receive(:update_profile).and_return(update_profile_response) allow(Rails.logger).to receive(:info) end @@ -361,6 +366,8 @@ let(:address) { nil } let(:mhv_correlation_id) { 'some-mhv-correlation-id' } let(:email) { 'some-email' } + let(:identifier) { mhv_correlation_id } + let(:identifier_type) { MPI::Constants::MHV_UUID } context 'and credential is missing mhv icn' do let(:mhv_icn) { nil } @@ -485,6 +492,8 @@ let(:country) { 'USA' } let(:birth_date) { '1930-01-01' } let(:email) { 'some-email' } + let(:identifier) { logingov_uuid } + let(:identifier_type) { MPI::Constants::LOGINGOV_UUID } context 'and credential is missing email' do let(:email) { nil } @@ -606,6 +615,8 @@ let(:ssn) { '444444758' } let(:birth_date) { '1930-01-01' } let(:email) { 'some-email' } + let(:identifier) { idme_uuid } + let(:identifier_type) { MPI::Constants::IDME_UUID } context 'and credential is missing email' do let(:email) { nil } @@ -662,6 +673,8 @@ let(:country) { 'USA' } let(:birth_date) { '1930-01-01' } let(:email) { 'some-email' } + let(:identifier) { idme_uuid } + let(:identifier_type) { MPI::Constants::IDME_UUID } context 'and credential is missing email' do let(:email) { nil }