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

[CST] Modifies claim letter downloader to include a new field for a unified display description #19241

Merged
merged 9 commits into from
Nov 12, 2024
16 changes: 16 additions & 0 deletions lib/claim_letters/claim_letter_downloader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ module ClaimStatusTool
class ClaimLetterDownloader
FILENAME = 'ClaimLetter'
DEFAULT_ALLOWED_DOCTYPES = %w[184].freeze
DOCTYPE_TO_TYPE_DESCRIPTION = {
'27' => 'Board decision',
'34' => 'Request for specific evidence or information',
'184' => 'Claim decision (or other notification, like Intent to File)',
'408' => 'Notification: Exam with VHA has been scheduled',
'700' => 'Request for specific evidence or information',
'704' => 'List of evidence we may need ("5103 notice")',
'706' => 'List of evidence we may need ("5103 notice")',
'858' => 'List of evidence we may need ("5103 notice")',
'859' => 'Request for specific evidence or information',
'864' => 'Copy of request for medical records sent to a non-VA provider',
'942' => 'Final notification: Request for specific evidence or information',
'1605' => 'Copy of request for non-medical records sent to a non-VA organization'
}.freeze

def initialize(user, allowed_doctypes = DEFAULT_ALLOWED_DOCTYPES)
@user = user
Expand Down Expand Up @@ -79,6 +93,8 @@ def format_letter_data(docs)
# using marshal_dump here because each document is an OpenStruct
letters = docs.map { |d| filter_letters(d.marshal_dump) }.compact
letters = letters.select { |d| filter_boa_letters(d) }
# Issue 96224, consolidating letters' display names upstream
letters.each { |d| d[:type_description] = DOCTYPE_TO_TYPE_DESCRIPTION[d[:doc_type]] }
# TODO: (rare) Handle nil received_at
letters.sort_by { |d| d[:received_at] }.reverse
end
Expand Down
50 changes: 34 additions & 16 deletions spec/controllers/v0/claim_letters_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,24 @@
end
end

describe '#index when "cst_include_ddl_5103_letters", "cst_include_ddl_boa_letters",
and "cst_include_ddl_sqd_letters" feature flags are all enabled' do
before do
Flipper.enable(:cst_include_ddl_5103_letters)
Flipper.enable(:cst_include_ddl_boa_letters)
Flipper.enable(:cst_include_ddl_sqd_letters)
end

it 'lists correct documents' do
all_allowed_doctypes = %w[27 34 184 408 700 704 706 858 859 864 942 1605]
get(:index)
letters = JSON.parse(response.body)
allowed_letters = letters.select { |d| all_allowed_doctypes.include?(d['doc_type']) }

expect(allowed_letters.length).to eql(letters.length)
end
end

describe '#show' do
it 'responds with a pdf with a dated filename' do
get(:show, params: { document_id: })
Expand Down Expand Up @@ -132,37 +150,37 @@
message_type: 'ddl.doctypes_metadata',
document_type_metadata: contain_exactly(
{ doc_type: '27',
type_description: 'Board Of Appeals Decision Letter' },
type_description: 'Board decision' },
{ doc_type: '864',
type_description: 'General Records Request (Medical)' },
type_description: 'Copy of request for medical records sent to a non-VA provider' },
{ doc_type: '859',
type_description: 'Subsequent Development letter' },
type_description: 'Request for specific evidence or information' },
{ doc_type: '700',
type_description: 'MAP-D Development letter' },
type_description: 'Request for specific evidence or information' },
{ doc_type: '408',
type_description: 'VA Examination Letter' },
type_description: 'Notification: Exam with VHA has been scheduled' },
{ doc_type: '34',
type_description: 'Correspondence' },
type_description: 'Request for specific evidence or information' },
{ doc_type: '858',
type_description: 'Custom 5103 Notice' },
type_description: 'List of evidence we may need ("5103 notice")' },
{ doc_type: '1605',
type_description: 'General Records Request (Non-Medical)' },
type_description: 'Copy of request for non-medical records sent to a non-VA organization' },
{ doc_type: '942',
type_description: 'Final Attempt Letter' },
type_description: 'Final notification: Request for specific evidence or information' },
{ doc_type: '706',
type_description: '5103/DTA Letter' },
type_description: 'List of evidence we may need ("5103 notice")' },
{ doc_type: '184',
type_description: 'Notification Letter (e.g. VA 20-8993, VA 21-0290, PCGL)' },
type_description: 'Claim decision (or other notification, like Intent to File)' },
{ doc_type: '184',
type_description: 'Notification Letter (e.g. VA 20-8993, VA 21-0290, PCGL)' },
type_description: 'Claim decision (or other notification, like Intent to File)' },
{ doc_type: '184',
type_description: 'Notification Letter (e.g. VA 20-8993, VA 21-0290, PCGL)' },
type_description: 'Claim decision (or other notification, like Intent to File)' },
{ doc_type: '704',
type_description: 'Standard 5103 Notice' },
type_description: 'List of evidence we may need ("5103 notice")' },
{ doc_type: '184',
type_description: 'Notification Letter (e.g. VA 20-8993, VA 21-0290, PCGL)' },
type_description: 'Claim decision (or other notification, like Intent to File)' },
{ doc_type: '184',
type_description: 'Notification Letter (e.g. VA 20-8993, VA 21-0290, PCGL)' }
type_description: 'Claim decision (or other notification, like Intent to File)' }
))
end
end
Expand Down
31 changes: 31 additions & 0 deletions spec/lib/claim_status_tool/claim_letter_downloader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,35 @@
end
end
end

describe 'unifying letters display names in the api' do
let(:allowed_doctypes) { %w[27 34 184 408 700 704 706 858 859 864 942 1605] }
let(:type_description_map) do
{
'27' => 'Board decision',
'34' => 'Request for specific evidence or information',
'184' => 'Claim decision (or other notification, like Intent to File)',
'408' => 'Notification: Exam with VHA has been scheduled',
'700' => 'Request for specific evidence or information',
'704' => 'List of evidence we may need ("5103 notice")',
'706' => 'List of evidence we may need ("5103 notice")',
'858' => 'List of evidence we may need ("5103 notice")',
'859' => 'Request for specific evidence or information',
'864' => 'Copy of request for medical records sent to a non-VA provider',
'942' => 'Final notification: Request for specific evidence or information',
'1605' => 'Copy of request for non-medical records sent to a non-VA organization'
}
end

before do
@downloader = ClaimStatusTool::ClaimLetterDownloader.new(current_user, allowed_doctypes)
end

it 'gives each letter a `display_description` field' do
letters = @downloader.get_letters
letters.each do |letter|
expect(letter[:type_description]).to eq(type_description_map[letter[:doc_type]])
end
end
end
end
Loading