Class: HCA::EzrSubmissionJob

Inherits:
Object
  • Object
show all
Extended by:
SentryLogging
Includes:
Sidekiq::Job
Defined in:
app/sidekiq/hca/ezr_submission_job.rb

Constant Summary collapse

VALIDATION_ERROR =
HCA::SOAPParser::ValidationError
STATSD_KEY_PREFIX =
'api.1010ezr'
DD_ZSF_TAGS =
[
  'service:healthcare-application',
  'function: 10-10EZR async form submission'
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SentryLogging

log_exception_to_sentry, log_message_to_sentry, non_nil_hash?, normalize_level, rails_logger, set_sentry_metadata

Class Method Details

.decrypt_form(encrypted_form) ⇒ Object



43
44
45
# File 'app/sidekiq/hca/ezr_submission_job.rb', line 43

def self.decrypt_form(encrypted_form)
  JSON.parse(HealthCareApplication::LOCKBOX.decrypt(encrypted_form))
end

.send_failure_email(parsed_form) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'app/sidekiq/hca/ezr_submission_job.rb', line 47

def self.send_failure_email(parsed_form)
  email = parsed_form['email']
  return if email.blank?

  first_name = parsed_form.dig('veteranFullName', 'first')
  template_id = Settings.vanotify.services.health_apps_1010.template_id.form1010_ezr_failure_email
  api_key = Settings.vanotify.services.health_apps_1010.api_key
  salutation = first_name ? "Dear #{first_name}," : ''

  VANotify::EmailJob.perform_async(
    email,
    template_id,
    { 'salutation' => salutation },
    api_key
  )
  StatsD.increment("#{STATSD_KEY_PREFIX}.submission_failure_email_sent")
  StatsD.increment('silent_failure_avoided_no_confirmation', tags: DD_ZSF_TAGS)
end

Instance Method Details

#perform(encrypted_form, user_uuid) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
# File 'app/sidekiq/hca/ezr_submission_job.rb', line 66

def perform(encrypted_form, user_uuid)
  user = User.find(user_uuid)
  parsed_form = self.class.decrypt_form(encrypted_form)

  Form1010Ezr::Service.new(user).submit_sync(parsed_form)
rescue VALIDATION_ERROR => e
  Form1010Ezr::Service.new(nil).log_submission_failure(parsed_form)
  self.class.log_exception_to_sentry(e)
rescue
  StatsD.increment("#{STATSD_KEY_PREFIX}.async.retries")
  raise
end