CaMa's silver load reads results from the reports' text, mapped by the catalog
How: `silver.extracted.DesdeTexto` turns the catalog's `etiquetas_fuente` and each value's `alias` into Extraction's field specs and into derived columns of a `DeStaging`. CaMa reads density and lesion size from the mammography interpretation, histology, grade, receptors, HER2 and Ki-67 from the pathology PDF's text layer (no OCR at load time), and the clinical stage from the note's texts. `resultados_extraibles` reads and checks the new keys: captions are a non-empty list, aliases need captions, and no spelling names two values. Implications: a code comes with the spelling it matched as `valor_fuente`; an unknown spelling is kept as `valor_fuente` with no code, counted as out of catalog, and becomes a code on the next load once its alias is in the catalog. Nothing is renamed in the stored data and no table or column changes. The synthetic CaMa staging gains a mammography text, a pathology PDF and a note with a stage.
This commit is contained in:
@@ -9,11 +9,13 @@ da sus tablas y su catálogo de especialidades. Es la normalización que hacían
|
||||
como llegó;
|
||||
- el CIE-10 de la nota, sin espacios ni punto y en mayúsculas; su identificador del hospital, en `id_hospital`;
|
||||
- el motivo de consulta y el diagnóstico en texto, solo si el proyecto los pide (`con_textos`, CaCu: T-24b),
|
||||
sin normalizarlos (I-K61).
|
||||
sin normalizarlos (I-K61);
|
||||
- the catalog results a project reads from the note's texts (`extraidos`, CaMa's clinical stage).
|
||||
"""
|
||||
|
||||
from collections.abc import Collection, Mapping
|
||||
|
||||
from webapi.orchestration.silver.extracted import DesdeTexto
|
||||
from webapi.orchestration.silver.values import INTENCION, cie, codigo_de_especialidad, texto_limpio
|
||||
from webapi.orchestration.silver.procedures import DeStaging
|
||||
|
||||
@@ -52,22 +54,26 @@ def orden_de_estudio(staging: type, alias: Mapping[str, str], codigos: Collectio
|
||||
|
||||
|
||||
def nota_medica(
|
||||
staging: type, alias: Mapping[str, str], codigos: Collection[str], *, con_textos: bool = False
|
||||
staging: type, alias: Mapping[str, str], codigos: Collection[str], *, con_textos: bool = False,
|
||||
extraidos: DesdeTexto | None = None,
|
||||
) -> DeStaging:
|
||||
textos = {
|
||||
"motivo": lambda f: texto_limpio(f.nm_motivo_consulta),
|
||||
"diagnostico_texto": lambda f: texto_limpio(f.nm_diagnostico_texto),
|
||||
} if con_textos else {}
|
||||
leidos = extraidos.derivadas if extraidos else {}
|
||||
return DeStaging(
|
||||
staging, "nm_id", "encuentro", estudio_id="nota_medica", fecha="nm_fecha",
|
||||
columnas={"id_hospital": "nm_id_hospital"}, # para ligarla después con sus órdenes (provisional)
|
||||
derivadas={
|
||||
"cie_codigo": lambda f: cie(f.nm_cie_codigo), **especialidad("nm_especialidad", alias, codigos), **textos,
|
||||
**leidos,
|
||||
},
|
||||
resultados={
|
||||
"cie_codigo": "nota_medica.diagnostico",
|
||||
"especialidad": "nota_medica.especialidad",
|
||||
**({f: f"nota_medica.{f}" for f in textos}),
|
||||
**(extraidos.resultados if extraidos else {}),
|
||||
},
|
||||
fuentes={"especialidad": "especialidad_fuente"},
|
||||
fuentes={"especialidad": "especialidad_fuente", **(extraidos.fuentes if extraidos else {})},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user