Browse Source

Allow illness type to be refused (#553)

pull/554/head
baarkerlounger 3 years ago committed by GitHub
parent
commit
9cbbd127c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      app/services/imports/case_logs_import_service.rb
  2. 3
      config/forms/2021_2022.json
  3. 3
      config/forms/2022_2023.json
  4. 5
      db/migrate/20220506092350_add_prefers_not_to_say_illness_type_to_case_logs.rb
  5. 3
      db/schema.rb
  6. 1
      spec/fixtures/exports/case_logs.xml

7
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"

3
config/forms/2021_2022.json

@ -3286,6 +3286,9 @@
},
"illness_type_10": {
"value": "Other"
},
"illness_type_0": {
"value": "Tenant prefers not to say"
}
}
}

3
config/forms/2022_2023.json

@ -3329,6 +3329,9 @@
},
"illness_type_10": {
"value": "Other"
},
"illness_type_0": {
"value": "Tenant prefers not to say"
}
}
}

5
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

3
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

1
spec/fixtures/exports/case_logs.xml vendored

@ -163,6 +163,7 @@
<old_id/>
<joint/>
<created_by_id>{created_by_id}</created_by_id>
<illness_type_0/>
<providertype>1</providertype>
</form>
</forms>

Loading…
Cancel
Save