TEA on its new staging: silver load, ten measures answered on request with the status at the period's end, several groups and column strata, and FHIR R4 endpoints for measures, follow-up and patient summary

This commit is contained in:
2026-11-12 15:21:25 -06:00
parent c430a5bd11
commit a0407e41d6
55 changed files with 2609 additions and 790 deletions
+17 -6
View File
@@ -5,7 +5,8 @@ from pydantic import ValidationError
from webapi.imports.schemas.registry import ENTITY_REGISTRY
from webapi.imports.schemas.cama.ordenes_estudio import OrdenesEstudioImportSchema as CamaOrdenesEstudioImportSchema
from webapi.imports.schemas.tea.eeg_estudio import EegEstudioImportSchema
from webapi.imports.schemas.tea.ados2 import Ados2ImportSchema
from webapi.imports.schemas.tea.mchat import MchatImportSchema
from webapi.imports.schemas.cacu.biopsia_cervical import BiopsiaCervicalImportSchema
from webapi.imports.schemas.cacu.episodio_clinico import EpisodioClinicoImportSchema
@@ -48,11 +49,21 @@ def test_cama_ordenes_estudio_requires_numero_hospital_and_coerces_tipo_estudio(
assert schema.ord_tipo_estudio == "BIOPSIA_CHICA"
# TEA entity with a bare Enum field (no *_ALIAS dict), so the schema builds
# a Catalog from the Enum alone, as in tea/pacientes.py.
def test_tea_eeg_estudio_coerces_simetria_from_bare_enum_no_alias_dict():
schema = EegEstudioImportSchema(eeg_simetria="simetrico")
assert schema.eeg_simetria == "SIMETRICO"
def test_tea_ados2_coerces_module_and_classification_aliases():
"""Pins down: the ADOS-2's module comes from the bare enum and its classification takes the old spelling
`NO_TEA`. Fails if either catalog stops normalizing case or aliases."""
schema = Ados2ImportSchema(ado_modulo="modulo_1", ado_clasificacion="no_tea")
assert (schema.ado_modulo, schema.ado_clasificacion) == ("MODULO_1", "NO_ESPECTRO")
@pytest.mark.parametrize(("schema", "field", "value"), [
(MchatImportSchema, "mch_puntaje", 21), (Ados2ImportSchema, "ado_css", 0), (Ados2ImportSchema, "ado_sa_b1", 4),
])
def test_tea_scores_out_of_their_range_are_rejected(schema, field, value):
"""Pins down: an M-CHAT score above 20, a CSS below 1 and an ADOS-2 item above 3 are validation errors. Fails if
a bound of `Bounded` is dropped from the schemas."""
with pytest.raises(ValidationError):
schema(**{field: value})
# CaCu entity with a real *_ALIAS-backed field (GRADO_CIN_ALIAS).