Skip to content

Commit 611d588

Browse files
Merge pull request #3786 from nhsuk/hide-previous-years-vaccination-records
MAV-1359 Hide previous years seasonal vaccinations
2 parents c512810 + df1c62b commit 611d588

4 files changed

Lines changed: 21 additions & 2 deletions

File tree

app/components/app_patient_vaccination_table_component.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@ def vaccination_records
2121
.then { programme ? it.where(programme:) : it }
2222
.includes(:location, :programme)
2323
.order(performed_at: :desc)
24+
.select(&:show_this_academic_year?)
2425
end
2526
end

app/lib/vaccinated_criteria.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def call
1111
vaccination_records_for_programme =
1212
vaccination_records.select { it.programme_id == programme.id }
1313

14-
if programme.flu?
14+
if programme.seasonal?
1515
vaccination_records_for_programme
1616
.select { it.administered? || it.already_had? }
1717
.any?(&:performed_this_academic_year?)

app/models/vaccination_record.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ def performed_this_academic_year?
179179
academic_year == Date.current.academic_year
180180
end
181181

182+
def show_this_academic_year?
183+
programme.seasonal? ? performed_this_academic_year? : true
184+
end
185+
182186
private
183187

184188
def requires_location_name?

spec/components/app_patient_vaccination_table_component_spec.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
let(:vaccination_record_programme) { create(:programme, :hpv) }
2626

27+
let(:performed_at) { Time.zone.local(2024, 1, 1) }
28+
2729
before do
2830
create(
2931
:vaccination_record,
@@ -35,7 +37,7 @@
3537
programmes: [vaccination_record_programme]
3638
),
3739
programme: vaccination_record_programme,
38-
performed_at: Time.zone.local(2024, 1, 1)
40+
performed_at:
3941
)
4042
end
4143

@@ -61,5 +63,17 @@
6163
it { should_not have_content("Vaccinated") }
6264
it { should_not have_content("HPV") }
6365
end
66+
67+
context "with a Flu vaccination record from a previous year" do
68+
let(:vaccination_record_programme) { create(:programme, :flu) }
69+
let(:programme) { vaccination_record_programme }
70+
let(:performed_at) { Time.zone.local(2022, 1, 1) }
71+
72+
it { should_not have_link("1 January 2022") }
73+
it { should_not have_content("Test School") }
74+
it { should_not have_content("Waterloo Road, London, SE1 8TY") }
75+
it { should_not have_content("Vaccinated") }
76+
it { should_not have_content("Flu") }
77+
end
6478
end
6579
end

0 commit comments

Comments
 (0)