Skip to content

Commit 3e1bceb

Browse files
authored
Merge pull request #6339 from NHSDigital/follow-up-nurse-facing
Handle `follow_up_requested` as a distinct consent status
2 parents 035f4be + 1c208eb commit 3e1bceb

14 files changed

Lines changed: 186 additions & 12 deletions

File tree

app/components/app_activity_log_component.rb

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,19 +216,34 @@ def consent_events
216216
consents.flat_map do |consent|
217217
events = []
218218

219-
original_response = consent.withdrawn? ? "given" : consent.response
219+
original_response =
220+
if consent.withdrawn?
221+
"given"
222+
elsif consent.follow_up_requested?
223+
"follow_up_requested"
224+
else
225+
consent.response
226+
end
227+
human_response = Consent.human_enum_name(:response, original_response)
228+
229+
title =
230+
if original_response == "not_provided"
231+
"Consent not provided"
232+
else
233+
human_response
234+
end
220235

221236
events << if (consent_form = consent.consent_form)
222237
{
223-
title: "Consent #{original_response}",
238+
title:,
224239
at: consent_form.recorded_at,
225240
by: consent_form.parent_relationship.label_with_parent,
226241
programmes: [consent.programme]
227242
}
228243
else
229244
{
230245
title:
231-
"Consent #{original_response} by #{consent.name} (#{consent.who_responded.downcase_first})",
246+
"#{title} by #{consent.name} (#{consent.who_responded.downcase_first})",
232247
at: consent.submitted_at,
233248
by: consent.recorded_by,
234249
programmes: [consent.programme]

app/components/app_patient_session_consent_component.html.erb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
<% end %>
1414
<% elsif consent_status_value == :conflicts %>
1515
<p>You can only vaccinate if all respondents give consent.</p>
16+
<% elsif consent_status_value == :follow_up_requested %>
17+
<p><%= who_refused %> would like to speak to a member of the team about other options for their child's vaccination.</p>
1618
<% elsif consent_status_value == :refused %>
1719
<p><%= who_refused %> refused to give consent.</p>
1820
<% elsif consent_status_generator.status == :given %>

app/helpers/consents_helper.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ def consent_response_tag(consent)
5454
text =
5555
if consent.withdrawn?
5656
Consent.human_enum_name(:response, :given)
57+
elsif consent.try(:refusal_with_follow_up?)
58+
Consent.human_enum_name(:response, :follow_up_requested)
5759
else
5860
consent.human_enum_name(:response)
5961
end
@@ -63,6 +65,8 @@ def consent_response_tag(consent)
6365
"grey"
6466
elsif consent.response_given?
6567
"green"
68+
elsif consent.try(:refusal_with_follow_up?)
69+
"orange"
6670
elsif consent.response_refused?
6771
"red"
6872
else

app/lib/status_generator/consent.rb

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ def status
2424
:given
2525
elsif status_should_be_refused?
2626
:refused
27+
elsif status_should_be_follow_up_requested?
28+
:follow_up_requested
2729
elsif status_should_be_conflicts?
2830
:conflicts
2931
elsif status_should_be_no_response?
@@ -84,7 +86,18 @@ def conflicting_disease_types?
8486
def status_should_be_refused?
8587
return false if vaccinated?
8688

87-
latest_consents.any? && latest_consents.all?(&:response_refused?)
89+
latest_consents.any? && latest_consents.all?(&:hard_refusal?)
90+
end
91+
92+
def status_should_be_follow_up_requested?
93+
return false if vaccinated?
94+
95+
# Follow-up is the outcome when there are no outright refusals and at least
96+
# one consent has follow_up_requested — including the case where one parent
97+
# has given consent and another has asked for a follow-up discussion,
98+
# because that discussion could change the outcome to :given.
99+
consents_for_status.any? && consents_for_status.none?(&:hard_refusal?) &&
100+
consents_for_status.any?(&:refusal_with_follow_up?)
88101
end
89102

90103
def status_should_be_conflicts?
@@ -93,10 +106,15 @@ def status_should_be_conflicts?
93106
consents_for_status =
94107
(self_consents.any? ? self_consents : parental_consents)
95108

96-
if consents_for_status.any?(&:response_refused?) &&
97-
consents_for_status.any?(&:response_given?)
98-
return true
99-
end
109+
has_given = consents_for_status.any?(&:response_given?)
110+
has_hard_refusal = consents_for_status.any?(&:hard_refusal?)
111+
has_follow_up = consents_for_status.any?(&:refusal_with_follow_up?)
112+
113+
return true if has_given && has_hard_refusal
114+
115+
# hard refusal + follow_up is a conflict: even if the follow-up
116+
# resolves to given, the outstanding refusal remains unresolved
117+
return true if has_hard_refusal && has_follow_up
100118

101119
consents_for_status.any? && consents_for_status.all?(&:response_given?) &&
102120
(agreed_vaccine_methods.blank? || conflicting_disease_types?)

app/lib/status_generator/programme.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,10 @@ def without_gelatine
102102
if not_eligible? ||
103103
triage_generator.status.in?(
104104
%i[required invite_to_clinic do_not_vaccinate]
105-
) || consent_status.in?(%i[no_response conflicts refused])
105+
) ||
106+
consent_status.in?(
107+
%i[no_response conflicts refused follow_up_requested]
108+
)
106109
return nil
107110
end
108111

@@ -113,7 +116,10 @@ def vaccine_methods
113116
if not_eligible? ||
114117
triage_generator.status.in?(
115118
%i[required invite_to_clinic do_not_vaccinate]
116-
) || consent_status.in?(%i[no_response conflicts refused])
119+
) ||
120+
consent_status.in?(
121+
%i[no_response conflicts refused follow_up_requested]
122+
)
117123
return nil
118124
end
119125

@@ -217,7 +223,7 @@ def should_be_has_refusal_consent_refused?
217223
end
218224

219225
def should_be_needs_consent_follow_up_requested?
220-
false # TODO: Implement this status.
226+
consent_status == :follow_up_requested
221227
end
222228

223229
def should_be_needs_consent_request_failed?

app/models/concerns/refusable.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ module Refusable
3232
unless: :can_have_reason_for_refusal?
3333
end
3434

35+
def hard_refusal? = response_refused? && !follow_up_requested?
36+
37+
def refusal_with_follow_up? = response_refused? && follow_up_requested?
38+
3539
def requires_reason_for_refusal?
3640
response_refused?
3741
end

app/models/patient/programme_status.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,14 @@ class Patient::ProgrammeStatus < ApplicationRecord
120120
validate: true
121121

122122
enum :consent_status,
123-
{ no_response: 0, given: 1, refused: 2, conflicts: 3, not_required: 4 },
123+
{
124+
no_response: 0,
125+
given: 1,
126+
refused: 2,
127+
conflicts: 3,
128+
not_required: 4,
129+
follow_up_requested: 5
130+
},
124131
default: :no_response,
125132
prefix: :consent,
126133
validate: true

config/locales/en.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ en:
292292
personal_choice: Personal choice
293293
will_be_vaccinated_elsewhere: Vaccine will be given elsewhere
294294
responses:
295+
follow_up_requested: Follow-up requested
295296
given: Consent given
296297
given_injection: Consent given
297298
given_nasal: Consent given

config/locales/status.en.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ en:
1414
given_injection_without_gelatine: Consent given for gelatine-free injection
1515
given_injection_without_gelatine_flu: Consent given for injection
1616
given_nasal: Consent given for nasal spray
17+
follow_up_requested: Follow-up requested
1718
no_response: No response
1819
not_required: No consent needed
1920
refused: Consent refused
2021
colour:
2122
conflicts: orange
23+
follow_up_requested: orange
2224
given: green
2325
given_injection: green
2426
given_injection_without_gelatine: green

spec/components/app_activity_log_component_spec.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,24 @@
526526
programme: "HPV"
527527
end
528528

529+
describe "follow-up requested consent" do
530+
before do
531+
create(
532+
:consent,
533+
:follow_up_requested,
534+
programme: programmes.first,
535+
patient:,
536+
parent: mum,
537+
submitted_at: Time.zone.local(2025, 5, 30, 12)
538+
)
539+
end
540+
541+
include_examples "card",
542+
title: "Follow-up requested by Jane Doe (mum)",
543+
date: "30 May 2025 at 12:00pm",
544+
programme: "HPV"
545+
end
546+
529547
describe "gillick assessments" do
530548
let(:programmes) { [Programme.td_ipv] }
531549

0 commit comments

Comments
 (0)