@@ -878,3 +878,81 @@ def test_rules_stop_behavior(rule_stop: bool, expected_reason_results: list[Rule
878878 contains_inanyorder (* [equal_to (result ) for result in expected_reason_results ]),
879879 test_comment ,
880880 )
881+
882+
883+ @pytest .mark .parametrize (
884+ ("person_cohorts" , "iteration_cohorts" , "expected_status" , "expected_cohorts" ),
885+ [
886+ (
887+ ["covid_cohort" , "flu_cohort" ],
888+ ["rsv_clinical_cohort" , "rsv_75_rolling" ],
889+ Status .not_eligible ,
890+ ["rsv_clinical_cohort" , "rsv_75_rolling" ],
891+ ),
892+ (
893+ ["rsv_clinical_cohort" , "rsv_75_rolling" ],
894+ ["rsv_clinical_cohort" , "rsv_75_rolling" ],
895+ Status .actionable ,
896+ ["rsv_clinical_cohort" ],
897+ ),
898+ (
899+ ["covid_cohort" , "rsv_75_rolling" ],
900+ ["rsv_clinical_cohort" , "rsv_75_rolling" ],
901+ Status .not_actionable ,
902+ ["rsv_75_rolling" ],
903+ ),
904+ (
905+ ["covid_cohort" , "rsv_clinical_cohort" ],
906+ ["rsv_clinical_cohort" , "rsv_75_rolling" ],
907+ Status .actionable ,
908+ ["rsv_clinical_cohort" ],
909+ ),
910+ (
911+ ["rsv_75to79_2024" , "rsv_75_rolling" ],
912+ ["rsv_75to79_2024" , "rsv_75_rolling" ],
913+ Status .not_actionable ,
914+ ["rsv_75_rolling" , "rsv_75to79_2024" ],
915+ ),
916+ ],
917+ )
918+ def test_eligibility_results_when_multiple_cohorts (
919+ person_cohorts : list [str ],
920+ iteration_cohorts : list [str ],
921+ expected_status : Status ,
922+ expected_cohorts : list [str ],
923+ faker : Faker ,
924+ ):
925+ # Given
926+ nhs_number = NHSNumber (faker .nhs_number ())
927+ dob_person_less_than_75 = DateOfBirth (faker .date_of_birth (minimum_age = 66 , maximum_age = 74 ))
928+
929+ person_rows = person_rows_builder (nhs_number , date_of_birth = dob_person_less_than_75 , cohorts = person_cohorts )
930+ campaign_configs = [
931+ rule_builder .CampaignConfigFactory .build (
932+ target = "RSV" ,
933+ iterations = [
934+ rule_builder .IterationFactory .build (
935+ iteration_cohorts = [
936+ rule_builder .IterationCohortFactory .build (cohort_label = cohorts ) for cohorts in iteration_cohorts
937+ ],
938+ iteration_rules = [
939+ rule_builder .PersonAgeSuppressionRuleFactory .build (cohort_label = "rsv_75_rolling" ),
940+ rule_builder .PersonAgeSuppressionRuleFactory .build (cohort_label = "rsv_75to79_2024" ),
941+ ],
942+ )
943+ ],
944+ )
945+ ]
946+
947+ calculator = EligibilityCalculator (person_rows , campaign_configs )
948+
949+ # When
950+ actual = calculator .evaluate_eligibility ()
951+
952+ # Then
953+ assert_that (
954+ actual ,
955+ is_eligibility_status ().with_conditions (
956+ has_items (is_condition ().with_condition_name (ConditionName ("RSV" )).and_status (expected_status ))
957+ ),
958+ )
0 commit comments