From 9cbbd127c0159454f0e792be45c5ecd2fbba2b11 Mon Sep 17 00:00:00 2001 From: baarkerlounger <5101747+baarkerlounger@users.noreply.github.com> Date: Fri, 6 May 2022 11:51:37 +0100 Subject: [PATCH] Allow illness type to be refused (#553) --- app/services/imports/case_logs_import_service.rb | 7 ++++++- config/forms/2021_2022.json | 3 +++ config/forms/2022_2023.json | 3 +++ ...350_add_prefers_not_to_say_illness_type_to_case_logs.rb | 5 +++++ db/schema.rb | 3 ++- spec/fixtures/exports/case_logs.xml | 1 + 6 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20220506092350_add_prefers_not_to_say_illness_type_to_case_logs.rb diff --git a/app/services/imports/case_logs_import_service.rb b/app/services/imports/case_logs_import_service.rb index c41837f5d..d1bab1056 100644 --- a/app/services/imports/case_logs_import_service.rb +++ b/app/services/imports/case_logs_import_service.rb @@ -95,6 +95,7 @@ module Imports (1..10).each do |index| attributes["illness_type_#{index}"] = illness_type(xml_doc, index, attributes["illness"]) end + attributes["illness_type_0"] = 1 if (1..10).all? { |idx| attributes["illness_type_#{idx}"].nil? || attributes["illness_type_#{idx}"].zero? } attributes["prevten"] = unsafe_string_as_integer(xml_doc, "Q11") attributes["prevloc"] = string_or_nil(xml_doc, "Q12aONS") @@ -203,7 +204,7 @@ module Imports differences = [] attributes.each do |key, value| case_log_value = case_log.send(key.to_sym) - next if key == "majorrepairs" + next if fields_not_present_in_softwire_data.include?(key) if value != case_log_value differences.push("#{key} #{value.inspect} #{case_log_value.inspect}") @@ -212,6 +213,10 @@ module Imports @logger.warn "Differences found when saving log #{case_log.old_id}: #{differences}" unless differences.empty? end + def fields_not_present_in_softwire_data + %w[majorrepairs illness_type_0] + end + def check_status_completed(case_log, previous_status) if previous_status.include?("submitted") && case_log.status != "completed" @logger.warn "Case log #{case_log.id} is not completed" diff --git a/config/forms/2021_2022.json b/config/forms/2021_2022.json index ce1506f36..8715e1a46 100644 --- a/config/forms/2021_2022.json +++ b/config/forms/2021_2022.json @@ -3286,6 +3286,9 @@ }, "illness_type_10": { "value": "Other" + }, + "illness_type_0": { + "value": "Tenant prefers not to say" } } } diff --git a/config/forms/2022_2023.json b/config/forms/2022_2023.json index a6cdee73e..911b1bece 100644 --- a/config/forms/2022_2023.json +++ b/config/forms/2022_2023.json @@ -3329,6 +3329,9 @@ }, "illness_type_10": { "value": "Other" + }, + "illness_type_0": { + "value": "Tenant prefers not to say" } } } diff --git a/db/migrate/20220506092350_add_prefers_not_to_say_illness_type_to_case_logs.rb b/db/migrate/20220506092350_add_prefers_not_to_say_illness_type_to_case_logs.rb new file mode 100644 index 000000000..0dfd80752 --- /dev/null +++ b/db/migrate/20220506092350_add_prefers_not_to_say_illness_type_to_case_logs.rb @@ -0,0 +1,5 @@ +class AddPrefersNotToSayIllnessTypeToCaseLogs < ActiveRecord::Migration[7.0] + def change + add_column :case_logs, :illness_type_0, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 910c52197..ddab93cfe 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2022_04_27_160536) do +ActiveRecord::Schema[7.0].define(version: 2022_05_06_092350) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -221,6 +221,7 @@ ActiveRecord::Schema[7.0].define(version: 2022_04_27_160536) do t.string "old_id" t.integer "joint" t.bigint "created_by_id" + t.integer "illness_type_0" t.index ["created_by_id"], name: "index_case_logs_on_created_by_id" t.index ["managing_organisation_id"], name: "index_case_logs_on_managing_organisation_id" t.index ["old_id"], name: "index_case_logs_on_old_id", unique: true diff --git a/spec/fixtures/exports/case_logs.xml b/spec/fixtures/exports/case_logs.xml index d1afb70d5..00dfd5243 100644 --- a/spec/fixtures/exports/case_logs.xml +++ b/spec/fixtures/exports/case_logs.xml @@ -163,6 +163,7 @@ {created_by_id} + 1