Skip to content

Commit

Permalink
Improve EP 400 Merge eligibility check to offramp if open 030/040 fou…
Browse files Browse the repository at this point in the history
…nd (#16309)

* Improve EP 400 Merge eligibility check to offramp if open 030/040 found

* Fix rubocop line length warnings
  • Loading branch information
nanotone authored Apr 22, 2024
1 parent 0abff03 commit 7640075
Show file tree
Hide file tree
Showing 4 changed files with 6,562 additions and 5 deletions.
33 changes: 30 additions & 3 deletions app/models/concerns/form526_claim_fast_tracking_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module Form526ClaimFastTrackingConcern
MAX_CFI_STATSD_KEY_PREFIX = 'api.max_cfi'
EP_MERGE_STATSD_KEY_PREFIX = 'worker.ep_merge'

EP_MERGE_BASE_CODES = %w[010 110 020 030 040].freeze
EP_MERGE_BASE_CODES = %w[010 110 020].freeze
EP_MERGE_SPECIAL_ISSUE = 'EMP'
OPEN_STATUSES = [
'CLAIM RECEIVED',
Expand All @@ -23,6 +23,8 @@ module Form526ClaimFastTrackingConcern
'CLAIM_RECEIVED',
'INITIAL_REVIEW'
].freeze
CLAIM_REVIEW_BASE_CODES = %w[030 040].freeze
CLAIM_REVIEW_TYPES = %w[higherLevelReview supplementalClaim].freeze

def send_rrd_alert_email(subject, message, error = nil, to = Settings.rrd.alerts.recipients)
RrdAlertMailer.build(self, subject, message, error, to).deliver_now
Expand Down Expand Up @@ -133,11 +135,13 @@ def prepare_for_ep_merge!
date = Date.strptime(pending_eps.first['date'], '%m/%d/%Y')
days_ago = (Time.zone.today - date).round
feature_enabled = Flipper.enabled?(:disability_526_ep_merge_api, User.find(user_uuid))
open_claim_review = open_claim_review?
Rails.logger.info(
'EP Merge open EP eligibility',
{ id:, feature_enabled:, pending_ep_age: days_ago, pending_ep_status: pending_eps.first['status'] }
{ id:, feature_enabled:, open_claim_review:,
pending_ep_age: days_ago, pending_ep_status: pending_eps.first['status'] }
)
if feature_enabled
if feature_enabled && !open_claim_review
save_metadata(ep_merge_pending_claim_id: pending_eps.first['id'])
add_ep_merge_special_issue!
end
Expand Down Expand Up @@ -271,6 +275,29 @@ def open_claims
end
end

# Check both Benefits Claim service and Caseflow Appeals status APIs for open 030 or 040
# Offramps EP 400 Merge process if any are found, or if anything fails
def open_claim_review?
open_claim_review = open_claims.any? do |claim|
CLAIM_REVIEW_BASE_CODES.include?(claim['base_end_product_code']) && OPEN_STATUSES.include?(claim['status'])
end
if open_claim_review
StatsD.increment("#{EP_MERGE_STATSD_KEY_PREFIX}.open_claim_review")
return true
end

ssn = User.find(user_uuid)&.ssn
ssn ||= auth_headers['va_eauth_pnid'] if auth_headers['va_eauth_pnidtype'] == 'SSN'
decision_reviews = Caseflow::Service.new.get_appeals(OpenStruct.new({ ssn: })).body['data']
StatsD.increment("#{EP_MERGE_STATSD_KEY_PREFIX}.caseflow_api_called")
decision_reviews.any? do |review|
CLAIM_REVIEW_TYPES.include?(review['type']) && review['attributes']['active']
end
rescue => e
Rails.logger.error('EP Merge failed open claim review check', backtrace: e.backtrace)
true
end

# fetch, memoize, and return all of the veteran's rated disabilities from EVSS
def all_rated_disabilities
settings = Settings.lighthouse.veteran_verification.form526
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@
saved_claim_id: saved_claim.id)
end
let(:open_claims_cassette) { 'evss/claims/claims_without_open_compensation_claims' }
let(:caseflow_cassette) { 'caseflow/appeals' }
let(:rated_disabilities_cassette) { 'evss/disability_compensation_form/rated_disabilities' }
let(:submit_form_cassette) { 'evss/disability_compensation_form/submit_form_v2' }
let(:lh_upload) { 'lighthouse/benefits_intake/200_lighthouse_intake_upload_location' }
let(:evss_get_pdf) { 'form526_backup/200_evss_get_pdf' }
let(:lh_intake_upload) { 'lighthouse/benefits_intake/200_lighthouse_intake_upload' }
let(:lh_submission) { 'lighthouse/benefits_claims/submit526/200_response' }
let(:cassettes) do
[open_claims_cassette, rated_disabilities_cassette, submit_form_cassette, lh_upload, evss_get_pdf,
[open_claims_cassette, caseflow_cassette, rated_disabilities_cassette,
submit_form_cassette, lh_upload, evss_get_pdf,
lh_intake_upload, lh_submission]
end
let(:backup_klass) { Sidekiq::Form526BackupSubmissionProcess::Submit }
Expand Down Expand Up @@ -151,7 +153,8 @@ def expect_retryable_error(error_class)
expect(Rails.logger).to have_received(:info).with('EP Merge total open EPs', id: submission.id, count: 1)
expect(Rails.logger).to have_received(:info).with(
'EP Merge open EP eligibility',
{ id: submission.id, feature_enabled: true, pending_ep_age: 365, pending_ep_status: 'UNDER REVIEW' }
{ id: submission.id, feature_enabled: true, open_claim_review: false,
pending_ep_age: 365, pending_ep_status: 'UNDER REVIEW' }
)
end

Expand Down Expand Up @@ -186,6 +189,32 @@ def expect_retryable_error(error_class)
end
end

context 'when an EP 030 or 040 is included in the list of open claims' do
let(:open_claims_cassette) { 'evss/claims/claims_with_open_040' }

it 'does not save any claim ID for EP400 merge' do
subject.perform_async(submission.id)
VCR.use_cassette('virtual_regional_office/contention_classification') do
described_class.drain
end
submission.reload
expect(submission.read_metadata(:ep_merge_pending_claim_id)).to be_nil
end
end

context 'when Caseflow appeals status API returns an open claim review' do
let(:caseflow_cassette) { 'caseflow/appeals_with_hlr_only' }

it 'does not save any claim ID for EP400 merge' do
subject.perform_async(submission.id)
VCR.use_cassette('virtual_regional_office/contention_classification') do
described_class.drain
end
submission.reload
expect(submission.read_metadata(:ep_merge_pending_claim_id)).to be_nil
end
end

context 'when EP400 merge API call is disabled' do
before { Flipper.disable(:disability_526_ep_merge_api) }

Expand Down
58 changes: 58 additions & 0 deletions spec/support/vcr_cassettes/caseflow/appeals_with_hlr_only.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7640075

Please sign in to comment.