-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Api 26640 establish 526 claim (#12907)
Finally got the mapper working mostly - PACT mapping still needs done, but got moved to another ticket
- Loading branch information
Showing
4 changed files
with
183 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
modules/claims_api/lib/claims_api/v2/disability_compensation_evss_mapper.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
modules/claims_api/spec/lib/claims_api/v2/disability_compensation_evss_mapper_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |