diff --git a/src/app/components/top/solicitudes/detalleSolicitud.component.ts b/src/app/components/top/solicitudes/detalleSolicitud.component.ts
index 5e9d8e6c63..3ae166b9dc 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,15 @@ export class DetalleSolicitudComponent implements OnChanges, OnDestroy {
public internacion = null;
public organizacionInternacion;
+ 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' },
@@ -31,33 +41,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..f88f7f03d1 100644
--- a/src/app/components/top/solicitudes/detalleSolicitud.html
+++ b/src/app/components/top/solicitudes/detalleSolicitud.html
@@ -26,6 +26,11 @@
+
+
+
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..7c705460c4 100644
--- a/src/app/components/top/solicitudes/formNuevaSolicitud.html
+++ b/src/app/components/top/solicitudes/formNuevaSolicitud.html
@@ -22,6 +22,11 @@
placeholder="Escriba al menos 3 letras" [required]="true"
(change)="onSelectPrestacionOrigen()">
+
+
+
+
{
+ 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,18 @@ 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));
+ } else {
+ return resultado.filter(s => s.estadoActual.tipo !== 'vencida' && !this.estaVencidaEnListado(s));
+ }
+ })
+ )
.subscribe(resultado => {
if (this.tipoSolicitud === 'entrada') {
this.prestacionesEntrada = this.prestacionesEntrada.concat(resultado);
@@ -759,6 +789,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}}
diff --git a/src/app/interfaces/ITipoPrestacion.ts b/src/app/interfaces/ITipoPrestacion.ts
index 877b2e8f6b..80315d96e8 100644
--- a/src/app/interfaces/ITipoPrestacion.ts
+++ b/src/app/interfaces/ITipoPrestacion.ts
@@ -10,4 +10,5 @@ export interface ITipoPrestacion {
ambito?: Array;
queries?: String[];
auditable?: Boolean;
+ tiempoVigencia?: number;
}