Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f3b73f4404 | |||
| 1fef7812b4 | |||
| 6465165e34 | |||
| a26df55214 |
+3
-1
@@ -7,10 +7,12 @@
|
|||||||
@if (m.escenarios.length === 0) { <p role="status">Todavía no hay escenarios clínicos con pacientes suficientes para mostrar.</p> }
|
@if (m.escenarios.length === 0) { <p role="status">Todavía no hay escenarios clínicos con pacientes suficientes para mostrar.</p> }
|
||||||
@else {
|
@else {
|
||||||
<label class="selector">Escenario clínico
|
<label class="selector">Escenario clínico
|
||||||
<select [value]="escenario()" (change)="elegir($any($event.target).value)">
|
<select [value]="escenario() ?? ''" (change)="elegir($any($event.target).value)">
|
||||||
|
@if (escenario() === null) { <option value="" selected disabled>Elige un escenario…</option> }
|
||||||
@for (e of m.escenarios; track e.nombre) { <option [value]="e.nombre" [selected]="e.nombre === escenario()">{{ e.nombre }}</option> }
|
@for (e of m.escenarios; track e.nombre) { <option [value]="e.nombre" [selected]="e.nombre === escenario()">{{ e.nombre }}</option> }
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
|
@if (escenario() === null) { <p role="status">La paciente no pertenece a ningún escenario clínico con pacientes suficientes; elige uno para ver su curva.</p> }
|
||||||
@let l = lectura();
|
@let l = lectura();
|
||||||
@if (l?.tipo === 'cargando') { <p role="status">Calculando con los datos más recientes…</p> }
|
@if (l?.tipo === 'cargando') { <p role="status">Calculando con los datos más recientes…</p> }
|
||||||
@if (l?.tipo === 'rechazada') { <p role="status">{{ $any(l).motivo }}</p> }
|
@if (l?.tipo === 'rechazada') { <p role="status">{{ $any(l).motivo }}</p> }
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import { CamaAnalisisSupervivencia } from './cama-analisis-supervivencia.compone
|
|||||||
import { CamaCurvasService, respuestaCurvas } from './cama-curvas.service';
|
import { CamaCurvasService, respuestaCurvas } from './cama-curvas.service';
|
||||||
import { CamaFactoresRiesgo, entradasDe } from './cama-factores-riesgo.component';
|
import { CamaFactoresRiesgo, entradasDe } from './cama-factores-riesgo.component';
|
||||||
import { CamaRecurrenciaService, respuestaRecurrencia } from './cama-recurrencia.service';
|
import { CamaRecurrenciaService, respuestaRecurrencia } from './cama-recurrencia.service';
|
||||||
|
import { figuraRecurrencia } from './cama-recurrencia-figura';
|
||||||
|
|
||||||
const meses = Array.from({ length: 25 }, (_, i) => i);
|
const meses = Array.from({ length: 25 }, (_, i) => i);
|
||||||
const decreciente = (fin: number) => meses.map(m => 1 - (1 - fin) * (m / 24));
|
const decreciente = (fin: number) => meses.map(m => 1 - (1 - fin) * (m / 24));
|
||||||
@@ -98,6 +99,18 @@ describe('Análisis de supervivencia', () => {
|
|||||||
expect([...(f.nativeElement as HTMLElement).querySelectorAll('h5')].map(h => h.textContent!.trim())).toEqual(['Análisis de supervivencia', 'Factores de riesgo']);
|
expect([...(f.nativeElement as HTMLElement).querySelectorAll('h5')].map(h => h.textContent!.trim())).toEqual(['Análisis de supervivencia', 'Factores de riesgo']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Fails if a patient in no drawable scenario gets another subgroup's curve instead of a prompt to choose one.
|
||||||
|
it('draws nothing and asks to choose when the patient belongs to no scenario', () => {
|
||||||
|
TestBed.resetTestingModule();
|
||||||
|
TestBed.configureTestingModule({ providers: [plotly(), { provide: CamaCurvasService, useValue: {
|
||||||
|
escenarios: () => of({ escenarios: [{ nombre: '< 45 años', n: 100 }], predeterminado: null }), consulta } }] });
|
||||||
|
const f = montar();
|
||||||
|
|
||||||
|
expect(consulta).not.toHaveBeenCalled();
|
||||||
|
expect(f.nativeElement.querySelectorAll('app-plotly-chart')).toHaveLength(0);
|
||||||
|
expect(texto(f)).toContain('no pertenece a ningún escenario clínico');
|
||||||
|
});
|
||||||
|
|
||||||
// Fails if choosing a scenario changes only the curve or only the label: the selector decides both at once, one scenario at a time.
|
// Fails if choosing a scenario changes only the curve or only the label: the selector decides both at once, one scenario at a time.
|
||||||
it('changes the curve and the label together when another scenario is chosen, and never draws two', () => {
|
it('changes the curve and the label together when another scenario is chosen, and never draws two', () => {
|
||||||
const f = montar();
|
const f = montar();
|
||||||
@@ -112,6 +125,14 @@ describe('Análisis de supervivencia', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('Análisis de recurrencia', () => {
|
describe('Análisis de recurrencia', () => {
|
||||||
|
// Fails if the y axis is scaled by follow-up the axis does not show: a curve that stays above 0.8 in the 72 months drawn must not start its axis at 0.2.
|
||||||
|
it('scales the y axis to the months it draws', () => {
|
||||||
|
const largo = { ...figura('metabric', 'Largo'), observado_hasta: 300, months_max: 72,
|
||||||
|
km: { months: Array.from({ length: 301 }, (_, i) => i), S: Array.from({ length: 301 }, (_, i) => 1 - i / 400), low: Array.from({ length: 301 }, (_, i) => (i <= 72 ? 0.85 : 0.2)), high: Array.from({ length: 301 }, () => 1) } };
|
||||||
|
|
||||||
|
expect((figuraRecurrencia(respuestaRecurrencia({ modelo: { nombre: 'cama-recurrence', version: '1' }, horizontes: [12, 36, 60], escenarios: [largo], resumen: [], predeterminado: null }).escenarios[0]).layout as any).yaxis.range[0]).toBeGreaterThan(0.5);
|
||||||
|
});
|
||||||
|
|
||||||
const figura = (cohorte: string, escenario: string) => ({ cohorte, cohorte_nombre: cohorte === 'scanb' ? 'SCAN-B' : 'METABRIC', escenario, n: 300, recaidas: 180,
|
const figura = (cohorte: string, escenario: string) => ({ cohorte, cohorte_nombre: cohorte === 'scanb' ? 'SCAN-B' : 'METABRIC', escenario, n: 300, recaidas: 180,
|
||||||
horizons_months: [12, 36, 60], observado_hasta: 60, months_max: 72,
|
horizons_months: [12, 36, 60], observado_hasta: 60, months_max: 72,
|
||||||
km: { months: Array.from({ length: 61 }, (_, i) => i), S: Array.from({ length: 61 }, (_, i) => 1 - i / 200), low: Array.from({ length: 61 }, (_, i) => 1 - i / 190), high: Array.from({ length: 61 }, () => 1) },
|
km: { months: Array.from({ length: 61 }, (_, i) => i), S: Array.from({ length: 61 }, (_, i) => 1 - i / 200), low: Array.from({ length: 61 }, (_, i) => 1 - i / 190), high: Array.from({ length: 61 }, () => 1) },
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export function figuraRecurrencia(f: FiguraRecurrencia, tema: Tema = 'claro'): P
|
|||||||
const L = ETIQUETAS_RECURRENCIA, d = f.points.COMB, km = f.km;
|
const L = ETIQUETAS_RECURRENCIA, d = f.points.COMB, km = f.km;
|
||||||
const texto = tema === 'oscuro' ? '#e5e9f0' : '#1f2933', rejilla = tema === 'oscuro' ? 'rgba(229,233,240,.18)' : 'rgba(31,41,51,.12)';
|
const texto = tema === 'oscuro' ? '#e5e9f0' : '#1f2933', rejilla = tema === 'oscuro' ? 'rgba(229,233,240,.18)' : 'rgba(31,41,51,.12)';
|
||||||
const visibles = (t: number[], S: number[]) => S.filter((_, i) => t[i] <= f.months_max);
|
const visibles = (t: number[], S: number[]) => S.filter((_, i) => t[i] <= f.months_max);
|
||||||
const minimo = Math.max(0, Math.floor((Math.min(...km.low, ...visibles(f.weibull.t, f.weibull.S), ...visibles(f.weibull_fractional.t, f.weibull_fractional.S), ...d.low) - 0.02) * 20) / 20);
|
const minimo = Math.max(0, Math.floor((Math.min(...visibles(km.months, km.low), ...visibles(f.weibull.t, f.weibull.S), ...visibles(f.weibull_fractional.t, f.weibull_fractional.S), ...d.low) - 0.02) * 20) / 20);
|
||||||
const data: Record<string, unknown>[] = [
|
const data: Record<string, unknown>[] = [
|
||||||
{ type: 'scatter', mode: 'lines', x: km.months, y: km.high, line: { width: 0, shape: 'hv' }, showlegend: false, hoverinfo: 'skip', legendgroup: 'km' },
|
{ type: 'scatter', mode: 'lines', x: km.months, y: km.high, line: { width: 0, shape: 'hv' }, showlegend: false, hoverinfo: 'skip', legendgroup: 'km' },
|
||||||
{ type: 'scatter', mode: 'lines', x: km.months, y: km.low, fill: 'tonexty', fillcolor: COLORES_RECURRENCIA.banda, line: { width: 0, shape: 'hv' }, showlegend: false, hoverinfo: 'skip', legendgroup: 'km' },
|
{ type: 'scatter', mode: 'lines', x: km.months, y: km.low, fill: 'tonexty', fillcolor: COLORES_RECURRENCIA.banda, line: { width: 0, shape: 'hv' }, showlegend: false, hoverinfo: 'skip', legendgroup: 'km' },
|
||||||
|
|||||||
Reference in New Issue
Block a user