Skip to content

Commit

Permalink
Merge feature/APPEALS-41559 into release/FY24Q4.6.0 (#22979)
Browse files Browse the repository at this point in the history
* Start feature work tracking PR with a TODO comment

* Remove TODO comment for CodeClimate

* SeanC/APPEALS-42315 | Create separate Remand table, model and seed data (#22220)

* added migration file for adding type column to supplemental claims table

* created stub for remand model

* added type to supplemental claim factory and new remand trait

* added remand sc's to vha seeds

* updated migration name and fixed typo

* Changed migration to inherit from Caseflow::Mirgration

* schema changes

* reverting schema

* changed the setting of the type column

* fixed schema and renamed migration file

* fixed migration and schema

* updated the remands factory and seeds

* fixed comment in schema

---------

Co-authored-by: Robert Travis Pierce <robert@roberttravispierce.com>

* TYLERB/APPEALS-42455: Display new and migrated Remands in Decision Review Queue tabs (#22206)

* Added support for remands to the business_line.rb model and the index.js util file that parses the decision review type filters for the decision review queue.

* Updated the business line spec file, the decision reviews controller spec tests, and the reviews spec feature test to support remands.

* Added a decision review polymorphic helper to DRY up some of the polymorphic appeal concerns.

* Overrode the remand model association to request issues so active record joins will work correctly.

* Added another helper for sti polymorphic relationships. Fixed filtering for STI decision review types for remands. Updated tests and added factories for testing.

* Code climate fixes and test fixes.

* Fixed more test failures. Removed the remand request issues relationship since it was incorrectly implemented. Added a scope to supplemental claims for remands. Fixed an issue where board grant effectuation tasks without request issues were missing from the new task type count method.

* Changed the UNION ALL to a UNION in the new task_type_count method to prevent duplicate row counts. Updated tests and fixed an issue where the board grant effectuation tasks were being counted for pending task queries.

* JHoang/APPEALS-42318 (#22270)

* some preliminary remand & sc model updates

* typo

* some preliminary hlr checks?

* undo seed change

* decision issue and sc updates

* attempt code climate fixes

* another code climate fix

* testing changes

* useless variable..

* fix conditional in decision issue

* fix undefined find_by method

* attempt rspec fix

* rspec fix attempt #2

* supplemental_claim_spec fix?

* remove comma

* code climate fix

* added comment for transparency on remand creation, attempt fix for remands route

* updated specs for decision_issue, hlr_spec, appeal_spec to account for remand creation type

* fix lint error

* fix lint error #2

---------

Co-authored-by: Jonathan Hoang <trinhjoanthan.hoang@va.gov>

* APPEALS-42458 (#22365)

* disable edit issues link for remands

* add banners explaining that remands are not editable

also makes sure that remands are not editable on the edit issues page

* TYLERB/APPEALS-44922: Update Generate task report page UI to include Remand in conditions (#22356)

* Initial commit. Changed the DecisionReviewType condition filter to a searchable dropdown and added the remands option to it as well. Updated the report page filter parsing to work with the searchable dropdown instead of checkboxes for the decision review type condition filter.

* Updated the ReportPage jest test and the report page feature test to work with the decision review type filter as a searchable dropdown instead of checkboxes.

* SeanC/APPEALS-42317 | Migrate existing Supplemental Claim Remands to Remand records via script (#22359)

* initial verison of update script

* remanded migration file

* updated sc spec with type

* schema

* fixed a few issues in the migration

* small fix to migration file

* moved the type column check into a seperate it block

* fixed wrong column in migration file

* created a new migration for creating the view

* updated the backfill migration file

---------

Co-authored-by: Brandon Lee Dorner <Brandondorner@yahoo.com>

* J hoang/appeals 44940 (#22428)

* initial

* some factory and spec updates

* change history query update and spec fixes

* code climate/lint fix

* change @claim_type identifier

* fix claim_history_event_spec.rb

* test coverage for change history with Remand claim type

* spec lint fixes

* refactor claim_type filtering to account for remand subtype

* business_line_spec fix

* decision_reviews_controller_spec update for remand claim type

* lint fixes for decision_reviews_controller_spec.rb

* comment updates in business_line.rb

* renamed mock data in change_history_reporter_spec

* trigger GA

* refactor claim type filter for less conditional handling

* business line spec fix

---------

Co-authored-by: Jonathan Hoang <trinhjoanthan.hoang@va.gov>

* Initial commit for the brakeman sql injection warning fixes. (#22598)

* Updated the business line reporter class to properly display Remands as a seperate type than SupplementalClaims. Also added additional testing logic for the business line reporter for hlr and scs since it was only covering appeals. (#22664)

Co-authored-by: Robert Travis Pierce <robert@roberttravispierce.com>

* Fixed a bug where the frontend would error due to calling .toLowerCase() on a null or undefined value which could happen sometimes if the api filter options are in an incorrect state. (#22796)

Co-authored-by: Robert Travis Pierce <robert@roberttravispierce.com>

* Updated the remand migration files to work with the rails 6 upgrade and the changes to Caseflow::Migration. (#22825)

* added fix for failing test in decision_reviews_controller_spec (#22829)

---------

Co-authored-by: Robert Travis Pierce <Pierce_Robert@ne.bah.com>
Co-authored-by: Sean Craig <110493538+seancva@users.noreply.github.com>
Co-authored-by: Tyler Broyles <109369527+TylerBroyles@users.noreply.github.com>
Co-authored-by: jonathanh-va <111081469+jonathanh-va@users.noreply.github.com>
Co-authored-by: Jonathan Hoang <trinhjoanthan.hoang@va.gov>
Co-authored-by: Brandon Lee Dorner <Brandondorner@yahoo.com>
Co-authored-by: Clay Sheppard <csheepy@gmail.com>
  • Loading branch information
8 people authored Sep 26, 2024
1 parent 0368053 commit 3c322cb
Show file tree
Hide file tree
Showing 53 changed files with 1,092 additions and 360 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,9 @@

module AppealStateBelongsToPolymorphicAppealConcern
extend ActiveSupport::Concern
include DecisionReviewPolymorphicHelper

included do
belongs_to :appeal, polymorphic: true

belongs_to :ama_appeal,
-> { where(appeal_states: { appeal_type: "Appeal" }) },
class_name: "Appeal", foreign_key: "appeal_id", optional: true

belongs_to :legacy_appeal,
-> { where(appeal_states: { appeal_type: "LegacyAppeal" }) },
class_name: "LegacyAppeal", foreign_key: "appeal_id", optional: true

scope :ama, -> { where(appeal_type: "Appeal") }
scope :legacy, -> { where(appeal_type: "LegacyAppeal") }
define_polymorphic_decision_review_associations(:appeal, :appeal_states, %w[Appeal LegacyAppeal])
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,9 @@

module AttorneyCaseReviewBelongsToPolymorphicAppealConcern
extend ActiveSupport::Concern
include DecisionReviewPolymorphicHelper

included do
belongs_to :appeal, polymorphic: true

belongs_to :ama_appeal,
-> { where(attorney_case_reviews: { appeal_type: "Appeal" }) },
class_name: "Appeal", foreign_key: "appeal_id", optional: true

belongs_to :legacy_appeal,
-> { where(attorney_case_reviews: { appeal_type: "LegacyAppeal" }) },
class_name: "LegacyAppeal", foreign_key: "appeal_id", optional: true

scope :ama, -> { where(appeal_type: "Appeal") }
scope :legacy, -> { where(appeal_type: "LegacyAppeal") }
define_polymorphic_decision_review_associations(:appeal, :attorney_case_reviews, %w[Appeal LegacyAppeal])
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,9 @@

module AvailableHearingLocationsBelongsToPolymorphicAppealConcern
extend ActiveSupport::Concern
include DecisionReviewPolymorphicHelper

included do
belongs_to :appeal, polymorphic: true

belongs_to :ama_appeal,
-> { where(available_hearing_locations: { appeal_type: "Appeal" }) },
class_name: "Appeal", foreign_key: "appeal_id", optional: true

belongs_to :legacy_appeal,
-> { where(available_hearing_locations: { appeal_type: "LegacyAppeal" }) },
class_name: "LegacyAppeal", foreign_key: "appeal_id", optional: true

scope :ama, -> { where(appeal_type: "Appeal") }
scope :legacy, -> { where(appeal_type: "LegacyAppeal") }
define_polymorphic_decision_review_associations(:appeal, :available_hearing_locations, %w[Appeal LegacyAppeal])
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,9 @@

module ClaimantBelongsToPolymorphicAppealConcern
extend ActiveSupport::Concern
include DecisionReviewPolymorphicHelper

included do
belongs_to :decision_review, polymorphic: true

belongs_to :ama_appeal,
-> { where(claimants: { decision_review_type: "Appeal" }) },
class_name: "Appeal", foreign_key: "decision_review_id", optional: true

belongs_to :legacy_appeal,
-> { where(claimants: { decision_review_type: "LegacyAppeal" }) },
class_name: "LegacyAppeal", foreign_key: "decision_review_id", optional: true

belongs_to :higher_level_review,
-> { where(claimants: { decision_review_type: "HigherLevelReview" }) },
class_name: "HigherLevelReview", foreign_key: "decision_review_id", optional: true

belongs_to :supplemental_claim,
-> { where(claimants: { decision_review_type: "SupplementalClaim" }) },
class_name: "SupplementalClaim", foreign_key: "decision_review_id", optional: true

scope :ama, -> { where(decision_review_type: "Appeal") }
scope :legacy, -> { where(decision_review_type: "LegacyAppeal") }
scope :higher_level_review, -> { where(decision_review_type: "HigherLevelReview") }
scope :supplemental_claim, -> { where(decision_review_type: "SupplementalClaim") }
define_polymorphic_decision_review_associations(:decision_review, :claimants)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,9 @@

module DecisionDocumentBelongsToPolymorphicAppealConcern
extend ActiveSupport::Concern
include DecisionReviewPolymorphicHelper

included do
belongs_to :appeal, polymorphic: true

belongs_to :ama_appeal,
-> { where(decision_documents: { appeal_type: "Appeal" }) },
class_name: "Appeal", foreign_key: "appeal_id", optional: true

belongs_to :legacy_appeal,
-> { where(decision_documents: { appeal_type: "LegacyAppeal" }) },
class_name: "LegacyAppeal", foreign_key: "appeal_id", optional: true

scope :ama, -> { where(appeal_type: "Appeal") }
scope :legacy, -> { where(appeal_type: "LegacyAppeal") }
define_polymorphic_decision_review_associations(:appeal, :decision_documents, %w[Appeal LegacyAppeal])
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,11 @@

module DecisionIssueBelongsToPolymorphicAppealConcern
extend ActiveSupport::Concern
include DecisionReviewPolymorphicHelper

included do
belongs_to :decision_review, polymorphic: true

belongs_to :ama_appeal,
-> { where(decision_issues: { decision_review_type: "Appeal" }) },
class_name: "Appeal", foreign_key: "decision_review_id", optional: true

belongs_to :higher_level_review,
-> { where(decision_issues: { decision_review_type: "HigherLevelReview" }) },
class_name: "HigherLevelReview", foreign_key: "decision_review_id", optional: true

belongs_to :supplemental_claim,
-> { where(decision_issues: { decision_review_type: "SupplementalClaim" }) },
class_name: "SupplementalClaim", foreign_key: "decision_review_id", optional: true

scope :ama, -> { where(decision_review_type: "Appeal") }
scope :higher_level_review, -> { where(decision_review_type: "HigherLevelReview") }
scope :supplemental_claim, -> { where(decision_review_type: "SupplementalClaim") }
define_polymorphic_decision_review_associations(:decision_review,
:decision_issues,
%w[Appeal HigherLevelReview SupplementalClaim])
end
end
30 changes: 30 additions & 0 deletions app/models/concerns/decision_review_polymorphic_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# frozen_string_literal: true

module DecisionReviewPolymorphicHelper
extend ActiveSupport::Concern

class_methods do
def define_polymorphic_decision_review_associations(association_name, from_association_name, types = nil)
belongs_to association_name, polymorphic: true

# Specific association mappings that are uniquely different from the calculated class name to underscored symbol
association_name_mapping = { "Appeal" => :ama_appeal, "Hearing" => :ama_hearing }
scope_mapping = { "Appeal" => :ama, "LegacyAppeal" => :legacy, "LegacyHearing" => :legacy, "Hearing" => :ama }

# LegacyAppeals + all of the non abstract subtypes of DecisionReview not incuding child types for STI
types ||= %w[Appeal LegacyAppeal HigherLevelReview SupplementalClaim]

types.each do |type|
type_symbol = type.underscore.to_sym
belongs_to_association_name = association_name_mapping[type] || type_symbol
scope_name = scope_mapping[type] || type_symbol

belongs_to belongs_to_association_name,
-> { where(from_association_name => { "#{association_name}_type": type }) },
class_name: type, foreign_key: "#{association_name}_id", optional: true

scope scope_name.to_sym, -> { where("#{association_name}_type": type) }
end
end
end
end
29 changes: 29 additions & 0 deletions app/models/concerns/decision_review_polymorphic_sti_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# frozen_string_literal: true

module DecisionReviewPolymorphicSTIHelper
extend ActiveSupport::Concern

class_methods do
def define_polymorphic_decision_review_sti_associations(association_name, from_association_name, types = nil)
# Mappings between STI types and their associated parent type and parent database table
sti_table_mapping = { "Remand" => :supplemental_claims }
sti_type_mapping = { "Remand" => "SupplementalClaim" }

types ||= %w[Remand]

types.each do |type|
type_symbol = type.underscore.to_sym
belongs_to_association_name = type_symbol
sti_type = sti_type_mapping[type] || type
sti_table_name = sti_table_mapping[type] || association_name

belongs_to belongs_to_association_name,
lambda {
where(from_association_name => { "#{association_name}_type": sti_type })
.where(Arel::Table.new(sti_table_name)[:type].eq(type))
},
class_name: type, foreign_key: "#{association_name}_id", optional: true
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,9 @@

module HearingEmailRecipientBelongsToPolymorphicAppealConcern
extend ActiveSupport::Concern
include DecisionReviewPolymorphicHelper

included do
belongs_to :appeal, polymorphic: true

belongs_to :ama_appeal,
-> { where(hearing_email_recipients: { appeal_type: "Appeal" }) },
class_name: "Appeal", foreign_key: "appeal_id", optional: true

belongs_to :legacy_appeal,
-> { where(hearing_email_recipients: { appeal_type: "LegacyAppeal" }) },
class_name: "LegacyAppeal", foreign_key: "appeal_id", optional: true

scope :ama, -> { where(appeal_type: "Appeal") }
scope :legacy, -> { where(appeal_type: "LegacyAppeal") }
define_polymorphic_decision_review_associations(:appeal, :hearing_email_recipients, %w[Appeal LegacyAppeal])
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,9 @@

module JudgeCaseReviewBelongsToPolymorphicAppealConcern
extend ActiveSupport::Concern
include DecisionReviewPolymorphicHelper

included do
belongs_to :appeal, polymorphic: true

belongs_to :ama_appeal,
-> { where(judge_case_reviews: { appeal_type: "Appeal" }) },
class_name: "Appeal", foreign_key: "appeal_id", optional: true

belongs_to :legacy_appeal,
-> { where(judge_case_reviews: { appeal_type: "LegacyAppeal" }) },
class_name: "LegacyAppeal", foreign_key: "appeal_id", optional: true

scope :ama, -> { where(appeal_type: "Appeal") }
scope :legacy, -> { where(appeal_type: "LegacyAppeal") }
define_polymorphic_decision_review_associations(:appeal, :judge_case_reviews, %w[Appeal LegacyAppeal])
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,9 @@

module SentHearingEmailEventBelongsToPolymorphicHearingConcern
extend ActiveSupport::Concern
include DecisionReviewPolymorphicHelper

included do
belongs_to :hearing, polymorphic: true

belongs_to :ama_hearing,
-> { where(sent_hearing_email_events: { hearing_type: "Hearing" }) },
class_name: "Hearing", foreign_key: "hearing_id", optional: true

belongs_to :legacy_hearing,
-> { where(sent_hearing_email_events: { hearing_type: "LegacyHearing" }) },
class_name: "LegacyHearing", foreign_key: "hearing_id", optional: true

scope :ama, -> { where(hearing_type: "Hearing") }
scope :legacy, -> { where(hearing_type: "LegacyHearing") }
define_polymorphic_decision_review_associations(:hearing, :sent_hearing_email_events, %w[Hearing LegacyHearing])
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,9 @@

module SpecialIssueListBelongsToPolymorphicAppealConcern
extend ActiveSupport::Concern
include DecisionReviewPolymorphicHelper

included do
belongs_to :appeal, polymorphic: true

belongs_to :ama_appeal,
-> { where(special_issue_lists: { appeal_type: "Appeal" }) },
class_name: "Appeal", foreign_key: "appeal_id", optional: true

belongs_to :legacy_appeal,
-> { where(special_issue_lists: { appeal_type: "LegacyAppeal" }) },
class_name: "LegacyAppeal", foreign_key: "appeal_id", optional: true

scope :ama, -> { where(appeal_type: "Appeal") }
scope :legacy, -> { where(appeal_type: "LegacyAppeal") }
define_polymorphic_decision_review_associations(:appeal, :special_issue_lists, %w[Appeal LegacyAppeal])
end
end
26 changes: 4 additions & 22 deletions app/models/concerns/task_belongs_to_polymorphic_appeal_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,11 @@

module TaskBelongsToPolymorphicAppealConcern
extend ActiveSupport::Concern
include DecisionReviewPolymorphicHelper
include DecisionReviewPolymorphicSTIHelper

included do
belongs_to :appeal, polymorphic: true

belongs_to :ama_appeal,
-> { where(tasks: { appeal_type: "Appeal" }) },
class_name: "Appeal", foreign_key: "appeal_id", optional: true

belongs_to :legacy_appeal,
-> { where(tasks: { appeal_type: "LegacyAppeal" }) },
class_name: "LegacyAppeal", foreign_key: "appeal_id", optional: true

belongs_to :higher_level_review,
-> { where(tasks: { appeal_type: "HigherLevelReview" }) },
class_name: "HigherLevelReview", foreign_key: "appeal_id", optional: true

belongs_to :supplemental_claim,
-> { where(tasks: { appeal_type: "SupplementalClaim" }) },
class_name: "SupplementalClaim", foreign_key: "appeal_id", optional: true

scope :ama, -> { where(appeal_type: "Appeal") }
scope :legacy, -> { where(appeal_type: "LegacyAppeal") }
scope :higher_level_review, -> { where(appeal_type: "HigherLevelReview") }
scope :supplemental_claim, -> { where(appeal_type: "SupplementalClaim") }
define_polymorphic_decision_review_associations(:appeal, :tasks)
define_polymorphic_decision_review_sti_associations(:appeal, :tasks)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,9 @@

module VbmsUploadedDocumentBelongsToPolymorphicAppealConcern
extend ActiveSupport::Concern
include DecisionReviewPolymorphicHelper

included do
belongs_to :appeal, polymorphic: true

belongs_to :ama_appeal,
-> { where(vbms_uploaded_documents: { appeal_type: "Appeal" }) },
class_name: "Appeal", foreign_key: "appeal_id", optional: true

belongs_to :legacy_appeal,
-> { where(vbms_uploaded_documents: { appeal_type: "LegacyAppeal" }) },
class_name: "LegacyAppeal", foreign_key: "appeal_id", optional: true

scope :ama, -> { where(appeal_type: "Appeal") }
scope :legacy, -> { where(appeal_type: "LegacyAppeal") }
define_polymorphic_decision_review_associations(:appeal, :vbms_uploaded_documents, %w[Appeal LegacyAppeal])
end
end
33 changes: 25 additions & 8 deletions app/models/decision_issue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -250,14 +250,7 @@ def create_remand_supplemental_claim!
# Checking our assumption that approx_decision_date will always be populated for Decision Issues
fail "approx_decision_date is required to create a DTA Supplemental Claim" unless approx_decision_date

sc = SupplementalClaim.create!(
veteran_file_number: veteran_file_number,
decision_review_remanded: decision_review,
benefit_type: benefit_type,
legacy_opt_in_approved: decision_review.legacy_opt_in_approved,
veteran_is_not_claimant: decision_review.veteran_is_not_claimant,
receipt_date: approx_decision_date
)
sc = determine_remand_creation_type
fail AppealDTAPayeeCodeError, decision_review.id unless dta_payee_code

sc.create_claimant!(
Expand All @@ -273,4 +266,28 @@ def create_remand_supplemental_claim!
decision_review.update_error!("DTA SC creation failed")
raise
end

# Create a Remand if the decision review is an Appeal.
# HLRs will still create remands as SupplementalClaims as of (APPEALS-41559)
def determine_remand_creation_type
if decision_review_type == Appeal.name
Remand.create!(
veteran_file_number: veteran_file_number,
decision_review_remanded: decision_review,
benefit_type: benefit_type,
legacy_opt_in_approved: decision_review.legacy_opt_in_approved,
veteran_is_not_claimant: decision_review.veteran_is_not_claimant,
receipt_date: approx_decision_date
)
else
SupplementalClaim.create!(
veteran_file_number: veteran_file_number,
decision_review_remanded: decision_review,
benefit_type: benefit_type,
legacy_opt_in_approved: decision_review.legacy_opt_in_approved,
veteran_is_not_claimant: decision_review.veteran_is_not_claimant,
receipt_date: approx_decision_date
)
end
end
end
Loading

0 comments on commit 3c322cb

Please sign in to comment.