3b246b4f1f
Rows name their patient with pac_id (a decimal string) or the legacy id_seudonimo. pac_id wins; an invalid pac_id is never replaced by the legacy field, and a page that repeats a patient or mixes both fields is not drawn or exported. The table, patient record, PDF and spreadsheet follow the announced identifier column and label. CaCu requests risk only with a pac_id.
58 lines
3.5 KiB
TypeScript
58 lines
3.5 KiB
TypeScript
import { AfterViewInit, Component, DestroyRef, ElementRef, inject, Input, OnDestroy, ViewChild, output } from '@angular/core';
|
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
import { MatButtonModule } from '@angular/material/button';
|
|
import { MatCardModule } from '@angular/material/card';
|
|
import { MatDialog, MatDialogModule, MatDialogRef } from '@angular/material/dialog';
|
|
import { MatIconModule } from '@angular/material/icon';
|
|
import { ETIQUETA_IDENTIDAD, IdentidadPaciente } from '../paciente-identidad';
|
|
import { PacienteDetalleEstado } from './paciente-detalle.models';
|
|
import { PacienteRegistroDialog } from './paciente-registro-dialog';
|
|
import { AltaRegistroTemporal, NuevoRegistroTemporal, RegistroTemporal, TipoRegistroTemporal } from './paciente-registro.models';
|
|
import { etiquetaRegistro, etiquetaResultado } from './paciente-registros-sesion';
|
|
import { PacienteRiesgoTabla } from './paciente-riesgo-tabla';
|
|
|
|
@Component({
|
|
selector: 'app-paciente-detalle',
|
|
imports: [MatButtonModule, MatCardModule, MatDialogModule, MatIconModule, PacienteRiesgoTabla],
|
|
templateUrl: './paciente-detalle.html',
|
|
styleUrl: './paciente-detalle.scss',
|
|
})
|
|
export class PacienteDetalleComponent implements AfterViewInit, OnDestroy {
|
|
@Input({ required: true }) estado: PacienteDetalleEstado = { tipo: 'cerrado' };
|
|
@Input() categorias: Record<string, { etiqueta: string }> = {};
|
|
@Input() registrosTemporales: readonly RegistroTemporal[] = [];
|
|
readonly volver = output<void>();
|
|
readonly registroAgregado = output<AltaRegistroTemporal>();
|
|
readonly etiquetaRegistro = etiquetaRegistro;
|
|
readonly etiquetaResultado = etiquetaResultado;
|
|
private readonly dialog = inject(MatDialog);
|
|
private readonly destroy = inject(DestroyRef);
|
|
private dialogoActivo?: MatDialogRef<PacienteRegistroDialog, NuevoRegistroTemporal>;
|
|
@ViewChild('titulo') private titulo?: ElementRef<HTMLElement>;
|
|
ngAfterViewInit() { this.titulo?.nativeElement.focus(); }
|
|
ngOnDestroy() { this.dialogoActivo?.close(); }
|
|
|
|
get etiquetaIdentidad() { return this.estado.tipo === 'cerrado' ? '' : ETIQUETA_IDENTIDAD[this.estado.resumen.identidad.campo]; }
|
|
/** The `pac_id` the risk is read by; a row with only the legacy `id_seudonimo` has none. */
|
|
get pacId() { return this.estado.tipo !== 'cerrado' && this.estado.resumen.identidad.campo === 'pac_id' ? this.estado.resumen.identidad.id : null; }
|
|
temporales(tipo: TipoRegistroTemporal) { return this.registrosTemporales.filter(item => item.tipo === tipo); }
|
|
|
|
abrirRegistro(tipo: TipoRegistroTemporal) {
|
|
if (this.estado.tipo === 'cerrado' || this.dialogoActivo) return;
|
|
const paciente = this.estado.resumen.identidad;
|
|
const ref = this.dialog.open<PacienteRegistroDialog, { tipo: TipoRegistroTemporal; paciente: IdentidadPaciente }, NuevoRegistroTemporal>(PacienteRegistroDialog, {
|
|
data: { tipo, paciente }, width: '34rem', maxWidth: 'calc(100vw - 2rem)', maxHeight: '90dvh',
|
|
autoFocus: 'first-tabbable', restoreFocus: true, disableClose: false,
|
|
});
|
|
this.dialogoActivo = ref;
|
|
ref.afterClosed().pipe(takeUntilDestroyed(this.destroy)).subscribe(registro => {
|
|
this.dialogoActivo = undefined;
|
|
if (registro) this.registroAgregado.emit({ paciente, registro });
|
|
});
|
|
}
|
|
etiquetaCitologia(resultado: string | null, calidad: string | null) {
|
|
if (resultado !== null) return this.categorias[resultado]?.etiqueta ?? resultado;
|
|
return calidad?.trim().toUpperCase() === 'INSATISFACTORIO' ? 'Insatisfactoria' : 'Sin resultado al corte';
|
|
}
|
|
}
|