Module: DecisionReviewV1::Appeals::SupplementalClaimServices

Includes:
Helpers
Included in:
Service
Defined in:
lib/decision_review_v1/appeals/supplemental_claim_services.rb

Instance Method Summary collapse

Methods included from Helpers

#create_supplemental_claims_headers, #get_and_rejigger_required_info, #middle_initial, #payload_encrypted_string

Methods included from LoggingUtils

#benchmark_to_log_data_hash, #log_formatted, #parse_form412_response_to_log_msg, #parse_lighthouse_response_to_log_msg, #run_and_benchmark_if_enabled

Instance Method Details

#create_supplemental_claim(request_body:, user:) ⇒ Faraday::Response

Creates a new Supplemental Claim

Parameters:

  • request_body (JSON)

    JSON serialized version of a Supplemental Claim Form (20-0995)

  • user (User)

    Veteran who the form is in regard to

Returns:

  • (Faraday::Response)


35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/decision_review_v1/appeals/supplemental_claim_services.rb', line 35

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)
    response, bm = run_and_benchmark_if_enabled do
      perform :post, 'supplemental_claims', request_body, headers
    end
    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)'

    submission_info_message = parse_lighthouse_response_to_log_msg(data: response.body['data'], bm:)
    ::Rails.logger.info(submission_info_message)
    response
  end
end

#get_supplemental_claim(uuid) ⇒ Faraday::Response

Returns all of the data associated with a specific Supplemental Claim.

Parameters:

  • uuid (uuid)

    supplemental Claim UUID

Returns:

  • (Faraday::Response)


18
19
20
21
22
23
24
25
26
# File 'lib/decision_review_v1/appeals/supplemental_claim_services.rb', line 18

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.

Parameters:

  • user (User)

    Veteran who the form is in regard to

  • benefit_type (String)

    Type of benefit the decision review is for

Returns:

  • (Faraday::Response)


81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/decision_review_v1/appeals/supplemental_claim_services.rb', line 81

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)
    response = perform :get, path, nil, headers
    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(uuid:) ⇒ Faraday::Response

Returns all of the data associated with a specific Supplemental Claim Evidence Submission.

Parameters:

  • uuid (uuid)

    supplemental Claim UUID Evidence Submission

Returns:

  • (Faraday::Response)


149
150
151
152
153
# File 'lib/decision_review_v1/appeals/supplemental_claim_services.rb', line 149

def get_supplemental_claim_upload(uuid:)
  with_monitoring_and_error_handling do
    perform :get, "supplemental_claims/evidence_submissions/#{uuid}", nil
  end
end

#get_supplemental_claim_upload_url(sc_uuid:, file_number:) ⇒ Faraday::Response

Get the url to upload supporting evidence for a Supplemental Claim

Parameters:

  • sc_uuid (uuid)

    associated Supplemental Claim UUID

  • file_number (Integer)

    The file number or ssn

Returns:

  • (Faraday::Response)


103
104
105
106
107
108
# File 'lib/decision_review_v1/appeals/supplemental_claim_services.rb', line 103

def get_supplemental_claim_upload_url(sc_uuid:, file_number:)
  with_monitoring_and_error_handling do
    perform :post, 'supplemental_claims/evidence_submissions', { sc_uuid: },
            { 'X-VA-SSN' => file_number.to_s.strip.presence }
  end
end

#process_form4142_submission(appeal_submission_id:, rejiggered_payload:) ⇒ Faraday::Response

Creates a new 4142(a) PDF, and sends to central mail

Parameters:

  • appeal_submission_id
  • rejiggered_payload

Returns:

  • (Faraday::Response)


59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/decision_review_v1/appeals/supplemental_claim_services.rb', line 59

def process_form4142_submission(appeal_submission_id:, rejiggered_payload:)
  with_monitoring_and_error_handling do
    form4142_response, bm = run_and_benchmark_if_enabled do
      submit_form4142(form_data: rejiggered_payload)
    end
    form4142_submission_info_message = parse_form412_response_to_log_msg(
      appeal_submission_id:, data: form4142_response, bm:
    )
    ::Rails.logger.info(form4142_submission_info_message)
    form4142_response
  end
end

#put_supplemental_claim_upload(upload_url:, file_upload:, metadata_string:) ⇒ Faraday::Response

Upload supporting evidence for a Supplemental Claim

Parameters:

  • upload_url (String)

    The url for the document to be uploaded

  • file_path (String)

    The file path for the document to be uploaded

  • metadata_string (Hash)

    additional data

Returns:

  • (Faraday::Response)


119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/decision_review_v1/appeals/supplemental_claim_services.rb', line 119

def put_supplemental_claim_upload(upload_url:, file_upload:, metadata_string:)
  content_tmpfile = Tempfile.new(file_upload.filename, 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) }
  with_monitoring_and_error_handling do
    perform :put, upload_url, params, { 'Content-Type' => 'multipart/form-data' }
  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.

Parameters:

  • appeal_submission_id
  • rejiggered_payload
  • submitted_appeal_uuid

Returns:

  • String



180
181
182
183
184
185
186
# File 'lib/decision_review_v1/appeals/supplemental_claim_services.rb', line 180

def queue_form4142(appeal_submission_id:, rejiggered_payload:, submitted_appeal_uuid:)
  DecisionReview::Form4142Submit.perform_async(
    appeal_submission_id,
    payload_encrypted_string(rejiggered_payload),
    
  )
end

#queue_submit_evidence_uploads(sc_evidences, appeal_submission_id) ⇒ String

Returns an array of Job IDs (jids) of the queued evidence submission jobs

Parameters:

  • sc_evidence (sc_evidence)

    supplemental Claim UUID Evidence Submission

  • appeal_submission_id

Returns:

  • (String)


162
163
164
165
166
167
168
169
# File 'lib/decision_review_v1/appeals/supplemental_claim_services.rb', line 162

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