T8/T9: Patient carries tea-eeg-result; the _id search keeps the TEA follow-up row; submodules
This commit is contained in:
@@ -52,6 +52,10 @@ CODE_SYSTEMS: dict[str, tuple[str, dict[str, str]]] = {
|
||||
"confirmed": "Diagnóstico confirmado", "in_process": "En proceso",
|
||||
"not_confirmed": "Sin TEA",
|
||||
}),
|
||||
"tea-eeg-result": ("Resultado del EEG", {
|
||||
"abnormal": "Anormal", "normal": "Normal",
|
||||
"no_valid_eeg": "Sin EEG válido", "not_scored": "Sin analizar",
|
||||
}),
|
||||
"follow-up-priority": ("Prioridad de seguimiento", {
|
||||
"high": "Alta", "medium": "Media", "low": "Baja",
|
||||
}),
|
||||
@@ -132,6 +136,7 @@ EXTENSIONS: dict[str, tuple[str | None, list[str]]] = {
|
||||
"tea-step": ("code", ["Patient"]),
|
||||
"tea-age-group": ("code", ["Patient"]),
|
||||
"tea-case": ("code", ["Patient"]),
|
||||
"tea-eeg-result": ("code", ["Patient"]),
|
||||
"report-date": ("date", ["DiagnosticReport"]),
|
||||
"days-to-diagnosis": ("integer", ["DiagnosticReport"]),
|
||||
"eeg-duration-min": ("decimal", ["DiagnosticReport"]),
|
||||
@@ -223,6 +228,7 @@ def patient(row: dict, status_system: str | None = None) -> Patient:
|
||||
("step", "tea-step"),
|
||||
("age_group", "tea-age-group"),
|
||||
("case", "tea-case"),
|
||||
("eeg_result", "tea-eeg-result"),
|
||||
):
|
||||
if row.get(field) is not None:
|
||||
found.setdefault("extension", []).append(ext(name, "code", row[field]))
|
||||
|
||||
+1
-1
Submodule WebApi updated: 6c1d098619...b61a4863d1
+1
-1
Submodule WebApp updated: 48e6c9f390...fcb3634fa9
@@ -1,11 +1,14 @@
|
||||
from datetime import date
|
||||
|
||||
import pytest
|
||||
from fastapi import Request
|
||||
|
||||
from core import fhir, fhir_in, tea
|
||||
from core.domains import Domain
|
||||
from core.pipeline import RECORD
|
||||
from core.tea import ados2_items, follow_up
|
||||
from core.tea import fhir as tea_fhir
|
||||
from webapi.fhir import _patient_rows
|
||||
|
||||
DAY = date(2025, 1, 1)
|
||||
EEG = {"person_id": "child", "edf": "0123456789abcdef", "study_date": DAY}
|
||||
@@ -204,6 +207,7 @@ def test_patient_tea_follow_up_fields(status_system):
|
||||
"step": "mchat_only",
|
||||
"age_group": "16-23",
|
||||
"confirmed_date": DAY,
|
||||
"eeg_result": "no_valid_eeg",
|
||||
}
|
||||
],
|
||||
DAY,
|
||||
@@ -215,11 +219,46 @@ def test_patient_tea_follow_up_fields(status_system):
|
||||
assert extensions["tea-step"]["valueCode"] == "mchat_only"
|
||||
assert extensions["tea-age-group"]["valueCode"] == "16-23"
|
||||
assert extensions["tea-case"]["valueCode"] == "confirmed"
|
||||
assert extensions["tea-eeg-result"]["valueCode"] == "no_valid_eeg"
|
||||
else:
|
||||
assert "extension" not in patient
|
||||
assert fhir.patient({"person_id": "child"}, status_system).extension is None
|
||||
|
||||
|
||||
def test_focused_patient_search_uses_the_tea_follow_up_cohort(fresh_platform):
|
||||
with fresh_platform.begin() as connection:
|
||||
connection.exec_driver_sql("create table silver.person (person_id, birth_date, sex)")
|
||||
connection.exec_driver_sql(
|
||||
"insert into silver.person (person_id) values ('child'), ('other'), ('outside')"
|
||||
)
|
||||
connection.exec_driver_sql("create table silver.death (person_id, death_date)")
|
||||
connection.exec_driver_sql(
|
||||
"create table gold.tea_follow_up "
|
||||
"(person_id, status, step, age_group, start_date, end_date, step_date, eeg_result)"
|
||||
)
|
||||
connection.exec_driver_sql(
|
||||
"insert into gold.tea_follow_up values "
|
||||
"('child', 'finished', 'eeg', '16-23', '2023-01-01', '2023-02-01', "
|
||||
"'2023-02-01', 'normal'), "
|
||||
"('other', 'active', 'mchat_only', '24-29', '2024-11-01', null, "
|
||||
"'2024-11-01', 'no_valid_eeg')"
|
||||
)
|
||||
|
||||
def listed_rows(patient_id=None):
|
||||
request = Request({"type": "http", "query_string": b""})
|
||||
rows, listed, _ = _patient_rows(
|
||||
request, Domain.TEA, follow_up, DAY, None, date.min, DAY, None, _id=patient_id
|
||||
)
|
||||
assert listed
|
||||
return rows
|
||||
|
||||
listed = listed_rows()
|
||||
assert len(listed) == 2
|
||||
(focused,) = listed_rows("child")
|
||||
assert focused == next(row for row in listed if row["person_id"] == "child")
|
||||
assert listed_rows("outside") == []
|
||||
|
||||
|
||||
def test_fhir_in_joins_encounter_results_and_subject_by_full_url():
|
||||
patient = {
|
||||
"resourceType": "Patient",
|
||||
|
||||
Reference in New Issue
Block a user