Skip to content

Commit

Permalink
Show disabilities with rating ID unless duplicate (#15317)
Browse files Browse the repository at this point in the history
connects #15292

## Description
Shows disability issues before receipt date with rating issue reference IDs unless those IDs are found in the list of rating issues.

This is related to this [batteam Slack thread.](https://dsva.slack.com/archives/CHX8FMP28/p1599760570192000)

### Acceptance Criteria
- [x] Remove the `contestable?` method on RatingDecision
- [x] In the ContestableIssueGenerator, select RatingDecisions where rating_issue_reference_id is nil, or where it is present but not found in the `rating_issues`

### Testing Plan
1. Automated tests
  • Loading branch information
leikkisa authored Sep 29, 2020
1 parent 3642b8e commit 0cf9233
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 63 deletions.
8 changes: 0 additions & 8 deletions app/models/rating_decision.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,6 @@ def decision_date
promulgation_date
end

def contestable?
!rating_issue?
end

def rating_issue?
rating_issue_reference_id.present?
end

def reference_id
disability_id
end
Expand Down
9 changes: 7 additions & 2 deletions app/workflows/contestable_issue_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def contestable_rating_decisions
return from_rating_decisions if FeatureToggle.enabled?(:disability_issue_test, user: RequestStore[:current_user])
return [] unless FeatureToggle.enabled?(:contestable_rating_decisions, user: RequestStore[:current_user])

from_rating_decisions.reject { |contestable_issue| decision_issue_duplicate_exists?(contestable_issue) }
from_rating_decisions.reject { |contestable_issue| rating_issue_duplicate_exists?(contestable_issue) }
end

def from_ratings
Expand All @@ -66,7 +66,6 @@ def from_rating_decisions
# rating decisions are a superset of every disability ever recorded for a veteran,
# so filter out any that are duplicates of a rating issue or that are not related to their parent rating.
rating_decisions
.select(&:contestable?)
.select { |rating_decision| rating_decision.profile_date && rating_decision.profile_date.to_date <= receipt_date }
.map { |rating_decision| ContestableIssue.from_rating_decision(rating_decision, review) }
end
Expand All @@ -85,6 +84,12 @@ def rating_hash_deserialize(from:, to:)
end
end

def rating_issue_duplicate_exists?(contestable_issue)
contestable_rating_issues.any? do |potential_duplicate|
contestable_issue.rating_issue_reference_id == potential_duplicate.rating_issue_reference_id
end
end

def decision_issue_duplicate_exists?(contestable_issue)
contestable_decision_issues.any? do |potential_duplicate|
contestable_issue.rating_issue_reference_id == potential_duplicate.rating_issue_reference_id
Expand Down
48 changes: 0 additions & 48 deletions spec/models/rating_decision_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@
before do
Time.zone = "UTC"
Timecop.freeze(Time.utc(2015, 1, 1, 12, 0, 0))

FeatureToggle.enable!(:contestable_rating_decisions)
end

after do
FeatureToggle.disable!(:contestable_rating_decisions)
end

let(:profile_date) { Time.zone.today - 40 }
Expand Down Expand Up @@ -170,48 +164,6 @@
end
end

describe "#contestable?" do
subject { described_class.from_bgs_disability(rating, bgs_record).contestable? }

context "rating_issue? is true" do
it { is_expected.to eq(false) }
end

context "rating_issue? is false" do
let(:rating_issue_reference_id) { nil }

context "promulgation date and original_denial_date are close" do
it { is_expected.to eq(true) }
end

context "promulgation date, profile date and disability_date are not close" do
let(:disability_date) { promulgation_date + 6.months }

it { is_expected.to eq(true) }
end

context "profile date and disability date are close, promulgation date is not close" do
let(:promulgation_date) { disability_date + 6.months }

it { is_expected.to eq(true) }
end

context "profile date is near original_denial_date but not promulgation date" do
let(:original_denial_date) { promulgation_date - 6.months }
let(:profile_date) { promulgation_date - 6.months + 3.days }

it { is_expected.to eq(true) }
end

context "original_denial_date is pre-2005, disability date is near promulgation date" do
let(:original_denial_date) { Time.utc(2004, 1, 1, 12, 0, 0) }
let(:disability_date) { promulgation_date - 7.days }

it { is_expected.to eq(true) }
end
end
end

describe "#effective_date" do
context "decision is not a rating issue" do
let(:rating_issue_reference_id) { nil }
Expand Down
75 changes: 70 additions & 5 deletions spec/workflows/contestable_issue_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,75 @@
let(:hlr) { create(:higher_level_review, veteran_file_number: veteran.file_number) }
let(:review) { hlr }
let(:veteran) { create(:veteran) }
let(:past_decision_date) { review.receipt_date - 1.day }
let!(:past_rating) do
Generators::PromulgatedRating.build(
participant_id: veteran.participant_id,
promulgation_date: review.receipt_date - 1.day,
profile_date: review.receipt_date - 1.day,
promulgation_date: past_decision_date,
profile_date: past_decision_date,
issues: [
{ reference_id: "abc123", decision_text: "Rating issue" }
],
decisions: [
{
rating_issue_reference_id: nil,
original_denial_date: past_decision_date,
diagnostic_text: "Right arm broken",
diagnostic_type: "Bone",
disability_id: "123",
disability_date: past_decision_date,
type_name: "Not Service Connected"
},
{
rating_issue_reference_id: "abc123",
original_denial_date: past_decision_date,
diagnostic_text: "Left arm broken",
diagnostic_type: "Bone",
disability_id: "456",
disability_date: past_decision_date,
type_name: "Not Service Connected"
},
{
rating_issue_reference_id: "disability_with_new_rating_issue_id",
original_denial_date: past_decision_date,
diagnostic_text: "Pinky toe broken",
diagnostic_type: "Bone",
disability_id: "123456",
disability_date: past_decision_date,
type_name: "Not Service Connected"
}
]
)
end

let(:future_decision_date) { review.receipt_date + 5.days }
let!(:future_rating) do
Generators::PromulgatedRating.build(
participant_id: veteran.participant_id,
promulgation_date: review.receipt_date + 5.days,
profile_date: review.receipt_date + 5.days,
promulgation_date: future_decision_date,
profile_date: future_decision_date,
issues: [
{ reference_id: "abc123", decision_text: "Future Rating issue" }
{ reference_id: "xyz123", decision_text: "Future Rating issue" }
],
decisions: [
{
rating_issue_reference_id: nil,
original_denial_date: future_decision_date,
diagnostic_text: "Right leg broken",
diagnostic_type: "Bone",
disability_id: "666001234",
disability_date: future_decision_date,
type_name: "Not Service Connected"
},
{
rating_issue_reference_id: "xyz123",
original_denial_date: future_decision_date,
diagnostic_text: "Left leg broken",
diagnostic_type: "Bone",
disability_id: "4567",
disability_date: future_decision_date,
type_name: "Not Service Connected"
}
]
)
end
Expand Down Expand Up @@ -83,6 +134,20 @@
end
end

context "when the contestable_rating_decisions Feature Toggle is enabled" do
before { FeatureToggle.enable!(:contestable_rating_decisions) }
after { FeatureToggle.disable!(:contestable_rating_decisions) }

it "returns rating decisions that are not present in rating issues" do
expect(subject.count).to eq(5)
descriptions = subject.map(&:description)
expect(descriptions.grep(/Pinky toe/).count).to eq 1
expect(descriptions.grep(/Right arm/).count).to eq 1
expect(descriptions.grep(/Left arm/).count).to eq 0
expect(descriptions.grep(/leg/).count).to eq 0
end
end

context "when the review is a remand supplemental claim" do
let(:review) do
create(
Expand Down

0 comments on commit 0cf9233

Please sign in to comment.