Skip to content

Commit

Permalink
Merge branch 'master' into Al/APPEALS-36565
Browse files Browse the repository at this point in the history
  • Loading branch information
almorbah authored Dec 21, 2023
2 parents 042a96d + 74be2b3 commit 46fe8a0
Show file tree
Hide file tree
Showing 12 changed files with 346 additions and 12 deletions.
85 changes: 85 additions & 0 deletions app/models/serializers/work_queue/appeal_search_serializer.rb
Original file line number Diff line number Diff line change
@@ -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
10 changes: 9 additions & 1 deletion app/models/serializers/work_queue/appeal_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?

Expand Down
100 changes: 100 additions & 0 deletions app/models/serializers/work_queue/legacy_appeal_search_serializer.rb
Original file line number Diff line number Diff line change
@@ -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
13 changes: 11 additions & 2 deletions app/services/appeal_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/workflows/case_search_results_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions client/app/queue/CaseList/CaseListActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
});
Expand Down
1 change: 0 additions & 1 deletion client/app/queue/CaseListView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ class CaseListView extends React.PureComponent {

<h3 className="cf-push-left" {...fullWidth}>{COPY.CASE_LIST_TABLE_TITLE}</h3>
<CaseListTable appeals={this.props.appeals} />

<h3 className="cf-push-left" {...fullWidth}>{COPY.OTHER_REVIEWS_TABLE_TITLE}</h3>
<OtherReviewsTable reviews={this.props.claimReviews} />
</div>
Expand Down
56 changes: 56 additions & 0 deletions client/app/queue/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ const prepareLocationHistoryForStore = (appeal) => {
return locationHistory;
};


export const prepareAppealForStore = (appeals) => {
const appealHash = appeals.reduce((accumulator, appeal) => {
const {
Expand Down Expand Up @@ -523,6 +524,61 @@ export const prepareAppealForStore = (appeals) => {
};
};

export const prepareAppealForSearchStore = (appeals) => {
const appealHash = appeals.reduce((accumulator, appeal) => {
const {
attributes: { issues },
} = appeal;

accumulator[appeal.attributes.external_id] = {
id: appeal.id,
externalId: appeal.attributes.external_id,
docketName: appeal.attributes.docket_name,
withdrawn: appeal.attributes.withdrawn,
overtime: appeal.attributes.overtime,
contestedClaim: appeal.attributes.contested_claim,
veteranAppellantDeceased: appeal.attributes.veteran_appellant_deceased,
withdrawalDate: formatDateStrUtc(appeal.attributes.withdrawal_date),
isLegacyAppeal: appeal.attributes.docket_name === 'legacy',
caseType: appeal.attributes.type,
isAdvancedOnDocket: appeal.attributes.aod,
issueCount: (appeal.attributes.docket_name === 'legacy' ?
getUndecidedIssues(issues) :
issues
).length,
docketNumber: appeal.attributes.docket_number,
distributedToJudge: appeal.attributes.distributed_to_a_judge,
veteranFullName: appeal.attributes.veteran_full_name,
veteranFileNumber: appeal.attributes.veteran_file_number,
vacateType: appeal.attributes.vacate_type,
};

return accumulator;
}, {});

const appealDetailsHash = appeals.reduce((accumulator, appeal) => {
accumulator[appeal.attributes.external_id] = {
hearings: prepareAppealHearingsForStore(appeal),
appellantFullName: appeal.attributes.appellant_full_name,
contestedClaim: appeal.attributes.contested_claim,
assignedToLocation: appeal.attributes.assigned_to_location,
veteranParticipantId: appeal.attributes.veteran_participant_id,
externalId: appeal.attributes.external_id,
status: appeal.attributes.status,
decisionDate: appeal.attributes.decision_date,
caseflowVeteranId: appeal.attributes.caseflow_veteran_id,
locationHistory: prepareLocationHistoryForStore(appeal),
};

return accumulator;
}, {});

return {
appeals: appealHash,
appealDetails: appealDetailsHash,
};
};

export const prepareClaimReviewForStore = (claimReviews) => {
const claimReviewHash = claimReviews.reduce((accumulator, claimReview) => {
const key = `${claimReview.review_type}-${claimReview.claim_id}`;
Expand Down
9 changes: 9 additions & 0 deletions client/constants/REGIONAL_OFFICE_FACILITY_ADDRESS.json
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,15 @@
"zip" : "39531",
"timezone" : "America/Chicago"
},
"vc_0742V" :{
"address_1" : "1118 Burlington Street",
"address_2" : null,
"address_3" : null,
"city" : "Holdrege",
"state" : "NE",
"zip" : "68949-1705",
"timezone" : "America/New_York"
},
"vha_402GA" : {
"address_1" : "163 Van Buren Road",
"address_2" : null,
Expand Down
2 changes: 1 addition & 1 deletion client/constants/REGIONAL_OFFICE_INFORMATION.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
"timezone": "America/New_York",
"hold_hearings": true,
"facility_locator_id": "vba_317",
"alternate_locations": ["vba_317a", "vc_0742V"]
"alternate_locations": ["vc_0742V"]
},
"RO18": {
"label": "Winston-Salem regional office",
Expand Down
Loading

0 comments on commit 46fe8a0

Please sign in to comment.