Skip to content

Commit 56df2b6

Browse files
committed
Merge pull request #3787 from nhsuk/hide-consent-if-vaccinated
Hide consent subtitle and buttons if vaccinated
2 parents 2a60a22 + 20ad852 commit 56df2b6

3 files changed

Lines changed: 43 additions & 28 deletions

File tree

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,40 @@
11
<%= render AppCardComponent.new(colour:) do |card| %>
22
<% card.with_heading { heading } %>
33

4-
<% if consent_status.no_response? %>
5-
<% if latest_consent_request %>
6-
<p>No-one responded to our requests for consent.</p>
7-
<p>A request was sent on <%= latest_consent_request.sent_at.to_fs(:long) %>.</p>
8-
<% else %>
9-
<p>No requests have been sent.</p>
4+
<% unless vaccination_status.vaccinated? %>
5+
<% if consent_status.no_response? %>
6+
<% if latest_consent_request %>
7+
<p>No-one responded to our requests for consent.</p>
8+
<p>A request was sent on <%= latest_consent_request.sent_at.to_fs(:long) %>.</p>
9+
<% else %>
10+
<p>No requests have been sent.</p>
11+
<% end %>
12+
<% elsif consent_status.conflicts? %>
13+
<p>You can only vaccinate if all respondents give consent.</p>
14+
<% elsif consent_status.refused? %>
15+
<p><%= who_refused %> refused to give consent.</p>
16+
<% elsif consent_status.given? %>
17+
<p><%= patient.full_name %> is ready for the vaccinator.</p>
1018
<% end %>
11-
<% elsif consent_status.conflicts? %>
12-
<p>You can only vaccinate if all respondents give consent.</p>
13-
<% elsif consent_status.refused? %>
14-
<p><%= who_refused %> refused to give consent.</p>
15-
<% elsif consent_status.given? %>
16-
<p><%= patient.full_name %> is ready for the vaccinator.</p>
17-
<% end %>
1819

19-
<div class="app-button-group nhsuk-u-margin-bottom-4">
20-
<% if can_send_consent_request? %>
21-
<%= govuk_button_to "Send consent request",
22-
send_request_session_patient_programme_consents_path(
20+
<div class="app-button-group nhsuk-u-margin-bottom-4">
21+
<% if can_send_consent_request? %>
22+
<%= govuk_button_to "Send consent request",
23+
send_request_session_patient_programme_consents_path(
24+
session, patient, programme
25+
),
26+
secondary: true %>
27+
<% end %>
28+
29+
<%= govuk_button_to "Get verbal consent",
30+
session_patient_programme_consents_path(
2331
session, patient, programme
2432
),
2533
secondary: true %>
26-
<% end %>
34+
</div>
2735

28-
<%= govuk_button_to "Get verbal consent",
29-
session_patient_programme_consents_path(
30-
session, patient, programme
31-
),
32-
secondary: true %>
33-
</div>
34-
35-
<%= render AppGillickAssessmentComponent.new(patient_session:, programme:) %>
36+
<%= render AppGillickAssessmentComponent.new(patient_session:, programme:) %>
37+
<% end %>
3638

3739
<%= render AppConsentTableComponent.new(patient_session:, programme:) %>
3840
<% end %>

app/components/app_consent_card_component.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ def latest_consent_request
3131
end
3232

3333
def consent_status
34-
@consent_status ||=
35-
patient.consent_statuses.find_or_initialize_by(programme:)
34+
@consent_status ||= patient.consent_status(programme:)
35+
end
36+
37+
def vaccination_status
38+
@vaccination_status ||= patient.vaccination_status(programme:)
3639
end
3740

3841
def can_send_consent_request?

spec/components/app_consent_card_component_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@
2929
end
3030
end
3131

32+
context "when vaccinated" do
33+
before do
34+
create(:patient_vaccination_status, :vaccinated, patient:, programme:)
35+
end
36+
37+
it { should_not have_css("p", text: "No requests have been sent.") }
38+
it { should_not have_css("button", text: "Get verbal consent") }
39+
it { should_not have_css("button", text: "Assess Gillick competence") }
40+
end
41+
3242
context "with refused consent" do
3343
let!(:consent) { create(:consent, :refused, patient:, programme:) }
3444

0 commit comments

Comments
 (0)