diff --git a/app/controllers/parent_interface/consent_forms/edit_controller.rb b/app/controllers/parent_interface/consent_forms/edit_controller.rb index 00b7df9be..c68f412e2 100644 --- a/app/controllers/parent_interface/consent_forms/edit_controller.rb +++ b/app/controllers/parent_interface/consent_forms/edit_controller.rb @@ -28,8 +28,7 @@ def update model.assign_attributes(update_params) end - if current_step == :confirm_school && - @consent_form.is_this_their_school == "no" + if current_step == :confirm_school && !@consent_form.location_confirmed redirect_to session_parent_interface_consent_form_cannot_consent_school_path( @session, @consent_form @@ -73,7 +72,7 @@ def update_params date_of_birth(2i) date_of_birth(1i) ], - confirm_school: %i[is_this_their_school], + confirm_school: %i[location_confirmed], parent: %i[ parent_email parent_name diff --git a/app/models/consent_form.rb b/app/models/consent_form.rb index 8228a2f57..d2a37fc7a 100644 --- a/app/models/consent_form.rb +++ b/app/models/consent_form.rb @@ -17,6 +17,7 @@ # gp_response :integer # health_answers :jsonb not null # last_name :text +# location_confirmed :boolean # parent_contact_method_other_details :string # parent_contact_method_type :string # parent_email :string @@ -33,18 +34,21 @@ # created_at :datetime not null # updated_at :datetime not null # consent_id :bigint +# location_id :bigint # programme_id :bigint not null # session_id :bigint not null # # Indexes # # index_consent_forms_on_consent_id (consent_id) +# index_consent_forms_on_location_id (location_id) # index_consent_forms_on_programme_id (programme_id) # index_consent_forms_on_session_id (session_id) # # Foreign Keys # # fk_rails_... (consent_id => consents.id) +# fk_rails_... (location_id => locations.id) # fk_rails_... (programme_id => programmes.id) # fk_rails_... (session_id => sessions.id) # @@ -59,9 +63,7 @@ class ConsentForm < ApplicationRecord scope :unmatched, -> { where(consent_id: nil) } scope :recorded, -> { where.not(recorded_at: nil) } - attr_accessor :health_question_number, - :is_this_their_school, - :parental_responsibility + attr_accessor :health_question_number, :parental_responsibility audited @@ -172,7 +174,7 @@ class ConsentForm < ApplicationRecord end on_wizard_step :confirm_school, exact: true do - validates :is_this_their_school, inclusion: { in: %w[yes no] } + validates :location_confirmed, inclusion: { in: [true, false] } end on_wizard_step :parent do diff --git a/app/views/parent_interface/consent_forms/edit/confirm_school.html.erb b/app/views/parent_interface/consent_forms/edit/confirm_school.html.erb index f428bb77b..b3db57027 100644 --- a/app/views/parent_interface/consent_forms/edit/confirm_school.html.erb +++ b/app/views/parent_interface/consent_forms/edit/confirm_school.html.erb @@ -19,12 +19,12 @@ <%= form_with model: @consent_form, url: wizard_path, method: :put do |f| %> <% content_for(:before_content) { f.govuk_error_summary } %> - <%= f.govuk_radio_buttons_fieldset(:is_this_their_school, + <%= f.govuk_radio_buttons_fieldset(:location_confirmed, legend: { size: "s", text: "Is this their school?" }) do %> - <%= f.govuk_radio_button :is_this_their_school, "yes", + <%= f.govuk_radio_button :location_confirmed, true, link_errors: true, label: { text: "Yes, they go to this school" } %> - <%= f.govuk_radio_button :is_this_their_school, "no", + <%= f.govuk_radio_button :location_confirmed, false, label: { text: "No, they go to a different school" } %> <% end %> diff --git a/db/migrate/20240926110216_add_location_fields_to_consent_form.rb b/db/migrate/20240926110216_add_location_fields_to_consent_form.rb new file mode 100644 index 000000000..d521168f7 --- /dev/null +++ b/db/migrate/20240926110216_add_location_fields_to_consent_form.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +class AddLocationFieldsToConsentForm < ActiveRecord::Migration[7.2] + def change + add_column :consent_forms, :location_confirmed, :boolean + add_reference :consent_forms, :location, foreign_key: true + end +end diff --git a/db/schema.rb b/db/schema.rb index f2ad90482..adf53e457 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.2].define(version: 2024_09_26_104802) do +ActiveRecord::Schema[7.2].define(version: 2024_09_26_110216) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -126,7 +126,10 @@ t.string "parent_relationship_type" t.boolean "parent_phone_receive_updates", default: false, null: false t.bigint "programme_id", null: false + t.boolean "location_confirmed" + t.bigint "location_id" t.index ["consent_id"], name: "index_consent_forms_on_consent_id" + t.index ["location_id"], name: "index_consent_forms_on_location_id" t.index ["programme_id"], name: "index_consent_forms_on_programme_id" t.index ["session_id"], name: "index_consent_forms_on_session_id" end @@ -600,6 +603,7 @@ add_foreign_key "cohort_imports_patients", "patients" add_foreign_key "cohorts", "teams" add_foreign_key "consent_forms", "consents" + add_foreign_key "consent_forms", "locations" add_foreign_key "consent_forms", "programmes" add_foreign_key "consent_forms", "sessions" add_foreign_key "consents", "parents" diff --git a/erd.pdf b/erd.pdf index a36497adc..9ca3c30f2 100644 Binary files a/erd.pdf and b/erd.pdf differ diff --git a/spec/factories/consent_forms.rb b/spec/factories/consent_forms.rb index 87f4aadf5..2f9585e87 100644 --- a/spec/factories/consent_forms.rb +++ b/spec/factories/consent_forms.rb @@ -17,6 +17,7 @@ # gp_response :integer # health_answers :jsonb not null # last_name :text +# location_confirmed :boolean # parent_contact_method_other_details :string # parent_contact_method_type :string # parent_email :string @@ -33,18 +34,21 @@ # created_at :datetime not null # updated_at :datetime not null # consent_id :bigint +# location_id :bigint # programme_id :bigint not null # session_id :bigint not null # # Indexes # # index_consent_forms_on_consent_id (consent_id) +# index_consent_forms_on_location_id (location_id) # index_consent_forms_on_programme_id (programme_id) # index_consent_forms_on_session_id (session_id) # # Foreign Keys # # fk_rails_... (consent_id => consents.id) +# fk_rails_... (location_id => locations.id) # fk_rails_... (programme_id => programmes.id) # fk_rails_... (session_id => sessions.id) # diff --git a/spec/models/consent_form_spec.rb b/spec/models/consent_form_spec.rb index 68affaf65..3ae8bb94f 100644 --- a/spec/models/consent_form_spec.rb +++ b/spec/models/consent_form_spec.rb @@ -17,6 +17,7 @@ # gp_response :integer # health_answers :jsonb not null # last_name :text +# location_confirmed :boolean # parent_contact_method_other_details :string # parent_contact_method_type :string # parent_email :string @@ -33,18 +34,21 @@ # created_at :datetime not null # updated_at :datetime not null # consent_id :bigint +# location_id :bigint # programme_id :bigint not null # session_id :bigint not null # # Indexes # # index_consent_forms_on_consent_id (consent_id) +# index_consent_forms_on_location_id (location_id) # index_consent_forms_on_programme_id (programme_id) # index_consent_forms_on_session_id (session_id) # # Foreign Keys # # fk_rails_... (consent_id => consents.id) +# fk_rails_... (location_id => locations.id) # fk_rails_... (programme_id => programmes.id) # fk_rails_... (session_id => sessions.id) #