Skip to content

Commit

Permalink
feat(CIT): chequea turnos antes de asignar demanda
Browse files Browse the repository at this point in the history
  • Loading branch information
ma7payne committed Nov 26, 2024
1 parent 3383479 commit e0c86cb
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ export class DemandaInsatisfechaComponent implements OnInit {
idAgenda: datosTurno.idAgenda,
};
};

this.listaEsperaService.patch(this.itemSelected.id, 'estado', data).subscribe(() => {
this.plex.toast('success', 'Demanda cerrada exitosamente');
this.actualizarFiltros({ value: '' }, '');
Expand Down
60 changes: 59 additions & 1 deletion src/app/components/turnos/dashboard/demandaInsatisfecha.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,62 @@
</plex-select>
<plex-select label="Motivo" [(ngModel)]="motivo" [required]="true" [data]="motivos" name="motivos"
placeholder="Seleccione motivo"></plex-select>
</form>
</form>

<plex-modal size="sm" #modalSolicitudes [allowEscClose]="true" [allowBackdropClose]="false">
<plex-icon name="check-circle" type="success"></plex-icon>
<plex-modal-subtitle class="font-title text-center" type="success" size="sm"><b>¡Demanda insatisfecha guardada
exitosamente!</b></plex-modal-subtitle>
<main>
<div class="modal-contents">
<p class="text-center">
Existen solicitudes asociadas a la prestación:
</p>
<ng-container *ngFor="let registro of solicitudesAsociadas">
<small>
Fecha de solicitud: {{ registro.solicitud.fecha | fecha }} {{ registro.solicitud.fecha | hora }}
</small>
<div class="content-row">
<plex-label size="sm" style="width: 100%;" color="#0070cc" icon="mano-corazon"
titulo="Tipos de solicitud"
subtitulo="{{ registro.solicitud.tipoPrestacion.term }}"></plex-label>

<plex-label size="sm" style="width: 100%;" color="#0070cc" icon="hospital"
titulo="Organización destino"
subtitulo="{{ registro.solicitud.organizacion.nombre }}"></plex-label>
</div>
</ng-container>
</div>
</main>
<plex-button modal center type="success" (click)="cerrar()">
ACEPTAR
</plex-button>
</plex-modal>

<plex-modal size="sm" #modalTurno [allowEscClose]="true" [allowBackdropClose]="false">
<plex-icon name="check-circle" type="warning"></plex-icon>
<plex-modal-subtitle class="font-title text-center" type="warning"
size="sm"><b>Información</b></plex-modal-subtitle>
<main>
<div class="modal-contents">
<p class="text-center">
Existe un turno pendiente para la prestacíon seleccionada:
</p>
<div *ngIf="turnoAsociado">
<p class="text-center"><b>{{turnoAsociado?.dia}}</b> a las <b>{{turnoAsociado?.horario}}</b> hs.</p>
<div class="text-center" *ngIf="turnoAsociado.profesionales.length">
<p>Profesionales: <br>
{{turnoAsociado?.profesionales}}</p>
</div>
<div class="text-center" *ngIf="!turnoAsociado.profesionales.length">
<p>
- Sin profesionales asignados -
</p>
</div>
</div>
</div>
</main>
<plex-button modal center type="warning" (click)="modalTurno.close()">
ACEPTAR
</plex-button>
</plex-modal>
16 changes: 16 additions & 0 deletions src/app/components/turnos/dashboard/demandaInsatisfecha.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
main {
min-height: auto !important;
}

.modal-contents {
.content-row:last-child {
border-bottom: none;
}
}

.content-row {
display: flex;
align-items: center;
margin-bottom: 10px;
border-bottom: 1px solid #999;
}
30 changes: 25 additions & 5 deletions src/app/components/turnos/dashboard/demandaInsatisfecha.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Auth } from '@andes/auth';
import { Plex } from '@andes/plex';
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { PlexModalComponent } from '@andes/plex/src/lib/modal/modal.component';
import { Component, EventEmitter, Input, Output, ViewChild } from '@angular/core';
import { IPaciente } from 'src/app/core/mpi/interfaces/IPaciente';
import { ConceptosTurneablesService } from 'src/app/services/conceptos-turneables.service';
import { ListaEsperaService } from 'src/app/services/turnos/listaEspera.service';
Expand All @@ -9,6 +10,7 @@ import { ProfesionalService } from './../../../services/profesional.service';
@Component({
selector: 'demandaInsatisfecha',
templateUrl: 'demandaInsatisfecha.html',
styleUrls: ['demandaInsatisfecha.scss']
})

export class demandaInsatisfechaComponent {
Expand All @@ -17,6 +19,8 @@ export class demandaInsatisfechaComponent {
@Input() origen = 'citas';
@Input() estado = 'pendiente';
@Output() demandaCerrada = new EventEmitter<any>();
@ViewChild('modalSolicitudes', { static: true }) modalSolicitudes: PlexModalComponent;
@ViewChild('modalTurno', { static: true }) modalTurno: PlexModalComponent;

tipoPrestacion: any;
permisos = [];
Expand All @@ -28,6 +32,8 @@ export class demandaInsatisfechaComponent {
];
motivo: any;
organizacion = this.auth.organizacion;
solicitudesAsociadas;
turnoAsociado;

constructor(
public auth: Auth,
Expand All @@ -54,9 +60,23 @@ export class demandaInsatisfechaComponent {
guardar() {
if (this.motivo && this.tipoPrestacion) {
this.listaEsperaService.save({ id: this.paciente.id }, this.tipoPrestacion, this.estado, this.profesional, this.organizacion, this.motivo.nombre, this.origen).subscribe({
complete: () => {
this.plex.toast('success', 'Demanda insatisfecha guardada exitosamente!');
this.cerrar();
next: ({ status, data }) => {
if (status === 'existeTurno') {
const dia = moment(data.horaInicio).format('LL');
const horario = moment(data.horaInicio).format('HH:mm');
const profesionales = data.profesionales?.map(prof => ` ${prof.nombre} ${prof.apellido}`);

this.turnoAsociado = { dia, horario, profesionales };
this.modalTurno.show();
} else {
if (data.solicitudes.length) {
this.solicitudesAsociadas = data.solicitudes;
this.modalSolicitudes.show();
} else {
this.plex.toast('success', 'Demanda insatisfecha guardada exitosamente!');
this.cerrar();
}
}
},
error: (e) => this.plex.toast('danger', e.message, 'Ha ocurrido un error al guardar')
});
Expand All @@ -65,6 +85,6 @@ export class demandaInsatisfechaComponent {

cerrar() {
this.demandaCerrada.emit();
this.modalSolicitudes.close();
}

}
2 changes: 1 addition & 1 deletion src/app/services/turnos/listaEspera.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class ListaEsperaService {
return this.server.get(this.listaEsperaUrl, { params: params, showError: true });
}

post(listaEspera: IListaEspera): Observable<IListaEspera> {
post(listaEspera: IListaEspera): Observable<any> {
return this.server.post(this.listaEsperaUrl, listaEspera);
}

Expand Down

0 comments on commit e0c86cb

Please sign in to comment.