feat(cama): the detection-rate card without its Wilson interval line
How: the card shows the rate, its period and its one-line description, like the other C1 cards. The `intervalo` option of KpiDefinition, the interval in KpiResult and the card's line drawing are removed, since no card uses them. Implications: the published ic_bajo/ic_alto are no longer read by any card; the interval is still shown where it belongs, in the rate's Histórico chart (the band) and in the BI-RADS confirmation rates.
This commit is contained in:
@@ -1,8 +1,6 @@
|
|||||||
import { Component, Input } from '@angular/core';
|
import { Component, Input } from '@angular/core';
|
||||||
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
||||||
import { MatCardModule } from '@angular/material/card';
|
import { MatCardModule } from '@angular/material/card';
|
||||||
import { percentNumber } from './indicadores-format';
|
|
||||||
import { KpiIntervalo } from './indicadores-kpi';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-indicador-kpi-card',
|
selector: 'app-indicador-kpi-card',
|
||||||
@@ -14,19 +12,6 @@ import { KpiIntervalo } from './indicadores-kpi';
|
|||||||
@if (value !== null && value !== undefined) {
|
@if (value !== null && value !== undefined) {
|
||||||
<p class="value">{{ value }}@if (unit) { <span>{{ unit }}</span> }</p>
|
<p class="value">{{ value }}@if (unit) { <span>{{ unit }}</span> }</p>
|
||||||
}
|
}
|
||||||
@if (intervalo; as ic) {
|
|
||||||
<div class="intervalo" role="img" [attr.aria-label]="'Intervalo de confianza de Wilson al 95 %: ' + texto(ic.bajo) + ' a ' + texto(ic.alto) + ' %'">
|
|
||||||
<svg viewBox="0 0 100 12" preserveAspectRatio="none" aria-hidden="true">
|
|
||||||
<line class="eje" x1="0" y1="6" x2="100" y2="6" />
|
|
||||||
<line class="ic" [attr.x1]="ic.bajo" y1="6" [attr.x2]="ic.alto" y2="6" />
|
|
||||||
<line class="ic" [attr.x1]="ic.bajo" y1="2" [attr.x2]="ic.bajo" y2="10" />
|
|
||||||
<line class="ic" [attr.x1]="ic.alto" y1="2" [attr.x2]="ic.alto" y2="10" />
|
|
||||||
<line class="punto" [attr.x1]="ic.valor" y1="1" [attr.x2]="ic.valor" y2="11" />
|
|
||||||
</svg>
|
|
||||||
<span class="escala" aria-hidden="true"><span>0 %</span><span>100 %</span></span>
|
|
||||||
<span class="leyenda">IC 95 % (Wilson): {{ texto(ic.bajo) }} a {{ texto(ic.alto) }} %</span>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
@if (temporalReference) { <p>{{ temporalReference }}</p> }
|
@if (temporalReference) { <p>{{ temporalReference }}</p> }
|
||||||
<!-- A card with its value says nothing more about its state; any other state is the message. -->
|
<!-- A card with its value says nothing more about its state; any other state is the message. -->
|
||||||
@if (state !== 'Disponible') { <p class="kpi-state" role="status">{{ state }}</p> }
|
@if (state !== 'Disponible') { <p class="kpi-state" role="status">{{ state }}</p> }
|
||||||
@@ -44,14 +29,6 @@ import { KpiIntervalo } from './indicadores-kpi';
|
|||||||
.kpi-state, .additional-info { color: var(--issste-text-secondary); font: var(--mat-sys-body-medium); }
|
.kpi-state, .additional-info { color: var(--issste-text-secondary); font: var(--mat-sys-body-medium); }
|
||||||
.value { font-size: 1.75rem; font-weight: 500; line-height: 1.2; }
|
.value { font-size: 1.75rem; font-weight: 500; line-height: 1.2; }
|
||||||
.value span { margin-inline-start: .3em; }
|
.value span { margin-inline-start: .3em; }
|
||||||
.intervalo { margin-top: var(--issste-space-3); }
|
|
||||||
.intervalo svg { display: block; width: 100%; height: 14px; overflow: visible; }
|
|
||||||
.intervalo line { vector-effect: non-scaling-stroke; }
|
|
||||||
.eje { stroke: var(--issste-border); stroke-width: 2; }
|
|
||||||
.ic { stroke: var(--issste-text); stroke-width: 2; }
|
|
||||||
.punto { stroke: var(--issste-accent); stroke-width: 4; }
|
|
||||||
.escala { display: flex; justify-content: space-between; color: var(--issste-text-secondary); font: var(--mat-sys-body-small); }
|
|
||||||
.leyenda { display: block; color: var(--issste-text-secondary); font: var(--mat-sys-body-medium); }
|
|
||||||
`,
|
`,
|
||||||
})
|
})
|
||||||
export class IndicadorKpiCard {
|
export class IndicadorKpiCard {
|
||||||
@@ -63,8 +40,6 @@ export class IndicadorKpiCard {
|
|||||||
@Input() notes: string[] = [];
|
@Input() notes: string[] = [];
|
||||||
@Input() state = 'Pendiente de definición';
|
@Input() state = 'Pendiente de definición';
|
||||||
@Input() additionalInfo?: string;
|
@Input() additionalInfo?: string;
|
||||||
@Input() intervalo?: KpiIntervalo;
|
|
||||||
texto(valor: number) { return percentNumber(valor); }
|
|
||||||
get informationLine(): string | undefined {
|
get informationLine(): string | undefined {
|
||||||
const lines = [this.additionalInfo, ...this.notes].map(value => value?.trim()).filter((value): value is string => !!value);
|
const lines = [this.additionalInfo, ...this.notes].map(value => value?.trim()).filter((value): value is string => !!value);
|
||||||
return [...new Set(lines)].join(' ');
|
return [...new Set(lines)].join(' ');
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ interface KpiDisplay extends KpiResult { period?: string; earlier?: boolean; ver
|
|||||||
imports: [IndicadorKpiCard, MatButtonModule],
|
imports: [IndicadorKpiCard, MatButtonModule],
|
||||||
template: `<app-indicador-kpi-card [title]="definition.title" [value]="result().value" [unit]="definition.unit"
|
template: `<app-indicador-kpi-card [title]="definition.title" [value]="result().value" [unit]="definition.unit"
|
||||||
[state]="result().state" [additionalInfo]="result().info" [temporalReference]="temporalReference"
|
[state]="result().state" [additionalInfo]="result().info" [temporalReference]="temporalReference"
|
||||||
[loading]="result().loading ?? false" [notes]="dominio !== 'tea' ? [] : result().notes ?? []" [intervalo]="result().intervalo" />
|
[loading]="result().loading ?? false" [notes]="dominio !== 'tea' ? [] : result().notes ?? []" />
|
||||||
@if (result().state === 'Error de consulta') {
|
@if (result().state === 'Error de consulta') {
|
||||||
<button type="button" mat-stroked-button (click)="retry()" [attr.aria-label]="'Reintentar ' + definition.title">Reintentar consulta</button>
|
<button type="button" mat-stroked-button (click)="retry()" [attr.aria-label]="'Reintentar ' + definition.title">Reintentar consulta</button>
|
||||||
}`,
|
}`,
|
||||||
|
|||||||
@@ -70,24 +70,3 @@ it('TEA usa sus cinco indicadores destacados y su grupo C1 es TOTAL', () => {
|
|||||||
.toBe('Selección no consolidable');
|
.toBe('Selección no consolidable');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('KPI con intervalo de Wilson', () => {
|
|
||||||
const definition = KPI_BY_DOMAIN.cama.find(d => d.intervalo)!;
|
|
||||||
const run = (row: Record<string, unknown>) => kpiResult({ id: definition.id, contrato: 'C1', tipo_periodo: 'semestre', periodos: ['2025-S1'],
|
|
||||||
filas: [{ ...total, grupo: 'total', numerador: 129, denominador: 306, valor: 42.2, ...row }] }, definition, 'cama', applied);
|
|
||||||
it('lleva el intervalo publicado junto al valor', () => {
|
|
||||||
// Fails if the card stops receiving the published Wilson bounds, or recomputes them.
|
|
||||||
expect(run({ ic_bajo: 36.8, ic_alto: 47.8 }).intervalo).toEqual({ valor: 42.2, bajo: 36.8, alto: 47.8 });
|
|
||||||
});
|
|
||||||
it('no dibuja un intervalo ausente o que no contiene su valor', () => {
|
|
||||||
// Fails if missing or inconsistent bounds are drawn instead of omitted.
|
|
||||||
expect(run({}).intervalo).toBeUndefined();
|
|
||||||
expect(run({ ic_bajo: 45, ic_alto: 47.8 }).intervalo).toBeUndefined();
|
|
||||||
expect(run({ ic_bajo: 36.8, ic_alto: 47.8 }).value).toBe('42.2');
|
|
||||||
});
|
|
||||||
it('una tarjeta C1 que no lo pide no lo recibe', () => {
|
|
||||||
// Fails if the interval line leaks to cards that didn't ask for it.
|
|
||||||
const other: KpiDefinition = { id: 'cama_confirmacion_birads45', title: 'Confirmación', contrato: 'C1', unit: '%' };
|
|
||||||
expect(kpiResult({ id: other.id, contrato: 'C1', tipo_periodo: 'semestre', periodos: ['2025-S1'],
|
|
||||||
filas: [{ ...total, grupo: 'total', numerador: 1, denominador: 2, valor: 50, ic_bajo: 9, ic_alto: 91 }] }, other, 'cama', applied).intervalo).toBeUndefined();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ export interface KpiDefinition {
|
|||||||
id: string; title: string; contrato: 'C1' | 'C2' | 'C3r'; unit: string; singleAppliedPeriod?: boolean;
|
id: string; title: string; contrato: 'C1' | 'C2' | 'C3r'; unit: string; singleAppliedPeriod?: boolean;
|
||||||
// C1 only: replaces the domain's explanatory line when the numerator is not the domain's usual one.
|
// C1 only: replaces the domain's explanatory line when the numerator is not the domain's usual one.
|
||||||
c1Info?: (numerador: number, denominador: number) => string;
|
c1Info?: (numerador: number, denominador: number) => string;
|
||||||
// C1 only: draw the published Wilson interval as a horizontal line under the value.
|
|
||||||
intervalo?: boolean;
|
|
||||||
}
|
}
|
||||||
// Same laboratory-result source used by PARES_TIEMPOS; diagnosis has its own ID.
|
// Same laboratory-result source used by PARES_TIEMPOS; diagnosis has its own ID.
|
||||||
export const CACU_RESULTADO_KPI: KpiDefinition = {
|
export const CACU_RESULTADO_KPI: KpiDefinition = {
|
||||||
@@ -39,7 +37,7 @@ export const KPI_BY_DOMAIN: Record<Dominio, KpiDefinition[]> = {
|
|||||||
],
|
],
|
||||||
cama: [
|
cama: [
|
||||||
{ id: 'cama_birads_456_paciente', title: 'Pacientes evaluadas con BI-RADS 4, 5 y 6', contrato: 'C2', unit: 'pacientes' },
|
{ id: 'cama_birads_456_paciente', title: 'Pacientes evaluadas con BI-RADS 4, 5 y 6', contrato: 'C2', unit: 'pacientes' },
|
||||||
{ id: 'cama_tasa_deteccion_histopatologica', title: 'Tasa de detección histopatológica', contrato: 'C1', unit: '%', intervalo: true,
|
{ id: 'cama_tasa_deteccion_histopatologica', title: 'Tasa de detección histopatológica', contrato: 'C1', unit: '%',
|
||||||
c1Info: (n, d) => `${n} de ${d} biopsias con resultado maligno.` },
|
c1Info: (n, d) => `${n} de ${d} biopsias con resultado maligno.` },
|
||||||
{ id: 'cama_eu38a', title: 'Tiempo de tamizaje a resultado', contrato: 'C3r', unit: 'días (mediana)' },
|
{ id: 'cama_eu38a', title: 'Tiempo de tamizaje a resultado', contrato: 'C3r', unit: 'días (mediana)' },
|
||||||
{ id: 'cama_dias_resultado_diagnostico', title: 'Tiempo de resultado a diagnóstico', contrato: 'C3r', unit: 'días (mediana)' },
|
{ id: 'cama_dias_resultado_diagnostico', title: 'Tiempo de resultado a diagnóstico', contrato: 'C3r', unit: 'días (mediana)' },
|
||||||
@@ -62,8 +60,7 @@ const C3R_INFO: Record<Dominio, (n: number, q1: number, q3: number) => string> =
|
|||||||
cacu: (n, q1, q3) => `${n} citologías; primer cuartil: ${q1} días; tercer cuartil: ${q3} días.`,
|
cacu: (n, q1, q3) => `${n} citologías; primer cuartil: ${q1} días; tercer cuartil: ${q3} días.`,
|
||||||
cama: (n, q1, q3) => `${n} mastografías; Q1 a Q3: ${q1} a ${q3} días.`,
|
cama: (n, q1, q3) => `${n} mastografías; Q1 a Q3: ${q1} a ${q3} días.`,
|
||||||
};
|
};
|
||||||
export interface KpiIntervalo { valor: number; bajo: number; alto: number; }
|
export interface KpiResult { state: string; value?: string | number; info?: string; loading?: boolean; notes?: string[]; categorias?: Record<string, number>; }
|
||||||
export interface KpiResult { state: string; value?: string | number; info?: string; loading?: boolean; notes?: string[]; categorias?: Record<string, number>; intervalo?: KpiIntervalo; }
|
|
||||||
const finite = (v: unknown): v is number => typeof v === 'number' && Number.isFinite(v);
|
const finite = (v: unknown): v is number => typeof v === 'number' && Number.isFinite(v);
|
||||||
const count = (v: unknown): v is number => finite(v) && Number.isSafeInteger(v) && v >= 0;
|
const count = (v: unknown): v is number => finite(v) && Number.isSafeInteger(v) && v >= 0;
|
||||||
const unscoped = { state: 'Selección no consolidable', info: 'Elige un único periodo. No hay una regla aprobada para consolidar periodos, grupos o estratos.' };
|
const unscoped = { state: 'Selección no consolidable', info: 'Elige un único periodo. No hay una regla aprobada para consolidar periodos, grupos o estratos.' };
|
||||||
@@ -102,12 +99,7 @@ export function kpiResult(data: IndicadorDatos, definition: KpiDefinition, domai
|
|||||||
}
|
}
|
||||||
if (definition.contrato === 'C1') {
|
if (definition.contrato === 'C1') {
|
||||||
if (!finite(row['valor']) || row['valor'] < 0 || row['valor'] > 100 || !count(row['numerador']) || !count(row['denominador']) || row['numerador'] > row['denominador']) return empty;
|
if (!finite(row['valor']) || row['valor'] < 0 || row['valor'] > 100 || !count(row['numerador']) || !count(row['denominador']) || row['numerador'] > row['denominador']) return empty;
|
||||||
const info = (definition.c1Info ?? C1_INFO[domain])(row['numerador'], row['denominador']);
|
return { state: 'Disponible', value: percentNumber(row['valor']), info: (definition.c1Info ?? C1_INFO[domain])(row['numerador'], row['denominador']) };
|
||||||
const [bajo, alto, valor] = [row['ic_bajo'], row['ic_alto'], row['valor']];
|
|
||||||
// An interval that doesn't contain its value is not drawn rather than drawn wrong.
|
|
||||||
const intervalo = definition.intervalo && finite(bajo) && finite(alto) && 0 <= bajo && bajo <= valor && valor <= alto && alto <= 100
|
|
||||||
? { valor, bajo, alto } : undefined;
|
|
||||||
return { state: 'Disponible', value: percentNumber(valor), info, ...(intervalo ? { intervalo } : {}) };
|
|
||||||
}
|
}
|
||||||
if (!finite(row['mediana']) || !count(row['n']) || (definition.id === CACU_RESULTADO_KPI.id && row['n'] === 0) || !finite(row['q1']) || !finite(row['q3']) || row['q1'] < 0 || row['q1'] > row['mediana'] || row['mediana'] > row['q3'] || row['unidad'] !== 'dias') return empty;
|
if (!finite(row['mediana']) || !count(row['n']) || (definition.id === CACU_RESULTADO_KPI.id && row['n'] === 0) || !finite(row['q1']) || !finite(row['q3']) || row['q1'] < 0 || row['q1'] > row['mediana'] || row['mediana'] > row['q3'] || row['unidad'] !== 'dias') return empty;
|
||||||
return { state: 'Disponible', value: row['mediana'], info: C3R_INFO[domain](row['n'], row['q1'], row['q3']) };
|
return { state: 'Disponible', value: row['mediana'], info: C3R_INFO[domain](row['n'], row['q1'], row['q3']) };
|
||||||
|
|||||||
Reference in New Issue
Block a user