Skip to content

Commit 0925a7b

Browse files
Addressed magic cohorts
1 parent 4b0089e commit 0925a7b

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

src/eligibility_signposting_api/services/calculators/eligibility_calculator.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ def evaluate_eligibility(self) -> eligibility.EligibilityStatus:
104104
}.values()
105105

106106
for cohort in sorted(active_iteration.iteration_cohorts, key=priority_getter):
107-
# Check base Eligibility
108-
if cohort.cohort_label in self.person_cohorts:
107+
# Check Base Eligibility
108+
if cohort.cohort_label in self.person_cohorts or cohort.cohort_label == magic_cohort:
109109
# Base eligible
110110
# Check Eligibility - F - Rules
111111
eligibility_flag: bool = True
@@ -117,7 +117,8 @@ def evaluate_eligibility(self) -> eligibility.EligibilityStatus:
117117
cohort_results[cohort.cohort_label] = CohortStatus(cohort, status, group_exclusions)
118118
eligibility_flag = False
119119
break
120-
120+
# Eligible
121+
# Check Actionable(ity) - S - Rules
121122
if eligibility_flag:
122123
actionable_flag: bool = True
123124
for _, rule_group in groupby(

tests/unit/services/calculators/test_eligibility_calculator.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@ def test_not_base_eligible(faker: Faker):
4646
)
4747

4848

49-
@pytest.mark.skip(reason="This test is temporarily ignored. Reason : magic cohort")
5049
@pytest.mark.parametrize(
51-
("person_cohorts", "iteration_cohorts", "test_comment"),
50+
("person_cohorts", "iteration_cohorts", "status", "test_comment"),
5251
[
53-
(["cohort1"], ["elid_all_people"], "Only magic cohort present"),
54-
(["cohort1"], ["elid_all_people", "cohort1"], "Magic cohort with other cohorts"),
55-
([], ["elid_all_people"], "Only magic cohort present without "),
52+
(["cohort1"], ["elid_all_people"], Status.actionable, "Only magic cohort present"),
53+
(["cohort1"], ["elid_all_people", "cohort1"], Status.actionable, "Magic cohort with other cohorts"),
54+
(["cohort1"], ["cohort2"], Status.not_eligible, "No magic cohort. No matching person cohort"),
55+
([], ["elid_all_people"], Status.actionable, "No person cohorts. Only magic cohort present"),
5656
],
5757
)
5858
def test_base_eligible_with_when_magic_cohort_is_present(
59-
faker: Faker, person_cohorts: list[str], iteration_cohorts: list[str], test_comment: str
59+
faker: Faker, person_cohorts: list[str], iteration_cohorts: list[str], status: Status, test_comment: str
6060
):
6161
# Given
6262
nhs_number = NHSNumber(faker.nhs_number())
@@ -86,7 +86,7 @@ def test_base_eligible_with_when_magic_cohort_is_present(
8686
assert_that(
8787
actual,
8888
is_eligibility_status().with_conditions(
89-
has_item(is_condition().with_condition_name(ConditionName("RSV")).and_status(Status.actionable))
89+
has_item(is_condition().with_condition_name(ConditionName("RSV")).and_status(status))
9090
),
9191
test_comment,
9292
)

0 commit comments

Comments
 (0)