Skip to content

Commit aeb0ef5

Browse files
authored
Merge pull request #3253 from nhsuk/change-consent-parent
Update change link for parents in consent journey
2 parents 74d30f6 + ea4015d commit aeb0ef5

File tree

4 files changed

+107
-34
lines changed

4 files changed

+107
-34
lines changed

app/models/draft_consent.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,7 @@ def wizard_steps
7878
end
7979
}
8080

81-
with_options if: -> do
82-
parent_id.nil? &&
83-
required_for_step?(:parent_details, exact: true)
84-
end do
81+
with_options if: -> { required_for_step?(:parent_details, exact: true) } do
8582
validates :parent_full_name, presence: true
8683
validates :parent_relationship_type,
8784
inclusion: {
@@ -90,7 +87,7 @@ def wizard_steps
9087
end
9188

9289
with_options if: -> do
93-
parent_id.nil? && parent_relationship_type == "other" &&
90+
parent_relationship_type == "other" &&
9491
required_for_step?(:parent_details, exact: true)
9592
end do
9693
validates :parent_relationship_other_name,
@@ -199,6 +196,7 @@ def parent=(value)
199196
self.parent_phone_receive_updates = value&.phone_receive_updates
200197
self.parent_relationship_type = parent_relationship&.type
201198
self.parent_relationship_other_name = parent_relationship&.other_name
199+
self.parent_responsibility = true # if consent was submitted this must've been true
202200
end
203201

204202
def patient_session

app/views/draft_consents/confirm.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626

2727
<% if (parent_relationship = @draft_consent.parent_relationship).present? %>
2828
<%= render AppParentCardComponent.new(parent_relationship:, change_links: {
29-
name: wizard_path("who"),
30-
relationship: wizard_path("who"),
29+
name: wizard_path("parent-details"),
30+
relationship: wizard_path("parent-details"),
3131
email: wizard_path("parent-details"),
3232
phone: wizard_path("parent-details"),
3333
}) %>

app/views/draft_consents/parent_details.html.erb

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,31 @@
1818
<%= form_with model: @draft_consent, url: wizard_path, method: :put do |f| %>
1919
<% content_for(:before_content) { f.govuk_error_summary } %>
2020

21-
<% if @parent.new_record? %>
22-
<%= f.govuk_text_field :parent_full_name, label: { text: "Full name" } %>
23-
24-
<%= f.govuk_radio_buttons_fieldset(:parent_relationship_type,
25-
legend: { size: "s",
26-
text: "Relationship to the child" }) do %>
27-
<%= f.govuk_radio_button :parent_relationship_type, "mother",
28-
label: { text: "Mum" }, link_errors: true %>
29-
<%= f.govuk_radio_button :parent_relationship_type, "father",
30-
label: { text: "Dad" } %>
31-
<%= f.govuk_radio_button :parent_relationship_type, "guardian",
32-
label: { text: "Guardian" } %>
33-
<%= f.govuk_radio_button :parent_relationship_type, "other",
34-
label: { text: "Other" } do %>
35-
<p>They need parental responsibility to give consent.</p>
36-
<%= f.govuk_text_field :parent_relationship_other_name,
37-
label: { text: "Relationship to the child" },
38-
hint: { text: "For example, carer" } %>
39-
<%= f.govuk_radio_buttons_fieldset(:parent_responsibility,
40-
legend: { size: "s",
41-
text: "Do they have parental responsibility?" },
42-
hint: { text: "They have the legal rights and duties relating to the child" }) do %>
43-
<%= f.govuk_radio_button :parent_responsibility, "yes",
44-
label: { text: "Yes" }, link_errors: true %>
45-
<%= f.govuk_radio_button :parent_responsibility, "no",
46-
label: { text: "No" } %>
47-
<% end %>
21+
<%= f.govuk_text_field :parent_full_name, label: { text: "Full name" } %>
22+
23+
<%= f.govuk_radio_buttons_fieldset(:parent_relationship_type,
24+
legend: { size: "s",
25+
text: "Relationship to the child" }) do %>
26+
<%= f.govuk_radio_button :parent_relationship_type, "mother",
27+
label: { text: "Mum" }, link_errors: true %>
28+
<%= f.govuk_radio_button :parent_relationship_type, "father",
29+
label: { text: "Dad" } %>
30+
<%= f.govuk_radio_button :parent_relationship_type, "guardian",
31+
label: { text: "Guardian" } %>
32+
<%= f.govuk_radio_button :parent_relationship_type, "other",
33+
label: { text: "Other" } do %>
34+
<p>They need parental responsibility to give consent.</p>
35+
<%= f.govuk_text_field :parent_relationship_other_name,
36+
label: { text: "Relationship to the child" },
37+
hint: { text: "For example, carer" } %>
38+
<%= f.govuk_radio_buttons_fieldset(:parent_responsibility,
39+
legend: { size: "s",
40+
text: "Do they have parental responsibility?" },
41+
hint: { text: "They have the legal rights and duties relating to the child" }) do %>
42+
<%= f.govuk_radio_button :parent_responsibility, "yes",
43+
label: { text: "Yes" }, link_errors: true %>
44+
<%= f.govuk_radio_button :parent_responsibility, "no",
45+
label: { text: "No" } %>
4846
<% end %>
4947
<% end %>
5048
<% end %>
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# frozen_string_literal: true
2+
3+
describe "Verbal consent" do
4+
scenario "Change answers" do
5+
given_a_patient_is_in_an_hpv_programme
6+
7+
when_i_get_consent_for_the_patient
8+
and_i_choose_the_parent
9+
and_i_fill_out_the_consent_details(parent_name: @parent.full_name)
10+
then_i_see_the_confirmation_page
11+
12+
when_i_click_on_change_name
13+
and_i_fill_out_the_consent_details(parent_name: "New parent name")
14+
then_i_see_the_confirmation_page
15+
end
16+
17+
def given_a_patient_is_in_an_hpv_programme
18+
programmes = [create(:programme, :hpv)]
19+
organisation = create(:organisation, programmes:)
20+
21+
@nurse = create(:nurse, organisation:)
22+
23+
@session = create(:session, organisation:, programmes:)
24+
25+
@parent = create(:parent)
26+
@patient = create(:patient, session: @session, parents: [@parent])
27+
end
28+
29+
def when_i_get_consent_for_the_patient
30+
sign_in @nurse
31+
visit session_consent_path(@session)
32+
click_link @patient.full_name
33+
click_button "Get consent"
34+
end
35+
36+
def and_i_choose_the_parent
37+
click_button "Continue"
38+
expect(page).to have_content(
39+
"Choose who you are trying to get consent from"
40+
)
41+
42+
choose "#{@parent.full_name} (#{@patient.parent_relationships.first.label})"
43+
click_button "Continue"
44+
end
45+
46+
def and_i_fill_out_the_consent_details(parent_name:)
47+
expect(page).to have_content(
48+
"Details for #{parent_name} (#{@patient.parent_relationships.first.label})"
49+
)
50+
51+
fill_in "Full name", with: "New parent name"
52+
click_button "Continue"
53+
54+
choose "By phone"
55+
click_button "Continue"
56+
57+
choose "Yes, they agree"
58+
click_button "Continue"
59+
60+
find_all(".nhsuk-fieldset")[0].choose "No"
61+
find_all(".nhsuk-fieldset")[1].choose "No"
62+
find_all(".nhsuk-fieldset")[2].choose "No"
63+
find_all(".nhsuk-fieldset")[3].choose "No"
64+
click_button "Continue"
65+
66+
choose "Yes, it’s safe to vaccinate"
67+
click_button "Continue"
68+
end
69+
70+
def then_i_see_the_confirmation_page
71+
expect(page).to have_content("Check and confirm answers")
72+
end
73+
74+
def when_i_click_on_change_name
75+
click_link "Change name"
76+
end
77+
end

0 commit comments

Comments
 (0)