diff --git a/src/app/features/indicadores/cacu-seguimiento.models.ts b/src/app/features/indicadores/cacu-seguimiento.models.ts
index 4fbd27f..40e7fad 100644
--- a/src/app/features/indicadores/cacu-seguimiento.models.ts
+++ b/src/app/features/indicadores/cacu-seguimiento.models.ts
@@ -1,4 +1,6 @@
-export interface SeguimientoQuery { corte?: string; meses: 1 | 3 | 6 | 12; estatus?: string; grupo_edad?: string; mchat?: string; css?: string; estado_caso?: string; alteracion?: string; page: number; page_size: number; }
+export type ProbabilidadClave = 'lieag' | 'cancer' | 'supervivencia';
+export type OrdenSeguimiento = 'reciente' | ProbabilidadClave;
+export interface SeguimientoQuery { corte?: string; meses: 1 | 3 | 6 | 12; estatus?: string; orden?: OrdenSeguimiento; horizonte?: number; grupo_edad?: string; mchat?: string; css?: string; estado_caso?: string; alteracion?: string; page: number; page_size: number; }
export interface SeguimientoStatus { codigo: string; etiqueta: string; }
// A row names its patient with `pac_id` (a decimal string) or the legacy `id_seudonimo`.
export interface SeguimientoPaciente {
@@ -9,13 +11,20 @@ export interface SeguimientoPaciente {
ultima_citologia: { fecha: string; bethesda: string | null; calidad: string | null } | null;
ultimo_vph: { fecha: string; resultado: string; genotipo_16_18: boolean | null } | null;
dias_toma_diagnostico: number | null;
+ /** CaCu: her latest biopsy reported by the cut-off, with its grade. */
+ ultima_biopsia?: { fecha: string; grado: string | null } | null;
+ /** CaCu: her current probability of LIEAG+, of cancer and (a case's) of surviving at each horizon, from the confirmed batches. */
+ probabilidades?: Partial> | null;
prioridad: SeguimientoStatus | null;
}
+export interface ProbabilidadHorizonte { horizonte_anios: number; probabilidad: number; ic_bajo: number | null; ic_alto: number | null; }
export interface SeguimientoResponse {
simulado: boolean;
corte: string;
ventana: { meses: 1 | 3 | 6 | 12; desde: string; hasta: string };
- filtros: { estatus: string | null };
+ filtros: { estatus: string | null; orden?: OrdenSeguimiento; horizonte?: number };
+ /** The horizons the models give, in years, for ordering and showing the probabilities. */
+ horizontes_disponibles?: number[];
estatus_disponibles: SeguimientoStatus[];
reglas: { clave: string; valor: unknown; estado: 'provisional' | 'confirmado' }[];
paginacion: { page: number; page_size: number; total_items: number; total_pages: number };
@@ -29,3 +38,15 @@ export function isoDate(value: unknown): value is string {
export function latestStudy(item: SeguimientoPaciente): string | null {
return [item.ultima_citologia?.fecha, item.ultimo_vph?.fecha].filter(isoDate).sort().at(-1) ?? null;
}
+/** Her probability of `clave` at `horizonte`, or `undefined` when no model gives it. */
+export function probabilidadAl(item: SeguimientoPaciente, clave: ProbabilidadClave, horizonte: number): ProbabilidadHorizonte | undefined {
+ return item.probabilidades?.[clave]?.find(h => h.horizonte_anios === horizonte);
+}
+/** CaCu: the probability columns a follow-up status shows, the ones its scenario's models give (a case: survival).
+ * Every patient or an unknown status shows none: each scenario has its own models. */
+export const COLUMNAS_DE_PROBABILIDAD: Readonly> = {
+ CASO: ['supervivencia'], PRE_COLPOSCOPIA: ['lieag', 'cancer'], POST_COLPOSCOPIA: ['lieag'], POST_TRATAMIENTO: ['lieag'],
+};
+export const ETIQUETA_PROBABILIDAD: Readonly> = {
+ lieag: 'Probabilidad a LIEAG+', cancer: 'Probabilidad a cáncer', supervivencia: 'Probabilidad de supervivencia',
+};
diff --git a/src/app/features/indicadores/cacu-seguimiento.service.ts b/src/app/features/indicadores/cacu-seguimiento.service.ts
index 53cf2da..a1e68fc 100644
--- a/src/app/features/indicadores/cacu-seguimiento.service.ts
+++ b/src/app/features/indicadores/cacu-seguimiento.service.ts
@@ -3,11 +3,20 @@ import { HttpClient, HttpParams } from '@angular/common/http';
import { map } from 'rxjs';
import { isoDate, SeguimientoQuery, SeguimientoResponse } from './cacu-seguimiento.models';
import { identidadDe, identidadesDe } from './paciente-identidad';
+import { PAGE_SIZE_MAX } from './seguimiento-tabla.service';
const record = (v: unknown): v is Record => !!v && typeof v === 'object' && !Array.isArray(v);
const status = (v: unknown) => record(v) && typeof v['codigo'] === 'string' && typeof v['etiqueta'] === 'string';
const integer = (v: unknown, min = 0) => typeof v === 'number' && Number.isSafeInteger(v) && v >= min;
+const ORDENES = ['reciente', 'lieag', 'cancer', 'supervivencia'];
+const anios = (v: unknown) => typeof v === 'number' && Number.isFinite(v) && v >= 0;
+const prob = (v: unknown) => typeof v === 'number' && Number.isFinite(v) && v >= 0 && v <= 1;
+// CaCu's biopsy and probabilities are optional: an API that doesn't give them still validates.
+const biopsia = (b: unknown) => b === undefined || b === null || record(b) && isoDate(b['fecha']) && (b['grado'] === null || typeof b['grado'] === 'string');
+const probabilidades = (p: unknown) => p === undefined || p === null || record(p) && Object.entries(p).every(([k, hs]) =>
+ ['lieag', 'cancer', 'supervivencia'].includes(k) && Array.isArray(hs) && hs.every(h => record(h) && anios(h['horizonte_anios']) && prob(h['probabilidad'])
+ && (h['ic_bajo'] === null || prob(h['ic_bajo'])) && (h['ic_alto'] === null || prob(h['ic_alto']))));
export function validSeguimientoQuery(q: SeguimientoQuery) {
- return (!q.corte || isoDate(q.corte)) && [1,3,6,12].includes(q.meses) && integer(q.page, 1) && integer(q.page_size, 1) && q.page_size <= 200;
+ return (!q.corte || isoDate(q.corte)) && [1,3,6,12].includes(q.meses) && integer(q.page, 1) && integer(q.page_size, 1) && q.page_size <= PAGE_SIZE_MAX;
}
export function seguimientoResponse(v: unknown): SeguimientoResponse {
// The current authorization covers demonstration records only. Validate this
@@ -16,15 +25,18 @@ export function seguimientoResponse(v: unknown): SeguimientoResponse {
const p = v['paginacion'], window = v['ventana'], filters = v['filtros'];
if (!isoDate(v['corte']) || !record(window) || ![1,3,6,12].includes(window['meses'] as number) || !isoDate(window['desde']) || !isoDate(window['hasta'])
|| !record(filters) || (filters['estatus'] !== null && typeof filters['estatus'] !== 'string')
+ || (filters['orden'] !== undefined && !ORDENES.includes(filters['orden'] as string))
+ || (v['horizontes_disponibles'] !== undefined && !(Array.isArray(v['horizontes_disponibles']) && v['horizontes_disponibles'].every(anios)))
|| !Array.isArray(v['estatus_disponibles']) || !v['estatus_disponibles'].every(status)
|| !Array.isArray(v['reglas']) || !v['reglas'].every(r => record(r) && typeof r['clave'] === 'string' && Object.hasOwn(r, 'valor') && ['provisional','confirmado'].includes(r['estado'] as string))
- || !record(p) || !integer(p['page'], 1) || !integer(p['page_size'], 1) || (p['page_size'] as number) > 200 || !integer(p['total_items']) || !integer(p['total_pages'])
+ || !record(p) || !integer(p['page'], 1) || !integer(p['page_size'], 1) || (p['page_size'] as number) > PAGE_SIZE_MAX || !integer(p['total_items']) || !integer(p['total_pages'])
|| !Array.isArray(v['items']) || v['items'].length > (p['page_size'] as number) || !v['items'].every(item => {
if (!record(item) || !identidadDe(item) || typeof item['grupo_edad'] !== 'string' || !status(item['estatus'])) return false;
const c = item['ultima_citologia'], h = item['ultimo_vph'];
return (c === null || record(c) && isoDate(c['fecha']) && (c['bethesda'] === null || typeof c['bethesda'] === 'string') && (c['calidad'] === null || typeof c['calidad'] === 'string'))
&& (h === null || record(h) && isoDate(h['fecha']) && typeof h['resultado'] === 'string' && (h['genotipo_16_18'] === null || typeof h['genotipo_16_18'] === 'boolean'))
- && (item['dias_toma_diagnostico'] === null || integer(item['dias_toma_diagnostico'])) && (item['prioridad'] === null || status(item['prioridad']));
+ && (item['dias_toma_diagnostico'] === null || integer(item['dias_toma_diagnostico'])) && (item['prioridad'] === null || status(item['prioridad']))
+ && biopsia(item['ultima_biopsia']) && probabilidades(item['probabilidades']);
}) || !identidadesDe(v['items'])) throw new Error('Respuesta de seguimiento inválida');
return v as unknown as SeguimientoResponse;
}
@@ -36,6 +48,8 @@ export class CacuSeguimientoService {
let params = new HttpParams().set('meses', query.meses).set('page', query.page).set('page_size', query.page_size);
if (query.corte) params = params.set('corte', query.corte);
if (query.estatus) params = params.set('estatus', query.estatus);
+ if (query.orden && query.orden !== 'reciente') params = params.set('orden', query.orden);
+ if (query.horizonte !== undefined) params = params.set('horizonte', query.horizonte);
return this.http.get('/cacu/seguimiento', { params }).pipe(map(seguimientoResponse));
}
}
diff --git a/src/app/features/indicadores/cacu-seguimiento.spec.ts b/src/app/features/indicadores/cacu-seguimiento.spec.ts
index b77f3a9..e9e24c6 100644
--- a/src/app/features/indicadores/cacu-seguimiento.spec.ts
+++ b/src/app/features/indicadores/cacu-seguimiento.spec.ts
@@ -36,12 +36,13 @@ describe('Seguimiento CaCu con contrato de demostración', () => {
const root:HTMLElement=fixture.nativeElement;
expect(root.textContent).not.toContain('Datos simulados — uso de demostración');
expect(root.textContent).not.toContain('Las reglas de selección son provisionales');
+ expect(root.querySelector('h2')?.textContent).toBe('Modelos de riesgo asociados a cáncer cervicouterino');
expect(root.textContent).toContain('Ventana consultada:');
expect(root.textContent).toContain('INSATISFACTORIO'); expect(root.textContent).toContain('Normal'); expect(root.textContent).toContain('No detectado');
expect(root.textContent).toContain('Insatisfactoria');
expect(fixture.componentInstance.cytologyLabel({ bethesda: null, calidad: 'SATISFACTORIO' })).toBe('Sin resultado al corte');
expect(fixture.componentInstance.cytologyLabel({ bethesda: null, calidad: null })).toBe('Sin resultado al corte');
- expect(root.querySelectorAll('tbody tr')).toHaveLength(10); expect(root.querySelectorAll('thead th')).toHaveLength(8);
+ expect(root.querySelectorAll('tbody tr')).toHaveLength(10); expect(root.querySelectorAll('thead th')).toHaveLength(9);
expect(root.querySelector('form input[name="corte"]')).not.toBeNull();
expect(root.querySelector('form select[name="meses"]')).not.toBeNull();
expect(root.querySelector('nav[aria-label="Paginación de seguimiento"]')).not.toBeNull();
@@ -96,4 +97,50 @@ describe('Seguimiento CaCu con contrato de demostración', () => {
for(const q of [{corte:'2026-02-30'},{page:0},{page_size:201},{meses:2}]) expect(()=>service.consultar({meses:3,page:1,page_size:50,...q} as never)).toThrow();
http.expectNone(()=>true);
});
+ // Fails if the list stops showing each patient's biopsy and probabilities at the horizon chosen, or the order and the
+ // horizon stop reaching the API (the list is paginated, so ordering happens there).
+ it('con Pre colposcopia muestra la biopsia y las probabilidades de LIEAG+ y cáncer al horizonte elegido, y pide el orden al servidor', () => {
+ const items = fixtureData.items.map((item: any, i: number) => i === 0 ? {
+ ...item, ultima_biopsia: { fecha: '2025-10-01', grado: 'LIEAG' },
+ probabilidades: { lieag: [{ horizonte_anios: 1, probabilidad: 0.08, ic_bajo: 0.05, ic_alto: 0.12 },
+ { horizonte_anios: 5, probabilidad: 0.34, ic_bajo: 0.26, ic_alto: 0.44 }],
+ cancer: [{ horizonte_anios: 5, probabilidad: 0.015, ic_bajo: null, ic_alto: null }] },
+ } : item);
+ const data = { ...fixtureData, items, horizontes_disponibles: [1, 5], filtros: { ...fixtureData.filtros, estatus: 'PRE_COLPOSCOPIA', orden: 'reciente', horizonte: 5 } };
+ open().flush(data); http.expectOne('/cacu/indicadores/cacu_eu7/metadatos').flush({ categorias: {} }); fixture.detectChanges();
+ const root: HTMLElement = fixture.nativeElement;
+ const fila = root.querySelector('tbody tr')!;
+ expect(fila.textContent).toContain('LIEAG'); expect(fila.textContent).toContain('34 % (26 – 44 %)'); expect(fila.textContent).toContain('1.5 %');
+ expect(root.querySelector('thead')!.textContent).toContain('Probabilidad a LIEAG+ a 5 años (%)');
+ expect([...root.querySelectorAll('select[name="horizonte"] option')].map(o => o.textContent!.trim())).toEqual(['1 año', '5 años']);
+
+ fixture.componentInstance.draft.orden = 'lieag'; fixture.componentInstance.draft.horizonte = 1;
+ fixture.componentInstance.apply();
+ const req = http.expectOne(r => r.url === '/cacu/seguimiento');
+ expect(req.request.params.get('orden')).toBe('lieag'); expect(req.request.params.get('horizonte')).toBe('1');
+ req.flush({ ...data, filtros: { ...data.filtros, orden: 'lieag', horizonte: 1 } }); fixture.detectChanges();
+ expect(root.querySelector('tbody tr')!.textContent).toContain('8 % (5 – 12 %)');
+ });
+
+ // Fails if the columns stop following the status filtered: each scenario has its own models.
+ it('las columnas de probabilidad siguen al estatus: un caso muestra supervivencia y todas las pacientes, ninguna', () => {
+ const items = fixtureData.items.map((item: any, i: number) => i === 0 ? {
+ ...item, estatus: { codigo: 'CASO', etiqueta: 'Caso (cáncer)' },
+ probabilidades: { supervivencia: [{ horizonte_anios: 5, probabilidad: 0.7, ic_bajo: 0.55, ic_alto: 0.8 }] } } : item);
+ const caso = { ...fixtureData, items, horizontes_disponibles: [5], filtros: { ...fixtureData.filtros, estatus: 'CASO', orden: 'reciente', horizonte: 5 } };
+ open().flush(caso); http.expectOne('/cacu/indicadores/cacu_eu7/metadatos').flush({ categorias: {} }); fixture.detectChanges();
+ const root: HTMLElement = fixture.nativeElement, encabezados = () => [...root.querySelectorAll('thead th')].map(t => t.textContent!.trim());
+ expect(encabezados()).toContain('Probabilidad de supervivencia a 5 años (%)');
+ expect(encabezados().some(t => t.includes('LIEAG+'))).toBe(false);
+ expect(root.querySelector('tbody tr')!.textContent).toContain('70 % (55 – 80 %)');
+ expect(fixture.componentInstance.ordenes().map(o => o.codigo)).toEqual(['reciente', 'supervivencia']);
+
+ fixture.componentInstance.draft.estatus = undefined; fixture.componentInstance.draft.orden = 'supervivencia';
+ fixture.componentInstance.apply();
+ const req = http.expectOne(r => r.url === '/cacu/seguimiento');
+ expect(req.request.params.has('orden')).toBe(false);
+ req.flush({ ...caso, filtros: { ...caso.filtros, estatus: null } }); fixture.detectChanges();
+ expect(encabezados().some(t => t.startsWith('Probabilidad'))).toBe(false);
+ expect(root.querySelector('select[name="orden"]')).toBeNull();
+ });
});
diff --git a/src/app/features/indicadores/fhir.ts b/src/app/features/indicadores/fhir.ts
index 71d0754..e7bc9ce 100644
--- a/src/app/features/indicadores/fhir.ts
+++ b/src/app/features/indicadores/fhir.ts
@@ -19,6 +19,7 @@ export interface Resource {
}
export interface Bundle extends Resource {
total?: number;
+ link?: { relation: string; url: string }[];
entry?: { fullUrl?: string; resource: Resource; search?: { mode?: string } }[];
}
diff --git a/src/app/features/indicadores/fixtures/cacu_fhir_measures.json b/src/app/features/indicadores/fixtures/cacu_fhir_measures.json
index d4126ee..bb879ea 100644
--- a/src/app/features/indicadores/fixtures/cacu_fhir_measures.json
+++ b/src/app/features/indicadores/fixtures/cacu_fhir_measures.json
@@ -1,7 +1,7 @@
{
"resourceType": "Bundle",
"type": "searchset",
- "total": 7,
+ "total": 9,
"link": [
{
"relation": "self",
@@ -297,6 +297,123 @@
"mode": "match"
}
},
+ {
+ "fullUrl": "http://webapi/cacu/fhir/Measure/CACU-DIAS-DIAGNOSTICO-TRATAMIENTO",
+ "resource": {
+ "resourceType": "Measure",
+ "id": "CACU-DIAS-DIAGNOSTICO-TRATAMIENTO",
+ "extension": [
+ {
+ "url": "https://isssteleon.org/fhir/StructureDefinition/contrato",
+ "valueCode": "C3r"
+ },
+ {
+ "url": "https://isssteleon.org/fhir/StructureDefinition/tipos-periodo",
+ "valueCode": "semestre"
+ },
+ {
+ "url": "https://isssteleon.org/fhir/StructureDefinition/tipos-periodo",
+ "valueCode": "mes"
+ },
+ {
+ "url": "https://isssteleon.org/fhir/StructureDefinition/figuras",
+ "valueString": "fig_c3r_caja"
+ }
+ ],
+ "url": "https://isssteleon.org/fhir/Measure/CACU-DIAS-DIAGNOSTICO-TRATAMIENTO",
+ "version": "0.1.0",
+ "name": "cacu_dias_diagnostico_tratamiento",
+ "title": "Tiempo de diagnóstico a tratamiento",
+ "status": "active",
+ "subjectCodeableConcept": {
+ "coding": [
+ {
+ "system": "https://isssteleon.org/fhir/CodeSystem/unidad",
+ "code": "examen"
+ }
+ ]
+ },
+ "description": "Días naturales del diagnóstico que resuelve cada citología del periodo al primer tratamiento posterior: una nota médica con un CIE-10 de tratamiento después de la primera colposcopia de la paciente, dentro del horizonte y a la fecha de corte. Solo entran las citologías que un diagnóstico resolvió; se excluyen las de pacientes con un diagnóstico de cáncer cervicouterino anterior a la toma. Dos citologías que resuelve el mismo diagnóstico cuentan cada una. El tratamiento se infiere de la nota: no distingue el indicado del realizado.",
+ "scoring": {
+ "coding": [
+ {
+ "system": "http://terminology.hl7.org/CodeSystem/measure-scoring",
+ "code": "continuous-variable"
+ }
+ ]
+ },
+ "improvementNotation": {
+ "coding": [
+ {
+ "system": "http://terminology.hl7.org/CodeSystem/measure-improvement-notation",
+ "code": "decrease"
+ }
+ ]
+ },
+ "group": [
+ {
+ "code": {
+ "coding": [
+ {
+ "system": "https://isssteleon.org/fhir/CodeSystem/grupo-medida",
+ "code": "TOTAL"
+ }
+ ]
+ },
+ "population": [
+ {
+ "code": {
+ "coding": [
+ {
+ "system": "http://terminology.hl7.org/CodeSystem/measure-population",
+ "code": "initial-population"
+ }
+ ]
+ },
+ "description": "Unidades del periodo",
+ "criteria": {
+ "language": "text/x-dbt-metric",
+ "expression": "cacu_dias_diagnostico_tratamiento"
+ }
+ },
+ {
+ "code": {
+ "coding": [
+ {
+ "system": "http://terminology.hl7.org/CodeSystem/measure-population",
+ "code": "measure-observation"
+ }
+ ]
+ },
+ "description": "Unidades con valor",
+ "criteria": {
+ "language": "text/x-dbt-metric",
+ "expression": "cacu_dias_diagnostico_tratamiento"
+ }
+ },
+ {
+ "code": {
+ "coding": [
+ {
+ "system": "http://terminology.hl7.org/CodeSystem/measure-population",
+ "code": "measure-population-exclusion"
+ }
+ ]
+ },
+ "description": "Unidades sin valor",
+ "criteria": {
+ "language": "text/x-dbt-metric",
+ "expression": "cacu_dias_diagnostico_tratamiento"
+ }
+ }
+ ]
+ }
+ ]
+ },
+ "search": {
+ "mode": "match"
+ }
+ },
{
"fullUrl": "http://webapi/cacu/fhir/Measure/CACU-DIAS-TOMA-DIAGNOSTICO",
"resource": {
@@ -414,6 +531,123 @@
"mode": "match"
}
},
+ {
+ "fullUrl": "http://webapi/cacu/fhir/Measure/CACU-DIAS-TOMA-TRATAMIENTO",
+ "resource": {
+ "resourceType": "Measure",
+ "id": "CACU-DIAS-TOMA-TRATAMIENTO",
+ "extension": [
+ {
+ "url": "https://isssteleon.org/fhir/StructureDefinition/contrato",
+ "valueCode": "C3r"
+ },
+ {
+ "url": "https://isssteleon.org/fhir/StructureDefinition/tipos-periodo",
+ "valueCode": "semestre"
+ },
+ {
+ "url": "https://isssteleon.org/fhir/StructureDefinition/tipos-periodo",
+ "valueCode": "mes"
+ },
+ {
+ "url": "https://isssteleon.org/fhir/StructureDefinition/figuras",
+ "valueString": "fig_c3r_caja"
+ }
+ ],
+ "url": "https://isssteleon.org/fhir/Measure/CACU-DIAS-TOMA-TRATAMIENTO",
+ "version": "0.1.0",
+ "name": "cacu_dias_toma_tratamiento",
+ "title": "Tiempo de tamizaje a tratamiento",
+ "status": "active",
+ "subjectCodeableConcept": {
+ "coding": [
+ {
+ "system": "https://isssteleon.org/fhir/CodeSystem/unidad",
+ "code": "examen"
+ }
+ ]
+ },
+ "description": "Días naturales de la toma de cada citología del periodo al primer tratamiento posterior: una nota médica con un CIE-10 de tratamiento después de la primera colposcopia de la paciente, dentro del horizonte y a la fecha de corte. Entran todas las citologías, sean de tamizaje o no; se excluyen las de pacientes con un diagnóstico de cáncer cervicouterino anterior a la toma. El tratamiento se infiere de la nota: no distingue el indicado del realizado.",
+ "scoring": {
+ "coding": [
+ {
+ "system": "http://terminology.hl7.org/CodeSystem/measure-scoring",
+ "code": "continuous-variable"
+ }
+ ]
+ },
+ "improvementNotation": {
+ "coding": [
+ {
+ "system": "http://terminology.hl7.org/CodeSystem/measure-improvement-notation",
+ "code": "decrease"
+ }
+ ]
+ },
+ "group": [
+ {
+ "code": {
+ "coding": [
+ {
+ "system": "https://isssteleon.org/fhir/CodeSystem/grupo-medida",
+ "code": "TOTAL"
+ }
+ ]
+ },
+ "population": [
+ {
+ "code": {
+ "coding": [
+ {
+ "system": "http://terminology.hl7.org/CodeSystem/measure-population",
+ "code": "initial-population"
+ }
+ ]
+ },
+ "description": "Unidades del periodo",
+ "criteria": {
+ "language": "text/x-dbt-metric",
+ "expression": "cacu_dias_toma_tratamiento"
+ }
+ },
+ {
+ "code": {
+ "coding": [
+ {
+ "system": "http://terminology.hl7.org/CodeSystem/measure-population",
+ "code": "measure-observation"
+ }
+ ]
+ },
+ "description": "Unidades con valor",
+ "criteria": {
+ "language": "text/x-dbt-metric",
+ "expression": "cacu_dias_toma_tratamiento"
+ }
+ },
+ {
+ "code": {
+ "coding": [
+ {
+ "system": "http://terminology.hl7.org/CodeSystem/measure-population",
+ "code": "measure-population-exclusion"
+ }
+ ]
+ },
+ "description": "Unidades sin valor",
+ "criteria": {
+ "language": "text/x-dbt-metric",
+ "expression": "cacu_dias_toma_tratamiento"
+ }
+ }
+ ]
+ }
+ ]
+ },
+ "search": {
+ "mode": "match"
+ }
+ },
{
"fullUrl": "http://webapi/cacu/fhir/Measure/CACU-EU-TIEMPO-REPORTE",
"resource": {
diff --git a/src/app/features/indicadores/fixtures/regresion_cacu_tea_mapeo.json b/src/app/features/indicadores/fixtures/regresion_cacu_tea_mapeo.json
index 5942e66..be738f4 100644
--- a/src/app/features/indicadores/fixtures/regresion_cacu_tea_mapeo.json
+++ b/src/app/features/indicadores/fixtures/regresion_cacu_tea_mapeo.json
@@ -46,6 +46,10 @@
"version": "0.1.2",
"contrato": "C2",
"unidad": "paciente",
+ "unidades_periodo": {
+ "2021-S1": 0,
+ "2025-S2": 1
+ },
"tipo_periodo": "semestre",
"periodos": [
"2021-S1",
@@ -662,6 +666,10 @@
"version": "0.3.3",
"contrato": "C2",
"unidad": "paciente",
+ "unidades_periodo": {
+ "2021-S1": 0,
+ "2025-S2": 89
+ },
"tipo_periodo": "semestre",
"periodos": [
"2021-S1",
@@ -747,6 +755,10 @@
"version": "0.1.0",
"contrato": "C2",
"unidad": "paciente",
+ "unidades_periodo": {
+ "2021-S1": 0,
+ "2025-S2": 0
+ },
"tipo_periodo": "semestre",
"periodos": [
"2021-S1",
@@ -2256,7 +2268,7 @@
"grupo": null
},
"MALO": {
- "etiqueta": "Malo",
+ "etiqueta": "No aceptable",
"color": "#B8433A",
"grupo": null
},
@@ -2291,7 +2303,7 @@
"grupo": null
},
"MALO": {
- "etiqueta": "Malo",
+ "etiqueta": "No aceptable",
"color": "#B8433A",
"grupo": null
},
diff --git a/src/app/features/indicadores/indicador-ayuda.spec.ts b/src/app/features/indicadores/indicador-ayuda.spec.ts
new file mode 100644
index 0000000..e177c77
--- /dev/null
+++ b/src/app/features/indicadores/indicador-ayuda.spec.ts
@@ -0,0 +1,50 @@
+// Covers the round "?" help of TEA's cards: hover or focus shows the text, a click keeps it until the next click.
+// Fixture: a host component that projects one line of text into the button.
+import { Component } from '@angular/core';
+import { TestBed } from '@angular/core/testing';
+import { IndicadorAyuda } from './indicador-ayuda';
+
+@Component({ imports: [IndicadorAyuda], template: `Texto de ayuda ` })
+class Host { aperturas = 0; }
+
+describe('Ayuda redonda', () => {
+ function crear() {
+ const fixture = TestBed.createComponent(Host);
+ fixture.detectChanges();
+ const root: HTMLElement = fixture.nativeElement;
+ const boton = () => root.querySelector('.ayuda-boton')!;
+ const texto = () => root.querySelector('.ayuda-texto')?.textContent?.trim();
+ const ayuda = root.querySelector('.ayuda')!;
+ return { fixture, boton, texto, ayuda };
+ }
+
+ it('muestra el texto al pasar el cursor y lo oculta al salir', () => {
+ // Fails if hovering stops showing the guide or leaving leaves it open when it was not pinned.
+ const { fixture, texto, ayuda } = crear();
+ expect(texto()).toBeUndefined();
+ ayuda.dispatchEvent(new MouseEvent('mouseenter')); fixture.detectChanges();
+ expect(texto()).toBe('Texto de ayuda');
+ ayuda.dispatchEvent(new MouseEvent('mouseleave')); fixture.detectChanges();
+ expect(texto()).toBeUndefined();
+ });
+
+ it('un clic fija el texto hasta el siguiente clic', () => {
+ // Fails if the click stops pinning the text, if leaving closes a pinned text, or if a second click does not close it.
+ const { fixture, boton, texto, ayuda } = crear();
+ ayuda.dispatchEvent(new MouseEvent('mouseenter')); boton().click(); fixture.detectChanges();
+ ayuda.dispatchEvent(new MouseEvent('mouseleave')); fixture.detectChanges();
+ expect(texto()).toBe('Texto de ayuda');
+ expect(boton().getAttribute('aria-expanded')).toBe('true');
+ boton().click(); fixture.detectChanges();
+ expect(texto()).toBeUndefined();
+ expect(boton().getAttribute('aria-expanded')).toBe('false');
+ });
+
+ it('avisa solo al abrirse con un clic y nombra el botón', () => {
+ // Fails if closing also reports an opening (the metadata would be requested again) or the accessible name is lost.
+ const { fixture, boton } = crear();
+ boton().click(); boton().click(); boton().click(); fixture.detectChanges();
+ expect(fixture.componentInstance.aperturas).toBe(2);
+ expect(boton().getAttribute('aria-label')).toBe('Cómo leer: prueba');
+ });
+});
diff --git a/src/app/features/indicadores/indicador-ayuda.ts b/src/app/features/indicadores/indicador-ayuda.ts
new file mode 100644
index 0000000..ffeb980
--- /dev/null
+++ b/src/app/features/indicadores/indicador-ayuda.ts
@@ -0,0 +1,39 @@
+import { Component, input, output, signal } from '@angular/core';
+
+// Round "?" button at the top right of a card. Hover or focus shows its text; a click keeps it open until the next click.
+@Component({
+ selector: 'app-indicador-ayuda',
+ template: `
+
+
?
+ @if (visible()) {
+
+ }
+
+ `,
+ styles: `
+ :host { position: absolute; top: .5rem; right: .5rem; z-index: 2; }
+ .ayuda { position: relative; }
+ .ayuda-boton { display: inline-flex; align-items: center; justify-content: center; width: 1.75rem; height: 1.75rem; padding: 0; border: 0;
+ border-radius: 50%; background: transparent; box-shadow: inset 0 0 0 1.5px var(--issste-text-secondary); color: var(--issste-text); font: inherit; font-weight: 800; line-height: 1; cursor: pointer; }
+ .ayuda-boton:focus-visible { outline: 2px solid var(--issste-text); outline-offset: 3px; }
+ .ayuda-texto { position: absolute; top: calc(100% + .375rem); right: 0; width: min(22rem, 80vw); box-sizing: border-box; padding: var(--issste-space-3) var(--issste-space-4);
+ background: var(--issste-surface); color: var(--issste-text); border: 1px solid var(--issste-border); border-inline-start: 3px solid var(--issste-accent);
+ border-radius: var(--issste-radius); box-shadow: 0 4px 16px rgb(0 0 0 / .18); font: var(--mat-sys-body-small); line-height: 1.5; text-align: start; overflow-wrap: anywhere; }
+ `,
+})
+export class IndicadorAyuda {
+ readonly etiqueta = input('Cómo leer');
+ readonly opened = output();
+ readonly sobre = signal(false);
+ readonly fijo = signal(false);
+ private static contador = 0;
+ readonly idPanel = 'ayuda-' + ++IndicadorAyuda.contador;
+ visible() { return this.sobre() || this.fijo(); }
+ alternar() {
+ const abre = !this.fijo();
+ this.fijo.set(abre);
+ if (abre) this.opened.emit();
+ }
+}
diff --git a/src/app/features/indicadores/indicador-catalog-card.ts b/src/app/features/indicadores/indicador-catalog-card.ts
index 40b0b66..2e21b53 100644
--- a/src/app/features/indicadores/indicador-catalog-card.ts
+++ b/src/app/features/indicadores/indicador-catalog-card.ts
@@ -24,16 +24,18 @@ import { parTiempos } from './indicadores-tiempos-pareados';
import { IndicadorConteosPareados } from './indicador-conteos-pareados';
import { parConteos } from './indicadores-conteos-pareados';
+const DOBLE_ANCHO_TEA: readonly string[] = ['M28_casos_por_estado', 'M23_pacientes_evaluados'];
+
@Component({
selector: 'app-indicador-catalog-card',
- host: { '[class.dual-card]': 'isDual || isEu7 || isConfirmacion || isHistopatologia || !!tiempos || !!conteos' },
+ host: { '[class.dual-card]': 'isDual || isEu7 || isConfirmacion || isHistopatologia || !!tiempos || !!conteos', '[class.doble]': 'ocupaDos' },
imports: [MatButtonModule, MatCardModule, MatIconModule, IndicadorFigurePanel, IndicadorEu7Escenario, IndicadorTiemposPareados, IndicadorConfirmacionCitologia, IndicadorHistopatologiaCama, IndicadorConteosPareados],
template: `
@if (!conteos) {
}
@@ -81,12 +83,13 @@ import { parConteos } from './indicadores-conteos-pareados';
`,
styles: `
:host { display: flex; min-width: 0; margin: 0; }
- mat-card { flex: 1; min-width: 0; padding: clamp(.75rem, 2vw, 1.5rem); background: var(--issste-surface);
+ mat-card { position: relative; flex: 1; min-width: 0; padding: clamp(.75rem, 2vw, 1.5rem); background: var(--issste-surface);
color: var(--issste-text); border: 1px solid var(--issste-border); border-radius: var(--issste-radius); box-shadow: none; }
header { display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; gap: var(--issste-space-3); }
.catalog-content { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.graphic-region { flex: 1; min-width: 0; }
:host(.dual-card) { grid-column: 1 / -1; }
+ :host(.doble) { grid-column: span 2; }
.graphic-region { display: grid; grid-template-columns: minmax(0, 1fr); }
.representation-panel { display: grid; min-width: 0; grid-template-rows: auto minmax(0, 1fr); }
.representation-panel > h3 { margin: 1rem 0 0; overflow-wrap: anywhere; }
@@ -108,6 +111,7 @@ import { parConteos } from './indicadores-conteos-pareados';
.card-identity { min-width: 0; }
h2, p { overflow-wrap: anywhere; }
h2 { margin: 0; font-family: var(--issste-font-heading); font-weight: 500; font-size: 1.125rem; line-height: 1.3; }
+ h2.con-ayuda { padding-right: 2.5rem; }
.pin-toggle { align-self: start; margin-top: var(--issste-space-1); max-width: 100%; height: auto;
min-width: 48px; min-height: 48px; color: var(--issste-text); }
.pin-toggle mat-icon { flex-shrink: 0; }
@@ -137,13 +141,15 @@ export class IndicadorCatalogCard implements OnChanges, OnDestroy {
}
// Every domain follows CaMa's mockup: no pin, representation selector or figure count.
get sobrio() { return true; }
+ // TEA's stacked case charts span two columns of its three-column grid.
+ get ocupaDos() { return this.dominio === 'tea' && DOBLE_ANCHO_TEA.includes(this.indicador.id); }
get pair() { return dualFigures(this.indicador); }
get isEu7() { return this.dominio === 'cacu' && this.indicador.id === 'cacu_eu7'; }
get isConfirmacion() { return this.dominio === 'cacu' && this.indicador.id === ID_CONFIRMACION; }
// CaMa's histopathology by BI-RADS has its own coordinated view, as the cytology confirmation has in CaCu.
get isHistopatologia() { return this.dominio === 'cama' && this.indicador.id === ID_HISTOPATOLOGIA; }
// Connected time pairs replace the diagnosis card with one coordinated box plot.
- get tiempos() { return parTiempos(this.dominio, this.indicador.id); }
+ get tiempos() { return this.individual ? undefined : parTiempos(this.dominio, this.indicador.id); }
// Exams and patients of the same finding, drawn together on the exams' card.
get conteos() { return parConteos(this.dominio, this.indicador.id); }
get isDual() { return this.pair.includes(this.selectedFigure ?? ''); }
@@ -170,6 +176,8 @@ export class IndicadorCatalogCard implements OnChanges, OnDestroy {
@Input({ required: true }) applied!: GlobalApplied;
@Input() independentPeriods = false;
@Input() pinned = false;
+ // Draws the indicator alone even when it belongs to a connected pair.
+ @Input() individual = false;
@Input() visualProfile: FigureVisualProfile = READABLE_VISUAL_PROFILE;
readonly pinChanged = output();
@ViewChild('visibilityRegion') visibilityRegion?: ElementRef;
diff --git a/src/app/features/indicadores/indicador-conteos-pareados.html b/src/app/features/indicadores/indicador-conteos-pareados.html
index 2aac49c..6f4d98c 100644
--- a/src/app/features/indicadores/indicador-conteos-pareados.html
+++ b/src/app/features/indicadores/indicador-conteos-pareados.html
@@ -7,8 +7,8 @@
@case ('incompatible') { Respuesta incompatible: {{ message }}
Reintentar }
}
@if (status() === 'ready' && model; as m) {
- @let tituloMastografias = 'Porcentaje de mastografías con resultado en la clasificación de BI-RADS 4, 5 o 6, ' + m.periodo;
- @let tituloPacientes = 'Porcentaje de pacientes con resultados de BI-RADS 4, 5 o 6, ' + m.periodo;
+ @let tituloMastografias = 'Porcentaje de mastografías con resultado BI-RADS 4, 5 ó 6 en ' + m.periodo;
+ @let tituloPacientes = 'Porcentaje de pacientes con resultados BI-RADS 4, 5 ó 6 en ' + m.periodo;
@if (pages.length > 1) {
‹
diff --git a/src/app/features/indicadores/indicador-figura-pendiente.ts b/src/app/features/indicadores/indicador-figura-pendiente.ts
new file mode 100644
index 0000000..f65c191
--- /dev/null
+++ b/src/app/features/indicadores/indicador-figura-pendiente.ts
@@ -0,0 +1,29 @@
+import { Component, Input } from '@angular/core';
+import { MatCardModule } from '@angular/material/card';
+
+/** A figure the catalog does not publish yet: it keeps its place and title, with no figure and no number. */
+@Component({
+ selector: 'app-indicador-figura-pendiente',
+ imports: [MatCardModule],
+ template: `
+
+ {{ titulo }}
+ Integración pendiente. {{ detalle }}
+ Sin datos publicados
+
+ `,
+ styles: `
+ :host { display: flex; min-width: 0; margin: 0; }
+ mat-card { flex: 1; min-width: 0; padding: clamp(.75rem, 2vw, 1.5rem); background: var(--issste-surface); color: var(--issste-text);
+ border: 1px solid var(--issste-border); border-radius: var(--issste-radius); box-shadow: none; }
+ h2 { margin: 0; font-family: var(--issste-font-heading); font-weight: 500; font-size: 1.125rem; line-height: 1.3; overflow-wrap: anywhere; }
+ p { margin: var(--issste-space-3) 0 0; overflow-wrap: anywhere; }
+ .estado { color: var(--issste-text-secondary); }
+ .vacio { display: grid; place-items: center; min-height: 12rem; margin-top: var(--issste-space-3); color: var(--issste-text-secondary);
+ border: 1px dashed var(--issste-border); border-radius: var(--issste-radius); }
+ `,
+})
+export class IndicadorFiguraPendiente {
+ @Input({ required: true }) titulo!: string;
+ @Input() detalle = 'Este indicador aún no está publicado por el catálogo institucional.';
+}
diff --git a/src/app/features/indicadores/indicador-figure-card.html b/src/app/features/indicadores/indicador-figure-card.html
index 406c5c4..58e55a3 100644
--- a/src/app/features/indicadores/indicador-figure-card.html
+++ b/src/app/features/indicadores/indicador-figure-card.html
@@ -1,5 +1,12 @@
-
-@if (selected) {
+
+@if (selected && ayudaRedonda) {
+
+ @for (line of interpretation; track $index) { {{ line }} }
+ @if (state.status === 'ready' && state.footnotes?.length) {
+ @for (note of state.footnotes; track $index) { {{ note }}
}
+ }
+
+} @else if (selected) {
{{ state.emptyMessage ?? 'No hay valores visibles para la selección. No se puede determinar la causa a partir de la figura recibida.' }}
}
-
- Figura: {{ figureDisplayName(figuraId, selected?.figuras ?? []) }}
+ @if (!ayudaRedonda) {
+
+ Figura: {{ figureDisplayName(figuraId, selected?.figuras ?? []) }}
+ }
} @else {
{{ !selected?.figuras?.length ? 'El indicador no tiene figuras disponibles.' : 'Completa una selección válida para consultar la figura.' }}
}
@@ -84,7 +93,7 @@
}
@if (state.status === 'ready' && state.highlight; as h) {
-
+
Selección: {{ highlightStatus }}
Volver
@for (row of highlightRows(h); track row.group?.id ?? '') {
diff --git a/src/app/features/indicadores/indicador-figure-card.scss b/src/app/features/indicadores/indicador-figure-card.scss
index 3fe56b0..8f2c09f 100644
--- a/src/app/features/indicadores/indicador-figure-card.scss
+++ b/src/app/features/indicadores/indicador-figure-card.scss
@@ -22,6 +22,7 @@
.methodology-toggle:focus-visible { outline: 2px solid var(--issste-text); outline-offset: 3px; }
.figure-card { display: grid; grid-template-rows: auto auto auto minmax(0, 1fr) auto auto;
overflow: visible; min-width: 0; border: 1px solid var(--issste-border); }
+.figure-card.sin-marco { position: static; border: 0; box-shadow: none; background: transparent; --mat-card-outlined-outline-width: 0; --mat-card-elevated-container-elevation: none; }
.figure-heading { grid-row: 2; min-width: 0; padding-bottom: .5rem; }
.interpretation { grid-row: 1; }
.figure-legend { grid-row: 3; min-width: 0; }
@@ -117,6 +118,7 @@
.highlight-legend { display: grid; gap: .5rem; padding: .5rem .75rem .75rem; color: var(--issste-text); }
.dark .highlight-legend { color: #eef1f7; }
.highlight-status { margin: 0; font-weight: 600; }
+.sin-estado .highlight-status { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.highlight-back { justify-self: start; }
.highlight-keys { display: flex; flex-wrap: wrap; gap: .5rem; }
.highlight-legend button { display: inline-flex; align-items: center; gap: .4rem; min-height: 36px; padding: .3rem .75rem; text-align: start;
@@ -126,3 +128,6 @@
.highlight-legend button:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
.highlight-legend .legend-swatch { border-radius: 50%; }
.highlight-legend .highlight-group { font-weight: 600; }
+
+.ayuda-lista { margin: 0; padding-left: 1.1rem; }
+.ayuda-nota { margin: .5rem 0 0; }
diff --git a/src/app/features/indicadores/indicador-figure-card.spec.ts b/src/app/features/indicadores/indicador-figure-card.spec.ts
index d7b6cd9..be6bde9 100644
--- a/src/app/features/indicadores/indicador-figure-card.spec.ts
+++ b/src/app/features/indicadores/indicador-figure-card.spec.ts
@@ -515,4 +515,14 @@ describe('IndicadorFigureCard', () => {
expect(JSON.stringify(original)).toBe(snapshot); expect(JSON.stringify(copy)).toBe(copySnapshot);
});
+ it('con la ayuda redonda no repite el título ni el nombre de la figura', () => {
+ // Fails if TEA's cards bring back the heading box with the title and «Figura: …» under the card's own title.
+ fixture.componentRef.setInput('ayudaRedonda', true);
+ ready({ data: [{ y: [1] }], layout: {} });
+ const root: HTMLElement = fixture.nativeElement;
+ expect(root.querySelector('.figure-title')).toBeNull();
+ expect(root.querySelector('.figure-id')).toBeNull();
+ expect(root.querySelector('.ayuda-boton')).not.toBeNull();
+ expect(root.querySelector('.interpretation')).toBeNull();
+ });
});
diff --git a/src/app/features/indicadores/indicador-figure-card.ts b/src/app/features/indicadores/indicador-figure-card.ts
index dc6f8cc..3e56541 100644
--- a/src/app/features/indicadores/indicador-figure-card.ts
+++ b/src/app/features/indicadores/indicador-figure-card.ts
@@ -10,6 +10,7 @@ import { figureDisplayName } from './indicadores-figure-labels';
import { CategoryLabel } from './indicadores-axis-labels';
import { figureIdentity, identityElementId } from './indicadores-identities';
import { PlotlyChart } from '../../shared/plotly/plotly-chart';
+import { IndicadorAyuda } from './indicador-ayuda';
import { figureInterpretation, PERIOD_INTERPRETATION } from './indicadores-methodology';
import { DonutHierarchy, DonutLegendEntry, DonutSelection, donutSimpleView, donutView } from './indicadores-donut-drilldown';
import { FigureHighlight, highlightAt, highlightFigure, highlightLabel, highlightRows, HighlightSelection, toggleHighlight } from './indicadores-highlight';
@@ -41,7 +42,7 @@ export interface FigureState {
selector: 'app-indicador-figure-card',
standalone: true,
host: { '[class.methodology-expanded]': 'methodologyExpanded()' },
- imports: [MatButtonModule, MatIconModule, MatCardModule, MatProgressBarModule, MatTooltipModule, PlotlyChart],
+ imports: [MatButtonModule, MatIconModule, MatCardModule, MatProgressBarModule, MatTooltipModule, PlotlyChart, IndicadorAyuda],
templateUrl: './indicador-figure-card.html',
styleUrl: './indicador-figure-card.scss',
})
@@ -142,6 +143,8 @@ export class IndicadorFigureCard implements OnChanges {
if (point?.curveNumber === (this.activeParent ? 1 : 0) && typeof point.label === 'string') this.expandParent(point.label);
else if (this.activeParent && point?.curveNumber === 0 && typeof point.label === 'string') this.selectCategory(point.label);
}
+ // A round "?" button with the reading guide instead of the «Cómo leer» box.
+ @Input() ayudaRedonda = false;
@Input() selected?: Indicador;
@Input() metadata?: IndicadorMetadatos;
@Input({ required: true }) figuraId!: string;
diff --git a/src/app/features/indicadores/indicador-figure-panel.spec.ts b/src/app/features/indicadores/indicador-figure-panel.spec.ts
index e34ec83..d858e65 100644
--- a/src/app/features/indicadores/indicador-figure-panel.spec.ts
+++ b/src/app/features/indicadores/indicador-figure-panel.spec.ts
@@ -33,6 +33,8 @@ describe('IndicadorFigurePanel', () => {
fixture.componentRef.setInput('dominio', 'tea');
fixture.componentRef.setInput('indicador', catalog[0]);
fixture.componentRef.setInput('figuraId', 'f1');
+ // These tests cover the «Cómo leer» box shared by the domains; TEA's round help has its own spec.
+ fixture.componentRef.setInput('ayudaRedonda', false);
fixture.componentRef.setInput('tema', 'claro');
state = TestBed.inject(IndicadoresMemory).restoreGlobal('tea', ['semestre']);
fixture.componentRef.setInput('applied', state.applied);
@@ -373,6 +375,7 @@ describe('IndicadorFigurePanel', () => {
fixture = TestBed.createComponent(IndicadorFigurePanel);
fixture.componentRef.setInput('dominio', 'tea'); fixture.componentRef.setInput('indicador', catalog[0]);
fixture.componentRef.setInput('figuraId', 'f1'); fixture.componentRef.setInput('tema', 'claro');
+ fixture.componentRef.setInput('ayudaRedonda', false);
fixture.componentRef.setInput('applied', state.applied);
page = fixture.componentInstance; load(); figure().flush({ data: [], layout: {} });
expect(JSON.stringify(state)).toBe(snapshot);
diff --git a/src/app/features/indicadores/indicador-figure-panel.ts b/src/app/features/indicadores/indicador-figure-panel.ts
index 0213b44..711c4c4 100644
--- a/src/app/features/indicadores/indicador-figure-panel.ts
+++ b/src/app/features/indicadores/indicador-figure-panel.ts
@@ -23,9 +23,10 @@ import { MatTooltipModule } from '@angular/material/tooltip';
@Component({
selector: 'app-indicador-figure-panel',
+ host: { '[class.ayuda-externa]': 'conAyudaRedonda' },
imports: [IndicadorFigureCard, MatTooltipModule],
template: `
-