Skip to content

Commit

Permalink
Merge branch 'master' into 95356-add-10-10cg-failure-email
Browse files Browse the repository at this point in the history
  • Loading branch information
coope93 committed Nov 14, 2024
2 parents 3f841f4 + 80a36cb commit eb6521b
Show file tree
Hide file tree
Showing 46 changed files with 489 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ gem 'connect_vbms', git: 'https://github.com/adhocteam/connect_vbms', tag: 'v2.1
gem 'csv'
gem 'date_validator'
gem 'ddtrace'
gem 'dogstatsd-ruby', '5.6.2'
gem 'dogstatsd-ruby', '5.6.3'
gem 'dry-struct'
gem 'dry-types'
gem 'ethon', '>=0.13.0'
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ GEM
thread_safe (~> 0.3, >= 0.3.1)
diff-lcs (1.5.1)
docile (1.4.0)
dogstatsd-ruby (5.6.2)
dogstatsd-ruby (5.6.3)
domain_name (0.6.20240107)
down (5.4.2)
addressable (~> 2.8)
Expand Down Expand Up @@ -1162,7 +1162,7 @@ DEPENDENCIES
ddtrace
debts_api!
dhp_connected_devices!
dogstatsd-ruby (= 5.6.2)
dogstatsd-ruby (= 5.6.3)
dry-struct
dry-types
ethon (>= 0.13.0)
Expand Down
25 changes: 22 additions & 3 deletions app/services/medical_copays/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,32 @@ def initialize
# @return [Faraday::Response]
#
def post(path, params)
with_monitoring do
connection.post(path) do |req|
req.body = Oj.dump(params)
if Flipper.enabled?(:debts_copay_logging) && !Rails.env.development?
with_monitoring_and_error_handling do
connection.post(path) do |req|
req.body = Oj.dump(params)
end
end
else
with_monitoring do
connection.post(path) do |req|
req.body = Oj.dump(params)
end
end
end
end

def with_monitoring_and_error_handling(&)
with_monitoring(2, &)
rescue => e
handle_error(e)
end

def handle_error(error)
Rails.logger.error("MedicalCopays::Request error: #{error.message}")
raise error
end

##
# Make a HTTP GET call to the VBS service in order to obtain copays or PDFs by id
#
Expand Down
4 changes: 4 additions & 0 deletions app/services/medical_copays/vbs/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ def get_pdf_statement_by_id(statement_id)
end

def get_copay_response
if Flipper.enabled?(:debts_copay_logging)
Rails.logger.info("MedicalCopays::VBS::Service#get_copay_response request data: #{@user.uuid}")
end

request.post("#{settings.base_path}/GetStatementsByEDIPIAndVistaAccountNumber", request_data.to_hash)
end

Expand Down
1 change: 0 additions & 1 deletion app/sidekiq/benefits_intake_status_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ def log_result(result, form_id, uuid, time_to_transition = nil, error_message =
StatsD.increment("#{STATS_KEY}.all_forms.#{result}")
if result == 'failure'
Rails.logger.error('BenefitsIntakeStatusJob', result:, form_id:, uuid:, time_to_transition:, error_message:)
monitor_failure(form_id, uuid)
else
Rails.logger.info('BenefitsIntakeStatusJob', result:, form_id:, uuid:, time_to_transition:)
end
Expand Down
5 changes: 5 additions & 0 deletions app/sidekiq/central_mail/submit_form4142_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ class CentralMailResponseError < Common::Exceptions::BackendServiceException; e
if Flipper.enabled?(:form526_send_4142_failure_notification)
EVSS::DisabilityCompensationForm::Form4142DocumentUploadFailureEmail.perform_async(form526_submission_id)
end
# NOTE: do NOT add any additional code here between the failure email being enqueued and the rescue block.
# The mailer prevents an upload from failing silently, since we notify the veteran and provide a workaround.
# The rescue will catch any errors in the sidekiq_retries_exhausted block and mark a "silent failure".
# This shouldn't happen if an email was sent; there should be no code here to throw an additional exception.
# The mailer should be the last thing that can fail.
rescue => e
cl = caller_locations.first
call_location = Logging::CallLocation.new(ZSF_DD_TAG_FUNCTION, cl.path, cl.lineno)
Expand Down
2 changes: 2 additions & 0 deletions app/sidekiq/evss/document_upload.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

class EVSS::DocumentUpload
include Sidekiq::Job
extend SentryLogging
extend Logging::ThirdPartyTransaction::MethodWrapper

FILENAME_EXTENSION_MATCHER = /\.\w*$/
Expand Down Expand Up @@ -63,6 +64,7 @@ class EVSS::DocumentUpload
::Rails.logger.error('EVSS::DocumentUpload exhaustion handler email error',
{ message: e.message })
StatsD.increment('silent_failure', tags: DD_ZSF_TAGS)
log_exception_to_sentry(e)
end

def perform(auth_headers, user_uuid, document_hash)
Expand Down
2 changes: 2 additions & 0 deletions app/sidekiq/lighthouse/document_upload.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

class Lighthouse::DocumentUpload
include Sidekiq::Job
extend SentryLogging

FILENAME_EXTENSION_MATCHER = /\.\w*$/
OBFUSCATED_CHARACTER_MATCHER = /[a-zA-Z\d]/
Expand Down Expand Up @@ -48,6 +49,7 @@ class Lighthouse::DocumentUpload
::Rails.logger.error('Lighthouse::DocumentUpload exhaustion handler email error',
{ message: e.message })
StatsD.increment('silent_failure', tags: DD_ZSF_TAGS)
log_exception_to_sentry(e)
end

def self.obscured_filename(original_filename)
Expand Down
3 changes: 3 additions & 0 deletions config/features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,9 @@ features:
debts_cache_vbs_copays_empty_response:
actor_type: user
description: Enables caching of empty VBS medical copay response
debts_copay_logging:
actor_type: user
description: Logs copay request data
decision_review_hlr_email:
actor_type: user
description: Send email notification for successful HLR submission
Expand Down
11 changes: 11 additions & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1847,3 +1847,14 @@ schema_contract:

form_mock_ae_design_patterns:
prefill: true

vaos:
eps:
key_path: /fake/client/key/path
mock: false
client_id: "fake_client_id"
kid: "fake_kid"
audience_claim_url: "https://login.wellhive.com/oauth2/default/v1/token"
access_token_url: "https://login.wellhive.com/oauth2/default/v1/token"
api_url: "https://api.wellhive.com/care-navigation/v1"
scopes: "care-nav"
2 changes: 2 additions & 0 deletions lib/sentry_logging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
require 'sentry_logging'

module SentryLogging
extend self

def log_message_to_sentry(message, level, extra_context = {}, tags_context = {})
level = normalize_level(level, nil)
formatted_message = extra_context.empty? ? message : "#{message} : #{extra_context}"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# frozen_string_literal: true

module AccreditedRepresentativePortal
module V0
class PowerOfAttorneyRequestsController < ApplicationController
POA_REQUEST_ITEM_MOCK_DATA = {
status: 'Pending',
declinedReason: nil,
powerOfAttorneyCode: '091',
submittedAt: '2024-04-30T11:03:17Z',
acceptedOrDeclinedAt: nil,
isAddressChangingAuthorized: false,
isTreatmentDisclosureAuthorized: true,
veteran: {
firstName: 'Jon',
middleName: nil,
lastName: 'Smith',
participantId: '6666666666666'
},
representative: {
email: '[email protected]',
firstName: 'Jane',
lastName: 'Doe'
},
claimant: {
firstName: 'Sam',
lastName: 'Smith',
participantId: '777777777777777',
relationshipToVeteran: 'Child'
},
claimantAddress: {
city: 'Hartford',
state: 'CT',
zip: '06107',
country: 'GU',
militaryPostOffice: nil,
militaryPostalCode: nil
}
}.freeze

def show
render json: POA_REQUEST_ITEM_MOCK_DATA
end
end
end
end
1 change: 1 addition & 0 deletions modules/accredited_representative_portal/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
post 'form21a', to: 'form21a#submit'

resources :in_progress_forms, only: %i[update show destroy]
resources :power_of_attorney_requests, only: :show
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# frozen_string_literal: true

require_relative '../../../rails_helper'

RSpec.describe AccreditedRepresentativePortal::V0::PowerOfAttorneyRequestsController, type: :request do
let(:test_user) { create(:representative_user) }
let(:poa_request_details_id) { '123' }
let(:poa_request_details_mock_data) do
{
'status' => 'Pending',
'declinedReason' => nil,
'powerOfAttorneyCode' => '091',
'submittedAt' => '2024-04-30T11:03:17Z',
'acceptedOrDeclinedAt' => nil,
'isAddressChangingAuthorized' => false,
'isTreatmentDisclosureAuthorized' => true,
'veteran' => { 'firstName' => 'Jon', 'middleName' => nil, 'lastName' => 'Smith',
'participantId' => '6666666666666' },
'representative' => { 'email' => '[email protected]', 'firstName' => 'Jane', 'lastName' => 'Doe' },
'claimant' => { 'firstName' => 'Sam', 'lastName' => 'Smith', 'participantId' => '777777777777777',
'relationshipToVeteran' => 'Child' },
'claimantAddress' => { 'city' => 'Hartford', 'state' => 'CT', 'zip' => '06107', 'country' => 'GU',
'militaryPostOffice' => nil, 'militaryPostalCode' => nil }
}
end

before do
Flipper.enable(:accredited_representative_portal_pilot)
login_as(test_user)
end

describe 'GET /accredited_representative_portal/v0/power_of_attorney_requests/:id' do
it 'returns the details of a power of attorney request' do
get("/accredited_representative_portal/v0/power_of_attorney_requests/#{poa_request_details_id}")
expect(response).to have_http_status(:ok)
expect(JSON.parse(response.body)).to include(poa_request_details_mock_data)
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class FormFields
veteran_insurance_policy_number: 'form1[0].#subform[2].VA_Insurance_Policy_Number_If_Applicable[0]',
veteran_state_code: 'form1[0].#subform[2].CurrentMailingAddress_StateOrProvince[0]',
veteran_country_code: 'form1[0].#subform[2].CurrentMailingAddress_Country[0]',
veteran_homeless: 'form1[0].#subform[2].ClaimantType[0]',
veteran_homeless: 'form1[0].#subform[2].I_Am_Experiencing_Or_At_Risk_Of_Homelessness[0]',
veteran_phone_area_code: 'form1[0].#subform[2].Telephone_Number_Area_Code[0]',
veteran_phone_prefix: 'form1[0].#subform[2].Telephone_Middle_Three_Numbers[0]',
veteran_phone_line_number: 'form1[0].#subform[2].Telephone_Last_Four_Numbers[0]',
Expand Down
Binary file not shown.
10 changes: 10 additions & 0 deletions modules/claims_api/app/models/claims_api/auto_established_claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def to_internal # rubocop:disable Metrics/MethodLength
resolve_homelessness_risk_situation_type_mappings!
transform_homelessness_point_of_contact_primary_phone!
transform_address_lines_length!
transform_empty_unit_name!

{
form526: form_data
Expand Down Expand Up @@ -533,5 +534,14 @@ def transform_address_lines_length!

form_data['veteran']['currentMailingAddress'] = addr
end

def transform_empty_unit_name!
reserves = form_data&.dig('serviceInformation', 'reservesNationalGuardService')
return if reserves.nil?

unit_name = reserves['unitName']
unit_name = unit_name.presence || ' '
reserves['unitName'] = unit_name
end
end
end
6 changes: 3 additions & 3 deletions modules/claims_api/app/swagger/claims_api/v1/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1571,7 +1571,7 @@
"example": "1990-01-02"
},
"separationLocationCode": {
"description": "Code for the facility the Veteran plans to separate from. Required if 'servicePeriod.activeDutyEndDate' is in the future. [Code values available here.](https://github.com/department-of-veterans-affairs/vets-api/blob/master/modules/claims_api/lib/claims_api/separation_location_code_values.json)",
"description": "Code for the facility the Veteran plans to separate from. Required if 'servicePeriod.activeDutyEndDate' is in the future. Code must match the values returned by the /intake-sites endpoint on the [Benefits reference Data API](https://developer.va.gov/explore/benefits/docs/benefits_reference_data?version=current).",
"type": "string",
"example": "98283"
}
Expand Down Expand Up @@ -3435,7 +3435,7 @@
"example": "1990-01-02"
},
"separationLocationCode": {
"description": "Code for the facility the Veteran plans to separate from. Required if 'servicePeriod.activeDutyEndDate' is in the future. [Code values available here.](https://github.com/department-of-veterans-affairs/vets-api/blob/master/modules/claims_api/lib/claims_api/separation_location_code_values.json)",
"description": "Code for the facility the Veteran plans to separate from. Required if 'servicePeriod.activeDutyEndDate' is in the future. Code must match the values returned by the /intake-sites endpoint on the [Benefits reference Data API](https://developer.va.gov/explore/benefits/docs/benefits_reference_data?version=current).",
"type": "string",
"example": "98283"
}
Expand Down Expand Up @@ -5693,7 +5693,7 @@
"example": "1990-01-02"
},
"separationLocationCode": {
"description": "Code for the facility the Veteran plans to separate from. Required if 'servicePeriod.activeDutyEndDate' is in the future. [Code values available here.](https://github.com/department-of-veterans-affairs/vets-api/blob/master/modules/claims_api/lib/claims_api/separation_location_code_values.json)",
"description": "Code for the facility the Veteran plans to separate from. Required if 'servicePeriod.activeDutyEndDate' is in the future. Code must match the values returned by the /intake-sites endpoint on the [Benefits reference Data API](https://developer.va.gov/explore/benefits/docs/benefits_reference_data?version=current).",
"type": "string",
"example": "98283"
}
Expand Down
2 changes: 1 addition & 1 deletion modules/claims_api/config/schemas/v1/526.json
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@
"example": "1990-01-02"
},
"separationLocationCode": {
"description": "Code for the facility the Veteran plans to separate from. Required if 'servicePeriod.activeDutyEndDate' is in the future. [Code values available here.](https://github.com/department-of-veterans-affairs/vets-api/blob/master/modules/claims_api/lib/claims_api/separation_location_code_values.json)",
"description": "Code for the facility the Veteran plans to separate from. Required if 'servicePeriod.activeDutyEndDate' is in the future. Code must match the values returned by the /intake-sites endpoint on the [Benefits reference Data API](https://developer.va.gov/explore/benefits/docs/benefits_reference_data?version=current).",
"type": "string",
"example": "98283"
}
Expand Down
15 changes: 15 additions & 0 deletions modules/claims_api/spec/models/auto_establish_claim_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,21 @@
end
end

describe '#transform_empty_unit_name!' do
let(:unit_name) { '' }

it 'trasforms an empty unit name to a space' do
temp_form_data = pending_record.form_data
temp_form_data['serviceInformation']['reservesNationalGuardService']['unitName'] = unit_name

pending_record.form_data = temp_form_data
payload = JSON.parse(pending_record.to_internal)
name = payload['form526']['serviceInformation']['reservesNationalGuardService']['unitName']

expect(name).to eq(' ')
end
end

describe 'evss_id_by_token' do
context 'with a record' do
let(:evss_record) { create(:auto_established_claim, evss_id: 123_456) }
Expand Down
Loading

0 comments on commit eb6521b

Please sign in to comment.