Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f4864c1981 | |||
| 5fb2bc682a | |||
| 11dabc4714 | |||
| c67b52b828 | |||
| 3aec97a8b7 |
@@ -14,3 +14,4 @@ dist/imagenes/
|
||||
dist/.env
|
||||
dist/datos/
|
||||
dist/*.tar.gz
|
||||
graphify-out/
|
||||
@@ -19,5 +19,21 @@ valores = [ # solo codigo; el orden de la lista es el de
|
||||
]
|
||||
```
|
||||
|
||||
A result read from a document's text (a report's interpretation, a PDF's text layer, a note) also says how it's
|
||||
printed. These keys don't reach any table; the silver load reads them (`webapi.orchestration.silver.extracted`):
|
||||
|
||||
```toml
|
||||
[<estudio>.resultados.<resultado>]
|
||||
etiquetas_fuente = ["Densidad mamaria", "Densidad"] # the captions it's printed under
|
||||
buscar_en_texto = true # codigo only: also as a mention anywhere in the text
|
||||
provisional = true # captions and spellings not yet confirmed with the hospital's documents
|
||||
valores = [
|
||||
{ valor = "C", etiqueta = "Heterogéneamente densa", alias = ["Tipo C", "ACR C"] }, # each spelling of the value
|
||||
]
|
||||
```
|
||||
|
||||
A spelling with no alias is stored as `valor_fuente` without `valor_id` and counted as out of catalog; adding it
|
||||
as an alias and reloading turns it into the code. One spelling on two values of a result is rejected.
|
||||
|
||||
Los valores son los que llegan del hospital (los enums de Core). Las etiquetas y los colores de las figuras
|
||||
siguen en `parametros.toml` del kit hasta F3; `indicadores_kit/tests/test_catalogos.py` exige que coincidan.
|
||||
|
||||
@@ -30,6 +30,27 @@ valores = [
|
||||
{ valor = "B6", etiqueta = "BI-RADS 6" },
|
||||
]
|
||||
|
||||
# Read from the radiologist's interpretation (`mast_interpretacion`). Provisional: captions and spellings are
|
||||
# assumptions until the hospital's reports are seen; adding one is a line in `etiquetas_fuente` or `alias`.
|
||||
[mastografia.resultados.densidad]
|
||||
etiqueta = "Densidad mamaria (ACR)"
|
||||
tipo_valor = "codigo"
|
||||
provisional = true
|
||||
etiquetas_fuente = ["Densidad mamaria", "Densidad", "Composición mamaria", "Patrón mamario"]
|
||||
valores = [
|
||||
{ valor = "A", etiqueta = "Predominantemente grasa", alias = ["Tipo A", "ACR A", "Categoría A", "(A)", "Grasa"] },
|
||||
{ valor = "B", etiqueta = "Densidades fibroglandulares dispersas", alias = ["Tipo B", "ACR B", "Categoría B", "(B)", "Fibroglandular dispersa"] },
|
||||
{ valor = "C", etiqueta = "Heterogéneamente densa", alias = ["Tipo C", "ACR C", "Categoría C", "(C)", "Heterogéneamente densas"] },
|
||||
{ valor = "D", etiqueta = "Extremadamente densa", alias = ["Tipo D", "ACR D", "Categoría D", "(D)", "Extremadamente densas"] },
|
||||
]
|
||||
|
||||
[mastografia.resultados.tamano_lesion_mm]
|
||||
etiqueta = "Tamaño de la lesión"
|
||||
tipo_valor = "numero"
|
||||
unidad = "mm"
|
||||
provisional = true
|
||||
etiquetas_fuente = ["Tamaño de la lesión", "Tamaño del nódulo", "Diámetro mayor", "Mide"]
|
||||
|
||||
[biopsia]
|
||||
etiqueta = "Biopsia de mama"
|
||||
codigos_hospital = ["BIOPSIA_CHICA"]
|
||||
@@ -48,6 +69,85 @@ valores = [
|
||||
etiqueta = "Fecha de solicitud"
|
||||
tipo_valor = "fecha"
|
||||
|
||||
# Read from the pathology report's text layer (`bx_pdf_blob`). Provisional, as the mammography's.
|
||||
[biopsia.resultados.tipo_histologico]
|
||||
etiqueta = "Tipo histológico"
|
||||
tipo_valor = "codigo"
|
||||
provisional = true
|
||||
etiquetas_fuente = ["Tipo histológico", "Diagnóstico histopatológico", "Diagnóstico"]
|
||||
buscar_en_texto = true
|
||||
valores = [
|
||||
{ valor = "DUCTAL_INFILTRANTE", etiqueta = "Carcinoma ductal infiltrante", alias = ["Ductal infiltrante", "Carcinoma ductal invasor", "Carcinoma infiltrante de tipo no especial", "CDI"] },
|
||||
{ valor = "LOBULILLAR_INFILTRANTE", etiqueta = "Carcinoma lobulillar infiltrante", alias = ["Lobulillar infiltrante", "Carcinoma lobulillar invasor", "CLI"] },
|
||||
{ valor = "DUCTAL_IN_SITU", etiqueta = "Carcinoma ductal in situ", alias = ["Ductal in situ", "CDIS"] },
|
||||
{ valor = "OTRO", etiqueta = "Otro tipo histológico" },
|
||||
]
|
||||
|
||||
[biopsia.resultados.grado_nottingham]
|
||||
etiqueta = "Grado histológico (Nottingham)"
|
||||
tipo_valor = "codigo"
|
||||
provisional = true
|
||||
etiquetas_fuente = ["Grado histológico", "Grado de Nottingham", "Grado Scarff-Bloom-Richardson", "SBR"]
|
||||
valores = [
|
||||
{ valor = "G1", etiqueta = "Grado 1", alias = ["1", "I", "Grado I", "Bien diferenciado"] },
|
||||
{ valor = "G2", etiqueta = "Grado 2", alias = ["2", "II", "Grado II", "Moderadamente diferenciado"] },
|
||||
{ valor = "G3", etiqueta = "Grado 3", alias = ["3", "III", "Grado III", "Poco diferenciado"] },
|
||||
]
|
||||
|
||||
[biopsia.resultados.receptor_estrogeno]
|
||||
etiqueta = "Receptor de estrógeno"
|
||||
tipo_valor = "codigo"
|
||||
provisional = true
|
||||
etiquetas_fuente = ["Receptores de estrógeno", "Receptor de estrógenos", "Receptores estrogénicos", "RE", "ER"]
|
||||
valores = [
|
||||
{ valor = "POSITIVO", etiqueta = "Positivo", alias = ["Pos", "+"] },
|
||||
{ valor = "NEGATIVO", etiqueta = "Negativo", alias = ["Neg", "-"] },
|
||||
]
|
||||
|
||||
[biopsia.resultados.receptor_estrogeno_pct]
|
||||
etiqueta = "Receptor de estrógeno, células teñidas"
|
||||
tipo_valor = "numero"
|
||||
unidad = "%"
|
||||
provisional = true
|
||||
etiquetas_fuente = ["Receptores de estrógeno", "Receptor de estrógenos", "Receptores estrogénicos", "RE", "ER"]
|
||||
|
||||
[biopsia.resultados.receptor_progesterona]
|
||||
etiqueta = "Receptor de progesterona"
|
||||
tipo_valor = "codigo"
|
||||
provisional = true
|
||||
etiquetas_fuente = ["Receptores de progesterona", "Receptor de progesterona", "Receptores progestágenos", "RP", "PR"]
|
||||
valores = [
|
||||
{ valor = "POSITIVO", etiqueta = "Positivo", alias = ["Pos", "+"] },
|
||||
{ valor = "NEGATIVO", etiqueta = "Negativo", alias = ["Neg", "-"] },
|
||||
]
|
||||
|
||||
[biopsia.resultados.receptor_progesterona_pct]
|
||||
etiqueta = "Receptor de progesterona, células teñidas"
|
||||
tipo_valor = "numero"
|
||||
unidad = "%"
|
||||
provisional = true
|
||||
etiquetas_fuente = ["Receptores de progesterona", "Receptor de progesterona", "Receptores progestágenos", "RP", "PR"]
|
||||
|
||||
# A bare "positivo" is left unmatched on purpose: it doesn't say whether it's 3+ or an amplified 2+.
|
||||
[biopsia.resultados.her2]
|
||||
etiqueta = "HER2 (inmunohistoquímica)"
|
||||
tipo_valor = "codigo"
|
||||
provisional = true
|
||||
etiquetas_fuente = ["HER2", "HER-2", "HER2/neu", "C-erbB-2"]
|
||||
valores = [
|
||||
{ valor = "H0", etiqueta = "0", alias = ["0", "Negativo (0)", "Score 0"] },
|
||||
{ valor = "H1", etiqueta = "1+", alias = ["1+", "Negativo (1+)", "Score 1+"] },
|
||||
{ valor = "H2", etiqueta = "2+", alias = ["2+", "Equívoco", "Indeterminado", "Score 2+"] },
|
||||
{ valor = "H3", etiqueta = "3+", alias = ["3+", "Positivo (3+)", "Score 3+"] },
|
||||
]
|
||||
|
||||
[biopsia.resultados.ki67_pct]
|
||||
etiqueta = "Ki-67"
|
||||
tipo_valor = "numero"
|
||||
unidad = "%"
|
||||
provisional = true
|
||||
etiquetas_fuente = ["Ki-67", "Ki67", "Índice de proliferación"]
|
||||
|
||||
[nota_medica]
|
||||
etiqueta = "Nota médica"
|
||||
|
||||
@@ -56,6 +156,25 @@ etiqueta = "Diagnóstico"
|
||||
tipo_valor = "externo"
|
||||
sistema = "CIE-10"
|
||||
|
||||
# Read from the note's diagnosis and prognosis texts. Provisional; a stage mentioned without a caption counts too
|
||||
# ("... estadio clínico IIA (T2N0M0)").
|
||||
[nota_medica.resultados.estadio_clinico]
|
||||
etiqueta = "Estadio clínico"
|
||||
tipo_valor = "codigo"
|
||||
provisional = true
|
||||
etiquetas_fuente = ["Estadio clínico", "Etapa clínica", "Estadio", "EC"]
|
||||
buscar_en_texto = true
|
||||
valores = [
|
||||
{ valor = "E0", etiqueta = "Estadio 0", alias = ["EC 0", "Etapa 0", "In situ", "Estadio clínico 0", "Etapa clínica 0"] },
|
||||
{ valor = "EI", etiqueta = "Estadio I", alias = ["I", "IA", "IB", "EC I", "EC IA", "EC IB", "Estadio IA", "Estadio IB", "Etapa I", "Estadio clínico I", "Etapa clínica I", "Estadio clínico IA", "Estadio clínico IB"] },
|
||||
{ valor = "EIIA", etiqueta = "Estadio IIA", alias = ["IIA", "EC IIA", "Etapa IIA", "Estadio clínico IIA", "Etapa clínica IIA"] },
|
||||
{ valor = "EIIB", etiqueta = "Estadio IIB", alias = ["IIB", "EC IIB", "Etapa IIB", "Estadio clínico IIB", "Etapa clínica IIB"] },
|
||||
{ valor = "EIIIA", etiqueta = "Estadio IIIA", alias = ["IIIA", "EC IIIA", "Etapa IIIA", "Estadio clínico IIIA", "Etapa clínica IIIA"] },
|
||||
{ valor = "EIIIB", etiqueta = "Estadio IIIB", alias = ["IIIB", "EC IIIB", "Etapa IIIB", "Estadio clínico IIIB", "Etapa clínica IIIB"] },
|
||||
{ valor = "EIIIC", etiqueta = "Estadio IIIC", alias = ["IIIC", "EC IIIC", "Etapa IIIC", "Estadio clínico IIIC", "Etapa clínica IIIC"] },
|
||||
{ valor = "EIV", etiqueta = "Estadio IV", alias = ["IV", "EC IV", "Etapa IV", "Metastásico", "Estadio clínico IV", "Etapa clínica IV"] },
|
||||
]
|
||||
|
||||
[nota_medica.resultados.especialidad]
|
||||
etiqueta = "Especialidad que la escribe"
|
||||
tipo_valor = "codigo"
|
||||
|
||||
+228
-219
@@ -1,267 +1,276 @@
|
||||
# Catálogo de TEA (F1). Valores: los enums de Core (`core/tea/enums.py`) y lo que guarda la carga.
|
||||
# Los instrumentos aplicados (M-CHAT-R/F, Ramos) son un estudio cada uno: una aplicación por informante y área.
|
||||
# TEA's catalog: the studies of the screening (M-CHAT, ADOS-2, neuropediatrics note, EEG) and their results.
|
||||
# Values are Core's enums (`core/tea/enums.py`). `codigos_hospital` are the codes of `ord_tipo_estudio`: an order's
|
||||
# `estudio_id` is the study it asks for.
|
||||
|
||||
[evaluacion_psicologica]
|
||||
etiqueta = "Evaluación psicológica"
|
||||
codigos_hospital = ["EVALUACION_PSICOLOGICA_TEA"]
|
||||
[mchat]
|
||||
etiqueta = "M-CHAT-R/F"
|
||||
|
||||
[evaluacion_psicologica.resultados.instrumento_tamizaje]
|
||||
etiqueta = "Instrumento de tamizaje"
|
||||
[mchat.resultados.puntaje]
|
||||
etiqueta = "Puntaje total"
|
||||
tipo_valor = "numero"
|
||||
unidad = "puntos"
|
||||
|
||||
# The ADOS-2: module, algorithm, classification, CSS and the algorithm items. An item's domain is its prefix:
|
||||
# `sa_` social affect, `rrb_` restricted and repetitive behaviour. Labels of the items without a published short name
|
||||
# wait for the hospital's manuals.
|
||||
[ados2]
|
||||
etiqueta = "Evaluación psicológica (ADOS-2)"
|
||||
codigos_hospital = ["ADOS2"]
|
||||
|
||||
[ados2.resultados.modulo]
|
||||
etiqueta = "Módulo"
|
||||
tipo_valor = "codigo"
|
||||
valores = [
|
||||
{ valor = "M_CHAT_R", etiqueta = "M-CHAT-R" },
|
||||
{ valor = "M_CHAT_RF", etiqueta = "M-CHAT-R/F" },
|
||||
{ valor = "OTRO", etiqueta = "Otro" },
|
||||
{ valor = "NO_REGISTRADO", etiqueta = "No registrado" },
|
||||
{ valor = "TODDLER", etiqueta = "Módulo T (niños pequeños)" },
|
||||
{ valor = "MODULO_1", etiqueta = "Módulo 1" },
|
||||
{ valor = "MODULO_2", etiqueta = "Módulo 2" },
|
||||
{ valor = "MODULO_3", etiqueta = "Módulo 3" },
|
||||
]
|
||||
|
||||
[evaluacion_psicologica.resultados.edad_meses]
|
||||
etiqueta = "Edad del niño"
|
||||
tipo_valor = "numero"
|
||||
unidad = "meses"
|
||||
[ados2.resultados.algoritmo]
|
||||
etiqueta = "Algoritmo"
|
||||
tipo_valor = "texto"
|
||||
|
||||
[evaluacion_psicologica.resultados.fecha_evaluacion]
|
||||
etiqueta = "Fecha de la evaluación"
|
||||
tipo_valor = "fecha"
|
||||
|
||||
[evaluacion_psicologica.resultados.fecha_entrevista_inicial]
|
||||
etiqueta = "Fecha de la entrevista inicial"
|
||||
tipo_valor = "fecha"
|
||||
|
||||
[ados2]
|
||||
etiqueta = "ADOS-2"
|
||||
[ados2.resultados.clasificacion]
|
||||
etiqueta = "Clasificación"
|
||||
tipo_valor = "codigo"
|
||||
valores = [
|
||||
{ valor = "NO_ESPECTRO", etiqueta = "No espectro" },
|
||||
{ valor = "ESPECTRO_AUTISTA", etiqueta = "Espectro autista" },
|
||||
{ valor = "AUTISMO", etiqueta = "Autismo" },
|
||||
{ valor = "PREOCUPACION_LEVE_MODERADA", etiqueta = "Preocupación leve a moderada" },
|
||||
{ valor = "PREOCUPACION_SEVERA", etiqueta = "Preocupación moderada a severa" },
|
||||
]
|
||||
|
||||
[ados2.resultados.css]
|
||||
etiqueta = "Puntaje de severidad (CSS)"
|
||||
tipo_valor = "numero"
|
||||
unidad = "puntos"
|
||||
|
||||
[mchat]
|
||||
etiqueta = "M-CHAT-R/F aplicado"
|
||||
codigos_hospital = ["M_CHAT_R_F"]
|
||||
|
||||
[mchat.resultados.informante]
|
||||
etiqueta = "Informante"
|
||||
tipo_valor = "codigo"
|
||||
valores = [
|
||||
{ valor = "MADRE", etiqueta = "Madre" },
|
||||
{ valor = "PADRE", etiqueta = "Padre" },
|
||||
{ valor = "OTRO_CUIDADOR", etiqueta = "Otro cuidador" },
|
||||
{ valor = "MAESTRO", etiqueta = "Maestro" },
|
||||
{ valor = "OBSERVACION_CLINICA", etiqueta = "Observación clínica" },
|
||||
{ valor = "NO_REGISTRADO", etiqueta = "No registrado" },
|
||||
]
|
||||
|
||||
[mchat.resultados.area]
|
||||
etiqueta = "Área"
|
||||
tipo_valor = "codigo"
|
||||
valores = [
|
||||
{ valor = "TOTAL", etiqueta = "Total" },
|
||||
]
|
||||
|
||||
[mchat.resultados.interpretacion]
|
||||
etiqueta = "Interpretación"
|
||||
tipo_valor = "codigo"
|
||||
valores = [
|
||||
{ valor = "RIESGO_BAJO", etiqueta = "Riesgo bajo" },
|
||||
{ valor = "RIESGO_MEDIO", etiqueta = "Riesgo medio" },
|
||||
{ valor = "RIESGO_ALTO", etiqueta = "Riesgo alto" },
|
||||
]
|
||||
|
||||
[ramos]
|
||||
etiqueta = "Escala de Ramos aplicada"
|
||||
codigos_hospital = ["RAMOS"]
|
||||
|
||||
[ramos.resultados.informante]
|
||||
etiqueta = "Informante"
|
||||
tipo_valor = "codigo"
|
||||
valores = [
|
||||
{ valor = "MADRE", etiqueta = "Madre" },
|
||||
{ valor = "PADRE", etiqueta = "Padre" },
|
||||
{ valor = "OTRO_CUIDADOR", etiqueta = "Otro cuidador" },
|
||||
{ valor = "MAESTRO", etiqueta = "Maestro" },
|
||||
{ valor = "OBSERVACION_CLINICA", etiqueta = "Observación clínica" },
|
||||
{ valor = "NO_REGISTRADO", etiqueta = "No registrado" },
|
||||
]
|
||||
|
||||
[ramos.resultados.area]
|
||||
etiqueta = "Área"
|
||||
tipo_valor = "codigo"
|
||||
valores = [
|
||||
{ valor = "ADAPTATIVO", etiqueta = "Adaptativo" },
|
||||
{ valor = "COGNOSCITIVO", etiqueta = "Cognoscitivo" },
|
||||
{ valor = "FISICO", etiqueta = "Físico" },
|
||||
{ valor = "LINGUISTICO", etiqueta = "Lingüístico" },
|
||||
{ valor = "SOCIOEMOCIONAL", etiqueta = "Socioemocional" },
|
||||
{ valor = "TOTAL", etiqueta = "Total" },
|
||||
]
|
||||
|
||||
[ramos.resultados.interpretacion]
|
||||
etiqueta = "Interpretación"
|
||||
tipo_valor = "codigo"
|
||||
valores = [
|
||||
{ valor = "DESARROLLO_ADECUADO", etiqueta = "Desarrollo adecuado" },
|
||||
{ valor = "MONITOREO", etiqueta = "Monitoreo" },
|
||||
{ valor = "RETRASO", etiqueta = "Retraso" },
|
||||
]
|
||||
|
||||
[eeg]
|
||||
etiqueta = "Electroencefalograma"
|
||||
codigos_hospital = ["ELECTROENCEFALOGRAMA"]
|
||||
|
||||
[eeg.resultados.duracion_min]
|
||||
etiqueta = "Duración"
|
||||
tipo_valor = "numero"
|
||||
unidad = "min"
|
||||
|
||||
[eeg.resultados.utilizable]
|
||||
etiqueta = "Utilizable"
|
||||
tipo_valor = "booleano"
|
||||
|
||||
[eeg.resultados.fecha_nacimiento_archivo]
|
||||
etiqueta = "Fecha de nacimiento en el archivo del equipo"
|
||||
tipo_valor = "fecha"
|
||||
|
||||
# Un segmento es una parte del EEG (procedimiento con clase `parte`).
|
||||
[eeg.resultados.estado_segmento]
|
||||
etiqueta = "Estado del segmento"
|
||||
tipo_valor = "codigo"
|
||||
valores = [
|
||||
{ valor = "NO_MARCADO", etiqueta = "No marcado" },
|
||||
{ valor = "OJOS_CERRADOS", etiqueta = "Ojos cerrados" },
|
||||
{ valor = "FOTOESTIMULACION", etiqueta = "Fotoestimulación" },
|
||||
{ valor = "SUENO", etiqueta = "Sueño" },
|
||||
]
|
||||
|
||||
[eeg.resultados.duracion_segmento]
|
||||
etiqueta = "Duración del segmento"
|
||||
tipo_valor = "numero"
|
||||
unidad = "s"
|
||||
|
||||
[pea]
|
||||
etiqueta = "Potenciales evocados auditivos"
|
||||
codigos_hospital = ["POTENCIALES_EVOCADOS_AUDITIVOS", "POTENCIALES_EVOCADOS"] # el segundo, como llega (responsable de TEA, 2026-10-21)
|
||||
|
||||
[pea.resultados.grado_hipoacusia]
|
||||
etiqueta = "Grado de hipoacusia"
|
||||
tipo_valor = "codigo"
|
||||
valores = [
|
||||
{ valor = "NORMAL", etiqueta = "Normal" },
|
||||
{ valor = "LEVE", etiqueta = "Leve" },
|
||||
{ valor = "MODERADA", etiqueta = "Moderada" },
|
||||
{ valor = "SEVERA", etiqueta = "Severa" },
|
||||
{ valor = "PROFUNDA", etiqueta = "Profunda" },
|
||||
{ valor = "NO_CONCLUYENTE", etiqueta = "No concluyente" },
|
||||
]
|
||||
|
||||
[parto]
|
||||
etiqueta = "Parto"
|
||||
|
||||
[parto.resultados.apgar_5min]
|
||||
etiqueta = "APGAR a los 5 minutos"
|
||||
[ados2.resultados.sa_a2]
|
||||
etiqueta = "Frecuencia de la vocalización espontánea dirigida a otros"
|
||||
tipo_valor = "numero"
|
||||
unidad = "puntos"
|
||||
|
||||
[parto.resultados.ingreso_ucin]
|
||||
etiqueta = "Ingreso a UCIN"
|
||||
tipo_valor = "booleano"
|
||||
[ados2.resultados.sa_a6]
|
||||
etiqueta = "Uso del cuerpo de otra persona para comunicarse"
|
||||
tipo_valor = "numero"
|
||||
unidad = "puntos"
|
||||
|
||||
[historia_perinatal]
|
||||
etiqueta = "Antecedentes maternos de la gestación"
|
||||
[ados2.resultados.sa_a7]
|
||||
etiqueta = "Señalar"
|
||||
tipo_valor = "numero"
|
||||
unidad = "puntos"
|
||||
|
||||
[historia_perinatal.resultados.antecedente_aborto]
|
||||
etiqueta = "Antecedente de aborto"
|
||||
tipo_valor = "booleano"
|
||||
[ados2.resultados.sa_a8]
|
||||
etiqueta = "Gestos"
|
||||
tipo_valor = "numero"
|
||||
unidad = "puntos"
|
||||
|
||||
[historia_perinatal.resultados.asma]
|
||||
etiqueta = "Asma"
|
||||
tipo_valor = "booleano"
|
||||
[ados2.resultados.sa_b1]
|
||||
etiqueta = "Contacto visual inusual"
|
||||
tipo_valor = "numero"
|
||||
unidad = "puntos"
|
||||
|
||||
[historia_perinatal.resultados.crisis_convulsivas]
|
||||
etiqueta = "Crisis convulsivas"
|
||||
tipo_valor = "booleano"
|
||||
[ados2.resultados.sa_b2]
|
||||
etiqueta = "Sonrisa social en respuesta"
|
||||
tipo_valor = "numero"
|
||||
unidad = "puntos"
|
||||
|
||||
[historia_perinatal.resultados.diabetes_gestacional]
|
||||
etiqueta = "Diabetes gestacional"
|
||||
tipo_valor = "booleano"
|
||||
[ados2.resultados.sa_b3]
|
||||
etiqueta = "Expresiones faciales dirigidas a otros"
|
||||
tipo_valor = "numero"
|
||||
unidad = "puntos"
|
||||
|
||||
[historia_perinatal.resultados.embarazo_multiple]
|
||||
etiqueta = "Embarazo múltiple"
|
||||
tipo_valor = "booleano"
|
||||
[ados2.resultados.sa_b4]
|
||||
etiqueta = "Integración de la mirada y otras conductas en las iniciaciones sociales"
|
||||
tipo_valor = "numero"
|
||||
unidad = "puntos"
|
||||
|
||||
[historia_perinatal.resultados.enfermedad_autoinmune]
|
||||
etiqueta = "Enfermedad autoinmune"
|
||||
tipo_valor = "booleano"
|
||||
[ados2.resultados.sa_b5]
|
||||
etiqueta = "Placer compartido durante la interacción"
|
||||
tipo_valor = "numero"
|
||||
unidad = "puntos"
|
||||
|
||||
[historia_perinatal.resultados.estres_agudo]
|
||||
etiqueta = "Estrés agudo"
|
||||
tipo_valor = "booleano"
|
||||
[ados2.resultados.sa_b6]
|
||||
etiqueta = "Respuesta al nombre"
|
||||
tipo_valor = "numero"
|
||||
unidad = "puntos"
|
||||
|
||||
[historia_perinatal.resultados.farmaco_riesgo_neurodesarrollo]
|
||||
etiqueta = "Fármaco de riesgo para el neurodesarrollo"
|
||||
tipo_valor = "booleano"
|
||||
[ados2.resultados.sa_b7]
|
||||
etiqueta = "Pedir"
|
||||
tipo_valor = "numero"
|
||||
unidad = "puntos"
|
||||
|
||||
[historia_perinatal.resultados.hipertension_preeclampsia]
|
||||
etiqueta = "Hipertensión o preeclampsia"
|
||||
tipo_valor = "booleano"
|
||||
[ados2.resultados.sa_b8]
|
||||
etiqueta = "Dar"
|
||||
tipo_valor = "numero"
|
||||
unidad = "puntos"
|
||||
|
||||
[historia_perinatal.resultados.hipertiroidismo]
|
||||
etiqueta = "Hipertiroidismo"
|
||||
tipo_valor = "booleano"
|
||||
[ados2.resultados.sa_b9]
|
||||
etiqueta = "Mostrar"
|
||||
tipo_valor = "numero"
|
||||
unidad = "puntos"
|
||||
|
||||
[historia_perinatal.resultados.hipotiroidismo]
|
||||
etiqueta = "Hipotiroidismo"
|
||||
tipo_valor = "booleano"
|
||||
[ados2.resultados.sa_b10]
|
||||
etiqueta = "Iniciación espontánea de la atención conjunta"
|
||||
tipo_valor = "numero"
|
||||
unidad = "puntos"
|
||||
|
||||
[historia_perinatal.resultados.hipoxia_materna]
|
||||
etiqueta = "Hipoxia materna"
|
||||
tipo_valor = "booleano"
|
||||
[ados2.resultados.sa_b11]
|
||||
etiqueta = "Respuesta a la atención conjunta"
|
||||
tipo_valor = "numero"
|
||||
unidad = "puntos"
|
||||
|
||||
[historia_perinatal.resultados.incompatibilidad_rh]
|
||||
etiqueta = "Incompatibilidad Rh"
|
||||
tipo_valor = "booleano"
|
||||
[ados2.resultados.sa_b12]
|
||||
etiqueta = "Calidad de los acercamientos sociales"
|
||||
tipo_valor = "numero"
|
||||
unidad = "puntos"
|
||||
|
||||
[historia_perinatal.resultados.infeccion_gestacion]
|
||||
etiqueta = "Infección en la gestación"
|
||||
tipo_valor = "booleano"
|
||||
[ados2.resultados.sa_b13]
|
||||
etiqueta = "Reactivo B13"
|
||||
tipo_valor = "numero"
|
||||
unidad = "puntos"
|
||||
|
||||
[historia_perinatal.resultados.liquido_amniotico]
|
||||
etiqueta = "Alteración del líquido amniótico"
|
||||
tipo_valor = "booleano"
|
||||
[ados2.resultados.sa_b14]
|
||||
etiqueta = "Reactivo B14"
|
||||
tipo_valor = "numero"
|
||||
unidad = "puntos"
|
||||
|
||||
[historia_perinatal.resultados.migrana]
|
||||
etiqueta = "Migraña"
|
||||
tipo_valor = "booleano"
|
||||
[ados2.resultados.sa_b15]
|
||||
etiqueta = "Reactivo B15"
|
||||
tipo_valor = "numero"
|
||||
unidad = "puntos"
|
||||
|
||||
[historia_perinatal.resultados.proceso_proinflamatorio]
|
||||
etiqueta = "Proceso proinflamatorio"
|
||||
tipo_valor = "booleano"
|
||||
[ados2.resultados.sa_b16b]
|
||||
etiqueta = "Reactivo B16b"
|
||||
tipo_valor = "numero"
|
||||
unidad = "puntos"
|
||||
|
||||
[historia_perinatal.resultados.tabaquismo_gestacion]
|
||||
etiqueta = "Tabaquismo en la gestación"
|
||||
tipo_valor = "booleano"
|
||||
[ados2.resultados.sa_b18]
|
||||
etiqueta = "Reactivo B18"
|
||||
tipo_valor = "numero"
|
||||
unidad = "puntos"
|
||||
|
||||
[historia_perinatal.resultados.trastorno_neurologico]
|
||||
etiqueta = "Trastorno neurológico"
|
||||
tipo_valor = "booleano"
|
||||
[ados2.resultados.rrb_a3]
|
||||
etiqueta = "Entonación de las vocalizaciones o verbalizaciones"
|
||||
tipo_valor = "numero"
|
||||
unidad = "puntos"
|
||||
|
||||
[nota_medica]
|
||||
etiqueta = "Nota médica"
|
||||
[ados2.resultados.rrb_a4]
|
||||
etiqueta = "Ecolalia inmediata"
|
||||
tipo_valor = "numero"
|
||||
unidad = "puntos"
|
||||
|
||||
[nota_medica.resultados.diagnostico]
|
||||
[ados2.resultados.rrb_a5]
|
||||
etiqueta = "Uso estereotipado o idiosincrásico de palabras o frases"
|
||||
tipo_valor = "numero"
|
||||
unidad = "puntos"
|
||||
|
||||
[ados2.resultados.rrb_d1]
|
||||
etiqueta = "Interés sensorial inusual en los materiales de juego o en las personas"
|
||||
tipo_valor = "numero"
|
||||
unidad = "puntos"
|
||||
|
||||
[ados2.resultados.rrb_d2]
|
||||
etiqueta = "Manierismos de manos, dedos y otros manierismos complejos"
|
||||
tipo_valor = "numero"
|
||||
unidad = "puntos"
|
||||
|
||||
[ados2.resultados.rrb_d4]
|
||||
etiqueta = "Intereses inusualmente repetitivos o conductas estereotipadas"
|
||||
tipo_valor = "numero"
|
||||
unidad = "puntos"
|
||||
|
||||
[ados2.resultados.rrb_d5]
|
||||
etiqueta = "Reactivo D5"
|
||||
tipo_valor = "numero"
|
||||
unidad = "puntos"
|
||||
|
||||
[evaluacion_neuropediatrica]
|
||||
etiqueta = "Evaluación neuropediátrica"
|
||||
codigos_hospital = ["NEUROPEDIATRIA"]
|
||||
|
||||
[evaluacion_neuropediatrica.resultados.diagnostico]
|
||||
etiqueta = "Diagnóstico"
|
||||
tipo_valor = "externo"
|
||||
sistema = "CIE-10"
|
||||
|
||||
# Los datos de una orden (procedimiento con clase `orden`; su `estudio_id` es el estudio pedido, de
|
||||
# `codigos_hospital`). ADR-MD-007.
|
||||
# The EEG: what its analysis writes. On the recording (`toma`), the sleep, channels, duration, the five quality
|
||||
# criteria and each metric's measured value; on each electrode (`parte`, `codigo_fuente` the electrode), the metric's
|
||||
# z-score there, under the same result.
|
||||
[eeg]
|
||||
etiqueta = "Electroencefalograma"
|
||||
codigos_hospital = ["EEG"]
|
||||
|
||||
[eeg.resultados.con_sueno]
|
||||
etiqueta = "Registro con sueño"
|
||||
tipo_valor = "booleano"
|
||||
|
||||
[eeg.resultados.canales]
|
||||
etiqueta = "Canales"
|
||||
tipo_valor = "numero"
|
||||
unidad = "canales"
|
||||
|
||||
[eeg.resultados.duracion_min]
|
||||
etiqueta = "Duración del registro"
|
||||
tipo_valor = "numero"
|
||||
unidad = "min"
|
||||
|
||||
[eeg.resultados.calidad_amplitud]
|
||||
etiqueta = "Canales con amplitud extrema"
|
||||
tipo_valor = "numero"
|
||||
unidad = "canales"
|
||||
|
||||
[eeg.resultados.calidad_alta_frecuencia]
|
||||
etiqueta = "Ruido de alta frecuencia"
|
||||
tipo_valor = "numero"
|
||||
unidad = "canales"
|
||||
|
||||
[eeg.resultados.calidad_correlacion]
|
||||
etiqueta = "Baja correlación entre canales"
|
||||
tipo_valor = "numero"
|
||||
unidad = "canales"
|
||||
|
||||
[eeg.resultados.calidad_sin_senal]
|
||||
etiqueta = "Canales planos o sin señal"
|
||||
tipo_valor = "numero"
|
||||
unidad = "canales"
|
||||
|
||||
[eeg.resultados.calidad_linea]
|
||||
etiqueta = "Ruido de la línea eléctrica"
|
||||
tipo_valor = "numero"
|
||||
unidad = "dB"
|
||||
|
||||
[eeg.resultados.ritmo_posterior]
|
||||
etiqueta = "Ritmo posterior"
|
||||
tipo_valor = "numero"
|
||||
unidad = "Hz"
|
||||
|
||||
[eeg.resultados.husos_sueno_n2]
|
||||
etiqueta = "Husos de sueño N2"
|
||||
tipo_valor = "numero"
|
||||
unidad = "husos/min"
|
||||
|
||||
[eeg.resultados.husos_sueno_n3]
|
||||
etiqueta = "Husos de sueño N3"
|
||||
tipo_valor = "numero"
|
||||
unidad = "husos/min"
|
||||
|
||||
[eeg.resultados.picos_paroxisticos]
|
||||
etiqueta = "Picos paroxísticos"
|
||||
tipo_valor = "numero"
|
||||
unidad = "picos/min"
|
||||
|
||||
[eeg.resultados.gradiente_anteroposterior]
|
||||
etiqueta = "Gradiente anteroposterior"
|
||||
tipo_valor = "numero"
|
||||
unidad = "razón posterior/anterior"
|
||||
|
||||
# An order (procedure of class `orden`): its `estudio_id` is the study it asks for, from `codigos_hospital`.
|
||||
[orden]
|
||||
etiqueta = "Orden de estudio"
|
||||
|
||||
[orden.resultados.intencion]
|
||||
etiqueta = "Intención (FHIR intent)"
|
||||
tipo_valor = "texto"
|
||||
|
||||
[orden.resultados.fecha_realizacion]
|
||||
etiqueta = "Fecha de realización"
|
||||
tipo_valor = "fecha"
|
||||
|
||||
+31
-297
@@ -1,327 +1,61 @@
|
||||
"""Vocabularios controlados del proyecto TEA.
|
||||
"""Controlled vocabularies of TEA's staging (spec/tablas_TEA.md).
|
||||
|
||||
Capa Core: sin importaciones de infraestructura. Seguro de importar
|
||||
desde cualquier módulo de src/.
|
||||
|
||||
Generado desde spec/tablas_TEA.md. No editar a mano.
|
||||
Core layer: no infrastructure imports.
|
||||
"""
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class Parentesco(str, Enum):
|
||||
"""pac_parentesco in table pacientes."""
|
||||
HIJO = "HIJO"
|
||||
HIJA = "HIJA"
|
||||
HIJASTRO = "HIJASTRO"
|
||||
TUTELADO = "TUTELADO"
|
||||
OTRO = "OTRO"
|
||||
|
||||
|
||||
class SexoBiologico(str, Enum):
|
||||
"""pac_sexo in table pacientes."""
|
||||
F = "F"
|
||||
M = "M"
|
||||
I = "I"
|
||||
|
||||
|
||||
class Especialidad(str, Enum):
|
||||
"""ord_especialidad in table ordenes_estudio."""
|
||||
NEUROLOGIA_PEDIATRICA = "NEUROLOGIA_PEDIATRICA"
|
||||
PEDIATRIA = "PEDIATRIA"
|
||||
PSICOLOGIA = "PSICOLOGIA"
|
||||
PSIQUIATRIA_INFANTIL = "PSIQUIATRIA_INFANTIL"
|
||||
AUDIOLOGIA = "AUDIOLOGIA"
|
||||
MEDICINA_FAMILIAR = "MEDICINA_FAMILIAR"
|
||||
ENFERMERIA = "ENFERMERIA"
|
||||
OTRO = "OTRO"
|
||||
|
||||
|
||||
class TipoEstudio(str, Enum):
|
||||
"""ord_tipo_estudio in table ordenes_estudio."""
|
||||
ELECTROENCEFALOGRAMA = "ELECTROENCEFALOGRAMA"
|
||||
POTENCIALES_EVOCADOS_AUDITIVOS = "POTENCIALES_EVOCADOS_AUDITIVOS"
|
||||
EVALUACION_PSICOLOGICA_TEA = "EVALUACION_PSICOLOGICA_TEA"
|
||||
OTRO = "OTRO"
|
||||
ADOS2 = "ADOS2"
|
||||
NEUROPEDIATRIA = "NEUROPEDIATRIA"
|
||||
EEG = "EEG"
|
||||
|
||||
|
||||
# How the hospital writes each study, normalized (upper case, without accents) before it is looked up.
|
||||
TIPO_ESTUDIO_ALIAS: dict[str, str] = {
|
||||
"POTENCIALES_EVOCADOS": "POTENCIALES_EVOCADOS_AUDITIVOS",
|
||||
"POTENCIALES EVOCADOS": "POTENCIALES_EVOCADOS_AUDITIVOS",
|
||||
"POTENCIALES EVOCADOS AUDITIVOS": "POTENCIALES_EVOCADOS_AUDITIVOS",
|
||||
"EVALUACION PSICOLOGICA TEA": "EVALUACION_PSICOLOGICA_TEA",
|
||||
"EEG": "ELECTROENCEFALOGRAMA",
|
||||
"ADOS-2": "ADOS2",
|
||||
"ADOS 2": "ADOS2",
|
||||
"EVALUACION PSICOLOGICA": "ADOS2",
|
||||
"EVALUACION_PSICOLOGICA_TEA": "ADOS2",
|
||||
"NEUROLOGIA PEDIATRICA": "NEUROPEDIATRIA",
|
||||
"NEUROLOGIA_PEDIATRICA": "NEUROPEDIATRIA",
|
||||
"EVALUACION NEUROPEDIATRICA": "NEUROPEDIATRIA",
|
||||
"ELECTROENCEFALOGRAMA": "EEG",
|
||||
}
|
||||
|
||||
|
||||
class EstatusEstudio(str, Enum):
|
||||
"""ord_estatus in table ordenes_estudio."""
|
||||
SOLICITADO = "SOLICITADO"
|
||||
EN_PROCESO = "EN_PROCESO"
|
||||
REALIZADO = "REALIZADO"
|
||||
RESULTADO_DISPONIBLE = "RESULTADO_DISPONIBLE"
|
||||
CANCELADO = "CANCELADO"
|
||||
NO_ACUDIO = "NO_ACUDIO"
|
||||
|
||||
|
||||
class VentanaMadurativa(str, Enum):
|
||||
"""ord_ventana_madurativa in table ordenes_estudio."""
|
||||
V1_16_23 = "V1_16_23"
|
||||
V2_24_30 = "V2_24_30"
|
||||
V3_31_36 = "V3_31_36"
|
||||
FUERA_DE_RANGO = "FUERA_DE_RANGO"
|
||||
|
||||
|
||||
class TipoNota(str, Enum):
|
||||
"""nm_tipo_nota in table nota_medica."""
|
||||
PRIMERA_VEZ = "PRIMERA_VEZ"
|
||||
TAMIZAJE = "TAMIZAJE"
|
||||
INTERPRETACION_EEG = "INTERPRETACION_EEG"
|
||||
TRATAMIENTO = "TRATAMIENTO"
|
||||
SEGUIMIENTO = "SEGUIMIENTO"
|
||||
INTERCONSULTA = "INTERCONSULTA"
|
||||
URGENCIA = "URGENCIA"
|
||||
OTRO = "OTRO"
|
||||
|
||||
|
||||
class Pronostico(str, Enum):
|
||||
"""nm_pronostico in table nota_medica."""
|
||||
BUENO = "BUENO"
|
||||
RESERVADO = "RESERVADO"
|
||||
MALO = "MALO"
|
||||
NO_ESPECIFICADO = "NO_ESPECIFICADO"
|
||||
|
||||
|
||||
class InstrumentoTamizaje(str, Enum):
|
||||
"""psi_instrumento_tamizaje in table evaluacion_psicologica."""
|
||||
M_CHAT_R = "M_CHAT_R"
|
||||
M_CHAT_RF = "M_CHAT_RF"
|
||||
OTRO = "OTRO"
|
||||
NO_REGISTRADO = "NO_REGISTRADO"
|
||||
|
||||
|
||||
class NivelRiesgoTamizaje(str, Enum):
|
||||
"""psi_tamizaje_riesgo in table evaluacion_psicologica."""
|
||||
BAJO = "BAJO"
|
||||
MEDIO = "MEDIO"
|
||||
ALTO = "ALTO"
|
||||
NO_APLICA = "NO_APLICA"
|
||||
|
||||
|
||||
class ModuloAdos2(str, Enum):
|
||||
"""psi_ados2_modulo in table evaluacion_psicologica."""
|
||||
"""ado_modulo in table ados2."""
|
||||
TODDLER = "TODDLER"
|
||||
MODULO_1 = "MODULO_1"
|
||||
MODULO_2 = "MODULO_2"
|
||||
NO_REGISTRADO = "NO_REGISTRADO"
|
||||
MODULO_3 = "MODULO_3"
|
||||
|
||||
|
||||
class ClasificacionAdos2(str, Enum):
|
||||
"""psi_ados2_clasificacion in table evaluacion_psicologica."""
|
||||
NO_TEA = "NO_TEA"
|
||||
"""ado_clasificacion in table ados2."""
|
||||
NO_ESPECTRO = "NO_ESPECTRO"
|
||||
ESPECTRO_AUTISTA = "ESPECTRO_AUTISTA"
|
||||
AUTISMO = "AUTISMO"
|
||||
PREOCUPACION_LEVE_MODERADA = "PREOCUPACION_LEVE_MODERADA"
|
||||
PREOCUPACION_SEVERA = "PREOCUPACION_SEVERA"
|
||||
|
||||
|
||||
class GradoHipoacusia(str, Enum):
|
||||
"""pea_grado_hipoacusia in table potenciales_evocados_auditivos."""
|
||||
NORMAL = "NORMAL"
|
||||
LEVE = "LEVE"
|
||||
MODERADA = "MODERADA"
|
||||
SEVERA = "SEVERA"
|
||||
PROFUNDA = "PROFUNDA"
|
||||
NO_CONCLUYENTE = "NO_CONCLUYENTE"
|
||||
CLASIFICACION_ADOS2_ALIAS: dict[str, str] = {"NO_TEA": "NO_ESPECTRO", "NO ESPECTRO": "NO_ESPECTRO"}
|
||||
|
||||
|
||||
class ClasificacionEeg(str, Enum):
|
||||
"""eeg_clasificacion in table eeg_estudio."""
|
||||
SIN_REFERENCIA_AURICULAR = "SIN_REFERENCIA_AURICULAR"
|
||||
class MetricaEeg(str, Enum):
|
||||
"""met_codigo in table eeg_metrica."""
|
||||
RITMO_POSTERIOR = "RITMO_POSTERIOR"
|
||||
HUSOS_SUENO_N2 = "HUSOS_SUENO_N2"
|
||||
HUSOS_SUENO_N3 = "HUSOS_SUENO_N3"
|
||||
PICOS_PAROXISTICOS = "PICOS_PAROXISTICOS"
|
||||
GRADIENTE_ANTEROPOSTERIOR = "GRADIENTE_ANTEROPOSTERIOR"
|
||||
|
||||
|
||||
class EstadoSegmentoEeg(str, Enum):
|
||||
"""seg_estado in table eeg_segmento."""
|
||||
NO_MARCADO = "NO_MARCADO"
|
||||
OJOS_CERRADOS = "OJOS_CERRADOS"
|
||||
FOTOESTIMULACION = "FOTOESTIMULACION"
|
||||
SUENO = "SUENO"
|
||||
|
||||
|
||||
class FuenteSegmentoEeg(str, Enum):
|
||||
"""seg_fuente in table eeg_segmento."""
|
||||
SIN_ANOTACION = "SIN_ANOTACION"
|
||||
ANOTACION_TECNICO = "ANOTACION_TECNICO"
|
||||
TRIGGER_EQUIPO = "TRIGGER_EQUIPO"
|
||||
|
||||
|
||||
class FuenteInterpretacionEeg(str, Enum):
|
||||
"""eeg_fuente_interpretacion in table eeg_estudio."""
|
||||
REPORTE_NEUROPEDIATRIA = "REPORTE_NEUROPEDIATRIA"
|
||||
NOTA_MEDICA = "NOTA_MEDICA"
|
||||
AMBAS = "AMBAS"
|
||||
NINGUNA = "NINGUNA"
|
||||
|
||||
|
||||
class EstadoRegistroEeg(str, Enum):
|
||||
"""eeg_estado_registro in table eeg_estudio."""
|
||||
VIGILIA = "VIGILIA"
|
||||
SUENO_ESPONTANEO = "SUENO_ESPONTANEO"
|
||||
SUENO_INDUCIDO = "SUENO_INDUCIDO"
|
||||
MIXTO = "MIXTO"
|
||||
NO_ESPECIFICADO = "NO_ESPECIFICADO"
|
||||
|
||||
|
||||
class CalidadTecnicaEeg(str, Enum):
|
||||
"""eeg_calidad_tecnica in table eeg_estudio."""
|
||||
SATISFACTORIA = "SATISFACTORIA"
|
||||
LIMITADA_POR_ARTEFACTO = "LIMITADA_POR_ARTEFACTO"
|
||||
LIMITADA_POR_COLABORACION = "LIMITADA_POR_COLABORACION"
|
||||
NO_VALORABLE = "NO_VALORABLE"
|
||||
NO_ESPECIFICADA = "NO_ESPECIFICADA"
|
||||
|
||||
|
||||
class Simetria(str, Enum):
|
||||
"""eeg_simetria in table eeg_estudio."""
|
||||
SIMETRICO = "SIMETRICO"
|
||||
ASIMETRICO_IZQUIERDO = "ASIMETRICO_IZQUIERDO"
|
||||
ASIMETRICO_DERECHO = "ASIMETRICO_DERECHO"
|
||||
NO_ESPECIFICADA = "NO_ESPECIFICADA"
|
||||
|
||||
|
||||
class TipoGrafoelemento(str, Enum):
|
||||
"""eeg_tipo_grafoelemento in table eeg_estudio."""
|
||||
NINGUNO = "NINGUNO"
|
||||
ESPIGA = "ESPIGA"
|
||||
ONDA_AGUDA = "ONDA_AGUDA"
|
||||
COMPLEJO_ESPIGA_ONDA = "COMPLEJO_ESPIGA_ONDA"
|
||||
COMPLEJO_POLIESPIGA_ONDA = "COMPLEJO_POLIESPIGA_ONDA"
|
||||
PUNTA_ONDA_LENTA = "PUNTA_ONDA_LENTA"
|
||||
DESCARGA_RITMICA = "DESCARGA_RITMICA"
|
||||
OTRO = "OTRO"
|
||||
|
||||
|
||||
class DistribucionAnormalidad(str, Enum):
|
||||
"""eeg_distribucion_anormalidad in table eeg_estudio."""
|
||||
FOCAL = "FOCAL"
|
||||
MULTIFOCAL = "MULTIFOCAL"
|
||||
GENERALIZADA = "GENERALIZADA"
|
||||
LATERALIZADA = "LATERALIZADA"
|
||||
NO_ESPECIFICADA = "NO_ESPECIFICADA"
|
||||
|
||||
|
||||
class Lentificacion(str, Enum):
|
||||
"""eeg_lentificacion in table eeg_estudio."""
|
||||
NINGUNA = "NINGUNA"
|
||||
FOCAL = "FOCAL"
|
||||
GENERALIZADA = "GENERALIZADA"
|
||||
INTERMITENTE = "INTERMITENTE"
|
||||
|
||||
|
||||
class RespuestaFotoestimulacion(str, Enum):
|
||||
"""eeg_respuesta_fotoestimulacion in table eeg_estudio."""
|
||||
NORMAL = "NORMAL"
|
||||
RESPUESTA_FOTOPAROXISTICA = "RESPUESTA_FOTOPAROXISTICA"
|
||||
SIN_RESPUESTA = "SIN_RESPUESTA"
|
||||
NO_PRACTICADA = "NO_PRACTICADA"
|
||||
|
||||
|
||||
class ConclusionEeg(str, Enum):
|
||||
"""eeg_conclusion_categoria in table eeg_estudio."""
|
||||
NORMAL_PARA_LA_EDAD = "NORMAL_PARA_LA_EDAD"
|
||||
NORMAL_CON_VARIANTES = "NORMAL_CON_VARIANTES"
|
||||
ANORMAL_EPILEPTIFORME = "ANORMAL_EPILEPTIFORME"
|
||||
ANORMAL_NO_EPILEPTIFORME = "ANORMAL_NO_EPILEPTIFORME"
|
||||
ANORMAL_MIXTO = "ANORMAL_MIXTO"
|
||||
NO_CONCLUYENTE = "NO_CONCLUYENTE"
|
||||
|
||||
|
||||
class FuenteAntecedenteMaterno(str, Enum):
|
||||
"""amg_fuente_antecedente in table antecedentes_maternos_gestacion."""
|
||||
EXPEDIENTE_MATERNO = "EXPEDIENTE_MATERNO"
|
||||
INTERROGATORIO_NM11 = "INTERROGATORIO_NM11"
|
||||
AMBAS = "AMBAS"
|
||||
NO_LOCALIZADO = "NO_LOCALIZADO"
|
||||
|
||||
|
||||
class CategoriaPesoMaterno(str, Enum):
|
||||
"""amg_categoria_peso_materno in table antecedentes_maternos_gestacion."""
|
||||
BAJO_PESO = "BAJO_PESO"
|
||||
NORMAL = "NORMAL"
|
||||
SOBREPESO = "SOBREPESO"
|
||||
OBESIDAD_I = "OBESIDAD_I"
|
||||
OBESIDAD_II = "OBESIDAD_II"
|
||||
OBESIDAD_III = "OBESIDAD_III"
|
||||
NO_REGISTRADA = "NO_REGISTRADA"
|
||||
|
||||
|
||||
class TipoEmbarazo(str, Enum):
|
||||
"""amg_embarazo_multiple in table antecedentes_maternos_gestacion."""
|
||||
UNICO = "UNICO"
|
||||
GEMELAR = "GEMELAR"
|
||||
TRIPLE_O_MAS = "TRIPLE_O_MAS"
|
||||
NO_REGISTRADO = "NO_REGISTRADO"
|
||||
|
||||
|
||||
class TrastornoHipertensivoGestacion(str, Enum):
|
||||
"""amg_hipertension_preeclampsia in table antecedentes_maternos_gestacion."""
|
||||
NINGUNO = "NINGUNO"
|
||||
HIPERTENSION_GESTACIONAL = "HIPERTENSION_GESTACIONAL"
|
||||
PREECLAMPSIA = "PREECLAMPSIA"
|
||||
ECLAMPSIA = "ECLAMPSIA"
|
||||
SINDROME_HELLP = "SINDROME_HELLP"
|
||||
NO_REGISTRADO = "NO_REGISTRADO"
|
||||
|
||||
|
||||
class VolumenLiquidoAmniotico(str, Enum):
|
||||
"""amg_liquido_amniotico in table antecedentes_maternos_gestacion."""
|
||||
NORMAL = "NORMAL"
|
||||
OLIGOHIDRAMNIOS = "OLIGOHIDRAMNIOS"
|
||||
POLIHIDRAMNIOS = "POLIHIDRAMNIOS"
|
||||
NO_REGISTRADO = "NO_REGISTRADO"
|
||||
|
||||
|
||||
class FuenteAntecedenteNeonatal(str, Enum):
|
||||
"""pnn_fuente_antecedente in table parto_neonatal."""
|
||||
NOTA_RECIEN_NACIDO = "NOTA_RECIEN_NACIDO"
|
||||
NOTA_RESOLUCION_OBSTETRICA = "NOTA_RESOLUCION_OBSTETRICA"
|
||||
INTERROGATORIO_NM11 = "INTERROGATORIO_NM11"
|
||||
AMBAS = "AMBAS"
|
||||
NO_LOCALIZADA = "NO_LOCALIZADA"
|
||||
|
||||
|
||||
class TipoParto(str, Enum):
|
||||
"""pnn_tipo_parto in table parto_neonatal."""
|
||||
VAGINAL_ESPONTANEO = "VAGINAL_ESPONTANEO"
|
||||
VAGINAL_INSTRUMENTADO = "VAGINAL_INSTRUMENTADO"
|
||||
CESAREA_ELECTIVA = "CESAREA_ELECTIVA"
|
||||
CESAREA_URGENCIA = "CESAREA_URGENCIA"
|
||||
NO_REGISTRADO = "NO_REGISTRADO"
|
||||
|
||||
|
||||
class ComplicacionIntraparto(str, Enum):
|
||||
"""pnn_complicacion_tipo in table parto_neonatal."""
|
||||
NINGUNA = "NINGUNA"
|
||||
HIPOXIA = "HIPOXIA"
|
||||
ISQUEMIA = "ISQUEMIA"
|
||||
TRAUMA_OBSTETRICO = "TRAUMA_OBSTETRICO"
|
||||
CIRCULAR_DE_CORDON = "CIRCULAR_DE_CORDON"
|
||||
SUFRIMIENTO_FETAL_AGUDO = "SUFRIMIENTO_FETAL_AGUDO"
|
||||
OTRA = "OTRA"
|
||||
|
||||
|
||||
class ClasificacionEdadGestacional(str, Enum):
|
||||
"""pnn_clasificacion_eg in table parto_neonatal."""
|
||||
PRETERMINO_EXTREMO = "PRETERMINO_EXTREMO"
|
||||
MUY_PRETERMINO = "MUY_PRETERMINO"
|
||||
PRETERMINO_TARDIO = "PRETERMINO_TARDIO"
|
||||
TERMINO = "TERMINO"
|
||||
POSTERMINO = "POSTERMINO"
|
||||
NO_DETERMINADA = "NO_DETERMINADA"
|
||||
|
||||
|
||||
class TamanoParaEdadGestacional(str, Enum):
|
||||
"""pnn_tamano_para_eg in table parto_neonatal."""
|
||||
PEQUENO = "PEQUENO"
|
||||
ADECUADO = "ADECUADO"
|
||||
GRANDE = "GRANDE"
|
||||
NO_DETERMINADO = "NO_DETERMINADO"
|
||||
# The electrodes of the 10-20 system an electrode value can name (mel_electrodo).
|
||||
ELECTRODOS_10_20 = (
|
||||
"Fp1", "Fp2", "F7", "F3", "Fz", "F4", "F8", "T3", "C3", "Cz", "C4", "T4",
|
||||
"T5", "P3", "Pz", "P4", "T6", "O1", "O2",
|
||||
)
|
||||
|
||||
+133
-338
@@ -1,18 +1,52 @@
|
||||
"""TEA staging tables (data dictionary: spec/tablas_TEA.md).
|
||||
|
||||
Permissive storage: every domain field is optional so a load never rejects a
|
||||
row; booleans are INTEGER and enums TEXT. Coercion and validation happen in
|
||||
the import schemas (WebApi/webapi/imports/schemas/tea).
|
||||
One table per kind of study: the M-CHAT, the ADOS-2, the neuropediatrics note and the EEG, with the patients and
|
||||
the orders. The EEG's quality criteria, channels, duration, sleep, metrics and electrode values are written by the
|
||||
EEG analysis from the stored EDF.
|
||||
|
||||
Permissive storage: every domain field is optional so a load never rejects a row; booleans are INTEGER and enums
|
||||
TEXT. Coercion and validation happen in the import schemas (WebApi/webapi/imports/schemas/tea).
|
||||
"""
|
||||
import uuid
|
||||
from datetime import date, datetime
|
||||
from datetime import date
|
||||
from typing import Optional
|
||||
|
||||
import sqlalchemy as sa
|
||||
from sqlmodel import Field
|
||||
|
||||
from core.tea.base import TeaModel
|
||||
from core.columns import FileBlob, HOSPITAL_ID_LENGTH
|
||||
from core.tea.base import TeaModel
|
||||
|
||||
# The ADOS-2 items with an algorithm score: social affect (SA) and restricted and repetitive behaviour (RRB).
|
||||
ADOS2_ITEMS = (
|
||||
"sa_a2", "sa_a6", "sa_a7", "sa_a8", "sa_b1", "sa_b2", "sa_b3", "sa_b4", "sa_b5", "sa_b6", "sa_b7", "sa_b8",
|
||||
"sa_b9", "sa_b10", "sa_b11", "sa_b12", "sa_b13", "sa_b14", "sa_b15", "sa_b16b", "sa_b18",
|
||||
"rrb_a3", "rrb_a4", "rrb_a5", "rrb_d1", "rrb_d2", "rrb_d4", "rrb_d5",
|
||||
)
|
||||
|
||||
|
||||
def _uuid() -> str:
|
||||
return str(uuid.uuid4())
|
||||
|
||||
|
||||
def _id() -> Field:
|
||||
return Field(default_factory=_uuid, sa_column=sa.Column(sa.String(36), primary_key=True))
|
||||
|
||||
|
||||
def _text() -> Field:
|
||||
return Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
|
||||
|
||||
def _int() -> Field:
|
||||
return Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
|
||||
|
||||
def _float() -> Field:
|
||||
return Field(default=None, sa_column=sa.Column(sa.Float))
|
||||
|
||||
|
||||
def _date() -> Field:
|
||||
return Field(default=None, sa_column=sa.Column(sa.Date))
|
||||
|
||||
|
||||
class Pacientes(TeaModel, table=True):
|
||||
@@ -22,366 +56,127 @@ class Pacientes(TeaModel, table=True):
|
||||
default=None,
|
||||
sa_column=sa.Column(sa.Integer, primary_key=True, autoincrement=True),
|
||||
)
|
||||
pac_id_hospital: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
pac_id_titular: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
pac_parentesco: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
pac_fecha_nacimiento: Optional[date] = Field(default=None, sa_column=sa.Column(sa.Date))
|
||||
pac_sexo: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
pac_codigo_postal_vigente: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
pac_dependencia: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
pac_created_at: Optional[datetime] = Field(default=None, sa_column=sa.Column(sa.DateTime))
|
||||
pac_updated_at: Optional[datetime] = Field(default=None, sa_column=sa.Column(sa.DateTime))
|
||||
pac_fuente_sistema: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
pac_id_hospital: Optional[str] = _text()
|
||||
pac_fecha_nacimiento: Optional[date] = _date()
|
||||
|
||||
|
||||
class OrdenesEstudio(TeaModel, table=True):
|
||||
__tablename__ = "ordenes_estudio"
|
||||
|
||||
ord_id: Optional[str] = Field(
|
||||
default_factory=lambda: str(uuid.uuid4()),
|
||||
sa_column=sa.Column(sa.String(36), primary_key=True),
|
||||
)
|
||||
ord_pac_id: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
ord_nota_medica_id: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
# Bounded and indexed, unlike TEA's other unenforced Text references: it
|
||||
# is the natural key the import layer upserts/merges orders on.
|
||||
ord_id: Optional[str] = _id()
|
||||
ord_pac_id: Optional[int] = _int()
|
||||
# Bounded and indexed: the natural key the import layer merges orders on.
|
||||
ord_id_hospital: Optional[str] = Field(
|
||||
default=None, sa_column=sa.Column(sa.String(HOSPITAL_ID_LENGTH), index=True)
|
||||
)
|
||||
ord_fecha: Optional[date] = Field(default=None, sa_column=sa.Column(sa.Date))
|
||||
ord_medico_solicitante: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
ord_especialidad: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
ord_diagnostico_asignado: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
ord_cie_asignado: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
ord_dias_vigencia: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
ord_fecha_vencimiento: Optional[date] = Field(default=None, sa_column=sa.Column(sa.Date))
|
||||
ord_tipo_estudio: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
ord_estatus: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
ord_fecha_realizacion: Optional[date] = Field(default=None, sa_column=sa.Column(sa.Date))
|
||||
ord_fecha_resultado: Optional[date] = Field(default=None, sa_column=sa.Column(sa.Date))
|
||||
ord_dias_espera: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
ord_proveedor: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
ord_edad_meses: Optional[float] = Field(default=None, sa_column=sa.Column(sa.Float))
|
||||
ord_ventana_madurativa: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
ord_pdf_ruta: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
ord_observaciones: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
ord_created_at: Optional[datetime] = Field(default=None, sa_column=sa.Column(sa.DateTime))
|
||||
ord_updated_at: Optional[datetime] = Field(default=None, sa_column=sa.Column(sa.DateTime))
|
||||
ord_fuente_sistema: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
ord_tipo_estudio: Optional[str] = _text() # TipoEstudio: ADOS2, NEUROPEDIATRIA, EEG
|
||||
ord_fecha: Optional[date] = _date()
|
||||
|
||||
|
||||
class NotaMedica(TeaModel, table=True):
|
||||
__tablename__ = "nota_medica"
|
||||
class Mchat(TeaModel, table=True):
|
||||
__tablename__ = "mchat"
|
||||
|
||||
nm_id: Optional[str] = Field(
|
||||
default_factory=lambda: str(uuid.uuid4()),
|
||||
sa_column=sa.Column(sa.String(36), primary_key=True),
|
||||
)
|
||||
nm_pac_id: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
# Bounded and indexed, unlike TEA's other unenforced Text references: it
|
||||
# is the natural key the import layer upserts/merges notes on.
|
||||
nm_id_hospital: Optional[str] = Field(
|
||||
default=None, sa_column=sa.Column(sa.String(HOSPITAL_ID_LENGTH), index=True)
|
||||
)
|
||||
nm_nota_previa_id: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
nm_tipo_nota: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
nm_especialidad: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
nm_fecha: Optional[date] = Field(default=None, sa_column=sa.Column(sa.Date))
|
||||
nm_edad_meses: Optional[float] = Field(default=None, sa_column=sa.Column(sa.Float))
|
||||
nm_ventana_madurativa: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
nm_medico_tratante: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
nm_motivo_consulta: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
nm_interrogatorio: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
nm_regresion_referida: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
nm_antecedente_familiar_tea: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
nm_perimetro_cefalico: Optional[float] = Field(default=None, sa_column=sa.Column(sa.Float))
|
||||
nm_diagnostico_texto: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
nm_cie_codigo: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
nm_cie_descripcion: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
nm_tratamiento_texto: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
nm_receta: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
nm_plan_estudios: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
nm_pronostico: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
nm_observaciones: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
nm_masa_corporal: Optional[float] = Field(default=None, sa_column=sa.Column(sa.Float))
|
||||
nm_talla: Optional[float] = Field(default=None, sa_column=sa.Column(sa.Float))
|
||||
nm_imc_visita: Optional[float] = Field(default=None, sa_column=sa.Column(sa.Float))
|
||||
nm_frecuencia_cardiaca: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
nm_frecuencia_respiratoria: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
nm_presion_arterial_sistolica: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
nm_presion_arterial_diastolica: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
nm_temperatura: Optional[float] = Field(default=None, sa_column=sa.Column(sa.Float))
|
||||
nm_pdf_ruta: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
nm_created_at: Optional[datetime] = Field(default=None, sa_column=sa.Column(sa.DateTime))
|
||||
nm_updated_at: Optional[datetime] = Field(default=None, sa_column=sa.Column(sa.DateTime))
|
||||
nm_fuente_sistema: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
mch_id: Optional[str] = _id()
|
||||
mch_pac_id: Optional[int] = _int()
|
||||
mch_ord_id: Optional[str] = _text()
|
||||
mch_fecha: Optional[date] = _date()
|
||||
mch_puntaje: Optional[int] = _int() # 0 to 20
|
||||
|
||||
|
||||
class EvaluacionPsicologica(TeaModel, table=True):
|
||||
__tablename__ = "evaluacion_psicologica"
|
||||
class Ados2(TeaModel, table=True):
|
||||
__tablename__ = "ados2"
|
||||
|
||||
psi_id: Optional[str] = Field(
|
||||
default_factory=lambda: str(uuid.uuid4()),
|
||||
sa_column=sa.Column(sa.String(36), primary_key=True),
|
||||
)
|
||||
psi_ord_id: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
psi_pac_id: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
psi_fecha_entrevista_inicial: Optional[date] = Field(default=None, sa_column=sa.Column(sa.Date))
|
||||
psi_fecha_ados2: Optional[date] = Field(default=None, sa_column=sa.Column(sa.Date))
|
||||
psi_fecha_evaluacion: Optional[date] = Field(default=None, sa_column=sa.Column(sa.Date))
|
||||
psi_psicologo: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
psi_edad_meses: Optional[float] = Field(default=None, sa_column=sa.Column(sa.Float))
|
||||
psi_ventana_madurativa: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
psi_instrumento_tamizaje: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
psi_tamizaje_puntaje: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
psi_tamizaje_riesgo: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
psi_ados2_modulo: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
# ADOS-2 item columns (data dictionary, annex B); the valid range and which
|
||||
# items apply depend on psi_ados2_modulo.
|
||||
psi_ados2_sa_a2: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
psi_ados2_sa_a6: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
psi_ados2_sa_a7: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
psi_ados2_sa_a8: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
psi_ados2_sa_b1: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
psi_ados2_sa_b2: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
psi_ados2_sa_b3: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
psi_ados2_sa_b4: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
psi_ados2_sa_b5: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
psi_ados2_sa_b6: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
psi_ados2_sa_b7: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
psi_ados2_sa_b8: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
psi_ados2_sa_b9: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
psi_ados2_sa_b10: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
psi_ados2_sa_b11: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
psi_ados2_sa_b12: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
psi_ados2_sa_b13: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
psi_ados2_sa_b14: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
psi_ados2_sa_b15: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
psi_ados2_sa_b16b: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
psi_ados2_sa_b18: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
psi_ados2_rrb_a3: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
psi_ados2_rrb_a4: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
psi_ados2_rrb_a5: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
psi_ados2_rrb_d1: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
psi_ados2_rrb_d2: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
psi_ados2_rrb_d4: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
psi_ados2_rrb_d5: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
psi_ados2_sa: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
psi_ados2_rrb: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
psi_ados2_total: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
psi_ados2_css: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
psi_ados2_css_sa: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
psi_ados2_css_rrb: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
psi_ados2_clasificacion: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
psi_rgd: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
psi_cociente_desarrollo: Optional[float] = Field(default=None, sa_column=sa.Column(sa.Float))
|
||||
psi_css_umbral_aplicado: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
psi_caso_confirmado: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
psi_cars_total: Optional[float] = Field(default=None, sa_column=sa.Column(sa.Float))
|
||||
psi_otros_instrumentos: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
psi_regresion_desarrollo: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
psi_diagnostico_texto: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
psi_ocr_confianza: Optional[float] = Field(default=None, sa_column=sa.Column(sa.Float))
|
||||
psi_nlp_version: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
psi_created_at: Optional[datetime] = Field(default=None, sa_column=sa.Column(sa.DateTime))
|
||||
psi_updated_at: Optional[datetime] = Field(default=None, sa_column=sa.Column(sa.DateTime))
|
||||
ado_id: Optional[str] = _id()
|
||||
ado_pac_id: Optional[int] = _int()
|
||||
ado_ord_id: Optional[str] = _text()
|
||||
ado_fecha: Optional[date] = _date()
|
||||
ado_modulo: Optional[str] = _text()
|
||||
# Within a module the algorithm depends on the child's language level (item A1).
|
||||
ado_algoritmo: Optional[str] = _text()
|
||||
ado_css: Optional[int] = _int() # 1 to 10
|
||||
ado_clasificacion: Optional[str] = _text()
|
||||
# Item scores, 0 to 3. The domain subtotals and the total are sums of their algorithm scores.
|
||||
ado_sa_a2: Optional[int] = _int()
|
||||
ado_sa_a6: Optional[int] = _int()
|
||||
ado_sa_a7: Optional[int] = _int()
|
||||
ado_sa_a8: Optional[int] = _int()
|
||||
ado_sa_b1: Optional[int] = _int()
|
||||
ado_sa_b2: Optional[int] = _int()
|
||||
ado_sa_b3: Optional[int] = _int()
|
||||
ado_sa_b4: Optional[int] = _int()
|
||||
ado_sa_b5: Optional[int] = _int()
|
||||
ado_sa_b6: Optional[int] = _int()
|
||||
ado_sa_b7: Optional[int] = _int()
|
||||
ado_sa_b8: Optional[int] = _int()
|
||||
ado_sa_b9: Optional[int] = _int()
|
||||
ado_sa_b10: Optional[int] = _int()
|
||||
ado_sa_b11: Optional[int] = _int()
|
||||
ado_sa_b12: Optional[int] = _int()
|
||||
ado_sa_b13: Optional[int] = _int()
|
||||
ado_sa_b14: Optional[int] = _int()
|
||||
ado_sa_b15: Optional[int] = _int()
|
||||
ado_sa_b16b: Optional[int] = _int()
|
||||
ado_sa_b18: Optional[int] = _int()
|
||||
ado_rrb_a3: Optional[int] = _int()
|
||||
ado_rrb_a4: Optional[int] = _int()
|
||||
ado_rrb_a5: Optional[int] = _int()
|
||||
ado_rrb_d1: Optional[int] = _int()
|
||||
ado_rrb_d2: Optional[int] = _int()
|
||||
ado_rrb_d4: Optional[int] = _int()
|
||||
ado_rrb_d5: Optional[int] = _int()
|
||||
|
||||
|
||||
class PotencialesEvocadosAuditivos(TeaModel, table=True):
|
||||
__tablename__ = "potenciales_evocados_auditivos"
|
||||
class EvaluacionNeuropediatrica(TeaModel, table=True):
|
||||
__tablename__ = "evaluacion_neuropediatrica"
|
||||
|
||||
pea_id: Optional[str] = Field(
|
||||
default_factory=lambda: str(uuid.uuid4()),
|
||||
sa_column=sa.Column(sa.String(36), primary_key=True),
|
||||
)
|
||||
pea_ord_id: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
pea_pac_id: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
pea_fecha_estudio: Optional[date] = Field(default=None, sa_column=sa.Column(sa.Date))
|
||||
pea_medico_interpreta: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
pea_umbral_od: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
pea_umbral_oi: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
pea_latencia_v_od: Optional[float] = Field(default=None, sa_column=sa.Column(sa.Float))
|
||||
pea_latencia_v_oi: Optional[float] = Field(default=None, sa_column=sa.Column(sa.Float))
|
||||
pea_interpico_i_v_od: Optional[float] = Field(default=None, sa_column=sa.Column(sa.Float))
|
||||
pea_interpico_i_v_oi: Optional[float] = Field(default=None, sa_column=sa.Column(sa.Float))
|
||||
pea_grado_hipoacusia: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
pea_conclusion_texto: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
pea_flag_diferencial_auditivo: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
pea_ocr_confianza: Optional[float] = Field(default=None, sa_column=sa.Column(sa.Float))
|
||||
pea_created_at: Optional[datetime] = Field(default=None, sa_column=sa.Column(sa.DateTime))
|
||||
pea_updated_at: Optional[datetime] = Field(default=None, sa_column=sa.Column(sa.DateTime))
|
||||
neu_id: Optional[str] = _id()
|
||||
neu_pac_id: Optional[int] = _int()
|
||||
neu_ord_id: Optional[str] = _text()
|
||||
neu_fecha: Optional[date] = _date()
|
||||
neu_cie_codigo: Optional[str] = _text()
|
||||
|
||||
|
||||
class EegEstudio(TeaModel, table=True):
|
||||
__tablename__ = "eeg_estudio"
|
||||
class Eeg(TeaModel, table=True):
|
||||
__tablename__ = "eeg"
|
||||
|
||||
eeg_id: Optional[str] = Field(
|
||||
default_factory=lambda: str(uuid.uuid4()),
|
||||
sa_column=sa.Column(sa.String(36), primary_key=True),
|
||||
)
|
||||
eeg_ord_id: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
# The child's integer pac_id, like the other studies' `*_pac_id`: the
|
||||
# indicator kit links each EEG to its patient by this key.
|
||||
eeg_pac_id: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
eeg_reporte_disponible: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
eeg_fuente_interpretacion: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
eeg_fecha_nacimiento_archivo: Optional[date] = Field(default=None, sa_column=sa.Column(sa.Date))
|
||||
eeg_edad_meses: Optional[float] = Field(default=None, sa_column=sa.Column(sa.Float))
|
||||
eeg_fecha_estudio: Optional[date] = Field(default=None, sa_column=sa.Column(sa.Date))
|
||||
eeg_fecha_reporte: Optional[date] = Field(default=None, sa_column=sa.Column(sa.Date))
|
||||
eeg_dias_respuesta: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
eeg_medico_interpreta: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
eeg_estado_registro: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
eeg_privacion_sueno: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
eeg_sedacion: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
eeg_sedacion_farmaco: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
eeg_duracion_min: Optional[float] = Field(default=None, sa_column=sa.Column(sa.Float))
|
||||
eeg_calidad_tecnica: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
eeg_descripcion_senal: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
eeg_ritmo_base_frecuencia: Optional[float] = Field(default=None, sa_column=sa.Column(sa.Float))
|
||||
eeg_ritmo_base_amplitud: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
eeg_simetria: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
eeg_anormalidad_presente: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
eeg_actividad_epileptiforme: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
eeg_tipo_grafoelemento: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
eeg_distribucion_anormalidad: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
eeg_localizacion: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
eeg_activacion_sueno: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
eeg_lentificacion: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
eeg_crisis_registradas: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
eeg_respuesta_fotoestimulacion: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
eeg_conclusion_texto: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
eeg_conclusion_categoria: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
# Bounded and indexed (unlike TEA's other unenforced Text references):
|
||||
# it is the natural key multiple sources (a report PDF, the EDF file
|
||||
# itself) use to land in the same row, so the import layer upserts on it.
|
||||
eeg_id: Optional[str] = _id()
|
||||
eeg_pac_id: Optional[int] = _int()
|
||||
eeg_ord_id: Optional[str] = _text()
|
||||
# Bounded and indexed: the natural key several sources (a report, the EDF itself) land in the same row by.
|
||||
eeg_id_registro_laboratorio: Optional[str] = Field(
|
||||
default=None, sa_column=sa.Column(sa.String(HOSPITAL_ID_LENGTH), index=True)
|
||||
)
|
||||
eeg_pdf_ruta: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
eeg_ocr_confianza: Optional[float] = Field(default=None, sa_column=sa.Column(sa.Float))
|
||||
eeg_nlp_version: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
eeg_utilizable: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
eeg_estudio: Optional[bytes] = Field(default=None, sa_column=sa.Column(FileBlob))
|
||||
eeg_created_at: Optional[datetime] = Field(default=None, sa_column=sa.Column(sa.DateTime))
|
||||
eeg_updated_at: Optional[datetime] = Field(default=None, sa_column=sa.Column(sa.DateTime))
|
||||
eeg_fecha_estudio: Optional[date] = _date()
|
||||
# Written by the EEG analysis.
|
||||
eeg_con_sueno: Optional[int] = _int()
|
||||
eeg_canales: Optional[int] = _int()
|
||||
eeg_duracion_min: Optional[float] = _float()
|
||||
# Quality criteria: channels flagged by each one, and the line noise. An EEG is bad when any criterion is.
|
||||
eeg_canales_amplitud: Optional[int] = _int()
|
||||
eeg_canales_alta_frecuencia: Optional[int] = _int()
|
||||
eeg_canales_correlacion: Optional[int] = _int()
|
||||
eeg_canales_sin_senal: Optional[int] = _int()
|
||||
eeg_ruido_linea_db: Optional[float] = _float()
|
||||
eeg_estudio: Optional[bytes] = Field(default=None, sa_column=sa.Column(FileBlob)) # the EDF
|
||||
|
||||
|
||||
class EegSegmento(TeaModel, table=True):
|
||||
__tablename__ = "eeg_segmento"
|
||||
class EegMetrica(TeaModel, table=True):
|
||||
"""One metric the EEG analysis measured on an EEG. A null value is a metric that can't be evaluated."""
|
||||
|
||||
seg_id: Optional[str] = Field(
|
||||
default_factory=lambda: str(uuid.uuid4()),
|
||||
sa_column=sa.Column(sa.String(36), primary_key=True),
|
||||
)
|
||||
seg_eeg_id: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
seg_estado: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
seg_inicio_s: Optional[float] = Field(default=None, sa_column=sa.Column(sa.Float))
|
||||
seg_fin_s: Optional[float] = Field(default=None, sa_column=sa.Column(sa.Float))
|
||||
seg_duracion_s: Optional[float] = Field(default=None, sa_column=sa.Column(sa.Float))
|
||||
seg_fuente: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
seg_frecuencia_flash_hz: Optional[float] = Field(default=None, sa_column=sa.Column(sa.Float))
|
||||
seg_n_destellos: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
seg_cobertura: Optional[float] = Field(default=None, sa_column=sa.Column(sa.Float))
|
||||
seg_rms_uv: Optional[float] = Field(default=None, sa_column=sa.Column(sa.Float))
|
||||
seg_emg: Optional[float] = Field(default=None, sa_column=sa.Column(sa.Float))
|
||||
seg_p2p_max_uv: Optional[float] = Field(default=None, sa_column=sa.Column(sa.Float))
|
||||
__tablename__ = "eeg_metrica"
|
||||
|
||||
met_id: Optional[str] = _id()
|
||||
met_eeg_id: Optional[str] = _text()
|
||||
met_codigo: Optional[str] = _text() # MetricaEeg
|
||||
met_valor: Optional[float] = _float()
|
||||
|
||||
|
||||
class InstrumentoAplicado(TeaModel, table=True):
|
||||
__tablename__ = "instrumento_aplicado"
|
||||
class EegMetricaElectrodo(TeaModel, table=True):
|
||||
"""A metric's value at one electrode of the 10-20 system."""
|
||||
|
||||
ins_id: Optional[str] = Field(
|
||||
default_factory=lambda: str(uuid.uuid4()),
|
||||
sa_column=sa.Column(sa.String(36), primary_key=True),
|
||||
)
|
||||
ins_psi_id: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
ins_instrumento: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
ins_informante: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
ins_area: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
ins_interpretacion: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
__tablename__ = "eeg_metrica_electrodo"
|
||||
|
||||
|
||||
class AntecedentesMaternosGestacion(TeaModel, table=True):
|
||||
__tablename__ = "antecedentes_maternos_gestacion"
|
||||
|
||||
amg_id: Optional[str] = Field(
|
||||
default_factory=lambda: str(uuid.uuid4()),
|
||||
sa_column=sa.Column(sa.String(36), primary_key=True),
|
||||
)
|
||||
amg_pac_id: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
amg_id_madre_seudonimo: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
amg_fuente_antecedente: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
amg_flag_vinculo_verificado: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
amg_imc_pregestacional: Optional[float] = Field(default=None, sa_column=sa.Column(sa.Float))
|
||||
amg_categoria_peso_materno: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
amg_tabaquismo_gestacion: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
amg_acido_folico_preconcepcional: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
amg_intervalo_intergenesico_meses: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
amg_antecedente_aborto: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
amg_embarazo_multiple: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
amg_infeccion_gestacion: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
amg_infeccion_tipo: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
amg_infeccion_hospitalizacion: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
amg_diabetes_gestacional: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
amg_hipertension_preeclampsia: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
amg_hipotiroidismo: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
amg_hipertiroidismo: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
amg_incompatibilidad_rh: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
amg_crisis_convulsivas: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
amg_proceso_proinflamatorio: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
amg_enfermedad_autoinmune: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
amg_migrana: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
amg_asma: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
amg_hipoxia_materna: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
amg_estres_agudo: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
amg_trastorno_neurologico: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
amg_liquido_amniotico: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
amg_medicamentos_gestacion: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
amg_farmaco_riesgo_neurodesarrollo: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
amg_observaciones: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
amg_ocr_confianza: Optional[float] = Field(default=None, sa_column=sa.Column(sa.Float))
|
||||
amg_nlp_version: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
amg_created_at: Optional[datetime] = Field(default=None, sa_column=sa.Column(sa.DateTime))
|
||||
amg_updated_at: Optional[datetime] = Field(default=None, sa_column=sa.Column(sa.DateTime))
|
||||
amg_fuente_sistema: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
|
||||
|
||||
class PartoNeonatal(TeaModel, table=True):
|
||||
__tablename__ = "parto_neonatal"
|
||||
|
||||
pnn_id: Optional[str] = Field(
|
||||
default_factory=lambda: str(uuid.uuid4()),
|
||||
sa_column=sa.Column(sa.String(36), primary_key=True),
|
||||
)
|
||||
pnn_pac_id: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
pnn_fuente_antecedente: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
pnn_tipo_parto: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
pnn_complicaciones_intraparto: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
pnn_complicacion_tipo: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
pnn_peso_nacer_g: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
pnn_talla_nacer_cm: Optional[float] = Field(default=None, sa_column=sa.Column(sa.Float))
|
||||
pnn_perimetro_cefalico_nacer_cm: Optional[float] = Field(default=None, sa_column=sa.Column(sa.Float))
|
||||
pnn_edad_gestacional_sem: Optional[float] = Field(default=None, sa_column=sa.Column(sa.Float))
|
||||
pnn_clasificacion_eg: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
pnn_tamano_para_eg: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
pnn_peso_nacer_zscore: Optional[float] = Field(default=None, sa_column=sa.Column(sa.Float))
|
||||
pnn_apgar_1min: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
pnn_apgar_5min: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
pnn_ingreso_ucin: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
pnn_dias_ucin: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
pnn_encefalopatia_hipoxico_isquemica: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
pnn_hipotermia_nacer: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
pnn_hiperbilirrubinemia: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
pnn_fototerapia: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
pnn_hipoglucemia_neonatal: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
pnn_anoxia: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
pnn_sindrome_congenito: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
pnn_sindrome_congenito_desc: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
pnn_flag_riesgo_neonatal: Optional[int] = Field(default=None, sa_column=sa.Column(sa.Integer))
|
||||
pnn_observaciones: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
pnn_ocr_confianza: Optional[float] = Field(default=None, sa_column=sa.Column(sa.Float))
|
||||
pnn_nlp_version: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
pnn_created_at: Optional[datetime] = Field(default=None, sa_column=sa.Column(sa.DateTime))
|
||||
pnn_updated_at: Optional[datetime] = Field(default=None, sa_column=sa.Column(sa.DateTime))
|
||||
pnn_fuente_sistema: Optional[str] = Field(default=None, sa_column=sa.Column(sa.Text))
|
||||
mel_id: Optional[str] = _id()
|
||||
mel_met_id: Optional[str] = _text()
|
||||
mel_electrodo: Optional[str] = _text()
|
||||
mel_valor: Optional[float] = _float()
|
||||
|
||||
+58
-479
@@ -1,8 +1,12 @@
|
||||
# Diccionario de datos y reglas de validación — Proyecto TEA
|
||||
|
||||
Este documento describe la base de datos del proyecto. Para cada tabla se listan sus
|
||||
variables, el tipo de dato, la unidad (cuando aplica) y la validación que debe
|
||||
cumplir cada una.
|
||||
Este documento describe el staging del proyecto: una tabla por tipo de estudio (M-CHAT, ADOS-2, nota de
|
||||
neuropediatría y EEG), más los pacientes y las órdenes. Para cada tabla se listan sus variables, el tipo de dato,
|
||||
la unidad (cuando aplica) y la validación que cumple cada una al importarse. El almacenamiento es permisivo: todo
|
||||
campo es opcional y la validación ocurre en los esquemas de importación (`WebApi/webapi/imports/schemas/tea`).
|
||||
|
||||
Las columnas marcadas **(análisis del EEG)** las escribe el análisis del EEG a partir del EDF guardado: calidad,
|
||||
canales, duración, sueño, métricas y valores por electrodo.
|
||||
|
||||
---
|
||||
|
||||
@@ -12,27 +16,7 @@ cumplir cada una.
|
||||
|---|---|---|---|---|
|
||||
| `pac_id` | INTEGER, llave primaria, autoincremental | — | — | — |
|
||||
| `pac_id_hospital` | TEXT | — | — | — |
|
||||
| `pac_id_titular` | TEXT | — | — | — |
|
||||
| `pac_parentesco` | TEXT | — | Catálogo cerrado `Parentesco`: `HIJO, HIJA, HIJASTRO, TUTELADO, OTRO`. | — |
|
||||
| `pac_fecha_nacimiento` | DATE | — | No puede ser una fecha futura. | — |
|
||||
| `pac_sexo` | TEXT | — | Catálogo cerrado `SexoBiologico`: `F, M, I`. | — |
|
||||
| `pac_codigo_postal_vigente` | TEXT | — | Debe quedar en 5 dígitos numéricos exactos (se completa con ceros a la izquierda si llega con menos). | — |
|
||||
| `pac_dependencia` | TEXT | — | — | — |
|
||||
| `pac_created_at` | DATETIME | — | — | — |
|
||||
| `pac_updated_at` | DATETIME | — | — | — |
|
||||
| `pac_fuente_sistema` | TEXT | — | — | — |
|
||||
|
||||
Sin validaciones cruzadas.
|
||||
|
||||
`pac_id` cambió de `VARCHAR(36)` (UUID) a `INTEGER` autoincremental el
|
||||
2026-10-19, para que `indicadores_kit` pueda cargar su CDM directamente
|
||||
(`core.indicadores.comunes.PersonaBase.pac_id` es `int`; el ETL del kit,
|
||||
`tea/etl.py::a_persona`, pasa `paciente.pac_id` sin convertir). Todas las
|
||||
columnas `*_pac_id` de las demás tablas de este documento cambiaron con
|
||||
ella. `eeg_estudio.eeg_pac_id` pasó a INTEGER después (2026-10-29): el
|
||||
origen la trae y `indicadores_kit` liga cada EEG a su niño por esta llave. Reset de la cadena de Alembic a una
|
||||
sola migración base (rule 3), no una migración de `ALTER COLUMN`: no había
|
||||
datos reales en ninguna base de TEA todavía.
|
||||
|
||||
---
|
||||
|
||||
@@ -42,502 +26,97 @@ datos reales en ninguna base de TEA todavía.
|
||||
|---|---|---|---|---|
|
||||
| `ord_id` | VARCHAR(36), llave primaria | — | — | — |
|
||||
| `ord_pac_id` | INTEGER | — | — | → `pacientes.pac_id` |
|
||||
| `ord_nota_medica_id` | TEXT | — | — | → `nota_medica.nm_id` |
|
||||
| `ord_id_hospital` | VARCHAR(64), indexado | — | Llave natural para `on_conflict=upsert`/`merge` al importar órdenes de varias fuentes. | — |
|
||||
| `ord_id_hospital` | VARCHAR(64), indexado | — | Llave natural para unir órdenes de varias fuentes al importar. | — |
|
||||
| `ord_tipo_estudio` | TEXT | — | Catálogo `TipoEstudio`: `ADOS2, NEUROPEDIATRIA, EEG`. | — |
|
||||
| `ord_fecha` | DATE | — | No puede ser una fecha futura. | — |
|
||||
| `ord_medico_solicitante` | TEXT | — | — | — |
|
||||
| `ord_especialidad` | TEXT | — | Catálogo `Especialidad`: `NEUROLOGIA_PEDIATRICA, PEDIATRIA, PSICOLOGIA, PSIQUIATRIA_INFANTIL, AUDIOLOGIA, MEDICINA_FAMILIAR, ENFERMERIA, OTRO`. | — |
|
||||
| `ord_diagnostico_asignado` | TEXT | — | — | — |
|
||||
| `ord_cie_asignado` | TEXT | — | Formato CIE: una letra mayúscula, dos dígitos, y opcionalmente un punto con uno o dos dígitos más (ejemplo: `A09.1`). | — |
|
||||
| `ord_dias_vigencia` | INTEGER | días | Entre 1 y 365. | — |
|
||||
| `ord_fecha_vencimiento` | DATE | — | Ver validación cruzada. | — |
|
||||
| `ord_proveedor` | TEXT | — | — | — |
|
||||
| `ord_tipo_estudio` | TEXT | — | Catálogo `TipoEstudio`: `ELECTROENCEFALOGRAMA, POTENCIALES_EVOCADOS_AUDITIVOS, EVALUACION_PSICOLOGICA_TEA, OTRO`. | — |
|
||||
| `ord_estatus` | TEXT | — | Catálogo `EstatusEstudio`: `SOLICITADO, EN_PROCESO, REALIZADO, RESULTADO_DISPONIBLE, CANCELADO, NO_ACUDIO`. | — |
|
||||
| `ord_fecha_realizacion` | DATE | — | No puede ser una fecha futura. Ver validación cruzada. | — |
|
||||
| `ord_fecha_resultado` | DATE | — | No puede ser una fecha futura. Ver validación cruzada. | — |
|
||||
| `ord_dias_espera` | INTEGER | días | Entre 0 y 180. | — |
|
||||
| `ord_edad_meses` | FLOAT | meses | Entre 16.0 y 36.0. | — |
|
||||
| `ord_ventana_madurativa` | TEXT | — | Catálogo `VentanaMadurativa`: `V1_16_23, V2_24_30, V3_31_36, FUERA_DE_RANGO`. Ver validación cruzada. | — |
|
||||
| `ord_pdf_ruta` | TEXT | — | — | — |
|
||||
| `ord_observaciones` | TEXT | — | — | — |
|
||||
| `ord_created_at` | DATETIME | — | — | — |
|
||||
| `ord_updated_at` | DATETIME | — | — | — |
|
||||
| `ord_fuente_sistema` | TEXT | — | — | — |
|
||||
|
||||
**Validaciones cruzadas de `ordenes_estudio`:**
|
||||
- `ord_fecha_vencimiento` debe ser igual a `ord_fecha + ord_dias_vigencia` días, cuando ambos valores existen.
|
||||
- `ord_fecha_realizacion` no puede ser anterior a `ord_fecha`.
|
||||
- `ord_fecha_resultado` no puede ser anterior a `ord_fecha_realizacion`.
|
||||
- `ord_ventana_madurativa` debe corresponder a `ord_edad_meses` según la tabla de ventanas (Anexo A).
|
||||
|
||||
---
|
||||
|
||||
## 3. Tabla `nota_medica`
|
||||
## 3. Tabla `mchat`
|
||||
|
||||
| Variable | Tipo | Unidad | Validación | Llave foránea |
|
||||
|---|---|---|---|---|
|
||||
| `nm_id` | VARCHAR(36), llave primaria | — | — | — |
|
||||
| `nm_pac_id` | INTEGER | — | — | → `pacientes.pac_id` |
|
||||
| `nm_id_hospital` | VARCHAR(64), indexado | — | Llave natural para `on_conflict=upsert`/`merge` al importar notas de varias fuentes. | — |
|
||||
| `nm_nota_previa_id` | TEXT | — | — | → `nota_medica.nm_id` (autorreferencia: nota previa del mismo paciente) |
|
||||
| `nm_tipo_nota` | TEXT | — | Catálogo `TipoNota`: `PRIMERA_VEZ, TAMIZAJE, INTERPRETACION_EEG, TRATAMIENTO, SEGUIMIENTO, INTERCONSULTA, URGENCIA, OTRO`. | — |
|
||||
| `nm_especialidad` | TEXT | — | Catálogo `Especialidad` (mismo que `ord_especialidad`). | — |
|
||||
| `nm_fecha` | DATE | — | No puede ser una fecha futura. | — |
|
||||
| `nm_edad_meses` | FLOAT | meses | Entre 16.0 y 36.0. | — |
|
||||
| `nm_ventana_madurativa` | TEXT | — | Catálogo `VentanaMadurativa`. Ver validación cruzada. | — |
|
||||
| `nm_medico_tratante` | TEXT | — | — | — |
|
||||
| `nm_motivo_consulta` | TEXT | — | — | — |
|
||||
| `nm_interrogatorio` | TEXT | — | — | — |
|
||||
| `nm_regresion_referida` | BOOL | — | — | — |
|
||||
| `nm_antecedente_familiar_tea` | BOOL | — | — | — |
|
||||
| `nm_perimetro_cefalico` | FLOAT | cm | Entre 38.0 y 58.0. | — |
|
||||
| `nm_diagnostico_texto` | TEXT | — | — | — |
|
||||
| `nm_cie_codigo` | TEXT | — | Formato CIE: una letra mayúscula, dos dígitos, punto opcional con uno o dos dígitos más. | — |
|
||||
| `nm_cie_descripcion` | TEXT | — | — | — |
|
||||
| `nm_tratamiento_texto` | TEXT | — | — | — |
|
||||
| `nm_receta` | TEXT | — | — | — |
|
||||
| `nm_plan_estudios` | TEXT | — | — | — |
|
||||
| `nm_pronostico` | TEXT | — | Catálogo `Pronostico`: `BUENO, RESERVADO, MALO, NO_ESPECIFICADO`. | — |
|
||||
| `nm_observaciones` | TEXT | — | — | — |
|
||||
| `nm_masa_corporal` | FLOAT | kg | Entre 2.0 y 40.0. | — |
|
||||
| `nm_talla` | FLOAT | m | Entre 0.4 y 1.4. | — |
|
||||
| `nm_imc_visita` | FLOAT | kg/m² | Entre 5.0 y 40.0. Ver validación cruzada con peso y talla. | — |
|
||||
| `nm_frecuencia_cardiaca` | INTEGER | lpm | Entre 50 y 230. | — |
|
||||
| `nm_frecuencia_respiratoria` | INTEGER | rpm | Entre 10 y 80. | — |
|
||||
| `nm_presion_arterial_sistolica` | INTEGER | mmHg | Entre 45 y 160. Ver validación cruzada. | — |
|
||||
| `nm_presion_arterial_diastolica` | INTEGER | mmHg | Entre 25 y 110. Ver validación cruzada. | — |
|
||||
| `nm_temperatura` | FLOAT | °C | Entre 32.0 y 43.0. | — |
|
||||
| `nm_pdf_ruta` | TEXT | — | — | — |
|
||||
| `nm_created_at` | DATETIME | — | — | — |
|
||||
| `nm_updated_at` | DATETIME | — | — | — |
|
||||
| `nm_fuente_sistema` | TEXT | — | — | — |
|
||||
|
||||
**Validaciones cruzadas de `nota_medica`:**
|
||||
- La presión sistólica debe ser mayor que la diastólica.
|
||||
- `nm_imc_visita` debe ser aproximadamente igual a `nm_masa_corporal / nm_talla²` (tolerancia de 0.5).
|
||||
- `nm_ventana_madurativa` debe corresponder a `nm_edad_meses` (Anexo A).
|
||||
| `mch_id` | VARCHAR(36), llave primaria | — | — | — |
|
||||
| `mch_pac_id` | INTEGER | — | — | → `pacientes.pac_id` |
|
||||
| `mch_ord_id` | TEXT | — | Casi siempre nulo: el M-CHAT rara vez tiene orden. | → `ordenes_estudio.ord_id` |
|
||||
| `mch_fecha` | DATE | — | No puede ser una fecha futura. | — |
|
||||
| `mch_puntaje` | INTEGER | puntos | Entre 0 y 20. | — |
|
||||
|
||||
---
|
||||
|
||||
## 4. Tabla `evaluacion_psicologica`
|
||||
## 4. Tabla `ados2`
|
||||
|
||||
| Variable | Tipo | Unidad | Validación | Llave foránea |
|
||||
|---|---|---|---|---|
|
||||
| `psi_id` | VARCHAR(36), llave primaria | — | — | — |
|
||||
| `psi_ord_id` | TEXT | — | — | → `ordenes_estudio.ord_id` |
|
||||
| `psi_pac_id` | INTEGER | — | — | → `pacientes.pac_id` |
|
||||
| `psi_fecha_entrevista_inicial` | DATE | — | No puede ser una fecha futura. | — |
|
||||
| `psi_fecha_ados2` | DATE | — | No puede ser una fecha futura. La fecha en que se aplicó el ADOS-2, distinta de `psi_fecha_evaluacion`. | — |
|
||||
| `psi_fecha_evaluacion` | DATE | — | No puede ser una fecha futura. | — |
|
||||
| `psi_psicologo` | TEXT | — | — | — |
|
||||
| `psi_edad_meses` | FLOAT | meses | Entre 16.0 y 36.0. | — |
|
||||
| `psi_ventana_madurativa` | TEXT | — | Catálogo `VentanaMadurativa`. Ver validación cruzada. | — |
|
||||
| `psi_instrumento_tamizaje` | TEXT | — | Catálogo `InstrumentoTamizaje`: `M_CHAT_R, M_CHAT_RF, OTRO, NO_REGISTRADO`. | — |
|
||||
| `psi_tamizaje_puntaje` | INTEGER | — | Entre 0 y 20. | — |
|
||||
| `psi_tamizaje_riesgo` | TEXT | — | Catálogo `NivelRiesgoTamizaje`: `BAJO, MEDIO, ALTO, NO_APLICA`. | — |
|
||||
| `psi_ados2_modulo` | TEXT | — | Catálogo `ModuloAdos2`: `TODDLER, MODULO_1, MODULO_2, NO_REGISTRADO`. Define qué ítems del ADOS-2 aplican (Anexo B). | — |
|
||||
| `psi_ados2_sa` | INTEGER | — | Entre 0 y 30. Ver validación cruzada. | — |
|
||||
| `psi_ados2_rrb` | INTEGER | — | Entre 0 y 20. Ver validación cruzada. | — |
|
||||
| `psi_ados2_total` | INTEGER | — | Entre 0 y 50. Debe ser igual a `psi_ados2_sa + psi_ados2_rrb`. | — |
|
||||
| `psi_ados2_css` | INTEGER | — | Entre 1 y 10. | — |
|
||||
| `psi_ados2_css_sa` | INTEGER | — | Entre 1 y 10. | — |
|
||||
| `psi_ados2_css_rrb` | INTEGER | — | Entre 1 y 10. | — |
|
||||
| `psi_ados2_clasificacion` | TEXT | — | Catálogo `ClasificacionAdos2`: `NO_TEA, ESPECTRO_AUTISTA, AUTISMO, PREOCUPACION_LEVE_MODERADA, PREOCUPACION_SEVERA`. | — |
|
||||
| `psi_rgd` | BOOL | — | Ver validación cruzada (retraso global del desarrollo). | — |
|
||||
| `psi_cociente_desarrollo` | FLOAT | — | Entre 20.0 y 160.0. | — |
|
||||
| `psi_css_umbral_aplicado` | INTEGER | — | Entre 1 y 10. Ver validación cruzada. | — |
|
||||
| `psi_caso_confirmado` | BOOL | — | Ver validación cruzada. | — |
|
||||
| `psi_cars_total` | FLOAT | — | Entre 15.0 y 60.0. Solo válido a partir de los 24 meses (ver validación cruzada). | — |
|
||||
| `psi_otros_instrumentos` | TEXT | — | — | — |
|
||||
| `psi_regresion_desarrollo` | BOOL | — | — | — |
|
||||
| `psi_diagnostico_texto` | TEXT | — | — | — |
|
||||
| `psi_ocr_confianza` | FLOAT | — | Entre 0.0 y 1.0. | — |
|
||||
| `psi_nlp_version` | TEXT | — | — | — |
|
||||
| `psi_created_at` | DATETIME | — | — | — |
|
||||
| `psi_updated_at` | DATETIME | — | — | — |
|
||||
| `ado_id` | VARCHAR(36), llave primaria | — | — | — |
|
||||
| `ado_pac_id` | INTEGER | — | — | → `pacientes.pac_id` |
|
||||
| `ado_ord_id` | TEXT | — | — | → `ordenes_estudio.ord_id` |
|
||||
| `ado_fecha` | DATE | — | No puede ser una fecha futura. | — |
|
||||
| `ado_modulo` | TEXT | — | Catálogo `ModuloAdos2`: `TODDLER, MODULO_1, MODULO_2, MODULO_3`. | — |
|
||||
| `ado_algoritmo` | TEXT | — | El algoritmo del módulo, que depende del nivel de lenguaje (reactivo A1). | — |
|
||||
| `ado_css` | INTEGER | puntos | Entre 1 y 10. | — |
|
||||
| `ado_clasificacion` | TEXT | — | Catálogo `ClasificacionAdos2`: `NO_ESPECTRO, ESPECTRO_AUTISTA, AUTISMO, PREOCUPACION_LEVE_MODERADA, PREOCUPACION_SEVERA`. | — |
|
||||
| `ado_sa_a2` … `ado_sa_b18` (21) | INTEGER | puntos | Entre 0 y 3. Reactivos de afecto social. | — |
|
||||
| `ado_rrb_a3` … `ado_rrb_d5` (7) | INTEGER | puntos | Entre 0 y 3. Reactivos de comportamiento restringido y repetitivo. | — |
|
||||
|
||||
**Columnas de ítem del ADOS-2** (mismo tipo y patrón de validación que los puntajes enteros de arriba):
|
||||
|
||||
| Variable | Tipo | Unidad | Validación |
|
||||
|---|---|---|---|
|
||||
| `psi_ados2_sa_a2`, `psi_ados2_sa_a6`, `psi_ados2_sa_a7`, `psi_ados2_sa_a8`, `psi_ados2_sa_b1` … `psi_ados2_sa_b16b`, `psi_ados2_sa_b18` | INTEGER | — | Rango permitido según el módulo (Anexo B); fuera de rango se rechaza. |
|
||||
| `psi_ados2_rrb_a3`, `psi_ados2_rrb_a4`, `psi_ados2_rrb_a5`, `psi_ados2_rrb_d1`, `psi_ados2_rrb_d2`, `psi_ados2_rrb_d4`, `psi_ados2_rrb_d5` | INTEGER | — | Rango permitido según el módulo (Anexo B); fuera de rango se rechaza. |
|
||||
|
||||
El detalle exacto de rango por código y por módulo, la validación de completitud y
|
||||
la validación de pertenencia a módulo están en el **Anexo B**.
|
||||
|
||||
**Validaciones cruzadas de `evaluacion_psicologica`:**
|
||||
- `psi_ados2_total` debe ser igual a `psi_ados2_sa + psi_ados2_rrb`.
|
||||
- `psi_css_umbral_aplicado` debe ser 6 si `psi_rgd` es verdadero, y 5 si es falso.
|
||||
- `psi_caso_confirmado` debe ser igual a `psi_ados2_css >= psi_css_umbral_aplicado`.
|
||||
- `psi_cars_total` solo es válido si la ventana madurativa no es `V1_16_23` (la escala CARS aplica desde los 24 meses).
|
||||
- `psi_ventana_madurativa` debe corresponder a `psi_edad_meses` (Anexo A).
|
||||
- `psi_rgd` debe ser verdadero cuando `psi_cociente_desarrollo` es menor o igual a 75.0, y falso en caso contrario.
|
||||
|
||||
Las validaciones cruzadas propias del Anexo B (completitud y pertenencia a módulo) se
|
||||
suman a esta lista.
|
||||
Los subtotales por dominio y el total no se guardan: son sumas de los puntajes de algoritmo de los reactivos.
|
||||
|
||||
---
|
||||
|
||||
## 5. Tabla `potenciales_evocados_auditivos`
|
||||
## 5. Tabla `evaluacion_neuropediatrica`
|
||||
|
||||
| Variable | Tipo | Unidad | Validación | Llave foránea |
|
||||
|---|---|---|---|---|
|
||||
| `pea_id` | VARCHAR(36), llave primaria | — | — | — |
|
||||
| `pea_ord_id` | TEXT | — | — | → `ordenes_estudio.ord_id` |
|
||||
| `pea_pac_id` | INTEGER | — | — | → `pacientes.pac_id` |
|
||||
| `pea_fecha_estudio` | DATE | — | No puede ser una fecha futura. | — |
|
||||
| `pea_medico_interpreta` | TEXT | — | — | — |
|
||||
| `pea_umbral_od` | INTEGER | dB | Entre 0 y 120 (oído derecho). | — |
|
||||
| `pea_umbral_oi` | INTEGER | dB | Entre 0 y 120 (oído izquierdo). | — |
|
||||
| `pea_latencia_v_od` | FLOAT | ms | Entre 3.5 y 12.0. | — |
|
||||
| `pea_latencia_v_oi` | FLOAT | ms | Entre 3.5 y 12.0. | — |
|
||||
| `pea_interpico_i_v_od` | FLOAT | ms | Entre 2.0 y 8.0. | — |
|
||||
| `pea_interpico_i_v_oi` | FLOAT | ms | Entre 2.0 y 8.0. | — |
|
||||
| `pea_grado_hipoacusia` | TEXT | — | Catálogo `GradoHipoacusia`: `NORMAL, LEVE, MODERADA, SEVERA, PROFUNDA, NO_CONCLUYENTE`. | — |
|
||||
| `pea_conclusion_texto` | TEXT | — | — | — |
|
||||
| `pea_flag_diferencial_auditivo` | BOOL | — | Ver validación cruzada. | — |
|
||||
| `pea_ocr_confianza` | FLOAT | — | Entre 0.0 y 1.0. | — |
|
||||
| `pea_created_at` | DATETIME | — | — | — |
|
||||
| `pea_updated_at` | DATETIME | — | — | — |
|
||||
|
||||
**Validación cruzada de `potenciales_evocados_auditivos`:**
|
||||
- Si `pea_grado_hipoacusia` es `MODERADA`, `SEVERA` o `PROFUNDA`, entonces `pea_flag_diferencial_auditivo` debe ser verdadero.
|
||||
| `neu_id` | VARCHAR(36), llave primaria | — | — | — |
|
||||
| `neu_pac_id` | INTEGER | — | — | → `pacientes.pac_id` |
|
||||
| `neu_ord_id` | TEXT | — | — | → `ordenes_estudio.ord_id` |
|
||||
| `neu_fecha` | DATE | — | No puede ser una fecha futura. | — |
|
||||
| `neu_cie_codigo` | TEXT | — | Formato CIE-10: una letra, dos dígitos y opcionalmente un punto con uno o dos dígitos (`F84.0`). | — |
|
||||
|
||||
---
|
||||
|
||||
## 6. Tabla `eeg_estudio`
|
||||
## 6. Tabla `eeg`
|
||||
|
||||
| Variable | Tipo | Unidad | Validación | Llave foránea |
|
||||
|---|---|---|---|---|
|
||||
| `eeg_id` | VARCHAR(36), llave primaria | — | — | — |
|
||||
| `eeg_ord_id` | TEXT | — | — | → `ordenes_estudio.ord_id` |
|
||||
| `eeg_pac_id` | INTEGER | — | — | → `pacientes.pac_id` |
|
||||
| `eeg_reporte_disponible` | BOOL | — | Ver validación cruzada. | — |
|
||||
| `eeg_fuente_interpretacion` | TEXT | — | Catálogo `FuenteInterpretacionEeg`: `REPORTE_NEUROPEDIATRIA, NOTA_MEDICA, AMBAS, NINGUNA`. | — |
|
||||
| `eeg_fecha_nacimiento_archivo` | DATE | — | No puede ser una fecha futura. | — |
|
||||
| `eeg_edad_meses` | FLOAT | meses | Entre 16.0 y 36.0. | — |
|
||||
| `eeg_ord_id` | TEXT | — | — | → `ordenes_estudio.ord_id` |
|
||||
| `eeg_id_registro_laboratorio` | VARCHAR(64), indexado | — | Llave natural: el reporte y el EDF del mismo estudio caen en la misma fila. | — |
|
||||
| `eeg_fecha_estudio` | DATE | — | No puede ser una fecha futura. | — |
|
||||
| `eeg_fecha_reporte` | DATE | — | No puede ser una fecha futura. Ver validación cruzada. | — |
|
||||
| `eeg_dias_respuesta` | INTEGER | días | Entre 0 y 60. Ver validación cruzada. | — |
|
||||
| `eeg_medico_interpreta` | TEXT | — | — | — |
|
||||
| `eeg_estado_registro` | TEXT | — | Catálogo `EstadoRegistroEeg`: `VIGILIA, SUENO_ESPONTANEO, SUENO_INDUCIDO, MIXTO, NO_ESPECIFICADO`. | — |
|
||||
| `eeg_privacion_sueno` | BOOL | — | — | — |
|
||||
| `eeg_sedacion` | BOOL | — | Ver validación cruzada. | — |
|
||||
| `eeg_sedacion_farmaco` | TEXT | — | Ver validación cruzada. | — |
|
||||
| `eeg_duracion_min` | REAL | min | Entre 10 y 1440. | — |
|
||||
| `eeg_calidad_tecnica` | TEXT | — | Catálogo `CalidadTecnicaEeg`: `SATISFACTORIA, LIMITADA_POR_ARTEFACTO, LIMITADA_POR_COLABORACION, NO_VALORABLE, NO_ESPECIFICADA`. | — |
|
||||
| `eeg_descripcion_senal` | TEXT | — | — | — |
|
||||
| `eeg_ritmo_base_frecuencia` | FLOAT | Hz | Entre 2.0 y 14.0. | — |
|
||||
| `eeg_ritmo_base_amplitud` | INTEGER | µV | Entre 5 y 300. | — |
|
||||
| `eeg_simetria` | TEXT | — | Catálogo `Simetria`: `SIMETRICO, ASIMETRICO_IZQUIERDO, ASIMETRICO_DERECHO, NO_ESPECIFICADA`. | — |
|
||||
| `eeg_anormalidad_presente` | BOOL | — | Ver validación cruzada. | — |
|
||||
| `eeg_actividad_epileptiforme` | BOOL | — | Ver validación cruzada. | — |
|
||||
| `eeg_tipo_grafoelemento` | TEXT | — | Catálogo `TipoGrafoelemento`: `NINGUNO, ESPIGA, ONDA_AGUDA, COMPLEJO_ESPIGA_ONDA, COMPLEJO_POLIESPIGA_ONDA, PUNTA_ONDA_LENTA, DESCARGA_RITMICA, OTRO`. Ver validación cruzada. | — |
|
||||
| `eeg_distribucion_anormalidad` | TEXT | — | Catálogo `DistribucionAnormalidad`: `FOCAL, MULTIFOCAL, GENERALIZADA, LATERALIZADA, NO_ESPECIFICADA`. | — |
|
||||
| `eeg_localizacion` | TEXT | — | — | — |
|
||||
| `eeg_activacion_sueno` | BOOL | — | — | — |
|
||||
| `eeg_lentificacion` | TEXT | — | Catálogo `Lentificacion`: `NINGUNA, FOCAL, GENERALIZADA, INTERMITENTE`. | — |
|
||||
| `eeg_crisis_registradas` | BOOL | — | — | — |
|
||||
| `eeg_respuesta_fotoestimulacion` | TEXT | — | Catálogo `RespuestaFotoestimulacion`: `NORMAL, RESPUESTA_FOTOPAROXISTICA, SIN_RESPUESTA, NO_PRACTICADA`. | — |
|
||||
| `eeg_conclusion_texto` | TEXT | — | Ver validación cruzada. | — |
|
||||
| `eeg_conclusion_categoria` | TEXT | — | Catálogo `ConclusionEeg`: `NORMAL_PARA_LA_EDAD, NORMAL_CON_VARIANTES, ANORMAL_EPILEPTIFORME, ANORMAL_NO_EPILEPTIFORME, ANORMAL_MIXTO, NO_CONCLUYENTE`. Ver validación cruzada. | — |
|
||||
| `eeg_id_registro_laboratorio` | VARCHAR(64), indexado | — | Llave natural: un reporte en PDF y el archivo EDF del mismo estudio comparten este valor y se combinan en el mismo renglón al importar (`on_conflict=upsert`/`merge`). | — |
|
||||
| `eeg_pdf_ruta` | TEXT | — | — | — |
|
||||
| `eeg_ocr_confianza` | FLOAT | — | Entre 0.0 y 1.0. | — |
|
||||
| `eeg_nlp_version` | TEXT | — | — | — |
|
||||
| `eeg_utilizable` | BOOL | — | Si el estudio completo puede usarse para calcular indicadores; criterio de `indicadores_kit` (medida K06), no de esta capa. | — |
|
||||
| `eeg_estudio` | BLOB | — | Archivo European Data Format (`.edf`) del registro; se valida con `mne.io.read_raw_edf` (Enmienda). | — |
|
||||
| `eeg_created_at` | DATETIME | — | — | — |
|
||||
| `eeg_updated_at` | DATETIME | — | — | — |
|
||||
| `eeg_con_sueno` | INTEGER | — | 0 o 1. **(análisis del EEG)** | — |
|
||||
| `eeg_canales` | INTEGER | canales | Entre 1 y 256. **(análisis del EEG)** | — |
|
||||
| `eeg_duracion_min` | FLOAT | minutos | Mayor que 0. **(análisis del EEG)** | — |
|
||||
| `eeg_canales_amplitud` | INTEGER | canales | Mayor o igual que 0. Criterio de calidad. **(análisis del EEG)** | — |
|
||||
| `eeg_canales_alta_frecuencia` | INTEGER | canales | Mayor o igual que 0. Criterio de calidad. **(análisis del EEG)** | — |
|
||||
| `eeg_canales_correlacion` | INTEGER | canales | Mayor o igual que 0. Criterio de calidad. **(análisis del EEG)** | — |
|
||||
| `eeg_canales_sin_senal` | INTEGER | canales | Mayor o igual que 0. Criterio de calidad. **(análisis del EEG)** | — |
|
||||
| `eeg_ruido_linea_db` | FLOAT | dB | Mayor o igual que 0. Criterio de calidad. **(análisis del EEG)** | — |
|
||||
| `eeg_estudio` | BLOB (LONGBLOB en MySQL) | — | El archivo EDF. | — |
|
||||
|
||||
**Validaciones cruzadas de `eeg_estudio`:**
|
||||
- `eeg_fecha_reporte` no puede ser anterior a `eeg_fecha_estudio`.
|
||||
- `eeg_dias_respuesta` debe ser igual a la diferencia en días entre `eeg_fecha_reporte` y `eeg_fecha_estudio`.
|
||||
- Si `eeg_actividad_epileptiforme` es falso, `eeg_tipo_grafoelemento` debe quedar vacío o en `NINGUNO`.
|
||||
- Si `eeg_actividad_epileptiforme` es verdadero, `eeg_anormalidad_presente` debe ser verdadero.
|
||||
- Si `eeg_sedacion` es falso, `eeg_sedacion_farmaco` debe quedar vacío.
|
||||
- Si `eeg_reporte_disponible` es verdadero, `eeg_conclusion_texto` no puede quedar vacío.
|
||||
- Si `eeg_conclusion_categoria` es `NORMAL_PARA_LA_EDAD` o `NORMAL_CON_VARIANTES`, entonces `eeg_anormalidad_presente` debe ser falso.
|
||||
|
||||
`eeg_fecha_nacimiento_archivo` se llamaba `eeg_fecha_nacimiento_declarada`
|
||||
hasta el 2026-10-19: se renombró para que coincidiera con el nombre real
|
||||
de la columna en el hospital (confirmado por introspección directa de
|
||||
`hospital.eeg_estudio` vía el túnel) y con lo que lee
|
||||
`indicadores_kit.tea.mapeo.ligar_eegs` (la liga del EEG con el niño por
|
||||
fecha de nacimiento, ver `tea/mapeo.md`). Mismo nombre, no un campo
|
||||
nuevo.
|
||||
Un EEG es malo cuando cualquiera de sus criterios de calidad está fuera de su umbral; uno malo no tiene resultado y
|
||||
sus alteraciones no cuentan.
|
||||
|
||||
---
|
||||
|
||||
## 7. Tabla `antecedentes_maternos_gestacion`
|
||||
## 7. Tabla `eeg_metrica` **(análisis del EEG)**
|
||||
|
||||
| Variable | Tipo | Unidad | Validación | Llave foránea |
|
||||
|---|---|---|---|---|
|
||||
| `amg_id` | VARCHAR(36), llave primaria | — | — | — |
|
||||
| `amg_pac_id` | INTEGER | — | — | → `pacientes.pac_id` |
|
||||
| `amg_id_madre_seudonimo` | TEXT | — | Ver validación cruzada. | — |
|
||||
| `amg_fuente_antecedente` | TEXT | — | Catálogo `FuenteAntecedenteMaterno`: `EXPEDIENTE_MATERNO, INTERROGATORIO_NM11, AMBAS, NO_LOCALIZADO`. Ver validación cruzada. | — |
|
||||
| `amg_flag_vinculo_verificado` | BOOL | — | — | — |
|
||||
| `amg_imc_pregestacional` | FLOAT | kg/m² | Entre 12.0 y 70.0. Ver validación cruzada. | — |
|
||||
| `amg_categoria_peso_materno` | TEXT | — | Catálogo `CategoriaPesoMaterno`: `BAJO_PESO, NORMAL, SOBREPESO, OBESIDAD_I, OBESIDAD_II, OBESIDAD_III, NO_REGISTRADA`. Ver validación cruzada. | — |
|
||||
| `amg_tabaquismo_gestacion` | BOOL | — | — | — |
|
||||
| `amg_acido_folico_preconcepcional` | BOOL | — | — | — |
|
||||
| `amg_intervalo_intergenesico_meses` | INTEGER | meses | Entre 0 y 360. | — |
|
||||
| `amg_antecedente_aborto` | BOOL | — | — | — |
|
||||
| `amg_embarazo_multiple` | TEXT | — | Catálogo `TipoEmbarazo`: `UNICO, GEMELAR, TRIPLE_O_MAS, NO_REGISTRADO`. | — |
|
||||
| `amg_infeccion_gestacion` | BOOL | — | Ver validación cruzada. | — |
|
||||
| `amg_infeccion_tipo` | TEXT | — | Ver validación cruzada. | — |
|
||||
| `amg_infeccion_hospitalizacion` | BOOL | — | Ver validación cruzada. | — |
|
||||
| `amg_diabetes_gestacional` | BOOL | — | — | — |
|
||||
| `amg_hipertension_preeclampsia` | TEXT | — | Catálogo `TrastornoHipertensivoGestacion`: `NINGUNO, HIPERTENSION_GESTACIONAL, PREECLAMPSIA, ECLAMPSIA, SINDROME_HELLP, NO_REGISTRADO`. | — |
|
||||
| `amg_hipotiroidismo` | BOOL | — | — | — |
|
||||
| `amg_hipertiroidismo` | BOOL | — | — | — |
|
||||
| `amg_incompatibilidad_rh` | BOOL | — | — | — |
|
||||
| `amg_crisis_convulsivas` | BOOL | — | — | — |
|
||||
| `amg_proceso_proinflamatorio` | BOOL | — | — | — |
|
||||
| `amg_enfermedad_autoinmune` | BOOL | — | — | — |
|
||||
| `amg_migrana` | BOOL | — | — | — |
|
||||
| `amg_asma` | BOOL | — | — | — |
|
||||
| `amg_hipoxia_materna` | BOOL | — | — | — |
|
||||
| `amg_estres_agudo` | BOOL | — | — | — |
|
||||
| `amg_trastorno_neurologico` | BOOL | — | — | — |
|
||||
| `amg_liquido_amniotico` | TEXT | — | Catálogo `VolumenLiquidoAmniotico`: `NORMAL, OLIGOHIDRAMNIOS, POLIHIDRAMNIOS, NO_REGISTRADO`. | — |
|
||||
| `amg_medicamentos_gestacion` | TEXT | — | Ver validación cruzada. | — |
|
||||
| `amg_farmaco_riesgo_neurodesarrollo` | BOOL | — | Ver validación cruzada. | — |
|
||||
| `amg_observaciones` | TEXT | — | — | — |
|
||||
| `amg_ocr_confianza` | FLOAT | — | Entre 0.0 y 1.0. | — |
|
||||
| `amg_nlp_version` | TEXT | — | — | — |
|
||||
| `amg_created_at` | DATETIME | — | — | — |
|
||||
| `amg_updated_at` | DATETIME | — | — | — |
|
||||
| `amg_fuente_sistema` | TEXT | — | — | — |
|
||||
| `met_id` | VARCHAR(36), llave primaria | — | — | — |
|
||||
| `met_eeg_id` | TEXT | — | — | → `eeg.eeg_id` |
|
||||
| `met_codigo` | TEXT | — | Catálogo `MetricaEeg`: `RITMO_POSTERIOR, HUSOS_SUENO_N2, HUSOS_SUENO_N3, PICOS_PAROXISTICOS, GRADIENTE_ANTEROPOSTERIOR`. | — |
|
||||
| `met_valor` | FLOAT | la de la métrica | Nulo: la métrica no se puede evaluar (por ejemplo, husos sin registro de sueño). | — |
|
||||
|
||||
**Validaciones cruzadas de `antecedentes_maternos_gestacion`:**
|
||||
- Si `amg_fuente_antecedente` es `EXPEDIENTE_MATERNO` o `AMBAS`, `amg_id_madre_seudonimo` debe estar presente.
|
||||
- `amg_categoria_peso_materno` debe corresponder al valor de `amg_imc_pregestacional` (Anexo A).
|
||||
- Si `amg_infeccion_gestacion` es falso, `amg_infeccion_tipo` debe quedar vacío y `amg_infeccion_hospitalizacion` debe ser falso o vacío.
|
||||
- Si `amg_farmaco_riesgo_neurodesarrollo` es verdadero, `amg_medicamentos_gestacion` no puede quedar vacío.
|
||||
Solo se guarda el valor medido: el puntaje z y el estado salen de los rangos de referencia por grupo de edad.
|
||||
|
||||
---
|
||||
|
||||
## 8. Tabla `parto_neonatal`
|
||||
## 8. Tabla `eeg_metrica_electrodo` **(análisis del EEG)**
|
||||
|
||||
| Variable | Tipo | Unidad | Validación | Llave foránea |
|
||||
|---|---|---|---|---|
|
||||
| `pnn_id` | VARCHAR(36), llave primaria | — | — | — |
|
||||
| `pnn_pac_id` | INTEGER | — | — | → `pacientes.pac_id` |
|
||||
| `pnn_fuente_antecedente` | TEXT | — | Catálogo `FuenteAntecedenteNeonatal`: `NOTA_RECIEN_NACIDO, NOTA_RESOLUCION_OBSTETRICA, INTERROGATORIO_NM11, AMBAS, NO_LOCALIZADA`. | — |
|
||||
| `pnn_tipo_parto` | TEXT | — | Catálogo `TipoParto`: `VAGINAL_ESPONTANEO, VAGINAL_INSTRUMENTADO, CESAREA_ELECTIVA, CESAREA_URGENCIA, NO_REGISTRADO`. | — |
|
||||
| `pnn_complicaciones_intraparto` | BOOL | — | Ver validación cruzada. | — |
|
||||
| `pnn_complicacion_tipo` | TEXT | — | Catálogo `ComplicacionIntraparto`: `NINGUNA, HIPOXIA, ISQUEMIA, TRAUMA_OBSTETRICO, CIRCULAR_DE_CORDON, SUFRIMIENTO_FETAL_AGUDO, OTRA`. Ver validación cruzada. | — |
|
||||
| `pnn_peso_nacer_g` | INTEGER | g | Entre 400 y 6000. | — |
|
||||
| `pnn_talla_nacer_cm` | FLOAT | cm | Entre 25.0 y 60.0. | — |
|
||||
| `pnn_perimetro_cefalico_nacer_cm` | FLOAT | cm | Entre 25.0 y 42.0. | — |
|
||||
| `pnn_edad_gestacional_sem` | FLOAT | semanas | Entre 22.0 y 43.0. | — |
|
||||
| `pnn_clasificacion_eg` | TEXT | — | Catálogo `ClasificacionEdadGestacional`: `PRETERMINO_EXTREMO, MUY_PRETERMINO, PRETERMINO_TARDIO, TERMINO, POSTERMINO, NO_DETERMINADA`. Ver validación cruzada. | — |
|
||||
| `pnn_tamano_para_eg` | TEXT | — | Catálogo `TamanoParaEdadGestacional`: `PEQUENO, ADECUADO, GRANDE, NO_DETERMINADO`. | — |
|
||||
| `pnn_peso_nacer_zscore` | FLOAT | — | Entre -5.0 y 5.0. | — |
|
||||
| `pnn_apgar_1min` | INTEGER | — | Entre 0 y 10. Ver validación cruzada. | — |
|
||||
| `pnn_apgar_5min` | INTEGER | — | Entre 0 y 10. Ver validación cruzada. | — |
|
||||
| `pnn_ingreso_ucin` | BOOL | — | Ver validación cruzada. | — |
|
||||
| `pnn_dias_ucin` | INTEGER | días | Entre 0 y 365. Ver validación cruzada. | — |
|
||||
| `pnn_encefalopatia_hipoxico_isquemica` | BOOL | — | — | — |
|
||||
| `pnn_hipotermia_nacer` | BOOL | — | — | — |
|
||||
| `pnn_hiperbilirrubinemia` | BOOL | — | Ver validación cruzada. | — |
|
||||
| `pnn_fototerapia` | BOOL | — | Ver validación cruzada. | — |
|
||||
| `pnn_hipoglucemia_neonatal` | BOOL | — | — | — |
|
||||
| `pnn_anoxia` | BOOL | — | — | — |
|
||||
| `pnn_sindrome_congenito` | BOOL | — | Ver validación cruzada. | — |
|
||||
| `pnn_sindrome_congenito_desc` | TEXT | — | Ver validación cruzada. | — |
|
||||
| `pnn_flag_riesgo_neonatal` | BOOL | — | Ver validación cruzada. | — |
|
||||
| `pnn_observaciones` | TEXT | — | — | — |
|
||||
| `pnn_ocr_confianza` | FLOAT | — | Entre 0.0 y 1.0. | — |
|
||||
| `pnn_nlp_version` | TEXT | — | — | — |
|
||||
| `pnn_created_at` | DATETIME | — | — | — |
|
||||
| `pnn_updated_at` | DATETIME | — | — | — |
|
||||
| `pnn_fuente_sistema` | TEXT | — | — | — |
|
||||
|
||||
**Validaciones cruzadas de `parto_neonatal`:**
|
||||
- `pnn_clasificacion_eg` debe corresponder a `pnn_edad_gestacional_sem` (Anexo A).
|
||||
- `pnn_apgar_5min` no puede ser menor que `pnn_apgar_1min`.
|
||||
- Si `pnn_dias_ucin` es mayor que 0, `pnn_ingreso_ucin` debe ser verdadero.
|
||||
- Si `pnn_fototerapia` es verdadero, `pnn_hiperbilirrubinemia` debe ser verdadero.
|
||||
- Si `pnn_complicaciones_intraparto` es falso, `pnn_complicacion_tipo` debe quedar vacío o en `NINGUNA`.
|
||||
- Si `pnn_sindrome_congenito` es falso, `pnn_sindrome_congenito_desc` debe quedar vacío.
|
||||
- `pnn_flag_riesgo_neonatal` debe ser verdadero si se cumple al menos una de estas cuatro condiciones: `pnn_apgar_5min < 7`, `pnn_ingreso_ucin` verdadero, `pnn_encefalopatia_hipoxico_isquemica` verdadero, o `pnn_anoxia` verdadero. Si no se cumple ninguna, debe ser falso.
|
||||
|
||||
---
|
||||
|
||||
## 9. Tabla `eeg_segmento`
|
||||
|
||||
Añadida 2026-10-19, junto con `eeg_utilizable` e `instrumento_aplicado`,
|
||||
para que `indicadores_kit` pueda calcular sus indicadores TEA (el campo
|
||||
que falta en su `tea/etl.py`/`tea/mapeo.py`, confirmado leyendo el fork).
|
||||
Una fila por segmento de un estudio de EEG (por ejemplo, el tramo de
|
||||
fotoestimulación o el tramo de sueño dentro del registro). Solo
|
||||
`seg_eeg_id`, `seg_estado` y `seg_duracion_s` los lee el kit hoy (K7, K8);
|
||||
el resto queda sin mapear pero existe en la fuente real (confirmado
|
||||
contra `hospital.eeg_segmento` en el espejo MySQL del hospital).
|
||||
|
||||
| Variable | Tipo | Unidad | Validación | Llave foránea |
|
||||
|---|---|---|---|---|
|
||||
| `seg_id` | VARCHAR(36), llave primaria | — | — | — |
|
||||
| `seg_eeg_id` | TEXT | — | — | → `eeg_estudio.eeg_id` |
|
||||
| `seg_estado` | TEXT | — | Código del segmento, por ejemplo `FOTOESTIMULACION` o `SUENO`. | — |
|
||||
| `seg_inicio_s` | FLOAT | s | — | — |
|
||||
| `seg_fin_s` | FLOAT | s | — | — |
|
||||
| `seg_duracion_s` | FLOAT | s | — | — |
|
||||
| `seg_fuente` | TEXT | — | — | — |
|
||||
| `seg_frecuencia_flash_hz` | FLOAT | Hz | — | — |
|
||||
| `seg_n_destellos` | INTEGER | — | — | — |
|
||||
| `seg_cobertura` | FLOAT | — | — | — |
|
||||
| `seg_rms_uv` | FLOAT | µV | — | — |
|
||||
| `seg_emg` | FLOAT | — | — | — |
|
||||
| `seg_p2p_max_uv` | FLOAT | µV | — | — |
|
||||
|
||||
---
|
||||
|
||||
## 10. Tabla `instrumento_aplicado`
|
||||
|
||||
Añadida 2026-10-19, ver nota de `eeg_segmento`. Una fila por instrumento
|
||||
aplicado dentro de una evaluación psicológica (por ejemplo, un
|
||||
cuestionario a un informante distinto del niño).
|
||||
|
||||
| Variable | Tipo | Unidad | Validación | Llave foránea |
|
||||
|---|---|---|---|---|
|
||||
| `ins_id` | VARCHAR(36), llave primaria | — | — | — |
|
||||
| `ins_psi_id` | TEXT | — | Puede ser nulo: el kit no lo exige. | → `evaluacion_psicologica.psi_id` |
|
||||
| `ins_instrumento` | TEXT | — | Código del instrumento. | — |
|
||||
| `ins_informante` | TEXT | — | Código de quién lo respondió. | — |
|
||||
| `ins_area` | TEXT | — | Código del área evaluada. | — |
|
||||
| `ins_interpretacion` | TEXT | — | Código de la interpretación. | — |
|
||||
|
||||
---
|
||||
|
||||
## Anexo A — Funciones de referencia usadas en varias validaciones cruzadas
|
||||
|
||||
**Ventana madurativa según edad en meses** (usada en `ordenes_estudio`, `nota_medica`, `evaluacion_psicologica`):
|
||||
|
||||
| Edad en meses | Ventana |
|
||||
|---|---|
|
||||
| 16.0 a 23.9 | `V1_16_23` |
|
||||
| 24.0 a 30.9 | `V2_24_30` |
|
||||
| 31.0 a 36.0 | `V3_31_36` |
|
||||
| Cualquier otro valor | `FUERA_DE_RANGO` |
|
||||
|
||||
**Categoría de peso materno según IMC pregestacional** (usada en `antecedentes_maternos_gestacion`, clasificación estándar de adultos de la OMS):
|
||||
|
||||
| IMC (kg/m²) | Categoría |
|
||||
|---|---|
|
||||
| Menor a 18.5 | `BAJO_PESO` |
|
||||
| 18.5 a 24.9 | `NORMAL` |
|
||||
| 25.0 a 29.9 | `SOBREPESO` |
|
||||
| 30.0 a 34.9 | `OBESIDAD_I` |
|
||||
| 35.0 a 39.9 | `OBESIDAD_II` |
|
||||
| 40.0 o más | `OBESIDAD_III` |
|
||||
|
||||
**Clasificación por edad gestacional al nacer** (usada en `parto_neonatal`):
|
||||
|
||||
| Semanas de gestación | Clasificación |
|
||||
|---|---|
|
||||
| Menos de 28.0 | `PRETERMINO_EXTREMO` |
|
||||
| 28.0 a 31.9 | `MUY_PRETERMINO` |
|
||||
| 32.0 a 36.9 | `PRETERMINO_TARDIO` |
|
||||
| 37.0 a 41.9 | `TERMINO` |
|
||||
| 42.0 o más | `POSTERMINO` |
|
||||
|
||||
---
|
||||
|
||||
## Anexo B — Validación de los códigos del ADOS-2 (`evaluacion_psicologica`)
|
||||
|
||||
El campo `psi_ados2_modulo` fija qué módulo del ADOS-2 se aplicó al paciente. Cada
|
||||
módulo usa un subconjunto distinto de códigos, dentro de los dos dominios que ya
|
||||
existen como columnas agregadas: `SA` (Interacción social recíproca / comunicación) y
|
||||
`RRB` (Conductas restringidas y repetitivas). Equivalencia entre el catálogo
|
||||
`ModuloAdos2` y los módulos del manual: `TODDLER` = Módulo T, `MODULO_1` = Módulo 1,
|
||||
`MODULO_2` = Módulo 2.
|
||||
|
||||
### B.1 Rango válido de cada código, por módulo
|
||||
|
||||
| Código | Dominio | Módulo T | Módulo 1 | Módulo 2 |
|
||||
|---|---|---|---|---|
|
||||
| a2 | SA | 0–3 | 0–3 | — |
|
||||
| a6 | SA | — | — | 0–3 |
|
||||
| a7 | SA | 0–3 | 0–3 | 0–3, 8 |
|
||||
| a8 | SA | 0–3, 8 | 0–2, 8 | — |
|
||||
| b1 | SA | 0–3 | 0, 2 | 0, 2 |
|
||||
| b2 | SA | — | — | 0–2 |
|
||||
| b3 | SA | — | 0–2 | 0–3 |
|
||||
| b4 | SA | 0–3 | 0–3 | — |
|
||||
| b5 | SA | 0–3 | 0–3 | 0–2 |
|
||||
| b6 | SA | 0–3 | — | 0–2 |
|
||||
| b7 | SA | 0–3 | — | — |
|
||||
| b8 | SA | 0–3 | — | 0–3 |
|
||||
| b9 | SA | 0–3 | 0–2 | — |
|
||||
| b10 | SA | — | 0–2 | — |
|
||||
| b11 | SA | — | 0–3 | 0–3 |
|
||||
| b12 | SA | 0–3 | 0–3 | 0–3 |
|
||||
| b13 | SA | 0–3 | — | — |
|
||||
| b14 | SA | 0–3 | — | — |
|
||||
| b15 | SA | 0–3 | — | — |
|
||||
| b16b | SA | 0–3, 7, 8 | — | — |
|
||||
| b18 | SA | 0–3 | — | — |
|
||||
| a3 | RRB | 0–3, 8 | 0–2, 8 | — |
|
||||
| a4 | RRB | — | — | 0–3 |
|
||||
| a5 | RRB | — | 0–3, 8 | — |
|
||||
| d1 | RRB | 0–3 | 0–3 | 0–3 |
|
||||
| d2 | RRB | 0–3 | 0–3 | 0–3 |
|
||||
| d4 | RRB | — | 0–3 | 0–3 |
|
||||
| d5 | RRB | 0–3 | — | — |
|
||||
|
||||
Nota de lectura: "0–3, 8" significa que, además de los valores enteros 0 a 3, el
|
||||
manual permite el código adicional 8 en ese ítem y módulo. Una celda con "—" quiere
|
||||
decir que ese código no existe para ese módulo (ver regla de pertenencia, B.3).
|
||||
|
||||
**Validación de rango por código:** si la columna correspondiente al código no está
|
||||
vacía, su valor debe ser un entero dentro del conjunto permitido para el módulo
|
||||
indicado en `psi_ados2_modulo`. Cualquier valor fuera del conjunto (incluido un
|
||||
entero "razonable" pero no listado, como un 4 donde el máximo es 3) se rechaza.
|
||||
|
||||
### B.2 Validación de completitud del módulo
|
||||
|
||||
Todos los códigos que pertenecen al módulo indicado en `psi_ados2_modulo` (columna
|
||||
correspondiente en la tabla de B.1) deben tener un valor, es decir, no pueden quedar
|
||||
vacíos. Si al menos uno de los códigos propios del módulo está vacío, el renglón se
|
||||
considera incompleto y se rechaza.
|
||||
|
||||
Ejemplo: si `psi_ados2_modulo = MODULO_1`, deben estar llenas las columnas
|
||||
`psi_ados2_sa_a2, sa_a7, sa_a8, sa_b1, sa_b3, sa_b4, sa_b5, sa_b9, sa_b10, sa_b11,
|
||||
sa_b12, rrb_a3, rrb_a5, rrb_d1, rrb_d2, rrb_d4`.
|
||||
|
||||
### B.3 Validación de pertenencia a módulo
|
||||
|
||||
Los códigos que **no** pertenecen al módulo indicado (celda "—" en B.1 para ese
|
||||
módulo) deben quedar vacíos. Si alguno de esos códigos trae un valor, el renglón se
|
||||
rechaza, porque ese código no corresponde a la versión de la prueba aplicada.
|
||||
|
||||
Ejemplo: si `psi_ados2_modulo = TODDLER`, las columnas `psi_ados2_sa_b2,
|
||||
sa_b3, sa_b10, sa_b11, rrb_a4, rrb_a5, rrb_d4` (propias de otros módulos) deben
|
||||
quedar vacías.
|
||||
|
||||
---
|
||||
|
||||
## Anexo C — Llaves foráneas (resumen)
|
||||
|
||||
| Columna | Tabla y columna referenciada |
|
||||
|---|---|
|
||||
| `ordenes_estudio.ord_pac_id` | `pacientes.pac_id` |
|
||||
| `ordenes_estudio.ord_nota_medica_id` | `nota_medica.nm_id` |
|
||||
| `nota_medica.nm_pac_id` | `pacientes.pac_id` |
|
||||
| `nota_medica.nm_nota_previa_id` | `nota_medica.nm_id` (autorreferencia) |
|
||||
| `evaluacion_psicologica.psi_ord_id` | `ordenes_estudio.ord_id` |
|
||||
| `evaluacion_psicologica.psi_pac_id` | `pacientes.pac_id` |
|
||||
| `potenciales_evocados_auditivos.pea_ord_id` | `ordenes_estudio.ord_id` |
|
||||
| `potenciales_evocados_auditivos.pea_pac_id` | `pacientes.pac_id` |
|
||||
| `eeg_estudio.eeg_ord_id` | `ordenes_estudio.ord_id` |
|
||||
| `eeg_estudio.eeg_pac_id` | `pacientes.pac_id` |
|
||||
| `antecedentes_maternos_gestacion.amg_pac_id` | `pacientes.pac_id` |
|
||||
| `parto_neonatal.pnn_pac_id` | `pacientes.pac_id` |
|
||||
| `eeg_segmento.seg_eeg_id` | `eeg_estudio.eeg_id` |
|
||||
| `instrumento_aplicado.ins_psi_id` | `evaluacion_psicologica.psi_id` |
|
||||
| `mel_id` | VARCHAR(36), llave primaria | — | — | — |
|
||||
| `mel_met_id` | TEXT | — | — | → `eeg_metrica.met_id` |
|
||||
| `mel_electrodo` | TEXT | — | Un electrodo del sistema 10-20 (`Fp1` … `O2`). | — |
|
||||
| `mel_valor` | FLOAT | puntaje z | — | — |
|
||||
|
||||
@@ -75,14 +75,12 @@ def test_tea_tables_registered():
|
||||
# Staging: fed by the hospital source via the import pipeline.
|
||||
"pacientes",
|
||||
"ordenes_estudio",
|
||||
"nota_medica",
|
||||
"evaluacion_psicologica",
|
||||
"potenciales_evocados_auditivos",
|
||||
"eeg_estudio",
|
||||
"eeg_segmento",
|
||||
"instrumento_aplicado",
|
||||
"antecedentes_maternos_gestacion",
|
||||
"parto_neonatal",
|
||||
"mchat",
|
||||
"ados2",
|
||||
"evaluacion_neuropediatrica",
|
||||
"eeg",
|
||||
"eeg_metrica",
|
||||
"eeg_metrica_electrodo",
|
||||
# indicadores_kit CDM, built from staging by the webapi.orquestacion graph.
|
||||
*INDICADORES_KIT_CDM,
|
||||
}
|
||||
|
||||
@@ -42,6 +42,15 @@ class MeasureHistoryRepository(Repository):
|
||||
return {**{("total", "total", r, v): n for r, v, n in total},
|
||||
**{(s, sv, r, v): n for s, sv, r, v, n in by_stratum}}
|
||||
|
||||
def group_counts(self, report_id: int) -> dict[tuple[str, str], int]:
|
||||
"""A stored answer's units per group and population: `{(grupo, resultado_id): units}`. For a measure with
|
||||
several groups, whose units repeat in each one."""
|
||||
u = self.unit_model
|
||||
with self._session_factory() as session:
|
||||
rows = session.execute(select(u.grupo, u.resultado_id, func.count(distinct(u.unidad_id)))
|
||||
.where(u.report_id == report_id).group_by(u.grupo, u.resultado_id)).all()
|
||||
return {(g, r): n for g, r, n in rows}
|
||||
|
||||
def find(self, measure_url: str, key_sha: str) -> int | None:
|
||||
"""The report already answering this key, if it was asked before."""
|
||||
report = self.model
|
||||
|
||||
@@ -16,7 +16,8 @@ Persistance lo importe:
|
||||
Un procedimiento sin `pac_id` toma el de su padre; sin `fecha`, también, si el kit lo
|
||||
marca con `fecha_del_padre` (su tabla no trae fecha: un segmento de EEG, un instrumento
|
||||
aplicado). Uno que sí trae columna de fecha y la trae vacía se queda sin fecha. Uno sin `pac_id` y sin padre (el segmento de un EEG que la
|
||||
carga descartó) no se escribe, ni sus observaciones: se cuenta en `huerfanos` y se avisa. Uno que trae `orden_numero` y no encontró su orden se liga
|
||||
carga descartó) no se escribe, ni sus observaciones: se cuenta en `huerfanos` y se avisa. An observation whose
|
||||
procedure isn't in silver (it attaches to another row's procedure, which didn't enter) isn't written either. Uno que trae `orden_numero` y no encontró su orden se liga
|
||||
a ella cuando llega, aunque sea en otro lote.
|
||||
"""
|
||||
|
||||
@@ -43,6 +44,7 @@ def save_silver_in(
|
||||
"huerfanos"), 0
|
||||
)
|
||||
huerfanos: set = set()
|
||||
huerfanas = 0
|
||||
nuevos: set = set()
|
||||
tocados: set = set()
|
||||
existentes = {tuple(getattr(fila, c) for c in KEY): fila for fila in sesion.exec(select(procedimiento))}
|
||||
@@ -85,9 +87,11 @@ def save_silver_in(
|
||||
for o in sesion.exec(select(observacion).where(observacion.procedimiento_id.in_(ids)))
|
||||
} if ids else {}
|
||||
for o in plata.observaciones:
|
||||
if o["procedimiento"] in huerfanos:
|
||||
dueno = existentes.get(o["procedimiento"])
|
||||
if dueno is None:
|
||||
# Its procedure didn't enter: it was an orphan, or it's the row of another table it attaches to.
|
||||
huerfanas += 1
|
||||
continue
|
||||
dueno = existentes[o["procedimiento"]]
|
||||
datos = {c: v for c, v in o.items() if c != "procedimiento"}
|
||||
datos["procedimiento_id"] = dueno.procedimiento_id
|
||||
if datos.get("pac_id") is None:
|
||||
@@ -108,6 +112,8 @@ def save_silver_in(
|
||||
if huerfanos:
|
||||
log.warning("%d procedimientos sin paciente ni padre no se escribieron (p. ej. %s).",
|
||||
len(huerfanos), sorted(huerfanos)[0])
|
||||
if huerfanas:
|
||||
log.warning("%d observations whose procedure isn't in silver weren't written.", huerfanas)
|
||||
return cuenta
|
||||
|
||||
|
||||
|
||||
@@ -29,16 +29,14 @@ from core.tea.indicadores.models import (
|
||||
Persona,
|
||||
)
|
||||
from core.tea.models import (
|
||||
AntecedentesMaternosGestacion,
|
||||
EegEstudio,
|
||||
EegSegmento,
|
||||
EvaluacionPsicologica,
|
||||
InstrumentoAplicado,
|
||||
NotaMedica,
|
||||
Ados2,
|
||||
Eeg,
|
||||
EegMetrica,
|
||||
EegMetricaElectrodo,
|
||||
EvaluacionNeuropediatrica,
|
||||
Mchat,
|
||||
OrdenesEstudio,
|
||||
Pacientes,
|
||||
PartoNeonatal,
|
||||
PotencialesEvocadosAuditivos,
|
||||
)
|
||||
|
||||
from core.indicadores.cohortes import TablasCohorte
|
||||
@@ -67,14 +65,12 @@ from persistance.repository import Repository
|
||||
|
||||
pacientes_repository = Repository(get_tea_session, Pacientes)
|
||||
ordenes_estudio_repository = Repository(get_tea_session, OrdenesEstudio)
|
||||
nota_medica_repository = Repository(get_tea_session, NotaMedica)
|
||||
evaluacion_psicologica_repository = Repository(get_tea_session, EvaluacionPsicologica)
|
||||
potenciales_evocados_auditivos_repository = Repository(get_tea_session, PotencialesEvocadosAuditivos)
|
||||
eeg_estudio_repository = Repository(get_tea_session, EegEstudio)
|
||||
eeg_segmento_repository = Repository(get_tea_session, EegSegmento)
|
||||
antecedentes_maternos_gestacion_repository = Repository(get_tea_session, AntecedentesMaternosGestacion)
|
||||
parto_neonatal_repository = Repository(get_tea_session, PartoNeonatal)
|
||||
instrumento_aplicado_repository = Repository(get_tea_session, InstrumentoAplicado)
|
||||
mchat_repository = Repository(get_tea_session, Mchat)
|
||||
ados2_repository = Repository(get_tea_session, Ados2)
|
||||
evaluacion_neuropediatrica_repository = Repository(get_tea_session, EvaluacionNeuropediatrica)
|
||||
eeg_repository = Repository(get_tea_session, Eeg)
|
||||
eeg_metrica_repository = Repository(get_tea_session, EegMetrica)
|
||||
eeg_metrica_electrodo_repository = Repository(get_tea_session, EegMetricaElectrodo)
|
||||
|
||||
# indicadores_kit (Core/docs/ADR-004). Se leen con get/list/count; lo que
|
||||
# se escribe va por métodos de subclases (persistance/edges, por capa).
|
||||
|
||||
@@ -0,0 +1,486 @@
|
||||
"""tea staging by study
|
||||
|
||||
One staging table per kind of study: `mchat`, `ados2`, `evaluacion_neuropediatrica` and `eeg`, with the EEG's
|
||||
metrics and electrode values from its analysis (`eeg_metrica`, `eeg_metrica_electrodo`). `pacientes` and
|
||||
`ordenes_estudio` keep their rows and lose the columns nothing reads; the orders' study codes move to the new
|
||||
catalog (`ADOS2`, `NEUROPEDIATRIA`, `EEG`). The psychological evaluation, instruments, EEG segments, auditory
|
||||
evoked potentials, birth, maternal history and medical notes go, with their rows: staging is reloaded from the
|
||||
source.
|
||||
|
||||
Revision ID: f2b6d1e8c934
|
||||
Revises: a3e1c7b90d12
|
||||
Create Date: 2026-11-12 13:44:52.541497
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'f2b6d1e8c934'
|
||||
down_revision = 'a3e1c7b90d12'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
# The orders' study codes, old -> new.
|
||||
STUDY_CODES = {"EVALUACION_PSICOLOGICA_TEA": "ADOS2", "ELECTROENCEFALOGRAMA": "EEG"}
|
||||
|
||||
|
||||
def _recode(codes: dict[str, str]) -> None:
|
||||
orders = sa.table("ordenes_estudio", sa.column("ord_tipo_estudio", sa.Text()))
|
||||
for old, new in codes.items():
|
||||
op.execute(orders.update().where(orders.c.ord_tipo_estudio == old).values(ord_tipo_estudio=new))
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.create_table('ados2',
|
||||
sa.Column('ado_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('ado_pac_id', sa.Integer(), nullable=True),
|
||||
sa.Column('ado_ord_id', sa.Text(), nullable=True),
|
||||
sa.Column('ado_fecha', sa.Date(), nullable=True),
|
||||
sa.Column('ado_modulo', sa.Text(), nullable=True),
|
||||
sa.Column('ado_algoritmo', sa.Text(), nullable=True),
|
||||
sa.Column('ado_css', sa.Integer(), nullable=True),
|
||||
sa.Column('ado_clasificacion', sa.Text(), nullable=True),
|
||||
sa.Column('ado_sa_a2', sa.Integer(), nullable=True),
|
||||
sa.Column('ado_sa_a6', sa.Integer(), nullable=True),
|
||||
sa.Column('ado_sa_a7', sa.Integer(), nullable=True),
|
||||
sa.Column('ado_sa_a8', sa.Integer(), nullable=True),
|
||||
sa.Column('ado_sa_b1', sa.Integer(), nullable=True),
|
||||
sa.Column('ado_sa_b2', sa.Integer(), nullable=True),
|
||||
sa.Column('ado_sa_b3', sa.Integer(), nullable=True),
|
||||
sa.Column('ado_sa_b4', sa.Integer(), nullable=True),
|
||||
sa.Column('ado_sa_b5', sa.Integer(), nullable=True),
|
||||
sa.Column('ado_sa_b6', sa.Integer(), nullable=True),
|
||||
sa.Column('ado_sa_b7', sa.Integer(), nullable=True),
|
||||
sa.Column('ado_sa_b8', sa.Integer(), nullable=True),
|
||||
sa.Column('ado_sa_b9', sa.Integer(), nullable=True),
|
||||
sa.Column('ado_sa_b10', sa.Integer(), nullable=True),
|
||||
sa.Column('ado_sa_b11', sa.Integer(), nullable=True),
|
||||
sa.Column('ado_sa_b12', sa.Integer(), nullable=True),
|
||||
sa.Column('ado_sa_b13', sa.Integer(), nullable=True),
|
||||
sa.Column('ado_sa_b14', sa.Integer(), nullable=True),
|
||||
sa.Column('ado_sa_b15', sa.Integer(), nullable=True),
|
||||
sa.Column('ado_sa_b16b', sa.Integer(), nullable=True),
|
||||
sa.Column('ado_sa_b18', sa.Integer(), nullable=True),
|
||||
sa.Column('ado_rrb_a3', sa.Integer(), nullable=True),
|
||||
sa.Column('ado_rrb_a4', sa.Integer(), nullable=True),
|
||||
sa.Column('ado_rrb_a5', sa.Integer(), nullable=True),
|
||||
sa.Column('ado_rrb_d1', sa.Integer(), nullable=True),
|
||||
sa.Column('ado_rrb_d2', sa.Integer(), nullable=True),
|
||||
sa.Column('ado_rrb_d4', sa.Integer(), nullable=True),
|
||||
sa.Column('ado_rrb_d5', sa.Integer(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('ado_id')
|
||||
)
|
||||
op.create_table('eeg',
|
||||
sa.Column('eeg_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('eeg_pac_id', sa.Integer(), nullable=True),
|
||||
sa.Column('eeg_ord_id', sa.Text(), nullable=True),
|
||||
sa.Column('eeg_id_registro_laboratorio', sa.String(length=64), nullable=True),
|
||||
sa.Column('eeg_fecha_estudio', sa.Date(), nullable=True),
|
||||
sa.Column('eeg_con_sueno', sa.Integer(), nullable=True),
|
||||
sa.Column('eeg_canales', sa.Integer(), nullable=True),
|
||||
sa.Column('eeg_duracion_min', sa.Float(), nullable=True),
|
||||
sa.Column('eeg_canales_amplitud', sa.Integer(), nullable=True),
|
||||
sa.Column('eeg_canales_alta_frecuencia', sa.Integer(), nullable=True),
|
||||
sa.Column('eeg_canales_correlacion', sa.Integer(), nullable=True),
|
||||
sa.Column('eeg_canales_sin_senal', sa.Integer(), nullable=True),
|
||||
sa.Column('eeg_ruido_linea_db', sa.Float(), nullable=True),
|
||||
sa.Column('eeg_estudio', sa.LargeBinary().with_variant(mysql.LONGBLOB(), 'mariadb').with_variant(mysql.LONGBLOB(), 'mysql'), nullable=True),
|
||||
sa.PrimaryKeyConstraint('eeg_id')
|
||||
)
|
||||
with op.batch_alter_table('eeg', schema=None) as batch_op:
|
||||
batch_op.create_index(batch_op.f('ix_eeg_eeg_id_registro_laboratorio'), ['eeg_id_registro_laboratorio'], unique=False)
|
||||
|
||||
op.create_table('eeg_metrica',
|
||||
sa.Column('met_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('met_eeg_id', sa.Text(), nullable=True),
|
||||
sa.Column('met_codigo', sa.Text(), nullable=True),
|
||||
sa.Column('met_valor', sa.Float(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('met_id')
|
||||
)
|
||||
op.create_table('eeg_metrica_electrodo',
|
||||
sa.Column('mel_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('mel_met_id', sa.Text(), nullable=True),
|
||||
sa.Column('mel_electrodo', sa.Text(), nullable=True),
|
||||
sa.Column('mel_valor', sa.Float(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('mel_id')
|
||||
)
|
||||
op.create_table('evaluacion_neuropediatrica',
|
||||
sa.Column('neu_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('neu_pac_id', sa.Integer(), nullable=True),
|
||||
sa.Column('neu_ord_id', sa.Text(), nullable=True),
|
||||
sa.Column('neu_fecha', sa.Date(), nullable=True),
|
||||
sa.Column('neu_cie_codigo', sa.Text(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('neu_id')
|
||||
)
|
||||
op.create_table('mchat',
|
||||
sa.Column('mch_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('mch_pac_id', sa.Integer(), nullable=True),
|
||||
sa.Column('mch_ord_id', sa.Text(), nullable=True),
|
||||
sa.Column('mch_fecha', sa.Date(), nullable=True),
|
||||
sa.Column('mch_puntaje', sa.Integer(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('mch_id')
|
||||
)
|
||||
op.drop_table('evaluacion_psicologica')
|
||||
with op.batch_alter_table('nota_medica', schema=None) as batch_op:
|
||||
batch_op.drop_index(batch_op.f('ix_nota_medica_nm_id_hospital'))
|
||||
|
||||
op.drop_table('nota_medica')
|
||||
with op.batch_alter_table('eeg_estudio', schema=None) as batch_op:
|
||||
batch_op.drop_index(batch_op.f('ix_eeg_estudio_eeg_id_registro_laboratorio'))
|
||||
|
||||
op.drop_table('eeg_estudio')
|
||||
op.drop_table('parto_neonatal')
|
||||
op.drop_table('potenciales_evocados_auditivos')
|
||||
op.drop_table('antecedentes_maternos_gestacion')
|
||||
op.drop_table('eeg_segmento')
|
||||
op.drop_table('instrumento_aplicado')
|
||||
with op.batch_alter_table('ordenes_estudio', schema=None) as batch_op:
|
||||
batch_op.drop_column('ord_nota_medica_id')
|
||||
batch_op.drop_column('ord_proveedor')
|
||||
batch_op.drop_column('ord_fecha_resultado')
|
||||
batch_op.drop_column('ord_especialidad')
|
||||
batch_op.drop_column('ord_ventana_madurativa')
|
||||
batch_op.drop_column('ord_diagnostico_asignado')
|
||||
batch_op.drop_column('ord_estatus')
|
||||
batch_op.drop_column('ord_pdf_ruta')
|
||||
batch_op.drop_column('ord_updated_at')
|
||||
batch_op.drop_column('ord_dias_vigencia')
|
||||
batch_op.drop_column('ord_fecha_realizacion')
|
||||
batch_op.drop_column('ord_fuente_sistema')
|
||||
batch_op.drop_column('ord_medico_solicitante')
|
||||
batch_op.drop_column('ord_cie_asignado')
|
||||
batch_op.drop_column('ord_fecha_vencimiento')
|
||||
batch_op.drop_column('ord_created_at')
|
||||
batch_op.drop_column('ord_dias_espera')
|
||||
batch_op.drop_column('ord_edad_meses')
|
||||
batch_op.drop_column('ord_observaciones')
|
||||
|
||||
with op.batch_alter_table('pacientes', schema=None) as batch_op:
|
||||
batch_op.drop_column('pac_fuente_sistema')
|
||||
batch_op.drop_column('pac_dependencia')
|
||||
batch_op.drop_column('pac_parentesco')
|
||||
batch_op.drop_column('pac_codigo_postal_vigente')
|
||||
batch_op.drop_column('pac_created_at')
|
||||
batch_op.drop_column('pac_sexo')
|
||||
batch_op.drop_column('pac_updated_at')
|
||||
batch_op.drop_column('pac_id_titular')
|
||||
|
||||
_recode(STUDY_CODES)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
with op.batch_alter_table('pacientes', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('pac_id_titular', sa.Text(), nullable=True))
|
||||
batch_op.add_column(sa.Column('pac_updated_at', sa.DateTime(), nullable=True))
|
||||
batch_op.add_column(sa.Column('pac_sexo', sa.Text(), nullable=True))
|
||||
batch_op.add_column(sa.Column('pac_created_at', sa.DateTime(), nullable=True))
|
||||
batch_op.add_column(sa.Column('pac_codigo_postal_vigente', sa.Text(), nullable=True))
|
||||
batch_op.add_column(sa.Column('pac_parentesco', sa.Text(), nullable=True))
|
||||
batch_op.add_column(sa.Column('pac_dependencia', sa.Text(), nullable=True))
|
||||
batch_op.add_column(sa.Column('pac_fuente_sistema', sa.Text(), nullable=True))
|
||||
|
||||
with op.batch_alter_table('ordenes_estudio', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('ord_observaciones', sa.Text(), nullable=True))
|
||||
batch_op.add_column(sa.Column('ord_edad_meses', sa.Float(), nullable=True))
|
||||
batch_op.add_column(sa.Column('ord_dias_espera', sa.Integer(), nullable=True))
|
||||
batch_op.add_column(sa.Column('ord_created_at', sa.DateTime(), nullable=True))
|
||||
batch_op.add_column(sa.Column('ord_fecha_vencimiento', sa.Date(), nullable=True))
|
||||
batch_op.add_column(sa.Column('ord_cie_asignado', sa.Text(), nullable=True))
|
||||
batch_op.add_column(sa.Column('ord_medico_solicitante', sa.Text(), nullable=True))
|
||||
batch_op.add_column(sa.Column('ord_fuente_sistema', sa.Text(), nullable=True))
|
||||
batch_op.add_column(sa.Column('ord_fecha_realizacion', sa.Date(), nullable=True))
|
||||
batch_op.add_column(sa.Column('ord_dias_vigencia', sa.Integer(), nullable=True))
|
||||
batch_op.add_column(sa.Column('ord_updated_at', sa.DateTime(), nullable=True))
|
||||
batch_op.add_column(sa.Column('ord_pdf_ruta', sa.Text(), nullable=True))
|
||||
batch_op.add_column(sa.Column('ord_estatus', sa.Text(), nullable=True))
|
||||
batch_op.add_column(sa.Column('ord_diagnostico_asignado', sa.Text(), nullable=True))
|
||||
batch_op.add_column(sa.Column('ord_ventana_madurativa', sa.Text(), nullable=True))
|
||||
batch_op.add_column(sa.Column('ord_especialidad', sa.Text(), nullable=True))
|
||||
batch_op.add_column(sa.Column('ord_fecha_resultado', sa.Date(), nullable=True))
|
||||
batch_op.add_column(sa.Column('ord_proveedor', sa.Text(), nullable=True))
|
||||
batch_op.add_column(sa.Column('ord_nota_medica_id', sa.Text(), nullable=True))
|
||||
|
||||
op.create_table('instrumento_aplicado',
|
||||
sa.Column('ins_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('ins_psi_id', sa.Text(), nullable=True),
|
||||
sa.Column('ins_instrumento', sa.Text(), nullable=True),
|
||||
sa.Column('ins_informante', sa.Text(), nullable=True),
|
||||
sa.Column('ins_area', sa.Text(), nullable=True),
|
||||
sa.Column('ins_interpretacion', sa.Text(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('ins_id')
|
||||
)
|
||||
op.create_table('eeg_segmento',
|
||||
sa.Column('seg_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('seg_eeg_id', sa.Text(), nullable=True),
|
||||
sa.Column('seg_estado', sa.Text(), nullable=True),
|
||||
sa.Column('seg_inicio_s', sa.Float(), nullable=True),
|
||||
sa.Column('seg_fin_s', sa.Float(), nullable=True),
|
||||
sa.Column('seg_duracion_s', sa.Float(), nullable=True),
|
||||
sa.Column('seg_fuente', sa.Text(), nullable=True),
|
||||
sa.Column('seg_frecuencia_flash_hz', sa.Float(), nullable=True),
|
||||
sa.Column('seg_n_destellos', sa.Integer(), nullable=True),
|
||||
sa.Column('seg_cobertura', sa.Float(), nullable=True),
|
||||
sa.Column('seg_rms_uv', sa.Float(), nullable=True),
|
||||
sa.Column('seg_emg', sa.Float(), nullable=True),
|
||||
sa.Column('seg_p2p_max_uv', sa.Float(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('seg_id')
|
||||
)
|
||||
op.create_table('antecedentes_maternos_gestacion',
|
||||
sa.Column('amg_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('amg_pac_id', sa.Integer(), nullable=True),
|
||||
sa.Column('amg_id_madre_seudonimo', sa.Text(), nullable=True),
|
||||
sa.Column('amg_fuente_antecedente', sa.Text(), nullable=True),
|
||||
sa.Column('amg_flag_vinculo_verificado', sa.Integer(), nullable=True),
|
||||
sa.Column('amg_imc_pregestacional', sa.Float(), nullable=True),
|
||||
sa.Column('amg_categoria_peso_materno', sa.Text(), nullable=True),
|
||||
sa.Column('amg_tabaquismo_gestacion', sa.Integer(), nullable=True),
|
||||
sa.Column('amg_acido_folico_preconcepcional', sa.Integer(), nullable=True),
|
||||
sa.Column('amg_intervalo_intergenesico_meses', sa.Integer(), nullable=True),
|
||||
sa.Column('amg_antecedente_aborto', sa.Integer(), nullable=True),
|
||||
sa.Column('amg_embarazo_multiple', sa.Text(), nullable=True),
|
||||
sa.Column('amg_infeccion_gestacion', sa.Integer(), nullable=True),
|
||||
sa.Column('amg_infeccion_tipo', sa.Text(), nullable=True),
|
||||
sa.Column('amg_infeccion_hospitalizacion', sa.Integer(), nullable=True),
|
||||
sa.Column('amg_diabetes_gestacional', sa.Integer(), nullable=True),
|
||||
sa.Column('amg_hipertension_preeclampsia', sa.Text(), nullable=True),
|
||||
sa.Column('amg_hipotiroidismo', sa.Integer(), nullable=True),
|
||||
sa.Column('amg_hipertiroidismo', sa.Integer(), nullable=True),
|
||||
sa.Column('amg_incompatibilidad_rh', sa.Integer(), nullable=True),
|
||||
sa.Column('amg_crisis_convulsivas', sa.Integer(), nullable=True),
|
||||
sa.Column('amg_proceso_proinflamatorio', sa.Integer(), nullable=True),
|
||||
sa.Column('amg_enfermedad_autoinmune', sa.Integer(), nullable=True),
|
||||
sa.Column('amg_migrana', sa.Integer(), nullable=True),
|
||||
sa.Column('amg_asma', sa.Integer(), nullable=True),
|
||||
sa.Column('amg_hipoxia_materna', sa.Integer(), nullable=True),
|
||||
sa.Column('amg_estres_agudo', sa.Integer(), nullable=True),
|
||||
sa.Column('amg_trastorno_neurologico', sa.Integer(), nullable=True),
|
||||
sa.Column('amg_liquido_amniotico', sa.Text(), nullable=True),
|
||||
sa.Column('amg_medicamentos_gestacion', sa.Text(), nullable=True),
|
||||
sa.Column('amg_farmaco_riesgo_neurodesarrollo', sa.Integer(), nullable=True),
|
||||
sa.Column('amg_observaciones', sa.Text(), nullable=True),
|
||||
sa.Column('amg_ocr_confianza', sa.Float(), nullable=True),
|
||||
sa.Column('amg_nlp_version', sa.Text(), nullable=True),
|
||||
sa.Column('amg_created_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('amg_updated_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('amg_fuente_sistema', sa.Text(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('amg_id')
|
||||
)
|
||||
op.create_table('potenciales_evocados_auditivos',
|
||||
sa.Column('pea_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('pea_ord_id', sa.Text(), nullable=True),
|
||||
sa.Column('pea_pac_id', sa.Integer(), nullable=True),
|
||||
sa.Column('pea_fecha_estudio', sa.Date(), nullable=True),
|
||||
sa.Column('pea_medico_interpreta', sa.Text(), nullable=True),
|
||||
sa.Column('pea_umbral_od', sa.Integer(), nullable=True),
|
||||
sa.Column('pea_umbral_oi', sa.Integer(), nullable=True),
|
||||
sa.Column('pea_latencia_v_od', sa.Float(), nullable=True),
|
||||
sa.Column('pea_latencia_v_oi', sa.Float(), nullable=True),
|
||||
sa.Column('pea_interpico_i_v_od', sa.Float(), nullable=True),
|
||||
sa.Column('pea_interpico_i_v_oi', sa.Float(), nullable=True),
|
||||
sa.Column('pea_grado_hipoacusia', sa.Text(), nullable=True),
|
||||
sa.Column('pea_conclusion_texto', sa.Text(), nullable=True),
|
||||
sa.Column('pea_flag_diferencial_auditivo', sa.Integer(), nullable=True),
|
||||
sa.Column('pea_ocr_confianza', sa.Float(), nullable=True),
|
||||
sa.Column('pea_created_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('pea_updated_at', sa.DateTime(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('pea_id')
|
||||
)
|
||||
op.create_table('parto_neonatal',
|
||||
sa.Column('pnn_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('pnn_pac_id', sa.Integer(), nullable=True),
|
||||
sa.Column('pnn_fuente_antecedente', sa.Text(), nullable=True),
|
||||
sa.Column('pnn_tipo_parto', sa.Text(), nullable=True),
|
||||
sa.Column('pnn_complicaciones_intraparto', sa.Integer(), nullable=True),
|
||||
sa.Column('pnn_complicacion_tipo', sa.Text(), nullable=True),
|
||||
sa.Column('pnn_peso_nacer_g', sa.Integer(), nullable=True),
|
||||
sa.Column('pnn_talla_nacer_cm', sa.Float(), nullable=True),
|
||||
sa.Column('pnn_perimetro_cefalico_nacer_cm', sa.Float(), nullable=True),
|
||||
sa.Column('pnn_edad_gestacional_sem', sa.Float(), nullable=True),
|
||||
sa.Column('pnn_clasificacion_eg', sa.Text(), nullable=True),
|
||||
sa.Column('pnn_tamano_para_eg', sa.Text(), nullable=True),
|
||||
sa.Column('pnn_peso_nacer_zscore', sa.Float(), nullable=True),
|
||||
sa.Column('pnn_apgar_1min', sa.Integer(), nullable=True),
|
||||
sa.Column('pnn_apgar_5min', sa.Integer(), nullable=True),
|
||||
sa.Column('pnn_ingreso_ucin', sa.Integer(), nullable=True),
|
||||
sa.Column('pnn_dias_ucin', sa.Integer(), nullable=True),
|
||||
sa.Column('pnn_encefalopatia_hipoxico_isquemica', sa.Integer(), nullable=True),
|
||||
sa.Column('pnn_hipotermia_nacer', sa.Integer(), nullable=True),
|
||||
sa.Column('pnn_hiperbilirrubinemia', sa.Integer(), nullable=True),
|
||||
sa.Column('pnn_fototerapia', sa.Integer(), nullable=True),
|
||||
sa.Column('pnn_hipoglucemia_neonatal', sa.Integer(), nullable=True),
|
||||
sa.Column('pnn_anoxia', sa.Integer(), nullable=True),
|
||||
sa.Column('pnn_sindrome_congenito', sa.Integer(), nullable=True),
|
||||
sa.Column('pnn_sindrome_congenito_desc', sa.Text(), nullable=True),
|
||||
sa.Column('pnn_flag_riesgo_neonatal', sa.Integer(), nullable=True),
|
||||
sa.Column('pnn_observaciones', sa.Text(), nullable=True),
|
||||
sa.Column('pnn_ocr_confianza', sa.Float(), nullable=True),
|
||||
sa.Column('pnn_nlp_version', sa.Text(), nullable=True),
|
||||
sa.Column('pnn_created_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('pnn_updated_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('pnn_fuente_sistema', sa.Text(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('pnn_id')
|
||||
)
|
||||
op.create_table('eeg_estudio',
|
||||
sa.Column('eeg_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('eeg_ord_id', sa.Text(), nullable=True),
|
||||
sa.Column('eeg_pac_id', sa.Integer(), nullable=True),
|
||||
sa.Column('eeg_reporte_disponible', sa.Integer(), nullable=True),
|
||||
sa.Column('eeg_fuente_interpretacion', sa.Text(), nullable=True),
|
||||
sa.Column('eeg_fecha_nacimiento_archivo', sa.Date(), nullable=True),
|
||||
sa.Column('eeg_edad_meses', sa.Float(), nullable=True),
|
||||
sa.Column('eeg_fecha_estudio', sa.Date(), nullable=True),
|
||||
sa.Column('eeg_fecha_reporte', sa.Date(), nullable=True),
|
||||
sa.Column('eeg_dias_respuesta', sa.Integer(), nullable=True),
|
||||
sa.Column('eeg_medico_interpreta', sa.Text(), nullable=True),
|
||||
sa.Column('eeg_estado_registro', sa.Text(), nullable=True),
|
||||
sa.Column('eeg_privacion_sueno', sa.Integer(), nullable=True),
|
||||
sa.Column('eeg_sedacion', sa.Integer(), nullable=True),
|
||||
sa.Column('eeg_sedacion_farmaco', sa.Text(), nullable=True),
|
||||
sa.Column('eeg_duracion_min', sa.Float(), nullable=True),
|
||||
sa.Column('eeg_calidad_tecnica', sa.Text(), nullable=True),
|
||||
sa.Column('eeg_descripcion_senal', sa.Text(), nullable=True),
|
||||
sa.Column('eeg_ritmo_base_frecuencia', sa.Float(), nullable=True),
|
||||
sa.Column('eeg_ritmo_base_amplitud', sa.Integer(), nullable=True),
|
||||
sa.Column('eeg_simetria', sa.Text(), nullable=True),
|
||||
sa.Column('eeg_anormalidad_presente', sa.Integer(), nullable=True),
|
||||
sa.Column('eeg_actividad_epileptiforme', sa.Integer(), nullable=True),
|
||||
sa.Column('eeg_tipo_grafoelemento', sa.Text(), nullable=True),
|
||||
sa.Column('eeg_distribucion_anormalidad', sa.Text(), nullable=True),
|
||||
sa.Column('eeg_localizacion', sa.Text(), nullable=True),
|
||||
sa.Column('eeg_activacion_sueno', sa.Integer(), nullable=True),
|
||||
sa.Column('eeg_lentificacion', sa.Text(), nullable=True),
|
||||
sa.Column('eeg_crisis_registradas', sa.Integer(), nullable=True),
|
||||
sa.Column('eeg_respuesta_fotoestimulacion', sa.Text(), nullable=True),
|
||||
sa.Column('eeg_conclusion_texto', sa.Text(), nullable=True),
|
||||
sa.Column('eeg_conclusion_categoria', sa.Text(), nullable=True),
|
||||
sa.Column('eeg_id_registro_laboratorio', sa.String(length=64), nullable=True),
|
||||
sa.Column('eeg_pdf_ruta', sa.Text(), nullable=True),
|
||||
sa.Column('eeg_ocr_confianza', sa.Float(), nullable=True),
|
||||
sa.Column('eeg_nlp_version', sa.Text(), nullable=True),
|
||||
sa.Column('eeg_utilizable', sa.Integer(), nullable=True),
|
||||
sa.Column('eeg_estudio', sa.LargeBinary().with_variant(mysql.LONGBLOB(), 'mariadb').with_variant(mysql.LONGBLOB(), 'mysql'), nullable=True),
|
||||
sa.Column('eeg_created_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('eeg_updated_at', sa.DateTime(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('eeg_id')
|
||||
)
|
||||
with op.batch_alter_table('eeg_estudio', schema=None) as batch_op:
|
||||
batch_op.create_index(batch_op.f('ix_eeg_estudio_eeg_id_registro_laboratorio'), ['eeg_id_registro_laboratorio'], unique=False)
|
||||
|
||||
op.create_table('nota_medica',
|
||||
sa.Column('nm_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('nm_pac_id', sa.Integer(), nullable=True),
|
||||
sa.Column('nm_id_hospital', sa.String(length=64), nullable=True),
|
||||
sa.Column('nm_nota_previa_id', sa.Text(), nullable=True),
|
||||
sa.Column('nm_tipo_nota', sa.Text(), nullable=True),
|
||||
sa.Column('nm_especialidad', sa.Text(), nullable=True),
|
||||
sa.Column('nm_fecha', sa.Date(), nullable=True),
|
||||
sa.Column('nm_edad_meses', sa.Float(), nullable=True),
|
||||
sa.Column('nm_ventana_madurativa', sa.Text(), nullable=True),
|
||||
sa.Column('nm_medico_tratante', sa.Text(), nullable=True),
|
||||
sa.Column('nm_motivo_consulta', sa.Text(), nullable=True),
|
||||
sa.Column('nm_interrogatorio', sa.Text(), nullable=True),
|
||||
sa.Column('nm_regresion_referida', sa.Integer(), nullable=True),
|
||||
sa.Column('nm_antecedente_familiar_tea', sa.Integer(), nullable=True),
|
||||
sa.Column('nm_perimetro_cefalico', sa.Float(), nullable=True),
|
||||
sa.Column('nm_diagnostico_texto', sa.Text(), nullable=True),
|
||||
sa.Column('nm_cie_codigo', sa.Text(), nullable=True),
|
||||
sa.Column('nm_cie_descripcion', sa.Text(), nullable=True),
|
||||
sa.Column('nm_tratamiento_texto', sa.Text(), nullable=True),
|
||||
sa.Column('nm_receta', sa.Text(), nullable=True),
|
||||
sa.Column('nm_plan_estudios', sa.Text(), nullable=True),
|
||||
sa.Column('nm_pronostico', sa.Text(), nullable=True),
|
||||
sa.Column('nm_observaciones', sa.Text(), nullable=True),
|
||||
sa.Column('nm_masa_corporal', sa.Float(), nullable=True),
|
||||
sa.Column('nm_talla', sa.Float(), nullable=True),
|
||||
sa.Column('nm_imc_visita', sa.Float(), nullable=True),
|
||||
sa.Column('nm_frecuencia_cardiaca', sa.Integer(), nullable=True),
|
||||
sa.Column('nm_frecuencia_respiratoria', sa.Integer(), nullable=True),
|
||||
sa.Column('nm_presion_arterial_sistolica', sa.Integer(), nullable=True),
|
||||
sa.Column('nm_presion_arterial_diastolica', sa.Integer(), nullable=True),
|
||||
sa.Column('nm_temperatura', sa.Float(), nullable=True),
|
||||
sa.Column('nm_pdf_ruta', sa.Text(), nullable=True),
|
||||
sa.Column('nm_created_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('nm_updated_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('nm_fuente_sistema', sa.Text(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('nm_id')
|
||||
)
|
||||
with op.batch_alter_table('nota_medica', schema=None) as batch_op:
|
||||
batch_op.create_index(batch_op.f('ix_nota_medica_nm_id_hospital'), ['nm_id_hospital'], unique=False)
|
||||
|
||||
op.create_table('evaluacion_psicologica',
|
||||
sa.Column('psi_id', sa.String(length=36), nullable=False),
|
||||
sa.Column('psi_ord_id', sa.Text(), nullable=True),
|
||||
sa.Column('psi_pac_id', sa.Integer(), nullable=True),
|
||||
sa.Column('psi_fecha_entrevista_inicial', sa.Date(), nullable=True),
|
||||
sa.Column('psi_fecha_ados2', sa.Date(), nullable=True),
|
||||
sa.Column('psi_fecha_evaluacion', sa.Date(), nullable=True),
|
||||
sa.Column('psi_psicologo', sa.Text(), nullable=True),
|
||||
sa.Column('psi_edad_meses', sa.Float(), nullable=True),
|
||||
sa.Column('psi_ventana_madurativa', sa.Text(), nullable=True),
|
||||
sa.Column('psi_instrumento_tamizaje', sa.Text(), nullable=True),
|
||||
sa.Column('psi_tamizaje_puntaje', sa.Integer(), nullable=True),
|
||||
sa.Column('psi_tamizaje_riesgo', sa.Text(), nullable=True),
|
||||
sa.Column('psi_ados2_modulo', sa.Text(), nullable=True),
|
||||
sa.Column('psi_ados2_sa_a2', sa.Integer(), nullable=True),
|
||||
sa.Column('psi_ados2_sa_a6', sa.Integer(), nullable=True),
|
||||
sa.Column('psi_ados2_sa_a7', sa.Integer(), nullable=True),
|
||||
sa.Column('psi_ados2_sa_a8', sa.Integer(), nullable=True),
|
||||
sa.Column('psi_ados2_sa_b1', sa.Integer(), nullable=True),
|
||||
sa.Column('psi_ados2_sa_b2', sa.Integer(), nullable=True),
|
||||
sa.Column('psi_ados2_sa_b3', sa.Integer(), nullable=True),
|
||||
sa.Column('psi_ados2_sa_b4', sa.Integer(), nullable=True),
|
||||
sa.Column('psi_ados2_sa_b5', sa.Integer(), nullable=True),
|
||||
sa.Column('psi_ados2_sa_b6', sa.Integer(), nullable=True),
|
||||
sa.Column('psi_ados2_sa_b7', sa.Integer(), nullable=True),
|
||||
sa.Column('psi_ados2_sa_b8', sa.Integer(), nullable=True),
|
||||
sa.Column('psi_ados2_sa_b9', sa.Integer(), nullable=True),
|
||||
sa.Column('psi_ados2_sa_b10', sa.Integer(), nullable=True),
|
||||
sa.Column('psi_ados2_sa_b11', sa.Integer(), nullable=True),
|
||||
sa.Column('psi_ados2_sa_b12', sa.Integer(), nullable=True),
|
||||
sa.Column('psi_ados2_sa_b13', sa.Integer(), nullable=True),
|
||||
sa.Column('psi_ados2_sa_b14', sa.Integer(), nullable=True),
|
||||
sa.Column('psi_ados2_sa_b15', sa.Integer(), nullable=True),
|
||||
sa.Column('psi_ados2_sa_b16b', sa.Integer(), nullable=True),
|
||||
sa.Column('psi_ados2_sa_b18', sa.Integer(), nullable=True),
|
||||
sa.Column('psi_ados2_rrb_a3', sa.Integer(), nullable=True),
|
||||
sa.Column('psi_ados2_rrb_a4', sa.Integer(), nullable=True),
|
||||
sa.Column('psi_ados2_rrb_a5', sa.Integer(), nullable=True),
|
||||
sa.Column('psi_ados2_rrb_d1', sa.Integer(), nullable=True),
|
||||
sa.Column('psi_ados2_rrb_d2', sa.Integer(), nullable=True),
|
||||
sa.Column('psi_ados2_rrb_d4', sa.Integer(), nullable=True),
|
||||
sa.Column('psi_ados2_rrb_d5', sa.Integer(), nullable=True),
|
||||
sa.Column('psi_ados2_sa', sa.Integer(), nullable=True),
|
||||
sa.Column('psi_ados2_rrb', sa.Integer(), nullable=True),
|
||||
sa.Column('psi_ados2_total', sa.Integer(), nullable=True),
|
||||
sa.Column('psi_ados2_css', sa.Integer(), nullable=True),
|
||||
sa.Column('psi_ados2_css_sa', sa.Integer(), nullable=True),
|
||||
sa.Column('psi_ados2_css_rrb', sa.Integer(), nullable=True),
|
||||
sa.Column('psi_ados2_clasificacion', sa.Text(), nullable=True),
|
||||
sa.Column('psi_rgd', sa.Integer(), nullable=True),
|
||||
sa.Column('psi_cociente_desarrollo', sa.Float(), nullable=True),
|
||||
sa.Column('psi_css_umbral_aplicado', sa.Integer(), nullable=True),
|
||||
sa.Column('psi_caso_confirmado', sa.Integer(), nullable=True),
|
||||
sa.Column('psi_cars_total', sa.Float(), nullable=True),
|
||||
sa.Column('psi_otros_instrumentos', sa.Text(), nullable=True),
|
||||
sa.Column('psi_regresion_desarrollo', sa.Integer(), nullable=True),
|
||||
sa.Column('psi_diagnostico_texto', sa.Text(), nullable=True),
|
||||
sa.Column('psi_ocr_confianza', sa.Float(), nullable=True),
|
||||
sa.Column('psi_nlp_version', sa.Text(), nullable=True),
|
||||
sa.Column('psi_created_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('psi_updated_at', sa.DateTime(), nullable=True),
|
||||
sa.PrimaryKeyConstraint('psi_id')
|
||||
)
|
||||
op.drop_table('mchat')
|
||||
op.drop_table('evaluacion_neuropediatrica')
|
||||
op.drop_table('eeg_metrica_electrodo')
|
||||
op.drop_table('eeg_metrica')
|
||||
with op.batch_alter_table('eeg', schema=None) as batch_op:
|
||||
batch_op.drop_index(batch_op.f('ix_eeg_eeg_id_registro_laboratorio'))
|
||||
|
||||
op.drop_table('eeg')
|
||||
op.drop_table('ados2')
|
||||
|
||||
_recode({new: old for old, new in STUDY_CODES.items()})
|
||||
@@ -6,3 +6,4 @@ uv.lock
|
||||
.user.yml
|
||||
package-lock.yml
|
||||
.venv/
|
||||
graphify-out/
|
||||
|
||||
@@ -56,6 +56,63 @@ vars:
|
||||
especialidades_diagnostico: ["CIRUGIA_ONCOLOGICA"]
|
||||
horizonte_toma_diagnostico_dias: 180
|
||||
birads_gravedad: ["B1", "B2", "B3", "B0", "B4", "B4A", "B4B", "B4C", "B5", "B6"]
|
||||
# The analysis' stratifiers (models/cama/silver/cama_estratificadores.sql), from the catalog's provisional results
|
||||
# read from reports; placeholders until the domain expert validates them. `estadios`: each clinical stage's
|
||||
# group; `etapa_temprana`: the groups counted as early, the rest of the known ones advanced. The surrogate
|
||||
# molecular subtype: HER2 3+ is HER2-positive; HER2 0 or 1+ with both receptors negative, triple negative; with a
|
||||
# positive receptor, luminal A when Ki-67 is under `ki67_corte` % and progesterone positive with at least
|
||||
# `rp_corte` % (or no percentage), luminal B when Ki-67 is at least `ki67_corte` % or progesterone falls short;
|
||||
# without Ki-67, none. `tamano_t`: T by the lesion's largest diameter in mm, each up to its bound.
|
||||
# The biopsy grades that are an invasive cancer (models/cama/gold/eventos/cama_cancer_invasor.sql).
|
||||
grados_invasor: ["CARCINOMA_INVASOR"]
|
||||
estratos:
|
||||
estadios: {E0: "0", EI: "i", EIIA: "ii", EIIB: "ii", EIIIA: "iii", EIIIB: "iii", EIIIC: "iii", EIV: "iv"}
|
||||
etapa_temprana: ["0", "i", "ii"]
|
||||
her2_positivo: ["H3"]
|
||||
her2_negativo: ["H0", "H1"]
|
||||
ki67_corte: 20
|
||||
rp_corte: 20
|
||||
tamano_t: [{t: "t1", hasta_mm: 20}, {t: "t2", hasta_mm: 50}, {t: "t3", hasta_mm: null}]
|
||||
# TEA's rules (models/tea). The cohort: children whose first M-CHAT was at `edad_min_meses` to `edad_max_meses`
|
||||
# completed months (days / `dias_por_mes`, rounded to one decimal, then truncated); `ventanas`, the age groups of
|
||||
# that age. A confirmation is a neuropediatrics note with one of `cie_tea` (without the dot, compared exactly).
|
||||
# An EEG is bad when any quality criterion passes its threshold (`calidad`); a metric is altered when its z-score
|
||||
# against the reference of the child's age group at the EEG is at least `alteracion_z` away from 0.
|
||||
# The references, thresholds and `alteracion_z` are placeholders until the domain expert validates them.
|
||||
tea:
|
||||
edad_min_meses: 16
|
||||
edad_max_meses: 36
|
||||
dias_por_mes: 30.4375
|
||||
ventanas:
|
||||
- {clave: "16_23", desde: 16, hasta: 23}
|
||||
- {clave: "24_29", desde: 24, hasta: 29}
|
||||
- {clave: "30_36", desde: 30, hasta: 36}
|
||||
cie_tea: ["F840"]
|
||||
alteracion_z: 2
|
||||
calidad:
|
||||
canales_amplitud: 2
|
||||
canales_alta_frecuencia: 2
|
||||
canales_correlacion: 2
|
||||
canales_sin_senal: 2
|
||||
ruido_linea_db: 8
|
||||
# Reference range of each metric by age group at the EEG: (metric, group, min, max). The mean is the middle of
|
||||
# the range and the standard deviation a quarter of its width.
|
||||
referencias:
|
||||
- ["ritmo_posterior", "16_23", 4.5, 7.0]
|
||||
- ["ritmo_posterior", "24_29", 5.0, 7.5]
|
||||
- ["ritmo_posterior", "30_36", 5.5, 8.5]
|
||||
- ["husos_sueno_n2", "16_23", 2.5, 6.5]
|
||||
- ["husos_sueno_n2", "24_29", 2.25, 6.25]
|
||||
- ["husos_sueno_n2", "30_36", 2.0, 6.0]
|
||||
- ["husos_sueno_n3", "16_23", 0.75, 2.75]
|
||||
- ["husos_sueno_n3", "24_29", 0.5, 2.5]
|
||||
- ["husos_sueno_n3", "30_36", 0.5, 2.5]
|
||||
- ["picos_paroxisticos", "16_23", 0.0, 1.0]
|
||||
- ["picos_paroxisticos", "24_29", 0.0, 1.0]
|
||||
- ["picos_paroxisticos", "30_36", 0.0, 1.0]
|
||||
- ["gradiente_anteroposterior", "16_23", 2.0, 3.5]
|
||||
- ["gradiente_anteroposterior", "24_29", 1.75, 3.25]
|
||||
- ["gradiente_anteroposterior", "30_36", 1.5, 3.0]
|
||||
# The surveillance cohort's rules (models/cacu/cohorts/surveillance).
|
||||
surveillance_cohort:
|
||||
recruitment_start: "2024-01-01"
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
{#
|
||||
Completed months from a number of days, as TEA counts them: days / `tea.dias_por_mes`, rounded to one decimal,
|
||||
then truncated (a child of 26.96 months is 27.0 and so 27, one of 26.94 is 26). Days are differences of
|
||||
`dim_fecha.dia_num`, never negative here.
|
||||
|
||||
Truncation is `floor`, except on SQLite, where a cast to integer truncates (PostgreSQL and MySQL round on that
|
||||
cast). PostgreSQL only rounds a numeric to a number of decimals, hence the cast to decimal first.
|
||||
#}
|
||||
{% macro tea_meses_cumplidos(dias) -%}
|
||||
{{ return(adapter.dispatch('tea_meses_cumplidos', 'isssteleon')(dias)) }}
|
||||
{%- endmacro %}
|
||||
|
||||
{% macro default__tea_meses_cumplidos(dias) -%}
|
||||
{{ as_integer('floor(round(cast(' ~ dias ~ ' as decimal(12, 4)) / ' ~ var('tea')['dias_por_mes'] ~ ', 1))') }}
|
||||
{%- endmacro %}
|
||||
|
||||
{% macro sqlite__tea_meses_cumplidos(dias) -%}
|
||||
cast(round(({{ dias }}) / {{ var('tea')['dias_por_mes'] }}, 1) as integer)
|
||||
{%- endmacro %}
|
||||
|
||||
{#
|
||||
The age group of a number of completed months: the `tea.ventanas` window it falls in, `sin_dato` when the months
|
||||
are null (no birth date), and null when it falls outside every window.
|
||||
#}
|
||||
{% macro tea_grupo_edad(meses) -%}
|
||||
case
|
||||
when {{ meses }} is null then {{ as_text("'sin_dato'") }}
|
||||
{%- for v in var('tea')['ventanas'] %}
|
||||
when {{ meses }} between {{ v['desde'] }} and {{ v['hasta'] }} then {{ as_text("'" ~ v['clave'] ~ "'") }}
|
||||
{%- endfor %}
|
||||
end
|
||||
{%- endmacro %}
|
||||
|
||||
{# A bounded number of the EEG's quality: within its threshold of `tea.calidad`. #}
|
||||
{% macro tea_criterio_bueno(columna, umbral) -%}
|
||||
({{ columna }} is not null and {{ columna }} <= {{ var('tea')['calidad'][umbral] }})
|
||||
{%- endmacro %}
|
||||
|
||||
{# The later of two values when both are known, else null: a step reached after the previous one is dated by the
|
||||
later of its fact and that step. SQL Server 2016 has no GREATEST. #}
|
||||
{% macro tea_despues(previo, propio) -%}
|
||||
case when ({{ previo }}) is null or ({{ propio }}) is null then null
|
||||
when ({{ propio }}) > ({{ previo }}) then ({{ propio }}) else ({{ previo }}) end
|
||||
{%- endmacro %}
|
||||
@@ -0,0 +1,23 @@
|
||||
-- One row per biopsy report with an invasive cancer (`vars.cama.grados_invasor`), dated by the report, with the
|
||||
-- BI-RADS of the mammogram that led to it (null when none was found or it has no report): the grain of the measures
|
||||
-- that describe the cancers found. When the report became known: the start of the load that wrote it. The birth date
|
||||
-- is the patient's, for strata by age; the tumour's stratifiers come from cama_estratificadores.
|
||||
|
||||
select
|
||||
b.procedimiento_id,
|
||||
b.fuente_id,
|
||||
b.pac_id,
|
||||
b.fecha_reporte,
|
||||
b.grado,
|
||||
m.birads,
|
||||
c.inicio as reporte_conocido_en,
|
||||
persona.fecha_nacimiento
|
||||
from {{ ref('cama_biopsias') }} b
|
||||
join {{ source('silver', 'carga') }} c
|
||||
on c.carga_id = b.reporte_carga_id
|
||||
join {{ source('silver', 'persona') }} persona
|
||||
on persona.pac_id = b.pac_id
|
||||
left join {{ ref('cama_mastografias') }} m
|
||||
on m.procedimiento_id = b.toma_id and m.pac_id = b.pac_id and m.birads is not null
|
||||
where b.fecha_reporte is not null
|
||||
and b.grado in {{ sql_list(var('cama')['grados_invasor']) }}
|
||||
@@ -0,0 +1,122 @@
|
||||
version: 2
|
||||
|
||||
models:
|
||||
- name: cama_cancer_invasor
|
||||
description: "Reportes de biopsia con cáncer invasor, con el BI-RADS de la mastografía que los originó."
|
||||
config:
|
||||
materialized: view
|
||||
|
||||
semantic_models:
|
||||
- name: cama_cancer_invasor
|
||||
description: "Biopsy reports with an invasive cancer and the BI-RADS that led to them: what the cancers found count."
|
||||
model: ref('cama_cancer_invasor')
|
||||
defaults:
|
||||
agg_time_dimension: fecha_reporte
|
||||
entities:
|
||||
- name: cancer
|
||||
type: primary
|
||||
expr: procedimiento_id
|
||||
- name: paciente
|
||||
type: foreign
|
||||
expr: pac_id
|
||||
dimensions:
|
||||
- name: fecha_reporte
|
||||
type: time
|
||||
type_params:
|
||||
time_granularity: day
|
||||
- name: reporte_conocido_en
|
||||
type: time
|
||||
type_params:
|
||||
time_granularity: day
|
||||
- name: fecha_nacimiento
|
||||
type: time
|
||||
type_params:
|
||||
time_granularity: day
|
||||
- name: birads
|
||||
type: categorical
|
||||
- name: fuente_id
|
||||
type: categorical
|
||||
measures:
|
||||
- name: pacientes_con_cancer_invasor
|
||||
description: "Distinct patients: each counts once per period, however many reports."
|
||||
agg: count_distinct
|
||||
expr: pac_id
|
||||
|
||||
metrics:
|
||||
- name: cama_birads_cancer_invasor
|
||||
label: "BI-RADS de los cánceres invasores"
|
||||
description: >-
|
||||
De las pacientes con una biopsia reportada en el periodo con carcinoma invasor, cuántas tenían cada BI-RADS en la
|
||||
mastografía que originó su biopsia más reciente, por edad y por las características del tumor: estadio clínico,
|
||||
etapa, subtipo molecular y tamaño. Las características vienen de los reportes leídos por texto y son
|
||||
provisionales. «Sin dato»: la biopsia no se ligó a una mastografía con BI-RADS.
|
||||
type: simple
|
||||
type_params:
|
||||
measure: pacientes_con_cancer_invasor
|
||||
config:
|
||||
meta:
|
||||
measure_url: cama/CAMA_BIRADS_CANCER_INVASOR
|
||||
version: 0.1.0
|
||||
scoring: composition
|
||||
basis: paciente
|
||||
grupo: TOTAL
|
||||
contrato: C2
|
||||
tipos_periodo: [semestre, mes]
|
||||
poblaciones_fhir: [measure-observation]
|
||||
conocida_en: [reporte_conocido_en]
|
||||
# Each patient's latest report of the period with a BI-RADS; one without it counts as SIN_DATO.
|
||||
categoria:
|
||||
valor: birads
|
||||
sin_dato: SIN_DATO
|
||||
elige: ultimo_valido
|
||||
valido: "{% raw %}{{ Dimension('cancer__birads') }} is not null{% endraw %}"
|
||||
orden: [fecha_reporte, fuente_id]
|
||||
# The tumour's stratifiers: what cama_estratificadores held by the event cut-off (the stage or the subtype
|
||||
# is usually written after the biopsy). The first value that holds wins: the most advanced, or for the
|
||||
# subtype the one with the worst prognosis, when the reports disagree.
|
||||
estratos:
|
||||
grupo_edad:
|
||||
tipo: edad_al_inicio_del_periodo
|
||||
nacimiento: fecha_nacimiento
|
||||
estadio:
|
||||
tipo: linea_de_tiempo_al_corte
|
||||
etiqueta: Estadio clínico
|
||||
linea: cama_estratificadores
|
||||
valores:
|
||||
- {valor: IV, etiqueta: Estadio IV, si: [{estadio_iv: true}]}
|
||||
- {valor: III, etiqueta: Estadio III, si: [{estadio_iii: true}]}
|
||||
- {valor: II, etiqueta: Estadio II, si: [{estadio_ii: true}]}
|
||||
- {valor: I, etiqueta: Estadio I, si: [{estadio_i: true}]}
|
||||
- {valor: "0", etiqueta: Estadio 0, si: [{estadio_0: true}]}
|
||||
resto: SIN_DATO
|
||||
resto_etiqueta: Sin dato
|
||||
etapa:
|
||||
tipo: linea_de_tiempo_al_corte
|
||||
etiqueta: Etapa
|
||||
linea: cama_estratificadores
|
||||
valores:
|
||||
- {valor: AVANZADA, etiqueta: Avanzada (III a IV), si: [{etapa_avanzada: true}]}
|
||||
- {valor: TEMPRANA, etiqueta: Temprana (0 a II), si: [{etapa_temprana: true}]}
|
||||
resto: SIN_DATO
|
||||
resto_etiqueta: Sin dato
|
||||
clasificacion:
|
||||
tipo: linea_de_tiempo_al_corte
|
||||
etiqueta: Subtipo molecular
|
||||
linea: cama_estratificadores
|
||||
valores:
|
||||
- {valor: TN, etiqueta: Triple negativo, si: [{subtipo_triple_negativo: true}]}
|
||||
- {valor: HER2, etiqueta: HER2 positivo, si: [{subtipo_her2: true}]}
|
||||
- {valor: LUM_B, etiqueta: Luminal B, si: [{subtipo_luminal_b: true}]}
|
||||
- {valor: LUM_A, etiqueta: Luminal A, si: [{subtipo_luminal_a: true}]}
|
||||
resto: SIN_DATO
|
||||
resto_etiqueta: Sin dato
|
||||
tamano:
|
||||
tipo: linea_de_tiempo_al_corte
|
||||
etiqueta: Tamaño tumoral (T)
|
||||
linea: cama_estratificadores
|
||||
valores:
|
||||
- {valor: T3, etiqueta: "> 5 cm (T3)", si: [{tamano_t3: true}]}
|
||||
- {valor: T2, etiqueta: "> 2 a 5 cm (T2)", si: [{tamano_t2: true}]}
|
||||
- {valor: T1, etiqueta: "≤ 2 cm (T1)", si: [{tamano_t1: true}]}
|
||||
resto: SIN_DATO
|
||||
resto_etiqueta: Sin dato
|
||||
@@ -0,0 +1,82 @@
|
||||
{# Each patient's stratifiers for the analysis, as timeline facts (`pac_id`, `tipo`, `fecha`, `conocida_en`): what a
|
||||
measure's `linea_de_tiempo_*` strata ask about. Derived from cama_linea_de_tiempo's lines read from reports, by the
|
||||
rules in `vars.cama.estratos`: the clinical stage's group and early or advanced stage (from a note), the surrogate
|
||||
molecular subtype (from one pathology report's receptors, HER2 and Ki-67 together) and the lesion's T (from a
|
||||
mammography report). A fact is dated and known as the lines it comes from. A view, like the timeline. #}
|
||||
{{ config(materialized = 'view') }}
|
||||
{%- set e = var('cama')['estratos'] -%}
|
||||
|
||||
with linea as (
|
||||
select pac_id, fecha, conocida_en, tipo, valor_codigo, valor_numerico, fuente_tabla, fuente_id
|
||||
from {{ ref('cama_linea_de_tiempo') }}
|
||||
),
|
||||
|
||||
estadio as (
|
||||
select
|
||||
pac_id, fecha, conocida_en,
|
||||
case valor_codigo
|
||||
{%- for codigo, grupo in e['estadios'].items() %}
|
||||
when '{{ codigo }}' then 'estadio_{{ grupo }}'
|
||||
{%- endfor %}
|
||||
end as estadio,
|
||||
case valor_codigo
|
||||
{%- for codigo, grupo in e['estadios'].items() %}
|
||||
when '{{ codigo }}' then '{{ 'etapa_temprana' if grupo in e['etapa_temprana'] else 'etapa_avanzada' }}'
|
||||
{%- endfor %}
|
||||
end as etapa
|
||||
from linea
|
||||
where tipo = 'estadio_clinico'
|
||||
),
|
||||
|
||||
reporte as (
|
||||
select
|
||||
pac_id, fecha, fuente_tabla, fuente_id,
|
||||
max(conocida_en) as conocida_en,
|
||||
max(case when tipo = 'receptor_estrogeno' then valor_codigo end) as re,
|
||||
max(case when tipo = 'receptor_progesterona' then valor_codigo end) as rp,
|
||||
max(case when tipo = 'receptor_progesterona_pct' then valor_numerico end) as rp_pct,
|
||||
max(case when tipo = 'her2' then valor_codigo end) as her2,
|
||||
max(case when tipo = 'ki67_pct' then valor_numerico end) as ki67
|
||||
from linea
|
||||
where tipo in ('receptor_estrogeno', 'receptor_progesterona', 'receptor_progesterona_pct', 'her2', 'ki67_pct')
|
||||
group by pac_id, fecha, fuente_tabla, fuente_id
|
||||
),
|
||||
|
||||
subtipo as (
|
||||
select
|
||||
pac_id, fecha, conocida_en,
|
||||
case
|
||||
when her2 in {{ sql_list(e['her2_positivo']) }} then 'subtipo_her2'
|
||||
when her2 not in {{ sql_list(e['her2_negativo']) }} or her2 is null then null
|
||||
when re = 'NEGATIVO' and rp = 'NEGATIVO' then 'subtipo_triple_negativo'
|
||||
when re = 'POSITIVO' or rp = 'POSITIVO' then
|
||||
case
|
||||
when ki67 is null then null
|
||||
when ki67 < {{ e['ki67_corte'] }} and rp = 'POSITIVO'
|
||||
and (rp_pct is null or rp_pct >= {{ e['rp_corte'] }}) then 'subtipo_luminal_a'
|
||||
else 'subtipo_luminal_b'
|
||||
end
|
||||
end as subtipo
|
||||
from reporte
|
||||
),
|
||||
|
||||
tamano as (
|
||||
select
|
||||
pac_id, fecha, conocida_en,
|
||||
case
|
||||
{%- for t in e['tamano_t'] if t['hasta_mm'] is not none %}
|
||||
when valor_numerico <= {{ t['hasta_mm'] }} then 'tamano_{{ t['t'] }}'
|
||||
{%- endfor %}
|
||||
else 'tamano_{{ (e['tamano_t'] | last)['t'] }}'
|
||||
end as t
|
||||
from linea
|
||||
where tipo = 'tamano_lesion_mm' and valor_numerico is not null
|
||||
)
|
||||
|
||||
select pac_id, estadio as tipo, fecha, conocida_en from estadio where estadio is not null
|
||||
union all
|
||||
select pac_id, etapa as tipo, fecha, conocida_en from estadio where etapa is not null
|
||||
union all
|
||||
select pac_id, subtipo as tipo, fecha, conocida_en from subtipo where subtipo is not null
|
||||
union all
|
||||
select pac_id, t as tipo, fecha, conocida_en from tamano
|
||||
@@ -17,5 +17,17 @@ models:
|
||||
- {estudio_id: "mastografia", clase: "toma", resultado_id: "mastografia.calidad_imagen", clase_de_linea: "procedimiento", tipo: "mastografia", codigo: "mastografia"}
|
||||
- {estudio_id: "mastografia", clase: "reporte", resultado_id: "mastografia.birads", clase_de_linea: "medicion", tipo: "birads", codigo: "birads"}
|
||||
- {estudio_id: "biopsia", clase: "reporte", resultado_id: "biopsia.grado", clase_de_linea: "medicion", tipo: "biopsia", codigo: "grado_histologico"}
|
||||
# Read from the reports' text (provisional catalog results): the stratifiers of the analysis.
|
||||
- {estudio_id: "mastografia", clase: "reporte", resultado_id: "mastografia.densidad", clase_de_linea: "medicion", tipo: "densidad_mamaria"}
|
||||
- {estudio_id: "mastografia", clase: "reporte", resultado_id: "mastografia.tamano_lesion_mm", clase_de_linea: "medicion", tipo: "tamano_lesion_mm", valor: "numerico"}
|
||||
- {estudio_id: "biopsia", clase: "reporte", resultado_id: "biopsia.tipo_histologico", clase_de_linea: "medicion", tipo: "tipo_histologico"}
|
||||
- {estudio_id: "biopsia", clase: "reporte", resultado_id: "biopsia.grado_nottingham", clase_de_linea: "medicion", tipo: "grado_nottingham"}
|
||||
- {estudio_id: "biopsia", clase: "reporte", resultado_id: "biopsia.receptor_estrogeno", clase_de_linea: "medicion", tipo: "receptor_estrogeno"}
|
||||
- {estudio_id: "biopsia", clase: "reporte", resultado_id: "biopsia.receptor_estrogeno_pct", clase_de_linea: "medicion", tipo: "receptor_estrogeno_pct", valor: "numerico"}
|
||||
- {estudio_id: "biopsia", clase: "reporte", resultado_id: "biopsia.receptor_progesterona", clase_de_linea: "medicion", tipo: "receptor_progesterona"}
|
||||
- {estudio_id: "biopsia", clase: "reporte", resultado_id: "biopsia.receptor_progesterona_pct", clase_de_linea: "medicion", tipo: "receptor_progesterona_pct", valor: "numerico"}
|
||||
- {estudio_id: "biopsia", clase: "reporte", resultado_id: "biopsia.her2", clase_de_linea: "medicion", tipo: "her2"}
|
||||
- {estudio_id: "biopsia", clase: "reporte", resultado_id: "biopsia.ki67_pct", clase_de_linea: "medicion", tipo: "ki67_pct", valor: "numerico"}
|
||||
- {estudio_id: "nota_medica", clase: "encuentro", resultado_id: "nota_medica.estadio_clinico", clase_de_linea: "medicion", tipo: "estadio_clinico"}
|
||||
- {estudio_id: null, clase: "orden", resultado_id: null, clase_de_linea: "orden", tipo: "orden", columna: "codigo_fuente"}
|
||||
- {estudio_id: "nota_medica", clase: "encuentro", resultado_id: "nota_medica.diagnostico", clase_de_linea: "diagnostico", tipo: "nota_medica"}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
-- One row per child of the cohort with a good EEG and knowledge version (`conocida_en`): the first good EEG known
|
||||
-- by then (the study's) and, from its
|
||||
-- metrics, whether it has any alteration and which. Later EEGs, good or bad, don't change them; each alteration
|
||||
-- counts once per child and a child can have several. What M30 counts, by the period of that EEG.
|
||||
|
||||
select
|
||||
h.pac_id,
|
||||
h.grupo_edad,
|
||||
h.eeg_estudio_id as procedimiento_id,
|
||||
h.fecha_eeg_estudio as fecha_eeg,
|
||||
h.conocida_en,
|
||||
max(case when m.estado in ('aumentado', 'disminuido') then 1 else 0 end) as con_alteracion,
|
||||
max(case when m.metrica = 'ritmo_posterior' and m.estado in ('aumentado', 'disminuido') then 1 else 0 end) as alt_ritmo_posterior,
|
||||
max(case when m.metrica = 'husos_sueno_n2' and m.estado in ('aumentado', 'disminuido') then 1 else 0 end) as alt_husos_sueno_n2,
|
||||
max(case when m.metrica = 'husos_sueno_n3' and m.estado in ('aumentado', 'disminuido') then 1 else 0 end) as alt_husos_sueno_n3,
|
||||
max(case when m.metrica = 'picos_paroxisticos' and m.estado in ('aumentado', 'disminuido') then 1 else 0 end) as alt_picos_paroxisticos,
|
||||
max(case when m.metrica = 'gradiente_anteroposterior' and m.estado in ('aumentado', 'disminuido') then 1 else 0 end) as alt_gradiente_anteroposterior
|
||||
from {{ ref('tea_hitos') }} h
|
||||
left join {{ ref('tea_eeg_metricas') }} m on m.procedimiento_id = h.eeg_estudio_id
|
||||
where h.eeg_estudio_id is not null
|
||||
group by h.pac_id, h.grupo_edad, h.eeg_estudio_id, h.fecha_eeg_estudio, h.conocida_en
|
||||
@@ -0,0 +1,89 @@
|
||||
version: 2
|
||||
|
||||
models:
|
||||
- name: tea_alteraciones
|
||||
description: "Niños de la cohorte con un EEG de buena calidad: el primero y las alteraciones que tiene."
|
||||
config:
|
||||
materialized: view
|
||||
|
||||
semantic_models:
|
||||
- name: tea_alteraciones
|
||||
description: "Each child's first good EEG and its alterations: what the EEG result measure counts over."
|
||||
model: ref('tea_alteraciones')
|
||||
defaults:
|
||||
agg_time_dimension: fecha_eeg
|
||||
entities:
|
||||
- name: eeg_estudio
|
||||
type: primary
|
||||
expr: pac_id
|
||||
dimensions:
|
||||
- {name: fecha_eeg, type: time, type_params: {time_granularity: day}}
|
||||
- {name: conocida_en, type: time, type_params: {time_granularity: day}}
|
||||
- {name: con_alteracion, type: categorical}
|
||||
- {name: alt_ritmo_posterior, type: categorical}
|
||||
- {name: alt_husos_sueno_n2, type: categorical}
|
||||
- {name: alt_husos_sueno_n3, type: categorical}
|
||||
- {name: alt_picos_paroxisticos, type: categorical}
|
||||
- {name: alt_gradiente_anteroposterior, type: categorical}
|
||||
- {name: grupo_edad, type: categorical}
|
||||
measures:
|
||||
- name: ninos_con_eeg
|
||||
description: "Distinct children whose first good EEG falls in the period."
|
||||
agg: count_distinct
|
||||
expr: pac_id
|
||||
|
||||
metrics:
|
||||
- name: tea_m30_con_eeg
|
||||
label: "TEA M30: niños con su primer EEG bueno"
|
||||
type: simple
|
||||
type_params:
|
||||
measure: ninos_con_eeg
|
||||
config:
|
||||
meta:
|
||||
poblaciones_fhir: [denominator]
|
||||
- name: tea_m30_con_alteracion
|
||||
label: "TEA M30: con alguna alteración"
|
||||
type: simple
|
||||
type_params:
|
||||
measure: ninos_con_eeg
|
||||
filter: "{{ Dimension('eeg_estudio__con_alteracion') }} = 1"
|
||||
config:
|
||||
meta:
|
||||
poblaciones_fhir: [numerator]
|
||||
- name: tea_resultado_eeg
|
||||
label: "Porcentaje de EEG normal y anormal"
|
||||
description: >-
|
||||
De los niños de la cohorte cuyo primer EEG de buena calidad cae en el periodo, cuántos tienen alguna alteración
|
||||
en él; un grupo por alteración, y un niño cuenta en cada una que tenga, así que no suman. Las alteraciones se
|
||||
miden contra los rangos de referencia por grupo de edad al EEG, pendientes de validar.
|
||||
type: ratio
|
||||
type_params:
|
||||
numerator: tea_m30_con_alteracion
|
||||
denominator: tea_m30_con_eeg
|
||||
config:
|
||||
meta:
|
||||
measure_url: tea/M30_resultado_eeg
|
||||
version_conocida: conocida_en
|
||||
version: 1.0.0
|
||||
basis: paciente
|
||||
grupo: TOTAL
|
||||
contrato: C1
|
||||
tipos_periodo: [semestre, mes]
|
||||
figuras: [fig_c1_barras_alteracion]
|
||||
requiere_validacion: alteraciones
|
||||
grupos:
|
||||
- grupo: ritmo_posterior
|
||||
etiqueta: "Ritmo posterior"
|
||||
filtro: "{% raw %}{{ Dimension('eeg_estudio__alt_ritmo_posterior') }} = 1{% endraw %}"
|
||||
- grupo: husos_sueno_n2
|
||||
etiqueta: "Husos de sueño N2"
|
||||
filtro: "{% raw %}{{ Dimension('eeg_estudio__alt_husos_sueno_n2') }} = 1{% endraw %}"
|
||||
- grupo: husos_sueno_n3
|
||||
etiqueta: "Husos de sueño N3"
|
||||
filtro: "{% raw %}{{ Dimension('eeg_estudio__alt_husos_sueno_n3') }} = 1{% endraw %}"
|
||||
- grupo: picos_paroxisticos
|
||||
etiqueta: "Picos paroxísticos"
|
||||
filtro: "{% raw %}{{ Dimension('eeg_estudio__alt_picos_paroxisticos') }} = 1{% endraw %}"
|
||||
- grupo: gradiente_anteroposterior
|
||||
etiqueta: "Gradiente anteroposterior"
|
||||
filtro: "{% raw %}{{ Dimension('eeg_estudio__alt_gradiente_anteroposterior') }} = 1{% endraw %}"
|
||||
@@ -0,0 +1,21 @@
|
||||
-- One row per child of the cohort and knowledge version (`conocida_en`): the date of each step and the days
|
||||
-- between them, from differences of `dim_fecha.dia_num`. What the day counts are asked over: the children in the
|
||||
-- screening during the period, whose interval ended by its end.
|
||||
|
||||
select
|
||||
h.pac_id,
|
||||
h.conocida_en,
|
||||
h.grupo_edad,
|
||||
h.fecha_mchat as ingreso,
|
||||
h.mchat_dia as ingreso_dia,
|
||||
h.fecha_eeg as salida,
|
||||
h.fecha_psicologia,
|
||||
h.fecha_neuropediatria,
|
||||
h.fecha_tea,
|
||||
dp.dia_num - h.mchat_dia as dias_mchat_ados2,
|
||||
dn.dia_num - dp.dia_num as dias_ados2_diagnostico,
|
||||
dt.dia_num - h.mchat_dia as dias_mchat_diagnostico
|
||||
from {{ ref('tea_hitos') }} h
|
||||
left join {{ source('silver', 'dim_fecha') }} dp on dp.fecha = h.fecha_psicologia
|
||||
left join {{ source('silver', 'dim_fecha') }} dn on dn.fecha = h.fecha_neuropediatria
|
||||
left join {{ source('silver', 'dim_fecha') }} dt on dt.fecha = h.fecha_tea
|
||||
@@ -0,0 +1,130 @@
|
||||
version: 2
|
||||
|
||||
models:
|
||||
- name: tea_casos
|
||||
description: "Cada niño de la cohorte con la fecha de cada paso y los días entre ellos."
|
||||
config:
|
||||
materialized: view
|
||||
|
||||
semantic_models:
|
||||
- name: tea_casos
|
||||
description: "The children of the cohort, with the days between their steps: what the day counts are asked over."
|
||||
model: ref('tea_casos')
|
||||
defaults:
|
||||
agg_time_dimension: ingreso
|
||||
entities:
|
||||
- name: caso
|
||||
type: primary
|
||||
expr: pac_id
|
||||
dimensions:
|
||||
- {name: ingreso, type: time, type_params: {time_granularity: day}}
|
||||
- {name: conocida_en, type: time, type_params: {time_granularity: day}}
|
||||
- {name: salida, type: time, type_params: {time_granularity: day}}
|
||||
- {name: fecha_psicologia, type: time, type_params: {time_granularity: day}}
|
||||
- {name: fecha_neuropediatria, type: time, type_params: {time_granularity: day}}
|
||||
- {name: fecha_tea, type: time, type_params: {time_granularity: day}}
|
||||
- {name: ingreso_dia, type: categorical}
|
||||
- {name: dias_mchat_ados2, type: categorical}
|
||||
- {name: dias_ados2_diagnostico, type: categorical}
|
||||
- {name: dias_mchat_diagnostico, type: categorical}
|
||||
- {name: grupo_edad, type: categorical}
|
||||
measures:
|
||||
- name: ninos
|
||||
description: "Distinct children of the cohort."
|
||||
agg: count_distinct
|
||||
expr: pac_id
|
||||
|
||||
metrics:
|
||||
- name: tea_dias_mchat_ados2
|
||||
label: "Días de M-CHAT a ADOS-2"
|
||||
description: >-
|
||||
Días naturales del primer M-CHAT a la nota de psicología con el ADOS-2, de los niños de la cohorte en el tamizaje durante el periodo cuyo intervalo terminó a más tardar al
|
||||
cierre. Los demás cuentan como sin evento.
|
||||
type: simple
|
||||
type_params:
|
||||
measure: ninos
|
||||
config:
|
||||
meta:
|
||||
measure_url: tea/M26_dias_mchat_ados2
|
||||
version_conocida: conocida_en
|
||||
version: 1.0.0
|
||||
scoring: continuous-variable
|
||||
basis: paciente
|
||||
grupo: TOTAL
|
||||
contrato: C3r
|
||||
improvement_notation: decrease
|
||||
tipos_periodo: [semestre, mes]
|
||||
figuras: [fig_c3r_caja]
|
||||
poblaciones_fhir: [initial-population]
|
||||
poblacion:
|
||||
tipo: estado_al_fin_del_periodo
|
||||
ingreso: ingreso
|
||||
salida: salida
|
||||
observacion:
|
||||
valor: dias_mchat_ados2
|
||||
fechada_en: [fecha_psicologia]
|
||||
horizonte:
|
||||
dias: 0
|
||||
dia_inicio: ingreso_dia
|
||||
- name: tea_dias_ados2_diagnostico
|
||||
label: "Días de ADOS-2 a diagnóstico"
|
||||
description: >-
|
||||
Días naturales de la nota de psicología a la nota de neuropediatría, de los niños de la cohorte en el tamizaje durante el periodo cuyo intervalo terminó a más tardar al
|
||||
cierre. Los demás cuentan como sin evento.
|
||||
type: simple
|
||||
type_params:
|
||||
measure: ninos
|
||||
config:
|
||||
meta:
|
||||
measure_url: tea/M27_dias_ados2_diagnostico
|
||||
version_conocida: conocida_en
|
||||
version: 1.0.0
|
||||
scoring: continuous-variable
|
||||
basis: paciente
|
||||
grupo: TOTAL
|
||||
contrato: C3r
|
||||
improvement_notation: decrease
|
||||
tipos_periodo: [semestre, mes]
|
||||
figuras: [fig_c3r_caja]
|
||||
poblaciones_fhir: [initial-population]
|
||||
poblacion:
|
||||
tipo: estado_al_fin_del_periodo
|
||||
ingreso: ingreso
|
||||
salida: salida
|
||||
observacion:
|
||||
valor: dias_ados2_diagnostico
|
||||
fechada_en: [fecha_neuropediatria]
|
||||
horizonte:
|
||||
dias: 0
|
||||
dia_inicio: ingreso_dia
|
||||
- name: tea_dias_mchat_diagnostico
|
||||
label: "Días de M-CHAT a diagnóstico positivo"
|
||||
description: >-
|
||||
Días naturales del primer M-CHAT a la nota de neuropediatría con F84.0, de los niños de la cohorte en el tamizaje durante el periodo cuyo intervalo terminó a más tardar al
|
||||
cierre. Los demás cuentan como sin evento.
|
||||
type: simple
|
||||
type_params:
|
||||
measure: ninos
|
||||
config:
|
||||
meta:
|
||||
measure_url: tea/M25_dias_mchat_diagnostico
|
||||
version_conocida: conocida_en
|
||||
version: 1.0.0
|
||||
scoring: continuous-variable
|
||||
basis: paciente
|
||||
grupo: TOTAL
|
||||
contrato: C3r
|
||||
improvement_notation: decrease
|
||||
tipos_periodo: [semestre, mes]
|
||||
figuras: [fig_c3r_caja]
|
||||
poblaciones_fhir: [initial-population]
|
||||
poblacion:
|
||||
tipo: estado_al_fin_del_periodo
|
||||
ingreso: ingreso
|
||||
salida: salida
|
||||
observacion:
|
||||
valor: dias_mchat_diagnostico
|
||||
fechada_en: [fecha_tea]
|
||||
horizonte:
|
||||
dias: 0
|
||||
dia_inicio: ingreso_dia
|
||||
@@ -0,0 +1,25 @@
|
||||
-- One row per child of the cohort, knowledge version (`conocida_en`) and diagnostic result reached: in process from the M-CHAT, without TEA from a
|
||||
-- neuropediatrics note without F84.0, confirmed from one with it; ordered so a confirmation is final. A note
|
||||
-- counts from the psychology step on, and the child enters and leaves the screening as in `tea_pasos`. `fecha_eeg`: the step that
|
||||
-- completes the chain, for the confirmed with or without a good EEG.
|
||||
|
||||
{% set estados = [
|
||||
('EN_PROCESO', 1, 'fecha_mchat'),
|
||||
('SIN_TEA', 2, 'fecha_sin_tea'),
|
||||
('CONFIRMADO', 3, 'fecha_tea')] %}
|
||||
|
||||
{% for estado, orden, fecha in estados %}
|
||||
{{ 'union all' if not loop.first }}
|
||||
select
|
||||
h.pac_id,
|
||||
{{ as_text("'" ~ estado ~ "'") }} as estado,
|
||||
{{ orden }} as estado_orden,
|
||||
h.{{ fecha }} as fecha,
|
||||
h.conocida_en,
|
||||
h.grupo_edad,
|
||||
h.fecha_mchat as ingreso,
|
||||
h.fecha_eeg as salida,
|
||||
h.fecha_eeg
|
||||
from {{ ref('tea_hitos') }} h
|
||||
where h.{{ fecha }} is not null
|
||||
{%- endfor %}
|
||||
@@ -0,0 +1,208 @@
|
||||
version: 2
|
||||
|
||||
models:
|
||||
- name: tea_diagnosticos
|
||||
description: "Resultado diagnóstico de cada niño de la cohorte: en proceso, sin TEA o confirmado, con su fecha."
|
||||
config:
|
||||
materialized: view
|
||||
|
||||
semantic_models:
|
||||
- name: tea_diagnosticos
|
||||
description: "The diagnostic results each child of the cohort reached: what M23, M24, M21 and M22 count over."
|
||||
model: ref('tea_diagnosticos')
|
||||
defaults:
|
||||
agg_time_dimension: fecha
|
||||
entities:
|
||||
- name: resultado_diagnostico
|
||||
type: primary
|
||||
expr: "pac_id || '-' || estado"
|
||||
- name: paciente
|
||||
type: foreign
|
||||
expr: pac_id
|
||||
dimensions:
|
||||
- {name: fecha, type: time, type_params: {time_granularity: day}}
|
||||
- {name: conocida_en, type: time, type_params: {time_granularity: day}}
|
||||
- {name: ingreso, type: time, type_params: {time_granularity: day}}
|
||||
- {name: salida, type: time, type_params: {time_granularity: day}}
|
||||
- {name: fecha_eeg, type: time, type_params: {time_granularity: day}}
|
||||
- {name: estado, type: categorical}
|
||||
- {name: estado_orden, type: categorical}
|
||||
- {name: grupo_edad, type: categorical}
|
||||
measures:
|
||||
- name: ninos_por_diagnostico
|
||||
description: "Distinct children, each at its diagnostic result at the period's end."
|
||||
agg: count_distinct
|
||||
expr: pac_id
|
||||
|
||||
metrics:
|
||||
- name: tea_pacientes_evaluados
|
||||
label: "Pacientes evaluados por resultado diagnóstico"
|
||||
description: >-
|
||||
Niños de la cohorte en el tamizaje durante el periodo por su resultado al cierre: confirmados (una nota de
|
||||
neuropediatría con F84.0) y en proceso (sin nota de neuropediatría todavía). Una nota sin F84.0 no cuenta.
|
||||
type: simple
|
||||
type_params:
|
||||
measure: ninos_por_diagnostico
|
||||
config:
|
||||
meta:
|
||||
measure_url: tea/M23_pacientes_evaluados
|
||||
version_conocida: conocida_en
|
||||
version: 1.0.0
|
||||
scoring: composition
|
||||
basis: paciente
|
||||
grupo: TOTAL
|
||||
contrato: C2
|
||||
tipos_periodo: [semestre, mes]
|
||||
figuras: [fig_c2_barras]
|
||||
poblaciones_fhir: [measure-observation]
|
||||
poblacion: &diagnostico_al_fin
|
||||
tipo: estado_al_fin_del_periodo
|
||||
ingreso: ingreso
|
||||
salida: salida
|
||||
orden: estado_orden
|
||||
categoria:
|
||||
valor: estado
|
||||
sin_dato: SIN_DATO
|
||||
valido: "{% raw %}{{ Dimension('resultado_diagnostico__estado') }} is not null{% endraw %}"
|
||||
orden: [estado_orden]
|
||||
admite: "{% raw %}{{ Dimension('resultado_diagnostico__estado') }} in ('CONFIRMADO', 'EN_PROCESO'){% endraw %}"
|
||||
etiquetas:
|
||||
CONFIRMADO: {etiqueta: "Diagnóstico confirmado", color: "#A8C243"}
|
||||
EN_PROCESO: {etiqueta: "En proceso", color: "#B8433A"}
|
||||
|
||||
# M24: confirmed out of confirmed plus in process, by age group.
|
||||
- name: tea_m24_confirmados
|
||||
label: "TEA M24: confirmados"
|
||||
type: simple
|
||||
type_params:
|
||||
measure: ninos_por_diagnostico
|
||||
filter: "{{ Dimension('resultado_diagnostico__estado') }} = 'CONFIRMADO'"
|
||||
config:
|
||||
meta:
|
||||
poblaciones_fhir: [numerator]
|
||||
- name: tea_m24_evaluados
|
||||
label: "TEA M24: confirmados y en proceso"
|
||||
type: simple
|
||||
type_params:
|
||||
measure: ninos_por_diagnostico
|
||||
filter: "{{ Dimension('resultado_diagnostico__estado') }} in ('CONFIRMADO', 'EN_PROCESO')"
|
||||
config:
|
||||
meta:
|
||||
poblaciones_fhir: [denominator]
|
||||
- name: tea_m24_sin_tea
|
||||
label: "TEA M24: notas sin F84.0"
|
||||
type: simple
|
||||
type_params:
|
||||
measure: ninos_por_diagnostico
|
||||
filter: "{{ Dimension('resultado_diagnostico__estado') }} = 'SIN_TEA'"
|
||||
config:
|
||||
meta:
|
||||
poblaciones_fhir: [denominator-exclusion]
|
||||
- name: tea_confirmacion_diagnostico
|
||||
label: "Porcentaje de confirmación diagnóstica"
|
||||
description: >-
|
||||
De los niños de la cohorte en el tamizaje durante el periodo, confirmados o en proceso al cierre, cuántos tienen
|
||||
el diagnóstico confirmado (F84.0 en la nota de neuropediatría). Por grupo de edad al primer M-CHAT. Los que
|
||||
tienen una nota sin F84.0 quedan fuera.
|
||||
type: ratio
|
||||
type_params:
|
||||
numerator: tea_m24_confirmados
|
||||
denominator: tea_m24_evaluados
|
||||
config:
|
||||
meta: &m24
|
||||
measure_url: tea/M24_confirmacion_diagnostico
|
||||
version_conocida: conocida_en
|
||||
version: 1.0.0
|
||||
basis: paciente
|
||||
grupo: TOTAL
|
||||
contrato: C1
|
||||
improvement_notation: increase
|
||||
tipos_periodo: [semestre, mes]
|
||||
figuras: [fig_c1_barras_apiladas_edad]
|
||||
exclusion: tea_m24_sin_tea
|
||||
poblacion: *diagnostico_al_fin
|
||||
estratos: &por_grupo_de_edad
|
||||
grupo_edad:
|
||||
tipo: columna
|
||||
columna: grupo_edad
|
||||
etiqueta: "Grupo de edad"
|
||||
valores:
|
||||
"16_23": "16 a 23 meses"
|
||||
"24_29": "24 a 29 meses"
|
||||
"30_36": "30 a 36 meses"
|
||||
sin_dato: "Sin dato"
|
||||
|
||||
# M21 and M22: of the confirmed, those with and without a good EEG by the period's end.
|
||||
- name: tea_m21_confirmados
|
||||
label: "TEA M21: confirmados"
|
||||
type: simple
|
||||
type_params:
|
||||
measure: ninos_por_diagnostico
|
||||
filter: "{{ Dimension('resultado_diagnostico__estado') }} = 'CONFIRMADO'"
|
||||
config:
|
||||
meta:
|
||||
poblaciones_fhir: [denominator]
|
||||
- name: tea_m21_con_eeg
|
||||
label: "TEA M21: confirmados con EEG"
|
||||
type: simple
|
||||
type_params:
|
||||
measure: ninos_por_diagnostico
|
||||
filter: "{{ Dimension('resultado_diagnostico__estado') }} = 'CONFIRMADO'"
|
||||
config:
|
||||
meta:
|
||||
poblaciones_fhir: [numerator]
|
||||
al_fin: [{fecha: fecha_eeg, alcanzada: true}]
|
||||
- name: tea_m22_sin_eeg
|
||||
label: "TEA M22: confirmados sin EEG"
|
||||
type: simple
|
||||
type_params:
|
||||
measure: ninos_por_diagnostico
|
||||
filter: "{{ Dimension('resultado_diagnostico__estado') }} = 'CONFIRMADO'"
|
||||
config:
|
||||
meta:
|
||||
poblaciones_fhir: [numerator]
|
||||
al_fin: [{fecha: fecha_eeg, alcanzada: false}]
|
||||
- name: tea_diagnosticados_con_eeg
|
||||
label: "Porcentaje de pacientes con diagnóstico de TEA con EEG"
|
||||
description: >-
|
||||
De los niños con diagnóstico confirmado al cierre del periodo, cuántos tienen ya un EEG de buena calidad. Por
|
||||
grupo de edad al primer M-CHAT.
|
||||
type: ratio
|
||||
type_params:
|
||||
numerator: tea_m21_con_eeg
|
||||
denominator: tea_m21_confirmados
|
||||
config:
|
||||
meta:
|
||||
measure_url: tea/M21_diagnosticados_con_eeg
|
||||
version_conocida: conocida_en
|
||||
version: 1.0.0
|
||||
basis: paciente
|
||||
grupo: TOTAL
|
||||
contrato: C1
|
||||
improvement_notation: increase
|
||||
tipos_periodo: [semestre, mes]
|
||||
figuras: [fig_c1_barras_edad]
|
||||
poblacion: *diagnostico_al_fin
|
||||
estratos: *por_grupo_de_edad
|
||||
- name: tea_diagnosticados_sin_eeg
|
||||
label: "Porcentaje de pacientes con diagnóstico de TEA sin EEG"
|
||||
description: >-
|
||||
De los niños con diagnóstico confirmado al cierre del periodo, cuántos no tienen todavía un EEG de buena
|
||||
calidad: el complemento de M21. Por grupo de edad al primer M-CHAT.
|
||||
type: ratio
|
||||
type_params:
|
||||
numerator: tea_m22_sin_eeg
|
||||
denominator: tea_m21_confirmados
|
||||
config:
|
||||
meta:
|
||||
measure_url: tea/M22_diagnosticados_sin_eeg
|
||||
version_conocida: conocida_en
|
||||
version: 1.0.0
|
||||
basis: paciente
|
||||
grupo: TOTAL
|
||||
contrato: C1
|
||||
improvement_notation: decrease
|
||||
tipos_periodo: [semestre, mes]
|
||||
figuras: [fig_c1_barras_edad]
|
||||
poblacion: *diagnostico_al_fin
|
||||
estratos: *por_grupo_de_edad
|
||||
@@ -0,0 +1,14 @@
|
||||
-- One row per EEG of a child of the cohort: its date, when it became known and its quality (good, bad, or not yet
|
||||
-- analysed). What M29 counts, by exam.
|
||||
|
||||
select
|
||||
e.procedimiento_id,
|
||||
e.fuente_id,
|
||||
e.pac_id,
|
||||
e.fecha_eeg,
|
||||
c.inicio as conocida_en,
|
||||
e.calidad
|
||||
from {{ ref('tea_eegs') }} e
|
||||
join {{ source('silver', 'carga') }} c on c.carga_id = e.carga_id
|
||||
join {{ ref('tea_cohorte') }} k on k.pac_id = e.pac_id
|
||||
where k.vigente = 1 and k.en_cohorte = 1 and e.fecha_eeg is not null
|
||||
@@ -0,0 +1,62 @@
|
||||
version: 2
|
||||
|
||||
models:
|
||||
- name: tea_eegs_periodo
|
||||
description: "EEG de los niños de la cohorte, con su calidad: buena, mala o sin analizar."
|
||||
config:
|
||||
materialized: view
|
||||
|
||||
semantic_models:
|
||||
- name: tea_eegs_periodo
|
||||
description: "The EEGs of the cohort's children: what the quality measure counts, by exam."
|
||||
model: ref('tea_eegs_periodo')
|
||||
defaults:
|
||||
agg_time_dimension: fecha_eeg
|
||||
entities:
|
||||
- name: eeg
|
||||
type: primary
|
||||
expr: fuente_id
|
||||
- name: paciente
|
||||
type: foreign
|
||||
expr: pac_id
|
||||
dimensions:
|
||||
- {name: fecha_eeg, type: time, type_params: {time_granularity: day}}
|
||||
- {name: conocida_en, type: time, type_params: {time_granularity: day}}
|
||||
- {name: calidad, type: categorical}
|
||||
- {name: fuente_id, type: categorical}
|
||||
measures:
|
||||
- name: eegs
|
||||
description: "Distinct EEGs (the source's id): the unit of the exam-based measure."
|
||||
agg: count_distinct
|
||||
expr: fuente_id
|
||||
|
||||
metrics:
|
||||
- name: tea_calidad_eeg
|
||||
label: "Calidad del EEG"
|
||||
description: >-
|
||||
EEG realizados en el periodo a niños de la cohorte, por su calidad: bueno si todos sus criterios de calidad
|
||||
están dentro de su umbral, malo si alguno no. Los que su análisis no ha calificado cuentan como sin analizar.
|
||||
type: simple
|
||||
type_params:
|
||||
measure: eegs
|
||||
config:
|
||||
meta:
|
||||
measure_url: tea/M29_calidad_eeg
|
||||
version: 1.0.0
|
||||
scoring: composition
|
||||
basis: examen
|
||||
grupo: TOTAL
|
||||
contrato: C2
|
||||
tipos_periodo: [semestre, mes]
|
||||
figuras: [fig_c2_barras]
|
||||
poblaciones_fhir: [measure-observation]
|
||||
conocida_en: [conocida_en]
|
||||
categoria:
|
||||
valor: calidad
|
||||
sin_dato: SIN_DATO
|
||||
valido: "{% raw %}{{ Dimension('eeg__calidad') }} is not null{% endraw %}"
|
||||
orden: [fecha_eeg]
|
||||
etiquetas:
|
||||
BUENO: {etiqueta: "Bueno", color: "#A8C243"}
|
||||
MALO: {etiqueta: "Malo", color: "#B8433A"}
|
||||
SIN_ANALIZAR: {etiqueta: "Sin analizar", color: "#C9CDD2"}
|
||||
@@ -0,0 +1,27 @@
|
||||
-- One row per child of the cohort and step of the screening reached (M-CHAT, psychology, neuropediatrics, EEG),
|
||||
-- with its order and its date, in each knowledge version of the child (`conocida_en`: what was known of them from
|
||||
-- that load on): the grain the status measures are asked over. A child is in
|
||||
-- the screening from the M-CHAT (`ingreso`) and leaves after the period of the step that completes the chain, the
|
||||
-- first good EEG (`salida`). Without it they never leave. No period here: each child's stage at a period's end is
|
||||
-- the question's.
|
||||
|
||||
{% set pasos = [
|
||||
('SOLO_MCHAT', 1, 'fecha_mchat'),
|
||||
('PSICOLOGIA', 2, 'fecha_psicologia'),
|
||||
('NEUROPEDIATRIA', 3, 'fecha_neuropediatria'),
|
||||
('EEG', 4, 'fecha_eeg')] %}
|
||||
|
||||
{% for paso, orden, fecha in pasos %}
|
||||
{{ 'union all' if not loop.first }}
|
||||
select
|
||||
h.pac_id,
|
||||
{{ as_text("'" ~ paso ~ "'") }} as paso,
|
||||
{{ orden }} as paso_orden,
|
||||
h.{{ fecha }} as fecha,
|
||||
h.conocida_en,
|
||||
h.grupo_edad,
|
||||
h.fecha_mchat as ingreso,
|
||||
h.fecha_eeg as salida
|
||||
from {{ ref('tea_hitos') }} h
|
||||
where h.{{ fecha }} is not null
|
||||
{%- endfor %}
|
||||
@@ -0,0 +1,72 @@
|
||||
version: 2
|
||||
|
||||
models:
|
||||
- name: tea_pasos
|
||||
description: "Pasos del tamizaje que alcanzó cada niño de la cohorte, con su fecha y cuándo se supo."
|
||||
config:
|
||||
materialized: view
|
||||
|
||||
semantic_models:
|
||||
- name: tea_pasos
|
||||
description: "The steps of the screening each child of the cohort reached: what the stage measure counts over."
|
||||
model: ref('tea_pasos')
|
||||
defaults:
|
||||
agg_time_dimension: fecha
|
||||
entities:
|
||||
- name: paso_alcanzado
|
||||
type: primary
|
||||
expr: "pac_id || '-' || paso"
|
||||
- name: paciente
|
||||
type: foreign
|
||||
expr: pac_id
|
||||
dimensions:
|
||||
- {name: fecha, type: time, type_params: {time_granularity: day}}
|
||||
- {name: conocida_en, type: time, type_params: {time_granularity: day}}
|
||||
- {name: ingreso, type: time, type_params: {time_granularity: day}}
|
||||
- {name: salida, type: time, type_params: {time_granularity: day}}
|
||||
- {name: paso, type: categorical}
|
||||
- {name: paso_orden, type: categorical}
|
||||
- {name: grupo_edad, type: categorical}
|
||||
measures:
|
||||
- name: ninos_en_tamizaje
|
||||
description: "Distinct children: each counts once per period, at its stage at the period's end."
|
||||
agg: count_distinct
|
||||
expr: pac_id
|
||||
|
||||
metrics:
|
||||
- name: tea_casos_por_estado
|
||||
label: "Casos por estatus"
|
||||
description: >-
|
||||
Niños de la cohorte en el tamizaje durante el periodo (entraron con su primer M-CHAT a más tardar al cierre y no
|
||||
lo terminaron antes del inicio), por la etapa más avanzada que alcanzaron al cierre del periodo. Un niño sale
|
||||
después del periodo de su primer EEG de buena calidad.
|
||||
type: simple
|
||||
type_params:
|
||||
measure: ninos_en_tamizaje
|
||||
config:
|
||||
meta:
|
||||
measure_url: tea/M28_casos_por_estado
|
||||
version_conocida: conocida_en
|
||||
version: 1.0.0
|
||||
scoring: composition
|
||||
basis: paciente
|
||||
grupo: TOTAL
|
||||
contrato: C2
|
||||
tipos_periodo: [semestre, mes]
|
||||
figuras: [fig_c2_barras]
|
||||
poblaciones_fhir: [measure-observation]
|
||||
poblacion: &al_fin_del_periodo
|
||||
tipo: estado_al_fin_del_periodo
|
||||
ingreso: ingreso
|
||||
salida: salida
|
||||
orden: paso_orden
|
||||
categoria:
|
||||
valor: paso
|
||||
sin_dato: SIN_DATO
|
||||
valido: "{% raw %}{{ Dimension('paso_alcanzado__paso') }} is not null{% endraw %}"
|
||||
orden: [paso_orden]
|
||||
etiquetas:
|
||||
SOLO_MCHAT: {etiqueta: "Solo M-CHAT", color: "#B8433A"}
|
||||
PSICOLOGIA: {etiqueta: "Hasta evaluación psicológica", color: "#D0B778"}
|
||||
NEUROPEDIATRIA: {etiqueta: "Hasta evaluación neuropediátrica", color: "#7184A2"}
|
||||
EEG: {etiqueta: "Con EEG", color: "#A8C243"}
|
||||
@@ -0,0 +1,19 @@
|
||||
version: 2
|
||||
|
||||
# Views the WebApi reads, not measures: the cycle creates them with the event models (`lee_la_webapi`).
|
||||
models:
|
||||
- name: tea_seguimiento
|
||||
description: "Cada niño de la cohorte con las fechas de sus pasos, su M-CHAT y su ADOS-2: la lista de seguimiento."
|
||||
config: {materialized: view, meta: {lee_la_webapi: true}}
|
||||
- name: tea_paciente_ados2
|
||||
description: "Cada ADOS-2 con sus reactivos: el resumen del paciente."
|
||||
config: {materialized: view, meta: {lee_la_webapi: true}}
|
||||
- name: tea_paciente_eegs
|
||||
description: "Cada EEG con su calidad: el EEG del estudio a una fecha de corte."
|
||||
config: {materialized: view, meta: {lee_la_webapi: true}}
|
||||
- name: tea_paciente_eeg_metricas
|
||||
description: "Cada métrica de cada EEG contra su referencia."
|
||||
config: {materialized: view, meta: {lee_la_webapi: true}}
|
||||
- name: tea_paciente_eeg_electrodos
|
||||
description: "El puntaje z de cada métrica en cada electrodo."
|
||||
config: {materialized: view, meta: {lee_la_webapi: true}}
|
||||
@@ -0,0 +1,18 @@
|
||||
-- One row per ADOS-2 and scored item, with the ADOS-2's module, algorithm, CSS and classification on each: what the
|
||||
-- patient summary draws its domains and items from. An ADOS-2 without items gives one row without an item.
|
||||
|
||||
select
|
||||
a.procedimiento_id,
|
||||
a.pac_id,
|
||||
a.fecha_ados2,
|
||||
a.modulo,
|
||||
a.algoritmo,
|
||||
a.css,
|
||||
a.clasificacion,
|
||||
r.dominio,
|
||||
r.reactivo,
|
||||
r.etiqueta,
|
||||
r.puntaje,
|
||||
r.puntaje_algoritmo
|
||||
from {{ ref('tea_ados2') }} a
|
||||
left join {{ ref('tea_ados2_reactivos') }} r on r.procedimiento_id = a.procedimiento_id
|
||||
@@ -0,0 +1,4 @@
|
||||
-- One row per EEG, metric and electrode: the metric's z-score there, what the WebApp draws the map from.
|
||||
|
||||
select procedimiento_id, pac_id, metrica, electrodo, valor
|
||||
from {{ ref('tea_eeg_electrodos') }}
|
||||
@@ -0,0 +1,4 @@
|
||||
-- One row per EEG and metric: value, age group at the EEG, reference range, z-score and state.
|
||||
|
||||
select procedimiento_id, pac_id, metrica, valor, grupo_edad_eeg, ref_min, ref_max, valor_z, estado
|
||||
from {{ ref('tea_eeg_metricas') }}
|
||||
@@ -0,0 +1,18 @@
|
||||
-- One row per EEG: its date, what its analysis wrote, each quality criterion within its threshold or not
|
||||
-- (`<criterio>_bueno`, null while not analysed) and its overall quality. The WebApi picks the study's EEG at a
|
||||
-- cut-off: the first good one by then, or else the latest, marked not valid.
|
||||
|
||||
{% set criterios = [
|
||||
('calidad_amplitud', 'canales_amplitud'), ('calidad_alta_frecuencia', 'canales_alta_frecuencia'),
|
||||
('calidad_correlacion', 'canales_correlacion'), ('calidad_sin_senal', 'canales_sin_senal'),
|
||||
('calidad_linea', 'ruido_linea_db')] %}
|
||||
|
||||
select
|
||||
procedimiento_id, pac_id, fecha_eeg, con_sueno, canales, duracion_min,
|
||||
{%- for r, umbral in criterios %}
|
||||
{{ r }},
|
||||
case when {{ r }} is null then null when {{ tea_criterio_bueno(r, umbral) }} then 1 else 0 end as {{ r }}_bueno,
|
||||
{%- endfor %}
|
||||
calidad,
|
||||
valido
|
||||
from {{ ref('tea_eegs') }}
|
||||
@@ -0,0 +1,37 @@
|
||||
-- One row per child of the cohort, for the follow-up list: the age group, the first M-CHAT and its score, the
|
||||
-- psychology step with its ADOS-2's module and CSS, the neuropediatrics step, the first notes with and without F84.0
|
||||
-- and the EEG step.
|
||||
-- The dates are the steps' as known today (`tea_hitos`, its latest version): the WebApi takes the stage at the cut-off it's asked for. The EEGs and
|
||||
-- their alterations are in `tea_paciente_eegs` and `tea_paciente_eeg_metricas`, also by date.
|
||||
|
||||
with puntaje as (
|
||||
select m.pac_id, max(m.puntaje) as mchat
|
||||
from {{ ref('tea_mchat') }} m
|
||||
join {{ ref('tea_hitos') }} h on h.pac_id = m.pac_id and h.fecha_mchat = m.fecha_mchat and h.vigente = 1
|
||||
group by m.pac_id
|
||||
),
|
||||
|
||||
primer_ados2 as (
|
||||
select a.pac_id, max(a.css) as css_ados2, max(a.modulo) as modulo_ados2
|
||||
from {{ ref('tea_ados2') }} a
|
||||
join (select pac_id, min(fecha_ados2) as fecha from {{ ref('tea_ados2') }} group by pac_id) f
|
||||
on f.pac_id = a.pac_id and f.fecha = a.fecha_ados2
|
||||
group by a.pac_id
|
||||
)
|
||||
|
||||
select
|
||||
h.pac_id,
|
||||
h.grupo_edad,
|
||||
h.fecha_mchat,
|
||||
p.mchat,
|
||||
h.fecha_psicologia,
|
||||
a.css_ados2,
|
||||
a.modulo_ados2,
|
||||
h.fecha_neuropediatria,
|
||||
h.fecha_tea,
|
||||
h.fecha_sin_tea,
|
||||
h.fecha_eeg
|
||||
from {{ ref('tea_hitos') }} h
|
||||
left join puntaje p on p.pac_id = h.pac_id
|
||||
left join primer_ados2 a on a.pac_id = h.pac_id
|
||||
where h.vigente = 1
|
||||
@@ -0,0 +1,22 @@
|
||||
/* One row per psychology note with its ADOS-2: module, algorithm, CSS and classification. A code the catalog
|
||||
doesn't know comes as it arrived. */
|
||||
|
||||
select
|
||||
p.procedimiento_id,
|
||||
p.pac_id,
|
||||
p.fecha as fecha_ados2,
|
||||
coalesce(o_mod.valor_id, o_mod.valor_fuente) as modulo,
|
||||
o_alg.valor_texto as algoritmo,
|
||||
o_css.valor_numerico as css,
|
||||
coalesce(o_cla.valor_id, o_cla.valor_fuente) as clasificacion,
|
||||
p.carga_id
|
||||
from {{ source('silver', 'procedimiento') }} p
|
||||
left join {{ source('silver', 'observacion_clinica') }} o_mod
|
||||
on o_mod.procedimiento_id = p.procedimiento_id and o_mod.resultado_id = 'ados2.modulo'
|
||||
left join {{ source('silver', 'observacion_clinica') }} o_alg
|
||||
on o_alg.procedimiento_id = p.procedimiento_id and o_alg.resultado_id = 'ados2.algoritmo'
|
||||
left join {{ source('silver', 'observacion_clinica') }} o_css
|
||||
on o_css.procedimiento_id = p.procedimiento_id and o_css.resultado_id = 'ados2.css'
|
||||
left join {{ source('silver', 'observacion_clinica') }} o_cla
|
||||
on o_cla.procedimiento_id = p.procedimiento_id and o_cla.resultado_id = 'ados2.clasificacion'
|
||||
where p.estudio_id = 'ados2' and p.clase = 'encuentro'
|
||||
@@ -0,0 +1,17 @@
|
||||
/* One row per ADOS-2 and scored item: its domain (`SA` social affect, `RRB` restricted and repetitive behaviour,
|
||||
from the item's prefix), its label in the catalog, its score and its algorithm score (a 3 counts as 2). */
|
||||
|
||||
select
|
||||
o.procedimiento_id,
|
||||
o.pac_id,
|
||||
case when substring(o.resultado_id, 1, 9) = 'ados2.sa_' then {{ as_text("'SA'") }}
|
||||
else {{ as_text("'RRB'") }} end as dominio,
|
||||
o.resultado_id as reactivo,
|
||||
r.etiqueta,
|
||||
o.valor_numerico as puntaje,
|
||||
case when o.valor_numerico = 3 then 2 else o.valor_numerico end as puntaje_algoritmo
|
||||
from {{ source('silver', 'observacion_clinica') }} o
|
||||
join {{ source('silver', 'cat_resultado') }} r
|
||||
on r.resultado_id = o.resultado_id
|
||||
where (substring(o.resultado_id, 1, 9) = 'ados2.sa_' or substring(o.resultado_id, 1, 10) = 'ados2.rrb_')
|
||||
and o.valor_numerico is not null
|
||||
@@ -0,0 +1,41 @@
|
||||
/* One row per child screened and knowledge version (`tea_versiones`): the first M-CHAT known by then, the age at it
|
||||
in completed months (`tea_meses_cumplidos`) and its age group. `en_cohorte`: the age is within
|
||||
`tea.edad_min_meses` to `tea.edad_max_meses`, or unknown (no birth date: age group `sin_dato`). Within a version
|
||||
the age group is the same in every period the child is counted in. */
|
||||
|
||||
{% set r = var('tea') %}
|
||||
|
||||
with primero as (
|
||||
select v.pac_id, v.conocida_en, v.vigente, min(m.fecha_mchat) as fecha_mchat
|
||||
from {{ ref('tea_versiones') }} v
|
||||
join {{ ref('tea_mchat') }} m on m.pac_id = v.pac_id
|
||||
join {{ source('silver', 'carga') }} c on c.carga_id = m.carga_id and c.inicio <= v.conocida_en
|
||||
where m.fecha_mchat is not null
|
||||
group by v.pac_id, v.conocida_en, v.vigente
|
||||
),
|
||||
|
||||
edad as (
|
||||
select
|
||||
f.pac_id,
|
||||
f.conocida_en,
|
||||
f.vigente,
|
||||
f.fecha_mchat,
|
||||
dm.dia_num as mchat_dia,
|
||||
{{ tea_meses_cumplidos('dm.dia_num - dn.dia_num') }} as edad_meses
|
||||
from primero f
|
||||
join {{ source('silver', 'dim_fecha') }} dm on dm.fecha = f.fecha_mchat
|
||||
left join {{ source('silver', 'persona') }} pe on pe.pac_id = f.pac_id
|
||||
left join {{ source('silver', 'dim_fecha') }} dn on dn.fecha = pe.fecha_nacimiento
|
||||
)
|
||||
|
||||
select
|
||||
e.pac_id,
|
||||
e.conocida_en,
|
||||
e.vigente,
|
||||
e.fecha_mchat,
|
||||
e.mchat_dia,
|
||||
e.edad_meses,
|
||||
{{ tea_grupo_edad('e.edad_meses') }} as grupo_edad,
|
||||
case when e.edad_meses is null or e.edad_meses between {{ r['edad_min_meses'] }} and {{ r['edad_max_meses'] }}
|
||||
then 1 else 0 end as en_cohorte
|
||||
from edad e
|
||||
@@ -0,0 +1,14 @@
|
||||
/* One row per EEG, metric and electrode: the metric's z-score at that 10-20 electrode, from its analysis. */
|
||||
|
||||
select
|
||||
padre.procedimiento_id,
|
||||
padre.pac_id,
|
||||
{{ as_text("substring(o.resultado_id, 5, 64)") }} as metrica,
|
||||
p.codigo_fuente as electrodo,
|
||||
o.valor_numerico as valor
|
||||
from {{ source('silver', 'procedimiento') }} p
|
||||
join {{ source('silver', 'procedimiento') }} padre
|
||||
on padre.procedimiento_id = p.padre_id
|
||||
join {{ source('silver', 'observacion_clinica') }} o
|
||||
on o.procedimiento_id = p.procedimiento_id
|
||||
where p.estudio_id = 'eeg' and p.clase = 'parte'
|
||||
@@ -0,0 +1,44 @@
|
||||
/* One row per EEG and metric its analysis measured: the value, the child's age group at the EEG, the reference
|
||||
range for it, the z-score and its state. `no_evaluable`: the value is null (spindles without sleep) or there's no
|
||||
reference for the age; `aumentado` or `disminuido`: at least `tea.alteracion_z` away from the mean; else `normal`. */
|
||||
|
||||
{% set z = var('tea')['alteracion_z'] %}
|
||||
|
||||
with medidas as (
|
||||
select
|
||||
e.procedimiento_id,
|
||||
e.pac_id,
|
||||
e.fecha_eeg,
|
||||
{{ as_text("substring(o.resultado_id, 5, 64)") }} as metrica,
|
||||
o.valor_numerico as valor,
|
||||
{{ tea_grupo_edad(tea_meses_cumplidos('de.dia_num - dn.dia_num')) }} as grupo_edad_eeg
|
||||
from {{ ref('tea_eegs') }} e
|
||||
join {{ source('silver', 'observacion_clinica') }} o
|
||||
on o.procedimiento_id = e.procedimiento_id
|
||||
and o.resultado_id in ('eeg.ritmo_posterior', 'eeg.husos_sueno_n2', 'eeg.husos_sueno_n3',
|
||||
'eeg.picos_paroxisticos', 'eeg.gradiente_anteroposterior')
|
||||
left join {{ source('silver', 'persona') }} pe on pe.pac_id = e.pac_id
|
||||
left join {{ source('silver', 'dim_fecha') }} de on de.fecha = e.fecha_eeg
|
||||
left join {{ source('silver', 'dim_fecha') }} dn on dn.fecha = pe.fecha_nacimiento
|
||||
),
|
||||
|
||||
puntuadas as (
|
||||
select
|
||||
m.*,
|
||||
r.ref_min,
|
||||
r.ref_max,
|
||||
case when m.valor is not null and r.ref_de > 0 then (m.valor - r.ref_media) / r.ref_de end as valor_z
|
||||
from medidas m
|
||||
left join {{ ref('tea_eeg_referencias') }} r
|
||||
on r.metrica = m.metrica and r.grupo_edad = m.grupo_edad_eeg
|
||||
)
|
||||
|
||||
select
|
||||
p.*,
|
||||
case
|
||||
when p.valor_z is null then {{ as_text("'no_evaluable'") }}
|
||||
when p.valor_z >= {{ z }} then {{ as_text("'aumentado'") }}
|
||||
when p.valor_z <= -{{ z }} then {{ as_text("'disminuido'") }}
|
||||
else {{ as_text("'normal'") }}
|
||||
end as estado
|
||||
from puntuadas p
|
||||
@@ -0,0 +1,10 @@
|
||||
{% set refs = var('tea')['referencias'] %}
|
||||
/* The reference range of each EEG metric by age group at the EEG (`tea.referencias`), with the mean (the middle of
|
||||
the range) and the standard deviation (a quarter of its width) its z-score is computed with. */
|
||||
{% for metrica, grupo, minimo, maximo in refs %}
|
||||
{{ 'union all' if not loop.first }}
|
||||
select {{ as_text("'" ~ metrica ~ "'") }} as metrica, {{ as_text("'" ~ grupo ~ "'") }} as grupo_edad,
|
||||
cast({{ minimo }} as {{ dbt.type_float() }}) as ref_min, cast({{ maximo }} as {{ dbt.type_float() }}) as ref_max,
|
||||
cast({{ (minimo + maximo) / 2 }} as {{ dbt.type_float() }}) as ref_media,
|
||||
cast({{ (maximo - minimo) / 4 }} as {{ dbt.type_float() }}) as ref_de
|
||||
{%- endfor %}
|
||||
@@ -0,0 +1,43 @@
|
||||
/* One row per EEG: what its analysis wrote and its quality. `BUENO` when every criterion is within its threshold
|
||||
(`tea.calidad`), `MALO` when one isn't, `SIN_ANALIZAR` while the analysis hasn't written any. Only a good EEG is
|
||||
valid: a bad one has no result and its alterations don't count. */
|
||||
|
||||
{% set criterios = [
|
||||
('calidad_amplitud', 'canales_amplitud'), ('calidad_alta_frecuencia', 'canales_alta_frecuencia'),
|
||||
('calidad_correlacion', 'canales_correlacion'), ('calidad_sin_senal', 'canales_sin_senal'),
|
||||
('calidad_linea', 'ruido_linea_db')] %}
|
||||
|
||||
with valores as (
|
||||
select
|
||||
p.procedimiento_id,
|
||||
p.pac_id,
|
||||
p.fuente_id,
|
||||
p.fecha as fecha_eeg,
|
||||
p.carga_id,
|
||||
max(case when o.resultado_id = 'eeg.con_sueno' then o.valor_numerico end) as con_sueno,
|
||||
max(case when o.resultado_id = 'eeg.canales' then o.valor_numerico end) as canales,
|
||||
max(case when o.resultado_id = 'eeg.duracion_min' then o.valor_numerico end) as duracion_min,
|
||||
{%- for resultado, _ in criterios %}
|
||||
max(case when o.resultado_id = 'eeg.{{ resultado }}' then o.valor_numerico end) as {{ resultado }}{{ ',' if not loop.last }}
|
||||
{%- endfor %}
|
||||
from {{ source('silver', 'procedimiento') }} p
|
||||
left join {{ source('silver', 'observacion_clinica') }} o
|
||||
on o.procedimiento_id = p.procedimiento_id
|
||||
where p.estudio_id = 'eeg' and p.clase = 'toma'
|
||||
group by p.procedimiento_id, p.pac_id, p.fuente_id, p.fecha, p.carga_id
|
||||
)
|
||||
|
||||
select
|
||||
v.*,
|
||||
case
|
||||
when {% for r, _ in criterios %}v.{{ r }} is null{{ ' and ' if not loop.last }}{% endfor %}
|
||||
then {{ as_text("'SIN_ANALIZAR'") }}
|
||||
when {% for r, umbral in criterios %}{{ tea_criterio_bueno('v.' ~ r, umbral) }}{{ ' and ' if not loop.last }}{% endfor %}
|
||||
then {{ as_text("'BUENO'") }}
|
||||
else {{ as_text("'MALO'") }}
|
||||
end as calidad,
|
||||
case
|
||||
when {% for r, umbral in criterios %}{{ tea_criterio_bueno('v.' ~ r, umbral) }}{{ ' and ' if not loop.last }}{% endfor %}
|
||||
then 1 else 0
|
||||
end as valido
|
||||
from valores v
|
||||
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
One row per child of the cohort and knowledge version (`tea_versiones`): the date of each step of the screening,
|
||||
from the facts known by that version. `vigente` marks the child's latest version.
|
||||
|
||||
Steps go in order (M-CHAT, psychology note with the ADOS-2, neuropediatrics note, good-quality EEG) and each needs
|
||||
the previous one: a step is dated by the later of its first fact and the previous step (an EEG before the note
|
||||
counts from the note). Without the previous step, a step isn't reached. The neuropediatrics step takes any note;
|
||||
`fecha_tea` is the first note that confirms (F84.0), `fecha_sin_tea` the first that doesn't, and both need the
|
||||
psychology step, as the note does. `fecha_eeg_estudio` is the first good EEG, the one the study uses, whether or
|
||||
not the chain reached it.
|
||||
*/
|
||||
|
||||
{# The first fact of each kind known by each version: (CTE, facts, condition). #}
|
||||
{% set primeras = [
|
||||
('primera_psicologia', 'ados', '1 = 1'), ('primera_nota', 'notas', '1 = 1'),
|
||||
('primera_tea', 'notas', 'h.es_tea = 1'), ('primera_sin_tea', 'notas', 'h.es_tea = 0'),
|
||||
('fecha_primer_bueno', 'buenos', '1 = 1')] %}
|
||||
|
||||
with ados as (
|
||||
select a.pac_id, a.fecha_ados2 as fecha, c.inicio as conocida_en
|
||||
from {{ ref('tea_ados2') }} a
|
||||
join {{ source('silver', 'carga') }} c on c.carga_id = a.carga_id
|
||||
where a.fecha_ados2 is not null
|
||||
),
|
||||
|
||||
notas as (
|
||||
select n.pac_id, n.fecha_nota as fecha, n.es_tea, c.inicio as conocida_en
|
||||
from {{ ref('tea_neuropediatria') }} n
|
||||
join {{ source('silver', 'carga') }} c on c.carga_id = n.carga_id
|
||||
where n.fecha_nota is not null
|
||||
),
|
||||
|
||||
buenos as (
|
||||
select e.pac_id, e.procedimiento_id, e.fecha_eeg as fecha, c.inicio as conocida_en
|
||||
from {{ ref('tea_eegs') }} e
|
||||
join {{ source('silver', 'carga') }} c on c.carga_id = e.carga_id
|
||||
where e.valido = 1 and e.fecha_eeg is not null
|
||||
),
|
||||
|
||||
{% for nombre, hechos, condicion in primeras %}
|
||||
{{ nombre }} as (
|
||||
select k.pac_id, k.conocida_en, min(h.fecha) as fecha
|
||||
from {{ ref('tea_cohorte') }} k
|
||||
join {{ hechos }} h on h.pac_id = k.pac_id and h.conocida_en <= k.conocida_en
|
||||
where {{ condicion }}
|
||||
group by k.pac_id, k.conocida_en
|
||||
),
|
||||
{% endfor %}
|
||||
|
||||
|
||||
primer_bueno as (
|
||||
-- The first good EEG; two on the same day: the first written.
|
||||
select f.pac_id, f.conocida_en, f.fecha, min(b.procedimiento_id) as procedimiento_id
|
||||
from fecha_primer_bueno f
|
||||
join buenos b on b.pac_id = f.pac_id and b.fecha = f.fecha and b.conocida_en <= f.conocida_en
|
||||
group by f.pac_id, f.conocida_en, f.fecha
|
||||
),
|
||||
|
||||
encadenados as (
|
||||
select
|
||||
k.pac_id,
|
||||
k.conocida_en,
|
||||
k.vigente,
|
||||
k.grupo_edad,
|
||||
k.fecha_mchat,
|
||||
k.mchat_dia,
|
||||
{{ tea_despues('k.fecha_mchat', 'ps.fecha') }} as fecha_psicologia,
|
||||
nt.fecha as nota_fecha,
|
||||
tea.fecha as tea_fecha,
|
||||
st.fecha as sin_tea_fecha,
|
||||
pb.procedimiento_id as eeg_estudio_id,
|
||||
pb.fecha as fecha_eeg_estudio
|
||||
from {{ ref('tea_cohorte') }} k
|
||||
left join primera_psicologia ps on ps.pac_id = k.pac_id and ps.conocida_en = k.conocida_en
|
||||
left join primera_nota nt on nt.pac_id = k.pac_id and nt.conocida_en = k.conocida_en
|
||||
left join primera_tea tea on tea.pac_id = k.pac_id and tea.conocida_en = k.conocida_en
|
||||
left join primera_sin_tea st on st.pac_id = k.pac_id and st.conocida_en = k.conocida_en
|
||||
left join primer_bueno pb on pb.pac_id = k.pac_id and pb.conocida_en = k.conocida_en
|
||||
where k.en_cohorte = 1
|
||||
),
|
||||
|
||||
neuro as (
|
||||
select
|
||||
e.*,
|
||||
{{ tea_despues('e.fecha_psicologia', 'e.nota_fecha') }} as fecha_neuropediatria,
|
||||
{{ tea_despues('e.fecha_psicologia', 'e.tea_fecha') }} as fecha_tea,
|
||||
{{ tea_despues('e.fecha_psicologia', 'e.sin_tea_fecha') }} as fecha_sin_tea
|
||||
from encadenados e
|
||||
)
|
||||
|
||||
select
|
||||
n.pac_id,
|
||||
n.conocida_en,
|
||||
n.vigente,
|
||||
n.grupo_edad,
|
||||
n.fecha_mchat,
|
||||
n.mchat_dia,
|
||||
n.fecha_psicologia,
|
||||
n.fecha_neuropediatria,
|
||||
{{ tea_despues('n.fecha_neuropediatria', 'n.fecha_eeg_estudio') }} as fecha_eeg,
|
||||
n.fecha_tea,
|
||||
n.fecha_sin_tea,
|
||||
n.eeg_estudio_id,
|
||||
n.fecha_eeg_estudio
|
||||
from neuro n
|
||||
@@ -14,31 +14,8 @@ models:
|
||||
# columna, fecha (procedimiento | nacimiento), fecha_resultado (an observed date that goes first),
|
||||
# del_padre (date and patient from the parent procedure).
|
||||
fuentes:
|
||||
- {estudio_id: "evaluacion_psicologica", clase: "encuentro", resultado_id: "evaluacion_psicologica.instrumento_tamizaje", clase_de_linea: "procedimiento", tipo: "evaluacion_psicologica", fecha_resultado: "evaluacion_psicologica.fecha_evaluacion"}
|
||||
- {estudio_id: "mchat", clase: "toma", resultado_id: "mchat.interpretacion", clase_de_linea: "medicion", tipo: "instrumento", codigo: "M_CHAT_R_F", fecha_resultado: "evaluacion_psicologica.fecha_evaluacion", del_padre: true}
|
||||
- {estudio_id: "ramos", clase: "toma", resultado_id: "ramos.interpretacion", clase_de_linea: "medicion", tipo: "instrumento", codigo: "RAMOS", fecha_resultado: "evaluacion_psicologica.fecha_evaluacion", del_padre: true}
|
||||
- {estudio_id: "eeg", clase: "toma", resultado_id: "eeg.utilizable", clase_de_linea: "procedimiento", tipo: "eeg", codigo: "electroencefalograma", valor: "numerico"}
|
||||
- {estudio_id: "pea", clase: "toma", resultado_id: "pea.grado_hipoacusia", clase_de_linea: "medicion", tipo: "pea"}
|
||||
- {estudio_id: "parto", clase: "encuentro", resultado_id: "parto.apgar_5min", clase_de_linea: "antecedente", tipo: "apgar_5min", valor: "numerico", fecha: "nacimiento"}
|
||||
- {estudio_id: "parto", clase: "encuentro", resultado_id: "parto.ingreso_ucin", clase_de_linea: "antecedente", tipo: "ingreso_ucin", valor: "numerico", fecha: "nacimiento"}
|
||||
- {estudio_id: "historia_perinatal", clase: "encuentro", resultado_id: "historia_perinatal.antecedente_aborto", clase_de_linea: "antecedente", tipo: "antecedente_aborto", valor: "numerico", fecha: "nacimiento"}
|
||||
- {estudio_id: "historia_perinatal", clase: "encuentro", resultado_id: "historia_perinatal.asma", clase_de_linea: "antecedente", tipo: "asma", valor: "numerico", fecha: "nacimiento"}
|
||||
- {estudio_id: "historia_perinatal", clase: "encuentro", resultado_id: "historia_perinatal.crisis_convulsivas", clase_de_linea: "antecedente", tipo: "crisis_convulsivas", valor: "numerico", fecha: "nacimiento"}
|
||||
- {estudio_id: "historia_perinatal", clase: "encuentro", resultado_id: "historia_perinatal.diabetes_gestacional", clase_de_linea: "antecedente", tipo: "diabetes_gestacional", valor: "numerico", fecha: "nacimiento"}
|
||||
- {estudio_id: "historia_perinatal", clase: "encuentro", resultado_id: "historia_perinatal.embarazo_multiple", clase_de_linea: "antecedente", tipo: "embarazo_multiple", valor: "numerico", fecha: "nacimiento"}
|
||||
- {estudio_id: "historia_perinatal", clase: "encuentro", resultado_id: "historia_perinatal.enfermedad_autoinmune", clase_de_linea: "antecedente", tipo: "enfermedad_autoinmune", valor: "numerico", fecha: "nacimiento"}
|
||||
- {estudio_id: "historia_perinatal", clase: "encuentro", resultado_id: "historia_perinatal.estres_agudo", clase_de_linea: "antecedente", tipo: "estres_agudo", valor: "numerico", fecha: "nacimiento"}
|
||||
- {estudio_id: "historia_perinatal", clase: "encuentro", resultado_id: "historia_perinatal.farmaco_riesgo_neurodesarrollo", clase_de_linea: "antecedente", tipo: "farmaco_riesgo_neurodesarrollo", valor: "numerico", fecha: "nacimiento"}
|
||||
- {estudio_id: "historia_perinatal", clase: "encuentro", resultado_id: "historia_perinatal.hipertension_preeclampsia", clase_de_linea: "antecedente", tipo: "hipertension_preeclampsia", valor: "numerico", fecha: "nacimiento"}
|
||||
- {estudio_id: "historia_perinatal", clase: "encuentro", resultado_id: "historia_perinatal.hipertiroidismo", clase_de_linea: "antecedente", tipo: "hipertiroidismo", valor: "numerico", fecha: "nacimiento"}
|
||||
- {estudio_id: "historia_perinatal", clase: "encuentro", resultado_id: "historia_perinatal.hipotiroidismo", clase_de_linea: "antecedente", tipo: "hipotiroidismo", valor: "numerico", fecha: "nacimiento"}
|
||||
- {estudio_id: "historia_perinatal", clase: "encuentro", resultado_id: "historia_perinatal.hipoxia_materna", clase_de_linea: "antecedente", tipo: "hipoxia_materna", valor: "numerico", fecha: "nacimiento"}
|
||||
- {estudio_id: "historia_perinatal", clase: "encuentro", resultado_id: "historia_perinatal.incompatibilidad_rh", clase_de_linea: "antecedente", tipo: "incompatibilidad_rh", valor: "numerico", fecha: "nacimiento"}
|
||||
- {estudio_id: "historia_perinatal", clase: "encuentro", resultado_id: "historia_perinatal.infeccion_gestacion", clase_de_linea: "antecedente", tipo: "infeccion_gestacion", valor: "numerico", fecha: "nacimiento"}
|
||||
- {estudio_id: "historia_perinatal", clase: "encuentro", resultado_id: "historia_perinatal.liquido_amniotico", clase_de_linea: "antecedente", tipo: "liquido_amniotico", valor: "numerico", fecha: "nacimiento"}
|
||||
- {estudio_id: "historia_perinatal", clase: "encuentro", resultado_id: "historia_perinatal.migrana", clase_de_linea: "antecedente", tipo: "migrana", valor: "numerico", fecha: "nacimiento"}
|
||||
- {estudio_id: "historia_perinatal", clase: "encuentro", resultado_id: "historia_perinatal.proceso_proinflamatorio", clase_de_linea: "antecedente", tipo: "proceso_proinflamatorio", valor: "numerico", fecha: "nacimiento"}
|
||||
- {estudio_id: "historia_perinatal", clase: "encuentro", resultado_id: "historia_perinatal.tabaquismo_gestacion", clase_de_linea: "antecedente", tipo: "tabaquismo_gestacion", valor: "numerico", fecha: "nacimiento"}
|
||||
- {estudio_id: "historia_perinatal", clase: "encuentro", resultado_id: "historia_perinatal.trastorno_neurologico", clase_de_linea: "antecedente", tipo: "trastorno_neurologico", valor: "numerico", fecha: "nacimiento"}
|
||||
- {estudio_id: "mchat", clase: "toma", resultado_id: "mchat.puntaje", clase_de_linea: "medicion", tipo: "mchat", valor: "numerico"}
|
||||
- {estudio_id: "ados2", clase: "encuentro", resultado_id: "ados2.css", clase_de_linea: "medicion", tipo: "ados2", valor: "numerico"}
|
||||
- {estudio_id: "evaluacion_neuropediatrica", clase: "encuentro", resultado_id: "evaluacion_neuropediatrica.diagnostico", clase_de_linea: "diagnostico", tipo: "evaluacion_neuropediatrica"}
|
||||
- {estudio_id: "eeg", clase: "toma", resultado_id: null, clase_de_linea: "procedimiento", tipo: "eeg", codigo: "electroencefalograma", columna: "id_hospital"}
|
||||
- {estudio_id: null, clase: "orden", resultado_id: null, clase_de_linea: "orden", tipo: "orden", columna: "codigo_fuente"}
|
||||
- {estudio_id: "nota_medica", clase: "encuentro", resultado_id: "nota_medica.diagnostico", clase_de_linea: "diagnostico", tipo: "nota_medica"}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
/* One row per M-CHAT: its date and total score. */
|
||||
|
||||
select
|
||||
p.procedimiento_id,
|
||||
p.pac_id,
|
||||
p.fecha as fecha_mchat,
|
||||
o.valor_numerico as puntaje,
|
||||
p.carga_id
|
||||
from {{ source('silver', 'procedimiento') }} p
|
||||
left join {{ source('silver', 'observacion_clinica') }} o
|
||||
on o.procedimiento_id = p.procedimiento_id and o.resultado_id = 'mchat.puntaje'
|
||||
where p.estudio_id = 'mchat' and p.clase = 'toma'
|
||||
@@ -0,0 +1,14 @@
|
||||
/* One row per neuropediatrics note: its ICD-10 code (without the dot) and whether it confirms TEA (`tea.cie_tea`,
|
||||
exactly: F84 without its subcode doesn't). */
|
||||
|
||||
select
|
||||
p.procedimiento_id,
|
||||
p.pac_id,
|
||||
p.fecha as fecha_nota,
|
||||
o.valor_texto as cie_codigo,
|
||||
case when o.valor_texto in {{ sql_list(var('tea')['cie_tea']) }} then 1 else 0 end as es_tea,
|
||||
p.carga_id
|
||||
from {{ source('silver', 'procedimiento') }} p
|
||||
left join {{ source('silver', 'observacion_clinica') }} o
|
||||
on o.procedimiento_id = p.procedimiento_id and o.resultado_id = 'evaluacion_neuropediatrica.diagnostico'
|
||||
where p.estudio_id = 'evaluacion_neuropediatrica' and p.clase = 'encuentro'
|
||||
@@ -0,0 +1,32 @@
|
||||
/* One row per child and knowledge version: each load's start (`carga.inicio`) in which a fact of the child's
|
||||
screening arrived (an M-CHAT, an ADOS-2, a neuropediatrics note or an EEG). What was known of a child at a date is
|
||||
their latest version by then; `vigente` marks the latest of all. */
|
||||
|
||||
with hechos as (
|
||||
select m.pac_id, c.inicio as conocida_en
|
||||
from {{ ref('tea_mchat') }} m
|
||||
join {{ source('silver', 'carga') }} c on c.carga_id = m.carga_id
|
||||
where m.fecha_mchat is not null
|
||||
union
|
||||
select a.pac_id, c.inicio
|
||||
from {{ ref('tea_ados2') }} a
|
||||
join {{ source('silver', 'carga') }} c on c.carga_id = a.carga_id
|
||||
where a.fecha_ados2 is not null
|
||||
union
|
||||
select n.pac_id, c.inicio
|
||||
from {{ ref('tea_neuropediatria') }} n
|
||||
join {{ source('silver', 'carga') }} c on c.carga_id = n.carga_id
|
||||
where n.fecha_nota is not null
|
||||
union
|
||||
select e.pac_id, c.inicio
|
||||
from {{ ref('tea_eegs') }} e
|
||||
join {{ source('silver', 'carga') }} c on c.carga_id = e.carga_id
|
||||
where e.fecha_eeg is not null
|
||||
)
|
||||
|
||||
select
|
||||
h.pac_id,
|
||||
h.conocida_en,
|
||||
case when h.conocida_en = u.ultima then 1 else 0 end as vigente
|
||||
from hechos h
|
||||
join (select pac_id, max(conocida_en) as ultima from hechos group by pac_id) u on u.pac_id = h.pac_id
|
||||
+1
-1
Submodule WebApi updated: c430a5bd11...dc9a3422e0
+1
-1
Submodule indicadores_kit updated: a20b4ed13c...05ed37ff04
+1
-1
Submodule models updated: a4ddad5c8e...c50c3a081e
Reference in New Issue
Block a user