Skip to content

Commit 422a5e4

Browse files
committed
Update Consent and Triage cards on patient-session page
We no longer show the coloured heading with consent/triage status, and we now use the new AppActionLinkComponent instaed of buttons for actions like recording a new response
1 parent 791e652 commit 422a5e4

40 files changed

Lines changed: 82 additions & 117 deletions

File tree

app/components/app_patient_session_consent_component.html.erb

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
<h3 class="nhsuk-heading-m">Consent</h3>
2-
3-
<%= render AppCardComponent.new(feature: true) do |card| %>
4-
<% card.with_heading(level: 4, colour:) { heading } %>
1+
<%= render AppCardComponent.new(section: true) do |card| %>
2+
<% card.with_heading(level: 2) { heading } %>
53

64
<% unless programme_status.vaccinated? %>
75
<% if consent_status_value == :no_response %>
@@ -27,21 +25,21 @@
2725
<p>A consent request will be sent on <%= session.send_consent_requests_at.to_fs(:long) %>.</p>
2826
<% end %>
2927

30-
<div class="nhsuk-button-group">
31-
<% if can_send_consent_request? %>
28+
<%= render AppActionLinkComponent.new(
29+
text: "Record a new consent response",
30+
href: new_session_patient_programme_consent_path(session, patient, programme),
31+
) %>
32+
33+
<% if can_send_consent_request? %>
34+
<div>
3235
<%= govuk_button_to "Send consent request",
3336
send_request_session_patient_programme_consents_path(
3437
session, patient, programme
3538
),
3639
secondary: true %>
37-
<% end %>
40+
</div>
41+
<% end %>
3842

39-
<%= govuk_button_to "Record a new consent response",
40-
session_patient_programme_consents_path(
41-
session, patient, programme
42-
),
43-
secondary: true %>
44-
</div>
4543
<% end %>
4644

4745
<% if consents.any? %>

app/components/app_patient_session_consent_component.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,8 @@ def initialize(patient:, session:, programme:)
1818

1919
def programme_type = programme.type
2020

21-
def colour
22-
I18n.t(consent_status_value, scope: %i[status consent colour])
23-
end
24-
2521
def heading
26-
status_text = I18n.t(consent_status_value, scope: %i[status consent label])
27-
"#{consent_status_generator.programme.name}: #{status_text}"
22+
"Consent for #{consent_status_generator.programme.name} vaccination"
2823
end
2924

3025
def consent_status_value

app/components/app_patient_session_triage_component.html.erb

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
1-
<h3 class="nhsuk-heading-m">Triage</h3>
2-
3-
<%= render AppCardComponent.new(feature: true) do |card| %>
4-
<% card.with_heading(level: 4, colour:) { heading } %>
1+
<%= render AppCardComponent.new(section: true) do |card| %>
2+
<% card.with_heading(level: 2) { heading } %>
53

64
<% if triage_status_value == :not_required %>
75
<p>No triage is needed for <%= patient.full_name %>.</p>
86

9-
<div class="nhsuk-button-group">
10-
<% if helpers.policy(Triage).new? %>
11-
<%= govuk_button_link_to "Update triage outcome",
12-
new_session_patient_programme_triages_path(session, patient, programme),
13-
secondary: true %>
14-
<% end %>
15-
</div>
7+
<% if helpers.policy(Triage).new? %>
8+
<%= render AppActionLinkComponent.new(text: "Update triage outcome",
9+
href: new_session_patient_programme_triages_path(session, patient, programme)) %>
10+
<% end %>
1611
<% elsif latest_triage.nil? || latest_triage.keep_in_triage? %>
1712
<% if helpers.policy(Triage).new? %>
18-
<p>You need to decide if <%= patient.full_name %> is safe to vaccinate.</p>
13+
<p>You need to decide if <%= patient.given_name %> is safe to vaccinate.</p>
1914

2015
<% if triage_status_generator.vaccination_history_requires_triage? %>
2116
<p>Incomplete vaccination history for <%= programme.name_in_sentence %>. Check if the child needs another dose.</p>
@@ -33,13 +28,10 @@
3328
<p><%= summary %></p>
3429
<% end %>
3530

36-
<div class="nhsuk-button-group">
37-
<% if helpers.policy(Triage).new? %>
38-
<%= govuk_button_link_to "Update triage outcome",
39-
new_session_patient_programme_triages_path(session, patient, programme),
40-
secondary: true %>
41-
<% end %>
42-
</div>
31+
<% if helpers.policy(Triage).new? %>
32+
<%= render AppActionLinkComponent.new(text: "Update triage outcome",
33+
href: new_session_patient_programme_triages_path(session, patient, programme)) %>
34+
<% end %>
4335
<% end %>
4436

4537
<%= render AppTriageTableComponent.new(patient:, session:, programme:) %>

app/components/app_patient_session_triage_component.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,8 @@ def render?
4444

4545
def programme_type = programme.type
4646

47-
def colour
48-
I18n.t(triage_status_value, scope: %i[status triage colour])
49-
end
50-
5147
def heading
52-
status_text = I18n.t(triage_status_value, scope: %i[status triage label])
53-
"#{triage_status_generator.programme.name}: #{status_text}"
48+
"Triage for #{triage_status_generator.programme.name} vaccination"
5449
end
5550

5651
def triage_status_value

app/components/app_triage_form_component.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,12 @@ def fieldset_options
4444
end
4545
end
4646

47+
legend = { text:, size: "m", classes: "nhsuk-u-font-size-22" }
48+
4749
if heading
48-
{ legend: { text:, tag: :h2 }, hint: { text: hint } }
50+
{ legend: legend.merge(tag: :h2), hint: { text: hint } }
4951
else
50-
{ legend: { text: }, hint: { text: hint } }
52+
{ legend:, hint: { text: hint } }
5153
end
5254
end
5355

app/controllers/patient_sessions/consents_controller.rb

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

33
class PatientSessions::ConsentsController < PatientSessions::BaseController
4-
before_action :set_consent, except: %i[create send_request]
4+
before_action :set_consent, except: %i[new send_request]
55
before_action :set_consent_follow_up_form,
66
only: %i[edit_follow_up update_follow_up]
77
before_action :set_consent_confirm_refusal_form,
@@ -17,21 +17,16 @@ class PatientSessions::ConsentsController < PatientSessions::BaseController
1717
before_action :ensure_can_invalidate,
1818
only: %i[edit_invalidate update_invalidate]
1919

20-
def create
20+
def new
2121
authorize Consent
2222

2323
@draft_consent = DraftConsent.new(request_session: session, current_user:)
2424

2525
@draft_consent.clear_attributes
2626
@draft_consent.assign_attributes(create_params)
27+
@draft_consent.save!
2728

28-
if @draft_consent.save
29-
redirect_to draft_consent_path(Wicked::FIRST_STEP)
30-
else
31-
render "patient_sessions/programmes/show",
32-
layout: "full",
33-
status: :unprocessable_content
34-
end
29+
redirect_to draft_consent_path(Wicked::FIRST_STEP)
3530
end
3631

3732
def send_request

config/routes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@
312312
resources :programmes, path: "", param: :type, only: :show do
313313
get "record-already-vaccinated"
314314

315-
resources :consents, only: %i[index create show] do
315+
resources :consents, only: %i[index new show] do
316316
post "send-request", on: :collection, action: :send_request
317317

318318
member do

spec/components/app_patient_session_consent_component_spec.rb

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
it { should_not have_css("details", text: /Consent (given|refused) by/) }
1717
it { should_not have_css("details", text: "Responses to health questions") }
1818
it { should have_css("p", text: "No consent request is scheduled") }
19-
it { should have_css("button", text: "Record a new consent response") }
19+
it { should have_link("Record a new consent response") }
2020
end
2121

2222
context "when vaccinated" do
@@ -25,7 +25,7 @@
2525
end
2626

2727
it { should_not have_css("p", text: "No requests have been sent.") }
28-
it { should_not have_css("button", text: "Record a new consent response") }
28+
it { should_not have_link("Record a new consent response") }
2929
end
3030

3131
context "with refused consent" do
@@ -34,7 +34,7 @@
3434
create(:consent, :refused, patient: patient.reload, parent:, programme:)
3535
end
3636

37-
it { should have_css(".app-card__heading--red", text: "Consent refused") }
37+
it { should have_content("refused to give consent") }
3838
it { should have_content(consent.parent.full_name) }
3939
it { should have_content(consent.parent_relationship.label) }
4040
it { should have_content("Consent refused") }
@@ -48,12 +48,7 @@
4848

4949
let(:consent) { patient.consents.first }
5050

51-
it do
52-
expect(rendered).to have_css(
53-
".app-card__heading--green",
54-
text: "Consent given"
55-
)
56-
end
51+
it { should have_text("is ready for the vaccinator") }
5752

5853
it { should_not have_css("a", text: "Contact #{consent.parent.full_name}") }
5954

@@ -64,7 +59,7 @@
6459
create(:patient, :consent_given_nasal_only_triage_not_needed, session:)
6560
end
6661

67-
it { should have_text("Consent given for nasal spray") }
62+
it { should have_text("Nasal spray only") }
6863

6964
context "and the vaccine method is overridden by triage" do
7065
let(:patient) do
@@ -75,7 +70,7 @@
7570
)
7671
end
7772

78-
it { should have_text("Consent given for injection") }
73+
it { should have_text("is ready for the vaccinator") }
7974
end
8075
end
8176
end

spec/components/app_patient_session_triage_component_spec.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,13 @@
3030
context "when triaged as safe to vaccinate" do
3131
before { create(:triage, :safe_to_vaccinate, patient:, programme:) }
3232

33-
it do
34-
expect(rendered).to have_css(
35-
".app-card__heading--green",
36-
text: "Safe to vaccinate"
37-
)
38-
end
39-
4033
it { should have_content("safe to vaccinate") }
4134
it { should have_link("Update triage outcome") }
4235
end
4336

4437
context "when triaged as unsafe to vaccinate" do
4538
before { create(:triage, :do_not_vaccinate, patient:, programme:) }
4639

47-
it { should have_css(".app-card__heading--red", text: "Do not vaccinate") }
4840
it { should have_content("should not be vaccinated") }
4941
it { should have_link("Update triage outcome") }
5042
end

spec/features/community_clinic_vaccination_session_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def when_i_record_a_non_administered_vaccination_with_reason
3737
visit session_record_path(@session)
3838
click_link @patient.full_name
3939

40-
within all("form")[3] do
40+
within all("form")[2] do
4141
within all("fieldset")[2] do
4242
choose "No"
4343
end

0 commit comments

Comments
 (0)