Skip to content
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,12 @@ export class TurnosSolicitudComponent implements OnInit {
return this._paciente;
}


cargarTurnos() {
const pacienteId = this._paciente?.id || (this._paciente as any)?._id;
if (pacienteId) {
this.serviceTurno.getHistorial({ pacienteId }).subscribe(turnos => {
const turnosFiltrados = turnos.filter(t => t.estado !== 'liberado' && moment(t.horaInicio).isSameOrAfter(this.todaysdate, 'day'));
this.serviceTurno.getTurnosFuturos({ pacienteId }).subscribe(turnos => {
const turnosFiltrados = turnos.filter(t => t.estado !== 'liberado' && moment(t.horaInicio).isSameOrAfter(moment(), 'day'));
this.turnosPaciente = turnosFiltrados.sort((a, b) => {
const inia = a.horaInicio ? new Date(a.horaInicio) : null;
const inib = b.horaInicio ? new Date(b.horaInicio) : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,9 @@ export class DarSobreturnoComponent implements OnChanges {

buscarTurnosFuturos() {
if (this.tipoPrestacion) {
this.serviceTurno.getHistorial({ pacienteId: this.idPaciente }).subscribe(turnos => {
// Filtrar los turnos que cumplen con la condición
const fechaHoy = moment();
this.serviceTurno.getTurnosFuturos({ pacienteId: this.idPaciente }).subscribe(turnos => {
this.turnosFuturos = turnos
.filter(turno => {
const fechaTurno = moment(turno.horaInicio);
const cumpleCondiciones =
turno.tipoPrestacion?._id === this.tipoPrestacion['_id'] &&
turno.estado === 'asignado' &&
fechaTurno.isAfter(fechaHoy);

return cumpleCondiciones;
})
.filter(turno => turno.tipoPrestacion?._id === this.tipoPrestacion['_id'])
.map(turno => (
{
horaInicio: turno.horaInicio,
Expand Down
14 changes: 2 additions & 12 deletions src/app/components/turnos/dar-turnos/dar-turnos.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -978,19 +978,9 @@ export class DarTurnosComponent implements OnInit {
*/
buscarTurnosFuturos() {
if (this.turnoTipoPrestacion) {
this.serviceTurno.getHistorial({ pacienteId: this.paciente.id }).subscribe(turnos => {
// Filtrar los turnos que cumplen con la condición
const fechaHoy = moment();
this.serviceTurno.getTurnosFuturos({ pacienteId: this.paciente.id }).subscribe(turnos => {
this.turnosFuturos = turnos
.filter(turno => {
const fechaTurno = moment(turno.horaInicio);
const cumpleCondiciones =
turno.tipoPrestacion?._id === this.turnoTipoPrestacion['_id'] &&
turno.estado === 'asignado' &&
fechaTurno.isAfter(fechaHoy);

return cumpleCondiciones;
})
.filter(turno => turno.tipoPrestacion?._id === this.turnoTipoPrestacion['_id'])
.map(turno => (
{
horaInicio: turno.horaInicio,
Expand Down
10 changes: 10 additions & 0 deletions src/app/services/turnos/turno.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Observable } from 'rxjs';
import * as moment from 'moment';
import { Injectable } from '@angular/core';
import { Server } from '@andes/shared';
import { IAgenda } from '../../interfaces/turnos/IAgenda';
Expand All @@ -21,6 +22,15 @@ export class TurnoService {
return this.server.get(this.turnoUrl + '/historial', { params: params, showError: true });
}

getTurnosFuturos(params: any): Observable<any[]> {
const query = {
...params,
estado: 'asignado',
desde: moment().startOf('day').toISOString()
};
return this.getHistorial(query);
}

/* Devuelve la agenda actualizada */
save(turno: any, options: any = {}): Observable<IAgenda> {
if (typeof options.showError === 'undefined') {
Expand Down
Loading