Skip to content

Commit 780e9f1

Browse files
committed
Exclude discontinued vaccines from side-effects in comms
vaccine_side_effects was including side effects from discontinued vaccines when building the union across a programme's vaccines. Filter with .active in both VaccineCriteria#side_effects and the no-patient fallback in GovukNotifyPersonalisation. Jira-Issue: MAV-5902
1 parent 67247c0 commit 780e9f1

3 files changed

Lines changed: 32 additions & 1 deletion

File tree

app/lib/govuk_notify_personalisation.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ def vaccine_side_effects
478478
patient.vaccine_criteria(programme:, academic_year:).side_effects
479479
end
480480
else
481-
Vaccine.for_programmes(programmes).flat_map(&:side_effects)
481+
Vaccine.for_programmes(programmes).active.flat_map(&:side_effects)
482482
end
483483
end
484484

app/lib/vaccine_criteria.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def primary_method
4646
def side_effects
4747
Vaccine
4848
.for_programme(programme)
49+
.active
4950
.where(method: primary_method)
5051
.flat_map(&:side_effects)
5152
end

spec/lib/govuk_notify_personalisation_spec.rb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,21 @@
852852
"- generally feeling unwell\n- swelling or pain where the injection was given"
853853
)
854854
end
855+
856+
context "when a vaccine is discontinued" do
857+
before do
858+
Vaccine
859+
.for_programme(hpv_programme)
860+
.first
861+
.update!(discontinued: true, side_effects: %w[headache])
862+
end
863+
864+
it "excludes side effects from the discontinued vaccine" do
865+
expect(personalisation).not_to have_attributes(
866+
vaccine_side_effects: a_string_matching("headache")
867+
)
868+
end
869+
end
855870
end
856871

857872
context "with a vaccination record" do
@@ -882,6 +897,21 @@
882897
"- generally feeling unwell\n- swelling or pain where the injection was given"
883898
)
884899
end
900+
901+
context "when a vaccine is discontinued" do
902+
before do
903+
Vaccine
904+
.for_programme(hpv_programme)
905+
.first
906+
.update!(discontinued: true, side_effects: %w[headache])
907+
end
908+
909+
it "excludes side effects from the discontinued vaccine" do
910+
expect(personalisation).not_to have_attributes(
911+
vaccine_side_effects: a_string_matching("headache")
912+
)
913+
end
914+
end
885915
end
886916
end
887917

0 commit comments

Comments
 (0)