Files
ISSSTELEON/Extraction/extraction/nlp/vocabulary.py
T

407 lines
24 KiB
Python

"""Captions and clinical synonyms used by the source documents, keyed by
the column they fill. Extend these tables when a new report format shows a
caption or a term the extractor doesn't know yet; no code changes are needed.
"""
import re
# Column -> captions printed before its value (accents/case don't matter).
LABELS: dict[str, tuple[str, ...]] = {
"pac_id_hospital": ("expediente", "no. expediente", "num. expediente", "número de expediente", "nss", "no. de afiliación", "afiliación", "registro", "folio del paciente"),
"pac_sexo": ("sexo", "género", "genero"),
"pac_fecha_nacimiento": ("fecha de nacimiento", "f. de nacimiento", "f. nacimiento", "fecha nac", "f. nac", "nacimiento", "fec. nac"),
"pac_codigo_postal": ("código postal", "c.p.", "cp"),
"pac_dependencia": ("dependencia",),
"pac_parentesco": ("parentesco",),
"ord_numero_hospital": ("número de orden", "no. de orden", "orden", "folio de orden", "solicitud"),
"ord_fecha_solicitud": ("fecha de solicitud", "solicitado el"),
"ord_fecha_resultado": ("fecha de resultado", "fecha del resultado"),
"ord_medico_solicitante": ("médico solicitante", "solicitante", "solicita"),
"ord_diagnostico": ("diagnóstico", "dx"),
"cit_fecha_toma": ("fecha de toma", "toma de muestra", "fecha toma", "fecha de muestra"),
"cit_fecha_reporte": ("fecha de reporte", "fecha del reporte", "fecha de informe", "reportado el"),
"cit_calidad_especimen": ("calidad de la muestra", "calidad del espécimen", "calidad de muestra"),
"cit_celulas_escamosas": ("células escamosas", "celulas escamosas", "anormalidades en células escamosas", "interpretación", "resultado citológico"),
"cit_celulas_glandulares": ("células glandulares",),
"cit_dx_lesion": ("diagnóstico",),
"cit_observaciones": ("observaciones", "comentarios", "notas"),
"cit_vph_resultado": ("resultado vph", "vph de alto riesgo", "vph alto riesgo", "virus del papiloma humano", "detección de vph", "vph", "hpv"),
"cit_vph_genotipo_16": ("genotipo 16", "vph 16", "hpv 16", "vph-16", "tipo 16"),
"cit_vph_genotipo_18": ("genotipo 18", "vph 18", "hpv 18", "vph-18", "tipo 18"),
"bx_fecha_solicitud": ("fecha de solicitud", "fecha de toma"),
"bx_fecha_reporte": ("fecha de reporte", "fecha del reporte", "fecha de informe"),
"bx_cin_grado": ("diagnóstico", "diagnóstico histopatológico", "resultado", "conclusión", "nic", "cin"),
"bx_grado_histologico": ("diagnóstico", "diagnóstico histopatológico", "resultado", "conclusión", "grado histológico"),
"bx_observaciones": ("observaciones", "descripción microscópica", "comentarios"),
"mast_birads": ("bi-rads", "birads", "categoría", "clasificación"),
"mast_fecha_toma": ("fecha de estudio", "fecha de toma", "fecha"),
"mast_interpretacion": ("interpretación", "impresión diagnóstica", "conclusión", "hallazgos"),
"nm_fecha": ("fecha", "fecha de consulta", "fecha de la nota"),
"nm_medico_tratante": ("médico tratante", "médico", "atendió"),
"nm_especialidad": ("especialidad", "servicio"),
"nm_motivo_consulta": ("motivo de consulta", "motivo"),
"nm_diagnostico_texto": ("diagnóstico", "impresión diagnóstica", "dx"),
"nm_cie_codigo": ("cie-10", "cie10", "cie"),
"nm_tratamiento_texto": ("tratamiento", "plan terapéutico"),
"nm_plan_estudios": ("plan", "estudios solicitados"),
"nm_pronostico": ("pronóstico",),
"nm_talla": ("talla", "estatura"),
"nm_masa_corporal": ("peso",),
"nm_imc_visita": ("imc", "índice de masa corporal"),
"nm_temperatura": ("temperatura", "temp"),
"nm_frecuencia_cardiaca": ("frecuencia cardiaca", "fc"),
"nm_frecuencia_respiratoria": ("frecuencia respiratoria", "fr"),
"hemoglobina_g_dl": ("hemoglobina", "hb", "hgb"),
"hematocrito_pct": ("hematocrito", "hto", "hct"),
"eritrocitos_mill_ul": ("eritrocitos", "glóbulos rojos", "rbc"),
"leucocitos_mil_ul": ("leucocitos", "glóbulos blancos", "wbc"),
"plaquetas_mil_ul": ("plaquetas", "plt"),
"neutrofilos_pct": ("neutrófilos",),
"linfocitos_pct": ("linfocitos",),
"monocitos_pct": ("monocitos",),
"eosinofilos_pct": ("eosinófilos",),
"basofilos_pct": ("basófilos",),
"bh_fecha": ("fecha", "fecha de toma"),
"eeg_id_registro_laboratorio": ("no. de estudio", "número de estudio", "folio", "no. de registro", "registro de laboratorio"),
"eeg_fecha_estudio": ("fecha de estudio", "fecha del estudio", "fecha de registro"),
"eeg_fecha_reporte": ("fecha de reporte", "fecha del reporte", "fecha de interpretación"),
"eeg_medico_interpreta": ("médico interpreta", "interpretado por", "médico que interpreta"),
"eeg_estado_registro": ("estado del registro", "estado"),
"eeg_calidad_tecnica": ("calidad técnica", "calidad del registro"),
"eeg_simetria": ("simetría", "simetria"),
"eeg_distribucion_anormalidad": ("distribución de la anormalidad", "localización de la anormalidad"),
"eeg_respuesta_fotoestimulacion": ("respuesta a fotoestimulación", "fotoestimulación"),
"eeg_conclusion_texto": ("conclusión", "impresión diagnóstica", "interpretación"),
"eeg_conclusion_categoria": ("conclusión", "categoría diagnóstica"),
}
# Free-text terms -> catalog value. Only what the source documents say
# differently from the catalog itself; the catalog values and their own
# aliases are added by whoever builds the FieldSpec.
CLINICAL_TERMS: dict[str, dict[str, object]] = {
"cit_vph_resultado": {
"POSITIVO": "POSITIVO",
"DETECTADO": "POSITIVO",
"NEGATIVO": "NEGATIVO",
"NO DETECTADO": "NEGATIVO",
"INDETERMINADO": "INDETERMINADO",
"INVALIDO": "INDETERMINADO",
"NO CONCLUYENTE": "INDETERMINADO",
},
"cit_vph_genotipo_16": {"POSITIVO": 1, "DETECTADO": 1, "PRESENTE": 1, "NEGATIVO": 0, "NO DETECTADO": 0, "AUSENTE": 0},
"cit_vph_genotipo_18": {"POSITIVO": 1, "DETECTADO": 1, "PRESENTE": 1, "NEGATIVO": 0, "NO DETECTADO": 0, "AUSENTE": 0},
"cit_celulas_escamosas": {
"ASCUS": "ASC-US",
"ASC US": "ASC-US",
"LSIL": "LIEBG",
"LIE BAJO GRADO": "LIEBG",
"LESION INTRAEPITELIAL ESCAMOSA DE BAJO GRADO": "LIEBG",
"HSIL": "LIEAG",
"LIE ALTO GRADO": "LIEAG",
"LESION INTRAEPITELIAL ESCAMOSA DE ALTO GRADO": "LIEAG",
"NEGATIVO PARA LESION INTRAEPITELIAL": "NORMAL",
"NEGATIVO PARA LESION INTRAEPITELIAL O MALIGNIDAD": "NORMAL",
},
"bx_cin_grado": {
"NIC I": "LIEBG", "NIC 1": "LIEBG", "CIN I": "LIEBG", "CIN 1": "LIEBG", "DISPLASIA LEVE": "LIEBG",
"NIC II": "LIEAG", "NIC 2": "LIEAG", "CIN II": "LIEAG", "CIN 2": "LIEAG", "DISPLASIA MODERADA": "LIEAG",
"NIC III": "LIEAG", "NIC 3": "LIEAG", "CIN III": "LIEAG", "CIN 3": "LIEAG", "DISPLASIA SEVERA": "LIEAG",
"LESION INTRAEPITELIAL DE BAJO GRADO": "LIEBG", "LESION INTRAEPITELIAL ESCAMOSA DE BAJO GRADO": "LIEBG",
"LESION INTRAEPITELIAL DE ALTO GRADO": "LIEAG", "LESION INTRAEPITELIAL ESCAMOSA DE ALTO GRADO": "LIEAG",
"CARCINOMA IN SITU": "CIS",
"CARCINOMA EPIDERMOIDE INVASOR": "CARCINOMA", "CARCINOMA INVASOR": "CARCINOMA", "CARCINOMA EPIDERMOIDE": "CARCINOMA",
"ADENOCARCINOMA": "CARCINOMA",
"CERVICITIS CRONICA": "NORMAL", "SIN ALTERACIONES": "NORMAL", "NEGATIVO PARA DISPLASIA": "NORMAL",
"NEGATIVO PARA MALIGNIDAD": "NORMAL",
},
"bx_grado_histologico": {
"CARCINOMA DUCTAL INFILTRANTE": "CARCINOMA_INVASOR",
"CARCINOMA LOBULILLAR INFILTRANTE": "CARCINOMA_INVASOR",
"CARCINOMA DUCTAL INVASOR": "CARCINOMA_INVASOR",
"CARCINOMA INVASOR": "CARCINOMA_INVASOR",
"CARCINOMA INFILTRANTE": "CARCINOMA_INVASOR",
"CARCINOMA DUCTAL IN SITU": "CARCINOMA_IN_SITU",
"CARCINOMA LOBULILLAR IN SITU": "CARCINOMA_IN_SITU",
"CARCINOMA IN SITU": "CARCINOMA_IN_SITU",
"CDIS": "CARCINOMA_IN_SITU",
"FIBROADENOMA": "BENIGNO",
"MASTOPATIA FIBROQUISTICA": "BENIGNO",
"CAMBIOS FIBROQUISTICOS": "BENIGNO",
"HIPERPLASIA DUCTAL USUAL": "BENIGNO",
"BENIGNO": "BENIGNO",
"NEGATIVO PARA MALIGNIDAD": "BENIGNO",
},
"mast_birads": {f"BI-RADS {n}": str(n) for n in ("0", "1", "2", "3", "4", "4A", "4B", "4C", "5", "6")},
}
# Columns worth looking for anywhere in the narrative, not only after a caption.
FREE_TEXT_FIELDS = frozenset(
{"cit_vph_resultado", "cit_celulas_escamosas", "cit_celulas_glandulares", "bx_cin_grado", "bx_grado_histologico", "mast_birads", "nm_cie_codigo"}
)
# Shape of a valid value.
PATTERNS: dict[str, str] = {
"pac_codigo_postal": r"(?<!\d)\d{5}(?!\d)",
"nm_cie_codigo": r"\b[A-TV-Z][0-9]{2}(?:\.[0-9A-Z]{1,2})?\b",
}
_DOMAIN_PREFIX = re.compile(r"^(pac|ord|cit|bx|mast|nm|bh|eeg|psi|pea|amg|pn)_")
def labels_for(column: str, description: str | None = None) -> tuple[str, ...]:
"""Known captions, plus the column name itself in words
(`pac_fecha_nacimiento` -> "fecha nacimiento") and a short
description when the schema has one."""
labels = list(LABELS.get(column, ()))
words = _DOMAIN_PREFIX.sub("", column).replace("_", " ").strip()
if words and words not in labels and not words.isdigit():
labels.append(words)
if description:
short = _caption_from_description(description)
if short and len(short.split()) <= 5 and short.lower() not in (label.lower() for label in labels):
labels.append(short)
return tuple(labels)
_DESCRIPTION_CODE = re.compile(r"^\s*[A-Z]{1,4}[-.]?\d+[A-Z]?[.:)\-]*\s+")
def _caption_from_description(description: str) -> str:
"""The part of a schema description a form would print as the
caption: without a leading item code (`A1.`) or what follows a dash,
a parenthesis or a colon."""
short = _DESCRIPTION_CODE.sub("", description)
for cut in ("—", "(", ":", ";", ","):
short = short.split(cut)[0]
return short.strip()
# What a report is about, per target table: a document that names none of
# these is probably a different kind of report (a biopsy read as a cytology).
SUBJECTS: dict[str, tuple[str, ...]] = {
"citologiacervical": ("citología", "citológico", "papanicolaou", "papanicolau", "bethesda", "virus del papiloma", "vph", "hpv"),
"biopsiacervical": ("biopsia", "histopatológico", "histopatología", "histológico", "cono cervical", "conización"),
"mastografia": ("mastografía", "mamografía", "mastográfico", "bi-rads", "birads", "tomosíntesis"),
"biopsiamama": ("biopsia", "histopatológico", "histopatología", "trucut", "tru-cut", "aguja gruesa", "mama"),
"eeg_estudio": ("electroencefalograma", "electroencefalografía", "electroencefalográfico", "eeg", "video-eeg", "videoelectroencefalograma"),
}
# Concepts a generic answer must be next to, in narrative text, to count for
# a field: "POSITIVO" alone says nothing about which test was positive.
ANCHORS: dict[str, tuple[str, ...]] = {
"cit_vph_resultado": ("vph", "hpv", "virus del papiloma", "papiloma humano"),
"cit_vph_genotipo_16": ("16",),
"cit_vph_genotipo_18": ("18",),
"cit_celulas_escamosas": ("escamosa", "escamosas", "intraepitelial", "células", "citológico", "citología"),
"bx_cin_grado": ("biopsia", "cérvix", "cervix", "diagnóstico", "intraepitelial", "displasia"),
"eeg_anormalidad_presente": ("eeg", "electroencefalograma", "trazo", "registro", "estudio"),
"eeg_actividad_epileptiforme": ("epileptiforme", "epileptiformes", "paroxística", "paroxísticas"),
"eeg_ritmo_base_frecuencia": ("ritmo de fondo", "actividad de fondo", "ritmo base", "ritmo de base", "ritmo dominante", "ritmo posterior", "actividad basal", "ritmo alfa", "frecuencia"),
"eeg_ritmo_base_amplitud": ("amplitud", "voltaje"),
"eeg_duracion_min": ("duración", "registro de", "tiempo de registro"),
}
# Answers that mean nothing without their concept (`ANCHORS`).
GENERIC_TERMS = frozenset(
{"POSITIVO", "POSITIVA", "NEGATIVO", "NEGATIVA", "SI", "NO", "PRESENTE", "AUSENTE", "DETECTADO", "NO DETECTADO",
"NORMAL", "ANORMAL", "REACTIVO", "NO REACTIVO", "INDETERMINADO", "INVALIDO", "NO CONCLUYENTE"}
)
# Catalog values from least to most severe. When a report names several
# (one per specimen, one per breast), the most severe one is the finding.
SEVERITY: dict[str, tuple[str, ...]] = {
"cit_celulas_escamosas": ("NORMAL", "ASC-US", "LIEBG", "ASC-H", "LIEAG", "CIS"),
"bx_cin_grado": ("NORMAL", "LIEBG", "LIEAG", "CIS", "CARCINOMA"),
"bx_grado_histologico": ("BENIGNO", "CARCINOMA_IN_SITU", "CARCINOMA_INVASOR"),
"mast_birads": ("1", "2", "3", "4", "4A", "4B", "4C", "5", "6"),
"eeg_tipo_grafoelemento": ("NINGUNO", "OTRO", "DESCARGA_RITMICA", "ONDA_AGUDA", "ESPIGA", "PUNTA_ONDA_LENTA", "COMPLEJO_ESPIGA_ONDA", "COMPLEJO_POLIESPIGA_ONDA"),
}
# What a denied mention means for a presence field ("sin actividad epileptiforme").
NEGATED_VALUES: dict[str, object] = {
"eeg_actividad_epileptiforme": 0,
"eeg_crisis_registradas": 0,
"eeg_tipo_grafoelemento": "NINGUNO",
"eeg_lentificacion": "NINGUNA",
"eeg_anormalidad_presente": 0,
}
# Units a measurement is written in, as a regular expression over folded text.
UNITS: dict[str, str] = {
"eeg_ritmo_base_frecuencia": r"HZ|HERTZ|C\s*/\s*S|CPS|CICLOS\s+POR\s+SEGUNDO",
"eeg_ritmo_base_amplitud": r"[µU]\s*V|MCV|MICROVOLTIOS?",
"eeg_duracion_min": r"MIN(?:UTOS?)?\.?",
}
# Report section headings (`extraction.nlp.context`). The longest match wins,
# so "diagnóstico clínico" opens a clinical section and "diagnóstico" a result.
SECTION_HEADINGS: dict = {}
# ConText trigger phrases, by the assertion they make about a mention after them.
PRE_TRIGGERS: dict = {}
PSEUDO_TRIGGERS: tuple[str, ...] = ()
CLAUSE_TERMINATORS: tuple[str, ...] = ()
POST_NEGATIONS: tuple[str, ...] = ()
POST_AFFIRMATIONS: tuple[str, ...] = ()
def _context_vocabulary() -> None:
from extraction.nlp.context import Assertion, Section
global PSEUDO_TRIGGERS, CLAUSE_TERMINATORS, POST_NEGATIONS, POST_AFFIRMATIONS
SECTION_HEADINGS.update({
Section.CLINICA: (
"datos clínicos", "resumen clínico", "diagnóstico clínico", "diagnóstico de envío",
"diagnóstico presuntivo", "diagnóstico de ingreso", "diagnóstico previo", "impresión clínica", "sospecha clínica",
"indicación", "indicaciones", "motivo del estudio", "motivo de envío", "motivo de solicitud", "cuadro clínico",
),
Section.DESCRIPCION: (
"descripción", "descripción macroscópica", "descripción microscópica", "macroscópico", "microscópico", "técnica",
"hallazgos", "descripción del trazo", "descripción del registro", "especimen", "espécimen", "muestra",
),
Section.RESULTADO: (
"diagnóstico", "diagnósticos", "diagnóstico final", "diagnóstico histopatológico", "diagnóstico patológico",
"diagnóstico citológico", "conclusión", "conclusiones", "resultado", "resultados", "impresión diagnóstica",
"interpretación", "dictamen",
),
Section.ANTECEDENTES: (
"antecedentes", "antecedentes personales", "antecedentes patológicos", "antecedentes familiares",
"estudios previos", "historia clínica",
),
Section.REFERENCIA: (
"valores de referencia", "valor de referencia", "intervalo de referencia", "intervalos de referencia",
"rango de referencia", "criterios de interpretación",
"metodología", "método", "limitaciones", "aviso", "advertencia", "nota técnica", "comentario técnico",
"aviso de privacidad",
),
})
PRE_TRIGGERS.update({
Assertion.NEGADO: (
"no", "sin", "ni", "nunca", "niega", "negativo para", "negativa para", "negativo a", "ausencia de", "ausente",
"descartado", "se descarta", "no se observa", "no se observan", "no hay", "libre de", "no se identifica",
"no se identifican", "no muestra", "no presenta", "no evidencia", "sin evidencia de",
),
Assertion.HIPOTETICO: (
"en caso de", "si se", "si el", "si la", "si hay", "si existe", "un resultado", "cuando", "puede", "pueden",
"podría", "podrían", "se recomienda", "riesgo de", "para descartar", "a descartar", "descartar", "de ser",
"en presencia de", "indica que", "se sugiere",
),
Assertion.HISTORICO: (
"antecedente de", "antecedentes de", "historia de", "previo", "previa", "previamente", "tratada por",
"tratado por", "postoperada de", "operada de", "conocida con",
),
Assertion.INCIERTO: (
"probable", "probablemente", "posible", "posiblemente", "sospecha de", "sospechoso de", "sospechosa de",
"no se descarta", "dudoso", "dudosa", "impresiona", "a considerar", "vs",
),
})
PSEUDO_TRIGGERS = ("sin embargo", "no obstante", "no solo", "no sólo", "sin cambios", "no se descarta", "no especial")
CLAUSE_TERMINATORS = ("pero", "aunque", "excepto", "salvo", "sin embargo", "no obstante")
POST_NEGATIONS = ("no", "negativo", "negativa", "ausente", "ausentes", "no se observa", "no detectado", "no detectada", "descartado", "descartada")
POST_AFFIRMATIONS = ("si", "sí", "positivo", "positiva", "presente", "presentes", "detectado", "detectada")
_context_vocabulary()
# EEG findings as reports state them (ACNS standardized terminology, 2021, in Spanish).
CLINICAL_TERMS.update({
"eeg_simetria": {
"SIMETRICO": "SIMETRICO", "SIMETRICA": "SIMETRICO", "SIMETRICOS": "SIMETRICO", "ADECUADA SIMETRIA": "SIMETRICO",
"ASIMETRIA IZQUIERDA": "ASIMETRICO_IZQUIERDO", "ASIMETRICO IZQUIERDO": "ASIMETRICO_IZQUIERDO",
"ASIMETRIA DERECHA": "ASIMETRICO_DERECHO", "ASIMETRICO DERECHO": "ASIMETRICO_DERECHO",
},
"eeg_anormalidad_presente": {
"EEG ANORMAL": 1, "ESTUDIO ANORMAL": 1, "TRAZO ANORMAL": 1, "REGISTRO ANORMAL": 1, "ANORMAL": 1,
"EEG NORMAL": 0, "ESTUDIO NORMAL": 0, "TRAZO NORMAL": 0, "REGISTRO NORMAL": 0, "DENTRO DE LIMITES NORMALES": 0,
"SIN ALTERACIONES": 0,
},
"eeg_actividad_epileptiforme": {
"ACTIVIDAD EPILEPTIFORME": 1, "DESCARGAS EPILEPTIFORMES": 1, "GRAFOELEMENTOS EPILEPTIFORMES": 1,
"ACTIVIDAD PAROXISTICA": 1, "DESCARGAS PAROXISTICAS": 1, "PUNTAS": 1, "ESPIGAS": 1, "POLIPUNTAS": 1,
"PUNTA ONDA": 1, "ONDAS AGUDAS": 1,
},
"eeg_tipo_grafoelemento": {
"ESPIGA": "ESPIGA", "ESPIGAS": "ESPIGA", "PUNTA": "ESPIGA", "PUNTAS": "ESPIGA",
"ONDA AGUDA": "ONDA_AGUDA", "ONDAS AGUDAS": "ONDA_AGUDA",
"COMPLEJO ESPIGA ONDA": "COMPLEJO_ESPIGA_ONDA", "COMPLEJOS ESPIGA ONDA": "COMPLEJO_ESPIGA_ONDA", "PUNTA ONDA": "COMPLEJO_ESPIGA_ONDA",
"POLIESPIGA ONDA": "COMPLEJO_POLIESPIGA_ONDA", "POLIPUNTA ONDA": "COMPLEJO_POLIESPIGA_ONDA", "POLIPUNTAS": "COMPLEJO_POLIESPIGA_ONDA",
"PUNTA ONDA LENTA": "PUNTA_ONDA_LENTA", "ESPIGA ONDA LENTA": "PUNTA_ONDA_LENTA",
"DESCARGA RITMICA": "DESCARGA_RITMICA", "DESCARGAS RITMICAS": "DESCARGA_RITMICA",
"GRAFOELEMENTOS EPILEPTIFORMES": "OTRO", "ACTIVIDAD EPILEPTIFORME": "OTRO",
},
"eeg_distribucion_anormalidad": {
"FOCAL": "FOCAL", "MULTIFOCAL": "MULTIFOCAL", "GENERALIZADA": "GENERALIZADA", "GENERALIZADAS": "GENERALIZADA",
"DIFUSA": "GENERALIZADA", "BILATERAL Y SINCRONICA": "GENERALIZADA", "LATERALIZADA": "LATERALIZADA",
"HEMISFERICA": "LATERALIZADA",
},
"eeg_lentificacion": {
"LENTIFICACION FOCAL": "FOCAL", "LENTIFICACION GENERALIZADA": "GENERALIZADA", "LENTIFICACION DIFUSA": "GENERALIZADA",
"LENTIFICACION INTERMITENTE": "INTERMITENTE", "ACTIVIDAD LENTA INTERMITENTE": "INTERMITENTE",
},
"eeg_crisis_registradas": {"CRISIS ELECTROGRAFICA": 1, "CRISIS ELECTROGRAFICAS": 1, "CRISIS ELECTROCLINICA": 1, "CRISIS ELECTROCLINICAS": 1, "SE REGISTRARON CRISIS": 1},
"eeg_respuesta_fotoestimulacion": {
"RESPUESTA FOTOPAROXISTICA": "RESPUESTA_FOTOPAROXISTICA", "FOTOPAROXISTICA": "RESPUESTA_FOTOPAROXISTICA",
"ARRASTRE FOTICO": "NORMAL", "RESPUESTA DE ARRASTRE": "NORMAL", "FOTOESTIMULACION SIN CAMBIOS": "SIN_RESPUESTA",
"SIN RESPUESTA A LA FOTOESTIMULACION": "SIN_RESPUESTA", "NO SE REALIZO FOTOESTIMULACION": "NO_PRACTICADA",
"FOTOESTIMULACION NO REALIZADA": "NO_PRACTICADA",
},
"eeg_conclusion_categoria": {
"NORMAL PARA LA EDAD": "NORMAL_PARA_LA_EDAD", "EEG NORMAL": "NORMAL_PARA_LA_EDAD", "DENTRO DE LIMITES NORMALES": "NORMAL_PARA_LA_EDAD",
"NORMAL CON VARIANTES": "NORMAL_CON_VARIANTES", "VARIANTES NORMALES": "NORMAL_CON_VARIANTES",
"ANORMAL EPILEPTIFORME": "ANORMAL_EPILEPTIFORME", "ANORMAL POR ACTIVIDAD EPILEPTIFORME": "ANORMAL_EPILEPTIFORME",
"ANORMAL NO EPILEPTIFORME": "ANORMAL_NO_EPILEPTIFORME", "ANORMAL POR LENTIFICACION": "ANORMAL_NO_EPILEPTIFORME",
"NO CONCLUYENTE": "NO_CONCLUYENTE",
},
"eeg_calidad_tecnica": {
"TECNICAMENTE SATISFACTORIO": "SATISFACTORIA", "ADECUADA CALIDAD TECNICA": "SATISFACTORIA",
"LIMITADO POR ARTEFACTO": "LIMITADA_POR_ARTEFACTO", "ARTEFACTO DE MOVIMIENTO": "LIMITADA_POR_ARTEFACTO",
"POCA COOPERACION": "LIMITADA_POR_COLABORACION", "NO VALORABLE": "NO_VALORABLE",
},
})
# Narrative BI-RADS: roman numerals, "categoría", subcategories.
CLINICAL_TERMS["mast_birads"].update({
**{f"BIRADS {n}": n for n in ("0", "1", "2", "3", "4", "4A", "4B", "4C", "5", "6")},
**{f"{prefix} {roman}": n for prefix in ("BI-RADS", "BIRADS", "CATEGORIA") for roman, n in (("I", "1"), ("II", "2"), ("III", "3"), ("IV", "4"), ("IVA", "4A"), ("IVB", "4B"), ("IVC", "4C"), ("V", "5"), ("VI", "6"))},
**{f"CATEGORIA {n}": n for n in ("0", "1", "2", "3", "4", "4A", "4B", "4C", "5", "6")},
})
# Cytology and histology in Bethesda (2014) and LAST (2012) terms.
CLINICAL_TERMS["cit_celulas_escamosas"].update({
"ASC-H": "ASC-H", "ASCH": "ASC-H", "ATIPIA EN CELULAS ESCAMOSAS DE SIGNIFICADO INDETERMINADO": "ASC-US",
"CELULAS ESCAMOSAS ATIPICAS DE SIGNIFICADO INDETERMINADO": "ASC-US",
"CELULAS ESCAMOSAS ATIPICAS SIN PODER EXCLUIR": "ASC-H", "NO SE PUEDE DESCARTAR LESION DE ALTO GRADO": "ASC-H",
"LIEBG": "LIEBG", "LIEAG": "LIEAG", "LIE DE BAJO GRADO": "LIEBG", "LIE DE ALTO GRADO": "LIEAG",
"DISPLASIA LEVE": "LIEBG", "DISPLASIA MODERADA": "LIEAG", "DISPLASIA GRAVE": "LIEAG", "DISPLASIA SEVERA": "LIEAG",
"CARCINOMA IN SITU": "CIS", "NILM": "NORMAL",
})
# Glandular cells in cytology: atypical glandular cells (AGC) and adenocarcinoma.
# Adenocarcinoma in situ has no catalog value and is deliberately not listed.
CLINICAL_TERMS["cit_celulas_glandulares"] = {
"CELULAS GLANDULARES ATIPICAS": "AGC", "ATIPIA DE CELULAS GLANDULARES": "AGC",
"ATIPIA EN CELULAS GLANDULARES": "AGC", "AGC": "AGC", "ACG": "AGC",
"ADENOCARCINOMA": "ADENOCARCINOMA", "ADENOCARCINOMA ENDOCERVICAL": "ADENOCARCINOMA",
"ADENOCARCINOMA ENDOMETRIAL": "ADENOCARCINOMA",
}
SEVERITY["cit_celulas_glandulares"] = ("AGC", "ADENOCARCINOMA")
CLINICAL_TERMS["bx_cin_grado"].update({
"NIC1": "LIEBG", "NIC2": "LIEAG", "NIC3": "LIEAG", "CIN1": "LIEBG", "CIN2": "LIEAG", "CIN3": "LIEAG",
"LIEBG": "LIEBG", "LIEAG": "LIEAG", "LIE DE BAJO GRADO": "LIEBG", "LIE DE ALTO GRADO": "LIEAG",
"CONDILOMA": "LIEBG", "CAMBIOS POR VPH": "LIEBG", "EFECTO CITOPATICO VIRAL": "LIEBG",
"DISPLASIA GRAVE": "LIEAG", "ADENOCARCINOMA IN SITU": "CIS",
})
CLINICAL_TERMS["bx_grado_histologico"].update({
"CARCINOMA MAMARIO INVASOR": "CARCINOMA_INVASOR", "CARCINOMA DE TIPO NO ESPECIAL": "CARCINOMA_INVASOR",
"CARCINOMA LOBULILLAR INVASOR": "CARCINOMA_INVASOR", "CARCINOMA MUCINOSO": "CARCINOMA_INVASOR",
"CARCINOMA INTRADUCTAL": "CARCINOMA_IN_SITU", "LESION PAPILAR BENIGNA": "BENIGNO", "PAPILOMA INTRADUCTAL": "BENIGNO",
"ADENOSIS ESCLEROSANTE": "BENIGNO", "MASTITIS": "BENIGNO", "SIN EVIDENCIA DE MALIGNIDAD": "BENIGNO",
})
LABELS["cit_fecha_reporte"] = (*LABELS["cit_fecha_reporte"], "fecha de interpretación", "fecha de emisión", "fecha de liberación")
LABELS["bx_fecha_reporte"] = (*LABELS["bx_fecha_reporte"], "fecha de emisión", "fecha de liberación")
LABELS["bx_cin_grado"] = (*LABELS["bx_cin_grado"], "diagnóstico final", "diagnóstico patológico")
LABELS["eeg_ritmo_base_frecuencia"] = ("ritmo de fondo", "actividad de fondo", "ritmo base", "ritmo dominante posterior", "actividad basal")
LABELS["eeg_ritmo_base_amplitud"] = ("amplitud", "voltaje")
LABELS["eeg_duracion_min"] = ("duración del registro", "duración", "tiempo de registro")
FREE_TEXT_FIELDS = FREE_TEXT_FIELDS | {
"eeg_simetria", "eeg_anormalidad_presente", "eeg_actividad_epileptiforme", "eeg_tipo_grafoelemento",
"eeg_distribucion_anormalidad", "eeg_lentificacion", "eeg_crisis_registradas", "eeg_respuesta_fotoestimulacion",
"eeg_conclusion_categoria", "eeg_calidad_tecnica",
}