Skip to content

Commit

Permalink
[Automated] Merged master into target k8s
Browse files Browse the repository at this point in the history
  • Loading branch information
va-vsp-bot authored Apr 10, 2024
2 parents d1d0f2f + 7b520a8 commit 02fc65f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 11 deletions.
29 changes: 19 additions & 10 deletions app/models/concerns/form526_claim_fast_tracking_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ def disabilities
form.dig('form526', 'form526', 'disabilities')
end

def increase_disabilities
disabilities.select { |disability| disability['disabilityActionType']&.upcase == 'INCREASE' }
end

def increase_only?
disabilities.all? { |disability| disability['disabilityActionType']&.upcase == 'INCREASE' }
end
Expand Down Expand Up @@ -188,18 +192,19 @@ def update_form_with_classification_code(classification_code)
end

def log_max_cfi_metrics_on_submit
ClaimFastTracking::DiagnosticCodesForMetrics::DC.intersection(diagnostic_codes).each do |diagnostic_code|
next unless disabilities.any? do |dis|
diagnostic_code == dis['diagnosticCode']
end
user = User.find(user_uuid)
max_cfi_enabled = Flipper.enabled?(:disability_526_maximum_rating, user) ? 'on' : 'off'
ClaimFastTracking::DiagnosticCodesForMetrics::DC.each do |diagnostic_code|
next unless max_rated_diagnostic_codes_from_ipf.include?(diagnostic_code)

next unless max_rated_disabilities_from_ipf.any? do |dis|
diagnostic_code == dis['diagnostic_code']
end
disability_claimed = diagnostic_codes.include?(diagnostic_code)

user = User.find(user_uuid)
max_cfi_enabled = Flipper.enabled?(:disability_526_maximum_rating, user) ? 'on' : 'off'
StatsD.increment("#{MAX_CFI_STATSD_KEY_PREFIX}.#{max_cfi_enabled}.submit.#{diagnostic_code}")
if disability_claimed
StatsD.increment("#{MAX_CFI_STATSD_KEY_PREFIX}.#{max_cfi_enabled}.submit.#{diagnostic_code}")
end
Rails.logger.info('Max CFI form526 submission',
id:, max_cfi_enabled:, disability_claimed:, diagnostic_code:,
total_increase_conditions: increase_disabilities.count)
end
rescue => e
# Log the exception but but do not fail, otherwise form will not be submitted
Expand Down Expand Up @@ -244,6 +249,10 @@ def max_rated_disabilities_from_ipf
end
end

def max_rated_diagnostic_codes_from_ipf
max_rated_disabilities_from_ipf.pluck('diagnostic_code')
end

# Fetch and memoize all of the veteran's open EPs. Establishing a new EP will make the memoized
# value outdated if using the same Form526Submission instance.
def open_claims
Expand Down
27 changes: 26 additions & 1 deletion spec/models/form526_submission_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,17 @@

before do
allow(StatsD).to receive(:increment)
allow(Rails.logger).to receive(:info)
Flipper.disable(:disability_526_maximum_rating)
end

def expect_max_cfi_logged(max_cfi_enabled, disability_claimed, diagnostic_code, total_increase_conditions)
expect(Rails.logger).to have_received(:info).with(
'Max CFI form526 submission',
{ id: subject.id, max_cfi_enabled:, disability_claimed:, diagnostic_code:, total_increase_conditions: }
)
end

context 'the submission is for tinnitus' do
let(:form_json) do
File.read('spec/support/disability_compensation_form/submissions/only_526_tinnitus.json')
Expand All @@ -117,6 +125,7 @@
it 'logs CFI metric upon submission' do
subject.start
expect(StatsD).to have_received(:increment).with('api.max_cfi.on.submit.6260')
expect_max_cfi_logged('on', true, 6260, 1)
end
end

Expand All @@ -137,6 +146,7 @@
it 'logs CFI metric upon submission' do
subject.start
expect(StatsD).to have_received(:increment).with('api.max_cfi.off.submit.6260')
expect_max_cfi_logged('off', true, 6260, 1)
end
end

Expand Down Expand Up @@ -180,7 +190,7 @@
end
end

context 'the submission is for tinnitus and hypertension' do
context 'the submission is from a Veteran with rated tinnitus and hypertension' do
let(:form_json) do
File.read('spec/support/disability_compensation_form/submissions/only_526_two_cfi_with_max_ratings.json')
end
Expand Down Expand Up @@ -218,6 +228,18 @@
subject.start
expect(StatsD).to have_received(:increment).with('api.max_cfi.on.submit.6260')
expect(StatsD).not_to have_received(:increment).with('api.max_cfi.on.submit.7101')
expect_max_cfi_logged('on', true, 6260, 2)
end

context 'when the submission omits tinnitus' do
let(:form_json) do
File.read('spec/support/disability_compensation_form/submissions/only_526_hypertension.json')
end

it 'logs CFI metric upon submission for tinnitus being omitted' do
subject.start
expect_max_cfi_logged('on', false, 6260, 1)
end
end
end

Expand All @@ -228,6 +250,7 @@
subject.start
expect(StatsD).to have_received(:increment).with('api.max_cfi.on.submit.6260')
expect(StatsD).not_to have_received(:increment).with('api.max_cfi.on.submit.7101')
expect_max_cfi_logged('on', true, 6260, 2)
end
end

Expand Down Expand Up @@ -261,6 +284,7 @@
subject.start
expect(StatsD).to have_received(:increment).with('api.max_cfi.off.submit.6260')
expect(StatsD).not_to have_received(:increment).with('api.max_cfi.off.submit.7101')
expect_max_cfi_logged('off', true, 6260, 2)
end
end

Expand All @@ -271,6 +295,7 @@
subject.start
expect(StatsD).to have_received(:increment).with('api.max_cfi.off.submit.6260')
expect(StatsD).not_to have_received(:increment).with('api.max_cfi.off.submit.7101')
expect_max_cfi_logged('off', true, 6260, 2)
end
end

Expand Down

0 comments on commit 02fc65f

Please sign in to comment.