TEA FHIR: an episode's _include brings its ADOS-2 observation
This commit is contained in:
@@ -167,8 +167,9 @@ def test_the_follow_up_filters(client, query, n):
|
|||||||
|
|
||||||
def test_includes_bring_the_patient_its_steps_and_its_study_eeg(client):
|
def test_includes_bring_the_patient_its_steps_and_its_study_eeg(client):
|
||||||
"""Pins down: `_include` adds each child's Patient (birth date to the month), CarePlan with its steps, M-CHAT,
|
"""Pins down: `_include` adds each child's Patient (birth date to the month), CarePlan with its steps, M-CHAT,
|
||||||
confirmed diagnosis and study EEG as a DiagnosticReport with its quality observations; no metric observation while
|
ADOS-2 (the list shows its CSS and module), confirmed diagnosis and study EEG as a DiagnosticReport with its quality
|
||||||
the alterations are hidden. Fails if an included resource drops out or the alterations leak."""
|
observations; no metric observation while the alterations are hidden. Fails if an included resource drops out or
|
||||||
|
the alterations leak."""
|
||||||
body = get(client, "/tea/fhir/EpisodeOfCare?date=le2025-12-31&status=finished&_include=*")
|
body = get(client, "/tea/fhir/EpisodeOfCare?date=le2025-12-31&status=finished&_include=*")
|
||||||
included = resources(body, mode="include")
|
included = resources(body, mode="include")
|
||||||
kinds = {r["resourceType"] for r in included}
|
kinds = {r["resourceType"] for r in included}
|
||||||
@@ -177,6 +178,8 @@ def test_includes_bring_the_patient_its_steps_and_its_study_eeg(client):
|
|||||||
reports = [r for r in included if r["resourceType"] == "DiagnosticReport"]
|
reports = [r for r in included if r["resourceType"] == "DiagnosticReport"]
|
||||||
assert {r["conclusionCode"][0]["coding"][0]["code"] for r in reports} == {"BUENO"}
|
assert {r["conclusionCode"][0]["coding"][0]["code"] for r in reports} == {"BUENO"}
|
||||||
assert all(len(r["result"]) == 5 for r in reports)
|
assert all(len(r["result"]) == 5 for r in reports)
|
||||||
|
ados2 = [r for r in included if r["resourceType"] == "Observation" and r["code"]["coding"][0]["code"] == "ados2"]
|
||||||
|
assert ados2 and all(any(c["code"]["coding"][0]["code"] == "ados2.css" for c in r["component"]) for r in ados2)
|
||||||
|
|
||||||
|
|
||||||
def test_the_alteration_filter_waits_for_the_validation(client, monkeypatch):
|
def test_the_alteration_filter_waits_for_the_validation(client, monkeypatch):
|
||||||
|
|||||||
@@ -342,13 +342,17 @@ def tea_outcome(status: int, code: str, error: Exception):
|
|||||||
|
|
||||||
|
|
||||||
def _included(tea, queries, e, simulated: bool) -> list[dict]:
|
def _included(tea, queries, e, simulated: bool) -> list[dict]:
|
||||||
"""What an episode's search includes: its patient, its steps, its M-CHAT, its diagnosis and its study EEG."""
|
"""What an episode's search includes: its patient, its steps, its M-CHAT, its ADOS-2, its diagnosis and its study
|
||||||
|
EEG."""
|
||||||
from sqlalchemy import select
|
from sqlalchemy import select
|
||||||
|
|
||||||
persons = tea._rows(queries, select(tea.PERSONS).where(tea.PERSONS.c.pac_id == e.child["pac_id"]))
|
pac_id = e.child["pac_id"]
|
||||||
resources = [tea.patient(e.child["pac_id"], persons[0]["fecha_nacimiento"] if persons else None, simulated),
|
persons = tea._rows(queries, select(tea.PERSONS).where(tea.PERSONS.c.pac_id == pac_id))
|
||||||
|
ados2 = tea.ados2_observation(tea._rows(queries, select(tea.ADOS2).where(tea.ADOS2.c.pac_id == pac_id)),
|
||||||
|
e.pseudonym, simulated)
|
||||||
|
resources = [tea.patient(pac_id, persons[0]["fecha_nacimiento"] if persons else None, simulated),
|
||||||
tea.care_plan(e, simulated)]
|
tea.care_plan(e, simulated)]
|
||||||
resources += [r for r in (tea.mchat_observation(e, simulated), tea.condition(e, simulated)) if r]
|
resources += [r for r in (tea.mchat_observation(e, simulated), ados2, tea.condition(e, simulated)) if r]
|
||||||
if (eeg := e.study_eeg()) is not None:
|
if (eeg := e.study_eeg()) is not None:
|
||||||
resources += tea.eeg_resources(eeg, e.pseudonym, e.metrics, [], simulated)
|
resources += tea.eeg_resources(eeg, e.pseudonym, e.metrics, [], simulated)
|
||||||
return resources
|
return resources
|
||||||
|
|||||||
Reference in New Issue
Block a user