Class: V0::DisabilityCompensationFormsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/v0/disability_compensation_forms_controller.rb

Constant Summary

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 Method Summary collapse

Methods inherited from ApplicationController

#clear_saved_form, #cors_preflight, #routing_error

Methods included from Traceable

#set_trace_tags

Methods included from SentryLogging

#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger

Methods included from SignIn::Authentication

#authenticate, #authenticate_service_account, #load_user

Methods included from Headers

#block_unknown_hosts, #set_app_info_headers

Methods included from AuthenticationAndSSOConcerns

#authenticate, #clear_session, #extend_session!, #load_user, #log_sso_info, #render_unauthorized, #reset_session, #set_api_cookie!, #set_session_expiration_header, #sso_logging_info, #validate_inbound_login_params, #validate_session

Instance Method Details

#rated_disabilitiesObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/v0/disability_compensation_forms_controller.rb', line 18

def rated_disabilities
  api_provider = ApiProviderFactory.call(
    type: ApiProviderFactory::FACTORIES[:rated_disabilities],
    provider: nil,
    options: { icn: @current_user.icn.to_s, auth_headers: },
    current_user: @current_user,
    feature_toggle: ApiProviderFactory::FEATURE_TOGGLE_RATED_DISABILITIES_FOREGROUND
  )

  response = api_provider.get_rated_disabilities

  render json: response,
         serializer: RatedDisabilitiesSerializer
end

#rating_infoObject



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'app/controllers/v0/disability_compensation_forms_controller.rb', line 78

def rating_info
  if lighthouse?
    service = LighthouseRatedDisabilitiesProvider.new(@current_user.icn)

    disability_rating = service.get_combined_disability_rating

    render json: { user_percent_of_disability: disability_rating },
           serializer: LighthouseRatingInfoSerializer
  else
    rating_info_service = EVSS::CommonService.new(auth_headers)
    response = rating_info_service.get_rating_info

    render json: response, serializer: RatingInfoSerializer
  end
end

#separation_locationsObject



33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/v0/disability_compensation_forms_controller.rb', line 33

def separation_locations
  response = EVSS::ReferenceData::ResponseStrategy.new.cache_by_user_and_type(
    :all_users,
    :get_separation_locations
  ) do
    EVSS::ReferenceData::Service.new(@current_user).get_separation_locations
  end

  render json: response, each_serializer: EVSSSeparationLocationSerializer
end

#submission_statusObject



71
72
73
74
75
76
# File 'app/controllers/v0/disability_compensation_forms_controller.rb', line 71

def submission_status
  job_status = Form526JobStatus.where(job_id: params[:job_id]).first
  raise Common::Exceptions::RecordNotFound, params[:job_id] unless job_status

  render json: job_status, serializer: Form526JobStatusSerializer
end

#submit_all_claimObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'app/controllers/v0/disability_compensation_forms_controller.rb', line 49

def submit_all_claim
  form_content = JSON.parse(request.body.string)
  saved_claim = SavedClaim::DisabilityCompensation::Form526AllClaim.from_hash(form_content)
  saved_claim.save ? log_success(saved_claim) : log_failure(saved_claim)
  submission = create_submission(saved_claim)
  # if jid = 0 then the submission was prevented from going any further in the process
  jid = 0

  # Feature flag to stop submission from being submitted to third-party service
  # With this on, the submission will NOT be processed by EVSS or Lighthouse,
  # nor will it go to VBMS,
  # but the line of code before this one creates the submission in the vets-api database
  if Flipper.enabled?(:disability_compensation_prevent_submission_job, @current_user)
    Rails.logger.info("Submission ID: #{submission.id} prevented from sending to third party service.")
  else
    jid = submission.start
  end

  render json: { data: { attributes: { job_id: jid } } },
         status: :ok
end

#suggested_conditionsObject



44
45
46
47
# File 'app/controllers/v0/disability_compensation_forms_controller.rb', line 44

def suggested_conditions
  results = DisabilityContention.suggested(params[:name_part])
  render json: results, each_serializer: DisabilityContentionSerializer
end