Class: MPIData
- Inherits:
-
Common::RedisStore
- Object
- Common::RedisStore
- MPIData
- 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
-
#user_birth_date ⇒ Object
Returns the value of attribute user_birth_date.
-
#user_edipi ⇒ Object
Returns the value of attribute user_edipi.
-
#user_first_name ⇒ Object
Returns the value of attribute user_first_name.
-
#user_icn ⇒ Object
Returns the value of attribute user_icn.
-
#user_idme_uuid ⇒ Object
Returns the value of attribute user_idme_uuid.
-
#user_last_name ⇒ Object
Returns the value of attribute user_last_name.
-
#user_loa3 ⇒ Object
Returns the value of attribute user_loa3.
-
#user_logingov_uuid ⇒ Object
Returns the value of attribute user_logingov_uuid.
-
#user_ssn ⇒ Object
Returns the value of attribute user_ssn.
-
#user_uuid ⇒ Object
Returns the value of attribute user_uuid.
Class Method Summary collapse
-
.for_user(user_identity) ⇒ MPIData
Creates a new MPIData instance for a user identity.
Instance Method Summary collapse
- #add_ids(response) ⇒ Object private
-
#add_person_proxy ⇒ Object
The status of the MPI Add Person Proxy Add call.
-
#birls_id ⇒ String
A BIRLS (Beneficiary Identification and Records Locator System) MVI correlation id.
-
#birls_ids ⇒ Array[String]
Multiple birls ids.
-
#cerner_facility_ids ⇒ Array[String]
The user’s Cerner facility ids.
-
#cerner_id ⇒ String
A Cerner ID.
-
#edipi ⇒ String
A DOD EDIPI (Electronic Data Interchange Personal Identifier) MVI correlation ID or nil for users < LOA 3.
-
#edipis ⇒ Array[String]
Multiple edipi correlation ids.
-
#error ⇒ Common::Exceptions::BackendServiceException
The error experienced when reaching out to the MVI service.
- #find_profile ⇒ Object private
- #get_user_key ⇒ Object private
-
#home_phone ⇒ String
The user’s home phone number.
-
#icn ⇒ String
A ICN (Integration Control Number - generated by the Master Patient Index) MVI correlation ID or nil for users < LOA 3.
-
#icn_with_aaid ⇒ String
A ICN (Integration Control Number - generated by the Master Patient Index) MVI correlation ID combined with its Assigning Authority ID.
-
#id_theft_flag ⇒ Boolean
Identity theft flag.
-
#mhv_correlation_id ⇒ String
A MHV (My HealtheVet) MVI correlation id or nil for users < LOA 3.
-
#mhv_ien ⇒ String
An MHV id.
-
#mhv_iens ⇒ Array[String]
Multiple mhv ien ids.
- #mpi_response_is_cached?(user_key: get_user_key) ⇒ Boolean
- #mpi_service ⇒ Object private
-
#mvi_response(user_key: get_user_key) ⇒ MPI::Responses::FindProfileResponse
The response returned from MVI.
-
#participant_id ⇒ String
A VBA (Veterans Benefits Administration) or participant MVI correlation id.
-
#participant_ids ⇒ Array[String]
Multiple participant ids.
-
#person_types ⇒ Array[String]
The person types that the user’s profile represents.
-
#profile ⇒ MPI::Models::MviProfile
The profile returned from the MVI service.
- #record_ttl ⇒ Object private
- #response_from_redis_or_service(user_key:) ⇒ Object private
- #save ⇒ Object private
-
#search_token ⇒ String
The search token given in the original MVI 1306 response message.
-
#status ⇒ String
The status of the last MVI response or not authorized for for users < LOA 3.
-
#vet360_id ⇒ String
A Vet360 Correlation ID.
Methods included from SentryLogging
#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger, #set_sentry_metadata
Methods included from Common::CacheAside
#cache, #cached?, #do_cached_with, #set_attributes
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_date ⇒ Object
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_edipi ⇒ Object
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_name ⇒ Object
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_icn ⇒ Object
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_uuid ⇒ Object
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_name ⇒ Object
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_loa3 ⇒ Object
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_uuid ⇒ Object
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_ssn ⇒ Object
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_uuid ⇒ Object
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.
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_ids(response) ⇒ Object (private)
234 235 236 237 238 239 240 |
# File 'app/models/mpi_data.rb', line 234 def add_ids(response) # set new ids in the profile and recache the response profile.birls_id = response.parsed_codes[:birls_id].presence profile.participant_id = response.parsed_codes[:participant_id].presence cache(user_uuid, mvi_response) if mvi_response.cache? end |
#add_person_proxy ⇒ Object
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_id ⇒ String
A BIRLS (Beneficiary Identification and Records Locator System) MVI correlation id.
91 |
# File 'app/models/mpi_data.rb', line 91 delegate :birls_id, to: :profile, allow_nil: true |
#birls_ids ⇒ Array[String]
Returns multiple birls ids.
94 |
# File 'app/models/mpi_data.rb', line 94 delegate :birls_ids, to: :profile, allow_nil: true |
#cerner_facility_ids ⇒ Array[String]
The user’s Cerner facility ids
122 |
# File 'app/models/mpi_data.rb', line 122 delegate :cerner_facility_ids, to: :profile, allow_nil: true |
#cerner_id ⇒ String
A Cerner ID
117 |
# File 'app/models/mpi_data.rb', line 117 delegate :cerner_id, to: :profile, allow_nil: true |
#edipi ⇒ String
A DOD EDIPI (Electronic Data Interchange Personal Identifier) MVI correlation ID or nil for users < LOA 3
55 |
# File 'app/models/mpi_data.rb', line 55 delegate :edipi, to: :profile, allow_nil: true |
#edipis ⇒ Array[String]
Returns multiple edipi correlation ids.
58 |
# File 'app/models/mpi_data.rb', line 58 delegate :edipis, to: :profile, allow_nil: true |
#error ⇒ Common::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 |
#find_profile ⇒ Object (private)
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
# File 'app/models/mpi_data.rb', line 216 def find_profile if user_icn.present? mpi_service.find_profile_by_identifier(identifier: user_icn, identifier_type: MPI::Constants::ICN) elsif user_edipi.present? mpi_service.find_profile_by_edipi(edipi: user_edipi) elsif user_logingov_uuid.present? mpi_service.find_profile_by_identifier(identifier: user_logingov_uuid, identifier_type: MPI::Constants::LOGINGOV_UUID) elsif user_idme_uuid.present? mpi_service.find_profile_by_identifier(identifier: user_idme_uuid, identifier_type: MPI::Constants::IDME_UUID) else mpi_service.find_profile_by_attributes(first_name: user_first_name, last_name: user_last_name, birth_date: user_birth_date, ssn: user_ssn) end end |
#get_user_key ⇒ Object (private)
202 203 204 205 206 207 208 209 210 211 212 213 214 |
# File 'app/models/mpi_data.rb', line 202 def get_user_key if user_icn.present? user_icn elsif user_edipi.present? user_edipi elsif user_logingov_uuid.present? user_logingov_uuid elsif user_idme_uuid.present? user_idme_uuid else user_uuid end end |
#home_phone ⇒ String
The user’s home phone number
137 |
# File 'app/models/mpi_data.rb', line 137 delegate :home_phone, to: :profile, allow_nil: true |
#icn ⇒ String
A ICN (Integration Control Number - generated by the Master Patient Index) MVI correlation ID or nil for users < LOA 3
64 |
# File 'app/models/mpi_data.rb', line 64 delegate :icn, to: :profile, allow_nil: true |
#icn_with_aaid ⇒ String
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.
72 |
# File 'app/models/mpi_data.rb', line 72 delegate :icn_with_aaid, to: :profile, allow_nil: true |
#id_theft_flag ⇒ Boolean
Identity theft flag
127 |
# File 'app/models/mpi_data.rb', line 127 delegate :id_theft_flag, to: :profile, allow_nil: true |
#mhv_correlation_id ⇒ String
A MHV (My HealtheVet) MVI correlation id or nil for users < LOA 3
78 |
# File 'app/models/mpi_data.rb', line 78 delegate :mhv_correlation_id, to: :profile, allow_nil: true |
#mhv_ien ⇒ String
An MHV id.
99 |
# File 'app/models/mpi_data.rb', line 99 delegate :mhv_ien, to: :profile, allow_nil: true |
#mhv_iens ⇒ Array[String]
Returns 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
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 |
#mpi_service ⇒ Object (private)
251 252 253 |
# File 'app/models/mpi_data.rb', line 251 def mpi_service @service ||= MPI::Service.new end |
#mvi_response(user_key: get_user_key) ⇒ MPI::Responses::FindProfileResponse
Returns the response returned from MVI.
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_id ⇒ String
A VBA (Veterans Benefits Administration) or participant MVI correlation id.
83 |
# File 'app/models/mpi_data.rb', line 83 delegate :participant_id, to: :profile, allow_nil: true |
#participant_ids ⇒ Array[String]
Returns multiple participant ids.
86 |
# File 'app/models/mpi_data.rb', line 86 delegate :participant_ids, to: :profile, allow_nil: true |
#person_types ⇒ Array[String]
The person types that the user’s profile represents
132 |
# File 'app/models/mpi_data.rb', line 132 delegate :person_types, to: :profile, allow_nil: true |
#profile ⇒ MPI::Models::MviProfile
The profile returned from the MVI service. Either returned from cached response in Redis or the MVI service.
142 143 144 145 146 |
# File 'app/models/mpi_data.rb', line 142 def profile return nil unless user_loa3 mvi_response&.profile end |
#record_ttl ⇒ Object (private)
261 262 263 264 265 266 267 268 269 |
# File 'app/models/mpi_data.rb', line 261 def record_ttl if status == :ok # ensure default ttl is used for 'ok' responses REDIS_CONFIG[REDIS_CONFIG_KEY][:each_ttl] else # assign separate ttl to redis cache for failure responses REDIS_CONFIG[REDIS_CONFIG_KEY][:failure_ttl] end end |
#response_from_redis_or_service(user_key:) ⇒ Object (private)
242 243 244 245 246 247 248 249 |
# File 'app/models/mpi_data.rb', line 242 def response_from_redis_or_service(user_key:) do_cached_with(key: user_key) do find_profile rescue ArgumentError, MPI::Errors::ArgumentError => e ("[MPI Data] Request error: #{e.}", :warn) return nil end end |
#save ⇒ Object (private)
255 256 257 258 259 |
# File 'app/models/mpi_data.rb', line 255 def save saved = super expire(record_ttl) if saved saved end |
#search_token ⇒ String
The search token given in the original MVI 1306 response message
112 |
# File 'app/models/mpi_data.rb', line 112 delegate :search_token, to: :profile, allow_nil: true |
#status ⇒ String
The status of the last MVI response or not authorized for for users < LOA 3
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_id ⇒ String
A Vet360 Correlation ID
107 |
# File 'app/models/mpi_data.rb', line 107 delegate :vet360_id, to: :profile, allow_nil: true |