Module: DecisionReviewV1::Appeals::SupplementalClaimServices
- Includes:
- Helpers, LoggingUtils
- Included in:
- Service
- Defined in:
- lib/decision_review_v1/appeals/supplemental_claim_services.rb
Overview
rubocop:disable Metrics/ModuleLength
Constant Summary
Constants included from Helpers
Instance Method Summary collapse
-
#create_supplemental_claim(request_body:, user:) ⇒ Faraday::Response
Creates a new Supplemental Claim.
-
#get_supplemental_claim(uuid) ⇒ Faraday::Response
Returns all of the data associated with a specific Supplemental Claim.
-
#get_supplemental_claim_contestable_issues(user:, benefit_type:) ⇒ Faraday::Response
Returns all issues associated with a Veteran that have been decided as of the receiptDate.
-
#get_supplemental_claim_upload(guid:) ⇒ Faraday::Response
Returns all of the data associated with a specific Supplemental Claim Evidence Submission.
-
#get_supplemental_claim_upload_url(sc_uuid:, file_number:, user_uuid: nil, appeal_submission_upload_id: nil) ⇒ Faraday::Response
Get the url to upload supporting evidence for a Supplemental Claim.
-
#process_form4142_submission(appeal_submission_id:, rejiggered_payload:) ⇒ Faraday::Response
Creates a new 4142(a) PDF, and sends to Lighthouse.
-
#put_supplemental_claim_upload(upload_url:, file_upload:, metadata_string:, user_uuid: nil, appeal_submission_upload_id: nil) ⇒ Faraday::Response
Upload supporting evidence for a Supplemental Claim.
-
#queue_form4142(appeal_submission_id:, rejiggered_payload:, submitted_appeal_uuid:) ⇒ Object
Returns a sidekiq Job ID (jid) of the queued form4142 generation Sidekiq job is queued with the payload encrypted so there are no plaintext PII in the sidekiq job args.
-
#queue_submit_evidence_uploads(sc_evidences, appeal_submission_id) ⇒ String
Returns an array of Job IDs (jids) of the queued evidence submission jobs.
- #save_form4142_submission(appeal_submission_id:, rejiggered_payload:, guid:) ⇒ Object
- #submit_form4142(form_data:) ⇒ Object private
Methods included from LoggingUtils
#benchmark?, #benchmark_to_log_data_hash, #extract_uuid_from_central_mail_message, #log_formatted, #parse_form412_response_to_log_msg, #parse_lighthouse_response_to_log_msg, #run_and_benchmark_if_enabled
Methods included from Helpers
#create_supplemental_claims_headers, #get_and_rejigger_required_info, #middle_initial, #payload_encrypted_string
Instance Method Details
#create_supplemental_claim(request_body:, user:) ⇒ Faraday::Response
Creates a new Supplemental Claim
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/decision_review_v1/appeals/supplemental_claim_services.rb', line 39 def create_supplemental_claim(request_body:, user:) with_monitoring_and_error_handling do request_body = request_body.to_json if request_body.is_a?(Hash) headers = create_supplemental_claims_headers(user) common_log_params = { key: :overall_claim_submission, form_id: '995', user_uuid: user.uuid, downstream_system: 'Lighthouse' } response, bm = run_and_benchmark_if_enabled do perform :post, 'supplemental_claims', request_body, headers rescue => e log_formatted(**common_log_params.merge(error_log_params(e))) raise e end log_formatted(**common_log_params.merge(is_success: true, status_code: response.status, body: '[Redacted]')) raise_schema_error_unless_200_status response.status validate_against_schema json: response.body, schema: SC_CREATE_RESPONSE_SCHEMA, append_to_error_class: ' (SC_V1)' = parse_lighthouse_response_to_log_msg(data: response.body['data'], bm:) ::Rails.logger.info() response end end |
#get_supplemental_claim(uuid) ⇒ Faraday::Response
Returns all of the data associated with a specific Supplemental Claim.
22 23 24 25 26 27 28 29 30 |
# File 'lib/decision_review_v1/appeals/supplemental_claim_services.rb', line 22 def get_supplemental_claim(uuid) with_monitoring_and_error_handling do response = perform :get, "supplemental_claims/#{uuid}", nil raise_schema_error_unless_200_status response.status validate_against_schema json: response.body, schema: SC_SHOW_RESPONSE_SCHEMA, append_to_error_class: ' (SC_V1)' response end end |
#get_supplemental_claim_contestable_issues(user:, benefit_type:) ⇒ Faraday::Response
Returns all issues associated with a Veteran that have been decided as of the receiptDate. Not all issues returned are guaranteed to be eligible for appeal.
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/decision_review_v1/appeals/supplemental_claim_services.rb', line 119 def get_supplemental_claim_contestable_issues(user:, benefit_type:) with_monitoring_and_error_handling do path = "contestable_issues/supplemental_claims?benefit_type=#{benefit_type}" headers = get_contestable_issues_headers(user) common_log_params = { key: :get_contestable_issues, form_id: '995', user_uuid: user.uuid, upstream_system: 'Lighthouse' } begin response = perform :get, path, nil, headers log_formatted(**common_log_params.merge(is_success: true, status_code: response.status, body: '[Redacted]')) rescue => e # We can freely log Lighthouse's error responses because they do not include PII or PHI. # See https://developer.va.gov/explore/api/decision-reviews/docs?version=v1. log_formatted(**common_log_params.merge(error_log_params(e))) raise e end raise_schema_error_unless_200_status response.status validate_against_schema( json: response.body, schema: GET_CONTESTABLE_ISSUES_RESPONSE_SCHEMA, append_to_error_class: ' (SC_V1)' ) response end end |
#get_supplemental_claim_upload(guid:) ⇒ Faraday::Response
Returns all of the data associated with a specific Supplemental Claim Evidence Submission.
236 237 238 239 240 |
# File 'lib/decision_review_v1/appeals/supplemental_claim_services.rb', line 236 def get_supplemental_claim_upload(guid:) with_monitoring_and_error_handling do perform :get, "supplemental_claims/evidence_submissions/#{guid}", nil end end |
#get_supplemental_claim_upload_url(sc_uuid:, file_number:, user_uuid: nil, appeal_submission_upload_id: nil) ⇒ Faraday::Response
Get the url to upload supporting evidence for a Supplemental Claim
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/decision_review_v1/appeals/supplemental_claim_services.rb', line 151 def get_supplemental_claim_upload_url(sc_uuid:, file_number:, user_uuid: nil, appeal_submission_upload_id: nil) common_log_params = { key: :get_lighthouse_evidence_upload_url, form_id: '995', user_uuid:, upstream_system: 'Lighthouse', downstream_system: 'Lighthouse', params: { sc_uuid:, appeal_submission_upload_id: } } with_monitoring_and_error_handling do response = perform :post, 'supplemental_claims/evidence_submissions', { sc_uuid: }, { 'X-VA-SSN' => file_number.to_s.strip.presence } log_formatted(**common_log_params.merge(is_success: true, status_code: response.status, body: response.body)) response rescue => e # We can freely log Lighthouse's error responses because they do not include PII or PHI. # See https://developer.va.gov/explore/api/decision-reviews/docs?version=v2 log_formatted(**common_log_params.merge(error_log_params(e))) raise e end end |
#process_form4142_submission(appeal_submission_id:, rejiggered_payload:) ⇒ Faraday::Response
Creates a new 4142(a) PDF, and sends to Lighthouse
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/decision_review_v1/appeals/supplemental_claim_services.rb', line 69 def process_form4142_submission(appeal_submission_id:, rejiggered_payload:) with_monitoring_and_error_handling do response_container, bm = run_and_benchmark_if_enabled do submit_form4142(form_data: rejiggered_payload) end form4142_response, uuid = response_container if Flipper.enabled?(:decision_review_track_4142_submissions) save_form4142_submission(appeal_submission_id:, rejiggered_payload:, guid: uuid) end = parse_form412_response_to_log_msg( appeal_submission_id:, data: form4142_response, uuid:, bm: ) ::Rails.logger.info() form4142_response end end |
#put_supplemental_claim_upload(upload_url:, file_upload:, metadata_string:, user_uuid: nil, appeal_submission_upload_id: nil) ⇒ Faraday::Response
Upload supporting evidence for a Supplemental Claim
rubocop:disable Metrics/MethodLength
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
# File 'lib/decision_review_v1/appeals/supplemental_claim_services.rb', line 186 def put_supplemental_claim_upload(upload_url:, file_upload:, metadata_string:, user_uuid: nil, appeal_submission_upload_id: nil) tmpfile_name = construct_tmpfile_name(appeal_submission_upload_id, file_upload.filename) content_tmpfile = Tempfile.new([tmpfile_name, '.pdf'], encoding: file_upload.read.encoding) content_tmpfile.write(file_upload.read) content_tmpfile.rewind json_tmpfile = Tempfile.new('metadata.json', encoding: 'utf-8') json_tmpfile.write() json_tmpfile.rewind params = { metadata: Faraday::UploadIO.new(json_tmpfile.path, Mime[:json].to_s, 'metadata.json'), content: Faraday::UploadIO.new(content_tmpfile.path, Mime[:pdf].to_s, file_upload.filename) } # when we upgrade to Faraday >1.0 # params = { metadata: Faraday::FilePart.new(json_tmpfile, Mime[:json].to_s, 'metadata.json'), # content: Faraday::FilePart.new(content_tmpfile, Mime[:pdf].to_s, file_upload.filename) } common_log_params = { key: :evidence_upload_to_lighthouse, form_id: '995', user_uuid:, downstream_system: 'Lighthouse', params: { upload_url:, appeal_submission_upload_id: } } with_monitoring_and_error_handling do response = perform :put, upload_url, params, { 'Content-Type' => 'multipart/form-data' } log_formatted(**common_log_params.merge(is_success: true, status_code: response.status, body: '[Redacted]')) response rescue => e # We can freely log Lighthouse's error responses because they do not include PII or PHI. # See https://developer.va.gov/explore/api/decision-reviews/docs?version=v2 log_formatted(**common_log_params.merge(error_log_params(e))) raise e end ensure content_tmpfile.close content_tmpfile.unlink json_tmpfile.close json_tmpfile.unlink end |
#queue_form4142(appeal_submission_id:, rejiggered_payload:, submitted_appeal_uuid:) ⇒ Object
Returns a sidekiq Job ID (jid) of the queued form4142 generation Sidekiq job is queued with the payload encrypted so there are no plaintext PII in the sidekiq job args.
267 268 269 270 271 272 273 |
# File 'lib/decision_review_v1/appeals/supplemental_claim_services.rb', line 267 def queue_form4142(appeal_submission_id:, rejiggered_payload:, submitted_appeal_uuid:) DecisionReview::Form4142Submit.perform_async( appeal_submission_id, payload_encrypted_string(rejiggered_payload), submitted_appeal_uuid ) end |
#queue_submit_evidence_uploads(sc_evidences, appeal_submission_id) ⇒ String
Returns an array of Job IDs (jids) of the queued evidence submission jobs
249 250 251 252 253 254 255 256 |
# File 'lib/decision_review_v1/appeals/supplemental_claim_services.rb', line 249 def queue_submit_evidence_uploads(sc_evidences, appeal_submission_id) sc_evidences.map do |upload| asu = AppealSubmissionUpload.create!(decision_review_evidence_attachment_guid: upload['confirmationCode'], appeal_submission_id:) DecisionReview::SubmitUpload.perform_async(asu.id) end end |
#save_form4142_submission(appeal_submission_id:, rejiggered_payload:, guid:) ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/decision_review_v1/appeals/supplemental_claim_services.rb', line 88 def save_form4142_submission(appeal_submission_id:, rejiggered_payload:, guid:) form_record = SecondaryAppealForm.new( form: rejiggered_payload.to_json, form_id: '21-4142', appeal_submission_id: appeal_submission_id, guid: guid ) form_record.save! rescue => e ::Rails.logger.error({ error_message: e., form_id: DecisionReviewV1::FORM4142_ID, parent_form_id: DecisionReviewV1::SUPP_CLAIM_FORM_ID, message: 'Supplemental Claim Form4142 Persistence Errored', appeal_submission_id:, lighthouse_submission: { id: uuid } }) raise e end |
#submit_form4142(form_data:) ⇒ Object (private)
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
# File 'lib/decision_review_v1/appeals/supplemental_claim_services.rb', line 277 def submit_form4142(form_data:) processor = DecisionReviewV1::Processor::Form4142Processor.new(form_data:) service = BenefitsIntake::Service.new service.request_upload payload = { metadata: processor.request_body['metadata'], document: processor.request_body['document'], upload_url: service.location } response = service.perform_upload(**payload) [response, service.uuid] end |