Skip to content

Commit

Permalink
update Form526Submission.form w/ classificationCode before submitting…
Browse files Browse the repository at this point in the history
… to eVSS (#12905)

* fix missing request param

* log submission id before classification

* write update_form_classification() to actually update the form for eVSS

* WIP - troubleshooting method not getting called

* wip endponit

* still WIP testing form update functionality

* fix logic for updating form, test against changed outputs

* remove comment

* fix rubocop issues

* remove safeguards for handling legacy vro code

* simplify form update function

* update spec mock request to resemble current api response

* address rubocop

* change logging statement to work better w/ datadog

* switch to form.to_json

* move nil check up

* update settings for local vro testing

* add additional test case for handling null response

* address rubocop issues

* address rubocop issue

* update spec to reflect latest vro api response

---------

Co-authored-by: verdanceluke <[email protected]>
  • Loading branch information
lukey-luke and verdance-luke authored Jun 9, 2023
1 parent a5722ee commit 2a75c3a
Show file tree
Hide file tree
Showing 7 changed files with 136 additions and 11 deletions.
13 changes: 9 additions & 4 deletions app/models/concerns/form526_rapid_ready_for_decision_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,24 @@ def update_classification
form526_submission_id: id
}

Rails.logger.info('classifying 526Submission', id:, saved_claim_id:)
classification = classify_by_diagnostic_code(params)
update_form_with_classification(classification['classification_code']) if classification.present?
update_form_with_classification_code(classification['classification_code']) if classification.present?
end

# check claims
def classify_by_diagnostic_code(params)
vro_client = VirtualRegionalOffice::Client.new
response = vro_client.classify_contention_by_diagnostic_code(params)
response.body
end

def update_form_with_classification(_classification_code)
# TODO: update form[FORM_526] to include the classification code
def update_form_with_classification_code(classification_code)
form[Form526Submission::FORM_526]['form526']['disabilities'].each do |disability|
disability['classificationCode'] = classification_code
end

update!(form_json: form.to_json)
invalidate_form_hash
end

def send_post_evss_notifications!
Expand Down
5 changes: 3 additions & 2 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1516,11 +1516,12 @@ rrd:
- fake_email

virtual_regional_office:
url: http://localhost:8080
url: http://localhost:8120
api_key: 9d3868d1-ec15-4889-8002-2bff1b50ba62
health_assessment_path: health-data-assessment
evidence_pdf_path: evidence-pdf
ctn_classification_path: contention-classification/classifier
# ctn_classification_path: contention-classification/classifier
ctn_classification_path: classifier

# Settings for Test User Dashboard modules
test_user_dashboard:
Expand Down
2 changes: 1 addition & 1 deletion lib/virtual_regional_office/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Configuration < Common::Client::Configuration::REST
self.read_timeout = Settings.virtual_regional_office&.read_timeout || 60

def base_path
"#{Settings.virtual_regional_office.url}/#{API_VERSION}"
Settings.virtual_regional_office.url.to_s
end

def service_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
require 'rails_helper'
require 'disability_compensation/factories/api_provider_factory'

ASTHMA_CLASSIFICATION_CODE = 6602
# pulled from vets-api/spec/support/disability_compensation_form/submissions/only_526.json
ONLY_526_JSON_CLASSIFICATION_CODE = 'string'

RSpec.describe EVSS::DisabilityCompensationForm::SubmitForm526AllClaim, type: :job do
subject { described_class }

Expand Down Expand Up @@ -80,6 +84,35 @@ def expect_retryable_error(error_class)
end.not_to change(Sidekiq::Form526BackupSubmissionProcess::Submit.jobs, :size)
expect(Form526JobStatus.last.status).to eq 'success'
end

it 'handles null response gracefully' do
subject.perform_async(submission.id)
expect do
VCR.use_cassette('virtual_regional_office/contention_classification_null_response') do
described_class.drain
submission.reload

final_classification_code = submission.form['form526']['form526']['disabilities'][0]['classificationCode']
expect(final_classification_code).to eq(ONLY_526_JSON_CLASSIFICATION_CODE)
end
end.not_to change(Sidekiq::Form526BackupSubmissionProcess::Submit.jobs, :size)
expect(Form526JobStatus.last.status).to eq 'success'
end

it 'updates Form526Submission form with id' do
expect(described_class).to be < EVSS::DisabilityCompensationForm::SubmitForm526
subject.perform_async(submission.id)

expect do
VCR.use_cassette('virtual_regional_office/contention_classification') do
described_class.drain
submission.reload

final_classification_code = submission.form['form526']['form526']['disabilities'][0]['classificationCode']
expect(final_classification_code).to eq(ASTHMA_CLASSIFICATION_CODE)
end
end.not_to change(Sidekiq::Form526BackupSubmissionProcess::Submit.jobs, :size)
end
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

it 'returns a classification' do
VCR.use_cassette('virtual_regional_office/contention_classification') do
expect(subject.body['responseBody']['classification_name']).to eq('asthma')
expect(subject.body['classification_name']).to eq('asthma')
end
end
end
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2a75c3a

Please sign in to comment.