d8f34a77c1
ADOS-2 records without A-1 where the manual needs it (Module 1; Toddler from 21 months) and records whose printed totals differ from their items' totals are held for Revision. The preview shows the same errors.
61 lines
2.0 KiB
Python
61 lines
2.0 KiB
Python
from datetime import date
|
|
|
|
import pytest
|
|
from sqlalchemy import text
|
|
|
|
from core.pipeline import HELD, RECORD, Target
|
|
from core.tea import ados2
|
|
from core.tea.ados2_items import ITEMS
|
|
from models.graph import run_target
|
|
from persistance import nodes, review
|
|
|
|
NODE = Target(id="ados2_out", inputs=["reports", "persons"], entity="ados2")
|
|
KINDS = {"reports": "extract", "persons": "link"}
|
|
A1_NEEDED = "language_level: A-1 (0 to 4) is needed to score"
|
|
|
|
|
|
def _loaded(module, birth):
|
|
report = {
|
|
RECORD: "report",
|
|
"_index": 0,
|
|
"evaluation_date": date(2025, 2, 1),
|
|
"module": module,
|
|
**{item.field: 1 for item in ITEMS[module]},
|
|
}
|
|
nodes.write("tea", "reports", [report])
|
|
persons = [
|
|
{RECORD: "report", "person_id": "child", "birth_date": None},
|
|
{RECORD: "patient", "person_id": "child", "birth_date": birth},
|
|
]
|
|
columns = {"birth_date": {"data_type": "text", "nullable": True}}
|
|
nodes.write("tea", "persons", persons, columns)
|
|
run_target("tea", NODE, KINDS)
|
|
|
|
|
|
def _held():
|
|
return [row[HELD] for row in review.held("ados2")]
|
|
|
|
|
|
def test_a_held_record_corrected_with_a1_is_scored(fresh_platform):
|
|
birth = "2022-08-01"
|
|
_loaded("module_1", birth)
|
|
assert _held() == [[A1_NEEDED]]
|
|
|
|
nodes.correct("report", "language_level", "3", "reviewer", "ados2")
|
|
run_target("tea", NODE, KINDS)
|
|
assert _held() == []
|
|
with fresh_platform.connect() as con:
|
|
sql = text("select field, value_num, value_text from bronze.staged__observation")
|
|
values = {field: num if num is not None else said for field, num, said in con.execute(sql)}
|
|
scored = ados2.score(values | {"evaluation_date": date(2025, 2, 1)}, date.fromisoformat(birth))
|
|
assert (scored.column, scored.column_source) == ("few_words", "a1")
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"birth, held",
|
|
[("2023-08-01", []), ("2023-01-01", [[A1_NEEDED]]), (None, [[A1_NEEDED]])],
|
|
)
|
|
def test_the_persons_birth_date_says_whether_a_toddler_needs_a1(fresh_platform, birth, held):
|
|
_loaded("toddler", birth)
|
|
assert _held() == held
|