Merge dashboard-test: the CaMa dashboard's presentation over the FHIR measures, with TEA's history and summary kept
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { afterNextRender, ChangeDetectorRef, Component, DestroyRef, inject, Injector, Input, OnChanges, output } from '@angular/core';
|
||||
import { afterNextRender, ChangeDetectorRef, Component, DestroyRef, inject, Injector, Input, OnChanges, output, signal } from '@angular/core';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { HttpErrorResponse } from '@angular/common/http';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
@@ -7,15 +7,17 @@ import { CacuSeguimientoService, validSeguimientoQuery } from './cacu-seguimient
|
||||
import { latestStudy, SeguimientoPaciente, SeguimientoQuery, SeguimientoResponse, SeguimientoStatus } from './cacu-seguimiento.models';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { PacienteDetalleComponent } from './paciente-detalle/paciente-detalle';
|
||||
import { IndicadoresSeguimientoTabla, SeleccionSeguimiento } from './indicadores-seguimiento-tabla';
|
||||
import { PacienteDetalleState } from './paciente-detalle/paciente-detalle.state';
|
||||
import { Dominio } from './indicadores.models';
|
||||
import { ETIQUETA_IDENTIDAD, IdentidadPaciente, identidadDe } from './paciente-identidad';
|
||||
import { IndicadoresService } from './indicadores.service';
|
||||
import { ALTERACIONES_EEG, ESTADOS_CASO, GRUPOS_EDAD_TEA, RANGOS_CSS, RANGOS_MCHAT, 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, PacienteDetalleComponent, TeaPacienteResumen, IndicadoresSeguimientoTabla],
|
||||
providers: [PacienteDetalleState],
|
||||
templateUrl: './indicadores-tracking.html',
|
||||
styleUrl: './indicadores-tracking.scss',
|
||||
@@ -24,6 +26,10 @@ export class IndicadoresTracking implements OnChanges {
|
||||
@Input({ required: true }) domainLabel = '';
|
||||
@Input() dominio: Dominio = 'tea';
|
||||
@Input() active = false;
|
||||
/** CaMa: the patients of a curve or a cell of the analysis, for its follow-up list. */
|
||||
@Input() seleccion?: SeleccionSeguimiento;
|
||||
/** CaMa: the way back to the analysis the selection came from. */
|
||||
readonly volverAlAnalisis = output<void>();
|
||||
private readonly service = inject(CacuSeguimientoService);
|
||||
private readonly indicators = inject(IndicadoresService);
|
||||
private readonly teaService = inject(TeaSeguimientoService);
|
||||
@@ -32,6 +38,9 @@ export class IndicadoresTracking implements OnChanges {
|
||||
private readonly injector = inject(Injector);
|
||||
readonly pacienteDetalle = inject(PacienteDetalleState);
|
||||
readonly fichaPacienteAbierta = output<boolean>();
|
||||
/** CaMa's record opens inside its own table; this hides the section title while it does. */
|
||||
readonly camaFichaAbierta = signal(false);
|
||||
cambiaFichaCama(abierta: boolean) { this.camaFichaAbierta.set(abierta); this.fichaPacienteAbierta.emit(abierta); }
|
||||
private controlPaciente?: HTMLElement;
|
||||
private readonly requests = new Subject<SeguimientoQuery | null>();
|
||||
private readonly teaRequests = new Subject<SeguimientoQuery | null>();
|
||||
@@ -96,7 +105,9 @@ export class IndicadoresTracking implements OnChanges {
|
||||
}
|
||||
ngOnChanges() {
|
||||
if (this.previousDomain !== this.dominio) {
|
||||
if (this.pacienteDetalle.estado().tipo !== 'cerrado') this.fichaPacienteAbierta.emit(false);
|
||||
// Changing domain removes the table that holds CaMa's record, so the page is told here that no record shows.
|
||||
if (this.pacienteDetalle.estado().tipo !== 'cerrado' || this.camaFichaAbierta()) this.fichaPacienteAbierta.emit(false);
|
||||
this.camaFichaAbierta.set(false);
|
||||
this.pacienteDetalle.cerrar(); this.controlPaciente = 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 };
|
||||
@@ -116,6 +127,10 @@ export class IndicadoresTracking implements OnChanges {
|
||||
if (!this.response || page < 1 || page > this.response.paginacion.total_pages) return;
|
||||
this.load({ ...this.applied, page });
|
||||
}
|
||||
// Every row of a shown answer has an identity: the answer is validated before it reaches the view.
|
||||
identidad(paciente: SeguimientoPaciente): IdentidadPaciente { return identidadDe(paciente)!; }
|
||||
// The rows of a page identify their patient by one field; an empty page keeps the legacy wording.
|
||||
etiquetaIdentidad(respuesta: SeguimientoResponse) { return ETIQUETA_IDENTIDAD[respuesta.items[0] ? this.identidad(respuesta.items[0]).campo : 'id_seudonimo']; }
|
||||
abrirPaciente(paciente: SeguimientoPaciente, evento: Event) {
|
||||
if (this.dominio !== 'cacu' || this.status !== 'ready' || !this.data?.items.includes(paciente)) return;
|
||||
evento.stopPropagation();
|
||||
|
||||
Reference in New Issue
Block a user