TEA's follow-up list by step, case and EEG result, with its filters and $eeg-summary; a list from a start day

This commit is contained in:
Roberto Treviño
2026-12-06 03:33:25 -06:00
parent 2a28e8fc50
commit 4ce3a165ad
3 changed files with 70 additions and 25 deletions
+26
View File
@@ -0,0 +1,26 @@
"""TEA's FHIR operations over its follow-up list: `$eeg-summary`, the EEGs of the children
the list holds (with its filters; its whole history when no window or start is asked)."""
from datetime import date
from fastapi import APIRouter, Query, Request
from fastapi.responses import Response
from core.domains import Domain
from core.tea import fhir as tea_fhir
from core.tea import follow_up
from webapi.fhir import _OK, _cutoff, _listed, fhir
router = APIRouter(prefix="/tea/fhir/Patient", tags=["fhir"])
@router.get("/$eeg-summary", responses=_OK, response_class=Response)
def eeg_summary(
request: Request,
window: int | None = Query(None, alias="follow-up-window", description="months"),
start: date | None = Query(None, alias="follow-up-start"),
cutoff: date | None = Query(None, alias="follow-up-cutoff"),
) -> Response:
at = _cutoff(Domain.TEA, cutoff)
rows, _ = _listed(request, Domain.TEA, at, window, start, at)
return fhir(tea_fhir.eeg_summary(follow_up.summary(rows)))