Class: V0::DisabilityCompensationFormsController
Constant Summary
ApplicationController::VERSION_STATUS
SignIn::Authentication::BEARER_PATTERN
ExceptionHandling::SKIP_SENTRY_EXCEPTION_TYPES
Instance Attribute Summary
#current_user
Instance Method Summary
collapse
#clear_saved_form, #cors_preflight, #pagination_params, #render_job_id, #routing_error, #set_csrf_header
Methods included from Traceable
#set_trace_tags
#set_tags_and_extra_context, #tags_context, #user_context
#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger, #set_sentry_metadata
#append_info_to_payload
#access_token, #access_token_authenticate, #authenticate, #authenticate_access_token, #bearer_token, #cookie_access_token, #handle_authenticate_error, #load_user, #load_user_object, #scrub_bearer_token, #validate_request_ip
Methods included from Headers
#set_app_info_headers
#render_errors, #report_mapped_exception, #report_original_exception, #skip_sentry_exception?, #skip_sentry_exception_types
#authenticate, #clear_session, #extend_session!, #load_user, #log_sso_info, #render_unauthorized, #reset_session, #set_api_cookie!, #set_current_user, #set_session_expiration_header, #set_session_object, #sign_in_service_exp_time, #sign_in_service_session, #sso_cookie_content, #sso_logging_info, #validate_inbound_login_params, #validate_session
#authenticate, #validate_audience!
Instance Method Details
#auth_rating_info ⇒ Object
104
105
106
107
|
# File 'app/controllers/v0/disability_compensation_forms_controller.rb', line 104
def auth_rating_info
api = lighthouse? ? :lighthouse : :evss
authorize(api, :rating_info_access?)
end
|
#create_submission(saved_claim) ⇒ Object
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
# File 'app/controllers/v0/disability_compensation_forms_controller.rb', line 117
def create_submission(saved_claim)
Rails.logger.info('Creating 526 submission', user_uuid: @current_user&.uuid, saved_claim_id: saved_claim&.id)
submission = Form526Submission.new(
user_uuid: @current_user.uuid,
user_account: @current_user.user_account,
saved_claim_id: saved_claim.id,
auth_headers_json: .to_json,
form_json: saved_claim.to_submission_data(@current_user),
submit_endpoint: includes_toxic_exposure? ? 'claims_api' : 'evss'
) { |sub| sub.add_birls_ids @current_user.birls_id }
if missing_disabilities?(submission)
raise Common::Exceptions::UnprocessableEntity.new(
detail: 'no new or increased disabilities were submitted', source: 'DisabilityCompensationFormsController'
)
end
submission.save! && submission
rescue PG::NotNullViolation => e
Rails.logger.error(
'Creating 526 submission: PG::NotNullViolation', user_uuid: @current_user&.uuid, saved_claim_id: saved_claim&.id
)
raise e
end
|
#form_content ⇒ Object
109
110
111
|
# File 'app/controllers/v0/disability_compensation_forms_controller.rb', line 109
def form_content
@form_content ||= JSON.parse(request.body.string)
end
|
#includes_toxic_exposure? ⇒ Boolean
164
165
166
167
|
# File 'app/controllers/v0/disability_compensation_forms_controller.rb', line 164
def includes_toxic_exposure?
form_content['form526']['startedFormVersion']
end
|
#lighthouse? ⇒ Boolean
113
114
115
|
# File 'app/controllers/v0/disability_compensation_forms_controller.rb', line 113
def lighthouse?
Flipper.enabled?(:profile_lighthouse_rating_info, @current_user)
end
|
#log_failure(claim) ⇒ Object
142
143
144
145
|
# File 'app/controllers/v0/disability_compensation_forms_controller.rb', line 142
def log_failure(claim)
StatsD.increment("#{stats_key}.failure")
raise Common::Exceptions::ValidationErrors, claim
end
|
#log_success(claim) ⇒ Object
147
148
149
150
|
# File 'app/controllers/v0/disability_compensation_forms_controller.rb', line 147
def log_success(claim)
StatsD.increment("#{stats_key}.success")
Rails.logger.info "ClaimID=#{claim.confirmation_number} Form=#{claim.class::FORM}"
end
|
#missing_disabilities?(submission) ⇒ Boolean
169
170
171
172
173
174
175
176
177
178
|
# File 'app/controllers/v0/disability_compensation_forms_controller.rb', line 169
def missing_disabilities?(submission)
if submission.form['form526']['form526']['disabilities'].none?
StatsD.increment("#{stats_key}.failure")
Rails.logger.error(
'Creating 526 submission: no new or increased disabilities were submitted', user_uuid: @current_user&.uuid
)
return true
end
false
end
|
#rated_disabilities ⇒ Object
#rating_info ⇒ Object
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
# File 'app/controllers/v0/disability_compensation_forms_controller.rb', line 86
def rating_info
if lighthouse?
service = LighthouseRatedDisabilitiesProvider.new(@current_user.icn)
disability_rating = service.get_combined_disability_rating
rating_info = { user_percent_of_disability: disability_rating }
render json: LighthouseRatingInfoSerializer.new(rating_info)
else
rating_info_service = EVSS::CommonService.new()
response = rating_info_service.get_rating_info
render json: RatingInfoSerializer.new(response)
end
end
|
#separation_locations ⇒ Object
#stats_key ⇒ Object
160
161
162
|
# File 'app/controllers/v0/disability_compensation_forms_controller.rb', line 160
def stats_key
'api.disability_compensation'
end
|
#submission_status ⇒ Object
#submit_all_claim ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'app/controllers/v0/disability_compensation_forms_controller.rb', line 55
def submit_all_claim
temp_separation_location_fix if Flipper.enabled?(:disability_compensation_temp_separation_location_code_string,
@current_user)
saved_claim = SavedClaim::DisabilityCompensation::Form526AllClaim.from_hash(form_content)
saved_claim.save ? log_success(saved_claim) : log_failure(saved_claim)
submission = create_submission(saved_claim)
jid = 0
if Flipper.enabled?(:disability_compensation_prevent_submission_job, @current_user)
Rails.logger.info("Submission ID: #{submission.id} prevented from sending to third party service.")
else
jid = submission.start
end
render json: { data: { attributes: { job_id: jid } } },
status: :ok
end
|
#suggested_conditions ⇒ Object
#temp_separation_location_fix ⇒ Object
TEMPORARY Turn separation location into string 11/18/2024 BRD EVSS -> Lighthouse migration caused separation location to turn into an integer, while SavedClaim (vets-json-schema) is expecting a string
184
185
186
187
188
189
190
191
192
193
|
# File 'app/controllers/v0/disability_compensation_forms_controller.rb', line 184
def temp_separation_location_fix
if form_content.is_a?(Hash) && form_content['form526'].is_a?(Hash)
separation_location_code = form_content.dig('form526', 'serviceInformation', 'separationLocation',
'separationLocationCode')
unless separation_location_code.nil?
form_content['form526']['serviceInformation']['separationLocation']['separationLocationCode'] =
separation_location_code.to_s
end
end
end
|
#validate_name_part ⇒ Object
152
153
154
|
# File 'app/controllers/v0/disability_compensation_forms_controller.rb', line 152
def validate_name_part
raise Common::Exceptions::ParameterMissing, 'name_part' if params[:name_part].blank?
end
|