Skip to content

Commit f95b900

Browse files
committed
Improve ActivityLog for followed-up consents
If a consent has been followed-up we improve the activity log entry to show the outcome of the follow-up. We also send a refusal confirmation email is refusal is confirmed which shows on the activity log too.
1 parent 5fc592b commit f95b900

3 files changed

Lines changed: 96 additions & 3 deletions

File tree

app/components/app_activity_log_component.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def consent_events
219219
original_response =
220220
if consent.withdrawn?
221221
"given"
222-
elsif consent.follow_up_requested?
222+
elsif consent.follow_up_requested? || consent.follow_up_resolved?
223223
"follow_up_requested"
224224
else
225225
consent.response
@@ -259,7 +259,7 @@ def consent_events
259259
}
260260
end
261261

262-
if consent.invalidated?
262+
if consent.invalidated? && !consent.follow_up_resolved?
263263
events << {
264264
title: "Consent from #{consent.name} invalidated",
265265
at: consent.invalidated_at,
@@ -275,6 +275,16 @@ def consent_events
275275
}
276276
end
277277

278+
if consent.follow_up_resolved?
279+
events << {
280+
title:
281+
"Consent response from #{consent.name} (#{consent.who_responded.downcase_first}) " \
282+
"followed-up: refusal #{consent.follow_up_outcome}",
283+
at: consent.follow_up_resolved_at,
284+
programmes: [consent.programme]
285+
}
286+
end
287+
278288
events
279289
end
280290
end

app/controllers/patient_sessions/consents_controller.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ def update_confirm_refusal
101101
)
102102
end
103103

104+
@consent.notifier.send_confirmation(
105+
session: @session,
106+
triage: nil,
107+
sent_by: current_user
108+
)
109+
104110
redirect_to session_patient_programme_consent_path,
105111
flash: {
106112
success: "Consent from #{@consent.name} updated."
@@ -163,7 +169,7 @@ def set_consent
163169
@patient
164170
.consents
165171
.where(academic_year: @session.academic_year)
166-
.includes(:consent_form, :parent, patient: :parent_relationships)
172+
.includes(:consent_form, :parent, :team, patient: :parent_relationships)
167173
.find(params[:id])
168174
end
169175

spec/components/app_activity_log_component_spec.rb

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,83 @@
544544
programme: "HPV"
545545
end
546546

547+
describe "follow-up resolved consent (confirmed)" do
548+
before do
549+
create(
550+
:consent,
551+
:follow_up_requested,
552+
follow_up_requested: false,
553+
follow_up_outcome: "confirmed",
554+
follow_up_resolved_at: Time.zone.local(2025, 6, 30, 12),
555+
programme: programmes.first,
556+
patient:,
557+
parent: mum,
558+
submitted_at: Time.zone.local(2025, 5, 30, 12)
559+
)
560+
end
561+
562+
include_examples "card",
563+
title: "Follow-up requested by Jane Doe (mum)",
564+
date: "30 May 2025 at 12:00pm",
565+
programme: "HPV"
566+
567+
include_examples "card",
568+
title:
569+
"Consent response from Jane Doe (mum) followed-up: " \
570+
"refusal confirmed",
571+
date: "30 June 2025 at 12:00pm",
572+
programme: "HPV"
573+
end
574+
575+
describe "follow-up resolved consent (withdrawn)" do
576+
before do
577+
create(
578+
:consent,
579+
:follow_up_requested,
580+
follow_up_outcome: "withdrawn",
581+
follow_up_resolved_at: Time.zone.local(2025, 6, 30, 12),
582+
invalidated_at: Time.zone.local(2025, 6, 30, 12),
583+
notes: "Consent given in follow-up discussion.",
584+
programme: programmes.first,
585+
patient:,
586+
parent: mum,
587+
submitted_at: Time.zone.local(2025, 5, 30, 12)
588+
)
589+
create(
590+
:consent,
591+
:given_verbally,
592+
programme: programmes.first,
593+
patient:,
594+
parent: mum,
595+
submitted_at: Time.zone.local(2025, 6, 30, 13)
596+
)
597+
end
598+
599+
include_examples "card",
600+
title: "Follow-up requested",
601+
date: "30 May 2025 at 12:00pm",
602+
programme: "HPV"
603+
604+
include_examples "card",
605+
title:
606+
"Consent response from Jane Doe (mum) followed-up: " \
607+
"refusal withdrawn",
608+
date: "30 June 2025 at 12:00pm",
609+
programme: "HPV"
610+
611+
include_examples "card",
612+
title: "Consent given by Jane Doe (mum)",
613+
date: "30 June 2025 at 1:00pm",
614+
programme: "HPV"
615+
616+
it "does not render an 'invalidated' card for the old consent" do
617+
expect(rendered).not_to have_css(
618+
".app-timeline__header",
619+
text: "Consent from Jane Doe invalidated"
620+
)
621+
end
622+
end
623+
547624
describe "gillick assessments" do
548625
let(:programmes) { [Programme.td_ipv] }
549626

0 commit comments

Comments
 (0)