feat(tea): ficha propia para la mitad de los pacientes de Seguimiento

Los pacientes con número impar abren su propia ventana, como la ficha de
cáncer cervicouterino (con «Regresar» y un resumen arriba); los pares
conservan el resumen desplegable en la fila. El encabezado de la ficha ya
nombra el dominio en lugar de decir siempre cáncer cervicouterino.
This commit is contained in:
2026-11-03 19:58:30 +00:00
parent b74f188b15
commit 1771cb7ec6
9 changed files with 116 additions and 28 deletions
@@ -6,16 +6,17 @@ import { catchError, defer, map, of, Subject, switchMap } from 'rxjs';
import { CacuSeguimientoService, validSeguimientoQuery } from './cacu-seguimiento.service';
import { latestStudy, SeguimientoPaciente, SeguimientoQuery, SeguimientoResponse, SeguimientoStatus } from './cacu-seguimiento.models';
import { MatButtonModule } from '@angular/material/button';
import { MatIconModule } from '@angular/material/icon';
import { PacienteDetalleComponent } from './paciente-detalle/paciente-detalle';
import { PacienteDetalleState } from './paciente-detalle/paciente-detalle.state';
import { Dominio } from './indicadores.models';
import { IndicadoresService } from './indicadores.service';
import { ALTERACIONES_EEG, TeaSeguimientoResponse, TeaSeguimientoService } from './tea-seguimiento.service';
import { ALTERACIONES_EEG, TeaSeguimientoPaciente, TeaSeguimientoResponse, TeaSeguimientoService } from './tea-seguimiento.service';
import { TeaPacienteResumen } from './tea-paciente-resumen';
@Component({
selector: 'app-indicadores-tracking',
imports: [FormsModule, MatButtonModule, PacienteDetalleComponent, TeaPacienteResumen],
imports: [FormsModule, MatButtonModule, MatIconModule, PacienteDetalleComponent, TeaPacienteResumen],
providers: [PacienteDetalleState],
templateUrl: './indicadores-tracking.html',
styleUrl: './indicadores-tracking.scss',
@@ -43,6 +44,8 @@ export class IndicadoresTracking implements OnChanges {
teaData?: TeaSeguimientoResponse;
// One open summary at a time, like an accordion.
teaAbierto?: string;
// Patient shown in its own window, like CaCu's patient page.
teaFicha?: TeaSeguimientoPaciente;
statuses: SeguimientoStatus[] = [];
private metadataLoaded = false;
categories: Record<string, { etiqueta: string; color?: string | null }> = {};
@@ -89,7 +92,8 @@ export class IndicadoresTracking implements OnChanges {
ngOnChanges() {
if (this.previousDomain !== this.dominio) {
if (this.pacienteDetalle.estado().tipo !== 'cerrado') this.fichaPacienteAbierta.emit(false);
this.pacienteDetalle.cerrar(); this.controlPaciente = undefined;
if (this.teaFicha) this.fichaPacienteAbierta.emit(false);
this.pacienteDetalle.cerrar(); this.controlPaciente = undefined; this.teaFicha = undefined;
this.previousDomain = this.dominio; this.requests.next(null); this.teaRequests.next(null); this.data = undefined; this.teaData = undefined;
this.status = 'idle'; this.statuses = []; this.initialized = false; this.draft = { meses: 3, page: 1, page_size: 50 }; this.applied = { ...this.draft };
}
@@ -127,6 +131,25 @@ export class IndicadoresTracking implements OnChanges {
if (evento.currentTarget instanceof HTMLTableRowElement && evento.target instanceof HTMLElement && evento.target.closest('button, a, input, select, textarea')) return;
this.teaAbierto = this.teaAbierto === id ? undefined : id;
}
// Mock: to show both ideas side by side, odd-numbered patients open their own window and
// even-numbered ones expand in place.
teaVentana(item: TeaSeguimientoPaciente) { return Number(item.id_seudonimo.replace(/\D/g, '')) % 2 === 1; }
abrirTea(item: TeaSeguimientoPaciente, evento: Event) {
evento.stopPropagation();
if (!this.teaVentana(item)) { this.alternarTea(item.id_seudonimo, evento); return; }
if (evento.currentTarget instanceof HTMLTableRowElement && evento.target instanceof HTMLElement
&& evento.target.closest('button, a, input, select, textarea')) return;
this.controlPaciente = evento.currentTarget instanceof HTMLElement ? evento.currentTarget : undefined;
this.teaAbierto = undefined; this.teaFicha = item;
this.fichaPacienteAbierta.emit(true);
afterNextRender(() => document.getElementById('tea-ficha-titulo')?.focus(), { injector: this.injector });
}
cerrarTea() {
this.teaFicha = undefined;
this.fichaPacienteAbierta.emit(false);
const control = this.controlPaciente;
afterNextRender(() => { if (control?.isConnected) control.focus({ preventScroll: true }); }, { injector: this.injector });
}
volverASeguimiento() {
this.pacienteDetalle.cerrar();
this.fichaPacienteAbierta.emit(false);