diff --git a/app/controllers/v0/disability_compensation_in_progress_forms_controller.rb b/app/controllers/v0/disability_compensation_in_progress_forms_controller.rb index fe1342c1238..08acc1a67d1 100644 --- a/app/controllers/v0/disability_compensation_in_progress_forms_controller.rb +++ b/app/controllers/v0/disability_compensation_in_progress_forms_controller.rb @@ -6,10 +6,15 @@ class DisabilityCompensationInProgressFormsController < InProgressFormsControlle def show if form_for_user - render json: data_and_metadata_with_updated_rated_disabilities + # get IPF + data = data_and_metadata_with_updated_rated_disabilities + log_started_form_version(data, 'get IPF') else - render json: camelized_prefill_for_user + # create IPF + data = camelized_prefill_for_user + log_started_form_version(data, 'create IPF') end + render json: data end private @@ -63,5 +68,27 @@ def arr_to_compare(rated_disabilities) "#{diagnostic_code}#{rated_disability_id}#{rd['name']}" end&.sort end + + # temp: for https://github.com/department-of-veterans-affairs/va.gov-team/issues/97932 + # tracking down a possible issue with prefill + def log_started_form_version(data, location) + cloned_data = data.deep_dup + cloned_data_as_json = cloned_data.as_json.deep_transform_keys { |k| k.camelize(:lower) } + + if cloned_data_as_json['formData'].present? + started_form_version = cloned_data_as_json['formData']['startedFormVersion'] + message = "Form526 InProgressForm startedFormVersion = #{started_form_version} #{location}" + Rails.logger.info(message) + end + + if started_form_version.blank? + raise Common::Exceptions::ServiceError.new( + detail: "no startedFormVersion detected in #{location}", + source: 'DisabilityCompensationInProgressFormsController#show' + ) + end + rescue => e + Rails.logger.error("Form526 InProgressForm startedFormVersion retrieval failed #{location} #{e.message}") + end end end