Skip to content

Commit

Permalink
Merge branch 'master' into mm/1422-v4-remove-fields
Browse files Browse the repository at this point in the history
  • Loading branch information
MarchandMD authored Nov 22, 2024
2 parents a9a4c67 + 4738869 commit 1a52b0d
Show file tree
Hide file tree
Showing 196 changed files with 7,739 additions and 6,347 deletions.
4 changes: 4 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ app/models/form526_job_status.rb @department-of-veterans-affairs/Disability-Expe
app/models/form526_submission.rb @department-of-veterans-affairs/Disability-Experience @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/models/form526_submission_remediation.rb @department-of-veterans-affairs/Disability-Experience @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/models/form_attachment.rb @department-of-veterans-affairs/benefits-decision-reviews-be @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/models/form_email_matches_profile_log.rb @department-of-veterans-affairs/vfs-10-10 @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/models/form_profile.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/form_profiles @department-of-veterans-affairs/my-education-benefits @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group
app/models/form_profiles/va_21p527ez.rb @department-of-veterans-affairs/pension-and-burials @department-of-veterans-affairs/backend-review-group
Expand Down Expand Up @@ -970,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 @@ -1331,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 @@ -1494,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
10 changes: 5 additions & 5 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 @@ -245,16 +245,16 @@ GEM
attr_extras (7.1.0)
awesome_print (1.9.2)
aws-eventstream (1.3.0)
aws-partitions (1.1004.0)
aws-sdk-core (3.212.0)
aws-partitions (1.1010.0)
aws-sdk-core (3.213.0)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.992.0)
aws-sigv4 (~> 1.9)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.95.0)
aws-sdk-core (~> 3, >= 3.210.0)
aws-sigv4 (~> 1.5)
aws-sdk-s3 (1.170.1)
aws-sdk-s3 (1.172.0)
aws-sdk-core (~> 3, >= 3.210.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.5)
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
18 changes: 16 additions & 2 deletions app/controllers/v0/terms_of_use_agreements_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ def latest

def accept
terms_of_use_agreement = acceptor.perform!
recache_user unless terms_code_temporary_auth?
unless terms_code_temporary_auth?
recache_user
current_user.create_mhv_account_async unless skip_mhv_account_creation?
end

render_success(action: 'accept', body: { terms_of_use_agreement: }, status: :created)
rescue TermsOfUse::Errors::AcceptorError => e
render_error(action: 'accept', message: e.message)
Expand All @@ -28,7 +32,13 @@ def accept_and_provision
if terms_of_use_agreement.accepted?
provisioner.perform
create_cerner_cookie
recache_user unless terms_code_temporary_auth?

unless terms_code_temporary_auth?
recache_user
current_user.create_mhv_account_async unless skip_mhv_account_creation?

end

render_success(action: 'accept_and_provision', body: { terms_of_use_agreement:, provisioned: true },
status: :created)
else
Expand Down Expand Up @@ -117,6 +127,10 @@ def mpi_profile
identifier_type: MPI::Constants::ICN)&.profile
end

def skip_mhv_account_creation?
ActiveModel::Type::Boolean.new.cast(params[:skip_mhv_account_creation])
end

def render_success(action:, body:, status: :ok, icn: @user_account.icn)
Rails.logger.info("[TermsOfUseAgreementsController] #{action} success", { icn: })
render json: body, status:
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/v1/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,8 @@ def set_cookies
end

def after_login_actions
Login::AfterLoginActions.new(@current_user).perform
client_id = url_service.tracker.payload_attr(:application)
Login::AfterLoginActions.new(@current_user, client_id).perform
log_persisted_session_and_warnings
end

Expand Down
5 changes: 2 additions & 3 deletions app/models/appeal_submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,8 @@ def current_email_address
def get_mpi_profile
@mpi_profile ||= begin
service = ::MPI::Service.new
idme_profile = service.find_profile_by_identifier(identifier: user_uuid, identifier_type: 'idme')&.profile
logingov_profile = service.find_profile_by_identifier(identifier: user_uuid, identifier_type: 'logingov')&.profile
response = idme_profile || logingov_profile
response = service.find_profile_by_identifier(identifier: user_uuid, identifier_type: 'idme')&.profile
response ||= service.find_profile_by_identifier(identifier: user_uuid, identifier_type: 'logingov')&.profile
raise 'Failed to fetch MPI profile' if response.nil?

response
Expand Down
28 changes: 24 additions & 4 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 @@ -160,8 +164,15 @@ def update_form_with_classification_codes(classified_contentions)
end

def classify_vagov_contentions(params)
user = OpenStruct.new({ flipper_id: user_uuid })
vro_client = VirtualRegionalOffice::Client.new
response = vro_client.classify_vagov_contentions(params)

response = if Flipper.enabled?(:disability_526_expanded_contention_classification, user)
vro_client.classify_vagov_contentions_expanded(params)
else
vro_client.classify_vagov_contentions(params)
end

response.body
end

Expand Down Expand Up @@ -235,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 @@ -389,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
4 changes: 4 additions & 0 deletions app/models/form_email_matches_profile_log.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# frozen_string_literal: true

class FormEmailMatchesProfileLog < ApplicationRecord
end
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
5 changes: 1 addition & 4 deletions app/models/saved_claim/dependency_claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,7 @@ 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)
def send_failure_email(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?
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
12 changes: 10 additions & 2 deletions app/services/login/after_login_actions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ module Login
class AfterLoginActions
include Accountable

attr_reader :current_user
attr_reader :current_user, :client_id

def initialize(user)
def initialize(user, client_id)
@current_user = user
@client_id = client_id
end

def perform
Expand All @@ -20,6 +21,7 @@ def perform
Login::UserAcceptableVerifiedCredentialUpdater.new(user_account: @current_user.user_account).perform
update_account_login_stats(login_type)
id_mismatch_validations
create_mhv_account

if Settings.test_user_dashboard.env == 'staging'
TestUserDashboard::UpdateUser.new(current_user).call(Time.current)
Expand All @@ -29,6 +31,12 @@ def perform

private

def create_mhv_account
return if client_id.in?(SAML::URLService::SKIP_MHV_ACCOUNT_CREATION_CLIENTS)

current_user.create_mhv_account_async
end

def login_type
@login_type ||= current_user.identity.sign_in[:service_name]
end
Expand Down
Loading

0 comments on commit 1a52b0d

Please sign in to comment.