TEA gate on the sitio-b hospital: counts come from the hospital itself, ADOS-2 rows match by the hospital's own patient ids, durations counted to the 2026-11-28 load
This commit is contained in:
+20
-13
@@ -1,9 +1,10 @@
|
||||
"""Phase 4 gate, TEA: the synthetic hospital (EEG signals and ADOS-2 reports as BLOBs), loaded
|
||||
through one drawn pipeline, gives what the current platform gives on the same hospital (the
|
||||
reference fixtures, captured at the last load): the ADOS-2 results read from the reports and
|
||||
their scores, the EEG analysis, its indicators and its pages. Real API, Dagster and MLflow.
|
||||
"""Phase 4 gate, TEA: the sitio-b hospital (62 children with real EEG signals, and ADOS-2
|
||||
reports, as BLOBs), loaded through one drawn pipeline, gives what the current platform gives
|
||||
on the same hospital (the reference fixtures, captured at the last load): the ADOS-2 results
|
||||
read from the reports and their scores, the EEG analysis, its indicators and its pages. Real
|
||||
API, Dagster and MLflow.
|
||||
|
||||
The hospital (205 MB) is kept outside git; its path is TEA_HOSPITAL (default
|
||||
The hospital (2 GB) is kept outside git; its path is TEA_HOSPITAL (default
|
||||
~/isssteleon-data), and its hash is the manifest's.
|
||||
"""
|
||||
|
||||
@@ -59,7 +60,7 @@ METRICS = {"RITMO_POSTERIOR": "posterior_rhythm", "HUSOS_SUENO_N2": "spindles_n2
|
||||
"GRADIENTE_ANTEROPOSTERIOR": "anteroposterior_gradient"} # fmt: skip
|
||||
LEVELS = {"completo": "complete", "no_analizable": "not_analyzable", "parcial": "partial",
|
||||
"sin_referencia_auricular": "no_ear_reference"} # fmt: skip
|
||||
CAPTURED_ON = "2026-11-26" # the day of the capture's load: durations counted to it
|
||||
CAPTURED_ON = "2026-11-28" # the day of the capture's load: durations counted to it
|
||||
PERIODS = [f"{y}-S{s}" for y in range(2021, 2027) for s in (1, 2)]
|
||||
CODES = { # the current platform's code -> the platform's
|
||||
"CONFIRMADO": "confirmed", "EN_PROCESO": "in_process", "SIN_TEA": "not_confirmed",
|
||||
@@ -139,15 +140,21 @@ def test_tea_from_the_hospital_to_indicators(api, platform, tmp_path):
|
||||
|
||||
# Silver holds every study of the hospital; each file (EEG signal, ADOS-2 report) is
|
||||
# kept once, by its hash.
|
||||
with sqlite3.connect(db) as con:
|
||||
source = {s: con.execute(f"select count(*) from {s}").fetchone()[0]
|
||||
for s in ("mchat", "ados2", "eeg", "evaluacion_neuropediatrica")} # fmt: skip
|
||||
signed = "select count(*) from eeg where eeg_estudio is not null"
|
||||
signals = con.execute(signed).fetchone()[0]
|
||||
patients = dict(con.execute("select pac_id_hospital, pac_id from pacientes"))
|
||||
counts = {s: q(f"select count(*) from silver.{s}")[0][0] for s in ("mchat", "ados2", "eeg")}
|
||||
assert counts == {"mchat": 216, "ados2": 113, "eeg": 84}
|
||||
assert counts == {s: source[s] for s in counts}
|
||||
assert q("select count(*) from silver.clinical_note where specialty = 'pediatric_neurology'"
|
||||
)[0][0] == 83 # fmt: skip
|
||||
assert q("select count(*) from silver.eeg where edf is not null")[0][0] == 78
|
||||
)[0][0] == source["evaluacion_neuropediatrica"] # fmt: skip
|
||||
assert q("select count(*) from silver.eeg where edf is not null")[0][0] == signals
|
||||
kept = "select count(*) from bronze.files where key in (select edf from silver.eeg)"
|
||||
assert q(kept)[0][0] == 78
|
||||
assert q(kept)[0][0] == signals
|
||||
|
||||
# ADOS-2: the results read from the 50 reports are the current platform's.
|
||||
# ADOS-2: the results read from every report are the current platform's.
|
||||
reference = {(r["ado_fecha"], r["ado_pac_id"]): r for r in
|
||||
json.loads((REFERENCE / "tables" / "ados2.json").read_text())
|
||||
if r["ado_modulo"]} # fmt: skip
|
||||
@@ -155,10 +162,10 @@ def test_tea_from_the_hospital_to_indicators(api, platform, tmp_path):
|
||||
names = ["person_id", "evaluation_date", "module", *ITEMS]
|
||||
sql = f"select {', '.join(names)} from silver.ados2 where module is not null"
|
||||
found = [dict(zip(names, r, strict=True)) for r in q(sql)]
|
||||
assert len(found) == len(reference) == 50
|
||||
assert len(found) == len(reference) == counts["ados2"]
|
||||
for row in found:
|
||||
theirs = reference[(str(row["evaluation_date"])[:10],
|
||||
int(numbers[row["person_id"]].removeprefix("N")))] # fmt: skip
|
||||
patients[numbers[row["person_id"]]])] # fmt: skip
|
||||
module = MODULES[theirs["ado_modulo"]]
|
||||
assert row["module"] == module
|
||||
for item, by_module in ITEMS.items():
|
||||
|
||||
Reference in New Issue
Block a user