diff --git a/app/models/serializers/work_queue/appeal_search_serializer.rb b/app/models/serializers/work_queue/appeal_search_serializer.rb new file mode 100644 index 00000000000..d72ff4547a8 --- /dev/null +++ b/app/models/serializers/work_queue/appeal_search_serializer.rb @@ -0,0 +1,85 @@ +# frozen_string_literal: true + +class WorkQueue::AppealSearchSerializer + include FastJsonapi::ObjectSerializer + extend Helpers::AppealHearingHelper + + set_type :appeal + + attribute :contested_claim, &:contested_claim? + + attribute :issues do |object| + object.request_issues.active_or_decided_or_withdrawn.includes(:remand_reasons).map do |issue| + { + id: issue.id, + program: issue.benefit_type, + description: issue.description, + notes: issue.notes, + diagnostic_code: issue.contested_rating_issue_diagnostic_code, + remand_reasons: issue.remand_reasons, + closed_status: issue.closed_status, + decision_date: issue.decision_date + } + end + end + + attribute :status + + attribute(:hearings) do |object, params| + # For substitution appeals after death dismissal, we need to show hearings from the source appeal + # in addition to those on the new/target appeal; this avoids copying them to new appeal stream + associated_hearings = [] + + if object.separate_appeal_substitution? + associated_hearings = hearings(object.appellant_substitution.source_appeal, params) + end + + associated_hearings + hearings(object, params) + end + + attribute :withdrawn, &:withdrawn? + + attribute :removed, &:removed? + + attribute :overtime, &:overtime? + + attribute :veteran_appellant_deceased, &:veteran_appellant_deceased? + + attribute :assigned_to_location + + attribute :distributed_to_a_judge, &:distributed_to_a_judge? + + attribute :appellant_full_name do |object| + object.claimant&.name + end + + attribute :veteran_death_date + + attribute :veteran_file_number + + attribute :veteran_full_name do |object| + object.veteran ? object.veteran.name.formatted(:readable_full) : "Cannot locate" + end + + attribute :external_id, &:uuid + + attribute :type + attribute :vacate_type + attribute :aod, &:advanced_on_docket? + attribute :docket_name + attribute :docket_number + attribute :docket_range_date + attribute :decision_date + attribute :nod_date, &:receipt_date + attribute :withdrawal_date + + attribute :caseflow_veteran_id do |object| + object.veteran ? object.veteran.id : nil + end + + attribute :docket_switch do |object| + if object.docket_switch + WorkQueue::DocketSwitchSerializer.new(object.docket_switch).serializable_hash[:data][:attributes] + end + end +end diff --git a/app/models/serializers/work_queue/appeal_serializer.rb b/app/models/serializers/work_queue/appeal_serializer.rb index bfa23c51fe4..62409533333 100644 --- a/app/models/serializers/work_queue/appeal_serializer.rb +++ b/app/models/serializers/work_queue/appeal_serializer.rb @@ -103,7 +103,15 @@ class WorkQueue::AppealSerializer attribute :veteran_appellant_deceased, &:veteran_appellant_deceased? - attribute :assigned_to_location + attribute :assigned_to_location do |object, params| + if object&.status&.status == :distributed_to_judge + if params[:user]&.judge? || params[:user]&.attorney? || User.list_hearing_coordinators.include?(params[:user]) + object.assigned_to_location + end + else + object.assigned_to_location + end + end attribute :distributed_to_a_judge, &:distributed_to_a_judge? diff --git a/app/models/serializers/work_queue/legacy_appeal_search_serializer.rb b/app/models/serializers/work_queue/legacy_appeal_search_serializer.rb new file mode 100644 index 00000000000..7cd374f20e6 --- /dev/null +++ b/app/models/serializers/work_queue/legacy_appeal_search_serializer.rb @@ -0,0 +1,100 @@ +# frozen_string_literal: true + +class WorkQueue::LegacyAppealSearchSerializer + include FastJsonapi::ObjectSerializer + extend Helpers::AppealHearingHelper + + set_type :legacy_appeal + + attribute :assigned_attorney + attribute :assigned_judge + + attribute :issues do |object| + object.issues.map do |issue| + WorkQueue::LegacyIssueSerializer.new(issue).serializable_hash[:data][:attributes] + end + end + + attribute :hearings do |object, params| + hearings(object, params) + end + + attribute :completed_hearing_on_previous_appeal? + + attribute :appellant_is_not_veteran, &:appellant_is_not_veteran + + attribute :appellant_full_name, &:appellant_name + + attribute :appellant_address, &:appellant_address + + attribute :appellant_tz, &:appellant_tz + + attribute :appellant_relationship + attribute :assigned_to_location + attribute :vbms_id, &:sanitized_vbms_id + attribute :veteran_full_name + attribute :veteran_death_date + attribute :veteran_appellant_deceased, &:veteran_appellant_deceased? + # Aliasing the vbms_id to make it clear what we're returning. + attribute :veteran_file_number, &:sanitized_vbms_id + attribute :veteran_participant_id do |object| + object&.veteran&.participant_id + end + attribute :efolder_link do + ENV["CLAIM_EVIDENCE_EFOLDER_BASE_URL"] + end + attribute :external_id, &:vacols_id + attribute :type + attribute :aod + attribute :docket_number + attribute :docket_range_date, &:docket_date + attribute :status + attribute :decision_date + attribute :form9_date + attribute :nod_date + attribute :certification_date + attribute :paper_case, &:paper_case? + attribute :overtime, &:overtime? + attribute :caseflow_veteran_id do |object| + object.veteran ? object.veteran.id : nil + end + + attribute(:available_hearing_locations) { |object| available_hearing_locations(object) } + + attribute :docket_name do + "legacy" + end + + attribute :document_id do |object| + latest_vacols_attorney_case_review(object)&.document_id + end + + attribute :can_edit_document_id do |object, params| + LegacyDocumentIdPolicy.new( + user: params[:user], + case_review: latest_vacols_attorney_case_review(object) + ).editable? + end + + attribute :attorney_case_review_id do |object| + latest_vacols_attorney_case_review(object)&.vacols_id + end + + attribute :current_user_email do |_, params| + params[:user]&.email + end + + attribute :current_user_timezone do |_, params| + params[:user]&.timezone + end + + attribute :location_history do |object| + object.location_history.map do |location| + WorkQueue::PriorlocSerializer.new(location).serializable_hash[:data][:attributes] + end + end + + def self.latest_vacols_attorney_case_review(object) + VACOLS::CaseAssignment.latest_task_for_appeal(object.vacols_id) + end +end diff --git a/app/services/appeal_finder.rb b/app/services/appeal_finder.rb index 30829666e7c..30e586b0798 100644 --- a/app/services/appeal_finder.rb +++ b/app/services/appeal_finder.rb @@ -8,12 +8,21 @@ def find_appeals_with_file_numbers(file_numbers) MetricsService.record("VACOLS: Get appeal information for file_numbers #{file_numbers}", service: :queue, name: "VeteranFinderQuery.find_appeals_with_file_numbers") do - appeals = Appeal.established.where(veteran_file_number: file_numbers).to_a + ## appeals = Appeal.established.where(veteran_file_number: file_numbers).to_a + ama_appeals = Appeal.established + .includes(:docket_switch, :available_hearing_locations, :tasks, :work_mode, + :request_issues, :hearings, :appellant_substitution, :nod_date_updates, + :decision_issues) + .where(veteran_file_number: file_numbers) + .to_a begin - appeals.concat(LegacyAppeal.fetch_appeals_by_file_number(*file_numbers)) + legacy_appeals = LegacyAppeal.fetch_appeals_by_file_number(*file_numbers) rescue ActiveRecord::RecordNotFound # file number could not be found. don't raise exception and not return, just ignore. + legacy_appeals = [] end + appeals = ama_appeals + legacy_appeals + appeals end end diff --git a/app/workflows/case_search_results_base.rb b/app/workflows/case_search_results_base.rb index 46f05c018ee..81e4f3a224d 100644 --- a/app/workflows/case_search_results_base.rb +++ b/app/workflows/case_search_results_base.rb @@ -60,11 +60,11 @@ def veterans_user_can_access def json_appeals(appeals) ama_appeals, legacy_appeals = appeals.partition { |appeal| appeal.is_a?(Appeal) } - ama_hash = WorkQueue::AppealSerializer.new( + ama_hash = WorkQueue::AppealSearchSerializer.new( ama_appeals, is_collection: true, params: { user: user } ).serializable_hash - legacy_hash = WorkQueue::LegacyAppealSerializer.new( + legacy_hash = WorkQueue::LegacyAppealSearchSerializer.new( legacy_appeals, is_collection: true, params: { user: user } ).serializable_hash diff --git a/client/app/queue/CaseList/CaseListActions.js b/client/app/queue/CaseList/CaseListActions.js index b9d7b8d82ec..8a9264b3edc 100644 --- a/client/app/queue/CaseList/CaseListActions.js +++ b/client/app/queue/CaseList/CaseListActions.js @@ -4,7 +4,7 @@ import * as Constants from './actionTypes'; import { get, size } from 'lodash'; import { onReceiveAppealDetails, onReceiveClaimReviewDetails } from '../QueueActions'; -import { prepareAppealForStore, prepareClaimReviewForStore } from '../utils'; +import { prepareAppealForStore, prepareAppealForSearchStore, prepareClaimReviewForStore } from '../utils'; import ValidatorsUtil from '../../util/ValidatorsUtil'; const { validSSN, validFileNum, validDocketNum } = ValidatorsUtil; @@ -54,7 +54,7 @@ export const fetchedNoAppeals = (searchQuery) => ({ }); export const onReceiveAppeals = (appeals) => (dispatch) => { - dispatch(onReceiveAppealDetails(prepareAppealForStore(appeals))); + dispatch(onReceiveAppealDetails(prepareAppealForSearchStore(appeals))); dispatch({ type: Constants.RECEIVED_APPEALS_USING_VETERAN_ID_SUCCESS }); diff --git a/client/app/queue/CaseListView.jsx b/client/app/queue/CaseListView.jsx index a01a23b83a4..0f951cdbdc2 100644 --- a/client/app/queue/CaseListView.jsx +++ b/client/app/queue/CaseListView.jsx @@ -105,7 +105,6 @@ class CaseListView extends React.PureComponent {