Class: Form526Submission
Constant Summary
collapse
- FORM_526 =
'form526'
- FORM_526_UPLOADS =
'form526_uploads'
- FORM_4142 =
'form4142'
- FORM_0781 =
'form0781'
- FORM_8940 =
'form8940'
- FLASHES =
'flashes'
- BIRLS_KEY =
'va_eauth_birlsfilenumber'
- SUBMIT_FORM_526_JOB_CLASSES =
%w[SubmitForm526AllClaim SubmitForm526].freeze
- MAX_PENDING_TIME =
MAX_PENDING_TIME aligns with the farthest out expectation given in the LH BI docs, plus 1 week to accomodate for edge cases and our sidekiq jobs
3.weeks
- ZSF_DD_TAG_SERVICE =
'disability-application'
Form526ClaimFastTrackingConcern::CLAIM_REVIEW_BASE_CODES, Form526ClaimFastTrackingConcern::CLAIM_REVIEW_TYPES, Form526ClaimFastTrackingConcern::DOCUMENT_NAME_PREFIX, Form526ClaimFastTrackingConcern::DOCUMENT_NAME_SUFFIX, Form526ClaimFastTrackingConcern::EP_MERGE_BASE_CODES, Form526ClaimFastTrackingConcern::EP_MERGE_SPECIAL_ISSUE, Form526ClaimFastTrackingConcern::EP_MERGE_STATSD_KEY_PREFIX, Form526ClaimFastTrackingConcern::FLASHES_STATSD_KEY, Form526ClaimFastTrackingConcern::FLASH_PROTOTYPES, Form526ClaimFastTrackingConcern::MAX_CFI_STATSD_KEY_PREFIX, Form526ClaimFastTrackingConcern::OPEN_STATUSES, Form526ClaimFastTrackingConcern::PDF_FILENAME_REGEX, Form526ClaimFastTrackingConcern::RRD_CODE, Form526ClaimFastTrackingConcern::RRD_STATSD_KEY_PREFIX
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#a_submit_form_526_job_succeeded? ⇒ Boolean
-
#account ⇒ Object
-
#add_birls_ids(id_or_ids) ⇒ Object
this method is for queuing up BIRLS ids in the birls_ids_tried hash, and can also be used for initializing birls_ids_tried.
-
#all_other_jobs_succeeded_if_any? ⇒ Boolean
-
#auth_headers ⇒ Hash
-
#bdd? ⇒ Boolean
-
#birls_id ⇒ Object
-
#birls_id! ⇒ Object
-
#birls_id=(value) ⇒ Object
-
#birls_ids ⇒ Object
-
#birls_ids_that_havent_been_tried_yet ⇒ Object
-
#birls_ids_tried_hash ⇒ Object
-
#cleanup ⇒ Object
private
-
#conditionally_submit_form_4142 ⇒ Object
private
-
#duplicate? ⇒ Boolean
-
#enqueue_backup_submission(id) ⇒ Object
private
-
#failure_type? ⇒ Boolean
-
#find_user_account_with_icn(records, record_type) ⇒ Object
private
-
#form ⇒ Hash
form_json is memoized here so call invalidate_form_hash after updating form_json.
-
#form_content_valid? ⇒ Boolean
Synchronous access to Lighthouse API validation boolean for 526 submission Because this method hits an external API, there could be exceptions generated for non-200 response codes.
-
#form_to_json(item) ⇒ String
A 526 submission can include the 526 form submission, uploads, and ancillary items.
-
#format_creation_time_for_mailers ⇒ Object
-
#full_name ⇒ Hash
Checks against the User record first, and then resorts to checking the auth_headers for the name attributes if the User record doesn’t exist or contain the full name.
-
#get_first_name ⇒ Object
Note that the User record is cached in Redis – ‘User.redis_namespace_ttl`.
-
#get_past_submissions ⇒ Object
private
-
#get_user_verifications ⇒ Object
private
-
#handle_validation_error(e) ⇒ Object
private
-
#in_process? ⇒ Boolean
-
#invalidate_form_hash ⇒ Object
Call this method to invalidate the memoized @form_hash variable after updating form_json.
-
#jobs_succeeded? ⇒ Boolean
-
#last_remediation ⇒ Object
-
#lighthouse_service ⇒ Object
private
Setup the Lighthouse service for this user account.
-
#lighthouse_validation_errors ⇒ Object
Returns an Array of Hashes when response.status is 422 otherwise it’s an empty Array.
-
#mark_birls_id_as_tried(id = birls_id!, , timestamp_string: Time.zone.now.iso8601.to_s) ⇒ Object
-
#mark_birls_id_as_tried! ⇒ Object
-
#mock_lighthouse_response(status:, error: 'Unknown') ⇒ Object
private
-
#perform_ancillary_jobs(first_name) ⇒ String
Creates a batch for the ancillary jobs, sets up the callback, and adds the jobs to the batch if necessary.
-
#perform_ancillary_jobs_handler(_status, options) ⇒ Object
Called by Sidekiq::Batch as part of the Form 526 submission workflow The workflow batch success handler.
-
#personalization_parameters(first_name) ⇒ Object
-
#poll_form526_pdf ⇒ Object
private
-
#queue_central_mail_backup_submission_for_non_retryable_error!(e: nil) ⇒ Object
private
-
#remediated? ⇒ Boolean
-
#start ⇒ Object
Called when the DisabilityCompensation form controller is ready to hand off to the backend submission process.
-
#start_evss_submission_job ⇒ String
Kicks off a retryable 526 submit workflow.
-
#submit_flashes ⇒ Object
private
-
#submit_form_0781 ⇒ Object
private
-
#submit_form_4142 ⇒ Object
private
-
#submit_form_8940 ⇒ Object
private
-
#submit_uploads ⇒ Object
private
-
#submit_with_birls_id_that_hasnt_been_tried_yet!(extra_content_for_sentry: {}, silence_errors_and_log_to_sentry: false) ⇒ String, NilClass
Runs start_evss_submission_job but first looks to see if the veteran has BIRLS IDs that previous start attempts haven’t used before (if so, swaps one of those into auth_headers).
-
#success_type? ⇒ Boolean
-
#system_transaction_id ⇒ Object
used to track in APMs between systems such as Lighthouse example: can be used as a search parameter in Datadog TODO: follow-up in ticket #93563 to make this more robust, i.e.
-
#upload_bdd_instructions ⇒ Object
private
-
#veteran_email_address ⇒ Object
-
#workflow_complete_handler(_status, options) ⇒ Object
Called by Sidekiq::Batch as part of the Form 526 submission workflow Checks if all workflow steps were successful and if so marks it as complete.
wrap_with_logging
#add_ep_merge_special_issue!, #all_rated_disabilities, #cfi_checkbox_was_selected?, #claim_age_in_days, #classify_vagov_contentions, #conditionally_merge_ep, #conditionally_notify_mas, #diagnostic_codes, #disabilities, #disabilities_not_service_connected?, #ep_merge_feature_enabled?, #flashes, #format_contention_for_vro, #in_progress_form, #increase_disabilities, #log_and_halt_if_no_disabilities, #log_claim_level_metrics, #log_flashes, #log_max_cfi_metrics_on_submit, #max_rated_diagnostic_codes_from_ipf, #max_rated_disabilities_from_ipf, #notify_mas_all_claims_tracking, #open_claim_review?, #open_claims, #pending_eps?, #prepare_for_ep_merge!, #prepare_for_evss!, #read_metadata, #rrd_claim_processed?, #rrd_pdf_added_for_uploading?, #rrd_pdf_created?, #rrd_pdf_uploaded_to_s3?, #rrd_special_issue_set?, #rrd_status, #save_metadata, #send_post_evss_notifications!, #send_rrd_alert_email, #update_contention_classification_all!, #update_form_with_classification_codes
#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger, #set_sentry_metadata
descendants_using_encryption, lockbox_options, #timestamp_attributes_for_update_in_model, #valid?
Instance Attribute Details
54
|
# File 'app/models/form526_submission.rb', line 54
has_kms_key
|
#created_at ⇒ Timestamp
54
|
# File 'app/models/form526_submission.rb', line 54
has_kms_key
|
Returns encrypted form submission as JSON.
54
|
# File 'app/models/form526_submission.rb', line 54
has_kms_key
|
#id ⇒ Integer
Returns auto-increment primary key.
54
|
# File 'app/models/form526_submission.rb', line 54
has_kms_key
|
#lighthouse_validation_response ⇒ Object
Returns the value of attribute lighthouse_validation_response.
487
488
489
|
# File 'app/models/form526_submission.rb', line 487
def lighthouse_validation_response
@lighthouse_validation_response
end
|
#saved_claim_id ⇒ Integer
54
|
# File 'app/models/form526_submission.rb', line 54
has_kms_key
|
#updated_at ⇒ Timestamp
54
|
# File 'app/models/form526_submission.rb', line 54
has_kms_key
|
#user_uuid ⇒ String
Returns points to the user’s uuid from the identity provider.
54
|
# File 'app/models/form526_submission.rb', line 54
has_kms_key
|
#workflow_complete ⇒ Boolean
54
|
# File 'app/models/form526_submission.rb', line 54
has_kms_key
|
Instance Method Details
295
296
297
298
299
300
301
302
303
304
305
|
# File 'app/models/form526_submission.rb', line 295
def a_submit_form_526_job_succeeded?
submit_form_526_job_statuses = form526_job_statuses.where(job_class: SUBMIT_FORM_526_JOB_CLASSES).order(:updated_at)
submit_form_526_job_statuses.presence&.any?(&:success?)
ensure
successful = submit_form_526_job_statuses.where(status: 'success').load
warn = ->(message) { log_message_to_sentry(message, :warn, { form_526_submission_id: id }) }
warn.call 'There are multiple successful SubmitForm526 job statuses' if successful.size > 1
if successful.size == 1 && submit_form_526_job_statuses.last.unsuccessful?
warn.call "There is a successful SubmitForm526 job, but it's not the most recent SubmitForm526 job"
end
end
|
#account ⇒ Object
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
|
# File 'app/models/form526_submission.rb', line 458
def account
account = user_account
return account if account&.icn.present?
past_submissions = get_past_submissions
account = find_user_account_with_icn(past_submissions, 'past submissions')
return account if account.present? && account.icn.present?
user_verifications = get_user_verifications
account = find_user_account_with_icn(user_verifications, 'user verifications')
return account if account.present? && account.icn.present?
Account.lookup_by_user_uuid(user_uuid)
end
|
#add_birls_ids(id_or_ids) ⇒ Object
this method is for queuing up BIRLS ids in the birls_ids_tried hash, and can also be used for initializing birls_ids_tried. birls_ids_tried has this shape:
birls_id => [timestamp, timestamp, ...],
birls_id => [timestamp, timestamp, ...], # in practice, will be only 1 timestamp
...
where each timestamp notes when a submissison job (start) was started with that BIRLS id (birls_id_tried keeps track of which BIRLS id have been tried so far). add_birls_ids does not overwrite birls_ids_tried. example: > sub.birls_ids_tried = { ‘111’ => [‘2021-01-01T0000Z’] } > sub.add_birls_ids [‘111’, ‘222’, ‘333’] > pp sub.birls_ids_tried
{
'111' => ['2021-01-01T0000Z'], '222' => [], '333' => [] }
NOTE: ‘111’ was not cleared
228
229
230
231
232
233
234
235
|
# File 'app/models/form526_submission.rb', line 228
def add_birls_ids(id_or_ids)
ids = Array.wrap(id_or_ids).map { |id| id.is_a?(Symbol) ? id.to_s : id }
hash = birls_ids_tried_hash
ids.each { |id| hash[id] ||= [] }
self.birls_ids_tried = hash.to_json
self.multiple_birls = true if birls_ids.length > 1
ids
end
|
#all_other_jobs_succeeded_if_any? ⇒ Boolean
307
308
309
|
# File 'app/models/form526_submission.rb', line 307
def all_other_jobs_succeeded_if_any?
form526_job_statuses.where.not(job_class: SUBMIT_FORM_526_JOB_CLASSES).all?(&:success?)
end
|
Returns parsed auth headers.
202
203
204
|
# File 'app/models/form526_submission.rb', line 202
def
@auth_headers_hash ||= JSON.parse()
end
|
#bdd? ⇒ Boolean
361
362
363
|
# File 'app/models/form526_submission.rb', line 361
def bdd?
form.dig('form526', 'form526', 'bddQualified') || false
end
|
#birls_id ⇒ Object
268
269
270
|
# File 'app/models/form526_submission.rb', line 268
def birls_id
birls_id! if
end
|
#birls_id! ⇒ Object
264
265
266
|
# File 'app/models/form526_submission.rb', line 264
def birls_id!
[BIRLS_KEY]
end
|
#birls_id=(value) ⇒ Object
272
273
274
275
276
277
|
# File 'app/models/form526_submission.rb', line 272
def birls_id=(value)
= JSON.parse() || {}
[BIRLS_KEY] = value
self. = .to_json
@auth_headers_hash = nil end
|
#birls_ids ⇒ Object
237
238
239
|
# File 'app/models/form526_submission.rb', line 237
def birls_ids
[*birls_ids_tried_hash&.keys, birls_id].compact.uniq
end
|
#birls_ids_that_havent_been_tried_yet ⇒ Object
259
260
261
262
|
# File 'app/models/form526_submission.rb', line 259
def birls_ids_that_havent_been_tried_yet
add_birls_ids birls_id if birls_id.present?
birls_ids_tried_hash.select { |_id, timestamps| timestamps.blank? }.keys
end
|
#birls_ids_tried_hash ⇒ Object
241
242
243
|
# File 'app/models/form526_submission.rb', line 241
def birls_ids_tried_hash
birls_ids_tried.presence&.then { |json| JSON.parse json } || {}
end
|
479
480
481
482
483
484
485
|
# File 'app/models/form526_submission.rb', line 479
def conditionally_submit_form_4142
if Flipper.enabled?(:disability_compensation_production_tester, OpenStruct.new({ flipper_id: user_uuid }))
Rails.logger.info("submit_form_4142 call skipped for submission #{id}")
elsif form[FORM_4142].present?
submit_form_4142
end
end
|
#duplicate? ⇒ Boolean
434
435
436
|
# File 'app/models/form526_submission.rb', line 434
def duplicate?
last_remediation&.ignored_as_duplicate?
end
|
#enqueue_backup_submission(id) ⇒ Object
#failure_type? ⇒ Boolean
442
443
444
|
# File 'app/models/form526_submission.rb', line 442
def failure_type?
!success_type? && !in_process?
end
|
#find_user_account_with_icn(records, record_type) ⇒ Object
594
595
596
597
598
599
600
601
602
603
|
# File 'app/models/form526_submission.rb', line 594
def find_user_account_with_icn(records, record_type)
records.pluck(:user_account_id).uniq.each do |user_account_id|
user_account = UserAccount.find(user_account_id)
next if user_account&.icn.blank?
Rails.logger.info("ICN not found on submission #{id}, " \
"using ICN for user account #{user_account_id} instead (based on #{record_type})")
return user_account
end
end
|
form_json is memoized here so call invalidate_form_hash after updating form_json
179
180
181
|
# File 'app/models/form526_submission.rb', line 179
def form
@form_hash ||= JSON.parse(form_json)
end
|
#form_content_valid? ⇒ Boolean
Synchronous access to Lighthouse API validation boolean for 526 submission Because this method hits an external API, there could be exceptions generated for non-200 response codes.
If return is false, then the errors are expected to be in the lighthouse_validation_errors Array of Hashes.
NOTE: This is a synchronous access to an external API
so should not be used within a request/response workflow.
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
|
# File 'app/models/form526_submission.rb', line 395
def form_content_valid?
transform_service = EVSS::DisabilityCompensationForm::Form526ToLighthouseTransform.new
body = transform_service.transform(form['form526'])
@lighthouse_validation_response = lighthouse_service.validate526(body)
if lighthouse_validation_response&.status == 200
true
else
mock_lighthouse_response(status: lighthouse_validation_response&.status)
false
end
rescue => e
handle_validation_error(e)
false
end
|
A 526 submission can include the 526 form submission, uploads, and ancillary items. This method returns a single item as JSON
196
197
198
|
# File 'app/models/form526_submission.rb', line 196
def form_to_json(item)
form[item].to_json
end
|
379
380
381
382
|
# File 'app/models/form526_submission.rb', line 379
def format_creation_time_for_mailers
created_at.strftime('%B %-d, %Y %-l:%M %P %Z').sub(/([ap])m/, '\1.m.')
end
|
#full_name ⇒ Hash
Checks against the User record first, and then resorts to checking the auth_headers for the name attributes if the User record doesn’t exist or contain the full name
164
165
166
167
168
169
170
171
172
173
174
|
# File 'app/models/form526_submission.rb', line 164
def full_name
name_hash = User.find(user_uuid)&.full_name_normalized
return name_hash if name_hash&.[](:first).present?
{
first: &.dig('va_eauth_firstName')&.capitalize,
middle: nil,
last: &.dig('va_eauth_lastName')&.capitalize,
suffix: nil
}
end
|
#get_first_name ⇒ Object
Note that the User record is cached in Redis – ‘User.redis_namespace_ttl`
153
154
155
156
157
|
# File 'app/models/form526_submission.rb', line 153
def get_first_name
user = User.find(user_uuid)
user&.first_name&.upcase.presence ||
&.dig('va_eauth_firstName')&.upcase
end
|
#get_past_submissions ⇒ Object
605
606
607
|
# File 'app/models/form526_submission.rb', line 605
def get_past_submissions
Form526Submission.where(user_uuid:).where.not(user_account_id:)
end
|
#get_user_verifications ⇒ Object
609
610
611
612
613
614
615
616
|
# File 'app/models/form526_submission.rb', line 609
def get_user_verifications
UserVerification.where(idme_uuid: user_uuid)
.or(UserVerification.where(backing_idme_uuid: user_uuid))
.or(UserVerification.where(logingov_uuid: user_uuid))
.or(UserVerification.where(mhv_uuid: user_uuid))
.or(UserVerification.where(dslogon_uuid: user_uuid))
.where.not(user_account_id:)
end
|
#handle_validation_error(e) ⇒ Object
496
497
498
499
500
501
502
|
# File 'app/models/form526_submission.rb', line 496
def handle_validation_error(e)
errors = e.errors if e.respond_to?(:errors)
detail = errors&.dig(0, :detail)
status = errors&.dig(0, :status)
error_msg = "#{detail || e} -- #{e.backtrace[0]}"
mock_lighthouse_response(status:, error: error_msg)
end
|
#in_process? ⇒ Boolean
450
451
452
|
# File 'app/models/form526_submission.rb', line 450
def in_process?
self.class.in_process.exists?(id:)
end
|
186
187
188
|
# File 'app/models/form526_submission.rb', line 186
def invalidate_form_hash
remove_instance_variable(:@form_hash) if instance_variable_defined?(:@form_hash)
end
|
#jobs_succeeded? ⇒ Boolean
291
292
293
|
# File 'app/models/form526_submission.rb', line 291
def jobs_succeeded?
a_submit_form_526_job_succeeded? && all_other_jobs_succeeded_if_any?
end
|
454
455
456
|
# File 'app/models/form526_submission.rb', line 454
def last_remediation
form526_submission_remediations&.order(:created_at)&.last
end
|
#lighthouse_service ⇒ Object
Setup the Lighthouse service for this user account. Lighthouse calls the user_account.icn the “ID of Veteran”
492
493
494
|
# File 'app/models/form526_submission.rb', line 492
def lighthouse_service
BenefitsClaims::Service.new(account.icn)
end
|
#lighthouse_validation_errors ⇒ Object
Returns an Array of Hashes when response.status is 422 otherwise it’s an empty Array.
The Array#empty? is true when there are no errors A Hash entry looks like this … {
"title": "Unprocessable entity",
"detail": "The property / did not contain the required key serviceInformation",
"status": "422",
"source": {
"pointer": "data/attributes/"
}
}
426
427
428
429
430
431
432
|
# File 'app/models/form526_submission.rb', line 426
def lighthouse_validation_errors
if lighthouse_validation_response&.status == 200
[]
else
lighthouse_validation_response.body['errors']
end
end
|
#mark_birls_id_as_tried(id = birls_id!, , timestamp_string: Time.zone.now.iso8601.to_s) ⇒ Object
245
246
247
248
249
250
251
|
# File 'app/models/form526_submission.rb', line 245
def mark_birls_id_as_tried(id = birls_id!, timestamp_string: Time.zone.now.iso8601.to_s)
ids = add_birls_ids id
hash = birls_ids_tried_hash
hash[ids.first] << timestamp_string
self.birls_ids_tried = hash.to_json
timestamp_string
end
|
#mark_birls_id_as_tried! ⇒ Object
253
254
255
256
257
|
# File 'app/models/form526_submission.rb', line 253
def mark_birls_id_as_tried!(*, **)
timestamp_string = mark_birls_id_as_tried(*, **)
save!
timestamp_string
end
|
#mock_lighthouse_response(status:, error: 'Unknown') ⇒ Object
504
505
506
507
508
509
510
511
512
513
514
515
516
517
|
# File 'app/models/form526_submission.rb', line 504
def mock_lighthouse_response(status:, error: 'Unknown')
response_struct = Struct.new(:status, :body)
mock_response = response_struct.new(status || 609, nil)
mock_response.body = {
'errors' => [
{
'title' => "Response Status Code '#{mock_response.status}' - #{error}"
}
]
}
@lighthouse_validation_response = mock_response
end
|
Creates a batch for the ancillary jobs, sets up the callback, and adds the jobs to the batch if necessary
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
|
# File 'app/models/form526_submission.rb', line 316
def perform_ancillary_jobs(first_name)
workflow_batch = Sidekiq::Batch.new
workflow_batch.on(
:success,
'Form526Submission#workflow_complete_handler',
'submission_id' => id,
'first_name' => first_name
)
workflow_batch.jobs do
submit_uploads if form[FORM_526_UPLOADS].present?
conditionally_submit_form_4142
submit_form_0781 if form[FORM_0781].present?
submit_form_8940 if form[FORM_8940].present?
upload_bdd_instructions if bdd?
submit_flashes if form[FLASHES].present?
poll_form526_pdf if Flipper.enabled?(:disability_526_toxic_exposure_document_upload_polling,
OpenStruct.new({ flipper_id: user_uuid }))
cleanup
end
end
|
Called by Sidekiq::Batch as part of the Form 526 submission workflow The workflow batch success handler
285
286
287
288
289
|
# File 'app/models/form526_submission.rb', line 285
def perform_ancillary_jobs_handler(_status, options)
submission = Form526Submission.find(options['submission_id'])
submission.perform_ancillary_jobs(options['first_name']) if submission.jobs_succeeded?
end
|
#personalization_parameters(first_name) ⇒ Object
365
366
367
368
369
370
371
372
373
|
# File 'app/models/form526_submission.rb', line 365
def personalization_parameters(first_name)
{
'email' => form['form526']['form526']['veteran']['emailAddress'],
'submitted_claim_id' => submitted_claim_id,
'date_submitted' => created_at.strftime('%B %-d, %Y %-l:%M %P %Z').sub(/([ap])m/, '\1.m.'),
'date_received' => Time.now.utc.strftime('%B %-d, %Y %-l:%M %P %Z').sub(/([ap])m/, '\1.m.'),
'first_name' => first_name
}
end
|
582
583
584
585
586
587
588
|
# File 'app/models/form526_submission.rb', line 582
def poll_form526_pdf
if saved_claim.parsed_form['startedFormVersion'].present? && submitted_claim_id
Lighthouse::PollForm526Pdf.perform_async(id)
end
end
|
#queue_central_mail_backup_submission_for_non_retryable_error!(e: nil) ⇒ Object
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
|
# File 'app/models/form526_submission.rb', line 519
def queue_central_mail_backup_submission_for_non_retryable_error!(e: nil)
backup_job_jid = nil
flipper_sym = :form526_backup_submission_temp_killswitch
send_backup_submission = Settings.form526_backup.enabled &&
Flipper.enabled?(flipper_sym) &&
submitted_claim_id.nil? &&
backup_submitted_claim_id.nil?
backup_job_jid = enqueue_backup_submission(id) if send_backup_submission
log_message = {
submission_id: id
}
log_message['error_class'] = e.class unless e.nil?
log_message['error_message'] = e.message unless e.nil?
log_message['backup_job_id'] = backup_job_jid unless backup_job_jid.nil?
::Rails.logger.error('Form526 Exhausted or Errored (non-retryable-error-path)', log_message)
end
|
438
439
440
|
# File 'app/models/form526_submission.rb', line 438
def remediated?
last_remediation&.success || false
end
|
#start ⇒ Object
Called when the DisabilityCompensation form controller is ready to hand off to the backend submission process. Currently this passes directly to the retryable EVSS workflow, but if any one-time setup or workflow redirection (e.g. for Claims Fast-Tracking) needs to happen, it should go here and call start_evss_submission_job when done.
94
95
96
97
|
# File 'app/models/form526_submission.rb', line 94
def start
log_max_cfi_metrics_on_submit
start_evss_submission_job
end
|
#start_evss_submission_job ⇒ String
Kicks off a retryable 526 submit workflow. The first step in a submission workflow is to submit an increase only or all claims form. Once the first job succeeds the batch will callback and run one (cleanup job) or more ancillary jobs such as uploading supporting evidence or submitting ancillary forms.
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
# File 'app/models/form526_submission.rb', line 105
def start_evss_submission_job
workflow_batch = Sidekiq::Batch.new
workflow_batch.on(
:success,
'Form526Submission#perform_ancillary_jobs_handler',
'submission_id' => id,
'first_name' => get_first_name
)
job_ids = workflow_batch.jobs do
EVSS::DisabilityCompensationForm::SubmitForm526AllClaim.perform_async(id)
end
job_ids.first
end
|
#submit_flashes ⇒ Object
575
576
577
578
579
580
|
# File 'app/models/form526_submission.rb', line 575
def submit_flashes
user = User.find(user_uuid)
BGS::FlashUpdater.perform_async(id) if user && Flipper.enabled?(:disability_compensation_flashes, user)
end
|
#submit_with_birls_id_that_hasnt_been_tried_yet!(extra_content_for_sentry: {}, silence_errors_and_log_to_sentry: false) ⇒ String, NilClass
Runs start_evss_submission_job but first looks to see if the veteran has BIRLS IDs that previous start attempts haven’t used before (if so, swaps one of those into auth_headers). If all BIRLS IDs for a veteran have been tried, does nothing and returns nil. Note: this assumes that the current BIRLS ID has been used (that ‘start` has been attempted once).
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
# File 'app/models/form526_submission.rb', line 129
def submit_with_birls_id_that_hasnt_been_tried_yet!(
extra_content_for_sentry: {},
silence_errors_and_log_to_sentry: false
)
untried_birls_id = birls_ids_that_havent_been_tried_yet.first
return unless untried_birls_id
self.birls_id = untried_birls_id
save!
start_evss_submission_job
rescue => e
raise unless silence_errors_and_log_to_sentry
log_exception_to_sentry e,
end
|
#success_type? ⇒ Boolean
446
447
448
|
# File 'app/models/form526_submission.rb', line 446
def success_type?
self.class.success_type.exists?(id:)
end
|
#system_transaction_id ⇒ Object
used to track in APMs between systems such as Lighthouse example: can be used as a search parameter in Datadog TODO: follow-up in ticket #93563 to make this more robust, i.e. attempts of jobs, etc.
85
86
87
88
|
# File 'app/models/form526_submission.rb', line 85
def system_transaction_id
service_provider = saved_claim.parsed_form['startedFormVersion'].present? ? 'lighthouse' : 'evss'
"Form526Submission_#{id}, user_uuid: #{user_uuid}, service_provider: #{service_provider}"
end
|
#upload_bdd_instructions ⇒ Object
#veteran_email_address ⇒ Object
375
376
377
|
# File 'app/models/form526_submission.rb', line 375
def veteran_email_address
form.dig('form526', 'form526', 'veteran', 'emailAddress')
end
|
#workflow_complete_handler(_status, options) ⇒ Object
Called by Sidekiq::Batch as part of the Form 526 submission workflow Checks if all workflow steps were successful and if so marks it as complete.
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
|
# File 'app/models/form526_submission.rb', line 343
def workflow_complete_handler(_status, options)
submission = Form526Submission.find(options['submission_id'])
params = submission.personalization_parameters(options['first_name'])
if submission.jobs_succeeded?
unless Flipper.enabled?(:disability_526_call_received_email_from_polling,
OpenStruct.new({ flipper_id: user_uuid }))
Rails.logger.info("Form526ConfirmationEmailJob called for user: #{user_uuid},
submission: #{submission.id} from form526_submission")
Form526ConfirmationEmailJob.perform_async(params)
end
submission.workflow_complete = true
submission.save
else
Form526SubmissionFailedEmailJob.perform_async(params)
end
end
|