Skip to content

Commit e64b31f

Browse files
committed
Show secondary consent vaccine methods
When displaying a consent either on the patient session page or when viewing a consent directly, we should show if the parent also consented to any alternative vaccine methods. This is only relevant for the flu programme where you can consent to both the nasal spray and the injection. To support this I've also updated the summary list showing the consent response to match the latest designs in the prototype. Jira-Issue: MAV-1473
1 parent b963d9e commit e64b31f

11 files changed

Lines changed: 102 additions & 47 deletions

app/components/app_consent_card_component.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,20 @@ def rows
5959
text: helpers.consent_status_tag(consent)
6060
}
6161
}
62-
].compact
62+
].compact +
63+
consent
64+
.vaccine_methods
65+
.drop(1)
66+
.map do |vaccine_method|
67+
method_name = Vaccine.human_enum_name(:method_prefix, vaccine_method)
68+
{
69+
key: {
70+
text: "Consent also given for #{method_name} vaccine?"
71+
},
72+
value: {
73+
text: "Yes"
74+
}
75+
}
76+
end
6377
end
6478
end

app/components/app_consent_summary_component.rb

Lines changed: 43 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,57 +10,74 @@ def initialize(consent, change_links: {})
1010

1111
def call
1212
govuk_summary_list(actions: @change_links.present?) do |summary_list|
13-
if @consent.responded_at.present?
13+
summary_list.with_row do |row|
14+
row.with_key { "Programme" }
15+
row.with_value do
16+
tag.strong(
17+
programme.name,
18+
class: "nhsuk-tag app-tag--attached nhsuk-tag--white"
19+
)
20+
end
21+
end
22+
23+
if consent.responded_at.present?
1424
summary_list.with_row do |row|
15-
row.with_key { "Response date" }
16-
row.with_value { @consent.responded_at.to_fs(:long) }
25+
row.with_key { "Date" }
26+
row.with_value { consent.responded_at.to_fs(:long) }
1727
end
1828
end
1929

2030
summary_list.with_row do |row|
21-
row.with_key { "Decision" }
22-
row.with_value { helpers.consent_status_tag(@consent) }
23-
if (href = @change_links[:response])
24-
row.with_action(
25-
text: "Change",
26-
visually_hidden_text: "decision",
27-
href:
28-
)
31+
row.with_key { "Method" }
32+
row.with_value { consent.human_enum_name(:route).humanize }
33+
if (href = change_links[:route])
34+
row.with_action(text: "Change", visually_hidden_text: "method", href:)
2935
end
3036
end
3137

3238
summary_list.with_row do |row|
33-
row.with_key { "Response method" }
34-
row.with_value do
35-
Consent.human_enum_name(:route, @consent.route).humanize
36-
end
37-
if (href = @change_links[:route])
39+
row.with_key { "Decision" }
40+
row.with_value { helpers.consent_status_tag(consent) }
41+
if (href = change_links[:response])
3842
row.with_action(
3943
text: "Change",
40-
visually_hidden_text: "response method",
44+
visually_hidden_text: "decision",
4145
href:
4246
)
4347
end
4448
end
4549

46-
if @consent.reason_for_refusal.present?
50+
consent
51+
.vaccine_methods
52+
.drop(1)
53+
.each do |vaccine_method|
54+
method_name = Vaccine.human_enum_name(:method_prefix, vaccine_method)
55+
56+
summary_list.with_row do |row|
57+
row.with_key { "Consent also given for #{method_name} vaccine?" }
58+
row.with_value { "Yes" }
59+
end
60+
end
61+
62+
if consent.reason_for_refusal.present?
4763
summary_list.with_row do |row|
4864
row.with_key { "Reason for refusal" }
49-
row.with_value do
50-
Consent.human_enum_name(
51-
:reason_for_refusal,
52-
@consent.reason_for_refusal
53-
)
54-
end
65+
row.with_value { consent.human_enum_name(:reason_for_refusal) }
5566
end
5667
end
5768

58-
if @consent.notes.present?
69+
if consent.notes.present?
5970
summary_list.with_row do |row|
6071
row.with_key { "Notes" }
61-
row.with_value { @consent.notes }
72+
row.with_value { consent.notes }
6273
end
6374
end
6475
end
6576
end
77+
78+
private
79+
80+
attr_reader :consent, :change_links
81+
82+
delegate :programme, to: :consent
6683
end

app/helpers/consents_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def consent_status_tag(consent)
2424
if consent.vaccine_methods.present? &&
2525
consent.programme.has_multiple_vaccine_methods?
2626
tag.span(
27-
Vaccine.human_enum_name(:method, consent.vaccine_methods.join("_")),
27+
Vaccine.human_enum_name(:method, consent.vaccine_methods.first),
2828
class: "nhsuk-u-secondary-text-color"
2929
)
3030
end

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
</ul>
2323

2424
<%= render AppCardComponent.new do |card| %>
25-
<% card.with_heading { "Consent" } %>
25+
<% card.with_heading { "Response" } %>
2626
<%= render AppConsentSummaryComponent.new(@consent) %>
2727
<% end %>
2828

spec/components/app_consent_card_component_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,18 @@
3838

3939
it { should have_content("Decision") }
4040
it { should have_content("Consent given") }
41+
42+
it { should_not have_content("Consent also given for injected vaccine?") }
43+
44+
context "when consenting to multiple vaccine methods" do
45+
let(:programme) { create(:programme, :flu) }
46+
47+
before { consent.update!(vaccine_methods: %w[nasal injection]) }
48+
49+
it { should have_content("Decision") }
50+
it { should have_content("Consent givenNasal spray") }
51+
52+
it { should have_content("Consent also given for injected vaccine?") }
53+
it { should have_content("Yes") }
54+
end
4155
end

spec/components/app_consent_summary_component_spec.rb

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77

88
let(:consent) { create(:consent) }
99

10+
it { should have_content("Programme") }
11+
it { should have_content("Method") }
1012
it { should have_content("Decision") }
11-
it { should have_content("Response method") }
1213

1314
context "when recorded" do
1415
let(:consent) { create(:consent) }
1516

16-
it { should have_content("Response date") }
17+
it { should have_content("Date") }
1718
end
1819

1920
context "when refused" do
@@ -33,4 +34,19 @@
3334

3435
it { should have_content("Notes") }
3536
end
37+
38+
it { should_not have_content("Consent also given for injected vaccine?") }
39+
40+
context "when consenting to multiple vaccine methods" do
41+
let(:programme) { create(:programme, :flu) }
42+
let(:consent) do
43+
create(:consent, programme:, vaccine_methods: %w[nasal injection])
44+
end
45+
46+
it { should have_content("Decision") }
47+
it { should have_content("Consent givenNasal spray") }
48+
49+
it { should have_content("Consent also given for injected vaccine?") }
50+
it { should have_content("Yes") }
51+
end
3652
end

spec/features/self_consent_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def and_the_nurse_records_consent_for_the_child
236236
end
237237

238238
def and_the_child_can_give_their_own_consent_that_the_nurse_records
239-
click_on "Change response method"
239+
click_on "Change method"
240240
choose "Child (Gillick competent)"
241241
5.times { click_on "Continue" }
242242

@@ -246,7 +246,7 @@ def and_the_child_can_give_their_own_consent_that_the_nurse_records
246246
end
247247

248248
def and_changes_the_response_method_to_the_parent
249-
click_on "Change response method"
249+
click_on "Change method"
250250
choose @parent.full_name
251251
click_on "Continue"
252252

spec/features/verbal_consent_given_by_new_parental_contact_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def and_i_record_that_verbal_consent_was_given
5959

6060
# Confirm
6161
expect(page).to have_content("Check and confirm answers")
62-
expect(page).to have_content(["Response method", "By phone"].join)
62+
expect(page).to have_content(["Method", "By phone"].join)
6363
click_button "Confirm"
6464

6565
# Back on the consent responses page

spec/features/verbal_consent_given_spec.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def record_that_verbal_consent_was_given(
100100

101101
# Confirm
102102
expect(page).to have_content("Check and confirm answers")
103-
expect(page).to have_content(["Response method", "By phone"].join)
103+
expect(page).to have_content(["Method", "By phone"].join)
104104
click_button "Confirm"
105105

106106
# Back on the consent responses page
@@ -116,11 +116,9 @@ def and_i_can_see_the_consent_response_details
116116
click_link @parent.full_name
117117

118118
expect(page).to have_content("Consent response from #{@parent.full_name}")
119-
expect(page).to have_content(
120-
["Response date", Date.current.to_fs(:long)].join
121-
)
119+
expect(page).to have_content(["Date", Date.current.to_fs(:long)].join)
122120
expect(page).to have_content(["Decision", "Consent given"].join)
123-
expect(page).to have_content(["Response method", "By phone"].join)
121+
expect(page).to have_content(["Method", "By phone"].join)
124122

125123
expect(page).to have_content(["Full name", @patient.full_name].join)
126124
expect(page).to have_content(

spec/features/verbal_consent_refused_personal_choice_spec.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,9 @@ def and_i_can_see_the_consent_response_details
6969
parent = @patient.parents.first
7070
click_link parent.full_name
7171

72-
expect(page).to have_content(
73-
["Response date", Time.zone.today.to_fs(:long)].join
74-
)
72+
expect(page).to have_content(["Date", Time.zone.today.to_fs(:long)].join)
7573
expect(page).to have_content(["Decision", "Consent refused"].join)
76-
expect(page).to have_content(["Response method", "By phone"].join)
74+
expect(page).to have_content(["Method", "By phone"].join)
7775
expect(page).to have_content(["Reason for refusal", "Personal choice"].join)
7876
expect(page).not_to have_content("Notes")
7977

0 commit comments

Comments
 (0)