Skip to content

Commit 06e75ae

Browse files
authored
Merge pull request #6055 from nhsuk/already-vaccinated-activity-log
Already vaccinated activity log
2 parents 4fbec57 + 0bd4f2b commit 06e75ae

4 files changed

Lines changed: 67 additions & 6 deletions

File tree

app/components/app_activity_log_component.rb

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,19 +400,30 @@ def vaccination_events
400400
if vaccination_record.administered?
401401
if (vaccine = vaccination_record.vaccine)
402402
"Vaccinated with #{vaccine.brand}"
403+
elsif vaccination_record.sourced_from_manual_report? ||
404+
vaccination_record.sourced_from_historical_upload?
405+
"Historical vaccination record added"
403406
else
404407
"Vaccinated"
405408
end
406409
else
407410
"Vaccination not given: #{vaccination_record.human_enum_name(:outcome)}"
408411
end
409412

413+
subtitle =
414+
if historical_vaccination_event?(vaccination_record)
415+
"Record added #{vaccination_record.reported_at.to_fs(:long)}. " \
416+
"Vaccination given #{vaccination_record.performed_at.to_date.to_fs(:long)}."
417+
end
418+
at = historical_vaccination_event?(vaccination_record) ? vaccination_record.reported_at : vaccination_record.performed_at
419+
410420
kept = {
411421
title:,
412422
body: vaccination_record.notes,
413-
at: vaccination_record.performed_at,
423+
at:,
414424
by: vaccination_record.performed_by,
415-
programmes: [vaccination_record.programme]
425+
programmes: [vaccination_record.programme],
426+
subtitle:
416427
}
417428

418429
discarded =
@@ -428,6 +439,14 @@ def vaccination_events
428439
end
429440
end
430441

442+
def historical_vaccination_event?(vaccination_record)
443+
vaccination_record.reported_at.present? &&
444+
(
445+
vaccination_record.sourced_from_manual_report? ||
446+
vaccination_record.sourced_from_historical_upload?
447+
)
448+
end
449+
431450
def attendance_events
432451
attendance_records.map do |attendance_record|
433452
title =

app/components/app_log_event_component.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ def initialize(
3838
by: nil,
3939
programmes: [],
4040
invalidated: false,
41-
card: false
41+
card: false,
42+
subtitle: nil
4243
)
4344
@title = title
4445
@body = body
@@ -47,13 +48,14 @@ def initialize(
4748
@programmes = programmes
4849
@invalidated = invalidated
4950
@card = card
51+
@subtitle = subtitle
5052
end
5153

5254
private
5355

5456
attr_reader :title, :body, :programmes, :invalidated, :card
5557

5658
def subtitle
57-
safe_join([@at, @by].compact, " · ".html_safe)
59+
@subtitle || safe_join([@at, @by].compact, " · ".html_safe)
5860
end
5961
end

spec/components/app_activity_log_component_spec.rb

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,18 @@
168168
vaccine: programmes.first.vaccines.find_by!(upload_name: "Cervarix")
169169
)
170170

171+
create(
172+
:vaccination_record,
173+
programme: programmes.second,
174+
patient:,
175+
session:,
176+
performed_at: Date.new(2025, 1, 6),
177+
performed_by: nil,
178+
reported_at: Time.zone.local(2025, 2, 15, 14, 33, 23),
179+
source: :manual_report,
180+
vaccine: nil
181+
)
182+
171183
create(
172184
:notify_log_entry,
173185
:email,
@@ -189,7 +201,7 @@
189201
end
190202

191203
it "has cards" do
192-
expect(rendered).to have_css(".nhsuk-card", count: 11)
204+
expect(rendered).to have_css(".nhsuk-card", count: 12)
193205
end
194206

195207
include_examples "card",
@@ -207,6 +219,12 @@
207219
notes: "Some notes millisecond later",
208220
programme: "HPV"
209221

222+
include_examples "card",
223+
title: "Historical vaccination record added",
224+
date:
225+
"Record added 15 February 2025 at 2:33pm. Vaccination given 6 January 2025.",
226+
programme: "Flu"
227+
210228
include_examples "card",
211229
title: "Triaged decision: Safe to vaccinate",
212230
date: "30 May 2025 at 2:30pm",
@@ -538,6 +556,7 @@
538556
:vaccination_record,
539557
patient:,
540558
programme:,
559+
session:,
541560
performed_at: Time.zone.local(2025, 5, 31, 13)
542561
)
543562
end
@@ -554,6 +573,7 @@
554573
:vaccination_record,
555574
patient:,
556575
programme: programmes.first,
576+
session:,
557577
vaccine: nil,
558578
performed_at: Time.zone.local(2025, 5, 31, 13)
559579
)

spec/features/mmr_already_had_spec.rb

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@
6767
when_the_status_updater_runs
6868
and_i_navigate_to_the_patient_record
6969
then_i_see_that_the_vaccination_record_has_outcome_vaccinated
70+
71+
when_i_open_the_activity_log
72+
then_i_see_a_historical_vaccination_log_entry_for_mmr
73+
and_it_includes_the_programme_and_both_reported_and_performed_at_dates
7074
end
7175

7276
scenario "record a patient as already had their 1st MMR dose and then edit dates" do
@@ -416,10 +420,26 @@ def and_i_navigate_to_the_patient_record
416420
end
417421

418422
def then_i_see_that_the_vaccination_record_has_outcome_vaccinated
419-
expect(page).to have_content("Vaccination date #{@vaccination_date.strftime("%-d %B %Y")}")
423+
expect(page).to have_content(
424+
"Vaccination date #{@vaccination_date.strftime("%-d %B %Y")}"
425+
)
420426
expect(page).to have_content("Location Unknown")
421427
expect(page).to have_content("Programme MMR")
422428
expect(page).to have_content("Source Manual report")
423429
expect(page).to have_content("Outcome Vaccinated")
424430
end
431+
432+
def when_i_open_the_activity_log
433+
click_on "Activity log"
434+
end
435+
436+
def then_i_see_a_historical_vaccination_log_entry_for_mmr
437+
expect(page).to have_content("Historical vaccination record added")
438+
end
439+
440+
def and_it_includes_the_programme_and_both_reported_and_performed_at_dates
441+
expect(page).to have_content(
442+
"MMR Record added 1 July 2025 at 12:00am. Vaccination given #{@vaccination_date.strftime("%-d %B %Y")}."
443+
)
444+
end
425445
end

0 commit comments

Comments
 (0)