Class: MPIData

Inherits:
Common::RedisStore show all
Includes:
Common::CacheAside, SentryLogging
Defined in:
app/models/mpi_data.rb

Overview

Facade for MVI. User model delegates MVI correlation id and VA profile (golden record) methods to this class. When a profile is requested from one of the delegates it is returned from either a cached response in Redis or from the MVI SOAP service.

Constant Summary collapse

REDIS_CONFIG_KEY =
:mpi_profile_response

Constants inherited from Common::RedisStore

Common::RedisStore::REQ_CLASS_INSTANCE_VARS

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SentryLogging

#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger

Methods included from Common::CacheAside

#cache, #cached?, #do_cached_with

Methods inherited from Common::RedisStore

create, delete, #destroy, #destroyed?, exists?, #expire, find, find_or_build, #initialize, #initialize_dup, keys, #persisted?, pop, redis_key, redis_store, redis_ttl, #save!, #ttl, #update, #update!

Constructor Details

This class inherits a constructor from Common::RedisStore

Instance Attribute Details

#user_birth_dateObject

Returns the value of attribute user_birth_date.



20
21
22
# File 'app/models/mpi_data.rb', line 20

def user_birth_date
  @user_birth_date
end

#user_edipiObject

Returns the value of attribute user_edipi.



20
21
22
# File 'app/models/mpi_data.rb', line 20

def user_edipi
  @user_edipi
end

#user_first_nameObject

Returns the value of attribute user_first_name.



20
21
22
# File 'app/models/mpi_data.rb', line 20

def user_first_name
  @user_first_name
end

#user_icnObject

Returns the value of attribute user_icn.



20
21
22
# File 'app/models/mpi_data.rb', line 20

def user_icn
  @user_icn
end

#user_idme_uuidObject

Returns the value of attribute user_idme_uuid.



20
21
22
# File 'app/models/mpi_data.rb', line 20

def user_idme_uuid
  @user_idme_uuid
end

#user_last_nameObject

Returns the value of attribute user_last_name.



20
21
22
# File 'app/models/mpi_data.rb', line 20

def user_last_name
  @user_last_name
end

#user_loa3Object

Returns the value of attribute user_loa3.



20
21
22
# File 'app/models/mpi_data.rb', line 20

def user_loa3
  @user_loa3
end

#user_logingov_uuidObject

Returns the value of attribute user_logingov_uuid.



20
21
22
# File 'app/models/mpi_data.rb', line 20

def user_logingov_uuid
  @user_logingov_uuid
end

#user_ssnObject

Returns the value of attribute user_ssn.



20
21
22
# File 'app/models/mpi_data.rb', line 20

def user_ssn
  @user_ssn
end

#user_uuidObject

Returns the value of attribute user_uuid.



20
21
22
# File 'app/models/mpi_data.rb', line 20

def user_uuid
  @user_uuid
end

Class Method Details

.for_user(user_identity) ⇒ MPIData

Creates a new MPIData instance for a user identity.

Parameters:

  • user (UserIdentity)

    the user identity to query MVI for

Returns:

  • (MPIData)

    an instance of this class



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/models/mpi_data.rb', line 35

def self.for_user(user_identity)
  mvi = MPIData.new

  mvi.user_loa3 = user_identity.loa3?
  mvi.user_icn = user_identity.mhv_icn || user_identity.icn
  mvi.user_first_name = user_identity.first_name
  mvi.user_last_name = user_identity.last_name
  mvi.user_birth_date = user_identity.birth_date
  mvi.user_ssn = user_identity.ssn
  mvi.user_edipi = user_identity.edipi
  mvi.user_logingov_uuid = user_identity.logingov_uuid
  mvi.user_idme_uuid = user_identity.idme_uuid
  mvi.user_uuid = user_identity.uuid
  mvi
end

Instance Method Details

#add_person_proxyObject

The status of the MPI Add Person Proxy Add call. An Orchestrated MVI Search needs to be made before an MPI add person proxy addcall is made. The response is recached afterwards so the new ids can be accessed on the next call.



178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'app/models/mpi_data.rb', line 178

def add_person_proxy
  search_response = mpi_service.find_profile_by_attributes_with_orch_search(first_name: user_first_name,
                                                                            last_name: user_last_name,
                                                                            birth_date: user_birth_date,
                                                                            ssn: user_ssn,
                                                                            edipi: user_edipi)
  if search_response.ok?
    @mvi_response = search_response
    add_response = mpi_service.add_person_proxy(last_name: search_response.profile.family_name,
                                                ssn: search_response.profile.ssn,
                                                birth_date: search_response.profile.birth_date,
                                                icn: search_response.profile.icn,
                                                edipi: search_response.profile.edipi,
                                                search_token: search_response.profile.search_token,
                                                first_name: search_response.profile.given_names.first)
    add_ids(add_response) if add_response.ok?
    add_response
  else
    search_response
  end
end

#birls_idString

A BIRLS (Beneficiary Identification and Records Locator System) MVI correlation id.

Returns:

  • (String)

    the birls id



91
# File 'app/models/mpi_data.rb', line 91

delegate :birls_id, to: :profile, allow_nil: true

#birls_idsArray[String]

Returns multiple birls ids.

Returns:

  • (Array[String])

    multiple birls ids



94
# File 'app/models/mpi_data.rb', line 94

delegate :birls_ids, to: :profile, allow_nil: true

#cerner_facility_idsArray[String]

The user’s Cerner facility ids

Returns:

  • (Array[String])

    the the list of Cerner facility ids



122
# File 'app/models/mpi_data.rb', line 122

delegate :cerner_facility_ids, to: :profile, allow_nil: true

#cerner_idString

A Cerner ID

Returns:

  • (String)

    the Cerner id



117
# File 'app/models/mpi_data.rb', line 117

delegate :cerner_id, to: :profile, allow_nil: true

#edipiString

A DOD EDIPI (Electronic Data Interchange Personal Identifier) MVI correlation ID or nil for users < LOA 3

Returns:

  • (String)

    the edipi correlation id



55
# File 'app/models/mpi_data.rb', line 55

delegate :edipi, to: :profile, allow_nil: true

#edipisArray[String]

Returns multiple edipi correlation ids.

Returns:

  • (Array[String])

    multiple edipi correlation ids



58
# File 'app/models/mpi_data.rb', line 58

delegate :edipis, to: :profile, allow_nil: true

#errorCommon::Exceptions::BackendServiceException

The error experienced when reaching out to the MVI service.



160
161
162
163
164
# File 'app/models/mpi_data.rb', line 160

def error
  return Common::Exceptions::Unauthorized.new(source: self.class) unless user_loa3

  mvi_response.try(:error)
end

#home_phoneString

The user’s home phone number

Returns:

  • (String)

    the home_phone



137
# File 'app/models/mpi_data.rb', line 137

delegate :home_phone, to: :profile, allow_nil: true

#icnString

A ICN (Integration Control Number - generated by the Master Patient Index) MVI correlation ID or nil for users < LOA 3

Returns:

  • (String)

    the icn correlation id



64
# File 'app/models/mpi_data.rb', line 64

delegate :icn, to: :profile, allow_nil: true

#icn_with_aaidString

A ICN (Integration Control Number - generated by the Master Patient Index) MVI correlation ID combined with its Assigning Authority ID. Or nil for users < LOA 3.

Returns:

  • (String)

    the icn correlation id with its assigning authority id. For example: ‘12345678901234567^NI^200M^USVHA^P’



72
# File 'app/models/mpi_data.rb', line 72

delegate :icn_with_aaid, to: :profile, allow_nil: true

#id_theft_flagBoolean

Identity theft flag

Returns:

  • (Boolean)

    presence or absence of identity theft flag



127
# File 'app/models/mpi_data.rb', line 127

delegate :id_theft_flag, to: :profile, allow_nil: true

#mhv_correlation_idString

A MHV (My HealtheVet) MVI correlation id or nil for users < LOA 3

Returns:

  • (String)

    the mhv correlation id



78
# File 'app/models/mpi_data.rb', line 78

delegate :mhv_correlation_id, to: :profile, allow_nil: true

#mhv_ienString

An MHV id.

Returns:

  • (String)

    the mhv ien id



99
# File 'app/models/mpi_data.rb', line 99

delegate :mhv_ien, to: :profile, allow_nil: true

#mhv_iensArray[String]

Returns multiple mhv ien ids.

Returns:

  • (Array[String])

    multiple mhv ien ids



102
# File 'app/models/mpi_data.rb', line 102

delegate :mhv_iens, to: :profile, allow_nil: true

#mpi_response_is_cached?(user_key: get_user_key) ⇒ Boolean

Returns:

  • (Boolean)


171
172
173
# File 'app/models/mpi_data.rb', line 171

def mpi_response_is_cached?(user_key: get_user_key)
  cached?(key: user_key)
end

#mvi_response(user_key: get_user_key) ⇒ MPI::Responses::FindProfileResponse

Returns the response returned from MVI.

Returns:



167
168
169
# File 'app/models/mpi_data.rb', line 167

def mvi_response(user_key: get_user_key)
  @mvi_response ||= response_from_redis_or_service(user_key:)
end

#participant_idString

A VBA (Veterans Benefits Administration) or participant MVI correlation id.

Returns:

  • (String)

    the participant id



83
# File 'app/models/mpi_data.rb', line 83

delegate :participant_id, to: :profile, allow_nil: true

#participant_idsArray[String]

Returns multiple participant ids.

Returns:

  • (Array[String])

    multiple participant ids



86
# File 'app/models/mpi_data.rb', line 86

delegate :participant_ids, to: :profile, allow_nil: true

#person_typesArray[String]

The person types that the user’s profile represents

Returns:

  • (Array[String])

    the list of person types



132
# File 'app/models/mpi_data.rb', line 132

delegate :person_types, to: :profile, allow_nil: true

#profileMPI::Models::MviProfile

The profile returned from the MVI service. Either returned from cached response in Redis or the MVI service.

Returns:



142
143
144
145
146
# File 'app/models/mpi_data.rb', line 142

def profile
  return nil unless user_loa3

  mvi_response&.profile
end

#search_tokenString

The search token given in the original MVI 1306 response message

Returns:

  • (String)

    the search token



112
# File 'app/models/mpi_data.rb', line 112

delegate :search_token, to: :profile, allow_nil: true

#statusString

The status of the last MVI response or not authorized for for users < LOA 3

Returns:

  • (String)

    the status of the last MVI response



151
152
153
154
155
# File 'app/models/mpi_data.rb', line 151

def status
  return :not_authorized unless user_loa3

  mvi_response&.status
end

#vet360_idString

A Vet360 Correlation ID

Returns:

  • (String)

    the Vet360 id



107
# File 'app/models/mpi_data.rb', line 107

delegate :vet360_id, to: :profile, allow_nil: true