Skip to content

Commit 2651014

Browse files
authored
Merge pull request #6532 from NHSDigital/MAV-5902-side-effects-from-discontinued-vaccines
Exclude discontinued vaccines from side-effects in comms
2 parents da5eb9c + 780e9f1 commit 2651014

3 files changed

Lines changed: 62 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: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,66 @@
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
870+
end
871+
872+
context "with a vaccination record" do
873+
let(:vaccination_record) do
874+
create(
875+
:vaccination_record,
876+
patient:,
877+
programme: hpv_programme,
878+
session:
879+
)
880+
end
881+
882+
it do
883+
expect(personalisation).to have_attributes(
884+
vaccine_side_effects:
885+
"- generally feeling unwell\n- swelling or pain where the injection was given"
886+
)
887+
end
888+
end
889+
890+
context "without a patient" do
891+
let(:patient) { nil }
892+
let(:vaccination_record) { nil }
893+
894+
it do
895+
expect(personalisation).to have_attributes(
896+
vaccine_side_effects:
897+
"- generally feeling unwell\n- swelling or pain where the injection was given"
898+
)
899+
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
855915
end
856916
end
857917

0 commit comments

Comments
 (0)