Class: V0::CaregiversAssistanceClaimsController
- Inherits:
-
ApplicationController
- Object
- ActionController::API
- ApplicationController
- V0::CaregiversAssistanceClaimsController
- Defined in:
- app/controllers/v0/caregivers_assistance_claims_controller.rb
Overview
Application for the Program of Comprehensive Assistance for Family Caregivers (Form 10-10CG)
Constant Summary collapse
- AUDITOR =
::Form1010cg::Auditor.new
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
- #auditor ⇒ Object private
- #backend_service_outage ⇒ Object private
- #create ⇒ Object
-
#download_pdf ⇒ Object
If we were unable to submit the user’s claim digitally, we allow them to the download the 10-10CG PDF, pre-filled with their data, for them to mail in.
- #facilities ⇒ Object
- #file_name_for_pdf(veteran_data) ⇒ Object private
- #form_submission ⇒ Object private
- #initialize_claim ⇒ Object private
- #lighthouse_facilities_params ⇒ Object private
- #lighthouse_facilities_service ⇒ Object private
- #record_submission_attempt ⇒ Object private
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
#auditor ⇒ Object (private)
124 125 126 |
# File 'app/controllers/v0/caregivers_assistance_claims_controller.rb', line 124 def auditor self.class::AUDITOR end |
#backend_service_outage ⇒ Object (private)
115 116 117 118 119 120 121 122 |
# File 'app/controllers/v0/caregivers_assistance_claims_controller.rb', line 115 def backend_service_outage auditor.record( :submission_failure_client_qualification, claim_guid: @claim.guid ) render_errors Common::Exceptions::ServiceOutage.new(nil, detail: 'Backend Service Outage') end |
#create ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/controllers/v0/caregivers_assistance_claims_controller.rb', line 19 def create if @claim.valid? Sentry.(claim_guid: @claim.guid) auditor.record_caregivers(@claim) ::Form1010cg::Service.new(@claim).assert_veteran_status @claim.save! ::Form1010cg::SubmissionJob.perform_async(@claim.id) render json: ::Form1010cg::ClaimSerializer.new(@claim) else PersonalInformationLog.create!(data: { form: @claim.parsed_form }, error_class: '1010CGValidationError') auditor.record(:submission_failure_client_data, claim_guid: @claim.guid, errors: @claim.errors.) raise(Common::Exceptions::ValidationErrors, @claim) end rescue => e unless e.is_a?(Common::Exceptions::ValidationErrors) || e.is_a?(::Form1010cg::Service::InvalidVeteranStatus) Rails.logger.error('CaregiverAssistanceClaim: error submitting claim', { saved_claim_guid: @claim.guid, error: e }) end raise e end |
#download_pdf ⇒ Object
If we were unable to submit the user’s claim digitally, we allow them to the download the 10-10CG PDF, pre-filled with their data, for them to mail in.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/controllers/v0/caregivers_assistance_claims_controller.rb', line 44 def download_pdf source_file_path = if Flipper.enabled?(:caregiver1010) @claim.to_pdf(SecureRandom.uuid, sign: false) else PdfFill::Filler.fill_form( @claim, SecureRandom.uuid, sign: false ) end client_file_name = file_name_for_pdf(@claim.veteran_data) file_contents = File.read(source_file_path) auditor.record(:pdf_download) send_data file_contents, filename: client_file_name, type: 'application/pdf', disposition: 'attachment' ensure File.delete(source_file_path) if source_file_path && File.exist?(source_file_path) end |
#facilities ⇒ Object
64 65 66 67 |
# File 'app/controllers/v0/caregivers_assistance_claims_controller.rb', line 64 def facilities lighthouse_facilities = lighthouse_facilities_service.get_paginated_facilities(lighthouse_facilities_params) render(json: lighthouse_facilities) end |
#file_name_for_pdf(veteran_data) ⇒ Object (private)
108 109 110 111 112 113 |
# File 'app/controllers/v0/caregivers_assistance_claims_controller.rb', line 108 def file_name_for_pdf(veteran_data) veteran_name = veteran_data.try(:[], 'fullName') first_name = veteran_name.try(:[], 'first') || 'First' last_name = veteran_name.try(:[], 'last') || 'Last' "10-10CG_#{first_name}_#{last_name}.pdf" end |
#form_submission ⇒ Object (private)
97 98 99 100 101 102 |
# File 'app/controllers/v0/caregivers_assistance_claims_controller.rb', line 97 def form_submission params.require(:caregivers_assistance_claim).require(:form) rescue => e auditor.record(:submission_failure_client_data, errors: [e.]) raise e end |
#initialize_claim ⇒ Object (private)
104 105 106 |
# File 'app/controllers/v0/caregivers_assistance_claims_controller.rb', line 104 def initialize_claim @claim = SavedClaim::CaregiversAssistanceClaim.new(form: form_submission) end |
#lighthouse_facilities_params ⇒ Object (private)
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'app/controllers/v0/caregivers_assistance_claims_controller.rb', line 75 def lighthouse_facilities_params params.permit( :zip, :state, :lat, :long, :radius, :visn, :type, :mobile, :page, :per_page, :facilityIds, services: [], bbox: [] ) end |
#lighthouse_facilities_service ⇒ Object (private)
71 72 73 |
# File 'app/controllers/v0/caregivers_assistance_claims_controller.rb', line 71 def lighthouse_facilities_service @lighthouse_facilities_service ||= Lighthouse::Facilities::V1::Client.new end |
#record_submission_attempt ⇒ Object (private)
93 94 95 |
# File 'app/controllers/v0/caregivers_assistance_claims_controller.rb', line 93 def record_submission_attempt auditor.record(:submission_attempt) end |