Class: LighthouseRatedDisabilitiesProvider
- Inherits:
-
Object
- Object
- LighthouseRatedDisabilitiesProvider
- Includes:
- RatedDisabilitiesProvider
- Defined in:
- lib/disability_compensation/providers/rated_disabilities/lighthouse_rated_disabilities_provider.rb
Instance Method Summary collapse
- #decision_code_transform(decision_code_text) ⇒ Object
-
#get_combined_disability_rating(lighthouse_client_id = nil, lighthouse_rsa_key_path = nil) ⇒ integer
The combined disability rating.
- #get_data(lighthouse_client_id = nil, lighthouse_rsa_key_path = nil, options = {}) ⇒ Object
-
#get_rated_disabilities(lighthouse_client_id = nil, lighthouse_rsa_key_path = nil, options = {}) ⇒ DisabilityCompensation::ApiProvider::RatedDisabilitiesResponse
A list of individual disability ratings.
-
#initialize(icn) ⇒ LighthouseRatedDisabilitiesProvider
constructor
A new instance of LighthouseRatedDisabilitiesProvider.
- #transform(data) ⇒ Object
Methods included from RatedDisabilitiesProvider
Constructor Details
#initialize(icn) ⇒ LighthouseRatedDisabilitiesProvider
Returns a new instance of LighthouseRatedDisabilitiesProvider.
11 12 13 14 |
# File 'lib/disability_compensation/providers/rated_disabilities/lighthouse_rated_disabilities_provider.rb', line 11 def initialize(icn) @service = VeteranVerification::Service.new @icn = icn end |
Instance Method Details
#decision_code_transform(decision_code_text) ⇒ Object
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/disability_compensation/providers/rated_disabilities/lighthouse_rated_disabilities_provider.rb', line 60 def decision_code_transform(decision_code_text) service_connected = decision_code_text&.downcase == 'Service Connected'.downcase || decision_code_text&.downcase == '1151 Granted'.downcase if service_connected 'SVCCONNCTED' else 'NOTSVCCON' end end |
#get_combined_disability_rating(lighthouse_client_id = nil, lighthouse_rsa_key_path = nil) ⇒ integer
Returns the combined disability rating.
19 20 21 22 |
# File 'lib/disability_compensation/providers/rated_disabilities/lighthouse_rated_disabilities_provider.rb', line 19 def (lighthouse_client_id = nil, lighthouse_rsa_key_path = nil) data = get_data(lighthouse_client_id, lighthouse_rsa_key_path) data.dig('data', 'attributes', 'combined_disability_rating') end |
#get_data(lighthouse_client_id = nil, lighthouse_rsa_key_path = nil, options = {}) ⇒ Object
36 37 38 |
# File 'lib/disability_compensation/providers/rated_disabilities/lighthouse_rated_disabilities_provider.rb', line 36 def get_data(lighthouse_client_id = nil, lighthouse_rsa_key_path = nil, = {}) @service.get_rated_disabilities(@icn, lighthouse_client_id, lighthouse_rsa_key_path, ) end |
#get_rated_disabilities(lighthouse_client_id = nil, lighthouse_rsa_key_path = nil, options = {}) ⇒ DisabilityCompensation::ApiProvider::RatedDisabilitiesResponse
Returns a list of individual disability ratings.
28 29 30 31 |
# File 'lib/disability_compensation/providers/rated_disabilities/lighthouse_rated_disabilities_provider.rb', line 28 def get_rated_disabilities(lighthouse_client_id = nil, lighthouse_rsa_key_path = nil, = {}) data = get_data(lighthouse_client_id, lighthouse_rsa_key_path, ) transform(data['data']['attributes']['individual_ratings']) end |
#transform(data) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/disability_compensation/providers/rated_disabilities/lighthouse_rated_disabilities_provider.rb', line 40 def transform(data) rated_disabilities = data.map do |rated_disability| DisabilityCompensation::ApiProvider::RatedDisability.new( name: rated_disability['diagnostic_text'], decision_code: decision_code_transform(rated_disability['decision']), decision_text: rated_disability['decision'], diagnostic_code: rated_disability['diagnostic_type_code'].to_i, hyphenated_diagnostic_code: rated_disability['hyph_diagnostic_type_code'].presence&.to_i, effective_date: rated_disability['effective_date'], rated_disability_id: rated_disability['disability_rating_id'], rating_decision_id: 0, rating_percentage: rated_disability['rating_percentage'], # TODO: figure out if this is important related_disability_date: DateTime.now ) end DisabilityCompensation::ApiProvider::RatedDisabilitiesResponse.new(rated_disabilities:) end |