Skip to content

Commit

Permalink
Merge branch 'master' into MHV-63090-self-entered-data-api
Browse files Browse the repository at this point in the history
  • Loading branch information
mmoyer-va authored Nov 27, 2024
2 parents 0aa5b88 + 3a1e551 commit 734d4cc
Show file tree
Hide file tree
Showing 18 changed files with 419 additions and 131 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def get_docs(submission_id, uuid)
if parsed_forms[form_type_key].present?
file_type_and_file_objs << {
type: actual_form_types,
file: process_0781(uuid, FORM_ID_0781, parsed_forms[form_type_key],
file: process_0781(uuid, actual_form_types, parsed_forms[form_type_key],
upload: false)
}
end
Expand Down
2 changes: 1 addition & 1 deletion config/redis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ development: &defaults
each_ttl: 60
eps_access_token:
namespace: eps-access-token
each_ttl: 900 # 15 minutes
each_ttl: 840 # 14 minutes
saml_request_tracker:
namespace: saml_request_tracker
each_ttl: 3600 # 1 hour
Expand Down
2 changes: 2 additions & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1288,6 +1288,8 @@ vanotify:
form21_674_action_needed_email: form21_674_action_needed_email_template_id
form21_0966_confirmation_email: form21_0966_confirmation_email_template_id
form21_0966_error_email: form21_0966_error_email_template_id
form21_0966_received_email: form21_0966_received_email_template_id
form21_0966_itf_api_received_email: form21_0966_itf_api_received_email_template_id
form21_0972_confirmation_email: form21_0972_confirmation_email_template_id
form21_0972_error_email: form21_0972_error_email_template_id
form21_0972_received_email: form21_0972_received_email_template_id
Expand Down
42 changes: 42 additions & 0 deletions config/settings/production.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,44 @@
betamocks:
recording: false
central_mail:
upload:
enabled: true
check_in:
authentication:
retry_attempt_expiry: 604800
chip_api_v2:
mock: false
timeout: 30
lorota_v2:
mock: false
travel_reimbursement_api:
redis_token_expiry: 3540
clamav:
mock: false
coverband:
github_organization: department-of-veterans-affairs
decision_review:
mock: false
pdf_validation:
enabled: true
dogstatsd:
enabled: true
evss:
s3:
uploads_enabled: true
expiry_scanner:
slack:
channel_id: C24RH0W11
flipper:
github_organization: department-of-veterans-affairs
mute_logs: false
form_10_10cg:
poa:
s3:
enabled: true
form526_backup:
submission_method: single
google_analytics_cvu:
type: service_account
hca:
ca: []
3 changes: 2 additions & 1 deletion modules/claims_api/spec/requests/v1/forms/rswag_2122_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
require_relative '../../../rails_helper'
require_relative '../../../support/swagger_shared_components/v1'
require 'bgs/power_of_attorney_verifier'
require 'bgs_service/person_web_service'

Rspec.describe 'Power of Attorney', openapi_spec: 'modules/claims_api/app/swagger/claims_api/v1/swagger.json' do
let(:pws) { ClaimsApi::LocalBGS }
let(:pws) { ClaimsApi::PersonWebService }

path '/forms/2122' do
get 'Gets schema for POA form.' do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ def handle_210966_authenticated
form.track_user_identity(confirmation_number)

if confirmation_number && Flipper.enabled?(:simple_forms_email_confirmations)
send_confirmation_email(parsed_form_data, get_form_id, confirmation_number)
send_intent_received_email(parsed_form_data, confirmation_number, expiration_date)
end

json_for210966(confirmation_number, expiration_date, existing_intents)
rescue Common::Exceptions::UnprocessableEntity, Net::ReadTimeout => e
rescue Common::Exceptions::UnprocessableEntity, Exceptions::BenefitsClaimsApiDownError => e
# Common::Exceptions::UnprocessableEntity: There is an authentication issue with the Intent to File API
# Faraday::TimeoutError: The Intent to File API is down or timed out
# Exceptions::BenefitsClaimsApiDownError: The Intent to File API is down or timed out
# In either case, we revert to sending a PDF to Central Mail through the Benefits Intake API
prepare_params_for_benefits_intake_and_log_error(e)
submit_form_to_benefits_intake
Expand Down Expand Up @@ -292,6 +292,22 @@ def send_confirmation_email(parsed_form_data, form_id, confirmation_number)
)
notification_email.send
end

def send_intent_received_email(parsed_form_data, confirmation_number, expiration_date)
config = {
form_data: parsed_form_data,
form_number: 'vba_21_0966_intent_api',
confirmation_number:,
date_submitted: Time.zone.today.strftime('%B %d, %Y'),
expiration_date:
}
notification_email = SimpleFormsApi::NotificationEmail.new(
config,
notification_type: :received,
user: @current_user
)
notification_email.send
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ def submit
type = benefit_type.downcase
next if existing_intents[type]

response = benefits_claims_lighthouse_service.create_intent_to_file(type, ssn)
confirmation_number = response.dig('data', 'id')
expiration_date = response.dig('data', 'attributes', 'expirationDate')
confirmation_number, expiration_date = create_intent_to_file(type, ssn)
end

user_account_uuid = user.user_account_uuid
Expand Down Expand Up @@ -61,6 +59,21 @@ def benefits_claims_lighthouse_service
@benefits_claims_lighthouse_service ||= BenefitsClaims::Service.new(icn)
end

def create_intent_to_file(type, ssn)
response = benefits_claims_lighthouse_service.create_intent_to_file(type, ssn)
[response.dig('data', 'id'), response.dig('data', 'attributes', 'expirationDate')]
rescue Common::Exceptions::ResourceNotFound => e
Rails.logger.error(
'Simple forms api - Benefits Claims API, intent to file endpoint is down',
{
intent_type: type,
form_number: params[:form_number],
error: e
}
)
raise Exceptions::BenefitsClaimsApiDownError
end

def existing_compensation_intent
@existing_compensation_intent ||=
benefits_claims_lighthouse_service.get_intent_to_file('compensation')&.dig('data', 'attributes')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

module SimpleFormsApi
class NotificationEmail
attr_reader :form_number, :confirmation_number, :date_submitted, :lighthouse_updated_at, :notification_type, :user,
:user_account, :form_data
attr_reader :form_number, :confirmation_number, :date_submitted, :expiration_date, :lighthouse_updated_at,
:notification_type, :user, :user_account, :form_data

TEMPLATE_IDS = {
'vba_21_0845' => {
Expand All @@ -19,7 +19,10 @@ class NotificationEmail
'vba_21_0966' => {
confirmation: Settings.vanotify.services.va_gov.template_id.form21_0966_confirmation_email,
error: Settings.vanotify.services.va_gov.template_id.form21_0966_error_email,
received: nil
received: Settings.vanotify.services.va_gov.template_id.form21_0966_received_email
},
'vba_21_0966_intent_api' => {
received: Settings.vanotify.services.va_gov.template_id.form21_0966_itf_api_received_email
},
'vba_21_0972' => {
confirmation: Settings.vanotify.services.va_gov.template_id.form21_0972_confirmation_email,
Expand Down Expand Up @@ -66,6 +69,7 @@ def initialize(config, notification_type: :confirmation, user: nil, user_account
@form_number = config[:form_number]
@confirmation_number = config[:confirmation_number]
@date_submitted = config[:date_submitted]
@expiration_date = config[:expiration_date]
@lighthouse_updated_at = config[:lighthouse_updated_at]
@notification_type = notification_type
@user = user
Expand All @@ -90,11 +94,16 @@ def send(at: nil)

def check_missing_keys(config)
missing_keys = %i[form_data form_number confirmation_number date_submitted].select { |key| config[key].nil? }
if config[:form_number] == 'vba_21_0966_intent_api' && config[:expiration_date].nil?
missing_keys << :expiration_date
end
raise ArgumentError, "Missing keys: #{missing_keys.join(', ')}" if missing_keys.any?
end

def flipper?
Flipper.enabled?(:"form#{form_number.gsub('vba_', '')}_confirmation_email")
number = form_number
number = 'vba_21_0966' if form_number.start_with? 'vba_21_0966'
Flipper.enabled?(:"form#{number.gsub('vba_', '')}_confirmation_email")
end

def enqueue_email(at, template_id)
Expand Down Expand Up @@ -172,7 +181,7 @@ def get_email_address_from_form_data
form21_0845_contact_info[0]
when 'vba_21p_0847', 'vba_21_0972'
form_data['preparer_email']
when 'vba_21_0966'
when 'vba_21_0966', 'vba_21_0966_intent_api'
form21_0966_email_address
when 'vba_21_4142'
form_data.dig('veteran', 'email')
Expand All @@ -196,7 +205,7 @@ def get_first_name_from_form_data
form21_0845_contact_info[1]
when 'vba_21p_0847'
form_data.dig('preparer_name', 'first')
when 'vba_21_0966'
when 'vba_21_0966', 'vba_21_0966_intent_api'
form21_0966_first_name
when 'vba_21_0972'
form_data.dig('preparer_full_name', 'first')
Expand Down Expand Up @@ -237,7 +246,7 @@ def get_first_name_from_user
end

def get_personalization(first_name)
if @form_number == 'vba_21_0966'
if @form_number.start_with? 'vba_21_0966'
default_personalization(first_name).merge(form21_0966_personalization)
else
default_personalization(first_name)
Expand Down Expand Up @@ -348,18 +357,31 @@ def form21_0966_email_address
end

def form21_0966_personalization
intent_to_file_benefits, intent_to_file_benefits_links = get_intent_to_file_benefits_variables
{
'intent_to_file_benefits' => intent_to_file_benefits,
'intent_to_file_benefits_links' => intent_to_file_benefits_links,
'itf_api_expiration_date' => expiration_date
}
end

def get_intent_to_file_benefits_variables
benefits = @form_data['benefit_selection']
intent_to_file_benefits = if benefits['compensation'] && benefits['pension']
'Disability Compensation (VA Form 21-526EZ) and Pension (VA Form 21P-527EZ)'
elsif benefits['compensation']
'Disability Compensation (VA Form 21-526EZ)'
elsif benefits['pension']
'Pension (VA Form 21P-527EZ)'
elsif benefits['survivor']
'Survivors Pension and/or Dependency and Indemnity Compensation (DIC)' \
' (VA Form 21P-534 or VA Form 21P-534EZ)'
end
{ 'intent_to_file_benefits' => intent_to_file_benefits }
if benefits['compensation'] && benefits['pension']
['disability compensation and Veterans pension benefits',
'[File for disability compensation (VA Form 21-526EZ)]' \
'(https://www.va.gov/disability/file-disability-claim-form-21-526ez/introduction) and [Apply for Veterans ' \
'Pension benefits (VA Form 21P-527EZ)](https://www.va.gov/find-forms/about-form-21p-527ez/)']
elsif benefits['compensation']
['disability compensation',
'[File for disability compensation (VA Form 21-526EZ)](https://www.va.gov/disability/file-disability-claim-form-21-526ez/introduction)']
elsif benefits['pension']
['Veterans pension benefits',
'[Apply for Veterans Pension benefits (VA Form 21P-527EZ)](https://www.va.gov/find-forms/about-form-21p-527ez/)']
elsif benefits['survivor']
['survivors pension benefits',
'[Apply for DIC, Survivors Pension, and/or Accrued Benefits (VA Form 21P-534EZ)](https://www.va.gov/find-forms/about-form-21p-534ez/)']
end
end

def form40_10007_first_name
Expand Down
2 changes: 2 additions & 0 deletions modules/simple_forms_api/lib/simple_forms_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,7 @@ def aggregate_words(parsed_params)
words.uniq.sort_by(&:length).reverse
end
end

class BenefitsClaimsApiDownError < RuntimeError; end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -852,9 +852,11 @@
end

context 'veteran preparer' do
it 'successful submission' do
let(:expiration_date) { Time.zone.now }

it 'sends the received email' do
allow_any_instance_of(SimpleFormsApi::IntentToFile)
.to receive(:submit).and_return([confirmation_number, Time.zone.now])
.to receive(:submit).and_return([confirmation_number, expiration_date])
allow_any_instance_of(SimpleFormsApi::IntentToFile)
.to receive(:existing_intents)
.and_return({ 'compensation' => 'false', 'pension' => 'false', 'survivor' => 'false' })
Expand All @@ -867,14 +869,16 @@

expect(VANotify::EmailJob).to have_received(:perform_async).with(
'[email protected]',
'form21_0966_confirmation_email_template_id',
'form21_0966_itf_api_received_email_template_id',
{
'first_name' => 'Veteran',
'date_submitted' => Time.zone.today.strftime('%B %d, %Y'),
'confirmation_number' => confirmation_number,
'lighthouse_updated_at' => nil,
'intent_to_file_benefits' => 'Survivors Pension and/or Dependency and Indemnity Compensation (DIC)' \
' (VA Form 21P-534 or VA Form 21P-534EZ)'
'intent_to_file_benefits' => 'survivors pension benefits',
'intent_to_file_benefits_links' => '[Apply for DIC, Survivors Pension, and/or Accrued Benefits ' \
'(VA Form 21P-534EZ)](https://www.va.gov/find-forms/about-form-21p-534ez/)',
'itf_api_expiration_date' => expiration_date
}
)
end
Expand All @@ -897,8 +901,10 @@
'date_submitted' => Time.zone.today.strftime('%B %d, %Y'),
'confirmation_number' => confirmation_number,
'lighthouse_updated_at' => nil,
'intent_to_file_benefits' => 'Survivors Pension and/or Dependency and Indemnity Compensation (DIC)' \
' (VA Form 21P-534 or VA Form 21P-534EZ)'
'intent_to_file_benefits' => 'survivors pension benefits',
'intent_to_file_benefits_links' => '[Apply for DIC, Survivors Pension, and/or Accrued Benefits ' \
'(VA Form 21P-534EZ)](https://www.va.gov/find-forms/about-form-21p-534ez/)',
'itf_api_expiration_date' => nil
}
)
end
Expand Down
Loading

0 comments on commit 734d4cc

Please sign in to comment.