Skip to content

Commit 7ca4c87

Browse files
committed
Add PSDs to activity log
This adds entries to the activity log when PSDs are attached to patients allowing a clear audit log.
1 parent c611700 commit 7ca4c87

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

app/components/app_activity_log_component.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ def all_events
9494
gillick_assessment_events,
9595
note_events,
9696
notify_events,
97+
patient_specific_direction_events,
9798
pre_screening_events,
9899
session_events,
99100
triage_events,
@@ -278,6 +279,29 @@ def notify_events
278279
end
279280
end
280281

282+
def patient_specific_direction_events
283+
patient_specific_directions.flat_map do |patient_specific_direction|
284+
events = []
285+
286+
events << {
287+
title: "PSD added",
288+
at: patient_specific_direction.created_at,
289+
by: patient_specific_direction.created_by,
290+
programmes: programmes_for(patient_specific_direction)
291+
}
292+
293+
if patient_specific_direction.invalidated?
294+
events << {
295+
title: "PSD invalidated",
296+
at: patient_specific_direction.invalidated_at,
297+
programmes: programmes_for(patient_specific_direction)
298+
}
299+
end
300+
301+
events
302+
end
303+
end
304+
281305
def pre_screening_events
282306
pre_screenings.map do |pre_screening|
283307
{

spec/components/app_activity_log_component_spec.rb

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,40 @@
256256
programme: "HPV"
257257
end
258258

259+
describe "patient specific directions" do
260+
before do
261+
create(
262+
:patient_specific_direction,
263+
created_at: Time.zone.local(2024, 6, 1, 12),
264+
created_by: user,
265+
patient:,
266+
programme: programmes.second,
267+
team:
268+
)
269+
270+
create(
271+
:patient_specific_direction,
272+
created_at: Time.zone.local(2024, 6, 1, 10),
273+
invalidated_at: Time.zone.local(2024, 6, 1, 11),
274+
created_by: user,
275+
patient:,
276+
programme: programmes.second,
277+
team:
278+
)
279+
end
280+
281+
include_examples "card",
282+
title: "PSD added",
283+
date: "1 June 2024 at 12:00pm",
284+
by: "JOY, Nurse",
285+
programme: "Flu"
286+
287+
include_examples "card",
288+
title: "PSD invalidated",
289+
date: "1 June 2024 at 11:00am",
290+
programme: "Flu"
291+
end
292+
259293
describe "vaccination not administered" do
260294
before do
261295
create(

0 commit comments

Comments
 (0)