60 lines
2.9 KiB
Python
60 lines
2.9 KiB
Python
"""TEA's measures (`core.measures` evaluates them), over gold's screening chain: one row per
|
|
child of the cohort (`gold.tea_screening`) with the day she reached each step, and her EEGs
|
|
(`gold.tea_eegs`).
|
|
|
|
A child is on the books from her first M-CHAT until the period after her chain ended with a
|
|
good EEG; in a period she is in the latest step, and diagnosis state, reached by its end."""
|
|
|
|
from core.measures import (
|
|
AtEnd,
|
|
Composition,
|
|
Measure,
|
|
StatusComposition,
|
|
StatusDuration,
|
|
StatusProportion,
|
|
as_day,
|
|
reached,
|
|
)
|
|
|
|
DIAGNOSIS = AtEnd("mchat_date", "eeg_date", (
|
|
("in_process", "mchat_date"), ("not_confirmed", "not_confirmed_date"),
|
|
("confirmed", "confirmed_date"),
|
|
)) # fmt: skip
|
|
STEPS = AtEnd("mchat_date", "eeg_date", (
|
|
("mchat_only", "mchat_date"), ("psychology", "psychology_date"),
|
|
("neuropediatrics", "neuro_date"), ("eeg", "eeg_date"),
|
|
)) # fmt: skip
|
|
AGE = ("age_group", lambda row, p: row["age_group"])
|
|
CONFIRMED = lambda row, state, p: state == "confirmed" # noqa: E731
|
|
|
|
MEASURES = {m.id: m for m in [
|
|
Measure("M21_DIAGNOSTICADOS_CON_EEG", "Pacientes con diagnóstico de TEA con EEG",
|
|
"screening",
|
|
StatusProportion(DIAGNOSIS, CONFIRMED,
|
|
lambda row, s, p: reached(row, "eeg_date", p), strata=(AGE,)),
|
|
"increase"),
|
|
Measure("M22_DIAGNOSTICADOS_SIN_EEG", "Pacientes con diagnóstico de TEA sin EEG",
|
|
"screening",
|
|
StatusProportion(DIAGNOSIS, CONFIRMED,
|
|
lambda row, s, p: not reached(row, "eeg_date", p), strata=(AGE,)),
|
|
"decrease"),
|
|
Measure("M23_PACIENTES_EVALUADOS", "Pacientes evaluados por resultado diagnóstico",
|
|
"screening",
|
|
StatusComposition(DIAGNOSIS, admit=lambda s: s in ("confirmed", "in_process"))),
|
|
Measure("M24_CONFIRMACION_DIAGNOSTICO", "Confirmación diagnóstica", "screening",
|
|
StatusProportion(DIAGNOSIS, lambda row, s, p: s in ("confirmed", "in_process"),
|
|
CONFIRMED, strata=(AGE,)),
|
|
"increase"),
|
|
Measure("M25_DIAS_MCHAT_DIAGNOSTICO", "Días de M-CHAT a diagnóstico positivo", "screening",
|
|
StatusDuration(STEPS, "days_mchat_confirmed", "confirmed_date"), "decrease"),
|
|
Measure("M26_DIAS_MCHAT_ADOS2", "Días de M-CHAT a ADOS-2", "screening",
|
|
StatusDuration(STEPS, "days_mchat_psychology", "psychology_date"), "decrease"),
|
|
Measure("M27_DIAS_ADOS2_DIAGNOSTICO", "Días de ADOS-2 a valoración neuropediátrica",
|
|
"screening",
|
|
StatusDuration(STEPS, "days_psychology_neuro", "neuro_date"), "decrease"),
|
|
Measure("M28_CASOS_POR_ESTADO", "Casos por estatus", "screening", StatusComposition(STEPS)),
|
|
Measure("M29_CALIDAD_EEG", "Calidad del EEG", "eegs",
|
|
Composition(lambda r: (as_day(r["study_date"]),), lambda r: r["quality"],
|
|
unit="eeg_id", date="study_date")),
|
|
]} # fmt: skip
|