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 49670 49667 phase ii release tested (#23257) #23269

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
"files.insertFinalNewline": true,
"files.trimTrailingWhitespace": true,
"git.autofetch": true,
"makefile.configureOnOpen": false,
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def decision_review_created

claim_id = drc_params[:claim_id]
headers = request.headers
consumer_and_claim_ids = { consumer_event_id: consumer_event_id, reference_id: claim_id }
consumer_and_claim_ids = { consumer_event_id: consumer_event_id, claim_id: claim_id }
::Events::DecisionReviewCreated.create!(consumer_and_claim_ids, headers, drc_params)
render json: { message: "DecisionReviewCreatedEvent successfully processed and backfilled" }, status: :created
rescue Caseflow::Error::RedisLockFailed => error
Expand Down Expand Up @@ -88,8 +88,10 @@ def drc_params
:contested_rating_issue_diagnostic_code,
:ramp_claim_id,
:rating_issue_associated_at,
:decision_review_issue_id,
:nonrating_issue_bgs_id,
:nonrating_issue_bgs_source])
:nonrating_issue_bgs_source,
:veteran_participant_id])
end
# rubocop:enable Metrics/MethodLength
end
117 changes: 117 additions & 0 deletions app/controllers/api/events/v1/decision_review_updated_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# frozen_string_literal: true

class Api::Events::V1::DecisionReviewUpdatedController < Api::ApplicationController
# Checks if API is disabled
before_action do
if FeatureToggle.enabled?(:disable_ama_eventing)
render json: {
errors: [
{
status: "501",
title: "API is disabled",
detail: "This endpoint is not supported."
}
]
},
status: :not_implemented
end
end

REQUEST_ISSUE_ATTRIBUTES = [
:original_caseflow_request_issue_id,
:contested_rating_decision_reference_id,
:contested_rating_issue_reference_id,
:contested_decision_issue_id,
:untimely_exemption,
:untimely_exemption_notes,
:edited_description,
:vacols_id,
:vacols_sequence_id,
:nonrating_issue_bgs_id,
:type,
:decision_review_issue_id,
:contention_reference_id,
:benefit_type,
:contested_issue_description,
:contested_rating_issue_profile_date,
:decision_date,
:ineligible_due_to_id,
:ineligible_reason,
:unidentified_issue_text,
:nonrating_issue_category,
:nonrating_issue_description,
:closed_at,
:closed_status,
:contested_rating_issue_diagnostic_code,
:rating_issue_associated_at,
:ramp_claim_id,
:is_unidentified,
:nonrating_issue_bgs_source,
:veteran_participant_id
].freeze

def decision_review_updated
consumer_event_id = dru_params[:event_id]
claim_id = dru_params[:claim_id]
headers = request.headers
consumer_and_claim_ids = { consumer_event_id: consumer_event_id, reference_id: claim_id }
::Events::DecisionReviewUpdated.update!(consumer_and_claim_ids, headers, dru_params)
render json: { message: "DecisionReviewUpdatedEvent successfully processed" }, status: :created
rescue Caseflow::Error::RedisLockFailed => error
render json: { message: error.message }, status: :conflict
rescue StandardError => error
render json: { message: error.message }, status: :unprocessable_entity
end

def decision_review_updated_error
event_id = dru_error_params[:event_id]
errored_claim_id = dru_error_params[:errored_claim_id]
error_message = dru_error_params[:error]
::Events::DecisionReviewUpdatedError.handle_service_error(event_id, errored_claim_id, error_message)
render json: { message: "Decision Review Updated Error Saved in Caseflow" }, status: :created
rescue Caseflow::Error::RedisLockFailed => error
render json: { message: error.message }, status: :conflict
rescue StandardError => error
render json: { message: error.message }, status: :unprocessable_entity
end

private

# rubocop:disable Metrics/MethodLength

def dru_error_params
params.permit(:event_id, :errored_claim_id, :error)
end

def dru_params
params.permit(
:event_id,
:claim_id,
:css_id,
:detail_type,
:station,
claim_review: [
:auto_remand,
:remand_source_id,
:informal_conference,
:same_office,
:legacy_opt_in_approved
],
end_product_establishment: [
:code,
:development_item_reference_id,
:reference_id,
:synced_status,
:last_synced_at
],
added_issues: REQUEST_ISSUE_ATTRIBUTES,
updated_issues: REQUEST_ISSUE_ATTRIBUTES,
removed_issues: REQUEST_ISSUE_ATTRIBUTES,
withdrawn_issues: REQUEST_ISSUE_ATTRIBUTES,
ineligible_to_eligible_issues: REQUEST_ISSUE_ATTRIBUTES,
eligible_to_ineligible_issues: REQUEST_ISSUE_ATTRIBUTES,
ineligible_to_ineligible_issues: REQUEST_ISSUE_ATTRIBUTES
)
end
# rubocop:enable Metrics/MethodLength
end
10 changes: 8 additions & 2 deletions app/models/claim_review.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class ClaimReview < DecisionReview

has_many :end_product_establishments, as: :source
has_many :messages, as: :detail
has_one :event_record, as: :evented_record
has_many :event_records, as: :evented_record
with_options if: :saving_review do
validate :validate_receipt_date
validate :validate_veteran
Expand Down Expand Up @@ -329,7 +329,13 @@ def cleared_end_products

def verify_contentions
# any open request_issues that have contention_reference_id pointers that no longer resolve should be removed.
request_issues.select(&:open?).select(&:contention_missing?).each(&:remove!)
# filter for only request issues that have a nil reference_id,
# this will filter out any request issues from AMA Event
request_issues
.select { |issue| issue.reference_id.nil? }
.select(&:open?)
.select(&:contention_missing?)
.each(&:remove!)
end

def incomplete_tasks?
Expand Down
5 changes: 5 additions & 0 deletions app/models/events/decision_review_updated_event.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

# This class represents the DecisionReviewUpdatedEvent info that is POSTED to Caseflow
class DecisionReviewUpdatedEvent < Event
end
1 change: 1 addition & 0 deletions app/models/events/event_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
class EventRecord < CaseflowRecord
belongs_to :event
belongs_to :evented_record, polymorphic: true
store_accessor :info

validate :valid_evented_record

Expand Down
2 changes: 1 addition & 1 deletion app/models/higher_level_review.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class HigherLevelReview < ClaimReview
end

has_many :remand_supplemental_claims, as: :decision_review_remanded, class_name: "SupplementalClaim"
has_one :event_record, as: :evented_record
has_many :event_records, as: :evented_record

attr_accessor :appeal_split_process

Expand Down
2 changes: 1 addition & 1 deletion app/models/legacy_issue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class LegacyIssue < CaseflowRecord
belongs_to :request_issue
has_one :legacy_issue_optin
has_one :event_record, as: :evented_record
has_many :event_records, as: :evented_record

validates :request_issue, presence: true

Expand Down
2 changes: 1 addition & 1 deletion app/models/legacy_issue_optin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class LegacyIssueOptin < CaseflowRecord
belongs_to :request_issue
belongs_to :legacy_issue
has_one :event_record, as: :evented_record
has_many :event_records, as: :evented_record

VACOLS_DISPOSITION_CODE = "O" # oh not zero
REMAND_DISPOSITION_CODES = %w[3 L].freeze
Expand Down
16 changes: 9 additions & 7 deletions app/models/request_issue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class RequestIssue < CaseflowRecord
has_one :legacy_issue_optin
has_many :legacy_issues
has_many :issue_modification_requests, dependent: :destroy
has_one :event_record, as: :evented_record
has_many :event_records, as: :evented_record
belongs_to :correction_request_issue, class_name: "RequestIssue", foreign_key: "corrected_by_request_issue_id"
belongs_to :ineligible_due_to, class_name: "RequestIssue", foreign_key: "ineligible_due_to_id"
belongs_to :contested_decision_issue, class_name: "DecisionIssue"
Expand All @@ -62,7 +62,8 @@ class RequestIssue < CaseflowRecord
appeal_to_higher_level_review: "appeal_to_higher_level_review",
before_ama: "before_ama",
legacy_issue_not_withdrawn: "legacy_issue_not_withdrawn",
legacy_appeal_not_eligible: "legacy_appeal_not_eligible"
legacy_appeal_not_eligible: "legacy_appeal_not_eligible",
contested: "contested"
}

enum closed_status: {
Expand Down Expand Up @@ -127,6 +128,7 @@ def initialize(request_issue_id)

class << self
# the umbrella term "rating" here is generalized to the type of EP it refers to.

def rating
rating_issue.or(rating_decision).or(unidentified)
end
Expand Down Expand Up @@ -202,7 +204,6 @@ def unidentified
def from_intake_data(data, decision_review: nil)
attrs = attributes_from_intake_data(data)
attrs = attrs.merge(decision_review: decision_review) if decision_review

new(attrs).tap(&:validate_eligibility!)
end

Expand All @@ -212,7 +213,6 @@ def from_intake_data(data, decision_review: nil)
def attributes_from_intake_data(data)
contested_issue_present = attributes_look_like_contested_issue?(data)
issue_text = (data[:is_unidentified] || data[:verified_unidentified_issue]) ? data[:decision_text] : nil

{
contested_rating_issue_reference_id: data[:rating_issue_reference_id],
contested_rating_issue_diagnostic_code: data[:rating_issue_diagnostic_code],
Expand Down Expand Up @@ -243,7 +243,8 @@ def attributes_from_intake_data(data)
mst_status_update_reason_notes: data[:mst_status_update_reason_notes],
pact_status: data[:pact_status],
vbms_pact_status: data[:vbms_pact_status],
pact_status_update_reason_notes: data[:pact_status_update_reason_notes]
pact_status_update_reason_notes: data[:pact_status_update_reason_notes],
reference_id: data[:reference_id]
}
end
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
Expand All @@ -264,7 +265,6 @@ def create_for_claim_review!(request_issues_update = nil)

epe = decision_review.end_product_establishment_for_issue(self, request_issues_update)
update!(end_product_establishment: epe) if epe

RequestIssueCorrectionCleaner.new(self).remove_dta_request_issue! if correction?
handle_legacy_issues!
end
Expand Down Expand Up @@ -633,6 +633,8 @@ def close!(status:, closed_at_value: Time.zone.now)
end

def close_if_ineligible!
return if reference_id.present?

close!(status: :ineligible) if ineligible_reason?
end

Expand Down Expand Up @@ -830,7 +832,7 @@ def remand_type
end

def title_of_active_review
duplicate_of_issue_in_active_review? ? ineligible_due_to.review_title : nil
duplicate_of_issue_in_active_review? ? ineligible_due_to&.review_title : nil
end

def handle_legacy_issues!
Expand Down
Loading
Loading