From 2aac45f2914faf8db9aa3de47c4bf1cbaf66c7ba Mon Sep 17 00:00:00 2001 From: Lakshmi Murugappan Date: Tue, 21 Apr 2026 15:29:15 +0100 Subject: [PATCH 1/4] Migrate needs_consent_follow_up_requested to has_a_refusal_follow_up_requested A parent can only request a follow-up discussion through a consent refusal. Hence, it makes sense for "follow-up requested" to be a substatus of "has a refusal" rather than "needs consent". This commit modifies the code to use has_a_refusal as the parent status. We retain needs_consent_follow_up_requested for now, and can remove it in a future commit when all patients have had their status updated appropriately. --- app/components/app_session_actions_component.rb | 6 +++--- app/lib/status_generator/programme.rb | 6 +++--- app/models/patient/programme_status.rb | 3 ++- config/locales/status.en.yml | 3 +++ spec/factories/patient_programme_statuses.rb | 4 ++-- spec/factories/patients.rb | 2 +- spec/lib/status_generator/programme_spec.rb | 2 +- 7 files changed, 15 insertions(+), 11 deletions(-) diff --git a/app/components/app_session_actions_component.rb b/app/components/app_session_actions_component.rb index 56a72c8f70..8333c75977 100644 --- a/app/components/app_session_actions_component.rb +++ b/app/components/app_session_actions_component.rb @@ -81,7 +81,7 @@ def no_consent_response_row def follow_up_requested_row count = patients.has_programme_status( - "needs_consent_follow_up_requested", + "has_refusal_follow_up_requested", programme: programmes, academic_year: ).count @@ -89,8 +89,8 @@ def follow_up_requested_row href = session_patients_path( session, - programme_status_group: "needs_consent", - programme_statuses: %w[needs_consent_follow_up_requested] + programme_status_group: "has_refusal", + programme_statuses: %w[has_refusal_follow_up_requested] ) generate_row(:children_with_follow_up_requested, count:, href:) diff --git a/app/lib/status_generator/programme.rb b/app/lib/status_generator/programme.rb index 6aa1fffb1c..4e3e5ce919 100644 --- a/app/lib/status_generator/programme.rb +++ b/app/lib/status_generator/programme.rb @@ -74,8 +74,8 @@ def status :has_refusal_consent_conflicts elsif should_be_has_refusal_consent_refused? :has_refusal_consent_refused - elsif should_be_needs_consent_follow_up_requested? - :needs_consent_follow_up_requested + elsif should_be_has_refusal_follow_up_requested? + :has_refusal_follow_up_requested elsif should_be_needs_consent_request_failed? :needs_consent_request_failed elsif should_be_needs_consent_request_scheduled? @@ -232,7 +232,7 @@ def should_be_has_refusal_consent_refused? consent_status == :refused end - def should_be_needs_consent_follow_up_requested? + def should_be_has_refusal_follow_up_requested? consent_status == :follow_up_requested end diff --git a/app/models/patient/programme_status.rb b/app/models/patient/programme_status.rb index c3ea99ac3e..08d9c04587 100644 --- a/app/models/patient/programme_status.rb +++ b/app/models/patient/programme_status.rb @@ -103,7 +103,8 @@ class Patient::ProgrammeStatus < ApplicationRecord HAS_REFUSAL_STATUSES = { "has_refusal_consent_conflicts" => 20, - "has_refusal_consent_refused" => 21 + "has_refusal_consent_refused" => 21, + "has_refusal_follow_up_requested" => 22 }.freeze NEEDS_TRIAGE_STATUSES = { "needs_triage" => 30 }.freeze diff --git a/config/locales/status.en.yml b/config/locales/status.en.yml index bee1d1d732..44dc08581c 100644 --- a/config/locales/status.en.yml +++ b/config/locales/status.en.yml @@ -60,6 +60,7 @@ en: has_refusal_consent_conflicts: Has a refusal has_refusal_consent_refused: Has a refusal needs_consent: Needs consent + has_refusal_follow_up_requested: Has a refusal needs_consent_follow_up_requested: Needs consent needs_consent_no_response: Needs consent needs_consent_request_failed: Needs consent @@ -88,6 +89,7 @@ en: has_refusal_consent_conflicts: orange has_refusal_consent_refused: orange needs_consent: blue + has_refusal_follow_up_requested: orange needs_consent_follow_up_requested: blue needs_consent_no_response: blue needs_consent_request_failed: blue @@ -108,6 +110,7 @@ en: cannot_vaccinate_unwell: Child unwell has_refusal_consent_conflicts: Conflicting consent has_refusal_consent_refused: Consent refused + has_refusal_follow_up_requested: Follow-up requested needs_consent_follow_up_requested: Follow-up requested needs_consent_no_response: No response needs_consent_request_failed: Request failed diff --git a/spec/factories/patient_programme_statuses.rb b/spec/factories/patient_programme_statuses.rb index 9be52c7a9b..bb41075acc 100644 --- a/spec/factories/patient_programme_statuses.rb +++ b/spec/factories/patient_programme_statuses.rb @@ -53,9 +53,9 @@ status { "has_refusal_consent_conflicts" } end - trait :needs_consent_follow_up_requested do + trait :has_refusal_follow_up_requested do consent_status { "follow_up_requested" } - status { "needs_consent_follow_up_requested" } + status { "has_refusal_follow_up_requested" } end trait :needs_triage do diff --git a/spec/factories/patients.rb b/spec/factories/patients.rb index e4afa3cc49..2fec6a2f95 100644 --- a/spec/factories/patients.rb +++ b/spec/factories/patients.rb @@ -239,7 +239,7 @@ programmes.map do |programme| association( :patient_programme_status, - :needs_consent_follow_up_requested, + :has_refusal_follow_up_requested, patient: instance, programme: ) diff --git a/spec/lib/status_generator/programme_spec.rb b/spec/lib/status_generator/programme_spec.rb index 3154b4e983..af00420061 100644 --- a/spec/lib/status_generator/programme_spec.rb +++ b/spec/lib/status_generator/programme_spec.rb @@ -368,7 +368,7 @@ its(:disease_types) { should be_nil } its(:dose_sequence) { should eq(1) } its(:location_id) { should be_nil } - its(:status) { should be(:needs_consent_follow_up_requested) } + its(:status) { should be(:has_refusal_follow_up_requested) } its(:vaccine_methods) { should be_nil } its(:without_gelatine) { should be_nil } end From e1a3a923d4ea315192242f6b943e9794bba4d9a2 Mon Sep 17 00:00:00 2001 From: Lakshmi Murugappan Date: Tue, 21 Apr 2026 15:31:52 +0100 Subject: [PATCH 2/4] Hide follow-up requested from session children filter With the post-deploy task all patients with needs_consent_follow_up_requested should be updated to has_a_refusal_follow_up_requested. This means we can hide the checkbox under needs consent till we remove the status altogether in a follow-up PR. --- app/components/app_patient_search_form_component.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/components/app_patient_search_form_component.rb b/app/components/app_patient_search_form_component.rb index 033f00bced..c5dd772bdf 100644 --- a/app/components/app_patient_search_form_component.rb +++ b/app/components/app_patient_search_form_component.rb @@ -1,8 +1,11 @@ # frozen_string_literal: true class AppPatientSearchFormComponent < ViewComponent::Base - # Remove these statuses once implemented. - HIDDEN_PROGRAMME_STATUSES = %w[needs_consent_request_failed].freeze + # Remove these statuses once implemented or fully migrated. + HIDDEN_PROGRAMME_STATUSES = %w[ + needs_consent_follow_up_requested + needs_consent_request_failed + ].freeze def initialize( form, From 3c37a448b44076d944bdbaaf7246eb476a7cccc0 Mon Sep 17 00:00:00 2001 From: Lakshmi Murugappan Date: Tue, 21 Apr 2026 15:34:16 +0100 Subject: [PATCH 3/4] Post-deploy task to update status of patients with follow-up The parent status should now be "Has a refusal" not "Needs consent" --- ...ate_follow_up_requested_programme_status.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 db/data/20260421100000_update_follow_up_requested_programme_status.rb diff --git a/db/data/20260421100000_update_follow_up_requested_programme_status.rb b/db/data/20260421100000_update_follow_up_requested_programme_status.rb new file mode 100644 index 0000000000..dc09c95d00 --- /dev/null +++ b/db/data/20260421100000_update_follow_up_requested_programme_status.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class UpdateFollowUpRequestedProgrammeStatus < ActiveRecord::Migration[8.1] + def up + PatientStatusUpdater.call( + patient_scope: + Patient.has_programme_status( + "needs_consent_follow_up_requested", + programme: Programme.all, + academic_year: AcademicYear.current + ) + ) + end + + def down + raise ActiveRecord::IrreversibleMigration + end +end From 97178bc34c97ab95f070130be6f2a6c73122b5c4 Mon Sep 17 00:00:00 2001 From: Lakshmi Murugappan Date: Tue, 21 Apr 2026 15:55:05 +0100 Subject: [PATCH 4/4] Remove needs_consent_follow_up_requested In 2aac45f2914faf8db9aa3de47c4bf1cbaf66c7ba, we removed any use of the needs_consent_follow_up_requested sattus, and instead migrated to has_refusal_follow_up_requested. This status can now be completely removed from the code base as all patients should have the new status now. --- app/components/app_patient_search_form_component.rb | 7 ++----- app/models/patient/programme_status.rb | 1 - config/locales/status.en.yml | 3 --- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/app/components/app_patient_search_form_component.rb b/app/components/app_patient_search_form_component.rb index c5dd772bdf..033f00bced 100644 --- a/app/components/app_patient_search_form_component.rb +++ b/app/components/app_patient_search_form_component.rb @@ -1,11 +1,8 @@ # frozen_string_literal: true class AppPatientSearchFormComponent < ViewComponent::Base - # Remove these statuses once implemented or fully migrated. - HIDDEN_PROGRAMME_STATUSES = %w[ - needs_consent_follow_up_requested - needs_consent_request_failed - ].freeze + # Remove these statuses once implemented. + HIDDEN_PROGRAMME_STATUSES = %w[needs_consent_request_failed].freeze def initialize( form, diff --git a/app/models/patient/programme_status.rb b/app/models/patient/programme_status.rb index 08d9c04587..75828a15d3 100644 --- a/app/models/patient/programme_status.rb +++ b/app/models/patient/programme_status.rb @@ -97,7 +97,6 @@ class Patient::ProgrammeStatus < ApplicationRecord "needs_consent_request_scheduled" => 11, "needs_consent_request_failed" => 12, "needs_consent_no_response" => 13, - "needs_consent_follow_up_requested" => 14, "needs_consent_no_contact_details" => 15 }.freeze diff --git a/config/locales/status.en.yml b/config/locales/status.en.yml index 44dc08581c..9c44994837 100644 --- a/config/locales/status.en.yml +++ b/config/locales/status.en.yml @@ -61,7 +61,6 @@ en: has_refusal_consent_refused: Has a refusal needs_consent: Needs consent has_refusal_follow_up_requested: Has a refusal - needs_consent_follow_up_requested: Needs consent needs_consent_no_response: Needs consent needs_consent_request_failed: Needs consent needs_consent_request_not_scheduled: Needs consent @@ -90,7 +89,6 @@ en: has_refusal_consent_refused: orange needs_consent: blue has_refusal_follow_up_requested: orange - needs_consent_follow_up_requested: blue needs_consent_no_response: blue needs_consent_request_failed: blue needs_consent_request_not_scheduled: blue @@ -111,7 +109,6 @@ en: has_refusal_consent_conflicts: Conflicting consent has_refusal_consent_refused: Consent refused has_refusal_follow_up_requested: Follow-up requested - needs_consent_follow_up_requested: Follow-up requested needs_consent_no_response: No response needs_consent_request_failed: Request failed needs_consent_request_not_scheduled: Request not scheduled