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
committed by rockdrigo
parent 205bc214fa
commit e224b8b2aa
55 changed files with 2607 additions and 788 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ from pathlib import Path
from webapi.orchestration.context import Context
from webapi.orchestration.runner import run
PROJECTS = ("cacu", "cama")
PROJECTS = ("cacu", "cama", "tea")
def main(argv: list[str] | None = None) -> None:
+12 -139
View File
@@ -51,12 +51,6 @@ valor = 1
estado = "provisional"
fuente = "Propuesta T-21g: el horizonte de `cama/cohorte_tamizaje` (sin definir, MD-Q14). Decide clínica con modelos (MD-Q5)"
[tea.riesgos.horizonte_banda]
# Años desde el M-CHAT índice: el horizonte del desenlace de la cohorte de tamizaje (48 meses).
valor = 4
estado = "provisional"
fuente = "Responsable de TEA, 2026-10-21: 48 meses. Sin uso mientras la cohorte de TEA sea propuesta (T-21h)"
[comun.catalogos.banda_riesgo]
# Las bandas del resumen de riesgos, de menor a mayor.
valor = [
@@ -90,10 +84,10 @@ estado = "provisional"
fuente = "Propuesta para v0.5.0, falta que clínica la confirme (usuario, 2026-10-12). Cortes del grupo blanco (indicadores_kit_0), sin confirmar"
# ===========================================================================
# TEA · los 18 indicadores de ulises (M2 a M19, K1 a K8)
# TEA · the screening's indicators (M21 to M30)
#
# Copia de ulises/parametros.toml, con el prefijo "tea.". La clave es la
# ruta con puntos: [tea.cohorte.edad_min_meses] -> "tea.cohorte.edad_min_meses".
# The key is the dotted path: [tea.cohorte.edad_min_meses] -> "tea.cohorte.edad_min_meses".
# The measures read their rules from dbt's var `tea` (Transformation/dbt_project.yml), which holds the same values.
# Las listas y tablas se guardan en def_parametro como JSON.
# El umbral de supresión es comun.umbral_supresion; tea.supresion.activa lo apaga.
# Documentos citados (repositorio analisis-tea, carpeta docs/):
@@ -102,9 +96,10 @@ fuente = "Propuesta para v0.5.0, falta que clínica la confirme (usuario, 2026-1
# ===========================================================================
[tea.cohorte.edad_min_meses]
# The cohort: children whose first M-CHAT was at 16 to 36 completed months.
valor = 16
estado = "confirmado"
fuente = "contexto §1: ADOS-2 y EEG ligado, de 16 a 36 meses cumplidos a la fecha del EEG (director)"
fuente = "Responsable del proyecto, 2026-11-11: edad cumplida al primer M-CHAT, de 16 a 36 meses"
[tea.cohorte.edad_max_meses]
valor = 36
@@ -117,97 +112,23 @@ valor = 30.4375
estado = "confirmado"
fuente = "analisis-tea/tea/comun.py, edad_meses"
[tea.cohorte.plazo_ados2_eeg_dias]
# ADOS-2 y EEG a este número de días o menos, en cualquier orden: solo marca diagnostico_eeg_en_plazo.
valor = 30
estado = "confirmado"
fuente = "contexto §1: más de un mes de diferencia afecta la validez (director)"
[tea.cohorte.ventanas]
# Ventanas madurativas por meses cumplidos a la fecha del EEG, sin huecos.
# Age groups, by completed months at the first M-CHAT, without gaps: the windows of the TEA page.
valor = [
{ clave = "V1_16_23", desde = 16, hasta = 23, etiqueta = "16 a 23 meses", color = "#9DBFE3" },
{ clave = "V2_24_30", desde = 24, hasta = 30, etiqueta = "24 a 30 meses", color = "#5E93CC" },
{ clave = "V3_31_36", desde = 31, hasta = 36, etiqueta = "31 a 36 meses", color = "#1B4A80" },
{ clave = "16_23", desde = 16, hasta = 23, etiqueta = "16 a 23 meses", color = "#9DBFE3" },
{ clave = "24_29", desde = 24, hasta = 29, etiqueta = "24 a 29 meses", color = "#5E93CC" },
{ clave = "30_36", desde = 30, hasta = 36, etiqueta = "30 a 36 meses", color = "#1B4A80" },
]
estado = "confirmado"
fuente = "contexto §1: revisión bibliográfica del proyecto. Colores: paleta de ejemplo (provisional)"
[tea.instrumentos.informantes_ramos]
# Orden de preferencia cuando contestaron varios: la madre; si no contestó, el padre.
valor = ["MADRE", "PADRE", "OTRO_CUIDADOR", "NO_REGISTRADO"]
estado = "confirmado"
fuente = "contexto §1 (equipo); psicología no registra al cuidador principal"
[tea.instrumentos.informantes_otros]
valor = ["MADRE", "PADRE", "OTRO_CUIDADOR", "OBSERVACION_CLINICA", "MAESTRO", "NO_REGISTRADO"]
estado = "confirmado"
fuente = "analisis-tea/tea/config.py, INFORMANTE_PRIORIDAD['_otros']; confirmado por el responsable de TEA, 2026-10-21"
[tea.ramos.areas]
# «TOTAL» no cuenta como área.
valor = [
{ clave = "COGNOSCITIVO", etiqueta = "Cognoscitivo" },
{ clave = "LINGUISTICO", etiqueta = "Lingüístico" },
{ clave = "FISICO", etiqueta = "Físico" },
{ clave = "SOCIOEMOCIONAL", etiqueta = "Socioemocional" },
{ clave = "ADAPTATIVO", etiqueta = "Adaptativo" },
]
estado = "confirmado"
fuente = "spec v2, catálogo de ins_area; contexto §1"
[tea.poblacion.css_min_tea]
# M21 y M22: TEA positivo si el CSS del ADOS-2 es al menos este valor.
valor = 3
estado = "confirmado"
fuente = "responsable de TEA, 2026-10-21: CSS de 3 a 4, espectro; de 5 a 10, autismo"
fuente = "Responsable del proyecto, 2026-11-10: las ventanas de la página de TEA. Colores: paleta de ejemplo (provisional)"
[tea.diagnostico.cie_tea]
# M24 y M25: códigos CIE-10 de la nota médica que confirman el diagnóstico, sin punto (F84.0 -> F840).
# M21 to M25: ICD-10 codes of the neuropediatrics note that confirm the diagnosis, without the dot (F84.0 -> F840).
# F84 without its subcode doesn't count.
valor = ["F840"]
estado = "confirmado"
fuente = "usuario (2026-10-15): solo F84.0 (autismo)"
[tea.diagnostico.instrumentos_mchat]
# M25: valores de psi_instrumento_tamizaje que son un M-CHAT.
valor = ["M_CHAT_R", "M_CHAT_RF"]
estado = "confirmado"
fuente = "Core, enum InstrumentoTamizaje (psi_instrumento_tamizaje)"
[tea.atencion.plazo_referencia_evaluacion_dias]
# K1: inicio de la evaluación a más tardar este número de días después de la referencia.
valor = 90
estado = "confirmado"
fuente = "estandares: NICE QS51, enunciado 1 (3 meses)"
[tea.parto.apgar_corte]
# Apgar a los 5 minutos: menor de este valor, igual, y mayor (8 a 10).
valor = 7
estado = "confirmado"
fuente = "lista, M17: menor de 7, 7, y 8 a 10"
# Las cuatro reglas siguientes las usa el mapeo (tea/mapeo.py) al cargar:
# un cambio pide volver a cargar.
[tea.antecedentes_maternos.no_registrado]
valor = "NO_REGISTRADO"
estado = "confirmado"
fuente = "spec v2: NO_REGISTRADO = sin dato"
[tea.antecedentes_maternos.hipertension_ninguno]
valor = "NINGUNO"
estado = "confirmado"
fuente = "spec v2, catálogo de amg_hipertension_preeclampsia"
[tea.antecedentes_maternos.embarazo_no_unico]
valor = ["GEMELAR", "TRIPLE_O_MAS"]
estado = "confirmado"
fuente = "spec v2, catálogo de amg_embarazo_multiple"
[tea.antecedentes_maternos.liquido_anormal]
valor = ["OLIGOHIDRAMNIOS", "POLIHIDRAMNIOS"]
estado = "confirmado"
fuente = "spec v2, catálogo de amg_liquido_amniotico"
[tea.supresion.activa]
# Apagada: el tablero es de uso interno del equipo y los médicos. Con false no se
# suprime nada, aunque comun.umbral_supresion tenga valor.
@@ -232,54 +153,6 @@ valor = { etiqueta = "Sin dato", color = "#C9CDD2" }
estado = "confirmado"
fuente = "lista: «sin dato» siempre se muestra como categoría propia"
[tea.catalogos.sexo]
valor = [
{ clave = "F", etiqueta = "Femenino", color = "#E0A030" },
{ clave = "M", etiqueta = "Masculino", color = "#2F6DB3" },
{ clave = "I", etiqueta = "Indeterminado", color = "#8A9199" },
]
estado = "provisional"
fuente = "spec v2, pac_sexo; colores provisionales"
[tea.catalogos.resultado_mchat]
valor = [
{ clave = "RIESGO_BAJO", etiqueta = "Riesgo bajo", color = "#F3E6D3" },
{ clave = "RIESGO_MEDIO", etiqueta = "Riesgo medio", color = "#E8C28E" },
{ clave = "RIESGO_ALTO", etiqueta = "Riesgo alto", color = "#B55A1F" },
]
estado = "provisional"
fuente = "spec v2, interpretación del M-CHAT-R/F (bajo 0–2, medio 3–7, alto 8–20); colores provisionales"
[tea.catalogos.interpretacion_ramos]
valor = [
{ clave = "DESARROLLO_ADECUADO", etiqueta = "Desarrollo adecuado", color = "#9DBFE3" },
{ clave = "MONITOREO", etiqueta = "Monitoreo", color = "#E8C28E" },
{ clave = "RETRASO", etiqueta = "Retraso", color = "#B55A1F" },
]
estado = "provisional"
fuente = "nota_para_cargas.md, interpretación de Ramos; colores provisionales"
[tea.catalogos.grado_hipoacusia]
valor = [
{ clave = "NORMAL", etiqueta = "Normal", color = "#F3E6D3" },
{ clave = "LEVE", etiqueta = "Leve", color = "#E8C28E" },
{ clave = "MODERADA", etiqueta = "Moderada", color = "#D98E4A" },
{ clave = "SEVERA", etiqueta = "Severa", color = "#B55A1F" },
{ clave = "PROFUNDA", etiqueta = "Profunda", color = "#B55A1F" },
{ clave = "NO_CONCLUYENTE", etiqueta = "No concluyente", color = "#8A9199" },
]
estado = "provisional"
fuente = "spec v2, pea_grado_hipoacusia; colores provisionales"
[tea.catalogos.apgar_5min]
valor = [
{ clave = "MENOR_7", etiqueta = "Menor de 7", color = "#B55A1F" },
{ clave = "SIETE", etiqueta = "7", color = "#E8C28E" },
{ clave = "OCHO_A_DIEZ", etiqueta = "8 a 10", color = "#9DBFE3" },
]
estado = "provisional"
fuente = "lista, M17; colores provisionales"
# ===========================================================================
# CaCu · reglas de IND1 (movidas de campo/parametros_campo.toml)
# ===========================================================================
+11 -3
View File
@@ -25,8 +25,9 @@ def event_views(manifest: Path, project: str) -> list:
"""`drop view if exists` and `create view … as <compiled SQL>` for every model the project's measures read,
parents first.
Those are the project's models semantic models count over (`models/<project>/…`) and the timelines its strata
read (`meta.estratos.*.linea`), with the non-ephemeral models they're built on; an ephemeral one is already inlined
Those are the project's models semantic models count over (`models/<project>/…`), the timelines its strata
read (`meta.estratos.*.linea`) and the views the WebApi reads (`meta.lee_la_webapi`), with the non-ephemeral
models they're built on; an ephemeral one is already inlined
in its child's compiled SQL. Another domain's models aren't created: their tables may not exist here.
"""
m = json.loads(manifest.read_text(encoding="utf-8"))
@@ -37,6 +38,9 @@ def event_views(manifest: Path, project: str) -> list:
roots |= {by_name[spec["linea"]] for metric in m["metrics"].values()
if metric["config"].get("meta", {}).get("measure_url", "").startswith(f"{project}/")
for spec in metric["config"]["meta"].get("estratos", {}).values() if "linea" in spec}
# The views the WebApi reads directly (a follow-up list, a patient summary).
roots |= {uid for uid, n in nodes.items() if n["resource_type"] == "model" and n["fqn"][1] == project
and n["config"].get("meta", {}).get("lee_la_webapi")}
ordered: list[str] = []
def visit(uid: str) -> None:
@@ -69,10 +73,14 @@ def catalog_layers(project: str, manifest: Path) -> list[list]:
contract = CONTRACTS[scoring_of(d)]
measures.append(t.CatMeasure(measure_id=d.measure_id, url=d.url, version=d.version, titulo=labels[d.metric],
contrato=contract, unidad=d.basis))
codes = dict.fromkeys((*d.denominator.codes, *d.numerator.codes, *((OBSERVATION,) if contract == "C3r" else ())))
exclusion = getattr(d, "exclusion", None)
codes = dict.fromkeys((*d.denominator.codes, *d.numerator.codes, *((OBSERVATION,) if contract == "C3r" else ()),
*(exclusion.codes if exclusion else ())))
children += [t.CatMeasureResultado(resultado_id=f"{d.measure_id}.{c}", measure_id=d.measure_id, poblacion=c,
etiqueta=c) for c in codes]
children.append(t.CatMeasureGrupo(measure_id=d.measure_id, grupo=d.group, etiqueta=d.group, orden=0))
children += [t.CatMeasureGrupo(measure_id=d.measure_id, grupo=g.name, etiqueta=g.label, orden=i)
for i, g in enumerate(getattr(d, "groups", ()), 1)]
children += [t.CatMeasureEstrato(measure_id=d.measure_id, estrato_id=s.name) for s in d.strata]
stratum_rows = [t.CatEstrato(estrato_id=s, etiqueta=labels_of[s], unidad="paciente") for s in strata]
return [stratum_rows + measures, children]
+41 -2
View File
@@ -14,6 +14,7 @@ llave lógica del procedimiento (`fuente_tabla`, `fuente_id`, `estudio_id`,
from collections.abc import Callable, Iterable, Mapping
from dataclasses import dataclass, field
from types import SimpleNamespace
from typing import NamedTuple
from webapi.orchestration.reference.catalogs import Catalogo
@@ -59,6 +60,16 @@ class Hija:
resultados: Mapping[str, str] = field(default_factory=dict)
@dataclass(frozen=True)
class Junta:
"""Another staging row whose columns the row's content takes: the row of `staging` whose `llave` equals the
row's column `columna` (an electrode value takes its metric's code and EEG). Without a match, they're null."""
staging: type
llave: str
columna: str
@dataclass(frozen=True)
class DeStaging:
"""Un procedimiento que sale de cada fila de una tabla de staging (staging directo, T-20c).
@@ -72,6 +83,10 @@ class DeStaging:
no es un reporte); no es un descarte.
- `descartar(fila, pacientes)`: el motivo por el que la fila no entra, que se cuenta en
`descartes`. `pacientes`: los `pac_id` de la tabla de pacientes del staging.
- `juntas`: rows of other staging tables whose columns join the content before the derived ones.
- `observa_en`: the row gives no procedure of its own; its observations go on the procedure this parent key
names (a metric of an EEG is a result of the EEG's recording). `clase` is unused then.
A result's template can name the content's columns (`eeg.{metrica}`) besides `{estudio}`.
Staging llega resuelto y completo (usuario, 2026-10-21): la carga no valida que no falte nada.
Un procedimiento sin paciente ni padre queda huérfano y se cuenta al escribir (I-MD17).
@@ -92,6 +107,8 @@ class DeStaging:
paciente: str | None = "pac_id"
solo_si: Callable | None = None
descartar: Callable | None = None
juntas: tuple[Junta, ...] = ()
observa_en: Padre | None = None
class LotePlata(NamedTuple):
@@ -124,6 +141,7 @@ def plata_desde_staging(
pacientes = set(pacientes)
tipos, vigentes = _tipos_y_vigentes(catalogo)
procedimientos, observaciones, descartes = [], [], {}
indices: dict[tuple[str, str], dict] = {}
for c in correspondencias:
tabla = c.staging.__tablename__
for fila in filas.get(tabla, ()):
@@ -133,7 +151,13 @@ def plata_desde_staging(
continue
if c.solo_si is not None and not c.solo_si(fila):
continue
contenido = {**fila.model_dump(), **{nombre: f(fila) for nombre, f in c.derivadas.items()}}
contenido = fila.model_dump()
if c.juntas:
for junta in c.juntas:
unida = _junta(junta, filas, indices).get(contenido.get(junta.columna))
contenido = {**(unida or dict.fromkeys(junta.staging.model_fields)), **contenido}
fila = SimpleNamespace(**contenido)
contenido = {**contenido, **{nombre: f(fila) for nombre, f in c.derivadas.items()}}
contenido["pac_id"] = None if c.paciente is None else contenido.get(c.paciente)
contenido.update({destino: contenido.get(origen) for destino, origen in c.columnas.items()})
_repartir(c, tabla, tabla, fuente_id, contenido, tuple(c.columnas), codigos_hospital,
@@ -168,6 +192,14 @@ def en_orden_de_padres(procedimientos: list[dict]) -> list[dict]:
return sorted(procedimientos, key=lambda p: (de(p["llave"]), ORDEN_DE_CLASES.index(p["llave"][3])))
def _junta(junta: Junta, filas: Mapping[str, Iterable], indices: dict) -> dict:
"""The rows of the joined table by their key, as dictionaries; built once per batch."""
clave = (junta.staging.__tablename__, junta.llave)
if clave not in indices:
indices[clave] = {getattr(f, junta.llave): f.model_dump() for f in filas.get(clave[0], ())}
return indices[clave]
def _tipos_y_vigentes(catalogo: Catalogo) -> tuple[dict, set]:
tipos = {r.resultado_id: r.tipo_valor for r in catalogo.resultados}
vigentes = {(v.resultado_id, v.valor_id) for v in catalogo.valores if v.estado == "vigente"}
@@ -183,6 +215,11 @@ def _repartir(c, nombre: str, fuente_tabla: str, fuente_id, contenido: dict, col
motivo = f"{nombre}: {c.estudio_de} fuera de catálogo"
descartes[motivo] = descartes.get(motivo, 0) + 1
return
if c.observa_en is not None:
dueno = _parent(c.observa_en, contenido)
if dueno is not None:
observaciones += _observaciones(dueno, contenido, c.resultados, c.fuentes, tipos, vigentes)
return
llave = (fuente_tabla, str(fuente_id), estudio_id, c.clase)
procedimientos.append({
"llave": llave,
@@ -225,7 +262,9 @@ def _observaciones(llave: Llave, contenido: dict, resultados: Mapping[str, str],
tipos: dict, vigentes: set) -> list[dict]:
filas = []
for columna, plantilla in resultados.items():
resultado_id = plantilla.format(estudio=llave[2])
resultado_id = plantilla.format_map({**contenido, "estudio": llave[2]})
if resultado_id not in tipos and "{" in plantilla.replace("{estudio}", ""):
continue # a value of the row names a result the catalog doesn't have (an unknown metric)
filas.append({
"procedimiento": llave,
"pac_id": contenido.get("pac_id"),
+120
View File
@@ -0,0 +1,120 @@
"""TEA in the two-table silver: what each staging row gives, as `DESDE_STAGING` (read by `carga_desde_staging`).
- an order is an `orden` of the study it asks for (`ord_tipo_estudio`, in Core's code or one of its aliases);
- the M-CHAT is a `toma`, the ADOS-2 and the neuropediatrics note are `encuentro`s, the EEG is a `toma`; each
hangs from its order when it has one;
- an EEG metric is a result of its EEG's recording, not a procedure; a metric's electrode value is a `parte` of the
EEG (`codigo_fuente` the electrode) with the metric's result. Both find their EEG through the metric's row.
"""
from core.tea.enums import (
CLASIFICACION_ADOS2_ALIAS,
TIPO_ESTUDIO_ALIAS,
ClasificacionAdos2,
ModuloAdos2,
TipoEstudio,
)
from core.tea.models import (
ADOS2_ITEMS,
Ados2,
Eeg,
EegMetrica,
EegMetricaElectrodo,
EvaluacionNeuropediatrica,
Mchat,
OrdenesEstudio,
Pacientes,
)
from webapi.orchestration.silver.procedures import DeStaging, Junta, Padre
from webapi.orchestration.silver.values import INTENCION, cie, codigo_de_especialidad, texto_limpio
PACIENTES = Pacientes # where persons come from
ORDENES = OrdenesEstudio.__tablename__
EEG = Eeg.__tablename__
def _codigo(columna: str, enum, alias: dict | None = None):
codigos = {e.value for e in enum}
return lambda f: codigo_de_especialidad(getattr(f, columna), alias or {}, codigos)
def _su_orden(estudio_id: str, columna: str) -> Padre:
"""The order a study row names by its `*_ord_id`."""
return Padre(estudio_id=estudio_id, clase="orden", fuente_id=columna, tabla=ORDENES)
def _metrica(f) -> str | None:
"""A metric's result in the catalog: its code in lower case (`RITMO_POSTERIOR` -> `ritmo_posterior`)."""
codigo = texto_limpio(f.met_codigo)
return None if codigo is None else codigo.lower()
SU_EEG = Padre(estudio_id="eeg", clase="toma", fuente_id="met_eeg_id", tabla=EEG)
DESDE_STAGING = (
DeStaging(
OrdenesEstudio, "ord_id", "orden", estudio_de="tipo_estudio", fecha="ord_fecha", paciente="ord_pac_id",
derivadas={
"tipo_estudio": _codigo("ord_tipo_estudio", TipoEstudio, TIPO_ESTUDIO_ALIAS),
"intencion": lambda f: INTENCION,
},
columnas={"id_hospital": "ord_id_hospital", "codigo_fuente": "ord_tipo_estudio"},
resultados={"intencion": "orden.intencion"},
),
DeStaging(
Mchat, "mch_id", "toma", estudio_id="mchat", fecha="mch_fecha", paciente="mch_pac_id",
padres=(_su_orden("mchat", "mch_ord_id"),),
resultados={"mch_puntaje": "mchat.puntaje"},
),
DeStaging(
Ados2, "ado_id", "encuentro", estudio_id="ados2", fecha="ado_fecha", paciente="ado_pac_id",
padres=(_su_orden("ados2", "ado_ord_id"),),
derivadas={
"modulo": _codigo("ado_modulo", ModuloAdos2),
"clasificacion": _codigo("ado_clasificacion", ClasificacionAdos2, CLASIFICACION_ADOS2_ALIAS),
"algoritmo": lambda f: texto_limpio(f.ado_algoritmo),
},
resultados={
"modulo": "ados2.modulo",
"algoritmo": "ados2.algoritmo",
"clasificacion": "ados2.clasificacion",
"ado_css": "ados2.css",
**{f"ado_{item}": f"ados2.{item}" for item in ADOS2_ITEMS},
},
fuentes={"modulo": "ado_modulo", "clasificacion": "ado_clasificacion"},
),
DeStaging(
EvaluacionNeuropediatrica, "neu_id", "encuentro", estudio_id="evaluacion_neuropediatrica",
fecha="neu_fecha", paciente="neu_pac_id", padres=(_su_orden("evaluacion_neuropediatrica", "neu_ord_id"),),
derivadas={"cie_codigo": lambda f: cie(f.neu_cie_codigo)},
resultados={"cie_codigo": "evaluacion_neuropediatrica.diagnostico"},
),
DeStaging(
Eeg, "eeg_id", "toma", estudio_id="eeg", fecha="eeg_fecha_estudio", paciente="eeg_pac_id",
padres=(_su_orden("eeg", "eeg_ord_id"),), columnas={"id_hospital": "eeg_id_registro_laboratorio"},
resultados={
"eeg_con_sueno": "eeg.con_sueno",
"eeg_canales": "eeg.canales",
"eeg_duracion_min": "eeg.duracion_min",
"eeg_canales_amplitud": "eeg.calidad_amplitud",
"eeg_canales_alta_frecuencia": "eeg.calidad_alta_frecuencia",
"eeg_canales_correlacion": "eeg.calidad_correlacion",
"eeg_canales_sin_senal": "eeg.calidad_sin_senal",
"eeg_ruido_linea_db": "eeg.calidad_linea",
},
),
DeStaging(
EegMetrica, "met_id", "toma", estudio_id="eeg", paciente=None, observa_en=SU_EEG,
derivadas={"metrica": _metrica},
resultados={"met_valor": "eeg.{metrica}"},
),
DeStaging(
EegMetricaElectrodo, "mel_id", "parte", estudio_id="eeg", paciente=None,
juntas=(Junta(EegMetrica, "met_id", "mel_met_id"),), padres=(SU_EEG,),
derivadas={"metrica": _metrica},
columnas={"codigo_fuente": "mel_electrodo"},
resultados={"mel_valor": "eeg.{metrica}"},
),
)
+1 -1
View File
@@ -14,7 +14,7 @@ from importlib import import_module
from sqlmodel import SQLModel
PROJECTS = ("cacu", "cama")
PROJECTS = ("cacu", "cama", "tea")
@dataclass(frozen=True)
+75
View File
@@ -0,0 +1,75 @@
"""TEA's tables: in `Core`, in the domain's registry.
`TABLAS` is what the shared code receives to work with this project; TEA's person adds nothing (its `sexo` stays null).
"""
from core.tea.indicadores.models import (
CatMeasure,
CatMeasureResultado,
CatMeasureValor,
CatMeasureGrupo,
CatEstrato,
CatEstratoValor,
CatMeasureEstrato,
MeasureReportUnidad,
MeasureReportUnidadEstrato,
CatEstudio,
CatResultado,
CatValor,
Observacion,
Procedimiento,
CohorteArmado,
CohorteExclusion,
CohorteMiembro,
CohorteVariable,
EvaluacionRiesgo,
EvaluacionRiesgoLote,
Carga,
DefParametro,
DimFecha,
DimGrupoEdad,
DimPeriodo,
MeasureReport,
PeriodoObservacion,
Persona,
)
from core.indicadores.cohortes import TablasCohorte
from webapi.orchestration.tables import TablasKit
__all__ = ["TABLAS", "COHORTES"]
TABLAS = TablasKit(
Persona=Persona,
PeriodoObservacion=PeriodoObservacion,
Carga=Carga,
DefParametro=DefParametro,
DimPeriodo=DimPeriodo,
DimFecha=DimFecha,
DimGrupoEdad=DimGrupoEdad,
MeasureReport=MeasureReport,
CatEstudio=CatEstudio,
CatResultado=CatResultado,
CatValor=CatValor,
Procedimiento=Procedimiento,
Observacion=Observacion,
CatMeasure=CatMeasure,
CatMeasureResultado=CatMeasureResultado,
CatMeasureValor=CatMeasureValor,
CatMeasureGrupo=CatMeasureGrupo,
CatEstrato=CatEstrato,
CatEstratoValor=CatEstratoValor,
CatMeasureEstrato=CatMeasureEstrato,
MeasureReportUnidad=MeasureReportUnidad,
MeasureReportUnidadEstrato=MeasureReportUnidadEstrato,
)
# Cohorts for models and their risk estimates: TEA builds none yet, the tables are the domain's.
COHORTES = TablasCohorte(
CohorteArmado=CohorteArmado,
CohorteMiembro=CohorteMiembro,
CohorteExclusion=CohorteExclusion,
CohorteVariable=CohorteVariable,
EvaluacionRiesgoLote=EvaluacionRiesgoLote,
EvaluacionRiesgo=EvaluacionRiesgo,
)