Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/appeals 17497 v6 ratings rework #19253

Merged
merged 66 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
e06b63c
pull v5 changes over
zurbergram Aug 17, 2023
94494f4
Update bgs_service.rb
zurbergram Aug 17, 2023
3218c49
Update metrics_service.rb
zurbergram Aug 17, 2023
83833c2
removed ratings work for MST/PACT
HunJerBAH Aug 21, 2023
2cf741c
first draft special issues comparator
HunJerBAH Aug 21, 2023
0c54d50
moved rating and contention special issue logic into special issue co…
HunJerBAH Aug 21, 2023
d463ff3
updated response to return false instead of nil
HunJerBAH Aug 22, 2023
a595d99
made code more readable
HunJerBAH Aug 23, 2023
f8ddbdd
refactored special issues comparator to unpack contetions
HunJerBAH Aug 29, 2023
8f0a96a
updated bgs service fake to use test data example
HunJerBAH Aug 29, 2023
b758a79
added error handling for nil rba contention data on the issue
HunJerBAH Aug 30, 2023
f7d5614
fixed test on task_queue_spec
HunJerBAH Sep 5, 2023
69e73ce
added MST/PACT feature toggles to flakey test
HunJerBAH Sep 5, 2023
01e00fc
updated flakey tests from MST/PACT changes
HunJerBAH Sep 5, 2023
3bc9f17
fixed flakey tests from MST/PACT
HunJerBAH Sep 5, 2023
f3b735e
updated flakey tasks for mst pact changes
HunJerBAH Sep 5, 2023
f08f35f
updated flakey test with MST/PACT feature toggles
HunJerBAH Sep 5, 2023
b524af7
reverted changes in case_issue generator to fix failing tests
HunJerBAH Sep 5, 2023
10051e2
added feature toggle to fix flakey test for mst pact
HunJerBAH Sep 5, 2023
92dc699
updated tests in AMA queue spec
HunJerBAH Sep 5, 2023
b1c97b5
removed leftover code from ratings rework
HunJerBAH Sep 6, 2023
89758b5
removed unecessary raven captures
HunJerBAH Sep 7, 2023
f3d167a
Merge branch 'master' into feature/APPEALS-17497-v6-ratings-rework
HunJerBAH Sep 8, 2023
198d8ee
resolved code climate issues
HunJerBAH Sep 11, 2023
1b1ea43
resolved code climate issues
HunJerBAH Sep 11, 2023
3fd8d2f
resolved code climate issues
HunJerBAH Sep 12, 2023
c8ebb3b
Merge branch 'master' into feature/APPEALS-17497-v6-ratings-rework
HunJerBAH Sep 14, 2023
a65bcd0
Fix Test (#19483)
wmedders21 Sep 18, 2023
610a5da
Will/appeals 17497 codeclimate remove sleeps (#19488)
wmedders21 Sep 18, 2023
ad58556
Will/appeals 17497 codeclimate task instructions (#19494)
wmedders21 Sep 18, 2023
da98855
Will/appeals 17497 codeclimate style (#19504)
wmedders21 Sep 20, 2023
c0664cf
Will/appeals 17497 Jest test fixes (#19544)
wmedders21 Sep 27, 2023
080ccf6
updated tests failing due to flaky date math
HunJerBAH Sep 27, 2023
765859c
APPEALS-17497: Resolved Merge Conflicts with Master Locally (#19591)
HunJerBAH Sep 27, 2023
74d77b9
Merge branch 'master' into feature/APPEALS-17497-v6-ratings-rework
HunJerBAH Sep 28, 2023
30bbee0
Merge branch 'master' into feature/APPEALS-17497-v6-ratings-rework
HunJerBAH Sep 29, 2023
9a09a4a
disabled code climate issues
HunJerBAH Sep 29, 2023
0f12b1a
fixed code climate issue
HunJerBAH Sep 29, 2023
4694a31
used round to fix flaky test that broke from date rounding issue
HunJerBAH Sep 29, 2023
0b86a8b
Merge branch 'master' into feature/APPEALS-17497-v6-ratings-rework
HunJerBAH Oct 4, 2023
ecc9318
turned off code smell checks for code that cannot be refactored
HunJerBAH Oct 10, 2023
dc94b03
cleaned up code climate issues
HunJerBAH Oct 10, 2023
3589fee
refactored to resolve code climate issues
HunJerBAH Oct 10, 2023
637b619
changed method name for code climate duplicate method
HunJerBAH Oct 10, 2023
884da71
fixed code climate issues
HunJerBAH Oct 10, 2023
9f884a6
fixed code climate issue
HunJerBAH Oct 10, 2023
4cfdd3e
Merge branch 'master' into feature/APPEALS-17497-v6-ratings-rework
HunJerBAH Oct 10, 2023
b429093
resolved code climate issues
HunJerBAH Oct 11, 2023
3577c6e
Merge branch 'master' into feature/APPEALS-17497-v6-ratings-rework
HunJerBAH Oct 13, 2023
57b2415
Merge branch 'master' into feature/APPEALS-17497-v6-ratings-rework
HunJerBAH Nov 1, 2023
6f7ed11
Merge branch 'master' into feature/APPEALS-17497-v6-ratings-rework
msteele96 Nov 7, 2023
2511c1f
Merge branch 'master' into feature/APPEALS-17497-v6-ratings-rework
msteele96 Nov 20, 2023
8e9aca7
updated tests with current master changes
HunJerBAH Nov 21, 2023
d681584
updated tests with vha modal changes
HunJerBAH Nov 21, 2023
395e5fe
Merge branch 'master' into feature/APPEALS-17497-v6-ratings-rework
msteele96 Nov 30, 2023
02344af
Merge branch 'master' into feature/APPEALS-17497-v6-ratings-rework
HunJerBAH Dec 6, 2023
fb6ec36
Merge branch 'master' into feature/APPEALS-17497-v6-ratings-rework
HunJerBAH Dec 7, 2023
e2b1b7b
Merge branch 'master' into feature/APPEALS-17497-v6-ratings-rework
HunJerBAH Dec 26, 2023
e3b6599
Merge branch 'master' into feature/APPEALS-17497-v6-ratings-rework
HunJerBAH Jan 5, 2024
4fd1d6f
Merge branch 'master' into feature/APPEALS-17497-v6-ratings-rework
HunJerBAH Jan 12, 2024
3e9df7e
APPEALS-37778: Decouple MST/PACT Feature Toggles (#20533)
HunJerBAH Jan 23, 2024
2a34dfe
APPEALS-37989: Create Seed Data for Legacy Cases with MST/PACT status…
HunJerBAH Jan 29, 2024
62720fd
Merge branch 'master' into feature/APPEALS-17497-v6-ratings-rework
HunJerBAH Jan 30, 2024
95b7139
Merge branch 'master' into feature/APPEALS-17497-v6-ratings-rework
HunJerBAH Feb 1, 2024
2c4ca04
APPEALS-39318: Resolve CodeClimate Issue on Branch (#20680)
HunJerBAH Feb 1, 2024
c9c2da6
Merge branch 'master' into feature/APPEALS-17497-v6-ratings-rework
HunJerBAH Feb 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ gem "acts_as_tree"
gem "amoeba"
# BGS

gem "bgs", git: "https://github.com/department-of-veterans-affairs/ruby-bgs.git", ref: "7d7c67f7bad5e5aa03e257f0d8e57a4aa1a6cbbf"
gem "bgs", git: "https://github.com/department-of-veterans-affairs/ruby-bgs.git", ref: "5f47e7b2656ef347d314ef43c93d38a9f20816ec"
# Bootsnap speeds up app boot (and started to be a default gem in 5.2).
gem "bootsnap", require: false
gem "browser"
Expand Down
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ GIT

GIT
remote: https://github.com/department-of-veterans-affairs/ruby-bgs.git
revision: 7d7c67f7bad5e5aa03e257f0d8e57a4aa1a6cbbf
ref: 7d7c67f7bad5e5aa03e257f0d8e57a4aa1a6cbbf
revision: 5f47e7b2656ef347d314ef43c93d38a9f20816ec
ref: 5f47e7b2656ef347d314ef43c93d38a9f20816ec
specs:
bgs (0.2)
bgs (0.3)
httpclient
nokogiri (>= 1.11.0.rc4)
savon (~> 2.12)
Expand Down
252 changes: 239 additions & 13 deletions app/controllers/appeals_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ def show

def edit
# only AMA appeals may call /edit
return not_found if appeal.is_a?(LegacyAppeal)
# this was removed for MST/PACT initiative to edit MST/PACT for legacy issues
return not_found if appeal.is_a?(LegacyAppeal) &&
!FeatureToggle.enabled?(:legacy_mst_pact_identification, user: RequestStore[:current_user])
end

helper_method :appeal, :url_appeal_uuid
Expand All @@ -178,18 +180,12 @@ def url_appeal_uuid
end

def update
if request_issues_update.perform!
# if cc appeal, create SendInitialNotificationLetterTask
if appeal.contested_claim? && FeatureToggle.enabled?(:cc_appeal_workflow)
# check if an existing letter task is open
existing_letter_task_open = appeal.tasks.any? do |task|
task.class == SendInitialNotificationLetterTask && task.status == "assigned"
end
# create SendInitialNotificationLetterTask unless one is open
send_initial_notification_letter unless existing_letter_task_open
end

if appeal.is_a?(LegacyAppeal) &&
FeatureToggle.enabled?(:legacy_mst_pact_identification, user: RequestStore[:current_user])
legacy_mst_pact_updates
elsif request_issues_update.perform!
set_flash_success_message
create_subtasks!

render json: {
beforeIssues: request_issues_update.before_issues.map(&:serialize),
Expand All @@ -203,6 +199,18 @@ def update

private

def create_subtasks!
# if cc appeal, create SendInitialNotificationLetterTask
if appeal.contested_claim? && FeatureToggle.enabled?(:cc_appeal_workflow)
# check if an existing letter task is open
existing_letter_task_open = appeal.tasks.any? do |task|
task.class == SendInitialNotificationLetterTask && task.status == "assigned"
end
# create SendInitialNotificationLetterTask unless one is open
send_initial_notification_letter unless existing_letter_task_open
end
end

# :reek:DuplicateMethodCall { allow_calls: ['result.extra'] }
# :reek:FeatureEnvy
def render_search_results_as_json(result)
Expand Down Expand Up @@ -270,7 +278,226 @@ def review_edited_message
"You have successfully " + [added_issues, removed_issues, withdrawn_issues].compact.to_sentence + "."
end

# check if changes in params
def mst_pact_changes?
request_issues_update.mst_edited_issues.any? || request_issues_update.pact_edited_issues.any?
end

# format MST/PACT edit success banner message
def mst_and_pact_edited_issues
# list of edit counts
mst_added = 0
mst_removed = 0
pact_added = 0
pact_removed = 0
# get edited issues from params and reject new issues without id
if !appeal.is_a?(LegacyAppeal)
existing_issues = params[:request_issues].reject { |i| i[:request_issue_id].nil? }

# get added issues
new_issues = request_issues_update.after_issues - request_issues_update.before_issues
# get removed issues
removed_issues = request_issues_update.before_issues - request_issues_update.after_issues

# calculate edits
existing_issues.each do |issue_edit|
# find the original issue and compare MST/PACT changes
before_issue = request_issues_update.before_issues.find { |i| i.id == issue_edit[:request_issue_id].to_i }

# increment edit counts if they meet the criteria for added/removed
mst_added += 1 if issue_edit[:mst_status] != before_issue.mst_status && issue_edit[:mst_status]
mst_removed += 1 if issue_edit[:mst_status] != before_issue.mst_status && !issue_edit[:mst_status]
pact_added += 1 if issue_edit[:pact_status] != before_issue.pact_status && issue_edit[:pact_status]
pact_removed += 1 if issue_edit[:pact_status] != before_issue.pact_status && !issue_edit[:pact_status]
end
else
existing_issues = legacy_issue_params[:request_issues]
existing_issues.each do |issue_edit|
mst_added += 1 if legacy_issues_with_updated_mst_pact_status[:mst_edited].include?(issue_edit) && issue_edit[:mst_status]
mst_removed += 1 if legacy_issues_with_updated_mst_pact_status[:mst_edited].include?(issue_edit) && !issue_edit[:mst_status]
pact_added += 1 if legacy_issues_with_updated_mst_pact_status[:pact_edited].include?(issue_edit) && issue_edit[:pact_status]
pact_removed += 1 if legacy_issues_with_updated_mst_pact_status[:pact_edited].include?(issue_edit) && !issue_edit[:pact_status]
new_issues = []
removed_issues = []
end
end

# return if no edits, removals, or additions
return if (mst_added + mst_removed + pact_added + pact_removed == 0) && removed_issues.empty? && new_issues.empty?

message = []

message << "#{pact_removed} #{'issue'.pluralize(pact_removed)} unmarked as PACT" unless pact_removed == 0
message << "#{mst_removed} #{'issue'.pluralize(mst_removed)} unmarked as MST" unless mst_removed == 0
message << "#{mst_added} #{'issue'.pluralize(mst_added)} marked as MST" unless mst_added == 0
message << "#{pact_added} #{'issue'.pluralize(pact_added)} marked as PACT" unless pact_added == 0

# add in removed message and added message, if any
message << create_mst_pact_message_for_new_and_removed_issues(new_issues, "added") unless new_issues.empty?
message << create_mst_pact_message_for_new_and_removed_issues(removed_issues, "removed") unless removed_issues.empty?

message.flatten
end

# create MST/PACT message for added/removed issues
def create_mst_pact_message_for_new_and_removed_issues(issues, type)
special_issue_message = []
# check if any added/removed issues have MST/PACT and get the count
mst_count = issues.count { |issue| issue.mst_status && !issue.pact_status }
pact_count = issues.count { |issue| issue.pact_status && !issue.mst_status }
both_count = issues.count { |issue| issue.pact_status && issue.mst_status }
none_count = issues.count { |issue| !issue.pact_status && !issue.mst_status }

special_issue_message << "#{mst_count} #{'issue'.pluralize(mst_count)} with MST #{type}" unless mst_count == 0
special_issue_message << "#{pact_count} #{'issue'.pluralize(pact_count)} with PACT #{type}" unless pact_count == 0
special_issue_message << "#{both_count} #{'issue'.pluralize(both_count)} with MST and PACT #{type}" unless both_count == 0
special_issue_message << "#{none_count} #{'issue'.pluralize(none_count)} #{type}" unless none_count == 0

special_issue_message
end

# check if there is a change in mst/pact on legacy issue
# if there is a change, creat an issue update task
def legacy_mst_pact_updates
legacy_issue_params[:request_issues].each do |current_issue|
issue = appeal.issues.find { |i| i.vacols_sequence_id == current_issue[:vacols_sequence_id].to_i }

# Check for changes in mst/pact status
if issue.mst_status != current_issue[:mst_status] || issue.pact_status != current_issue[:pact_status]
# If there is a change :
# Create issue_update_task to populate casetimeline if there is a change
create_legacy_issue_update_task(issue, current_issue)

# Grab record from Vacols database to issue.
# When updating an Issue, method in IssueMapper and IssueRepo requires the attrs show below in issue_attrs:{}
record = VACOLS::CaseIssue.find_by(isskey: appeal.vacols_id, issseq: current_issue[:vacols_sequence_id])
Issue.update_in_vacols!(
vacols_id: appeal.vacols_id,
vacols_sequence_id: current_issue[:vacols_sequence_id],
issue_attrs: {
mst_status: current_issue[:mst_status] ? "Y" : "N",
pact_status: current_issue[:pact_status] ? "Y" : "N",
program: record[:issprog],
issue: record[:isscode],
level_1: record[:isslev1],
level_2: record[:isslev2],
level_3: record[:isslev3]
}
)
end
end
set_flash_mst_edit_message
render json: { issues: json_issues }, status: :ok
end

def json_issues
appeal.issues.map do |issue|
::WorkQueue::LegacyIssueSerializer.new(issue).serializable_hash[:data][:attributes]
end
end

def legacy_issues_with_updated_mst_pact_status
mst_edited = legacy_issue_params[:request_issues].find_all do |current_issue|
issue = appeal.issues.find { |i| i.vacols_sequence_id == current_issue[:vacols_sequence_id].to_i }
issue.mst_status != current_issue[:mst_status]
end
pact_edited = legacy_issue_params[:request_issues].find_all do |current_issue|
issue = appeal.issues.find { |i| i.vacols_sequence_id == current_issue[:vacols_sequence_id].to_i }
issue.pact_status != current_issue[:pact_status]
end
{mst_edited: mst_edited, pact_edited: pact_edited}
end

def legacy_issue_params
# Checks the keys for each object in request_issues array
request_issue_params = params.require("request_issues").each do |current_param|
current_param.permit(:request_issue_id,
:withdrawal_date,
:vacols_sequence_id,
:mst_status,
:pact_status,
:mst_status_update_reason_notes,
:pact_status_update_reason_notes).to_h
end

# After check, recreate safe_params object and include vacols_uniq_id
safe_params = {
request_issues: request_issue_params,
vacols_user_id: current_user.vacols_uniq_id
}
safe_params
end

def create_params
legacy_issue_params.merge(vacols_id: appeal.vacols_id)
end

def create_legacy_issue_update_task(before_issue, current_issue)
user = RequestStore[:current_user]

# close out any tasks that might be open
open_issue_task = Task.where(
assigned_to: SpecialIssueEditTeam.singleton
).where(status: "assigned").where(appeal: appeal)
open_issue_task[0].delete unless open_issue_task.empty?

task = IssuesUpdateTask.create!(
appeal: appeal,
parent: appeal.root_task,
assigned_to: SpecialIssueEditTeam.singleton,
assigned_by: user,
completed_by: user
)
# format the task instructions and close out
task.format_instructions(
"Edited Issue",
[
"Benefit Type: #{before_issue.labels[0]}\n",
"Issue: #{before_issue.labels[1..-2].join("\n")}\n",
"Code: #{[before_issue.codes[-1], before_issue.labels[-1]].join(" - ")}\n",
"Note: #{before_issue.note}\n",
"Disposition: #{before_issue.readable_disposition}\n"
].compact.join("\r\n"),
"",
before_issue.mst_status,
before_issue.pact_status,
current_issue[:mst_status],
current_issue[:pact_status]
)
task.completed!

# create SpecialIssueChange record to log the changes
SpecialIssueChange.create!(
issue_id: before_issue.id,
appeal_id: appeal.id,
appeal_type: "LegacyAppeal",
task_id: task.id,
created_at: Time.zone.now.utc,
created_by_id: RequestStore[:current_user].id,
created_by_css_id: RequestStore[:current_user].css_id,
original_mst_status: before_issue.mst_status,
original_pact_status: before_issue.pact_status,
updated_mst_status: current_issue[:mst_status],
updated_pact_status: current_issue[:pact_status],
change_category: "Edited Issue"
)
end

# updated flash message to show mst/pact message if mst/pact changes (not to legacy)
def set_flash_success_message
return set_flash_mst_edit_message if mst_pact_changes? &&
(FeatureToggle.enabled?(:mst_identification, user: RequestStore[:current_user]) ||
FeatureToggle.enabled?(:pact_identification, user: RequestStore[:current_user]))

set_flash_edit_message
end

# create success message with added and removed issues
def set_flash_mst_edit_message
flash[:mst_pact_edited] = mst_and_pact_edited_issues
end

def set_flash_edit_message
flash[:edited] = if request_issues_update.after_issues.empty?
review_removed_message
elsif (request_issues_update.after_issues - request_issues_update.withdrawn_issues).empty?
Expand Down Expand Up @@ -395,4 +622,3 @@ def get_appeal_object(appeals_id)
end
end
end

7 changes: 5 additions & 2 deletions app/controllers/case_reviews_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ def set_application
end

def complete
result = CompleteCaseReview.new(case_review_class: case_review_class, params: complete_params).call

new_complete_case_review = CompleteCaseReview.new(case_review_class: case_review_class, params: complete_params)
result = new_complete_case_review.call
if result.success?
case_review = result.extra[:case_review]
render json: {
Expand Down Expand Up @@ -74,13 +74,16 @@ def judge_case_review_params

def issues_params
# This is a combined list of params for ama and legacy appeals
# Reprsents the information the front end is sending to create a decision issue object
[
:id,
:disposition,
:description,
:readjudication,
:benefit_type,
:diagnostic_code,
:mst_status,
:pact_status,
request_issue_ids: [],
remand_reasons: [
:code,
Expand Down
7 changes: 6 additions & 1 deletion app/controllers/intakes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class IntakesController < ApplicationController

def index
no_cache

respond_to do |format|
format.html { render(:index) }
end
Expand Down Expand Up @@ -43,6 +42,7 @@ def destroy
def review
if intake.review!(params)
render json: intake.ui_hash

else
render json: { error_codes: intake.review_errors }, status: :unprocessable_entity
end
Expand Down Expand Up @@ -97,6 +97,7 @@ def index_props
{
userDisplayName: current_user.display_name,
userCanIntakeAppeals: current_user.can_intake_appeals?,
userCanEditIntakeIssues: current_user.can_edit_intake_issues?,
serverIntake: intake_ui_hash,
dropdownUrls: dropdown_urls,
applicationUrls: application_urls,
Expand Down Expand Up @@ -150,6 +151,10 @@ def feature_toggle_ui_hash
filedByVaGovHlr: FeatureToggle.enabled?(:filed_by_va_gov_hlr, user: current_user),
updatedIntakeForms: FeatureToggle.enabled?(:updated_intake_forms, user: current_user),
eduPreDocketAppeals: FeatureToggle.enabled?(:edu_predocket_appeals, user: current_user),
mstIdentification: FeatureToggle.enabled?(:mst_identification, user: current_user),
pactIdentification: FeatureToggle.enabled?(:pact_identification, user: current_user),
legacyMstPactIdentification: FeatureToggle.enabled?(:legacy_mst_pact_identification, user: current_user),
justificationReason: FeatureToggle.enabled?(:justification_reason, user: current_user),
updatedAppealForm: FeatureToggle.enabled?(:updated_appeal_form, user: current_user),
hlrScUnrecognizedClaimants: FeatureToggle.enabled?(:hlr_sc_unrecognized_claimants, user: current_user),
vhaClaimReviewEstablishment: FeatureToggle.enabled?(:vha_claim_review_establishment, user: current_user)
Expand Down
Loading
Loading