diff --git a/src/app/components/turnos/gestor-agendas/operaciones-agenda/suspender-agenda.component.ts b/src/app/components/turnos/gestor-agendas/operaciones-agenda/suspender-agenda.component.ts index f358de3add..ab6d2a408b 100644 --- a/src/app/components/turnos/gestor-agendas/operaciones-agenda/suspender-agenda.component.ts +++ b/src/app/components/turnos/gestor-agendas/operaciones-agenda/suspender-agenda.component.ts @@ -8,6 +8,7 @@ import { TurnoService } from './../../../../services/turnos/turno.service'; import { Auth } from '@andes/auth'; import { forkJoin } from 'rxjs'; import { PacienteService } from '../../../../core/mpi/services/paciente.service'; +import { ConstantesService } from './../../../../services/constantes.service'; @Component({ selector: 'suspender-agenda', @@ -24,11 +25,18 @@ export class SuspenderAgendaComponent implements OnInit { @Output() cerrarSidebar = new EventEmitter(); - constructor(public plex: Plex, public auth: Auth, public serviceAgenda: AgendaService, public smsService: SmsService, public turnosService: TurnoService, public pacienteService: PacienteService) { } + constructor( + public plex: Plex, + public auth: Auth, + public serviceAgenda: AgendaService, + public smsService: SmsService, + public turnosService: TurnoService, + public pacienteService: PacienteService, + public constantesService: ConstantesService) { } public mostrarHeaderCompleto = false; // Pongo false por defecto, estipo que arranca así. [Agregado para AOT] public motivoSuspensionSelect = { select: null }; - public motivoSuspension: { id: number; nombre: string }[]; + public motivoSuspension: Array<{ key: string; nombre: string }> = []; public estadosAgenda = EstadosAgenda; public ag; public showData = false; @@ -42,20 +50,10 @@ export class SuspenderAgendaComponent implements OnInit { */ public turnos = []; ngOnInit() { - this.motivoSuspension = [ - { - id: 1, - nombre: 'edilicia' - }, - { - id: 2, - nombre: 'profesional' - }, - { - id: 3, - nombre: 'organizacion' - }]; - this.motivoSuspensionSelect.select = this.motivoSuspension[1]; + this.constantesService.search({ source: 'citas:motivos:suspension' }).subscribe((constantes) => { + this.motivoSuspension = constantes; + this.motivoSuspensionSelect.select = this.motivoSuspension[1] || this.motivoSuspension[0] || null; + }); if (this.agenda.estado === 'suspendida') { let sinTelefono = []; this.agenda.bloques.forEach(bloque => { @@ -114,7 +112,7 @@ export class SuspenderAgendaComponent implements OnInit { suspenderAgenda() { this.showConfirmar = false; this.showData = true; - if (this.motivoSuspensionSelect.select.nombre === null) { + if (!this.motivoSuspensionSelect.select?.nombre) { return; } diff --git a/src/app/components/turnos/gestor-agendas/operaciones-agenda/suspender-agenda.html b/src/app/components/turnos/gestor-agendas/operaciones-agenda/suspender-agenda.html index 32ecb9dc74..9364fcf5e6 100644 --- a/src/app/components/turnos/gestor-agendas/operaciones-agenda/suspender-agenda.html +++ b/src/app/components/turnos/gestor-agendas/operaciones-agenda/suspender-agenda.html @@ -336,7 +336,8 @@
+ label="Motivos de Suspensión" placeholder="Seleccione un motivo de suspensión" [required]="true" + idField="key" labelField="nombre">
@@ -346,4 +347,4 @@
- \ No newline at end of file + diff --git a/src/app/components/turnos/gestor-agendas/operaciones-turnos/suspender-turno.component.ts b/src/app/components/turnos/gestor-agendas/operaciones-turnos/suspender-turno.component.ts index 64c79c9b0c..ce5444a709 100644 --- a/src/app/components/turnos/gestor-agendas/operaciones-turnos/suspender-turno.component.ts +++ b/src/app/components/turnos/gestor-agendas/operaciones-turnos/suspender-turno.component.ts @@ -8,6 +8,7 @@ import { TurnoService } from './../../../../services/turnos/turno.service'; import { SmsService } from './../../../../services/turnos/sms.service'; import { Auth } from '@andes/auth'; import { mergeMap } from 'rxjs/operators'; +import { ConstantesService } from './../../../../services/constantes.service'; @Component({ selector: 'suspender-turno', @@ -31,7 +32,7 @@ export class SuspenderTurnoComponent implements OnInit { public reasignar: any = {}; - public motivoSuspension: any[]; + public motivoSuspension: Array<{ key: string; nombre: string }> = []; public motivoSuspensionSelect = { select: null }; public seleccionadosSMS = []; public avisoSuspension = 'no enviado'; @@ -43,7 +44,8 @@ export class SuspenderTurnoComponent implements OnInit { public listaEsperaService: ListaEsperaService, public serviceAgenda: AgendaService, public smsService: SmsService, - public turnosService: TurnoService + public turnosService: TurnoService, + public constantesService: ConstantesService ) { } ngOnInit() { @@ -53,22 +55,10 @@ export class SuspenderTurnoComponent implements OnInit { } this.turnos = this.turnosSeleccionados; - - this.motivoSuspension = [ - { - id: 1, - nombre: 'edilicia' - }, { - id: 2, - nombre: 'profesional' - }, - { - id: 3, - nombre: 'organizacion' - } - ]; - - this.motivoSuspensionSelect.select = this.motivoSuspension[1]; + this.constantesService.search({ source: 'citas:motivos:suspension' }).subscribe((constantes) => { + this.motivoSuspension = constantes; + this.motivoSuspensionSelect.select = this.motivoSuspension[1] || this.motivoSuspension[0] || null; + }); } @@ -97,7 +87,7 @@ export class SuspenderTurnoComponent implements OnInit { suspenderTurno() { - if (this.motivoSuspensionSelect.select.nombre === null) { + if (!this.motivoSuspensionSelect.select?.nombre) { return; } diff --git a/src/app/components/turnos/gestor-agendas/operaciones-turnos/suspender-turno.html b/src/app/components/turnos/gestor-agendas/operaciones-turnos/suspender-turno.html index ac2a68d9ac..f642dcc751 100644 --- a/src/app/components/turnos/gestor-agendas/operaciones-turnos/suspender-turno.html +++ b/src/app/components/turnos/gestor-agendas/operaciones-turnos/suspender-turno.html @@ -38,7 +38,8 @@
+ label="Motivo de Suspensión" placeholder="Seleccione un motivo de suspensión" + idField="key" labelField="nombre">
@@ -49,4 +50,4 @@ - \ No newline at end of file + diff --git a/src/app/interfaces/turnos/ITurno.ts b/src/app/interfaces/turnos/ITurno.ts index 180f06498f..9f6ead09fe 100644 --- a/src/app/interfaces/turnos/ITurno.ts +++ b/src/app/interfaces/turnos/ITurno.ts @@ -47,10 +47,7 @@ export interface ITurno { nroCarpeta: string; }]; nota: string; - motivoSuspension: { - type: string; - enum: ['edilicia', 'profesional', 'organizacion', 'agendaSuspendida']; - }; + motivoSuspension: string; avisoSuspension: { type: string; enum: ['pendiente', 'no enviado', 'enviado', 'fallido'];