Skip to content

Commit

Permalink
Fix EP400 Merge eligibility logic to be compatible with LH Benefits C…
Browse files Browse the repository at this point in the history
…laims API
  • Loading branch information
nanotone committed Apr 25, 2024
1 parent c2cc95b commit d487f44
Show file tree
Hide file tree
Showing 5 changed files with 174 additions and 3 deletions.
15 changes: 12 additions & 3 deletions app/models/concerns/form526_claim_fast_tracking_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ module Form526ClaimFastTrackingConcern
CLAIM_REVIEW_BASE_CODES = %w[030 040].freeze
CLAIM_REVIEW_TYPES = %w[higherLevelReview supplementalClaim].freeze

def claim_age_in_days(pending_ep)
date = if pending_ep.respond_to?(:claim_date)
Date.strptime(pending_ep.claim_date, '%Y-%m-%d')
else
Date.strptime(pending_ep['date'], '%m/%d/%Y')
end
(Time.zone.today - date).round
end

def send_rrd_alert_email(subject, message, error = nil, to = Settings.rrd.alerts.recipients)
RrdAlertMailer.build(self, subject, message, error, to).deliver_now
end
Expand Down Expand Up @@ -132,19 +141,19 @@ def prepare_for_ep_merge!
Rails.logger.info('EP Merge total open EPs', id:, count: pending_eps.count)
return unless pending_eps.count == 1

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:, open_claim_review:,
pending_ep_age: days_ago, pending_ep_status: pending_eps.first['status'] }
pending_ep_age: claim_age_in_days(pending_eps.first), pending_ep_status: pending_eps.first['status'] }
)
if feature_enabled && !open_claim_review
save_metadata(ep_merge_pending_claim_id: pending_eps.first['id'])
add_ep_merge_special_issue!
end
rescue => e
Rails.logger.error("EP400 Merge eligibility failed #{e.message}.", backtrace: e.backtrace)
end

def get_claim_type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def transform(data)
DisabilityCompensation::ApiProvider::Claim.new(
id: open_claim['id'],
base_end_product_code: open_claim['attributes']['baseEndProductCode'],
claim_date: open_claim['attributes']['claimDate'],
claim_phase_dates: open_claim['attributes']['claimPhaseDates'],
development_letter_sent: open_claim['attributes']['developmentLetterSent'],
status: open_claim['attributes']['status'] # make sure words/strings syntax is perfect match
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Claim
attribute :base_end_product_code, String
attribute :development_letter_sent, Boolean
attribute :status, String
attribute :claim_date, String
attribute :claim_phase_dates, ClaimPhaseDates
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@

let(:saved_claim) { FactoryBot.create(:va526ez) }
let(:submitted_claim_id) { 600_130_094 }
let(:user_account) { create(:user_account, icn: '123498767V234859') }
let(:submission) do
create(:form526_submission,
user_account_id: user_account.id,
user_uuid: user.uuid,
auth_headers_json: auth_headers.to_json,
saved_claim_id: saved_claim.id)
Expand Down Expand Up @@ -158,6 +160,30 @@ def expect_retryable_error(error_class)
)
end

context 'when using LH Benefits Claims API instead of EVSS' do
before do
Flipper.enable(:disability_compensation_lighthouse_claims_service_provider)
allow_any_instance_of(BenefitsClaims::Configuration).to receive(:access_token).and_return('access_token')
end

after { Flipper.disable(:disability_compensation_lighthouse_claims_service_provider) }

let(:open_claims_cassette) { 'lighthouse/benefits_claims/index/claims_with_single_open_disability_claim' }

it 'logs the expected data for EP 400 merge eligibility' do
subject.perform_async(submission.id)
VCR.use_cassette('virtual_regional_office/contention_classification') do
described_class.drain
end
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, open_claim_review: false,
pending_ep_age: 365, pending_ep_status: 'INITIAL_REVIEW' }
)
end
end

context 'when EP400 merge API call is enabled' do
before do
Flipper.enable(:disability_526_ep_merge_api, user)
Expand Down

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

0 comments on commit d487f44

Please sign in to comment.