-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged together the remand feature branch with the reassign cases to …
…camo change history updates feature branch.
- Loading branch information
Showing
53 changed files
with
1,142 additions
and
359 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
29
app/models/concerns/decision_review_polymorphic_sti_helper.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.