Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#90355 [10-10 Health Apps] Improve code quality for shared code #20022

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
eceeff9
Created a new enrollment system service to help with code readability
JoshingYou1 Dec 24, 2024
7fe7ebf
Merge branch 'master' of https://github.com/department-of-veterans-af…
JoshingYou1 Dec 24, 2024
1c48fca
Fixed linting issues
JoshingYou1 Dec 24, 2024
fd68cdd
Fixed linting issues
JoshingYou1 Dec 24, 2024
92a5f1f
Removed some unused test code and updated the swagger specs for HCA
JoshingYou1 Dec 24, 2024
993d293
Fixed some failing tests
JoshingYou1 Dec 24, 2024
874539a
Fixed a couple more failing tests
JoshingYou1 Dec 24, 2024
03066c6
Separated tests with flipper enabled and disabled
JoshingYou1 Dec 24, 2024
6f18f95
Fixed linting issue
JoshingYou1 Dec 26, 2024
efb5141
Fixed linting issue
JoshingYou1 Dec 26, 2024
f2a6d59
Fixed linting issues
JoshingYou1 Dec 26, 2024
49c107b
Fixed linting issues
JoshingYou1 Dec 26, 2024
ae3a419
Fixed linting issue
JoshingYou1 Dec 26, 2024
9347b9b
Removed some code changes that were made in a different branch
JoshingYou1 Jan 7, 2025
35b9cfb
Merged from master
JoshingYou1 Jan 7, 2025
7d05fde
Cleaned up some test code
JoshingYou1 Jan 7, 2025
afe1337
Fixed some linting errors
JoshingYou1 Jan 7, 2025
35a5789
Fixed some more linting errors
JoshingYou1 Jan 7, 2025
8fff4f5
Fixed another linting issue
JoshingYou1 Jan 7, 2025
4683176
Fixed another linting issue
JoshingYou1 Jan 7, 2025
827217d
Fixed some failing tests
JoshingYou1 Jan 8, 2025
19b426f
Tried to fix a linting issue
JoshingYou1 Jan 8, 2025
9efcd0a
Tried to fix a linting issue
JoshingYou1 Jan 8, 2025
761d5f2
test: trigger preview environment
JoshingYou1 Jan 14, 2025
d1599d5
test: trigger preview environment
JoshingYou1 Jan 15, 2025
ec715c9
Merge branch 'master' of https://github.com/department-of-veterans-af…
JoshingYou1 Jan 15, 2025
c891ec6
Merged from master
JoshingYou1 Jan 15, 2025
daf3fe7
Fixed linting issues
JoshingYou1 Jan 16, 2025
fa9eb40
Merge branch 'master' of https://github.com/department-of-veterans-af…
JoshingYou1 Jan 16, 2025
37e125d
Fixed linting issues
JoshingYou1 Jan 16, 2025
154ded0
test: trigger preview environment
JoshingYou1 Jan 22, 2025
88da1e2
Merge branch 'master' of https://github.com/department-of-veterans-af…
JoshingYou1 Jan 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions config/features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1406,6 +1406,10 @@ features:
actor_type: user
description: Use the original veteran_x models to power Appoint a Rep entity search
enable_in_development: true
va1010_forms_enrollment_system_service_enabled:
actor_type: user
description: Enables the VA1010Forms enrollment system service
enable_in_development: true
va_notify_custom_errors:
actor_type: user
description: Custom error classes instead of the generic Common::Exceptions::BackendServiceException
Expand Down
44 changes: 26 additions & 18 deletions lib/form1010_ezr/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
require 'hca/ezr_postfill'
require 'va1010_forms/utils'
require 'hca/overrides_parser'
require 'va1010_forms/enrollment_system/service'

module Form1010Ezr
class Service < Common::Client::Base
Expand Down Expand Up @@ -38,23 +39,25 @@ def submit_async(parsed_form)

def submit_sync(parsed_form)
res = with_monitoring do
es_submit(parsed_form, HealthCareApplication.get_user_identifier(@user), FORM_ID)
if Flipper.enabled?(:va1010_forms_enrollment_system_service_enabled)
VA1010Forms::EnrollmentSystem::Service.new(
HealthCareApplication.get_user_identifier(@user)
).submit(parsed_form, FORM_ID)
else
es_submit(parsed_form, HealthCareApplication.get_user_identifier(@user), FORM_ID)
end
end

# Log the 'formSubmissionId' for successful submissions
Rails.logger.info(
'1010EZR successfully submitted',
submission_id: res[:formSubmissionId],
veteran_initials: veteran_initials(parsed_form)
)
log_successful_submission(res[:formSubmissionId], veteran_initials(parsed_form))

if parsed_form['attachments'].present?
StatsD.increment("#{Form1010Ezr::Service::STATSD_KEY_PREFIX}.submission_with_attachment")
end

res
rescue => e
log_and_raise_error(e, parsed_form)
log_submission_failure(parsed_form)
raise e
end

# @param [HashWithIndifferentAccess] parsed_form JSON form data
Expand All @@ -66,7 +69,8 @@ def submit_form(parsed_form)

submit_async(parsed_form)
rescue => e
log_and_raise_error(e, parsed_form)
log_submission_failure(parsed_form)
raise e
end

def log_submission_failure(parsed_form)
Expand Down Expand Up @@ -107,11 +111,8 @@ def validate_form(parsed_form)
)
end

log_validation_errors(parsed_form)
log_validation_errors(validation_errors, parsed_form)

Rails.logger.error(
"10-10EZR form validation failed. Form does not match schema. Error list: #{validation_errors}"
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logger was moved into the log_validation_errors method.

raise Common::Exceptions::SchemaValidationErrors, validation_errors
end
end
Expand Down Expand Up @@ -168,19 +169,26 @@ def add_financial_flag(parsed_form)
end
end

def log_validation_errors(parsed_form)
# @param [Hash] errors
def log_validation_errors(errors, parsed_form)
StatsD.increment("#{Form1010Ezr::Service::STATSD_KEY_PREFIX}.validation_error")

Rails.logger.error(
"10-10EZR form validation failed. Form does not match schema. Error list: #{errors}"
)

PersonalInformationLog.create(
data: parsed_form,
error_class: 'Form1010Ezr ValidationError'
)
end

def log_and_raise_error(error, form)
log_submission_failure(form)
Rails.logger.error "10-10EZR form submission failed: #{error.message}"
raise error
def log_successful_submission(submission_id, veteran_initials)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to create this method because the submit_sync method was too long with this logger in place 😆

Rails.logger.info(
'1010EZR successfully submitted',
submission_id:,
veteran_initials:
)
end
end
end
7 changes: 6 additions & 1 deletion lib/hca/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require 'hca/enrollment_system'
require 'hca/configuration'
require 'va1010_forms/utils'
require 'va1010_forms/enrollment_system/service'

module HCA
class Service < Common::Client::Base
Expand All @@ -24,7 +25,11 @@ def submit_form(form)
is_short_form = HealthCareApplication.new(form: form.to_json).short_form?

with_monitoring do
es_submit(form, @user, '10-10EZ')
if Flipper.enabled?(:va1010_forms_enrollment_system_service_enabled)
VA1010Forms::EnrollmentSystem::Service.new(@user).submit(form, '10-10EZ')
else
es_submit(form, @user, '10-10EZ')
end
rescue => e
increment_failure('submit_form_short_form', e) if is_short_form
raise e
Expand Down
Loading
Loading