Skip to content

Commit 83d5645

Browse files
committed
feat(TOP-176):"Se agrega correciones en listado por vencimiento"
1 parent 3ffa7e4 commit 83d5645

5 files changed

Lines changed: 70 additions & 10 deletions

File tree

src/app/components/top/solicitudes/detalleSolicitud.component.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ export class DetalleSolicitudComponent implements OnChanges, OnDestroy {
2222
public internacion = null;
2323
public organizacionInternacion;
2424
public tiempoVigencia: number;
25+
public fechaVencimiento: Date;
26+
27+
get estaVencida(): boolean {
28+
if (!this.fechaVencimiento) { return false; }
29+
const estadoTipo = this.prestacionSeleccionada?.estadoActual?.tipo;
30+
if (estadoTipo === 'vencida' || estadoTipo === 'anulada' || estadoTipo === 'validada') { return false; }
31+
return this.fechaVencimiento < new Date();
32+
}
2533

2634
public items = [
2735
{ key: 'solicitud', label: 'SOLICITUD' },
@@ -63,6 +71,9 @@ export class DetalleSolicitudComponent implements OnChanges, OnDestroy {
6371
const conceptId = this.prestacionSeleccionada.solicitud.tipoPrestacion.conceptId;
6472
this.conceptosTurneablesService.search({ conceptId }).subscribe(conceptos => {
6573
this.tiempoVigencia = conceptos?.[0]?.tiempoVigencia || 365;
74+
const fechaSolicitud = new Date(this.prestacionSeleccionada.solicitud.fecha);
75+
this.fechaVencimiento = new Date(fechaSolicitud);
76+
this.fechaVencimiento.setDate(this.fechaVencimiento.getDate() + this.tiempoVigencia);
6677
});
6778
}
6879

src/app/components/top/solicitudes/detalleSolicitud.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
subtitulo="{{prestacionSeleccionada.solicitud.organizacion?.nombre}}">
2828
</plex-label>
2929

30-
<plex-label titulo="Vencimiento" subtitulo="{{ tiempoVigencia }} días">
30+
<plex-label titulo="Vencimiento"
31+
[subtitulo]="estaVencida ? (fechaVencimiento | date: 'dd/MM/yyyy') : (fechaVencimiento | date: 'dd/MM/yyyy')"
32+
[type]="estaVencida ? 'danger' : ''">
3133
</plex-label>
3234
<plex-label *ngIf="prestacionSeleccionada.solicitud.profesional" titulo="Profesional de destino" subtitulo="{{ prestacionSeleccionada.solicitud.profesional?.nombre }} {{
3335
prestacionSeleccionada.solicitud.profesional?.apellido

src/app/components/top/solicitudes/formNuevaSolicitud.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@
2424
</plex-select>
2525
<div class="mr-4 mb-3" *ngIf="tiempoVigenciaPrestacion" justify="start">
2626
<span hint="Esta prestación tiene un tiempo de vigencia de {{tiempoVigenciaPrestacion}} días."
27-
hintType="warning" detach="top">
27+
hintType="warning" hintIcon="informacion" detach="top">
2828
</span>
2929
</div>
30-
3130
<plex-select *ngIf="!autocitado" [(ngModel)]="modelo.solicitud.organizacionOrigen" name="organizacionOrigen"
3231
[data]="dataOrganizacionesOrigen" label="Organización origen"
3332
placeholder="Seleccione la organización" labelField="nombre"

src/app/components/top/solicitudes/solicitudes.component.ts

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { TurnoService } from '../../../services/turnos/turno.service';
1818
import { ConstantesService } from 'src/app/services/constantes.service';
1919
import { SnomedService } from 'src/app/apps/mitos';
2020
import { ECLQueriesService } from 'src/app/services/eclqueries.service';
21+
import { ConceptosTurneablesService } from 'src/app/services/conceptos-turneables.service';
2122

2223

2324
@Component({
@@ -131,6 +132,7 @@ export class SolicitudesComponent implements OnInit {
131132
public check;
132133
public collapse = false;
133134
public loader = true;
135+
private vigenciasMap: { [conceptId: string]: number } = {};
134136
public columns = [
135137
{
136138
key: 'fecha',
@@ -178,13 +180,21 @@ export class SolicitudesComponent implements OnInit {
178180
public motivosHudsService: MotivosHudsService,
179181
public constantesService: ConstantesService,
180182
public snomedService: SnomedService,
181-
public eclqueriesServicies: ECLQueriesService
183+
public eclqueriesServicies: ECLQueriesService,
184+
private conceptosTurneablesService: ConceptosTurneablesService
182185
) {
183186
}
184187

185188
ngOnInit() {
186189
this.initFechas();
187190

191+
// Precarga el mapa de tiempoVigencia por conceptId (con caché)
192+
this.conceptosTurneablesService.getAll().subscribe((conceptos: any[]) => {
193+
conceptos.forEach(c => {
194+
this.vigenciasMap[c.conceptId] = c.tiempoVigencia || 365;
195+
});
196+
});
197+
188198
if (!this.auth.getPermissions('solicitudes:?').length) {
189199
this.router.navigate([this.auth.profesional ? '/solicitudes/asignadas' : 'inicio']);
190200
} else if (this.auth.getPermissions('solicitudes:?').length === 1 && this.auth.getPermissions('solicitudes:reglas:?')[0] !== '*' && !this.auth.getPermissions('solicitudes:tipoPrestacion:?').length) {
@@ -466,7 +476,12 @@ export class SolicitudesComponent implements OnInit {
466476
} else if (this.estadoEntrada.id === 'registroHUDS') {
467477
params['estados'] = ['validada'];
468478
} else {
469-
params['estados'] = [this.estadoEntrada.id];
479+
if (this.estadoEntrada.id === 'vencida') {
480+
// Traer pendiente+auditoria+vencida para filtrar client-side
481+
params['estados'] = ['vencida', 'pendiente', 'auditoria'];
482+
} else {
483+
params['estados'] = [this.estadoEntrada.id];
484+
}
470485
if (this.estadoEntrada.id === 'pendiente') {
471486
params['tieneTurno'] = false;
472487
}
@@ -512,7 +527,12 @@ export class SolicitudesComponent implements OnInit {
512527
} else if (this.estadoSalida.id === 'registroHUDS') {
513528
params['estados'] = ['validada'];
514529
} else {
515-
params['estados'] = [this.estadoSalida.id];
530+
if (this.estadoSalida.id === 'vencida') {
531+
// Traer pendiente+auditoria+vencida para filtrar client-side
532+
params['estados'] = ['vencida', 'pendiente', 'auditoria'];
533+
} else {
534+
params['estados'] = [this.estadoSalida.id];
535+
}
516536
if (this.estadoSalida.id === 'pendiente') {
517537
params['tieneTurno'] = false;
518538
}
@@ -567,8 +587,20 @@ export class SolicitudesComponent implements OnInit {
567587

568588
@Unsubscribe()
569589
buscarSolicitudes() {
590+
const estadoFiltro = this.tipoSolicitud === 'entrada' ? this.estadoEntrada?.id : this.estadoSalida?.id;
570591
return this.servicioPrestacion.getSolicitudes(this.getParams())
571-
.pipe(map((resultado) => resultado.filter((solicitud) => !this.esPacienteRestringido(solicitud.paciente))))
592+
.pipe(
593+
map((resultado) => resultado.filter((solicitud) => !this.esPacienteRestringido(solicitud.paciente))),
594+
map((resultado) => {
595+
if (estadoFiltro === 'vencida') {
596+
return resultado.filter(s => s.estadoActual.tipo === 'vencida' || this.estaVencidaEnListado(s));
597+
}
598+
if (estadoFiltro) {
599+
return resultado.filter(s => !this.estaVencidaEnListado(s));
600+
}
601+
return resultado;
602+
})
603+
)
572604
.subscribe(resultado => {
573605
if (this.tipoSolicitud === 'entrada') {
574606
this.prestacionesEntrada = this.prestacionesEntrada.concat(resultado);
@@ -760,6 +792,17 @@ export class SolicitudesComponent implements OnInit {
760792
}
761793
}
762794

795+
estaVencidaEnListado(prestacion: any): boolean {
796+
if (!prestacion?.solicitud?.fecha) { return false; }
797+
const estadoTipo = prestacion.estadoActual?.tipo;
798+
if (estadoTipo === 'vencida' || estadoTipo === 'anulada' || estadoTipo === 'validada') { return false; }
799+
const conceptId = prestacion.solicitud.tipoPrestacion?.conceptId;
800+
const vigencia = this.vigenciasMap[conceptId] ?? 365;
801+
const fechaVenc = new Date(prestacion.solicitud.fecha);
802+
fechaVenc.setDate(fechaVenc.getDate() + vigencia);
803+
return fechaVenc < new Date();
804+
}
805+
763806
onChange() {
764807
this.actualizacion = !this.actualizacion;
765808
this.loader = true;

src/app/components/top/solicitudes/solicitudes.html

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,16 @@
158158
<plex-badge *ngIf="prestacion.solicitud?.registros[0]?.valor?.solicitudPrestacion?.autocitado"
159159
type="danger">AUTOCITADO
160160
</plex-badge>
161-
<plex-badge *ngIf="prestacion.estadoActual.tipo === 'vencida'" type="danger">
161+
<plex-badge *ngIf="prestacion.estadoActual.tipo === 'vencida' || estaVencidaEnListado(prestacion)"
162+
type="danger">
162163
VENCIDA
163164
</plex-badge>
164165
<plex-badge type="danger"
165166
*ngIf="prestacion.solicitud.registros[0]?.valor.solicitudPrestacion.prioridad === 'prioritario'">
166167
{{prestacion.solicitud.registros[0].valor.solicitudPrestacion.prioridad}}
167168
</plex-badge>
168169
<plex-badge type="{{prestacion | estadoPrestacion}}"
169-
*ngIf="prestacion.estadoActual.tipo !== 'rechazada' && prestacion.estadoActual.tipo !== 'auditoria' && prestacion.estadoActual.tipo !== 'validada' && prestacion.estadoActual.tipo !== 'vencida'">
170+
*ngIf="prestacion.estadoActual.tipo !== 'rechazada' && prestacion.estadoActual.tipo !== 'auditoria' && prestacion.estadoActual.tipo !== 'validada' && prestacion.estadoActual.tipo !== 'vencida' && !estaVencidaEnListado(prestacion)">
170171
{{ prestacion | estadoSolicitud}}
171172

172173
</plex-badge>
@@ -312,7 +313,11 @@
312313
<plex-badge *ngIf="prestacion.estadoActual.tipo === 'rechazada'"
313314
type="{{prestacion | estadoPrestacion}}">
314315
CONTRARREFERIDA</plex-badge>
315-
<plex-badge *ngIf="prestacion.estadoActual.tipo !== 'rechazada' && !prestacion.solicitud.turno"
316+
<plex-badge *ngIf="prestacion.estadoActual.tipo === 'vencida' || estaVencidaEnListado(prestacion)"
317+
type="danger">
318+
VENCIDA
319+
</plex-badge>
320+
<plex-badge *ngIf="prestacion.estadoActual.tipo !== 'rechazada' && prestacion.estadoActual.tipo !== 'vencida' && !estaVencidaEnListado(prestacion) && !prestacion.solicitud.turno"
316321
type="{{prestacion | estadoPrestacion}}">
317322
{{prestacion.estadoActual.tipo}}
318323
</plex-badge>

0 commit comments

Comments
 (0)