Skip to content

Commit

Permalink
Merge branch 'master' into 78699_block_csp_acr
Browse files Browse the repository at this point in the history
  • Loading branch information
bramleyjl authored Apr 16, 2024
2 parents 3db0969 + 46d4b66 commit d3ca827
Show file tree
Hide file tree
Showing 197 changed files with 5,792 additions and 2,585 deletions.
4 changes: 4 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ app/controllers/v0/appeals_controller.rb @department-of-veterans-affairs/benefit
app/controllers/v0/appointments_controller.rb @department-of-veterans-affairs/vfs-vaos @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/controllers/v0/apps_controller.rb @department-of-veterans-affairs/lighthouse-pivot
app/controllers/v0/ask_va @department-of-veterans-affairs/ask-va-team @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/controllers/v0/average_days_for_claim_completion_controller.rb @department-of-veterans-affairs/benefits-microservices @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/controllers/v0/backend_statuses_controller.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/controllers/v0/benefits_claims_controller.rb @department-of-veterans-affairs/benefits-management-tools-be @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/controllers/v0/benefits_documents_controller.rb @department-of-veterans-affairs/benefits-management-tools-be @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
Expand Down Expand Up @@ -194,6 +195,7 @@ app/models/async_transaction/base.rb @department-of-veterans-affairs/vfs-authent
app/models/async_transaction/va_profile @department-of-veterans-affairs/vfs-authenticated-experience-backend @department-of-veterans-affairs/vfs-authenticated-experience-backend @department-of-veterans-affairs/backend-review-group
app/models/async_transaction/vet360 @department-of-veterans-affairs/vfs-authenticated-experience-backend @department-of-veterans-affairs/backend-review-group
app/models/attachment.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/models/average_days_for_claim_completion.rb @department-of-veterans-affairs/benefits-microservices @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/models/backend_status.rb @department-of-veterans-affairs/backend-review-group
app/models/bank_name.rb @department-of-veterans-affairs/vfs-authenticated-experience-backend @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/models/base_facility.rb @department-of-veterans-affairs/vfs-facilities-frontend @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
Expand Down Expand Up @@ -995,6 +997,7 @@ spec/controllers/sign_in @department-of-veterans-affairs/octo-identity
spec/controllers/v0/account_controls_controller_spec.rb @department-of-veterans-affairs/octo-identity
spec/controllers/v0/apps_controller_spec.rb @department-of-veterans-affairs/lighthouse-pivot
spec/controllers/v0/ask_va @department-of-veterans-affairs/ask-va-team @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/controllers/v0/average_days_for_claim_completion_controller_spec.rb @department-of-veterans-affairs/benefits-microservices @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/controllers/v0/benefits_claims_controller_spec.rb @department-of-veterans-affairs/benefits-management-tools-be @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/controllers/v0/benefits_reference_data_controller_spec.rb @department-of-veterans-affairs/Benefits-Team-1 @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/controllers/v0/burial_claims_controller_spec.rb @department-of-veterans-affairs/mbs-core-team @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
Expand Down Expand Up @@ -1189,6 +1192,7 @@ spec/fixtures/pdf_fill/21-674 @department-of-veterans-affairs/Benefits-Team-1 @d
spec/fixtures/pdf_fill/21-8940 @department-of-veterans-affairs/Benefits-Team-1 @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/fixtures/pdf_fill/21P-527EZ @department-of-veterans-affairs/pensions @department-of-veterans-affairs/backend-review-group
spec/fixtures/pdf_fill/21P-530 @department-of-veterans-affairs/Benefits-Team-1 @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/fixtures/pdf_fill/21P-530V2 @department-of-veterans-affairs/Benefits-Team-1 @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/fixtures/pdf_fill/26-1880 @department-of-veterans-affairs/Benefits-Team-1 @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/fixtures/pdf_fill/28-1900 @department-of-veterans-affairs/Benefits-Team-1 @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/fixtures/pdf_fill/28-8832 @department-of-veterans-affairs/Benefits-Team-1 @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ GEM
multipart-post (~> 2)
faraday-net_http (3.1.0)
net-http
faraday-retry (2.2.0)
faraday-retry (2.2.1)
faraday (~> 2.0)
faraday-typhoeus (1.1.0)
faraday (~> 2.0)
Expand Down Expand Up @@ -890,7 +890,7 @@ GEM
rswag-ui (2.13.0)
actionpack (>= 3.1, < 7.2)
railties (>= 3.1, < 7.2)
rubocop (1.63.1)
rubocop (1.63.2)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
Expand Down
15 changes: 15 additions & 0 deletions app/controllers/v0/average_days_for_claim_completion_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

module V0
class AverageDaysForClaimCompletionController < ApplicationController
service_tag 'average-days-to-completion'
skip_before_action :authenticate, only: :index

def index
rtn = AverageDaysForClaimCompletion.order('created_at DESC').first
render json: {
average_days: rtn.present? ? rtn.average_days : -1.0
}
end
end
end
17 changes: 1 addition & 16 deletions app/controllers/v0/health_care_applications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class HealthCareApplicationsController < ApplicationController
service_tag 'healthcare-application'
FORM_ID = '1010ez'

skip_before_action(:authenticate, only: %i[create show enrollment_status healthcheck download_pdf facilities])
skip_before_action(:authenticate, only: %i[create show enrollment_status healthcheck facilities])

before_action :record_submission_attempt, only: :create
before_action :load_user, only: %i[create enrollment_status]
Expand Down Expand Up @@ -69,14 +69,6 @@ def healthcheck
render(json: HCA::Service.new.health_check)
end

def download_pdf
source_file_path = PdfFill::Filler.fill_form(health_care_application, SecureRandom.uuid, sign: false)
file_contents = File.read(source_file_path)
File.delete(source_file_path)

send_data file_contents, filename: file_name_for_pdf, type: 'application/pdf', disposition: 'attachment'
end

def facilities
render(json: lighthouse_facilities_service.get_facilities(lighthouse_facilities_params))
end
Expand Down Expand Up @@ -109,13 +101,6 @@ def lighthouse_facilities_params
)
end

def file_name_for_pdf
veteran_name = health_care_application.parsed_form.try(:[], 'veteranFullName')
first_name = veteran_name.try(:[], 'first') || 'First'
last_name = veteran_name.try(:[], 'last') || 'Last'
"10-10EZ_#{first_name}_#{last_name}.pdf"
end

def record_submission_attempt
StatsD.increment("#{HCA::Service::STATSD_KEY_PREFIX}.submission_attempt")
if health_care_application.short_form?
Expand Down
4 changes: 4 additions & 0 deletions app/models/average_days_for_claim_completion.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# frozen_string_literal: true

class AverageDaysForClaimCompletion < ApplicationRecord
end
1 change: 1 addition & 0 deletions app/sidekiq/kms_key_rotation/batch_initiator_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def gids_for_model(model, max_records_per_batch)

model
.where.not('encrypted_kms_key LIKE ?', "v#{KmsEncryptedModelPatch.kms_version}:%")
.or(model.where(encrypted_kms_key: nil))
.limit(max_records_per_batch)
.pluck(model.primary_key)
.map { |id| URI::GID.build(app: GlobalID.app, model_name: model.name, model_id: id).to_s }
Expand Down
3 changes: 2 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@
get(:enrollment_status)
get(:rating_info)
get(:facilities)
post(:download_pdf)
end
end

Expand Down Expand Up @@ -149,6 +148,8 @@
get 'claim_letters', to: 'claim_letters#index'
get 'claim_letters/:document_id', to: 'claim_letters#show'

get 'average_days_for_claim_completion', to: 'average_days_for_claim_completion#index'

get 'virtual_agent_claim_letters', to: 'virtual_agent_claim_letters#index'
get 'virtual_agent_claim_letters/:document_id', to: 'virtual_agent_claim_letters#show'

Expand Down
40 changes: 40 additions & 0 deletions db/migrate/20240411153910_create_accredited_individuals.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# frozen_string_literal: true

class CreateAccreditedIndividuals < ActiveRecord::Migration[7.1]
def change
create_table :accredited_individuals, id: :uuid do |t|
t.uuid :ogc_id, null: false
t.string :registration_number, null: false
t.string :poa_code, limit: 3, index: true
t.string :individual_type, null: false
t.string :first_name
t.string :middle_initial
t.string :last_name
t.string :full_name, index: true
t.string :email
t.string :phone
t.string :address_type
t.string :address_line1
t.string :address_line2
t.string :address_line3
t.string :city
t.string :country_code_iso3
t.string :country_name
t.string :county_name
t.string :county_code
t.string :international_postal_code
t.string :province
t.string :state_code
t.string :zip_code
t.string :zip_suffix
t.jsonb :raw_address
t.float :lat
t.float :long
t.geography :location, limit: { srid: 4326, type: 'st_point', geographic: true }
t.timestamps

t.index :location, using: :gist
t.index %i[ registration_number individual_type ], name: 'index_on_reg_num_and_type_for_accredited_individuals', unique: true
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
class CreateAverageDaysForClaimCompletions < ActiveRecord::Migration[7.1]
def change
create_table :average_days_for_claim_completions do |t|
t.float average_days
t.float :average_days

t.timestamps
end
Expand Down
37 changes: 37 additions & 0 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

132 changes: 132 additions & 0 deletions lib/lighthouse/benefits_intake/metadata.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# frozen_string_literal: true

module BenefitsIntake
##
# Validate the required metadata which must accompany an upload:
#
# {
# 'veteranFirstName': String,
# 'veteranLastName': String,
# 'fileNumber': String, # 8-9 digits
# 'zipCode': String, # 5 or 9 digits
# 'source': String,
# 'docType': String,
# 'businessLine': String, # optional; enum in BUSINESS_LINE
# }
#
# https://developer.va.gov/explore/api/benefits-intake/docs
#
class Metadata
BUSINESS_LINE = {
CMP: 'Compensation requests such as those related to disability, unemployment, and pandemic claims',
PMC: 'Pension requests including survivor’s pension',
INS: 'Insurance such as life insurance, disability insurance, and other health insurance',
EDU: 'Education benefits, programs, and affiliations',
VRE: 'Veteran Readiness & Employment such as employment questionnaires, ' \
'employment discrimination, employment verification',
BVA: 'Board of Veteran Appeals',
FID: 'Fiduciary / financial appointee, including family member benefits',
NCA: 'National Cemetery Administration',
OTH: 'Other (this value if used, will be treated as CMP)'
}.freeze

# rubocop:disable Metrics/ParameterLists
def self.generate(first_name, last_name, file_number, zip_code, source, doc_type, business_line = nil)
validate({
'veteranFirstName' => first_name,
'veteranLastName' => last_name,
'fileNumber' => file_number,
'zipCode' => zip_code,
'source' => source,
'docType' => doc_type,
'businessLine' => business_line
})
end
# rubocop:enable Metrics/ParameterLists

def self.validate(metadata)
validate_first_name(metadata)
.then { |m| validate_last_name(m) }
.then { |m| validate_file_number(m) }
.then { |m| validate_zip_code(m) }
.then { |m| validate_source(m) }
.then { |m| validate_doc_type(m) }
.then { |m| validate_business_line(m) }
end

def self.validate_first_name(metadata)
validate_presence_and_stringiness(metadata['veteranFirstName'], 'veteran first name')

first_name = I18n.transliterate(metadata['veteranFirstName']).gsub(%r{[^a-zA-Z\-\/\s]}, '').strip.first(50)
validate_nonblank(first_name, 'veteran first name')

metadata['veteranFirstName'] = first_name
metadata
end

def self.validate_last_name(metadata)
validate_presence_and_stringiness(metadata['veteranLastName'], 'veteran last name')

last_name = I18n.transliterate(metadata['veteranLastName']).gsub(%r{[^a-zA-Z\-\/\s]}, '').strip.first(50)
validate_nonblank(last_name, 'veteran last name')

metadata['veteranLastName'] = last_name
metadata
end

def self.validate_file_number(metadata)
validate_presence_and_stringiness(metadata['fileNumber'], 'file number')
unless metadata['fileNumber'].match?(/^\d{8,9}$/)
raise ArgumentError, 'file number is invalid. It must be 8 or 9 digits'
end

metadata
end

def self.validate_zip_code(metadata)
validate_presence_and_stringiness(metadata['zipCode'], 'zip code')

zip_code = metadata['zipCode'].dup.gsub(/[^0-9]/, '')
zip_code.insert(5, '-') if zip_code.match?(/\A[0-9]{9}\z/)
zip_code = '00000' unless zip_code.match?(/\A[0-9]{5}(-[0-9]{4})?\z/)

metadata['zipCode'] = zip_code

metadata
end

def self.validate_source(metadata)
validate_presence_and_stringiness(metadata['source'], 'source')

metadata
end

def self.validate_doc_type(metadata)
validate_presence_and_stringiness(metadata['docType'], 'doc type')

metadata
end

def self.validate_business_line(metadata)
bl = metadata['businessLine']
if bl
bl = bl.dup.to_s.upcase.to_sym
bl = :OTH unless BUSINESS_LINE.key?(bl)
metadata['businessLine'] = bl.to_s
else
metadata.delete('businessLine')
end

metadata
end

def self.validate_presence_and_stringiness(value, error_label)
raise ArgumentError, "#{error_label} is missing" unless value
raise ArgumentError, "#{error_label} is not a string" if value.class != String
end

def self.validate_nonblank(value, error_label)
raise ArgumentError, "#{error_label} is blank" if value.blank?
end
end
end
2 changes: 0 additions & 2 deletions lib/pdf_fill/filler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
require 'pdf_fill/forms/va210781'
require 'pdf_fill/forms/va218940'
require 'pdf_fill/forms/va1010cg'
require 'pdf_fill/forms/va1010ez'
require 'pdf_fill/forms/va686c674'
require 'pdf_fill/forms/va281900'
require 'pdf_fill/forms/va288832'
Expand All @@ -32,7 +31,6 @@ module Filler
'21-0781' => PdfFill::Forms::Va210781,
'21-8940' => PdfFill::Forms::Va218940,
'10-10CG' => PdfFill::Forms::Va1010cg,
'10-10EZ' => PdfFill::Forms::Va1010ez,
'686C-674' => PdfFill::Forms::Va686c674,
'28-1900' => PdfFill::Forms::Va281900,
'28-8832' => PdfFill::Forms::Va288832,
Expand Down
Loading

0 comments on commit d3ca827

Please sign in to comment.