Skip to content

Commit 8d28c5a

Browse files
committed
feat(TOP): implementa resolucion de solicitudes
1 parent 381f832 commit 8d28c5a

5 files changed

Lines changed: 249 additions & 148 deletions

File tree

src/app/components/top/pipes/botones.pipe.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ export class BotonesSolicitudPipe implements PipeTransform {
2020
verHuds: false,
2121
devolverDeshacer: false,
2222
cancelar: false,
23-
comunicacionPaciente: false
23+
comunicacionPaciente: false,
24+
resolver: false,
25+
deshacerResolver: false
2426
};
2527
if (prestacion?.paciente) {
2628
if (prestacion.estadoActual.tipo === 'asignada') {
@@ -37,12 +39,18 @@ export class BotonesSolicitudPipe implements PipeTransform {
3739
if (prestacion.estadoActual.tipo === 'rechazada') {
3840
botones.referir = true;
3941
}
42+
if (prestacion.estadoActual.tipo === 'resuelta') {
43+
if (this.esEfectorDestino(prestacion)) {
44+
botones.deshacerResolver = true;
45+
}
46+
}
4047
if (!prestacion.solicitud.turno) {
4148
if (prestacion.estadoActual.tipo === 'pendiente') {
4249
if (this.esEfectorDestino(prestacion)) {
4350
botones.darTurno = true;
4451
botones.anular = true;
4552
botones.volverAuditoria = true;
53+
botones.resolver = true;
4654
}
4755
if (prestacion.solicitud.historial.length) {
4856
botones.comunicacionPaciente = true;
@@ -55,6 +63,7 @@ export class BotonesSolicitudPipe implements PipeTransform {
5563
if ((this.esEfectorDestino(prestacion) && prestacion.estadoActual.tipo === 'auditoria')) {
5664
botones.anular = true;
5765
botones.auditar = true;
66+
botones.resolver = true;
5867
}
5968
}
6069
}

src/app/components/top/pipes/estado-prestacion.pipe.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ export class EstadoPrestacionPipe implements PipeTransform {
1818
'turnoDado': 'success',
1919
'validada': 'success',
2020
'anulada': 'danger',
21-
'vencida': 'danger'
21+
'vencida': 'danger',
22+
'resuelta': 'success'
2223
};
2324

2425
return badge[prestacion.estadoActual.tipo];

src/app/components/top/pipes/estado-solicitud.pipe.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ export class EstadoSolicitudPipe implements PipeTransform {
3939
if (prestacion.estadoActual.tipo === 'rechazada') {
4040
return 'rechazada';
4141
}
42+
if (prestacion.estadoActual.tipo === 'resuelta') {
43+
return 'resuelta';
44+
}
4245

4346
}
4447
}

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

Lines changed: 63 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export class SolicitudesComponent implements OnInit {
3030
@HostBinding('class.plex-layout') layout = true;
3131
@ViewChild('modalDevolver', { static: true }) modalDevolver: PlexModalComponent;
3232
@ViewChild('modalIniciar', { static: true }) modalIniciar: PlexModalComponent;
33+
@ViewChild('modalResolver', { static: true }) modalResolver: PlexModalComponent;
3334
@ViewChild('helpIniciar', { static: false }) helpIniciar: PlexHelpComponent;
3435
@ViewChild('helpAnular', { static: false }) helpAnular: PlexHelpComponent;
3536
@ViewChild('helpCitar', { static: false }) helpCitar: PlexHelpComponent;
@@ -76,14 +77,22 @@ export class SolicitudesComponent implements OnInit {
7677
{ id: 'turnoDado', nombre: 'TURNO DADO' },
7778
{ id: 'registroHUDS', nombre: 'REGISTRO EN HUDS' },
7879
{ id: 'anulada', nombre: 'ANULADA' },
79-
{ id: 'vencida', nombre: 'VENCIDA' }
80+
{ id: 'vencida', nombre: 'VENCIDA' },
81+
{ id: 'resuelta', nombre: 'RESUELTA' }
8082
];
8183

8284
public prioridad;
8385
public prioridades = [
8486
{ id: 'prioritario', nombre: 'PRIORITARIO' },
8587
];
86-
prestacionSeleccionada: any;
88+
public prestacionSeleccionada: any;
89+
public motivosResolucion = [
90+
{ id: 'turno_en_efector', nombre: 'Con turno programado en el efector' },
91+
{ id: 'turno_otro_efector', nombre: 'Con turno programado en otro efector' },
92+
{ id: 'no_requiere', nombre: 'Ya no requiere turno' },
93+
{ id: 'fallecido', nombre: 'Paciente fallecido' }
94+
];
95+
public motivoResolucionSeleccionado: any;
8796
public showModalMotivo = false;
8897
public motivoVerContinuarPrestacion = 'Continuidad del cuidado del paciente';
8998
public routeToParams = [];
@@ -367,6 +376,50 @@ export class SolicitudesComponent implements OnInit {
367376
this.observacionesAnular = '';
368377
}
369378
}
379+
380+
onResolver() {
381+
if (this.prestacionSeleccionada.estados?.length && this.motivoResolucionSeleccionado) {
382+
const patch = {
383+
op: 'estadoPush',
384+
estado: {
385+
tipo: 'resuelta',
386+
observaciones: this.motivoResolucionSeleccionado.nombre
387+
}
388+
};
389+
this.servicioPrestacion.patch(this.prestacionSeleccionada.id, patch).subscribe(
390+
() => {
391+
this.cargarSolicitudes();
392+
this.plex.toast('success', 'Solicitud resuelta exitosamente');
393+
}
394+
);
395+
this.hideModal('resolver');
396+
this.closeSidebar();
397+
}
398+
}
399+
400+
onDeshacerResolver() {
401+
this.closeSidebar();
402+
let estadoPrevio = 'pendiente';
403+
if (this.prestacionSeleccionada.estados?.length > 1) {
404+
const prev = this.prestacionSeleccionada.estados[this.prestacionSeleccionada.estados.length - 2];
405+
estadoPrevio = prev.tipo;
406+
}
407+
408+
const patch = {
409+
op: 'estadoPush',
410+
estado: {
411+
tipo: estadoPrevio,
412+
observaciones: 'Reversión de estado resuelto'
413+
}
414+
};
415+
this.servicioPrestacion.patch(this.prestacionSeleccionada.id, patch).subscribe(
416+
() => {
417+
this.cargarSolicitudes();
418+
this.plex.toast('success', 'Se deshizo la resolución de la solicitud');
419+
}
420+
);
421+
}
422+
370423
citar() {
371424
if (this.prestacionSeleccionada.estados?.length) {
372425
const patch = {
@@ -437,7 +490,8 @@ export class SolicitudesComponent implements OnInit {
437490
'validada',
438491
'ejecucion',
439492
'asignada',
440-
'referir'
493+
'referir',
494+
'resuelta'
441495
]
442496
};
443497
if (this.tipoSolicitud === 'entrada') {
@@ -949,6 +1003,8 @@ export class SolicitudesComponent implements OnInit {
9491003
break;
9501004
case 'devolver': this.modalDevolver.showed = true;
9511005
break;
1006+
case 'resolver': this.modalResolver.showed = true;
1007+
break;
9521008
}
9531009
}
9541010

@@ -961,6 +1017,10 @@ export class SolicitudesComponent implements OnInit {
9611017
this.modalDevolver.showed = false;
9621018
this.motivoRespuesta = '';
9631019
break;
1020+
case 'resolver':
1021+
this.modalResolver.showed = false;
1022+
this.motivoResolucionSeleccionado = null;
1023+
break;
9641024
}
9651025
}
9661026

0 commit comments

Comments
 (0)