Class: PdfFill::Forms::Va214142

Inherits:
FormBase
  • Object
show all
Includes:
FormHelper
Defined in:
lib/pdf_fill/forms/va214142.rb

Constant Summary collapse

PROVIDER_ITERATOR =
PdfFill::HashConverter::ITERATOR
KEY =
{
  'veteranFullName' => {
    'first' => {
      key: 'F[0].Page_1[0].VeteranFirstName[0]',
      limit: 12,
      question_num: 1,
      question_text: "VETERAN/BENEFICIARY'S FIRST NAME"
    },
    'middleInitial' => {
      key: 'F[0].Page_1[0].VeteranMiddleInitial1[0]'
    },
    'last' => {
      key: 'F[0].Page_1[0].VeteranLastName[0]',
      limit: 18,
      question_num: 1,
      question_text: "VETERAN/BENEFICIARY'S LAST NAME"
    }
  },
  'veteranSocialSecurityNumber' => {
    'first' => {
      key: 'F[0].Page_1[0].ClaimantsSocialSecurityNumber_FirstThreeNumbers[0]'
    },
    'second' => {
      key: 'F[0].Page_1[0].ClaimantsSocialSecurityNumber_SecondTwoNumbers[0]'
    },
    'third' => {
      key: 'F[0].Page_1[0].ClaimantsSocialSecurityNumber_LastFourNumbers[0]'
    }
  },
  'vaFileNumber' => {
    key: 'F[0].Page_1[0].VAFileNumber[0]'
  },
  'veteranDateOfBirth' => {
    'month' => {
      key: 'F[0].Page_1[0].DOBmonth[0]'
    },
    'day' => {
      key: 'F[0].Page_1[0].DOBday[0]'
    },
    'year' => {
      key: 'F[0].Page_1[0].DOByear[0]'
    }
  },
  'veteranServiceNumber' => {
    key: 'F[0].Page_1[0].VeteransServiceNumber[0]'
  },
  'veteranAddress' => {
    question_num: 6,
    question_text: 'MAILING ADDRESS',

    'street' => {
      key: 'F[0].Page_1[0].CurrentMailingAddress_NumberAndStreet[0]',
      limit: 30,
      question_num: 6,
      question_suffix: 'A',
      question_text: 'Number and Street'
    },
    'street2' => {
      key: 'F[0].Page_1[0].CurrentMailingAddress_ApartmentOrUnitNumber[0]',
      limit: 5,
      question_num: 6,
      question_suffix: 'B',
      question_text: 'Apartment or Unit Number'
    },
    'city' => {
      key: 'F[0].Page_1[0].CurrentMailingAddress_City[0]',
      limit: 18,
      question_num: 6,
      question_suffix: 'C',
      question_text: 'City'
    },
    'state' => {
      key: 'F[0].Page_1[0].CurrentMailingAddress_StateOrProvince[0]'
    },
    'country' => {
      key: 'F[0].Page_1[0].CurrentMailingAddress_Country[0]',
      limit: 2
    },
    'postalCode' => {
      'firstFive' => {
        key: 'F[0].Page_1[0].CurrentMailingAddress_ZIPOrPostalCode_FirstFiveNumbers[0]'
      },
      'lastFour' => {
        key: 'F[0].Page_1[0].CurrentMailingAddress_ZIPOrPostalCode_LastFourNumbers[0]'
      }
    }
  },
  'email' => {
    key: 'F[0].Page_1[0].EMAIL[0]'
  },
  'veteranPhone' => {
    key: 'F[0].Page_1[0].EMAIL[1]'
  },
  'veteranSocialSecurityNumber1' => {
    'first' => {
      key: 'F[0].#subform[1].VeteransSocialSecurityNumber_FirstThreeNumbers[0]'
    },
    'second' => {
      key: 'F[0].#subform[1].VeteransSocialSecurityNumber_SecondTwoNumbers[0]'
    },
    'third' => {
      key: 'F[0].#subform[1].VeteransSocialSecurityNumber_LastFourNumbers[0]'
    }
  },
  'limitedConsent' => {
    limit: 83,
    question_num: 12,
    question_text: 'Limited Consent',
    key: 'F[0].#subform[1].InformationIsLimitedToWhatIsWrittenInThisSpace[0]'
  },
  'signature' => {
    key: 'F[0].#subform[1].CLAIMANT_SIGNATURE[0]'
  },
  'signatureDate' => {
    key: 'F[0].#subform[1].DateSigned_Month_Day_Year[0]',
    format: 'date'
  },
  'printedName' => {
    key: 'F[0].#subform[1].PrintedNameOfPersonAuthorizingDisclosure[0]'
  },
  'veteranFullName1' => {
    'first' => {
      key: 'F[0].#subform[8].VeteranFirstName[0]',
      limit: 12,
      question_num: 17,
      question_text: "4142a VETERAN/BENEFICIARY'S FIRST NAME"
    },
    'middleInitial' => {
      key: 'F[0].#subform[8].VeteranMiddleInitial1[0]'
    },
    'last' => {
      key: 'F[0].#subform[8].VeteranLastName[0]',
      limit: 18,
      question_num: 17,
      question_text: "4142a VETERAN/BENEFICIARY'S LAST NAME"
    }
  },
  'veteranSocialSecurityNumber2' => {
    'first' => {
      key: 'F[0].#subform[8].ClaimantsSocialSecurityNumber_FirstThreeNumbers[0]'
    },
    'second' => {
      key: 'F[0].#subform[8].ClaimantsSocialSecurityNumber_SecondTwoNumbers[0]'
    },
    'third' => {
      key: 'F[0].#subform[8].ClaimantsSocialSecurityNumber_LastFourNumbers[0]'
    }
  },
  'vaFileNumber1' => {
    key: 'F[0].#subform[8].VAFileNumber[0]'
  },
  'veteranDateOfBirth1' => {
    'month' => {
      key: 'F[0].#subform[8].DOBmonth[0]'
    },
    'day' => {
      key: 'F[0].#subform[8].DOBday[0]'
    },
    'year' => {
      key: 'F[0].#subform[8].DOByear[0]'
    }
  },
  'veteranServiceNumber1' => {
    key: 'F[0].#subform[8].VeteransServiceNumber[0]'
  },
  'veteranSocialSecurityNumber3' => {
    'first' => {
      key: 'F[0].#subform[9].VeteransSocialSecurityNumber_FirstThreeNumbers[1]'
    },
    'second' => {
      key: 'F[0].#subform[9].VeteransSocialSecurityNumber_SecondTwoNumbers[1]'
    },
    'third' => {
      key: 'F[0].#subform[9].VeteransSocialSecurityNumber_LastFourNumbers[1]'
    }
  },
  'providerFacility' => {
    limit: 5,
    first_key: 'providerFacilityName',
    question_text: 'PROVIDER / FACILITY',

    'providerFacilityName' => {
      key: "F[0].provider.name[#{PROVIDER_ITERATOR}]"
    },
    'dateRangeStart0' => {
      key: "F[0].provider.dateRangeStart0[#{PROVIDER_ITERATOR}]",
      format: 'date'
    },
    'dateRangeEnd0' => {
      key: "F[0].provider.dateRangeEnd0[#{PROVIDER_ITERATOR}]",
      format: 'date'
    },
    'dateRangeStart1' => {
      key: "F[0].provider.dateRangeStart1[#{PROVIDER_ITERATOR}]",
      format: 'date'
    },
    'dateRangeEnd1' => {
      key: "F[0].provider.dateRangeEnd1[#{PROVIDER_ITERATOR}]",
      format: 'date'
    },
    'street' => {
      limit: 30,
      key: "F[0].provider.numberAndStreet[#{PROVIDER_ITERATOR}]"
    },
    'street2' => {
      limit: 5,
      key: "F[0].provider.apartmentOrUnitNumber[#{PROVIDER_ITERATOR}]"
    },
    'city' => {
      limit: 18,
      key: "F[0].provider.city[#{PROVIDER_ITERATOR}]"
    },
    'state' => {
      key: "F[0].provider.state[#{PROVIDER_ITERATOR}]"
    },
    'country' => {
      key: "F[0].provider.country[#{PROVIDER_ITERATOR}]"
    },
    'postalCode' => {
      'firstFive' => {
        key: "F[0].provider.postalCode_FirstFiveNumbers[#{PROVIDER_ITERATOR}]"
      },
      'lastFour' => {
        key: "F[0].provider.postalCode_LastFourNumbers[#{PROVIDER_ITERATOR}]"
      }
    },
    'nameAndAddressOfProvider' => {
      key: '',
      question_suffix: 'A',
      question_text: 'Name and Address of Provider',
      question_num: 9
    },
    'combinedTreatmentDates' => {
      key: '',
      question_suffix: 'B',
      question_text: 'Treatment Dates',
      question_num: 9
    }
  }
}.freeze

Instance Attribute Summary

Attributes inherited from FormBase

#form_data

Instance Method Summary collapse

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_claimant_addressObject



272
273
274
275
# File 'lib/pdf_fill/forms/va214142.rb', line 272

def expand_claimant_address
  @form_data['veteranAddress']['country'] = extract_country(@form_data['veteranAddress'])
  @form_data['veteranAddress']['postalCode'] = split_postal_code(@form_data['veteranAddress'])
end

#expand_provider_address(providers) ⇒ Object



318
319
320
321
322
323
324
325
326
327
328
329
330
331
# File 'lib/pdf_fill/forms/va214142.rb', line 318

def expand_provider_address(providers)
  providers.each do |provider|
    provider_address = {
      'street' => provider['providerFacilityAddress']['street'],
      'street2' => provider['providerFacilityAddress']['street2'],
      'city' => provider['providerFacilityAddress']['city'],
      'state' => provider['providerFacilityAddress']['state'],
      'country' => extract_country(provider['providerFacilityAddress']),
      'postalCode' => split_postal_code(provider['providerFacilityAddress'])
    }
    provider.except!('providerFacilityAddress')
    provider.merge!(provider_address)
  end
end

#expand_provider_date_range(providers) ⇒ Object



303
304
305
306
307
308
309
310
311
312
313
314
315
316
# File 'lib/pdf_fill/forms/va214142.rb', line 303

def expand_provider_date_range(providers)
  providers.each do |provider|
    dates_of_treatment = provider['treatmentDateRange']
    date_ranges = {}
    dates_of_treatment.each_with_index do |date_range, index|
      date_ranges.merge!(
        "dateRangeStart#{index}" => date_range['from'],
        "dateRangeEnd#{index}" => date_range['to']
      )
    end
    provider.except!('treatmentDateRange')
    provider.merge!(date_ranges)
  end
end

#expand_provider_extras(providers) ⇒ Object



333
334
335
336
337
338
339
340
# File 'lib/pdf_fill/forms/va214142.rb', line 333

def expand_provider_extras(providers)
  providers.each do |provider|
    name_address_extras = combine_name_addr_extras(provider, 'providerFacilityName', 'providerFacilityAddress')
    provider['nameAndAddressOfProvider'] = PdfFill::FormValue.new('', name_address_extras)
    dates_extras = combine_date_ranges(provider['treatmentDateRange'])
    provider['combinedTreatmentDates'] = PdfFill::FormValue.new('', dates_extras)
  end
end

#expand_providers(providers) ⇒ Object



342
343
344
345
346
347
348
# File 'lib/pdf_fill/forms/va214142.rb', line 342

def expand_providers(providers)
  return if providers.blank?

  expand_provider_extras(providers)
  expand_provider_address(providers)
  expand_provider_date_range(providers)
end

#expand_ssnObject



263
264
265
266
267
268
269
270
# File 'lib/pdf_fill/forms/va214142.rb', line 263

def expand_ssn
  ssn = @form_data['veteranSocialSecurityNumber']
  return if ssn.blank?

  ['', '1', '2', '3'].each do |suffix|
    @form_data["veteranSocialSecurityNumber#{suffix}"] = split_ssn(ssn)
  end
end

#expand_va_file_numberObject



254
255
256
257
258
259
260
261
# File 'lib/pdf_fill/forms/va214142.rb', line 254

def expand_va_file_number
  va_file_number = @form_data['vaFileNumber']
  return if va_file_number.blank?

  ['', '1'].each do |suffix|
    @form_data["vaFileNumber#{suffix}"] = va_file_number
  end
end

#expand_veteran_dobObject



283
284
285
286
287
288
289
290
# File 'lib/pdf_fill/forms/va214142.rb', line 283

def expand_veteran_dob
  veteran_date_of_birth = @form_data['veteranDateOfBirth']
  return if veteran_date_of_birth.blank?

  ['', '1'].each do |suffix|
    @form_data["veteranDateOfBirth#{suffix}"] = split_date(veteran_date_of_birth)
  end
end

#expand_veteran_full_nameObject



277
278
279
280
281
# File 'lib/pdf_fill/forms/va214142.rb', line 277

def expand_veteran_full_name
  ['', '1'].each do |suffix|
    @form_data["veteranFullName#{suffix}"] = extract_middle_i(@form_data, 'veteranFullName')
  end
end

#expand_veteran_service_numberObject



292
293
294
295
296
297
298
299
300
301
# File 'lib/pdf_fill/forms/va214142.rb', line 292

def expand_veteran_service_number
  veteran_service_number = @form_data['veteranServiceNumber']
  return if veteran_service_number.blank?

  if veteran_service_number
    ['', '1'].each do |suffix|
      @form_data["veteranServiceNumber#{suffix}"] = veteran_service_number
    end
  end
end

#merge_fields(_options = {}) ⇒ Object



350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
# File 'lib/pdf_fill/forms/va214142.rb', line 350

def merge_fields(_options = {})
  expand_va_file_number

  expand_ssn

  expand_veteran_full_name
  signature_date = @form_data['signatureDate']
  expand_signature(@form_data['veteranFullName'], signature_date)
  @form_data['printedName'] = @form_data['signature']
  @form_data['signature'] = "/es/ #{@form_data['signature']}"

  expand_claimant_address

  expand_veteran_dob

  expand_veteran_service_number

  @form_data['providerFacility'] = expand_providers(@form_data['providerFacility'])

  @form_data
end