Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 36 additions & 16 deletions src/app/components/top/solicitudes/solicitudes.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Unsubscribe } from '@andes/shared';
import { Location } from '@angular/common';
import { Component, ElementRef, HostBinding, Input, OnInit, ViewChild } from '@angular/core';
import { Router } from '@angular/router';
import { catchError, concatWith, map, switchMap } from 'rxjs';
import { catchError, concatWith, map, switchMap, from, filter, NEVER } from 'rxjs';
import { PacienteService } from 'src/app/core/mpi/services/paciente.service';
import { IMotivoAcceso } from 'src/app/modules/rup/interfaces/IMotivoAcceso';
import { PacienteRestringidoPipe } from 'src/app/pipes/pacienteRestringido.pipe';
Expand Down Expand Up @@ -812,21 +812,41 @@ export class SolicitudesComponent implements OnInit {
}

volverAuditoria() {
this.plex.confirm('¿Realmente quiere volver al estado Auditoría?', 'Atención').then(confirmar => {
if (confirmar) {
const cambioEstado: any = {
op: 'estadoPush',
estado: { tipo: 'auditoria', observaciones: 'La solicitud pasó a estado Auditoría' }
};
this.servicioPrestacion.patch(this.prestacionSeleccionada.id, cambioEstado).subscribe({
complete: () => {
this.plex.toast('info', 'Prestación nuevamente en Auditoría');
this.cargarSolicitudes();
},
error: () => this.plex.toast('danger', 'ERROR: No es posible cambiar el estado de la prestación')
});
}
});
this.servicioPrestacion.getById(this.prestacionSeleccionada._id)
.pipe(
switchMap(prestacion => {
const tieneTurnoInvalido =
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me hace ruido el nombre, el turno se dió correctamente. Lo dejaría como "tieneTurno"

prestacion.solicitud.turno &&
prestacion.estadoActual.tipo !== 'validada' &&
prestacion.estadoActual.tipo !== 'ejecucion';

if (tieneTurnoInvalido) {
this.plex.info(
'warning',
'La solicitud ya tiene un turno asignado.'
).then(() => {
window.location.reload();
});
return NEVER;
}
return from(this.plex.confirm('¿Realmente quiere volver al estado Auditoría?', 'Atención'));
}),
filter(confirmar => confirmar === true),
switchMap(() => {
const cambioEstado: any = {
op: 'estadoPush',
estado: { tipo: 'auditoria', observaciones: 'La solicitud pasó a estado Auditoría' }
};
return this.servicioPrestacion.patch(this.prestacionSeleccionada.id, cambioEstado);
})
)
.subscribe({
complete: () => {
this.plex.toast('info', 'Prestación nuevamente en Auditoría');
this.cargarSolicitudes();
},
error: () => this.plex.toast('danger', 'ERROR: No es posible cambiar el estado de la prestación')
});
}

onDarTurno() {
Expand Down