Aplicar la exclusión por histerectomía al seleccionar la citología
This commit is contained in:
@@ -115,6 +115,13 @@ def last_screening_cytology(events: pd.DataFrame) -> pd.Series:
|
||||
key = ["person_id", "source_table", "source_id"]
|
||||
samples = events.loc[(events["type"] == "cytology") & ~events["person_id"].isin(referred),
|
||||
[*key, "date"]] # fmt: skip
|
||||
hysterectomy = events.loc[
|
||||
(events["source_table"] == "cervical_cytology")
|
||||
& (events["type"] == "gynecologic_condition")
|
||||
& (events["value_code"] == "hysterectomy")
|
||||
].groupby("person_id")["date"].min()
|
||||
recorded = samples["person_id"].map(hysterectomy)
|
||||
samples = samples[recorded.isna() | (samples["date"] < recorded)]
|
||||
results = events[events["type"].isin(RESULTS) & events["value_code"].notna()]
|
||||
has = results.pivot_table(index=key, columns="type", values="value_code", aggfunc="first")
|
||||
has = has.reindex(columns=list(RESULTS))
|
||||
|
||||
Reference in New Issue
Block a user