TEA gate compares M24 by age and sex and M31 by sex; the platform-only M30 group per alteration is left out of the comparison

This commit is contained in:
2026-11-28 05:56:42 -06:00
parent 074fdb5305
commit de4485094f
+13 -2
View File
@@ -67,9 +67,19 @@ CODES = { # the current platform's code -> the platform's
"SOLO_MCHAT": "mchat_only", "PSICOLOGIA": "psychology", "NEUROPEDIATRIA": "neuropediatrics",
"EEG": "eeg", "BUENO": "good", "MALO": "bad", "SIN_ANALIZAR": "not_analyzed",
"16_23": "16-23", "24_29": "24-29", "30_36": "30-36", "sin_dato": "no_data",
"FEMENINO": "female", "MASCULINO": "male", "EN_POBLACION": "in_population",
} # fmt: skip
STRATA = {"estado": "category", "paso": "category", "calidad": "category",
"grupo_edad": "age_group"} # fmt: skip
"grupo_edad": "age_group", "edad_sexo": "age_sex", "sexo": "sex"} # fmt: skip
# Stratifiers only the platform reports: the current platform's M30 gives the total alone, so
# its group per alteration has nothing here to be compared with (gold.tea_alterations is
# tested in dbt).
ONLY_OURS = {"M30_RESULTADO_EEG": {"alteration"}}
def _code(text: str) -> str:
"""A stratum value in the platform's codes; "16_23|FEMENINO" part by part."""
return "|".join(CODES.get(part, part) for part in text.split("|"))
def _report(entry: dict, ours: bool) -> tuple:
@@ -90,7 +100,7 @@ def _report(entry: dict, ours: bool) -> tuple:
for p in x["population"]:
kind = p["code"]["coding"][0]["code"]
if not (ours and kind == "initial-population" and "denominator" in populations):
cells[CODES.get(x["value"]["text"], x["value"]["text"])][kind] = p["count"]
cells[_code(x["value"]["text"])][kind] = p["count"]
strata[name] = dict(cells)
return populations, score.get("value"), extensions, {k: v for k, v in strata.items() if v}
@@ -109,6 +119,7 @@ def indicators(api) -> None:
name = measure["name"]
for ours, theirs in zip(found, reference[name]["body"]["entry"], strict=True):
a, b = _report(ours, True), _report(theirs, False)
a = (*a[:3], {k: v for k, v in a[3].items() if k not in ONLY_OURS.get(name, ())})
where = (name, ours["resource"]["period"]["start"])
assert a[0] == b[0] and a[3] == b[3], (where, a, b)
if cohort: