Class: V1::SupplementalClaimsController
- Inherits:
-
AppealsBaseControllerV1
- Object
- ActionController::API
- ApplicationController
- AppealsBaseControllerV1
- V1::SupplementalClaimsController
- Defined in:
- app/controllers/v1/supplemental_claims_controller.rb
Constant Summary
Constants included from DecisionReview::SavedClaim::Service
DecisionReview::SavedClaim::Service::VALID_CLASS
Constants included from DecisionReviewV1::Appeals::Helpers
DecisionReviewV1::Appeals::Helpers::DR_LOCKBOX
Constants inherited from ApplicationController
ApplicationController::VERSION_STATUS
Constants included from SignIn::Authentication
SignIn::Authentication::BEARER_PATTERN
Constants included from ExceptionHandling
ExceptionHandling::SKIP_SENTRY_EXCEPTION_TYPES
Instance Attribute Summary
Attributes inherited from ApplicationController
Instance Method Summary collapse
- #clear_in_progress_form ⇒ Object private
- #create ⇒ Object
- #create_appeal_submission(submitted_appeal_uuid, backup_zip) ⇒ Object private
- #error_class(method:, exception_class:) ⇒ Object private
- #handle_4142(request_body:, form4142:, appeal_submission_id:, submitted_appeal_uuid:) ⇒ Object private
- #handle_personal_info_error(e) ⇒ Object private
- #handle_saved_claim(form:, guid:, form4142:) ⇒ Object private
- #log_form4142_job_queued(appeal_submission_id, submitted_appeal_uuid, jid) ⇒ Object private
- #post_create_log_msg(appeal_submission_id:, submitted_appeal_uuid:) ⇒ Object private
- #process_submission ⇒ Object private
- #show ⇒ Object
- #submit_evidence(sc_evidence, appeal_submission_id, submitted_appeal_uuid) ⇒ Object private
Methods included from DecisionReview::SavedClaim::Service
Methods included from DecisionReviewV1::Appeals::Helpers
#create_supplemental_claims_headers, #get_and_rejigger_required_info, #middle_initial, #payload_encrypted_string
Methods included from DecisionReviewV1::Appeals::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 inherited from AppealsBaseControllerV1
#decision_review_service, #get_hash_from_request_body, #request_body_debug_data, #request_body_hash, #request_body_is_not_a_hash_error
Methods included from FailedRequestLoggable
#current_user_hash, #log_exception_to_personal_information_log
Methods inherited from ApplicationController
#clear_saved_form, #cors_preflight, #pagination_params, #render_job_id, #routing_error, #set_csrf_header
Methods included from Traceable
Methods included from SentryControllerLogging
#set_tags_and_extra_context, #tags_context, #user_context
Methods included from SentryLogging
#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger, #set_sentry_metadata
Methods included from Instrumentation
Methods included from SignIn::Authentication
#access_token, #access_token_authenticate, #authenticate, #authenticate_access_token, #bearer_token, #cookie_access_token, #handle_authenticate_error, #load_user, #load_user_object, #scrub_bearer_token, #validate_request_ip
Methods included from Headers
Methods included from ExceptionHandling
#render_errors, #report_mapped_exception, #report_original_exception, #skip_sentry_exception?, #skip_sentry_exception_types
Methods included from AuthenticationAndSSOConcerns
#authenticate, #clear_session, #extend_session!, #load_user, #log_sso_info, #render_unauthorized, #reset_session, #set_api_cookie!, #set_current_user, #set_session_expiration_header, #set_session_object, #sign_in_service_exp_time, #sign_in_service_session, #sso_cookie_content, #sso_logging_info, #validate_inbound_login_params, #validate_session
Methods included from SignIn::AudienceValidator
#authenticate, #validate_audience!
Instance Method Details
#clear_in_progress_form ⇒ Object (private)
138 139 140 |
# File 'app/controllers/v1/supplemental_claims_controller.rb', line 138 def clear_in_progress_form InProgressForm.form_for_user('20-0995', @current_user)&.destroy! end |
#create ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/v1/supplemental_claims_controller.rb', line 22 def create process_submission rescue => e ::Rails.logger.error( message: "Exception occurred while submitting Supplemental Claim: #{e.}", backtrace: e.backtrace ) handle_personal_info_error(e) end |
#create_appeal_submission(submitted_appeal_uuid, backup_zip) ⇒ Object (private)
117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'app/controllers/v1/supplemental_claims_controller.rb', line 117 def create_appeal_submission(submitted_appeal_uuid, backup_zip) = DecisionReviewV1::Service.( @current_user, backup_zip ) create_params = { user_uuid: @current_user.uuid, user_account: @current_user.user_account, type_of_appeal: 'SC', submitted_appeal_uuid:, upload_metadata: } appeal_submission = AppealSubmission.create!(create_params) appeal_submission.id end |
#error_class(method:, exception_class:) ⇒ Object (private)
142 143 144 |
# File 'app/controllers/v1/supplemental_claims_controller.rb', line 142 def error_class(method:, exception_class:) "#{self.class.name}##{method} exception #{exception_class} (SC_V1)" end |
#handle_4142(request_body:, form4142:, appeal_submission_id:, submitted_appeal_uuid:) ⇒ Object (private)
44 45 46 47 48 49 50 |
# File 'app/controllers/v1/supplemental_claims_controller.rb', line 44 def handle_4142(request_body:, form4142:, appeal_submission_id:, submitted_appeal_uuid:) return if form4142.blank? rejiggered_payload = get_and_rejigger_required_info(request_body:, form4142:, user: @current_user) jid = decision_review_service.queue_form4142(appeal_submission_id:, rejiggered_payload:, submitted_appeal_uuid:) log_form4142_job_queued(appeal_submission_id, submitted_appeal_uuid, jid) end |
#handle_personal_info_error(e) ⇒ Object (private)
80 81 82 83 84 85 86 87 88 89 90 |
# File 'app/controllers/v1/supplemental_claims_controller.rb', line 80 def handle_personal_info_error(e) request = begin { body: request_body_hash } rescue request_body_debug_data end log_exception_to_personal_information_log( e, error_class: error_class(method: 'create', exception_class: e.class), request: ) raise end |
#handle_saved_claim(form:, guid:, form4142:) ⇒ Object (private)
132 133 134 135 136 |
# File 'app/controllers/v1/supplemental_claims_controller.rb', line 132 def handle_saved_claim(form:, guid:, form4142:) uploaded_forms = [] uploaded_forms << '21-4142' if form4142.present? store_saved_claim(claim_class: SavedClaim::SupplementalClaim, form:, guid:, uploaded_forms:) end |
#log_form4142_job_queued(appeal_submission_id, submitted_appeal_uuid, jid) ⇒ Object (private)
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/controllers/v1/supplemental_claims_controller.rb', line 52 def log_form4142_job_queued(appeal_submission_id, submitted_appeal_uuid, jid) ::Rails.logger.info({ form_id: DecisionReviewV1::FORM4142_ID, parent_form_id: DecisionReviewV1::SUPP_CLAIM_FORM_ID, message: 'Supplemental Claim Form4142 queued.', jid:, appeal_submission_id:, lighthouse_submission: { id: submitted_appeal_uuid } }) end |
#post_create_log_msg(appeal_submission_id:, submitted_appeal_uuid:) ⇒ Object (private)
34 35 36 37 38 39 40 41 42 |
# File 'app/controllers/v1/supplemental_claims_controller.rb', line 34 def post_create_log_msg(appeal_submission_id:, submitted_appeal_uuid:) { message: 'Supplemental Claim Appeal Record Created', appeal_submission_id:, lighthouse_submission: { id: submitted_appeal_uuid } } end |
#process_submission ⇒ Object (private)
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'app/controllers/v1/supplemental_claims_controller.rb', line 92 def process_submission req_body_obj = request_body_hash.is_a?(String) ? JSON.parse(request_body_hash) : request_body_hash saved_claim_request_body = req_body_obj.to_json # serialize before request body is modified form4142 = req_body_obj.delete('form4142') sc_evidence = req_body_obj.delete('additionalDocuments') zip_from_frontend = req_body_obj.dig('data', 'attributes', 'veteran', 'address', 'zipCode5') sc_response = decision_review_service.create_supplemental_claim(request_body: req_body_obj, user: @current_user) submitted_appeal_uuid = sc_response.body.dig('data', 'id') ActiveRecord::Base.transaction do appeal_submission_id = create_appeal_submission(submitted_appeal_uuid, zip_from_frontend) handle_saved_claim(form: saved_claim_request_body, guid: submitted_appeal_uuid, form4142:) ::Rails.logger.info(post_create_log_msg(appeal_submission_id:, submitted_appeal_uuid:)) handle_4142(request_body: req_body_obj, form4142:, appeal_submission_id:, submitted_appeal_uuid:) submit_evidence(sc_evidence, appeal_submission_id, submitted_appeal_uuid) if sc_evidence.present? # Only destroy InProgressForm after evidence upload step # so that we still have references if a fatal error occurs before this step clear_in_progress_form end render json: sc_response.body, status: sc_response.status end |
#show ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'app/controllers/v1/supplemental_claims_controller.rb', line 13 def show render json: decision_review_service.get_supplemental_claim(params[:id]).body rescue => e log_exception_to_personal_information_log( e, error_class: error_class(method: 'show', exception_class: e.class), id: params[:id] ) raise end |
#submit_evidence(sc_evidence, appeal_submission_id, submitted_appeal_uuid) ⇒ Object (private)
65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'app/controllers/v1/supplemental_claims_controller.rb', line 65 def submit_evidence(sc_evidence, appeal_submission_id, submitted_appeal_uuid) # I know I could just use `appeal_submission.enqueue_uploads` here, but I want to return the jids to log, so # replicating instead. There is some duplicate code but I want them jids in the logs. jids = decision_review_service.queue_submit_evidence_uploads(sc_evidence, appeal_submission_id) ::Rails.logger.info({ form_id: DecisionReviewV1::SUPP_CLAIM_FORM_ID, message: 'Supplemental Claim Evidence jobs created.', appeal_submission_id:, lighthouse_submission: { id: submitted_appeal_uuid }, evidence_upload_job_ids: jids }) end |