Skip to content

Commit f055dc3

Browse files
committed
Hide "Get a new consent response" button
This ensures that the button is hidden if no consent response is needed for this patient to prevent nurses from accidentally recording a consent response when not needed. Specifically this prevents a scenario that was found to be possible in testing, but wouldn't occur in reality where a patient already had consent from a parent and then the nurse could request consent from another parent which changed the status from consent given to consent conflicting. Jira-Issue: MAV-1591
1 parent 31555f1 commit f055dc3

3 files changed

Lines changed: 26 additions & 5 deletions

File tree

app/components/app_patient_session_consent_component.html.erb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@
2828
secondary: true %>
2929
<% end %>
3030

31-
<%= govuk_button_to "Record a new consent response",
32-
session_patient_programme_consents_path(
33-
session, patient, programme
34-
),
35-
secondary: true %>
31+
<% if can_record_new_response? %>
32+
<%= govuk_button_to "Record a new consent response",
33+
session_patient_programme_consents_path(
34+
session, patient, programme
35+
),
36+
secondary: true %>
37+
<% end %>
3638
</div>
3739

3840
<%= render AppGillickAssessmentComponent.new(patient_session:, programme:) %>

app/components/app_patient_session_consent_component.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ def consents
4141
.order(created_at: :desc)
4242
end
4343

44+
def gillick_assessment
45+
@gillick_assessment ||=
46+
patient_session
47+
.gillick_assessments
48+
.order(created_at: :desc)
49+
.find_by(programme:)
50+
end
51+
4452
def consent_status
4553
@consent_status ||= patient.consent_status(programme:)
4654
end
@@ -54,6 +62,10 @@ def can_send_consent_request?
5462
session.open_for_consent? && patient.parents.any?
5563
end
5664

65+
def can_record_new_response?
66+
!consent_status.given? || gillick_assessment&.gillick_competent?
67+
end
68+
5769
def grouped_consents
5870
@grouped_consents ||= ConsentGrouper.call(consents, programme:)
5971
end

spec/components/app_patient_session_consent_component_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,12 @@
5858

5959
it { should have_css(".app-card--aqua-green", text: "Consent given") }
6060
it { should_not have_css("a", text: "Contact #{consent.parent.full_name}") }
61+
it { should_not have_css("button", text: "Record a new consent response") }
62+
63+
context "when patient is Gillick competent" do
64+
before { create(:gillick_assessment, :competent, patient_session:) }
65+
66+
it { should have_css("button", text: "Record a new consent response") }
67+
end
6168
end
6269
end

0 commit comments

Comments
 (0)