Class: Pension21p527ez::PensionMilitaryInformation

Inherits:
VAProfile::Prefill::MilitaryInformation show all
Defined in:
lib/pension_21p527ez/pension_military_information.rb

Overview

extends MilitaryInformation to add additional prefill methods to Pensions military information prefill

See Also:

  • VAProfile::Prefill::MilitaryInformation

Constant Summary collapse

PREFILL_METHODS =
VAProfile::Prefill::MilitaryInformation::PREFILL_METHODS + %w[
  first_uniformed_entry_date
  last_active_discharge_date
  service_branches_for_pensions
  service_number
].freeze
PENSION_SERVICE_BRANCHES_MAPPING =

Map between service branch names and the fields used for pensions.serviceBranch

{
  'Army' => 'army',
  'Navy' => 'navy',
  'Air Force' => 'airForce',
  'Coast Guard' => 'coastGuard',
  'Marine Corps' => 'marineCorps',
  'Space Force' => 'spaceForce',
  'Public Health Service' => 'usphs',
  'National Oceanic & Atmospheric Administration' => 'noaa'
}.freeze

Constants inherited from VAProfile::Prefill::MilitaryInformation

VAProfile::Prefill::MilitaryInformation::COMBINED_SERVICE_BRANCHES, VAProfile::Prefill::MilitaryInformation::DISCHARGE_TYPES, VAProfile::Prefill::MilitaryInformation::GULF_WAR_RANGE, VAProfile::Prefill::MilitaryInformation::HCA_SERVICE_BRANCHES, VAProfile::Prefill::MilitaryInformation::NOV_1998, VAProfile::Prefill::MilitaryInformation::SOUTHWEST_ASIA

Instance Attribute Summary

Attributes inherited from VAProfile::Prefill::MilitaryInformation

#military_personnel_service

Instance Method Summary collapse

Methods inherited from VAProfile::Prefill::MilitaryInformation

#currently_active_duty, #currently_active_duty_hash, #deployed_to?, #deployments, #discharge_type, #guard_reserve_service_by_date, #guard_reserve_service_history, #hca_last_service_branch, #last_discharge_date, #last_entry_date, #last_service_branch, #latest_guard_reserve_service_period, #latest_service_episode, #military_service_episodes, #military_service_episodes_by_date, #national_guard?, #post_nov111998_combat, #reserve?, #service_branch_used_in_disability, #service_branches, #service_episodes_by_date, #service_history, #service_periods, #sw_asia_combat, #tours_of_duty

Constructor Details

#initialize(user) ⇒ PensionMilitaryInformation

Returns a new instance of PensionMilitaryInformation.

[View source] [View on GitHub]

44
45
46
47
# File 'lib/pension_21p527ez/pension_military_information.rb', line 44

def initialize(user)
  @user = user
  super
end

Instance Method Details

#first_uniformed_entry_dateString

Returns “YYYY-MM-DD”.

Returns:

  • (String)

    “YYYY-MM-DD”

[View source] [View on GitHub]

50
51
52
# File 'lib/pension_21p527ez/pension_military_information.rb', line 50

def 
  service_history.
end

#format_service_branches_for_pensions(branches) ⇒ Hash

Filters out any unknown branches

Returns:

  • (Hash)

    { army => true, navy => true, … }

[View source] [View on GitHub]

69
70
71
# File 'lib/pension_21p527ez/pension_military_information.rb', line 69

def format_service_branches_for_pensions(branches)
  branches.uniq.compact_blank.index_with { true }
end

#last_active_discharge_dateString

Returns “YYYY-MM-DD”.

Returns:

  • (String)

    “YYYY-MM-DD”

[View source] [View on GitHub]

55
56
57
# File 'lib/pension_21p527ez/pension_military_information.rb', line 55

def last_active_discharge_date
  service_history.release_from_active_duty_date
end

#map_service_episodes_to_branchesObject (private)

[View source] [View on GitHub]

86
87
88
89
90
91
92
# File 'lib/pension_21p527ez/pension_military_information.rb', line 86

def map_service_episodes_to_branches
  service_history.episodes.map do |episode|
    branch = episode.branch_of_service
    branch_value = ClaimsApi::ServiceBranchMapper.new(branch).value
    PensionMilitaryInformation::PENSION_SERVICE_BRANCHES_MAPPING[branch_value]
  end
end

#service_branches_for_pensionsHash

Returns { army => true, navy => true, … } in the format required for pensions.serviceBranch.

Returns:

  • (Hash)

    { army => true, navy => true, … } in the format required for pensions.serviceBranch

[View source] [View on GitHub]

60
61
62
63
64
65
# File 'lib/pension_21p527ez/pension_military_information.rb', line 60

def service_branches_for_pensions
  format_service_branches_for_pensions(map_service_episodes_to_branches)
rescue => e
  Rails.logger.error("Error fetching service branches for Pension prefill: #{e}")
  {}
end

#service_numberObject

If the veteran began service after 1971, their service number is their SSN We haven’t identified a source for pre-1971 service numbers for prefill

[View source] [View on GitHub]

76
77
78
79
80
81
82
# File 'lib/pension_21p527ez/pension_military_information.rb', line 76

def service_number
  year_of_entry = .to_i if 
  @user&.ssn_normalized if year_of_entry > 1971
rescue => e
  Rails.logger.error("Error fetching service number for Pension prefill: #{e}")
  nil
end