F7a: ADOS-2 scoring from the manual algorithm sheets
Algorithm scores 0, 1, 2, 3 -> 0, 1, 2, 2 and 7, 8, 9 -> 0, with the Toddler B-1 exception (1 -> 2). The algorithm column comes from completed months and item A-1 (new catalog field language_level): Toddler 12-20 months few words, 21-30 by A-1; Module 1 by A-1; Module 2 under five or not. The total adds only the column's items. Classification from the manual's total cuts; Toddler CSS from Esler 2015 table 3; Modules 1-2 CSS from the manual's comparison tables (test transcription, in code for now). Module 3 is not scored (no items in the ADOS-2 list). Labels non_tea / autism_spectrum / autism and little_or_no / mild_to_moderate / moderate_to_severe concern. A-1 travels to FHIR, follow-up (ados2_language_level), association input, synthetic hospital, pipelines and the Gobernanza preview. Ported from the tea library 0.4.0 (patches 0001/0002).
This commit is contained in:
+3
-1
@@ -140,6 +140,7 @@ def cohort() -> tuple[pd.DataFrame, pd.DataFrame]:
|
|||||||
"age_months",
|
"age_months",
|
||||||
"ados_module",
|
"ados_module",
|
||||||
"css",
|
"css",
|
||||||
|
"language_level",
|
||||||
*ADOS2_ITEMS,
|
*ADOS2_ITEMS,
|
||||||
]
|
]
|
||||||
biomarker = {metric: name for name, metric in ASSOCIATION_BIOMARKERS.items()}
|
biomarker = {metric: name for name, metric in ASSOCIATION_BIOMARKERS.items()}
|
||||||
@@ -148,12 +149,13 @@ def cohort() -> tuple[pd.DataFrame, pd.DataFrame]:
|
|||||||
for row in studies:
|
for row in studies:
|
||||||
row["evaluation_date"] = as_day(row["evaluation_date"]) if row["evaluation_date"] else None
|
row["evaluation_date"] = as_day(row["evaluation_date"]) if row["evaluation_date"] else None
|
||||||
birth = as_day(row["birth_date"]) if row["evaluation_date"] and row["birth_date"] else None
|
birth = as_day(row["birth_date"]) if row["evaluation_date"] and row["birth_date"] else None
|
||||||
|
scored = ados2.score(row, birth)
|
||||||
records.append(
|
records.append(
|
||||||
{
|
{
|
||||||
**row,
|
**row,
|
||||||
"key": eeg_study_id(row["person_id"], row["study_date"]),
|
"key": eeg_study_id(row["person_id"], row["study_date"]),
|
||||||
"ados_module": row["module"],
|
"ados_module": row["module"],
|
||||||
"css": ados2.score(row, birth)[0],
|
"css": scored.css if scored else None,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
values = {}
|
values = {}
|
||||||
|
|||||||
+10
-5
@@ -151,20 +151,25 @@ def _report(
|
|||||||
evaluation_date = recorded_on
|
evaluation_date = recorded_on
|
||||||
module = row.get("module")
|
module = row.get("module")
|
||||||
titles = {i.field: f"{i.code} {i.title}" for i in ados2_items.ITEMS.get(module, ())}
|
titles = {i.field: f"{i.code} {i.title}" for i in ados2_items.ITEMS.get(module, ())}
|
||||||
order = [*titles, *(item for item in tea.ADOS2_ITEMS if item not in titles)]
|
titles["language_level"] = "A-1 Nivel general de lenguaje oral no ecolálico"
|
||||||
|
order = [
|
||||||
|
"language_level",
|
||||||
|
*(field for field in titles if field != "language_level"),
|
||||||
|
*(item for item in tea.ADOS2_ITEMS if item not in titles),
|
||||||
|
]
|
||||||
items = {item: _parse(item, row.get(item), "number", warnings) for item in order}
|
items = {item: _parse(item, row.get(item), "number", warnings) for item in order}
|
||||||
css, classification = None, None
|
css, classification = None, None
|
||||||
if evaluation_date is None:
|
if evaluation_date is None:
|
||||||
warnings.append("ADOS-2 not scored: no evaluation date")
|
warnings.append("ADOS-2 not scored: no evaluation date")
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
css, classification = scoring.score(
|
scored = scoring.score(row | items | {"evaluation_date": evaluation_date}, birth)
|
||||||
row | items | {"evaluation_date": evaluation_date}, birth
|
|
||||||
)
|
|
||||||
except (ValueError, TypeError) as exc:
|
except (ValueError, TypeError) as exc:
|
||||||
warnings.append(f"ADOS-2 not scored: {exc}")
|
warnings.append(f"ADOS-2 not scored: {exc}")
|
||||||
else:
|
else:
|
||||||
if css is None and classification is None:
|
if scored:
|
||||||
|
css, classification = scored.css, scored.classification
|
||||||
|
else:
|
||||||
warnings.append(
|
warnings.append(
|
||||||
"the ADOS-2 score could not be calculated: "
|
"the ADOS-2 score could not be calculated: "
|
||||||
"the report lacks the module or the item scores"
|
"the report lacks the module or the item scores"
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
import hashlib
|
import hashlib
|
||||||
import os
|
import os
|
||||||
|
from datetime import date
|
||||||
|
from types import SimpleNamespace
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from dagster import build_op_context
|
from dagster import build_op_context
|
||||||
|
|
||||||
|
from core.pipeline import Extract
|
||||||
from models.definitions import Preview, preview_study
|
from models.definitions import Preview, preview_study
|
||||||
from models.tea import preview as study
|
from models.tea import preview as study
|
||||||
from persistance import config, previews
|
from persistance import config, previews
|
||||||
@@ -59,3 +62,36 @@ def test_the_job_deletes_its_files_when_the_study_fails(preview_area):
|
|||||||
with build_op_context() as context, pytest.raises(LookupError, match="no preview file"):
|
with build_op_context() as context, pytest.raises(LookupError, match="no preview file"):
|
||||||
preview_study(context, Preview(edf="0" * 64, ados2=report))
|
preview_study(context, Preview(edf="0" * 64, ados2=report))
|
||||||
assert list(preview_area.iterdir()) == []
|
assert list(preview_area.iterdir()) == []
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("language, css", [(3, 1), (1, 2)])
|
||||||
|
def test_ados2_preview_reads_language_level_and_scores_its_column(monkeypatch, language, css):
|
||||||
|
node = Extract(
|
||||||
|
id="ados2",
|
||||||
|
column="text",
|
||||||
|
entity="ados2",
|
||||||
|
patterns={
|
||||||
|
"module": r"Módulo (module_1)",
|
||||||
|
"language_level": r"A-1 (\d)",
|
||||||
|
"vocalization_directed": r"A-2 (\d)",
|
||||||
|
"intonation": r"A-3 (\d)",
|
||||||
|
"stereotyped_language": r"A-5 (\d)",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
monkeypatch.setattr(
|
||||||
|
study.graph,
|
||||||
|
"read_file",
|
||||||
|
lambda _: {
|
||||||
|
"text": f"Módulo module_1\nA-1 {language}\nA-2 2\nA-3 3\nA-5 3",
|
||||||
|
"error": None,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
monkeypatch.setattr(study.config_log, "get", lambda _: (1, SimpleNamespace(nodes=[node])))
|
||||||
|
warnings = []
|
||||||
|
result = study._report(b"%PDF", "tea", date(2026, 1, 1), date(2023, 7, 1), warnings)
|
||||||
|
assert result.items["language_level"] == language
|
||||||
|
assert next(iter(result.items)) == "language_level"
|
||||||
|
assert result.titles["language_level"] == "A-1 Nivel general de lenguaje oral no ecolálico"
|
||||||
|
assert result.css == css
|
||||||
|
assert result.classification == "non_tea"
|
||||||
|
assert warnings == []
|
||||||
|
|||||||
Reference in New Issue
Block a user