Skip to content

Commit e549409

Browse files
authored
Merge pull request #6594 from NHSDigital/add-gillick-assessment-card
Update AppGillickAssessmentComponent
2 parents 6f99c90 + 791e652 commit e549409

8 files changed

Lines changed: 153 additions & 59 deletions
Lines changed: 26 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,33 @@
11
<% if gillick_assessment || can_assess? %>
2-
<h5 class="nhsuk-heading-s">Gillick assessment</h5>
2+
<%= render AppCardComponent.new(section: true) do |card| %>
3+
<% card.with_heading(level: 2) { "Gillick assessment" } %>
34

4-
<% if gillick_assessment %>
5-
<% if gillick_assessment.gillick_competent? %>
6-
<p class="app-status app-status--green">
7-
<svg class="nhsuk-icon nhsuk-icon--tick" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16" focusable="false" aria-hidden="true">
8-
<path d="M11.4 18.8a2 2 0 0 1-2.7.1h-.1L4 14.1a1.5 1.5 0 0 1 2.1-2L10 16l8.1-8.1a1.5 1.5 0 1 1 2.2 2l-8.9 9Z"/>
9-
</svg>
10-
Child assessed as Gillick competent
11-
</p>
12-
<% else %>
13-
<p class="app-status app-status--red">
14-
<svg class="nhsuk-icon nhsuk-icon--cross" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16" focusable="false" aria-hidden="true">
15-
<path d="M17 18.5c-.4 0-.8-.1-1.1-.4l-10-10c-.6-.6-.6-1.6 0-2.1.6-.6 1.5-.6 2.1 0l10 10c.6.6.6 1.5 0 2.1-.3.3-.6.4-1 .4z M7 18.5c-.4 0-.8-.1-1.1-.4-.6-.6-.6-1.5 0-2.1l10-10c.6-.6 1.5-.6 2.1 0 .6.6.6 1.5 0 2.1l-10 10c-.3.3-.6.4-1 .4z"/>
16-
</svg>
17-
Child assessed as not Gillick competent
18-
</p>
19-
<% end %>
5+
<% if gillick_assessment %>
6+
<% if gillick_assessment.gillick_competent? %>
7+
<%= render AppStatusComponent.new(text: "Child assessed as Gillick competent", colour: "green", icon: :tick) %>
8+
<% else %>
9+
<%= render AppStatusComponent.new(text: "Child assessed as not Gillick competent", colour: "red", icon: :cross) %>
10+
<% end %>
2011

21-
<% if (notes = gillick_assessment.notes).present? %>
22-
<p><%= notes %></p>
23-
<% end %>
12+
<% if (notes = gillick_assessment.notes).present? %>
13+
<p><%= notes %></p>
14+
<% end %>
2415

25-
<% if policy(gillick_assessment).edit? %>
26-
<p>
27-
<%= govuk_button_link_to "Edit Gillick competence",
28-
edit_session_patient_programme_gillick_assessment_path(
29-
session,
30-
patient,
31-
programme,
32-
),
33-
secondary: true,
34-
class: "nhsuk-u-margin-bottom-0" %>
35-
</p>
16+
<% if policy(gillick_assessment).edit? %>
17+
<%= render AppActionLinkComponent.new(text: "Update Gillick competence",
18+
href: edit_session_patient_programme_gillick_assessment_path(
19+
session,
20+
patient,
21+
programme,
22+
)) %>
23+
<% end %>
24+
<% elsif can_assess? %>
25+
<%= render AppActionLinkComponent.new(text: "Assess Gillick competence",
26+
href: edit_session_patient_programme_gillick_assessment_path(
27+
session,
28+
patient,
29+
programme,
30+
)) %>
3631
<% end %>
37-
<% elsif can_assess? %>
38-
<p>
39-
<%= govuk_button_link_to "Assess Gillick competence",
40-
edit_session_patient_programme_gillick_assessment_path(
41-
session,
42-
patient,
43-
programme,
44-
),
45-
secondary: true,
46-
class: "nhsuk-u-margin-bottom-0" %>
47-
</p>
4832
<% end %>
4933
<% end %>

app/components/app_patient_session_consent_component.html.erb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@
4242
),
4343
secondary: true %>
4444
</div>
45-
46-
<%= render AppGillickAssessmentComponent.new(patient:, session:, programme:) %>
4745
<% end %>
4846

4947
<% if consents.any? %>

app/components/app_status_component.rb

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,65 @@
33
class AppStatusComponent < ViewComponent::Base
44
erb_template <<-ERB
55
<p class="app-status app-status--<%= @colour %> <% if @small %>app-status--small<% end %> <%= @classes %>">
6-
<svg class="nhsuk-icon nhsuk-icon--warning" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16" focusable="false" aria-hidden="true">
7-
<path d="M12 2a10 10 0 1 1 0 20 10 10 0 0 1 0-20Zm0 14a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3Zm-1.5-9.5V13a1.5 1.5 0 0 0 3 0V6.5a1.5 1.5 0 0 0-3 0Z"/>
8-
</svg>
6+
<%= icon_svg %>
97
<%= @text %>
108
</p>
119
ERB
1210

13-
def initialize(text:, colour: "blue", small: false, classes: "")
11+
def initialize(
12+
text:,
13+
colour: "blue",
14+
icon: :warning,
15+
small: false,
16+
classes: ""
17+
)
1418
@text = text
1519
@colour = colour
20+
@icon = icon
1621
@small = small
1722
@classes = classes
1823
end
24+
25+
private
26+
27+
def icon_svg
28+
case @icon
29+
when :tick
30+
path = <<~PATH.squish
31+
M11.4 18.8a2 2 0 0 1-2.7.1h-.1L4 14.1a1.5 1.5 0 0 1 2.1-2L10 16l8.1-8.1a1.5 1.5 0 1 1
32+
2.2 2l-8.9 9Z
33+
PATH
34+
svg_icon("nhsuk-icon--tick", path)
35+
when :cross
36+
path = <<~PATH.squish
37+
M17 18.5c-.4 0-.8-.1-1.1-.4l-10-10c-.6-.6-.6-1.6 0-2.1.6-.6 1.5-.6 2.1 0l10 10c.6.6.6
38+
1.5 0 2.1-.3.3-.6.4-1 .4z M7 18.5c-.4 0-.8-.1-1.1-.4-.6-.6-.6-1.5 0-2.1l10-10c.6-.6
39+
1.5-.6 2.1 0 .6.6.6 1.5 0 2.1l-10 10c-.3.3-.6.4-1 .4z
40+
PATH
41+
svg_icon("nhsuk-icon--cross", path)
42+
when :warning
43+
path = <<~PATH.squish
44+
M12 2a10 10 0 1 1 0 20 10 10 0 0 1 0-20Zm0 14a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0
45+
0-3Zm-1.5-9.5V13a1.5 1.5 0 0 0 3 0V6.5a1.5 1.5 0 0 0-3 0Z
46+
PATH
47+
svg_icon("nhsuk-icon--warning", path)
48+
else
49+
raise ArgumentError,
50+
"Unknown icon: #{@icon.inspect}. Must be :warning, :tick, or :cross"
51+
end
52+
end
53+
54+
def svg_icon(icon_class, path)
55+
tag.svg(
56+
class: "nhsuk-icon #{icon_class}",
57+
xmlns: "http://www.w3.org/2000/svg",
58+
viewBox: "0 0 24 24",
59+
width: "16",
60+
height: "16",
61+
focusable: "false",
62+
aria: {
63+
hidden: "true"
64+
}
65+
) { tag.path(d: path) }
66+
end
1967
end

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
<div class="app-grid-column-patient-session">
99
<%= render AppPatientSessionProgrammeComponent.new(patient: @patient, session: @session, programme: @programme) %>
1010

11+
<%= render AppGillickAssessmentComponent.new(patient: @patient, session: @session, programme: @programme) %>
12+
1113
<%= render AppPatientSessionConsentComponent.new(patient: @patient, session: @session, programme: @programme) %>
1214

1315
<%= render AppPatientSessionTriageComponent.new(patient: @patient, session: @session, programme: @programme, current_user:, triage_form: @triage_form) %>

spec/components/app_gillick_assessment_component_spec.rb

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
before { stub_authorization(allowed: true) }
2626

2727
it { should have_heading("Gillick assessment") }
28-
it { should have_link("Edit Gillick competence") }
28+
it { should have_link("Update Gillick competence") }
2929
it { should have_content("Child assessed as Gillick competent") }
3030

3131
context "when the assessment is for a different day" do
@@ -39,7 +39,21 @@
3939
context "with an admin user" do
4040
before { stub_authorization(allowed: false) }
4141

42-
it { should_not have_link("Edit Gillick competence") }
42+
it { should_not have_link("Update Gillick competence") }
43+
end
44+
45+
context "with a not-competent Gillick assessment" do
46+
before { create(:gillick_assessment, :not_competent, patient:, session:) }
47+
48+
it { should have_text("Child assessed as not Gillick competent") }
49+
it { should have_link("Update Gillick competence") }
50+
end
51+
52+
context "when the session is not today" do
53+
let(:session) { create(:session, :scheduled, programmes:) }
54+
55+
it { should_not have_heading("Gillick assessment") }
56+
it { should_not have_link("Assess Gillick competence") }
4357
end
4458
end
4559
end

spec/components/app_patient_session_consent_component_spec.rb

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@
1717
it { should_not have_css("details", text: "Responses to health questions") }
1818
it { should have_css("p", text: "No consent request is scheduled") }
1919
it { should have_css("button", text: "Record a new consent response") }
20-
21-
context "when session is not in progress" do
22-
let(:session) { create(:session, :scheduled, programmes: [programme]) }
23-
24-
it { should_not have_css("button", text: "Assess Gillick competence") }
25-
end
2620
end
2721

2822
context "when vaccinated" do
@@ -32,7 +26,6 @@
3226

3327
it { should_not have_css("p", text: "No requests have been sent.") }
3428
it { should_not have_css("button", text: "Record a new consent response") }
35-
it { should_not have_css("button", text: "Assess Gillick competence") }
3629
end
3730

3831
context "with refused consent" do
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# frozen_string_literal: true
2+
3+
describe AppStatusComponent do
4+
subject(:rendered) { render_inline(component) }
5+
6+
let(:component) { described_class.new(text: "Some status", colour:, icon:) }
7+
let(:colour) { "blue" }
8+
let(:icon) { :warning }
9+
10+
it { should have_css("p.app-status.app-status--blue", text: "Some status") }
11+
it { should have_css("svg.nhsuk-icon--warning") }
12+
13+
context "with colour: 'green'" do
14+
let(:colour) { "green" }
15+
16+
it { should have_css("p.app-status.app-status--green") }
17+
end
18+
19+
context "with icon: :tick" do
20+
let(:icon) { :tick }
21+
22+
it { should have_css("svg.nhsuk-icon--tick") }
23+
it { should_not have_css("svg.nhsuk-icon--warning") }
24+
end
25+
26+
context "with icon: :cross" do
27+
let(:icon) { :cross }
28+
29+
it { should have_css("svg.nhsuk-icon--cross") }
30+
it { should_not have_css("svg.nhsuk-icon--warning") }
31+
end
32+
33+
context "with an unknown icon" do
34+
let(:icon) { :unknown }
35+
36+
it { expect { rendered }.to raise_error(ArgumentError) }
37+
end
38+
39+
context "with small: true" do
40+
let(:component) { described_class.new(text: "Some status", small: true) }
41+
42+
it { should have_css("p.app-status.app-status--small") }
43+
end
44+
45+
context "with extra classes" do
46+
let(:component) do
47+
described_class.new(
48+
text: "Some status",
49+
classes: "nhsuk-u-margin-bottom-0"
50+
)
51+
end
52+
53+
it { should have_css("p.app-status.nhsuk-u-margin-bottom-0") }
54+
end
55+
end

spec/features/self_consent_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def and_the_child_cannot_give_their_own_consent
146146
end
147147

148148
def and_the_child_status_reflects_that_there_is_no_consent
149-
expect(page).to have_content("No contact details")
149+
expect(page).to have_content("no parent contact details")
150150
end
151151

152152
def and_the_activity_log_shows_the_gillick_non_competence
@@ -158,7 +158,7 @@ def and_the_activity_log_shows_the_gillick_non_competence
158158
end
159159

160160
def when_the_nurse_edits_the_assessment_the_child_as_gillick_competent
161-
click_on "Edit Gillick competence"
161+
click_on "Update Gillick competence"
162162

163163
# notes from previous assessment
164164
expect(page).to have_content(

0 commit comments

Comments
 (0)