department-of-veterans-affairs / va.gov-team

Public resources for building on and in support of VA.gov. Visit complete Knowledge Hub:
https://depo-platform-documentation.scrollhelp.site/index.html
281 stars 201 forks source link

Add MPI call to ITF process #93996

Open mjknight50 opened 3 hours ago

mjknight50 commented 3 hours ago

Overview

In order to improve the number of veterans who can set an ITF, @sanjabaj2 has asked that we modify the existing ITF code and add a call to MPI for any veteran that doesn't an a participant_id

ITF specific numbers for pension: 80% have a participant_id and ICN 91% have a ICN So, we're talking about 9% of ITF attempts over the past month that would have been able to do an ITF.

@wayne-weibel stated that "we would want this in sidekiq since if it is rerun the PID may still not be present, but we do catch the non-existence and do not retry in that case"

Tasks

wayne-weibel commented 2 hours ago

something along these lines:


  def mpi_profile
        response = nil
        a = user_account
        f = form
        if a && a.icn.present?
            response = MPI::Service.new.find_profile_by_identifier(
                identifier: a.icn,
                identifier_type: MPI::Constants::ICN
            )
        elsif f
            name = f['veteranFullName'] || {}
            response = MPI::Service.new.find_profile_by_attributes(first_name: name['first'],
                last_name: name['last'],
                birth_date: f['veteranDateOfBirth'],
                ssn: f['veteranSocialSecurityNumber']) if name['first'] && name['last'] && f['veteranDateOfBirth'] && f['veteranSocialSecurityNumber']
        end

        if response and response.error.present?
            report_error "MPI profile error: #{response.error}"
            nil
        else
            response&.profile
        end
  rescue => e
    report_error "MPI profile error: #{e}"
        nil
  end