Skip to content

Commit

Permalink
Api 26640 establish 526 claim (#12907)
Browse files Browse the repository at this point in the history
Finally got the mapper working mostly - PACT mapping still needs done, but got moved to another ticket
  • Loading branch information
acovrig authored Jun 13, 2023
1 parent e41fd07 commit f1d09a5
Show file tree
Hide file tree
Showing 4 changed files with 183 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require 'jsonapi/parser'
require 'claims_api/v2/disability_compensation_validation'
require 'claims_api/v2/disability_compensation_pdf_mapper'
require 'claims_api/v2/disability_compensation_evss_mapper'
require 'evss_service/base'

module ClaimsApi
Expand All @@ -29,7 +30,8 @@ def submit
pdf_data = get_pdf_data
pdf_mapper_service(form_attributes, pdf_data, target_veteran).map_claim

# evss_service.submit(auto_claim)
# evss_data = evss_mapper_service(auto_claim).map_claim
# evss_claim = evss_service.submit(auto_claim, evss_data)

render json: auto_claim
end
Expand All @@ -48,6 +50,10 @@ def pdf_mapper_service(auto_claim, pdf_data, target_veteran)
ClaimsApi::V2::DisabilityCompensationPdfMapper.new(auto_claim, pdf_data, target_veteran)
end

def evss_mapper_service(auto_claim)
ClaimsApi::V2::DisabilityCompensationEvssMapper.new(auto_claim)
end

def get_pdf_data
{
data: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# frozen_string_literal: true

module ClaimsApi
module V2
class DisabilityCompensationEvssMapper
def initialize(auto_claim)
@auto_claim = auto_claim
@data = auto_claim&.form_data&.deep_symbolize_keys
@evss_claim = {}
end

def map_claim
claim_attributes
claim_meta

{ form526: @evss_claim }
end

private

def claim_attributes
service_information
current_mailing_address
direct_deposit
disabilities
standard_claim
veteran_meta
end

def current_mailing_address
addr = @data.dig(:veteranIdentification, :mailingAddress) || {}
@evss_claim[:veteran] ||= {}
@evss_claim[:veteran][:currentMailingAddress] = addr
@evss_claim[:veteran][:currentMailingAddress].merge!({
addressLine1: addr[:numberAndStreet],
addressLines2: addr[:apartmentOrUnitNumber],
type: 'DOMESTIC'
})
@evss_claim[:veteran][:currentMailingAddress].except!(:numberAndStreet, :apartmentOrUnitNumber)
end

def direct_deposit
return if @data[:directDeposit].empty?

@evss_claim[:directDeposit] = @data[:directDeposit]
@evss_claim[:directDeposit][:bankName] = @data[:directDeposit][:financialInstitutionName]
@evss_claim[:directDeposit].except!(:financialInstitutionName, :noAccount)
end

def disabilities
@evss_claim[:disabilities] = @data[:disabilities].map do |disability|
disability[:approximateBeginDate] = map_date_to_obj disability[:approximateDate]
disability[:secondaryDisabilities] = disability[:secondaryDisabilities].map do |secondary|
secondary[:approximateBeginDate] = map_date_to_obj secondary[:approximateDate]
secondary.except(:exposureOrEventOrInjury, :approximateDate)
end

disability.except(:approximateDate, :isRelatedToToxicExposure)
end
end

def service_information
info = @data[:serviceInformation]
@evss_claim[:serviceInformation] = {
servicePeriods: info[:servicePeriods],
reservesNationalGuardService: {
obligationTermOfServiceFromDate: info[:reservesNationalGuardService][:obligationTermsOfService][:startDate],
obligationTermOfServiceToDate: info[:reservesNationalGuardService][:obligationTermsOfService][:endDate],
unitName: info[:reservesNationalGuardService][:unitName]
}
}
end

def standard_claim
@evss_claim[:standardClaim] = @data[:claimProcessType] == 'STANDARD_CLAIM_PROCESS'
end

def claim_meta
@evss_claim[:applicationExpirationDate] = Time.zone.today + 1.year
@evss_claim[:claimantCertification] = @data[:claimantCertification]
@evss_claim[:submtrApplcnTypeCd] = 'LH-B'
end

def veteran_meta
@evss_claim[:veteran] ||= {}
@evss_claim[:veteran][:currentlyVAEmployee] = @data.dig(:veteranIdentification, :currentlyVaEmployee)
@evss_claim[:veteran][:emailAddress] = @data.dig(:veteranIdentification, :emailAddress, :email)
@evss_claim[:veteran][:fileNumber] = @data.dig(:veteranIdentification, :vaFileNumber)
end

def map_date_to_obj(date)
date = if date.is_a? Date
date
else
DateTime.parse(date)
end
{ year: date.year, month: date.month, day: date.day }
end
end
end
end
6 changes: 3 additions & 3 deletions modules/claims_api/lib/evss_service/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ def initialize(request = nil)
@auth_headers = {}
end

def submit(claim)
def submit(claim, data)
@auth_headers = claim.auth_headers

client.post('submit', body: claim.form_data).body
client.post('submit', data).body
end

private

def client
base_name = Settings.dvp&.url
base_name = Settings.evss&.dvp&.url
service_name = Settings.evss&.service_name
raise StandardError, 'DVP URL missing' if base_name.blank?

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# frozen_string_literal: true

require 'rails_helper'
require 'claims_api/v2/disability_compensation_evss_mapper'

describe ClaimsApi::V2::DisabilityCompensationEvssMapper do
describe '526 claim maps to the evss container' do
let(:form_data) do
JSON.parse(
Rails.root.join(
'modules',
'claims_api',
'spec',
'fixtures',
'v2',
'veterans',
'disability_compensation',
'form_526_json_api.json'
).read
)
end
let(:auto_claim) do
create(:auto_established_claim, form_data: form_data['data']['attributes'])
end
let(:evss_data) { ClaimsApi::V2::DisabilityCompensationEvssMapper.new(auto_claim).map_claim[:form526] }

context '526 section 0' do
it 'maps the cert correctly' do
expect(evss_data[:claimantCertification]).to be true
end
end

context '526 section 1' do
it 'maps the mailing address' do
addr = evss_data[:veteran][:currentMailingAddress]
expect(addr[:addressLine1]).to eq('1234 Couch Street')
expect(addr[:city]).to eq('Portland')
expect(addr[:country]).to eq('USA')
expect(addr[:zipFirstFive]).to eq('41726')
expect(addr[:state]).to eq('OR')
end

it 'maps the other veteran info' do
expect(evss_data[:veteran][:fileNumber]).to eq('AB123CDEF')
expect(evss_data[:veteran][:currentlyVAEmployee]).to eq(false)
expect(evss_data[:veteran][:emailAddress]).to eq('valid@somedomain.com')
end
end

context '526 section 5, claim info: disabilities' do
it 'maps the attributes correctly' do
disability = evss_data[:disabilities][0]
secondary = disability[:secondaryDisabilities][0]

expect(disability[:disabilityActionType]).to eq('REOPEN')
expect(disability[:name]).to eq('PTSD (post traumatic stress disorder)')
expect(disability[:classificationCode]).to eq('5420')
expect(disability[:serviceRelevance]).to eq('ABCDEFG')
expect(disability[:ratedDisabilityId]).to eq('ABCDEFGHIJKLMNOPQRSTUVWX')
expect(disability[:diagnosticCode]).to eq(9999)
expect(disability[:exposureOrEventOrInjury]).to eq('EXPOSURE')
expect(disability[:approximateBeginDate]).to eq({ year: 2018, month: 11, day: 3 })

expect(secondary[:name]).to eq('Cancer - Musculoskeletal - Elbow')
expect(secondary[:disabilityActionType]).to eq('SECONDARY')
expect(secondary[:serviceRelevance]).to eq('ABCDEFGHIJKLMNOPQ')
expect(secondary[:classificationCode]).to eq('249470')
expect(secondary[:approximateBeginDate]).to eq({ year: 2018, month: 12, day: 3 })
end
end
end
end

0 comments on commit f1d09a5

Please sign in to comment.