Class: EVSS::DisabilityCompensationForm::Form0781
- Inherits:
-
Object
- Object
- EVSS::DisabilityCompensationForm::Form0781
- Defined in:
- lib/evss/disability_compensation_form/form0781.rb
Overview
Transforms a client 0781 form submission into the format expected by the EVSS service
Instance Method Summary collapse
- #create_form(incidents) ⇒ Object private
- #full_name ⇒ Object private
-
#initialize(user, form_content) ⇒ Form0781
constructor
A new instance of Form0781.
- #join_location(location) ⇒ Object private
- #split_incidents(incidents) ⇒ Object private
-
#translate ⇒ Hash
Merges the user data and performs the translation.
Constructor Details
#initialize(user, form_content) ⇒ Form0781
Returns a new instance of Form0781.
11 12 13 14 15 16 |
# File 'lib/evss/disability_compensation_form/form0781.rb', line 11 def initialize(user, form_content) @user = user @phone_email = form_content.dig('form526', 'phoneAndEmail') @form_content = form_content.dig('form526', 'form0781') @translated_forms = {} end |
Instance Method Details
#create_form(incidents) ⇒ Object (private)
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/evss/disability_compensation_form/form0781.rb', line 41 def create_form(incidents) { 'vaFileNumber' => @user.ssn, 'veteranSocialSecurityNumber' => @user.ssn, 'veteranFullName' => full_name, 'veteranDateOfBirth' => @user.birth_date, 'email' => @phone_email['emailAddress'], 'veteranPhone' => @phone_email['primaryPhone'], 'veteranSecondaryPhone' => '', # No secondary phone available in 526 PreFill 'veteranServiceNumber' => '', # No veteran service number available in 526 PreFill 'incidents' => incidents, 'remarks' => @form_content['remarks'], 'additionalIncidentText' => @form_content['additionalIncidentText'], 'otherInformation' => @form_content['otherInformation'] } end |
#full_name ⇒ Object (private)
73 74 75 76 77 78 79 |
# File 'lib/evss/disability_compensation_form/form0781.rb', line 73 def full_name { 'first' => @user.first_name, 'middle' => @user.middle_name, 'last' => @user.last_name } end |
#join_location(location) ⇒ Object (private)
64 65 66 67 68 69 70 71 |
# File 'lib/evss/disability_compensation_form/form0781.rb', line 64 def join_location(location) [ location['city'], location['state'], location['country'], location['additionalDetails'] ].reject(&:blank?).join(', ') end |
#split_incidents(incidents) ⇒ Object (private)
58 59 60 61 62 |
# File 'lib/evss/disability_compensation_form/form0781.rb', line 58 def split_incidents(incidents) return nil if incidents.blank? incidents.partition { |incident| incident['personalAssault'] } end |
#translate ⇒ Hash
Merges the user data and performs the translation
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/evss/disability_compensation_form/form0781.rb', line 22 def translate return nil unless @form_content # The pdf creation functionality is looking for a single street address # instead of a hash @form_content['incidents'].each do |incident| incident['incidentLocation'] = join_location(incident['incidentLocation']) if incident['incidentLocation'] end incs0781a, incs0781 = split_incidents(@form_content['incidents']) @translated_forms['form0781'] = create_form(incs0781) if incs0781.present? @translated_forms['form0781a'] = create_form(incs0781a) if incs0781a.present? @translated_forms end |