Skip to content

Commit

Permalink
Ndbex 70721 map form fields (#15838)
Browse files Browse the repository at this point in the history
* initial commit, add 530ez to repo

* replace with new version

* setup copies of 530 to prep for 530ez

* setup tentative keys for veteran info

* wip: updated fields for pages 1 and 2

* small changes, swapped forms

* slight changes

* renaming

* prepare to toggle on form id

* temporarily point at other branch

* version 2 toggle

* change to formV2

* update schema ref

* experiment to get formV2

* update api to receive 21p-530v2, maintain form_id throughout process for burial and in progress forms

* updated hash for temp branch

* temporary update to schema ref

* mapped a new pdf, small field updates

* fix pdf telephone field. begin mapping values

* relationship to veteran and final resting place

* updates to pdf and methods filling in values

* update schema ref

* combine previous names and service

* more pdf fill work

* flipper for controller and model

* fix lettering

* update schema ref

* small updates

* fix overflow for both suffix fields and international phone number. add new test, tests still wip

* unit tests

* process option

* rubocop

* remove flipper check that interferes with other claim types

* update with process option

* better error handling for parse

---------

Co-authored-by: Thomas Blackwell <[email protected]>
  • Loading branch information
evansmith and tblackwe authored Mar 26, 2024
1 parent 58d8519 commit 5761817
Show file tree
Hide file tree
Showing 19 changed files with 1,151 additions and 11 deletions.
12 changes: 9 additions & 3 deletions app/controllers/v0/burial_claims_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,24 @@ class BurialClaimsController < ClaimsBaseController

def create
PensionBurial::TagSentry.tag_sentry
claim = claim_class.new(form: filtered_params[:form])

claim = if Flipper.enabled?(:va_burial_v2)
# cannot parse a nil form, to pass unit tests do a check for form presence
form = filtered_params[:form]
claim_class.new(form:, formV2: form.present? ? JSON.parse(form)['formV2'] : nil)
else
claim_class.new(form: filtered_params[:form])
end

unless claim.save
StatsD.increment("#{stats_key}.failure")
Sentry.set_tags(team: 'benefits-memorial-1') # tag sentry logs with team name
raise Common::Exceptions::ValidationErrors, claim
end

# this method also calls claim.process_attachments!
claim.submit_to_structured_data_services!

Rails.logger.info "ClaimID=#{claim.confirmation_number} Form=#{claim.class::FORM}"
Rails.logger.info "ClaimID=#{claim.confirmation_number} Form=#{claim.form_id}"
clear_saved_form(claim.form_id)
render(json: claim)
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/v0/claim_documents_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def create

def klass
case form_id
when '21P-527EZ', '21P-530'
when '21P-527EZ', '21P-530', '21P-530V2'
PensionBurial::TagSentry.tag_sentry
PersistentAttachments::PensionBurial
when '21-686C', '686C-674'
Expand Down
3 changes: 2 additions & 1 deletion app/models/form_profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class FormProfile
22-5495 22-0993 22-0994 FEEDBACK-TOOL 22-10203 22-1990S 22-1990EZ],
evss: ['21-526EZ'],
hca: %w[1010ez 10-10EZR],
pension_burial: %w[21P-530 21P-527EZ],
pension_burial: %w[21P-530 21P-527EZ 21P-530V2],
dependents: ['686C-674'],
decision_review: %w[20-0995 20-0996 10182],
mdot: ['MDOT'],
Expand Down Expand Up @@ -121,6 +121,7 @@ class FormProfile
'22-5490E' => ::FormProfiles::VA5490e,
'22-5495' => ::FormProfiles::VA5495,
'21P-530' => ::FormProfiles::VA21p530,
'21P-530V2' => ::FormProfiles::VA21p530v2,
'21-686C' => ::FormProfiles::VA21686c,
'686C-674' => ::FormProfiles::VA686c674,
'40-10007' => ::FormProfiles::VA4010007,
Expand Down
33 changes: 33 additions & 0 deletions app/models/form_profiles/va_21p530v2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# frozen_string_literal: true

require 'iso_country_codes'

class FormProfiles::VA21p530v2 < FormProfile
def metadata
{
version: 0,
prefill: true,
returnUrl: '/claimant-information'
}
end

def prefill
@identity_information = initialize_identity_information
@contact_information = initialize_contact_information
if @contact_information&.address&.country.present?
@contact_information.address.country = convert_to_iso2(@contact_information.address.country)
end
mappings = self.class.mappings_for_form(form_id)

form_data = generate_prefill(mappings) if FormProfile.prefill_enabled_forms.include?(form_id)

{ form_data:, metadata: }
end

private

def convert_to_iso2(country_code)
code = IsoCountryCodes.find(country_code)
code.alpha2
end
end
4 changes: 2 additions & 2 deletions app/models/saved_claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class SavedClaim < ApplicationRecord
# create a uuid for this second (used in the confirmation number) and store
# the form type based on the constant found in the subclass.
after_initialize do
self.form_id = self.class::FORM.upcase
self.form_id = self.class::FORM.upcase unless instance_of?(SavedClaim::Burial)
end

def self.add_form_and_validation(form_id)
Expand All @@ -51,7 +51,7 @@ def process_attachments!

def submit_to_structured_data_services!
# Only 21P-530 burial forms are supported at this time
if form_id != '21P-530'
unless %w[21P-530 21P-530V2].include?(form_id)
err_message = "Unsupported form id: #{form_id}"
raise Common::Exceptions::UnprocessableEntity.new(detail: err_message), err_message
end
Expand Down
19 changes: 19 additions & 0 deletions app/models/saved_claim/burial.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@
class SavedClaim::Burial < CentralMailClaim
FORM = '21P-530'

# attribute name is passed from the FE as a flag, maintaining camel case
attr_accessor :formV2 # rubocop:disable Naming/MethodName

after_initialize do
self.form_id = if Flipper.enabled?(:va_burial_v2)
formV2 || form_id == '21P-530V2' ? '21P-530V2' : self.class::FORM.upcase
else
self.class::FORM.upcase
end
end

def process_attachments!
refs = attachment_keys.map { |key| Array(open_struct_form.send(key)) }.flatten
files = PersistentAttachment.where(guid: refs.map(&:confirmationCode))
Expand All @@ -25,6 +36,14 @@ def email
parsed_form['claimantEmail']
end

def form_matches_schema
return unless form_is_string

JSON::Validator.fully_validate(VetsJsonSchema::SCHEMAS[form_id], parsed_form).each do |v|
errors.add(:form, v.to_s)
end
end

def business_line
'NCA'
end
Expand Down
3 changes: 1 addition & 2 deletions app/sidekiq/structured_data/process_data_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ def perform(saved_claim_id)
ensure
@claim.process_attachments! # upload claim and attachments to Central Mail

send_confirmation_email if @claim.form_id == '21P-530'

send_confirmation_email if %w[21P-530 21P-530V2].include?(@claim.form_id)
# veteran lookup for hit/miss metrics in support of Automation work
StatsD.increment("#{stats_key}.success",
tags: %W[relationship:#{relationship_type} veteranInMVI:#{veteran&.participant_id}])
Expand Down
3 changes: 3 additions & 0 deletions config/features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,9 @@ features:
va_view_dependents_access:
actor_type: user
description: Allows us to gate the View/ Modify dependents content in a progressive rollout
va_burial_v2:
actor_type: user
description: Allows us to toggle between 21-P530 and 21-P530V2
show_edu_benefits_1990EZ_Wizard:
actor_type: user
description: Navigates user to 1990EZ or 1990 depending on form questions.
Expand Down
2 changes: 1 addition & 1 deletion lib/bip_claims/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Service < Common::Client::Base

def veteran_attributes(claim)
case claim.form_id
when '21P-530'
when '21P-530', '21P-530V2'
ssn, full_name, bday = claim.parsed_form.values_at(
'veteranSocialSecurityNumber',
'veteranFullName',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

require 'pdf_fill/forms/va21p527ez'
require 'pdf_fill/forms/va21p530'
require 'pdf_fill/forms/va21p530v2'
require 'pdf_fill/forms/va214142'
require 'pdf_fill/forms/va210781a'
require 'pdf_fill/forms/va210781'
Expand Down
2 changes: 2 additions & 0 deletions lib/pdf_fill/filler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

require 'pdf_fill/forms/va21p527ez'
require 'pdf_fill/forms/va21p530'
require 'pdf_fill/forms/va21p530v2'
require 'pdf_fill/forms/va214142'
require 'pdf_fill/forms/va210781a'
require 'pdf_fill/forms/va210781'
Expand All @@ -25,6 +26,7 @@ module Filler
FORM_CLASSES = {
'21P-527EZ' => PdfFill::Forms::Va21p527ez,
'21P-530' => PdfFill::Forms::Va21p530,
'21P-530V2' => PdfFill::Forms::Va21p530v2,
'21-4142' => PdfFill::Forms::Va214142,
'21-0781a' => PdfFill::Forms::Va210781a,
'21-0781' => PdfFill::Forms::Va210781,
Expand Down
Binary file added lib/pdf_fill/forms/pdfs/21P-530V2.pdf
Binary file not shown.
Loading

0 comments on commit 5761817

Please sign in to comment.