Class: EVSS::DisabilityCompensationForm::Form4142

Inherits:
Object
  • Object
show all
Defined in:
lib/evss/disability_compensation_form/form4142.rb

Overview

Transforms a client 4142 form submission into the format expected by the EVSS service 4142 - AUTHORIZATION TO DISCLOSE INFORMATION TO THE DEPARTMENT OF VETERANS AFFAIRS

Instance Method Summary collapse

Constructor Details

#initialize(user, form_content) ⇒ Form4142

Returns a new instance of Form4142.



12
13
14
15
16
17
# File 'lib/evss/disability_compensation_form/form4142.rb', line 12

def initialize(user, form_content)
  @user = user
  @phone_email = form_content.dig('form526', 'phoneAndEmail')
  @mailing_address = form_content.dig('form526', 'mailingAddress')
  @final_output = form_content.dig('form526', 'form4142')
end

Instance Method Details

#address(data) ⇒ Object (private)



47
48
49
50
51
52
53
54
55
56
# File 'lib/evss/disability_compensation_form/form4142.rb', line 47

def address(data)
  {
    'city' => data['city'],
    'country' => data['country'],
    'postalCode' => data['zipCode'],
    'street' => data['addressLine1'],
    'street2' => data['addressLine2'],
    'state' => data['state']
  }
end

#full_nameObject (private)



39
40
41
42
43
44
45
# File 'lib/evss/disability_compensation_form/form4142.rb', line 39

def full_name
  {
    'first' => @user.first_name,
    'middle' => @user.middle_name,
    'last' => @user.last_name
  }
end

#translateHash

Merges the user data and performs the translation

Returns:

  • (Hash)

    The translated form ready for submission



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/evss/disability_compensation_form/form4142.rb', line 23

def translate
  return nil unless @final_output

  @final_output['vaFileNumber'] = @user.ssn
  @final_output['veteranSocialSecurityNumber'] = @user.ssn
  @final_output['veteranFullName'] = full_name
  @final_output['veteranDateOfBirth'] = @user.birth_date
  @final_output['veteranAddress'] = address(@mailing_address)
  @final_output['email'] = @phone_email['emailAddress']
  @final_output['veteranPhone'] = @phone_email['primaryPhone']
  @final_output['veteranServiceNumber'] = '' # No veteran service number available in 526 PreFill
  @final_output
end