Class: PdfFill::Forms::Va281900
- Includes:
- FormHelper
- Defined in:
- lib/pdf_fill/forms/va281900.rb
Constant Summary collapse
- ITERATOR =
PdfFill::HashConverter::ITERATOR
- KEY =
{ 'veteranInformation' => { 'fullName' => { 'first' => { key: 'VBA281900[0].#subform[0].Claimants_First_Name[0]', limit: 12, question_num: 1, question_suffix: 'A', question_text: 'NAME OF CLAIMANT' }, 'middleInitial' => { key: 'VBA281900[0].#subform[0].Middle_Initial1[0]', limit: 1, question_num: 1, question_suffix: 'B', question_text: 'NAME OF CLAIMANT' }, 'last' => { key: 'VBA281900[0].#subform[0].Last_Name[0]', limit: 18, question_num: 1, question_suffix: 'C', question_text: 'NAME OF CLAIMANT' } }, # end fullName 'ssn' => { 'first' => { key: 'VBA281900[0].#subform[0].SocialSecurityNumber_FirstThreeNumbers[0]', limit: 3, question_num: 2, question_suffix: 'A', question_text: 'SOCIAL SECURITY NUMBER' }, 'second' => { key: 'VBA281900[0].#subform[0].SocialSecurityNumber_SecondTwoNumbers[0]', limit: 2, question_num: 2, question_suffix: 'B', question_text: 'SOCIAL SECURITY NUMBER' }, 'third' => { key: 'VBA281900[0].#subform[0].SocialSecurityNumber_LastFourNumbers[0]', limit: 4, question_num: 2, question_suffix: 'C', question_text: 'SOCIAL SECURITY NUMBER' } }, 'VAFileNumber' => { key: 'VBA281900[0].#subform[0].VA_File_Number[0]', limit: 9, question_num: 3, question_suffix: 'A', question_text: 'VA FILE NUMBER' }, 'dob' => { 'month' => { key: 'VBA281900[0].#subform[0].DOB_Month[0]', limit: 2, question_num: 4, question_suffix: 'A', question_text: 'DATE OF BIRTH' }, 'day' => { key: 'VBA281900[0].#subform[0].DOB_Day[0]', limit: 2, question_num: 4, question_suffix: 'B', question_text: 'DATE OF BIRTH' }, 'year' => { key: 'VBA281900[0].#subform[0].DOB_Year[0]', limit: 4, question_num: 4, question_suffix: 'C', question_text: 'DATE OF BIRTH' } } }, # end veteran_information 'veteranAddress' => { 'addressLine1' => { key: 'VBA281900[0].#subform[0].Mailing_Address1[0]', limit: 30, question_num: 5, question_suffix: 'A', question_text: 'MAILING ADDRESS' }, 'addressLine2' => { key: 'VBA281900[0].#subform[0].Mailing_Address1[1]', limit: 30, question_num: 5, question_suffix: 'B', question_text: 'MAILING ADDRESS' }, 'addressLine3' => { key: 'VBA281900[0].#subform[0].Mailing_Address1[2]', limit: 30, question_num: 5, question_suffix: 'C', question_text: 'MAILING ADDRESS' } }, # end veteran_address 'mainPhone' => { 'phone_area_code' => { key: 'VBA281900[0].#subform[0].TelephoneNumber_AreaCode[0]', limit: 3, question_num: 6, question_suffix: 'A', question_text: 'MAIN TELEPHONE NUMBER' }, 'phone_first_three_numbers' => { key: 'VBA281900[0].#subform[0].TelephoneNumber_FirstThreeNumbers[0]', limit: 3, question_num: 6, question_suffix: 'B', question_text: 'MAIN TELEPHONE NUMBER' }, 'phone_last_four_numbers' => { key: 'VBA281900[0].#subform[0].TelephoneNumber_LastFourNumbers[0]', limit: 4, question_num: 6, question_suffix: 'C', question_text: 'MAIN TELEPHONE NUMBER' } }, 'email' => { key: 'VBA281900[0].#subform[0].Email_Address[0]', limit: 30, question_num: 7, question_suffix: 'A', question_text: 'E-MAIL ADDRESS OF CLAIMANT' }, 'cellPhone' => { 'phone_area_code' => { key: 'VBA281900[0].#subform[0].Cell_Phone_Number_AreaCode[0]', limit: 3, question_num: 8, question_suffix: 'A', question_text: 'CELL PHONE NUMBER' }, 'phone_first_three_numbers' => { key: 'VBA281900[0].#subform[0].Cell_Phone_Number_FirstThreeNumbers[0]', limit: 3, question_num: 8, question_suffix: 'B', question_text: 'CELL PHONE NUMBER' }, 'phone_last_four_numbers' => { key: 'VBA281900[0].#subform[0].Cell_PhoneNumber_LastFourNumbers[0]', limit: 4, question_num: 8, question_suffix: 'C', question_text: 'CELL PHONE NUMBER' } }, 'newAddress' => { 'addressLine1' => { key: 'VBA281900[0].#subform[0].Address1[0]', limit: 30, question_num: 9, question_suffix: 'A', question_text: 'NEW ADDRESS IF MOVING WITHIN THE NEXT 30 DAYS' }, 'addressLine2' => { key: 'VBA281900[0].#subform[0].Address1[1]', limit: 30, question_num: 9, question_suffix: 'B', question_text: 'NEW ADDRESS IF MOVING WITHIN THE NEXT 30 DAYS' }, 'addressLine3' => { key: 'VBA281900[0].#subform[0].Address1[2]', limit: 30, question_num: 9, question_suffix: 'C', question_text: 'NEW ADDRESS IF MOVING WITHIN THE NEXT 30 DAYS' } }, # end new_address 'yearsOfEducation' => { key: 'VBA281900[0].#subform[0].Number_Of_Years_Of_Education[0]', limit: 2, question_num: 10, question_suffix: 'A', question_text: 'NUMBER OF YEARS OF EDUCATION' }, 'signature' => { key: 'SignatureField' }, 'date_signed' => { 'month' => { key: 'VBA281900[0].#subform[0].Date_Signed_Month[0]' }, 'day' => { key: 'VBA281900[0].#subform[0].Date_Signed_Day[0]' }, 'year' => { key: 'VBA281900[0].#subform[0].Date_Signed_Year[0]' } }, # end date_signed 'useEva' => { key: 'useEva' }, 'useTelecounseling' => { key: 'useTelecounseling' }, 'appointmentTimePreferences' => { key: 'appointmentTimePreferences' } }.freeze
Instance Attribute Summary
Attributes inherited from FormBase
Instance Method Summary collapse
- #expand_phone_number(phone_type) ⇒ Object
- #format_address(address) ⇒ Object
- #merge_address_helpers ⇒ Object
- #merge_fields(options = {}) ⇒ Object
- #merge_preferences_helpers ⇒ Object
- #merge_veteran_helpers ⇒ Object
- #set_appointment_time_preferences ⇒ Object
Methods included from FormHelper
#address_block, #combine_date_ranges, #expand_checkbox_as_hash, #extract_country, #extract_middle_i, #format_boolean, #select_checkbox, #select_radio_button, #split_date, #split_postal_code, #split_ssn, #validate_date
Methods inherited from FormBase
#combine_both_addr, #combine_full_address, #combine_full_address_extras, #combine_full_name, #combine_hash, #combine_name_addr, #combine_name_addr_extras, #combine_postal_code, #combine_previous_names, date_strftime, #expand_checkbox, #expand_date_range, #expand_signature, #initialize
Constructor Details
This class inherits a constructor from PdfFill::Forms::FormBase
Instance Method Details
#expand_phone_number(phone_type) ⇒ Object
254 255 256 257 258 259 260 261 262 263 264 |
# File 'lib/pdf_fill/forms/va281900.rb', line 254 def (phone_type) phone_number = @form_data[phone_type] # ie. "main_phone", "cell_phone" if phone_number.present? phone_number = phone_number.delete('^0-9') @form_data[phone_type] = { 'phone_area_code' => phone_number[0..2], 'phone_first_three_numbers' => phone_number[3..5], 'phone_last_four_numbers' => phone_number[6..9] } end end |
#format_address(address) ⇒ Object
271 272 273 274 275 276 277 278 279 |
# File 'lib/pdf_fill/forms/va281900.rb', line 271 def format_address(address) street2 = address['street2'] || '' street3 = address['street3'] || '' state = address['state'] || '' address['addressLine1'] = "#{address['street']} #{street2} #{street3}" address['addressLine2'] = "#{address['city']} #{state} #{address['postalCode']}" address['addressLine3'] = address['country'] end |
#merge_address_helpers ⇒ Object
266 267 268 269 |
# File 'lib/pdf_fill/forms/va281900.rb', line 266 def merge_address_helpers format_address(@form_data['veteranAddress']) format_address(@form_data['newAddress']) if @form_data['isMoving'] end |
#merge_fields(options = {}) ⇒ Object
220 221 222 223 224 225 226 227 228 229 230 |
# File 'lib/pdf_fill/forms/va281900.rb', line 220 def merge_fields( = {}) merge_veteran_helpers merge_address_helpers merge_preferences_helpers created_at = [:created_at] if [:created_at].present? (@form_data['veteranInformation']['fullName'], created_at&.to_date || Time.zone.today) @form_data['date_signed'] = split_date(@form_data['signatureDate']) @form_data end |
#merge_preferences_helpers ⇒ Object
281 282 283 284 285 |
# File 'lib/pdf_fill/forms/va281900.rb', line 281 def merge_preferences_helpers @form_data['useEva'] = @form_data['useEva'] ? 'Yes' : 'No' @form_data['useTelecounseling'] = @form_data['useTelecounseling'] ? 'Yes' : 'No' @form_data['appointmentTimePreferences'] = set_appointment_time_preferences end |
#merge_veteran_helpers ⇒ Object
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/pdf_fill/forms/va281900.rb', line 232 def merge_veteran_helpers veteran_information = @form_data['veteranInformation'] # extract middle initial veteran_information['fullName'] = extract_middle_i(veteran_information, 'fullName') # extract ssn ssn = veteran_information['ssn'] if ssn.present? ssn = ssn.delete('-') veteran_information['ssn'] = split_ssn(ssn) va_file_number = veteran_information['VAFileNumber'] veteran_information['VAFileNumber'] = '' if ssn == va_file_number end # extract birth date veteran_information['dob'] = split_date(veteran_information['dob']) ('mainPhone') ('cellPhone') end |
#set_appointment_time_preferences ⇒ Object
287 288 289 290 291 292 293 294 295 296 |
# File 'lib/pdf_fill/forms/va281900.rb', line 287 def set_appointment_time_preferences times = @form_data['appointmentTimePreferences'] # ex. {'morning'=>true, 'mid_day'=>false, 'afternoon'=>false} counseling_hours = { 'morning' => "Mornings 6:00 to 10:00 a.m.\n", 'midday' => "Midday 10:00 a.m. to 2:00 p.m.\n", 'afternoon' => "Afternoons 2:00 to 6:00 p.m.\n" } times.map { |time| counseling_hours[time] }.join end |