Skip to content

Commit c3c510a

Browse files
authored
Allow changing consent response from child to parent (#3547)
When changing the consent response from a child, currently this doesn't reset the "route" from self-consent, meaning that the consent continues to show as part of the self-consent journey even if the consent has been changed to be from a parent.
2 parents bb2b211 + 7b4d079 commit c3c510a

File tree

2 files changed

+71
-8
lines changed

2 files changed

+71
-8
lines changed

app/models/draft_consent.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,13 @@ def new_or_existing_contact=(value)
141141
@new_or_existing_contact = value
142142

143143
if value == "new"
144+
self.route = nil
144145
self.parent = nil
145146
elsif value == "patient"
146147
self.route = "self_consent"
147148
self.parent = nil
148149
else
150+
self.route = nil
149151
self.parent =
150152
patient.parents.find_by(id: value) ||
151153
Parent.where(consents: patient.consents.where(programme:)).find_by(

spec/features/self_consent_spec.rb

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

33
describe "Self-consent" do
4-
scenario "From Gillick assessment" do
4+
scenario "after Gillick assessment" do
55
given_an_hpv_programme_is_underway
66
and_there_is_a_child_without_parental_consent
77

@@ -15,18 +15,35 @@
1515
then_the_details_of_the_gillick_competence_assessment_are_visible
1616
and_the_activity_log_shows_the_gillick_non_competence
1717
and_the_activity_log_shows_the_gillick_competence
18+
and_the_nurse_records_consent_for_the_child
1819
and_the_child_can_give_their_own_consent_that_the_nurse_records
1920

2021
when_the_nurse_views_the_childs_record
21-
then_they_see_that_the_child_has_consent
22+
then_they_see_that_the_child_has_consent_from_themselves
2223
and_the_child_should_be_safe_to_vaccinate
2324
and_enqueued_jobs_run_with_no_errors
2425
end
2526

27+
scenario "change to parent consent" do
28+
given_an_hpv_programme_is_underway
29+
and_there_is_a_child_with_gillick_competence
30+
and_the_child_has_a_parent
31+
32+
when_the_nurse_goes_to_the_child
33+
and_the_nurse_records_consent_for_the_child
34+
and_changes_the_response_method_to_the_parent
35+
then_the_parent_can_give_consent
36+
37+
when_the_nurse_views_the_childs_record
38+
then_they_see_that_the_child_has_consent_from_the_parent
39+
and_the_child_should_be_safe_to_vaccinate
40+
end
41+
2642
def given_an_hpv_programme_is_underway
27-
programme = create(:programme, :hpv)
43+
@programme = create(:programme, :hpv)
44+
2845
@organisation =
29-
create(:organisation, :with_one_nurse, programmes: [programme])
46+
create(:organisation, :with_one_nurse, programmes: [@programme])
3047

3148
@school = create(:school)
3249

@@ -35,7 +52,7 @@ def given_an_hpv_programme_is_underway
3552
:session,
3653
:today,
3754
organisation: @organisation,
38-
programmes: [programme],
55+
programmes: [@programme],
3956
location: @school
4057
)
4158

@@ -62,6 +79,25 @@ def and_there_is_a_child_without_parental_consent
6279
expect(page).to have_content(@patient.full_name)
6380
end
6481

82+
def and_there_is_a_child_with_gillick_competence
83+
create(
84+
:gillick_assessment,
85+
:competent,
86+
patient_session: @patient.patient_sessions.first,
87+
programme: @programme
88+
)
89+
end
90+
91+
def and_the_child_has_a_parent
92+
@parent = create(:parent_relationship, patient: @patient).parent
93+
end
94+
95+
def when_the_nurse_goes_to_the_child
96+
sign_in @organisation.users.first
97+
98+
visit session_patient_programme_path(@session, @patient, @programme)
99+
end
100+
65101
def when_the_nurse_assesses_the_child_as_not_being_gillick_competent
66102
click_on @patient.full_name
67103
click_on "Assess Gillick competence"
@@ -176,7 +212,7 @@ def and_the_activity_log_shows_the_gillick_competence
176212
click_on "HPV"
177213
end
178214

179-
def and_the_child_can_give_their_own_consent_that_the_nurse_records
215+
def and_the_nurse_records_consent_for_the_child
180216
click_on "Get consent"
181217

182218
# who
@@ -197,8 +233,9 @@ def and_the_child_can_give_their_own_consent_that_the_nurse_records
197233

198234
choose "Yes, it’s safe to vaccinate"
199235
click_on "Continue"
236+
end
200237

201-
# confirmation page
238+
def and_the_child_can_give_their_own_consent_that_the_nurse_records
202239
click_on "Change response method"
203240
choose "Child (Gillick competent)"
204241
5.times { click_on "Continue" }
@@ -208,17 +245,41 @@ def and_the_child_can_give_their_own_consent_that_the_nurse_records
208245
expect(page).to have_content("Consent recorded for #{@patient.full_name}")
209246
end
210247

248+
def and_changes_the_response_method_to_the_parent
249+
click_on "Change response method"
250+
choose @parent.full_name
251+
click_on "Continue"
252+
253+
click_on "Continue"
254+
255+
choose "By phone"
256+
click_on "Continue"
257+
258+
3.times { click_on "Continue" }
259+
end
260+
261+
def then_the_parent_can_give_consent
262+
click_on "Confirm"
263+
end
264+
211265
def when_the_nurse_views_the_childs_record
212266
click_on @patient.full_name, match: :first
213267
end
214268

215-
def then_they_see_that_the_child_has_consent
269+
def then_they_see_that_the_child_has_consent_from_themselves
216270
expect(page).to have_content(
217271
"#{@patient.full_name} Child (Gillick competent)"
218272
)
219273
expect(page).to have_content("Consent given")
220274
end
221275

276+
def then_they_see_that_the_child_has_consent_from_the_parent
277+
expect(page).to have_content(
278+
"Consent given\nNameResponse dateDecision #{@parent.full_name}"
279+
)
280+
expect(page).to have_content("Consent given")
281+
end
282+
222283
def and_the_child_should_be_safe_to_vaccinate
223284
expect(page).to have_content("Safe to vaccinate")
224285
end

0 commit comments

Comments
 (0)