Skip to content

Commit

Permalink
Merge branch 'master' into ip/1429-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
ianperera authored Dec 19, 2024
2 parents 508c86a + 862c2f7 commit 4442423
Show file tree
Hide file tree
Showing 28 changed files with 2,133 additions and 529 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ app/controllers/v0/search_controller.rb @department-of-veterans-affairs/va-api-e
app/controllers/v0/search_typeahead_controller.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/controllers/v0/sign_in_controller.rb @department-of-veterans-affairs/octo-identity
app/controllers/v0/terms_of_use_agreements_controller.rb @department-of-veterans-affairs/octo-identity
app/controllers/v0/test_account_user_emails_controller.rb @department-of-veterans-affairs/octo-identity
app/controllers/v0/trackings_controller.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/qa-standards @department-of-veterans-affairs/backend-review-group
app/controllers/v0/triage_teams_controller.rb @department-of-veterans-affairs/vfs-mhv-secure-messaging @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/controllers/v0/upload_supporting_evidences_controller.rb @department-of-veterans-affairs/Disability-Experience @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
Expand Down Expand Up @@ -1733,6 +1734,7 @@ spec/requests/v0/caregivers_assistance_claims_spec.rb @department-of-veterans-af
spec/requests/v0/claim_documents_spec.rb @department-of-veterans-affairs/Disability-Experience @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/requests/v0/debts_spec.rb @department-of-veterans-affairs/vsa-debt-resolution @department-of-veterans-affairs/backend-review-group
spec/requests/v0/disability_compensation_form_spec.rb @department-of-veterans-affairs/Disability-Experience @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/requests/v0/test_account_user_emails_spec.rb @department-of-veterans-affairs/octo-identity
spec/requests/v1/higher_level_reviews @department-of-veterans-affairs/benefits-decision-reviews-be @department-of-veterans-affairs/backend-review-group
spec/requests/v1/notice_of_disagreements @department-of-veterans-affairs/benefits-decision-reviews-be @department-of-veterans-affairs/backend-review-group
spec/requests/v1/supplemental_claims @department-of-veterans-affairs/benefits-decision-reviews-be @department-of-veterans-affairs/backend-review-group
Expand Down
4 changes: 1 addition & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -705,11 +705,9 @@ GEM
nio4r (2.7.4-java)
nkf (0.2.0)
nkf (0.2.0-java)
nokogiri (1.16.8)
nokogiri (1.17.2)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
nokogiri (1.16.8-java)
racc (~> 1.4)
nori (2.7.1)
bigdecimal
notiffany (0.1.3)
Expand Down
26 changes: 26 additions & 0 deletions app/controllers/v0/test_account_user_emails_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# frozen_string_literal: true

module V0
class TestAccountUserEmailsController < ApplicationController
service_tag 'identity'
skip_before_action :authenticate

NAMESPACE = 'test_account_user_email'
TTL = 2_592_000

def create
email_redis_key = SecureRandom.uuid
Rails.cache.write(email_redis_key, create_params, namespace: NAMESPACE, expires_in: TTL)

Rails.logger.info("[V0][TestAccountUserEmailsController] create, key:#{email_redis_key}")

render json: { test_account_user_email_uuid: email_redis_key }, status: :created
rescue
render json: { errors: 'invalid params' }, status: :bad_request
end

def create_params
params.require(:email)
end
end
end
31 changes: 20 additions & 11 deletions app/sidekiq/evss/disability_compensation_form/submit_form0781.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ class SubmitForm0781 < Job

FORM_ID_0781 = '21-0781' # form id for PTSD
FORM_ID_0781A = '21-0781a' # form id for PTSD Secondary to Personal Assault
FORM_ID_0781V2 = '21-0781V2' # form id for Mental Health Disorder(s) Due to In-Service Traumatic Event(s)

FORMS_METADATA = {
FORM_ID_0781 => { docType: 'L228' },
FORM_ID_0781A => { docType: 'L229' }
FORM_ID_0781A => { docType: 'L229' },
FORM_ID_0781V2 => { docType: 'L228' }
}.freeze

STATSD_KEY_PREFIX = 'worker.evss.submit_form0781'
Expand Down Expand Up @@ -145,12 +147,17 @@ def get_docs(submission_id, uuid)
@submission = Form526Submission.find_by(id: submission_id)

file_type_and_file_objs = []
{ 'form0781' => FORM_ID_0781, 'form0781a' => FORM_ID_0781A }.each do |form_type_key, actual_form_types|
if parsed_forms[form_type_key].present?
{
'form0781' => FORM_ID_0781,
'form0781a' => FORM_ID_0781A,
'form0781v2' => FORM_ID_0781V2
}.each do |form_type_key, actual_form_types|
form_content = parsed_forms[form_type_key]

if form_content.present?
file_type_and_file_objs << {
type: actual_form_types,
file: process_0781(uuid, actual_form_types, parsed_forms[form_type_key],
upload: false)
file: process_0781(uuid, actual_form_types, form_content, upload: false)
}
end
end
Expand All @@ -172,12 +179,14 @@ def perform(submission_id)
super(submission_id)

with_tracking('Form0781 Submission', submission.saved_claim_id, submission.id) do
# process 0781 and 0781a
if parsed_forms['form0781'].present?
process_0781(submission.submitted_claim_id, FORM_ID_0781, parsed_forms['form0781'])
end
if parsed_forms['form0781a'].present?
process_0781(submission.submitted_claim_id, FORM_ID_0781A, parsed_forms['form0781a'])
# process 0781, 0781a and 0781v2
{
'form0781' => FORM_ID_0781,
'form0781a' => FORM_ID_0781A,
'form0781v2' => FORM_ID_0781V2
}.each do |form_key, form_id|
form_content = parsed_forms[form_key]
process_0781(submission.submitted_claim_id, form_id, form_content) if form_content.present?
end
end
rescue => e
Expand Down
66 changes: 43 additions & 23 deletions app/sidekiq/form1010cg/submission_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,20 @@
module Form1010cg
class SubmissionJob
STATSD_KEY_PREFIX = "#{Form1010cg::Auditor::STATSD_KEY_PREFIX}.async.".freeze

DD_ZSF_TAGS = [
'caregiver-application',
'service:caregiver-application',
'function: 10-10CG async form submission'
].freeze

CALLBACK_METADATA = {
callback_metadata: {
notification_type: 'error',
form_number: '10-10CG',
statsd_tags: DD_ZSF_TAGS
}
}.freeze

include Sidekiq::Job
include Sidekiq::MonitoredWorker
include SentryLogging
Expand All @@ -19,7 +29,6 @@ class SubmissionJob

sidekiq_retries_exhausted do |msg, _e|
StatsD.increment("#{STATSD_KEY_PREFIX}failed_no_retries_left", tags: ["claim_id:#{msg['args'][0]}"])
StatsD.increment('silent_failure_avoided_no_confirmation', tags: DD_ZSF_TAGS)

claim = SavedClaim::CaregiversAssistanceClaim.find(msg['args'][0])
send_failure_email(claim)
Expand Down Expand Up @@ -49,8 +58,6 @@ def perform(claim_id)
end
rescue CARMA::Client::MuleSoftClient::RecordParseError
StatsD.increment("#{STATSD_KEY_PREFIX}record_parse_error", tags: ["claim_id:#{claim_id}"])
StatsD.increment('silent_failure_avoided_no_confirmation', tags: DD_ZSF_TAGS)

self.class.send_failure_email(claim)
rescue => e
log_exception_to_sentry(e)
Expand All @@ -59,25 +66,38 @@ def perform(claim_id)
raise
end

def self.send_failure_email(claim)
return unless Flipper.enabled?(:caregiver_use_va_notify_on_submission_failure)
return unless claim.parsed_form.dig('veteran', 'email')

parsed_form = claim.parsed_form
first_name = parsed_form.dig('veteran', 'fullName', 'first')
email = parsed_form.dig('veteran', 'email')
template_id = Settings.vanotify.services.health_apps_1010.template_id.form1010_cg_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")
class << self
def send_failure_email(claim)
unless can_send_failure_email?(claim)
StatsD.increment('silent_failure', tags: DD_ZSF_TAGS)
return
end

parsed_form = claim.parsed_form
first_name = parsed_form.dig('veteran', 'fullName', 'first')
email = parsed_form.dig('veteran', 'email')
template_id = Settings.vanotify.services.health_apps_1010.template_id.form1010_cg_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,
CALLBACK_METADATA
)

StatsD.increment("#{STATSD_KEY_PREFIX}submission_failure_email_sent")
end

private

def can_send_failure_email?(claim)
Flipper.enabled?(:caregiver_use_va_notify_on_submission_failure) && claim.parsed_form.dig(
'veteran', 'email'
)
end
end
end
end
15 changes: 10 additions & 5 deletions app/sidekiq/form526_submission_failure_email_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,16 @@ class Form526SubmissionFailureEmailJob
'form4142' => 'VA Form 21-4142',
'form0781' => 'VA Form 21-0781',
'form0781a' => 'VA Form 21-0781a',
'form0781v2' => 'VA Form 21-0781',
'form8940' => 'VA Form 21-8940'
}.freeze
FORM_KEYS = {
'form4142' => 'form4142',
'form0781' => 'form0781.form0781',
'form0781a' => 'form0781.form0781a',
'form0781v2' => 'form0781.form0781v2',
'form8940' => 'form8940'
}.freeze

# retry for 2d 1h 47m 12s
# https://github.com/sidekiq/sidekiq/wiki/Error-Handling
Expand Down Expand Up @@ -86,11 +94,8 @@ def send_email
end

def list_forms_submitted
[].tap do |forms|
forms << FORM_DESCRIPTIONS['form4142'] if form['form4142'].present?
forms << FORM_DESCRIPTIONS['form0781'] if form['form0781'].present?
forms << FORM_DESCRIPTIONS['form0781a'] if form.dig('form0781', 'form0781a').present?
forms << FORM_DESCRIPTIONS['form8940'] if form['form8940'].present?
FORM_KEYS.each_with_object([]) do |(key, path), forms|
forms << FORM_DESCRIPTIONS[key] if form.dig(*path.split('.')).present?
end
end

Expand Down
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@
resource :mhv_user_account, only: [:show], controller: 'user/mhv_user_accounts'
end

resource :test_account_user_email, only: [:create]

resource :veteran_onboarding, only: %i[show update]

resource :education_benefits_claims, only: %i[create show] do
Expand Down
52 changes: 39 additions & 13 deletions lib/evss/disability_compensation_form/form0781.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def initialize(user, form_content)
@user = user
@phone_email = form_content.dig('form526', 'phoneAndEmail')
@form_content = form_content.dig('form526', 'form0781')
@sync_modern_0781_flow = form_content.dig('form526', 'syncModern0781Flow')
@translated_forms = {}
end

Expand All @@ -22,23 +23,52 @@ def initialize(user, form_content)
def translate
return nil unless @form_content

# The pdf creation functionality is looking for a single street address
# instead of a hash
@form_content['incidents'].each do |incident|
incident['incidentLocation'] = join_location(incident['incidentLocation']) if incident['incidentLocation']
end
if @sync_modern_0781_flow
@translated_forms['form0781v2'] = create_form_v2
else
# The pdf creation functionality is looking for a single street address
# instead of a hash
@form_content['incidents'].each do |incident|
incident['incidentLocation'] = join_location(incident['incidentLocation']) if incident['incidentLocation']
end

incs0781a, incs0781 = split_incidents(@form_content['incidents'])
incs0781a, incs0781 = split_incidents(@form_content['incidents'])

@translated_forms['form0781'] = create_form(incs0781) if incs0781.present?
@translated_forms['form0781a'] = create_form(incs0781a) if incs0781a.present?
@translated_forms['form0781'] = create_form(incs0781) if incs0781.present?
@translated_forms['form0781a'] = create_form(incs0781a) if incs0781a.present?
end

@translated_forms
end

private

def create_form(incidents)
prepare_veteran_info.merge({
'incidents' => incidents,
'remarks' => @form_content['remarks'],
'additionalIncidentText' => @form_content['additionalIncidentText'],
'otherInformation' => @form_content['otherInformation']
})
end

def create_form_v2
prepare_veteran_info.merge({
'eventsDetails' => @form_content['eventsDetails'],
'reports' => @form_content['reports'],
'reportsDetails' => @form_content['reportsDetails'],
'behaviors' => @form_content['behaviors'],
'behaviorsDetails' => @form_content['behaviorsDetails'],
'evidence' => @form_content['evidence'],
'traumaTreatment' => @form_content['traumaTreatment'],
'treatmentProviders' => @form_content['treatmentProviders'],
'treatmentProvidersDetails' => @form_content['treatmentProvidersDetails'],
'optionIndicator' => @form_content['optionIndicator'],
'additionalInformation' => @form_content['additionalInformation']
})
end

def prepare_veteran_info
{
'vaFileNumber' => @user.ssn,
'veteranSocialSecurityNumber' => @user.ssn,
Expand All @@ -47,11 +77,7 @@ def create_form(incidents)
'email' => @phone_email['emailAddress'],
'veteranPhone' => @phone_email['primaryPhone'],
'veteranSecondaryPhone' => '', # No secondary phone available in 526 PreFill
'veteranServiceNumber' => '', # No veteran service number available in 526 PreFill
'incidents' => incidents,
'remarks' => @form_content['remarks'],
'additionalIncidentText' => @form_content['additionalIncidentText'],
'otherInformation' => @form_content['otherInformation']
'veteranServiceNumber' => '' # No veteran service number available in 526 PreFill
}
end

Expand Down
2 changes: 2 additions & 0 deletions lib/pdf_fill/filler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
require 'pdf_fill/forms/va214142'
require 'pdf_fill/forms/va210781a'
require 'pdf_fill/forms/va210781'
require 'pdf_fill/forms/va210781v2'
require 'pdf_fill/forms/va218940'
require 'pdf_fill/forms/va1010cg'
require 'pdf_fill/forms/va686c674'
Expand Down Expand Up @@ -51,6 +52,7 @@ def register_form(form_id, form_class)
'21-4142' => PdfFill::Forms::Va214142,
'21-0781a' => PdfFill::Forms::Va210781a,
'21-0781' => PdfFill::Forms::Va210781,
'21-0781V2' => PdfFill::Forms::Va210781v2,
'21-8940' => PdfFill::Forms::Va218940,
'10-10CG' => PdfFill::Forms::Va1010cg,
'686C-674' => PdfFill::Forms::Va686c674,
Expand Down
Binary file added lib/pdf_fill/forms/pdfs/21-0781V2.pdf
Binary file not shown.
2 changes: 2 additions & 0 deletions lib/sidekiq/form526_backup_submission_process/processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class Processor
'21-4142' => 'L107',
'21-0781' => 'L228',
'21-0781a' => 'L229',
'21-0781V2' => 'L228',
'21-8940' => 'L149',
'bdd' => 'L023'
}.freeze
Expand All @@ -59,6 +60,7 @@ class Processor
21-4142
21-0781
21-0781a
21-0781V2
21-8940
].freeze

Expand Down
6 changes: 6 additions & 0 deletions spec/factories/form526_submissions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@
end
end

trait :with_0781v2 do
form_json do
File.read("#{submissions_path}/with_0781v2.json")
end
end

trait :with_everything_toxic_exposure do
form_json do
File.read("#{submissions_path}/with_everything_toxic_exposure.json")
Expand Down
Loading

0 comments on commit 4442423

Please sign in to comment.