Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into MHV-63090-self-ente…
Browse files Browse the repository at this point in the history
…red-data-api

# Conflicts:
#	lib/medical_records/bb_internal/client.rb
#	modules/my_health/config/routes.rb
#	spec/lib/medical_records/bb_internal/client_spec.rb
  • Loading branch information
mmoyer-va committed Nov 22, 2024
2 parents 57e2d29 + 749ece8 commit b53ecc5
Show file tree
Hide file tree
Showing 137 changed files with 5,835 additions and 5,947 deletions.
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,7 @@ lib/pension_burial @department-of-veterans-affairs/mbs-core-team @department-of-
lib/pension_21p527ez @department-of-veterans-affairs/pension-and-burials @department-of-veterans-affairs/backend-review-group
lib/periodic_jobs.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
lib/preneeds @department-of-veterans-affairs/mbs-core-team @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
lib/post911_sob @department-of-veterans-affairs/govcio-vfep-codereviewers @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
lib/rubocop/cops/ams_serializer.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
lib/rx @department-of-veterans-affairs/mobile-api-team @department-of-veterans-affairs/vfs-mhv-medications @department-of-veterans-affairs/backend-review-group
lib/saml @department-of-veterans-affairs/octo-identity
Expand Down Expand Up @@ -1332,6 +1333,7 @@ spec/fixtures/pdf_fill/extras.pdf @department-of-veterans-affairs/va-api-enginee
spec/fixtures/pdf_utilities @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/fixtures/pension @department-of-veterans-affairs/pension-and-burials @department-of-veterans-affairs/backend-review-group
spec/fixtures/preneeds @department-of-veterans-affairs/mbs-core-team @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/fixtures/post911_sob @department-of-veterans-affairs/govcio-vfep-codereviewers @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/fixtures/sign_in @department-of-veterans-affairs/octo-identity
spec/fixtures/supplemental_claims @department-of-veterans-affairs/benefits-decision-reviews-be @department-of-veterans-affairs/backend-review-group
spec/fixtures/va_profile @department-of-veterans-affairs/vfs-authenticated-experience-backend @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
Expand Down Expand Up @@ -1495,6 +1497,7 @@ spec/lib/pdf_utilities @department-of-veterans-affairs/va-api-engineers @departm
spec/lib/pension_burial @department-of-veterans-affairs/mbs-core-team @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/lib/pension21p527ez/pension_military_information_spec.rb @department-of-veterans-affairs/pension-and-burials @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/lib/preneeds @department-of-veterans-affairs/mbs-core-team @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/lib/post911_sob @department-of-veterans-affairs/govcio-vfep-codereviewers @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
spec/lib/rx @department-of-veterans-affairs/vfs-mhv-medications
spec/lib/rx/client_request_spec.rb @department-of-veterans-affairs/vfs-mhv-medications @department-of-veterans-affairs/mobile-api-team
spec/lib/saml @department-of-veterans-affairs/octo-identity
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/code_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,15 @@ jobs:
- name: Setup Database
uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0
with:
timeout_minutes: 20
timeout_minutes: 10
retry_wait_seconds: 3 # Seconds
max_attempts: 3
command: |
docker compose -f docker-compose.test.yml run web bash \
-c "CI=true RAILS_ENV=test DISABLE_BOOTSNAP=true bundle exec parallel_test -n 24 -e 'bin/rails db:reset'"
- name: Run Specs
timeout-minutes: 20
timeout-minutes: 15
run: |
docker compose -f docker-compose.test.yml run web bash \
-c "CI=true DISABLE_BOOTSNAP=true bundle exec parallel_rspec spec/ modules/ -n 24 -o '--color --tty'"
Expand Down
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ GIT

GIT
remote: https://github.com/department-of-veterans-affairs/vets-json-schema
revision: 71c4501d45b75000818c88707c9c0ecd3dc86dc7
revision: d100b223e002a2a4eea12544a9b9d539b0d2242f
branch: master
specs:
vets_json_schema (24.5.2)
vets_json_schema (24.5.7)
multi_json (~> 1.0)
script_utils (= 0.0.4)

Expand Down Expand Up @@ -662,7 +662,7 @@ GEM
mini_mime (1.1.5)
mini_portile2 (2.8.7)
minitest (5.25.1)
mock_redis (0.45.0)
mock_redis (0.46.0)
msgpack (1.7.2)
msgpack (1.7.2-java)
multi_json (1.15.0)
Expand Down
7 changes: 0 additions & 7 deletions app/controllers/v0/my_va/submission_statuses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module V0
module MyVA
class SubmissionStatusesController < ApplicationController
service_tag 'form-submission-statuses'
before_action :controller_enabled?

def show
report = Forms::SubmissionStatuses::Report.new(
Expand All @@ -21,12 +20,6 @@ def show

private

def controller_enabled?
unless Flipper.enabled?(:my_va_form_submission_statuses, @current_user)
raise Common::Exceptions::Forbidden, detail: 'Submission statuses are disabled.'
end
end

def allowed_forms
%w[20-10206 20-10207 21-0845 21-0972 21-10210 21-4142 21-4142a 21P-0847]
end
Expand Down
19 changes: 16 additions & 3 deletions app/models/concerns/form526_claim_fast_tracking_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ def rrd_special_issue_set?
end
end

def flashes
form.dig('form526', 'form526', 'flashes') || []
end

def disabilities
form.dig('form526', 'form526', 'disabilities')
end
Expand All @@ -114,8 +118,8 @@ def prepare_for_evss!
begin
is_claim_fully_classified = update_contention_classification_all!
rescue => e
Rails.logger.error "Contention Classification failed #{e.message}."
Rails.logger.error e.backtrace.join('\n')
Rails.logger.error("Contention Classification failed #{e.message}.")
Rails.logger.error(e.backtrace.join('\n'))
end

prepare_for_ep_merge! if is_claim_fully_classified
Expand Down Expand Up @@ -242,6 +246,7 @@ def log_max_cfi_metrics_on_submit
def send_post_evss_notifications!
conditionally_notify_mas
conditionally_merge_ep
log_flashes
Rails.logger.info('Submitted 526Submission to eVSS', id:, saved_claim_id:, submitted_claim_id:)
end

Expand Down Expand Up @@ -396,7 +401,15 @@ def conditionally_merge_ep
vro_client = VirtualRegionalOffice::Client.new
vro_client.merge_end_products(pending_claim_id:, ep400_id: submitted_claim_id)
rescue => e
Rails.logger.error "EP merge request failed #{e.message}.", backtrace: e.backtrace
Rails.logger.error("EP merge request failed #{e.message}.", backtrace: e.backtrace)
end

def log_flashes
if flashes.includes?('Amyotrophic Lateral Sclerosis')
Rails.logger.info('Flash Prototype Added', { submitted_claim_id:, flash: 'Amyotrophic Lateral Sclerosis' })
end
rescue => e
Rails.logger.error("Failed to log Flash Prototypes #{e.message}.", backtrace: e.backtrace)
end
end
# rubocop:enable Metrics/ModuleLength
1 change: 1 addition & 0 deletions app/models/form526_submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ def personalization_parameters(first_name)
'email' => form['form526']['form526']['veteran']['emailAddress'],
'submitted_claim_id' => submitted_claim_id,
'date_submitted' => created_at.strftime('%B %-d, %Y %-l:%M %P %Z').sub(/([ap])m/, '\1.m.'),
'date_received' => Time.now.utc.strftime('%B %-d, %Y %-l:%M %P %Z').sub(/([ap])m/, '\1.m.'),
'first_name' => first_name
}
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/prescription.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Prescription < Common::Base
attribute :facility_api_name, String
attribute :ordered_date, Common::UTCTime, sortable: { order: 'DESC' }
attribute :quantity, Integer
attribute :expiration_date, Common::UTCTime
attribute :expiration_date, Common::UTCTime, filterable: %w[eq lteq gteq]
attribute :prescription_number, String
attribute :sig, String
attribute :prescription_name, String, sortable: { order: 'ASC', default: true }
Expand Down
44 changes: 24 additions & 20 deletions app/models/saved_claim/dependency_claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,26 +139,30 @@ def to_pdf(form_id: FORM)
# Future work will be integrating into the Va Notify common lib:
# https://github.com/department-of-veterans-affairs/vets-api/blob/master/lib/va_notify/notification_email.rb

def send_failure_email(encrypted_user_struct = nil)
user_struct = encrypted_user_struct.present? ? JSON.parse(KmsEncrypted::Box.new.decrypt(encrypted_user_struct)) : nil # rubocop:disable Layout/LineLength
email = parsed_form.dig('dependents_application', 'veteran_contact_information', 'email_address') ||
user_struct.try(:va_profile_email)
template_ids = []
template_ids << Settings.vanotify.services.va_gov.template_id.form21_686c_action_needed_email if submittable_686?
template_ids << Settings.vanotify.services.va_gov.template_id.form21_674_action_needed_email if submittable_674?

template_ids.each do |template_id|
if email.present?
VANotify::EmailJob.perform_async(
email,
template_id,
{
'first_name' => parsed_form.dig('veteran_information', 'full_name', 'first')&.upcase.presence,
'date_submitted' => Time.zone.today.strftime('%B %d, %Y'),
'confirmation_number' => confirmation_number
}
)
end
def send_failure_email(email) # rubocop:disable Metrics/MethodLength
# if the claim is both a 686c and a 674, send a combination email.
# otherwise, check to see which individual type it is and send the corresponding email.
template_id = if submittable_686? && submittable_674?
Settings.vanotify.services.va_gov.template_id.form21_686c_674_action_needed_email
elsif submittable_686?
Settings.vanotify.services.va_gov.template_id.form21_686c_action_needed_email
elsif submittable_674?
Settings.vanotify.services.va_gov.template_id.form21_674_action_needed_email
else
Rails.logger.error('Email template cannot be assigned for SavedClaim', saved_claim_id: id)
nil
end

if email.present? && template_id.present?
VANotify::EmailJob.perform_async(
email,
template_id,
{
'first_name' => parsed_form.dig('veteran_information', 'full_name', 'first')&.upcase.presence,
'date_submitted' => Time.zone.today.strftime('%B %d, %Y'),
'confirmation_number' => confirmation_number
}
)
end
end

Expand Down
3 changes: 2 additions & 1 deletion app/models/saved_claim/disability_compensation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def to_submission_data(user)
form4142 = EVSS::DisabilityCompensationForm::Form4142.new(user, @form_hash.deep_dup).translate
form526 = @form_hash.deep_dup
dis_form = EVSS::DisabilityCompensationForm::DataTranslationAllClaim.new(user, form526, form4142.present?).translate
claimed_disabilities = dis_form.dig('form526', 'disabilities')
form526_uploads = form526['form526'].delete('attachments')

{
Expand All @@ -33,7 +34,7 @@ def to_submission_data(user)
@form_hash.deep_dup).translate,
Form526Submission::FORM_8940 => EVSS::DisabilityCompensationForm::Form8940.new(user,
@form_hash.deep_dup).translate,
'flashes' => BGS::DisabilityCompensationFormFlashes.new(user, @form_hash.deep_dup).translate
'flashes' => BGS::DisabilityCompensationFormFlashes.new(user, @form_hash.deep_dup, claimed_disabilities).translate
}.to_json
end
end
3 changes: 1 addition & 2 deletions app/models/saved_claim/education_career_counseling_claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ def business_line
# part of the ZSF work, but with the initial timeline it handles the email as intended.
# Future work will be integrating into the Va Notify common lib:
# https://github.com/department-of-veterans-affairs/vets-api/blob/master/lib/va_notify/notification_email.rb
def send_failure_email
email = parsed_form.dig('claimantInformation', 'emailAddress')
def send_failure_email(email)
if email.present?
VANotify::EmailJob.perform_async(
email,
Expand Down
4 changes: 1 addition & 3 deletions app/models/saved_claim/veteran_readiness_employment_claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,7 @@ def business_line
# part of the ZSF work, but with the initial timeline it handles the email as intended.
# Future work will be integrating into the Va Notify common lib:
# https://github.com/department-of-veterans-affairs/vets-api/blob/master/lib/va_notify/notification_email.rb
def send_failure_email(encrypted_user = nil)
user = encrypted_user.present? ? OpenStruct.new(JSON.parse(KmsEncrypted::Box.new.decrypt(encrypted_user))) : nil
email = parsed_form['email'] || user.try(:va_profile_email)
def send_failure_email(email)
if email.present?
VANotify::EmailJob.perform_async(
email,
Expand Down
79 changes: 79 additions & 0 deletions app/services/claim_fast_tracking/flash_picker.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# frozen_string_literal: true

module ClaimFastTracking
class FlashPicker
DEFAULT_FUZZY_TOLERANCE = 0.2
MIN_FUZZY_MATCH_LENGTH = 6
MIN_LENGTH_RATIO = 0.9

ALS_DC = 8017
ALS_PARTIAL_MATCH_TERMS = [
'amyotrophic lateral sclerosis',
'(als)'
].freeze
ALS_MATCH_TERMS = (ALS_PARTIAL_MATCH_TERMS + [
'als',
'lou gehrig disease',
'lou gehrigs disease',
'lou gehrig\'s disease',
'lou gehrig',
'lou gehrigs',
'lou gehrig\'s'
]).freeze

def self.als?(claimed_disabilities)
return if claimed_disabilities.pluck('diagnosticCode').include?(ALS_DC)

claimed_disabilities.map { |disability| disability['name']&.downcase }.compact.any? do |name|
partial_matches?(name, ALS_PARTIAL_MATCH_TERMS) || matches?(name, ALS_MATCH_TERMS)
end
end

def self.partial_matches?(name, match_terms)
match_terms = [match_terms] unless match_terms.is_a?(Array)

match_terms.any? { |term| name.include?(term) }
end

def self.matches?(name,
match_terms,
tolerance = DEFAULT_FUZZY_TOLERANCE,
min_length_ratio = MIN_LENGTH_RATIO,
min_length_limit = MIN_FUZZY_MATCH_LENGTH)
match_terms = [match_terms] unless match_terms.is_a?(Array)

match_terms.any? do |term|
# Early exact match check (case insensitive)
return true if name.casecmp?(term)

# Prevent fuzzy matching for very short terms (e.g., less than min_length_limit)
next false if name.length < min_length_limit || term.length < min_length_limit

# Calculate the length ratio based on the shorter and longer lengths
shorter_length = [name.length, term.length].min
longer_length = [name.length, term.length].max

# Skip comparison if the length ratio is below minimum length ratio, indicating a significant length difference
next false if shorter_length.to_f / longer_length < min_length_ratio

# Calculate the Levenshtein threshold based on tolerance and maximum length
return true if fuzzy_match?(name, term, longer_length, tolerance)
end
end

def self.fuzzy_match?(name, term, longer_length, tolerance = DEFAULT_FUZZY_TOLERANCE)
threshold = (longer_length * tolerance).ceil
distance = StringHelpers.levenshtein_distance(name, term)

if distance - 1 == threshold
Rails.logger.info(
'FlashPicker close fuzzy match for condition',
{ name: name, match_term: term, distance: distance, threshold: threshold }
)
end
distance <= threshold
end

private_class_method :partial_matches?, :matches?, :fuzzy_match?
end
end
2 changes: 1 addition & 1 deletion app/services/mhv/user_account/creator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def perform
def create_mhv_user_account!
account = MHVUserAccount.new(mhv_account_creation_response)
account.validate!

MPIData.find(icn)&.destroy
account
end

Expand Down
17 changes: 11 additions & 6 deletions app/sidekiq/benefits_intake_status_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,11 @@ def monitor_failure(form_id, saved_claim_id, bi_uuid)
# Dependents
if %w[686C-674].include?(form_id)
claim = SavedClaim::DependencyClaim.find(saved_claim_id)
if claim
claim.send_failure_email
email = if claim.present?
claim.parsed_form.dig('dependents_application', 'veteran_contact_information', 'email_address')
end
if claim.present? && email.present?
claim.send_failure_email(email)
Dependents::Monitor.new.log_silent_failure_avoided(context, nil, call_location:)
else
Dependents::Monitor.new.log_silent_failure(context, nil, call_location:)
Expand All @@ -173,8 +176,9 @@ def monitor_failure(form_id, saved_claim_id, bi_uuid)
# PCPG
if %w[28-8832].include?(form_id)
claim = SavedClaim::EducationCareerCounselingClaim.find(saved_claim_id)
if claim
claim.send_failure_email
email = claim.parsed_form.dig('claimantInformation', 'emailAddress') if claim.present?
if claim.present? && email.present?
claim.send_failure_email(email)
PCPG::Monitor.new.log_silent_failure_avoided(context, nil, call_location:)
else
PCPG::Monitor.new.log_silent_failure(ocntext, nil, call_location:)
Expand All @@ -184,8 +188,9 @@ def monitor_failure(form_id, saved_claim_id, bi_uuid)
# VRE
if %w[28-1900].include?(form_id)
claim = SavedClaim::VeteranReadinessEmploymentClaim.find(saved_claim_id)
if claim
claim.send_failure_email
email = claim.parsed_form['email'] if claim.present?
if claim.present? && email.present?
claim.send_failure_email(email)
VRE::Monitor.new.log_silent_failure_avoided(context, nil, call_location:)
else
VRE::Monitor.new.log_silent_failure(context, nil, call_location:)
Expand Down
16 changes: 9 additions & 7 deletions app/sidekiq/central_mail/submit_central_form686c_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,8 @@ def extract_uuid_from_central_mail_message(data)
sidekiq_options retry: RETRY

sidekiq_retries_exhausted do |msg, _ex|
monitor = Dependents::Monitor.new
monitor.track_submission_exhaustion(msg)

saved_claim_id, _, encrypted_user_struct = msg['args']
if Flipper.enabled?(:dependents_trigger_action_needed_email)
CentralMail::SubmitCentralForm686cJob.trigger_failure_events(saved_claim_id, encrypted_user_struct)
CentralMail::SubmitCentralForm686cJob.trigger_failure_events(msg)
end
end

Expand Down Expand Up @@ -232,9 +228,15 @@ def send_confirmation_email(user)
)
end

def self.trigger_failure_events(saved_claim_id, encrypted_user_struct)
def self.trigger_failure_events(msg)
monitor = Dependents::Monitor.new
saved_claim_id, _, encrypted_user_struct = msg['args']
user_struct = JSON.parse(KmsEncrypted::Box.new.decrypt(encrypted_user_struct)) if encrypted_user_struct.present?
claim = SavedClaim::DependencyClaim.find(saved_claim_id)
claim.send_failure_email(encrypted_user_struct)
email = claim.parsed_form.dig('dependents_application', 'veteran_contact_information', 'email_address') ||
user_struct.try(:va_profile_email)
monitor.track_submission_exhaustion(msg, email)
claim.send_failure_email(email)
end

private
Expand Down
Loading

0 comments on commit b53ecc5

Please sign in to comment.