Class: EducationForm::EducationFacility

Inherits:
Object
  • Object
show all
Defined in:
app/sidekiq/education_form/education_facility.rb

Constant Summary collapse

EASTERN =
%w[
  CO CT DE DC IA IL IN KS KY MA ME MI MD MN MO MT NC ND NE
  NH NJ NY OH PA RI SD TN VT VA WV WI WY VI AA
].freeze
SOUTHERN =

We need to keep SOUTHERN and CENTRAL because existing records will have this as a region, and we need to continue to show the counts in the YTD reports.

%w[].freeze
CENTRAL =
%w[].freeze
WESTERN =
%w[
  AK AL AR AZ CA FL GA HI ID LA MS NM NV OK OR SC TX UT WA
  GU PR AP
].freeze
ADDRESSES =
{
  eastern: [
    'P.O. Box 4616',
    'Buffalo, NY 14240-4616'
  ],
  southern: [
    'P.O. Box 100022',
    'Decatur, GA 30031-7022'
  ],
  central: [
    '9770 Page Avenue',
    'Suite 101 Education',
    'St. Louis, MO 63132-1502'
  ],
  western: [
    'P.O. Box 8888',
    'Muskogee, OK 74402-8888'
  ]
}.freeze
REGIONS =
ADDRESSES.keys
RPO_NAMES =
{
  eastern: 'BUFFALO (307)',
  southern: 'ATLANTA (316)',
  central: 'ST. LOUIS (331)',
  western: 'MUSKOGEE (351)'
}.freeze
EMAIL_NAMES =
{
  eastern: 'Eastern Region',
  southern: 'Southern Region',
  central: 'Central Region',
  western: 'Western Region'
}.freeze
FACILITY_IDS =
{
  eastern: 307,
  southern: 316,
  central: 331,
  western: 351
}.freeze

Class Method Summary collapse

Class Method Details

.check_area(address) ⇒ Object



91
92
93
94
95
96
97
98
# File 'app/sidekiq/education_form/education_facility.rb', line 91

def self.check_area(address)
  area = address&.state
  if WESTERN.any? { |state| state == area }
    :western
  else
    :eastern
  end
end

.education_program(record) ⇒ Object



100
101
102
# File 'app/sidekiq/education_form/education_facility.rb', line 100

def self.education_program(record)
  record.educationProgram || record.school
end

.facility_for(region:) ⇒ Object



66
67
68
# File 'app/sidekiq/education_form/education_facility.rb', line 66

def self.facility_for(region:)
  FACILITY_IDS[region]
end

.region_for(model) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'app/sidekiq/education_form/education_facility.rb', line 74

def self.region_for(model)
  record = model.open_struct_form
  address = routing_address(record, form_type: model.form_type)

  # special case 0993 and 1990s
  return :western if model.form_type == '0993' || model.form_type == '1990s'

  # special case 0994
  # special case 10203
  return :eastern if %w[0994 10203].include?(model.form_type)

  # special case Philippines
  return :western if address&.country == 'PHL'

  check_area(address)
end

.regional_office_for(model) ⇒ Object



120
121
122
123
# File 'app/sidekiq/education_form/education_facility.rb', line 120

def self.regional_office_for(model)
  region = region_for(model)
  ['VA Regional Office', ADDRESSES[region]].join("\n")
end

.routing_address(record, form_type:) ⇒ Object

Claims are sent to different RPOs based first on the location of the school that the claim is relating to (either ‘school` or `newSchool` in our submissions) or to the applicant’s address (either as a relative or the veteran themselves)



107
108
109
110
111
112
113
114
115
116
117
118
# File 'app/sidekiq/education_form/education_facility.rb', line 107

def self.routing_address(record, form_type:)
  case form_type.upcase
  when '1990'
    education_program(record)&.address || record.veteranAddress
  when '1990N'
    record.educationProgram&.address || record.veteranAddress
  when '1990E', '5490', '5495'
    record.educationProgram&.address || record.relativeAddress
  when '1995'
    record.newSchool&.address || record.veteranAddress
  end
end

.rpo_name(region:) ⇒ Object



70
71
72
# File 'app/sidekiq/education_form/education_facility.rb', line 70

def self.rpo_name(region:)
  RPO_NAMES[region]
end