Skip to content

Commit 809f150

Browse files
committed
wip
1 parent 7de2555 commit 809f150

11 files changed

+133
-225
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<%= render AppCardComponent.new(colour:) do |card| %>
2+
<% card.with_heading { heading } %>
3+
4+
<% if patient.consent_outcome.no_response?(programme) %>
5+
<% if latest_consent_request %>
6+
<p class="nhsuk-body">
7+
No-one responded to our requests for consent.
8+
</p>
9+
10+
<p class="nhsuk-body">
11+
A request was sent on <%= latest_consent_request.sent_at.to_fs(:long) %>.
12+
</p>
13+
<% else %>
14+
<p class="nhsuk-body">
15+
No requests have been sent.
16+
</p>
17+
<% end %>
18+
<% end %>
19+
20+
<%= render AppConsentTableComponent.new(patient_session:, programme:) %>
21+
22+
<% if can_send_consent_request? %>
23+
<%= govuk_button_to "Send consent request",
24+
send_request_session_patient_programme_consents_path(
25+
session, patient, programme
26+
),
27+
class: "app-button--secondary" %>
28+
<% end %>
29+
30+
<%= govuk_button_to "Get consent response",
31+
session_patient_programme_consents_path(
32+
session, patient, programme
33+
),
34+
class: "app-button--secondary" %>
35+
36+
<%= render AppGillickAssessmentComponent.new(patient_session:, programme:) %>
37+
<% end %>

app/components/app_consent_component.rb renamed to app/components/app_consent_card_component.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
class AppConsentComponent < ViewComponent::Base
3+
class AppConsentCardComponent < ViewComponent::Base
44
def initialize(patient_session:, programme:)
55
super
66

@@ -12,6 +12,14 @@ def initialize(patient_session:, programme:)
1212

1313
delegate :patient, :session, to: :patient_session
1414

15+
def colour
16+
I18n.t(status, scope: %i[status consent colour])
17+
end
18+
19+
def heading
20+
"#{programme.name}: #{I18n.t(status, scope: %i[status consent label])}"
21+
end
22+
1523
def latest_consent_request
1624
@latest_consent_request ||=
1725
patient
@@ -27,4 +35,10 @@ def can_send_consent_request?
2735
patient.send_notifications? && session.open_for_consent? &&
2836
patient.parents.any?
2937
end
38+
39+
private
40+
41+
def status
42+
patient.consent_outcome.status[programme]
43+
end
3044
end

app/components/app_consent_component.html.erb

Lines changed: 0 additions & 33 deletions
This file was deleted.
Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,45 @@
11
<% if gillick_assessment || can_assess? %>
2-
<%= render AppCardComponent.new do |card| %>
3-
<% card.with_heading { "Gillick assessment" } %>
2+
<h3 class="nhsuk-heading-s nhsuk-u-margin-bottom-3">Gillick assessment</h3>
43

5-
<% if gillick_assessment %>
6-
<% if gillick_assessment.gillick_competent? %>
7-
<p class="app-status app-status--aqua-green">
8-
<svg class="nhsuk-icon nhsuk-icon__tick" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true">
9-
<path d="M18.4 7.8l-8.5 8.4L5.6 12" fill="none" stroke="currentColor" stroke-width="4" stroke-linecap="round"></path>
10-
</svg>
11-
Child assessed as Gillick competent
12-
</p>
13-
<% else %>
14-
<p class="app-status app-status--red">
15-
<svg class="nhsuk-icon nhsuk-icon__cross" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true">
16-
<path d="M18.6 6.5c.5.5.5 1.5 0 2l-4 4 4 4c.5.6.5 1.4 0 2-.4.4-.7.4-1 .4-.5 0-.9 0-1.2-.3l-3.9-4-4 4c-.3.3-.5.3-1 .3a1.5 1.5 0 0 1-1-2.4l3.9-4-4-4c-.5-.5-.5-1.4 0-2 .6-.7 1.5-.7 2.2 0l3.9 3.9 4-4c.6-.6 1.4-.6 2 0Z" fill="currentColor"></path>
17-
</svg>
18-
Child assessed as not Gillick competent
19-
</p>
20-
<% end %>
4+
<% if gillick_assessment %>
5+
<% if gillick_assessment.gillick_competent? %>
6+
<p class="app-status app-status--aqua-green">
7+
<svg class="nhsuk-icon nhsuk-icon__tick" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true">
8+
<path d="M18.4 7.8l-8.5 8.4L5.6 12" fill="none" stroke="currentColor" stroke-width="4" stroke-linecap="round"></path>
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" aria-hidden="true">
15+
<path d="M18.6 6.5c.5.5.5 1.5 0 2l-4 4 4 4c.5.6.5 1.4 0 2-.4.4-.7.4-1 .4-.5 0-.9 0-1.2-.3l-3.9-4-4 4c-.3.3-.5.3-1 .3a1.5 1.5 0 0 1-1-2.4l3.9-4-4-4c-.5-.5-.5-1.4 0-2 .6-.7 1.5-.7 2.2 0l3.9 3.9 4-4c.6-.6 1.4-.6 2 0Z" fill="currentColor"></path>
16+
</svg>
17+
Child assessed as not Gillick competent
18+
</p>
19+
<% end %>
2120

22-
<% if (notes = gillick_assessment.notes).present? %>
23-
<p class="nhsuk-body"><%= notes %></p>
24-
<% end %>
21+
<% if (notes = gillick_assessment.notes).present? %>
22+
<p class="nhsuk-body"><%= notes %></p>
23+
<% end %>
2524

26-
<% if helpers.policy(gillick_assessment).edit? %>
27-
<p class="nhsuk-body">
28-
<%= govuk_button_link_to "Edit Gillick competence",
29-
edit_session_patient_programme_gillick_assessment_path(
30-
session,
31-
patient,
32-
programme,
33-
), class: "app-button--secondary nhsuk-u-margin-bottom-0" %>
34-
</p>
35-
<% end %>
36-
<% elsif can_assess? %>
25+
<% if helpers.policy(gillick_assessment).edit? %>
3726
<p class="nhsuk-body">
38-
<%= govuk_button_link_to "Assess Gillick competence",
27+
<%= govuk_button_link_to "Edit Gillick competence",
3928
edit_session_patient_programme_gillick_assessment_path(
4029
session,
4130
patient,
4231
programme,
4332
), class: "app-button--secondary nhsuk-u-margin-bottom-0" %>
4433
</p>
4534
<% end %>
35+
<% elsif can_assess? %>
36+
<p class="nhsuk-body">
37+
<%= govuk_button_link_to "Assess Gillick competence",
38+
edit_session_patient_programme_gillick_assessment_path(
39+
session,
40+
patient,
41+
programme,
42+
), class: "app-button--secondary nhsuk-u-margin-bottom-0" %>
43+
</p>
4644
<% end %>
4745
<% end %>

app/components/app_patient_page_component.html.erb

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,6 @@
1313

1414
<%= render AppPatientCardComponent.new(patient) %>
1515

16-
<%= render AppGillickAssessmentComponent.new(patient_session:, programme:) %>
17-
18-
<%= render AppCardComponent.new do |c| %>
19-
<% c.with_heading { "Consent" } %>
20-
<%= render AppConsentComponent.new(patient_session:, programme:) %>
21-
<% end %>
22-
23-
<% if display_health_questions? %>
24-
<%= render AppHealthAnswersCardComponent.new(
25-
patient.consent_outcome.latest[programme],
26-
heading: "All answers to health questions",
27-
) %>
28-
<% end %>
29-
3016
<% if patient.triage_outcome.all[programme].any? %>
3117
<%= render AppCardComponent.new do |c| %>
3218
<% c.with_heading { "Triage notes" } %>

app/components/app_patient_page_component.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ def initialize(
2323

2424
delegate :patient, :session, to: :patient_session
2525

26-
def display_health_questions?
27-
patient.consent_outcome.latest[programme].any?(&:response_given?)
28-
end
29-
3026
def default_vaccinate_form
3127
pre_screening = patient_session.pre_screenings.last
3228

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# frozen_string_literal: true
2+
3+
class AppPatientSessionConsentComponent < ViewComponent::Base
4+
erb_template <<-ERB
5+
<h2 class="nhsuk-heading-m">Consent</h2>
6+
7+
<%= render AppConsentCardComponent.new(patient_session:, programme:) %>
8+
9+
<% if show_health_answers? %>
10+
<%= render AppHealthAnswersCardComponent.new(
11+
latest_consent,
12+
heading: "All answers to health questions",
13+
) %>
14+
<% end %>
15+
ERB
16+
17+
def initialize(patient_session, programme:)
18+
super
19+
20+
@patient_session = patient_session
21+
@programme = programme
22+
end
23+
24+
private
25+
26+
attr_reader :patient_session, :programme
27+
28+
delegate :patient, to: :patient_session
29+
30+
def latest_consent
31+
patient.consent_outcome.latest[programme]
32+
end
33+
34+
def show_health_answers?
35+
latest_consent.any?(&:response_given?)
36+
end
37+
end

app/views/patient_sessions/show.html.erb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
<div class="nhsuk-grid-row">
44
<div class="nhsuk-grid-column-three-quarters">
5+
<%= render AppPatientSessionConsentComponent.new(@patient_session, programme: @programme) %>
6+
57
<%= render AppPatientPageComponent.new(
68
patient_session: @patient_session,
79
programme: @programme,

spec/components/app_consent_component_spec.rb renamed to spec/components/app_consent_card_component_spec.rb

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

3-
describe AppConsentComponent do
4-
subject(:rendered) { render_inline(component) }
3+
describe AppConsentCardComponent do
4+
subject { render_inline(component) }
55

66
let(:component) do
77
described_class.new(patient_session:, programme: programmes.first)
@@ -12,7 +12,10 @@
1212
patient_session.patient.consent_outcome.all[programmes.first].first
1313
end
1414

15-
before { patient_session.reload.strict_loading!(false) }
15+
before do
16+
patient_session.reload.strict_loading!(false)
17+
stub_authorization(allowed: true)
18+
end
1619

1720
context "consent is not present" do
1821
let(:patient_session) { create(:patient_session, programmes:) }
@@ -36,21 +39,10 @@
3639
create(:patient_session, :consent_refused, programmes:)
3740
end
3841

39-
it { should have_css("p.app-status--red", text: "Consent refused") }
40-
41-
it { should have_css("table tr", text: /#{consent.parent.full_name}/) }
42-
43-
it do
44-
expect(rendered).to have_css(
45-
"table tr",
46-
text: /#{consent.parent_relationship.label}/
47-
)
48-
end
49-
50-
it "displays the response" do
51-
expect(rendered).to have_css("table tr", text: /Consent refused/)
52-
end
53-
42+
it { should have_css(".app-card--red", text: "Consent refused") }
43+
it { should have_css("tr", text: /#{consent.parent.full_name}/) }
44+
it { should have_css("tr", text: /#{consent.parent_relationship.label}/) }
45+
it { should have_css("table tr", text: /Consent refused/) }
5446
it { should_not have_css("details", text: "Responses to health questions") }
5547
end
5648

@@ -59,7 +51,7 @@
5951
create(:patient_session, :consent_given_triage_needed, programmes:)
6052
end
6153

62-
it { should have_css("p.app-status--aqua-green", text: "Consent given") }
54+
it { should have_css(".app-card--aqua-green", text: "Consent given") }
6355
it { should_not have_css("a", text: "Contact #{consent.parent.full_name}") }
6456
end
6557
end

spec/components/app_patient_page_component_spec.rb

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,12 @@
3636
end
3737

3838
it { should have_css(".nhsuk-card__heading", text: "Child") }
39-
it { should have_css(".nhsuk-card__heading", text: "Consent") }
4039
it { should_not have_css(".nhsuk-card__heading", text: "Triage notes") }
4140

4241
it { should have_content("Is it safe to vaccinate") }
4342

4443
it { should_not have_content("ready for their HPV vaccination?") }
4544

46-
it { should have_css("a", text: "Assess Gillick competence") }
47-
4845
context "user is not allowed to triage or vaccinate" do
4946
before { stub_authorization(allowed: false) }
5047

@@ -64,7 +61,6 @@
6461
end
6562

6663
it { should have_css(".nhsuk-card__heading", text: "Child") }
67-
it { should have_css(".nhsuk-card__heading", text: "Consent") }
6864
it { should have_css(".nhsuk-card__heading", text: "Triage notes") }
6965

7066
it { should_not have_content("Is it safe to vaccinate") }
@@ -77,52 +73,4 @@
7773
it { should_not have_content("ready for their HPV vaccination?") }
7874
end
7975
end
80-
81-
context "session in progress, patient without consent, no Gillick assessment" do
82-
let(:patient_session) do
83-
create(:patient_session, :session_in_progress, programmes:)
84-
end
85-
86-
context "nurse user" do
87-
before { stub_authorization(allowed: true) }
88-
89-
it { should have_css("a", text: "Assess Gillick competence") }
90-
end
91-
92-
context "admin user" do
93-
before { stub_authorization(allowed: false) }
94-
95-
it { should_not have_css("a", text: "Assess Gillick competence") }
96-
end
97-
end
98-
99-
context "session in progress, patient without consent, Gillick assessment" do
100-
let(:patient_session) do
101-
create(
102-
:patient_session,
103-
:session_in_progress,
104-
:gillick_competent,
105-
programmes:
106-
)
107-
end
108-
109-
context "nurse user" do
110-
before { stub_authorization(allowed: true) }
111-
112-
it { should have_css("a", text: "Edit Gillick competence") }
113-
114-
it "shows the Gillick assessment" do
115-
expect(rendered).to have_css(
116-
".nhsuk-card__heading",
117-
text: "Gillick assessment"
118-
)
119-
end
120-
end
121-
122-
context "admin user" do
123-
before { stub_authorization(allowed: false) }
124-
125-
it { should_not have_css("a", text: "Edit Gillick competence") }
126-
end
127-
end
12876
end

0 commit comments

Comments
 (0)