Guardar la deserción de cada cohorte CaCu junto al modelo entrenado
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
"""Attrition of a CaCu cohort: candidates, eligible, pending and reasons, each counted once."""
|
||||
|
||||
from datetime import date
|
||||
|
||||
import pandas as pd
|
||||
|
||||
from models.cacu import reports
|
||||
|
||||
|
||||
def test_a_candidate_with_two_reasons_is_excluded_once():
|
||||
"""Pins the totals, the pending rule, the people without a candidate and the as-of cut."""
|
||||
rows = pd.DataFrame(
|
||||
[
|
||||
("eligible", "2025-01-01", None, None),
|
||||
("two", "2025-01-01", None, "hysterectomy"),
|
||||
("two", "2025-01-01", None, "under_18"),
|
||||
("waiting", "2025-01-01", None, "no_index_result"),
|
||||
("waiting_and_out", "2025-01-01", None, "no_index_result"),
|
||||
("waiting_and_out", "2025-01-01", None, "prior_outcome"),
|
||||
("after", "2025-07-01", None, "hysterectomy"),
|
||||
],
|
||||
columns=["person_id", "index_date", "index_sample_id", "criterion"],
|
||||
)
|
||||
|
||||
found = reports.attrition("cacu_cohort_surveillance", rows, 10, date(2025, 6, 30))
|
||||
|
||||
assert (found["candidates"], found["eligible"], found["excluded"]) == (4, 1, 3)
|
||||
assert (found["pending"], found["without_candidate"]) == (1, 6)
|
||||
assert found["by_reason"] == {
|
||||
"hysterectomy": 1, "no_index_result": 2, "prior_outcome": 1, "under_18": 1,
|
||||
} # fmt: skip
|
||||
Reference in New Issue
Block a user