Contar CIN2 y CIN3 como biopsia de alto grado previa

This commit is contained in:
2026-12-04 09:12:15 -06:00
parent daff410b46
commit 984d168da7
+1 -1
View File
@@ -160,7 +160,7 @@ def _history(events: pd.DataFrame, people: pd.Index) -> dict[str, pd.Series]:
rank = {grade: i for i, grade in enumerate(cacu.BIOPSY_SEVERITY)} rank = {grade: i for i, grade in enumerate(cacu.BIOPSY_SEVERITY)}
worst = of["biopsy"]["value_code"].map(rank).groupby(of["biopsy"]["person_id"]).max() worst = of["biopsy"]["value_code"].map(rank).groupby(of["biopsy"]["person_id"]).max()
worst = worst.reindex(people) worst = worst.reindex(people)
for name, grade in (("lsil_plus", "LSIL"), ("hsil_plus", "HSIL"), ("carcinoma", "carcinoma")): for name, grade in (("lsil_plus", "LSIL"), ("hsil_plus", "CIN2"), ("carcinoma", "carcinoma")):
columns[f"prior_biopsy_{name}"] = _flag(worst.notna(), worst >= rank[grade]) columns[f"prior_biopsy_{name}"] = _flag(worst.notna(), worst >= rank[grade])
persons = pd.Series(people, index=people) persons = pd.Series(people, index=people)