File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments