From 772442f7af03fb4e911f07670e8e20b79948b844 Mon Sep 17 00:00:00 2001 From: nicolasarana <90768149+nicolasarana@users.noreply.github.com> Date: Tue, 24 Feb 2026 14:23:48 -0300 Subject: [PATCH 1/3] feat(TOP-176):"Poder configurar vencimiento de solicitudes" --- .../solicitudes/detalleSolicitud.component.ts | 54 +++++++++++++------ .../top/solicitudes/detalleSolicitud.html | 3 ++ .../formNuevaSolicitud.component.ts | 5 ++ .../top/solicitudes/formNuevaSolicitud.html | 6 +++ src/app/interfaces/ITipoPrestacion.ts | 1 + 5 files changed, 53 insertions(+), 16 deletions(-) diff --git a/src/app/components/top/solicitudes/detalleSolicitud.component.ts b/src/app/components/top/solicitudes/detalleSolicitud.component.ts index 5e9d8e6c63..1f1e1b58d4 100644 --- a/src/app/components/top/solicitudes/detalleSolicitud.component.ts +++ b/src/app/components/top/solicitudes/detalleSolicitud.component.ts @@ -1,6 +1,7 @@ import { Input, Component, SimpleChanges, OnChanges, OnDestroy, Output, EventEmitter } from '@angular/core'; import { AdjuntosService } from '../../../modules/rup/services/adjuntos.service'; import { PacienteService } from 'src/app/core/mpi/services/paciente.service'; +import { ConceptosTurneablesService } from 'src/app/services/conceptos-turneables.service'; @Component({ selector: 'detalle-solicitud', @@ -20,6 +21,9 @@ export class DetalleSolicitudComponent implements OnChanges, OnDestroy { public internacion = null; public organizacionInternacion; + public tiempoVigencia: number; + public fechaVencimiento: Date; + public items = [ { key: 'solicitud', label: 'SOLICITUD' }, @@ -31,33 +35,51 @@ export class DetalleSolicitudComponent implements OnChanges, OnDestroy { constructor( public adjuntosService: AdjuntosService, - private pacienteService: PacienteService + private pacienteService: PacienteService, + private conceptosTurneablesService: ConceptosTurneablesService ) { } fotos: any[] = []; ngOnChanges(changes: SimpleChanges) { - if (changes.prestacionSeleccionada) { - this.adjuntosService.token$.subscribe((payload) => { - const { token } = payload; - const solicitudRegistros = this.prestacionSeleccionada.solicitud.registros; - const documentos = solicitudRegistros[0].valor.documentos || []; - this.fotos = documentos.map((doc) => { - return { - ...doc, - url: this.adjuntosService.createUrl('rup', doc, token) - }; - }); + if (!changes.prestacionSeleccionada || !this.prestacionSeleccionada) { + return; + } + + this.adjuntosService.token$.subscribe((payload) => { + const { token } = payload; + const solicitudRegistros = this.prestacionSeleccionada.solicitud.registros; + const documentos = solicitudRegistros?.[0]?.valor?.documentos || []; + this.fotos = documentos.map((doc) => { + return { + ...doc, + url: this.adjuntosService.createUrl('rup', doc, token) + }; }); - if (this.prestacionSeleccionada?.paciente?.id) { - this.pacienteService.getEstadoInternacion(this.prestacionSeleccionada.paciente.id).subscribe(resp => { + }); + + if (this.prestacionSeleccionada?.paciente?.id) { + this.pacienteService + .getEstadoInternacion(this.prestacionSeleccionada.paciente.id) + .subscribe(resp => { if (resp) { this.internacion = resp.estado; - this.organizacionInternacion = resp.organizacion ? resp.organizacion : 'Sin organización'; + this.organizacionInternacion = resp.organizacion ?? 'Sin organización'; } this.internacionPaciente.emit(this.internacion); }); - } + } + + const conceptId = this.prestacionSeleccionada?.solicitud?.tipoPrestacion?.conceptId; + if (conceptId) { + this.conceptosTurneablesService.search({ conceptId }).subscribe(conceptos => { + this.tiempoVigencia = conceptos?.[0]?.tiempoVigencia || 365; + const fechaSolicitud = new Date(this.prestacionSeleccionada.solicitud.fecha); + this.fechaVencimiento = new Date(fechaSolicitud); + this.fechaVencimiento.setDate( + this.fechaVencimiento.getDate() + this.tiempoVigencia + ); + }); } } diff --git a/src/app/components/top/solicitudes/detalleSolicitud.html b/src/app/components/top/solicitudes/detalleSolicitud.html index edae79dad1..370baa16c6 100644 --- a/src/app/components/top/solicitudes/detalleSolicitud.html +++ b/src/app/components/top/solicitudes/detalleSolicitud.html @@ -26,6 +26,9 @@ + + + diff --git a/src/app/components/top/solicitudes/formNuevaSolicitud.component.ts b/src/app/components/top/solicitudes/formNuevaSolicitud.component.ts index 67e07c4065..4f6fa1c36a 100644 --- a/src/app/components/top/solicitudes/formNuevaSolicitud.component.ts +++ b/src/app/components/top/solicitudes/formNuevaSolicitud.component.ts @@ -29,6 +29,7 @@ export class FormNuevaSolicitudComponent implements OnInit { fecha: any; arrayReglasDestino = []; autocitado = false; + tiempoVigenciaPrestacion: number = null; prestacionDestino: any; prestacionOrigen: any; // Adjuntar Archivo @@ -201,8 +202,12 @@ export class FormNuevaSolicitudComponent implements OnInit { this.dataOrganizacionesOrigen = []; this.modelo.solicitud.organizacionOrigen = null; this.dataTipoPrestacionesOrigen = []; + this.tiempoVigenciaPrestacion = null; if (this.modelo.solicitud && this.modelo.solicitud.tipoPrestacion) { + // Captura el tiempoVigencia del concepto seleccionado (365 días por defecto) + this.tiempoVigenciaPrestacion = this.modelo.solicitud.tipoPrestacion.tiempoVigencia || 365; + this.servicioReglas.get({ organizacionDestino: this.auth.organizacion.id, prestacionDestino: this.modelo.solicitud.tipoPrestacion.conceptId }) .subscribe( res => { diff --git a/src/app/components/top/solicitudes/formNuevaSolicitud.html b/src/app/components/top/solicitudes/formNuevaSolicitud.html index 81a3af6175..44d3fbe9e7 100644 --- a/src/app/components/top/solicitudes/formNuevaSolicitud.html +++ b/src/app/components/top/solicitudes/formNuevaSolicitud.html @@ -22,6 +22,12 @@ placeholder="Escriba al menos 3 letras" [required]="true" (change)="onSelectPrestacionOrigen()"> +
+ + +
+ ; queries?: String[]; auditable?: Boolean; + tiempoVigencia?: number; } From 48fcda0bf597831097ab329bd74cc6ebf8c66446 Mon Sep 17 00:00:00 2001 From: nicolasarana <90768149+nicolasarana@users.noreply.github.com> Date: Wed, 25 Feb 2026 13:01:08 -0300 Subject: [PATCH 2/3] feat(TOP-176):"Se agrega correciones en listado por vencimiento" --- .../solicitudes/detalleSolicitud.component.ts | 6 +++ .../top/solicitudes/detalleSolicitud.html | 4 +- .../top/solicitudes/formNuevaSolicitud.html | 3 +- .../top/solicitudes/solicitudes.component.ts | 51 +++++++++++++++++-- .../top/solicitudes/solicitudes.html | 11 ++-- 5 files changed, 65 insertions(+), 10 deletions(-) diff --git a/src/app/components/top/solicitudes/detalleSolicitud.component.ts b/src/app/components/top/solicitudes/detalleSolicitud.component.ts index 1f1e1b58d4..3ae166b9dc 100644 --- a/src/app/components/top/solicitudes/detalleSolicitud.component.ts +++ b/src/app/components/top/solicitudes/detalleSolicitud.component.ts @@ -24,6 +24,12 @@ export class DetalleSolicitudComponent implements OnChanges, OnDestroy { public tiempoVigencia: number; public fechaVencimiento: Date; + get estaVencida(): boolean { + if (!this.fechaVencimiento) { return false; } + const estadoTipo = this.prestacionSeleccionada?.estadoActual?.tipo; + if (estadoTipo === 'vencida' || estadoTipo === 'anulada' || estadoTipo === 'validada') { return false; } + return this.fechaVencimiento < new Date(); + } public items = [ { key: 'solicitud', label: 'SOLICITUD' }, diff --git a/src/app/components/top/solicitudes/detalleSolicitud.html b/src/app/components/top/solicitudes/detalleSolicitud.html index 370baa16c6..f88f7f03d1 100644 --- a/src/app/components/top/solicitudes/detalleSolicitud.html +++ b/src/app/components/top/solicitudes/detalleSolicitud.html @@ -27,7 +27,9 @@ subtitulo="{{prestacionSeleccionada.solicitud.organizacion?.nombre}}">
- + + hintType="warning" hintIcon="informacion" detach="top"> - { + conceptos.forEach(c => { + this.vigenciasMap[c.conceptId] = c.tiempoVigencia || 365; + }); + }); + if (!this.auth.getPermissions('solicitudes:?').length) { this.router.navigate([this.auth.profesional ? '/solicitudes/asignadas' : 'inicio']); } else if (this.auth.getPermissions('solicitudes:?').length === 1 && this.auth.getPermissions('solicitudes:reglas:?')[0] !== '*' && !this.auth.getPermissions('solicitudes:tipoPrestacion:?').length) { @@ -465,7 +475,12 @@ export class SolicitudesComponent implements OnInit { } else if (this.estadoEntrada.id === 'registroHUDS') { params['estados'] = ['validada']; } else { - params['estados'] = [this.estadoEntrada.id]; + if (this.estadoEntrada.id === 'vencida') { + // Traer pendiente+auditoria+vencida para filtrar client-side + params['estados'] = ['vencida', 'pendiente', 'auditoria']; + } else { + params['estados'] = [this.estadoEntrada.id]; + } if (this.estadoEntrada.id === 'pendiente') { params['tieneTurno'] = false; } @@ -511,7 +526,12 @@ export class SolicitudesComponent implements OnInit { } else if (this.estadoSalida.id === 'registroHUDS') { params['estados'] = ['validada']; } else { - params['estados'] = [this.estadoSalida.id]; + if (this.estadoSalida.id === 'vencida') { + // Traer pendiente+auditoria+vencida para filtrar client-side + params['estados'] = ['vencida', 'pendiente', 'auditoria']; + } else { + params['estados'] = [this.estadoSalida.id]; + } if (this.estadoSalida.id === 'pendiente') { params['tieneTurno'] = false; } @@ -566,8 +586,20 @@ export class SolicitudesComponent implements OnInit { @Unsubscribe() buscarSolicitudes() { + const estadoFiltro = this.tipoSolicitud === 'entrada' ? this.estadoEntrada?.id : this.estadoSalida?.id; return this.servicioPrestacion.getSolicitudes(this.getParams()) - .pipe(map((resultado) => resultado.filter((solicitud) => !this.esPacienteRestringido(solicitud.paciente)))) + .pipe( + map((resultado) => resultado.filter((solicitud) => !this.esPacienteRestringido(solicitud.paciente))), + map((resultado) => { + if (estadoFiltro === 'vencida') { + return resultado.filter(s => s.estadoActual.tipo === 'vencida' || this.estaVencidaEnListado(s)); + } + if (estadoFiltro) { + return resultado.filter(s => !this.estaVencidaEnListado(s)); + } + return resultado; + }) + ) .subscribe(resultado => { if (this.tipoSolicitud === 'entrada') { this.prestacionesEntrada = this.prestacionesEntrada.concat(resultado); @@ -759,6 +791,17 @@ export class SolicitudesComponent implements OnInit { } } + estaVencidaEnListado(prestacion: any): boolean { + if (!prestacion?.solicitud?.fecha) { return false; } + const estadoTipo = prestacion.estadoActual?.tipo; + if (estadoTipo === 'vencida' || estadoTipo === 'anulada' || estadoTipo === 'validada') { return false; } + const conceptId = prestacion.solicitud.tipoPrestacion?.conceptId; + const vigencia = this.vigenciasMap[conceptId] ?? 365; + const fechaVenc = new Date(prestacion.solicitud.fecha); + fechaVenc.setDate(fechaVenc.getDate() + vigencia); + return fechaVenc < new Date(); + } + onChange() { this.actualizacion = !this.actualizacion; this.loader = true; diff --git a/src/app/components/top/solicitudes/solicitudes.html b/src/app/components/top/solicitudes/solicitudes.html index 4100b83f7d..0cd6593bf7 100644 --- a/src/app/components/top/solicitudes/solicitudes.html +++ b/src/app/components/top/solicitudes/solicitudes.html @@ -158,7 +158,8 @@ AUTOCITADO - + VENCIDA + *ngIf="prestacion.estadoActual.tipo !== 'rechazada' && prestacion.estadoActual.tipo !== 'auditoria' && prestacion.estadoActual.tipo !== 'validada' && prestacion.estadoActual.tipo !== 'vencida' && !estaVencidaEnListado(prestacion)"> {{ prestacion | estadoSolicitud}} @@ -312,7 +313,11 @@ CONTRARREFERIDA - + VENCIDA + + {{prestacion.estadoActual.tipo}} From 6722d9a226f3cacfe83c0bb635fa9217a422b0b1 Mon Sep 17 00:00:00 2001 From: nicolasarana <90768149+nicolasarana@users.noreply.github.com> Date: Thu, 5 Mar 2026 09:57:30 -0300 Subject: [PATCH 3/3] feat(TOP):"Ahora las solicitudes vencidas solo se ven si se eligen en el filtro" --- src/app/components/top/solicitudes/solicitudes.component.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/app/components/top/solicitudes/solicitudes.component.ts b/src/app/components/top/solicitudes/solicitudes.component.ts index fb9bdb6fc6..43dca92e84 100644 --- a/src/app/components/top/solicitudes/solicitudes.component.ts +++ b/src/app/components/top/solicitudes/solicitudes.component.ts @@ -593,11 +593,9 @@ export class SolicitudesComponent implements OnInit { map((resultado) => { if (estadoFiltro === 'vencida') { return resultado.filter(s => s.estadoActual.tipo === 'vencida' || this.estaVencidaEnListado(s)); + } else { + return resultado.filter(s => s.estadoActual.tipo !== 'vencida' && !this.estaVencidaEnListado(s)); } - if (estadoFiltro) { - return resultado.filter(s => !this.estaVencidaEnListado(s)); - } - return resultado; }) ) .subscribe(resultado => {