Skip to content

Commit ce7a00d

Browse files
authored
Merge pull request #6431 from NHSDigital/add-dont-want-vaccination-at-school-refusal-reason
Add "do not want vaccination at school" as a consent refusal reason
2 parents ef373fb + d23ad7f commit ce7a00d

9 files changed

Lines changed: 82 additions & 3 deletions

File tree

app/helpers/consents_helper.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
module ConsentsHelper
4-
ConsentRefusalOption = Struct.new(:value, :label, :divider)
4+
ConsentRefusalOption = Struct.new(:value, :label, :hint, :divider)
55

66
def consent_refusal_reasons(consent)
77
reasons = %w[
@@ -16,10 +16,19 @@ def consent_refusal_reasons(consent)
1616
reasons.insert(0, "contains_gelatine")
1717
end
1818

19+
if consent.respond_to?(:location) && consent.location&.school?
20+
reasons.insert(-2, "do_not_want_vaccination_at_school")
21+
end
22+
1923
reasons.map do |value|
2024
label = refusal_reason_label(consent, value)
25+
hint =
26+
I18n.t(
27+
"activerecord.attributes.consent.reason_for_refusal_hints.#{value}",
28+
default: nil
29+
)
2130

22-
ConsentRefusalOption.new(value:, label:, divider: value == "other")
31+
ConsentRefusalOption.new(value:, label:, hint:, divider: value == "other")
2332
end
2433
end
2534

app/models/concerns/refusable.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ module Refusable
2020
will_be_vaccinated_elsewhere: 2,
2121
medical_reasons: 3,
2222
personal_choice: 4,
23-
other: 5
23+
other: 5,
24+
do_not_want_vaccination_at_school: 6
2425
},
2526
prefix: true,
2627
validate: {

app/models/consent_form.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ class ConsentForm < ApplicationRecord
329329
ETHNICITY_STEPS = %i[ethnicity ethnic_group ethnic_background].freeze
330330
FOLLOW_UP_REQUIRED_REASONS = %w[
331331
contains_gelatine
332+
do_not_want_vaccination_at_school
332333
medical_reasons
333334
personal_choice
334335
other

app/views/draft_consents/reason_for_refusal.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
<%= f.govuk_radio_button :reason_for_refusal, refusal_reason.value,
1919
label: { text: refusal_reason.label },
20+
hint: { text: refusal_reason.hint },
2021
link_errors: index.zero? %>
2122
<% end %>
2223
<% end %>

app/views/parent_interface/consent_forms/edit/follow_up_discussion.html.erb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
<% hint = case @consent_form.reason_for_refusal
99
when "contains_gelatine"
1010
"For example, it may be possible to use a vaccine that does not contain gelatine."
11+
when "do_not_want_vaccination_at_school"
12+
"For example, it may be possible to vaccinate your child in a community clinic."
1113
when "medical_reasons"
1214
"We understand alternatives might not be suitable in some cases."
1315
end %>

app/views/parent_interface/consent_forms/edit/reason_for_refusal.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<%= f.govuk_radio_button :reason_for_refusal,
1919
refusal_reason.value,
2020
label: { text: refusal_reason.label },
21+
hint: { text: refusal_reason.hint },
2122
link_errors: index.zero? %>
2223
<% end %>
2324
<% end %>

app/views/patient_sessions/consents/withdraw.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
<%= f.govuk_radio_button :reason_for_refusal, refusal_reason.value,
2121
label: { text: refusal_reason.label },
22+
hint: { text: refusal_reason.hint },
2223
link_errors: index.zero? %>
2324
<% end %>
2425
<% end %>

config/locales/en.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,13 @@ en:
353353
contains_gelatine_mmrv: I’m concerned the vaccine contains gelatine
354354
medical: Medical reasons
355355
other: Other
356+
do_not_want_vaccination_at_school: Do not want vaccination at school
356357
personal_choice: Personal choice
357358
will_be_vaccinated_elsewhere: Vaccine will be given elsewhere
359+
reason_for_refusal_hints:
360+
do_not_want_vaccination_at_school: >-
361+
For example, you do not want your child to be vaccinated in a busy environment
362+
will_be_vaccinated_elsewhere: "For example, you've booked your child into a clinic"
358363
responses:
359364
follow_up_requested: Follow-up requested
360365
given: Consent given
@@ -1158,6 +1163,7 @@ en:
11581163
contains_gelatine: of the gelatine in the nasal spray
11591164
medical_reasons: of medical reasons
11601165
other: of other reasons
1166+
does_not_want_vaccination_at_school: they do not want vaccination at school
11611167
personal_choice: of personal choice
11621168
will_be_vaccinated_elsewhere: they will be given the vaccine elsewhere
11631169
vaccination_mailer:

spec/helpers/consents_helper_spec.rb

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,63 @@
33
describe ConsentsHelper do
44
subject(:reasons) { helper.consent_refusal_reasons(consent) }
55

6+
describe "#consent_refusal_reasons" do
7+
subject(:reasons) { helper.consent_refusal_reasons(consent) }
8+
9+
context "with a ConsentForm for a school session" do
10+
let(:session) { create(:session, location: create(:gias_school)) }
11+
let(:consent) { build(:consent_form, session:) }
12+
13+
it "includes do_not_want_vaccination_at_school" do
14+
expect(reasons.map(&:value)).to include(
15+
"do_not_want_vaccination_at_school"
16+
)
17+
end
18+
19+
it "includes the hint for do_not_want_vaccination_at_school" do
20+
reason =
21+
reasons.find { |r| r.value == "do_not_want_vaccination_at_school" }
22+
expect(reason.hint).to eq(
23+
"For example, you do not want your child to be vaccinated in a busy environment"
24+
)
25+
end
26+
end
27+
28+
context "with a ConsentForm for a clinic session" do
29+
let(:session) { create(:session, location: create(:generic_clinic)) }
30+
let(:consent) { build(:consent_form, session:) }
31+
32+
it "does not include do_not_want_vaccination_at_school" do
33+
expect(reasons.map(&:value)).not_to include(
34+
"do_not_want_vaccination_at_school"
35+
)
36+
end
37+
end
38+
39+
context "with any consent form" do
40+
let(:session) { create(:session) }
41+
let(:consent) { build(:consent_form, session:) }
42+
43+
it "includes the hint for will_be_vaccinated_elsewhere" do
44+
reason = reasons.find { |r| r.value == "will_be_vaccinated_elsewhere" }
45+
expect(reason.hint).to eq(
46+
"For example, you've booked your child into a clinic"
47+
)
48+
end
49+
50+
it "does not include hints for other reasons" do
51+
reasons_without_hints =
52+
reasons.reject do |r|
53+
%w[
54+
will_be_vaccinated_elsewhere
55+
do_not_want_vaccination_at_school
56+
].include?(r.value)
57+
end
58+
expect(reasons_without_hints.map(&:hint)).to all(be_nil)
59+
end
60+
end
61+
end
62+
663
shared_examples "refusal reason label" do |expected_label|
764
it "uses the programme-specific refusal reason label" do
865
reason = reasons.find { |reason| reason.value == "contains_gelatine" }

0 commit comments

Comments
 (0)