Skip to content

Commit 4da1abf

Browse files
committed
wip
1 parent 200fc0f commit 4da1abf

10 files changed

+110
-156
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<%= render AppCardComponent.new do |card| %>
2+
<% card.with_heading { "Consent" } %>
3+
4+
<% if patient.consent_outcome.none?(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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

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

77
@patient_session = patient_session

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

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

66
let(:component) do

spec/components/previews/app_consent_component_preview.rb

Lines changed: 0 additions & 69 deletions
This file was deleted.

0 commit comments

Comments
 (0)