Class: DecisionReview::Form4142Submit

Inherits:
Object
  • Object
show all
Includes:
DecisionReviewV1::Appeals::Helpers, Sidekiq::Job
Defined in:
app/sidekiq/decision_review/form4142_submit.rb

Constant Summary collapse

STATSD_KEY_PREFIX =
'worker.decision_review.form4142_submit'

Constants included from DecisionReviewV1::Appeals::Helpers

DecisionReviewV1::Appeals::Helpers::DR_LOCKBOX

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DecisionReviewV1::Appeals::Helpers

#create_supplemental_claims_headers, #get_and_rejigger_required_info, #middle_initial, #payload_encrypted_string

Methods included from DecisionReviewV1::Appeals::LoggingUtils

#benchmark?, #benchmark_to_log_data_hash, #extract_uuid_from_central_mail_message, #log_formatted, #parse_form412_response_to_log_msg, #parse_lighthouse_response_to_log_msg, #run_and_benchmark_if_enabled

Class Method Details

.record_email_send_failure(submission, e) ⇒ Object (private)



108
109
110
111
112
113
114
115
# File 'app/sidekiq/decision_review/form4142_submit.rb', line 108

def self.record_email_send_failure(submission, e)
  appeal_type = submission.type_of_appeal
  params = { submitted_appeal_uuid: submission.,
             appeal_type:,
             message: e.message }
  Rails.logger.error('DecisionReview::Form4142Submit retries exhausted email error', params)
  StatsD.increment("#{STATSD_KEY_PREFIX}.retries_exhausted.email_error", tags: ["appeal_type:#{appeal_type}"])
end

.record_email_send_successful(submission, notification_id) ⇒ Object (private)



94
95
96
97
98
99
100
101
102
103
104
105
# File 'app/sidekiq/decision_review/form4142_submit.rb', line 94

def self.record_email_send_successful(submission, notification_id)
  appeal_type = submission.type_of_appeal
  params = { submitted_appeal_uuid: submission.,
             appeal_type:,
             notification_id: }
  Rails.logger.info('DecisionReview::Form4142Submit retries exhausted email queued', params)
  StatsD.increment("#{STATSD_KEY_PREFIX}.retries_exhausted.email_queued")

  tags = ["service:#{DecisionReviewV1::APPEAL_TYPE_TO_SERVICE_MAP[appeal_type]}",
          'function: secondary form submission to Lighthouse']
  StatsD.increment('silent_failure_avoided_no_confirmation', tags:)
end

.send_notification_email(submission) ⇒ Object (private)



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'app/sidekiq/decision_review/form4142_submit.rb', line 77

def self.send_notification_email(submission)
  appeal_type = submission.type_of_appeal
  created_at = submission.created_at
  reference = "#{appeal_type}-secondary_form-#{submission.}"

  email_address = submission.current_email_address
  template_id = DecisionReviewV1::SECONDARY_FORM_TEMPLATE_ID
  personalisation = {
    first_name: submission.get_mpi_profile.given_names[0],
    date_submitted: created_at.strftime('%B %d, %Y')
  }

  service = ::VaNotify::Service.new(Settings.vanotify.services.benefits_decision_review.api_key)
  service.send_email({ email_address:, template_id:, personalisation:, reference: })
end

Instance Method Details

#decision_review_serviceObject (private)



73
74
75
# File 'app/sidekiq/decision_review/form4142_submit.rb', line 73

def decision_review_service
  DecisionReviewV1::Service.new
end

#decrypt_form(encrypted_payload) ⇒ Object



47
48
49
# File 'app/sidekiq/decision_review/form4142_submit.rb', line 47

def decrypt_form(encrypted_payload)
  JSON.parse(DecisionReviewV1::Appeals::Helpers::DR_LOCKBOX.decrypt(encrypted_payload))
end

#perform(appeal_submission_id, encrypted_payload, submitted_appeal_uuid) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'app/sidekiq/decision_review/form4142_submit.rb', line 51

def perform(appeal_submission_id, encrypted_payload, )
  rejiggered_payload = decrypt_form(encrypted_payload)
  decision_review_service.process_form4142_submission(appeal_submission_id:, rejiggered_payload:)

  StatsD.increment("#{STATSD_KEY_PREFIX}.success")
rescue => e
  StatsD.increment("#{STATSD_KEY_PREFIX}.error")
  ::Rails.logger.error({
                         error_message: e.message,
                         form_id: DecisionReviewV1::FORM4142_ID,
                         parent_form_id: DecisionReviewV1::SUPP_CLAIM_FORM_ID,
                         message: 'Supplemental Claim Form4142 Queued Job Errored',
                         appeal_submission_id:,
                         lighthouse_submission: {
                           id: 
                         }
                       })
  raise e
end