@@ -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