ADOS-2 scoring step in the indicators cycle, run after the document import commits; EEG analysis ordered before the relation steps
This commit is contained in:
@@ -200,6 +200,27 @@ def test_an_import_into_tea_queues_its_recomputation(client):
|
||||
assert body["indicadores_en_recalculo"] is True
|
||||
|
||||
|
||||
def test_an_ados2_import_scores_the_evaluations_it_wrote(client):
|
||||
"""Pins down: after a commit that wrote `tea.Ados2` rows, their CSS and classification are computed from the
|
||||
stored items, module and the child's age, without waiting for the cycle; a value the source gave stays. Fails if
|
||||
the commit stops scoring (the CSS would wait for the next cycle, behind any EEG analysis) or scores over a value
|
||||
the source supplied."""
|
||||
patient = _json_source([{"pac_id": 9100, "pac_id_hospital": "T-ADOS", "pac_fecha_nacimiento": "2022-01-01"}],
|
||||
target="tea.Pacientes", column_mapping={"pac_id": "pac_id", "pac_id_hospital": "pac_id_hospital",
|
||||
"pac_fecha_nacimiento": "pac_fecha_nacimiento"})
|
||||
client.post("/imports/commit", json={"sources": [patient], "on_conflict": "upsert"})
|
||||
items = {"ado_sa_b1": 2, "ado_sa_b2": 2, "ado_sa_b3": 2, "ado_sa_b4": 2, "ado_rrb_d1": 2, "ado_rrb_d2": 2}
|
||||
rows = [{"ado_id": "a-1", "ado_pac_id": 9100, "ado_fecha": "2026-01-01", "ado_modulo": "MODULO_3", **items},
|
||||
{"ado_id": "a-2", "ado_pac_id": 9100, "ado_fecha": "2026-01-01", "ado_modulo": "MODULO_3", "ado_css": 9,
|
||||
"ado_clasificacion": "AUTISMO", **items}]
|
||||
ados = _json_source(rows, target="tea.Ados2", column_mapping={k: k for k in rows[0] | rows[1]})
|
||||
body = client.post("/imports/commit", json={"sources": [ados], "on_conflict": "upsert"}).get_json()
|
||||
assert body["results"][0]["created"] == 2
|
||||
stored = {r["ado_id"]: r for r in client.get("/data/tea.Ados2").get_json()["rows"]}
|
||||
assert (stored["a-1"]["ado_css"], stored["a-1"]["ado_clasificacion"]) == (7, "AUTISMO")
|
||||
assert stored["a-2"]["ado_css"] == 9
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sql_source_db(tmp_path):
|
||||
db_path = tmp_path / "external_source.db"
|
||||
|
||||
Reference in New Issue
Block a user