Skip to content

Commit 68510e9

Browse files
committed
feat(TOP-209):"Turnos futuros al dar un turno( es en ventanilla citas)"
1 parent 8af86ec commit 68510e9

File tree

2 files changed

+68
-2
lines changed

2 files changed

+68
-2
lines changed

src/app/components/turnos/dar-turnos/dar-turnos.component.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export class DarTurnosComponent implements OnInit {
4444
public link: String = '';
4545
public changeCarpeta = false;
4646
public financiador;
47+
public todaysdate: Date;
4748
hideDarTurno: boolean;
4849
@HostBinding('class.plex-layout') layout = true; // Permite el uso de flex-box en el componente
4950
autocitado = false;
@@ -67,6 +68,10 @@ export class DarTurnosComponent implements OnInit {
6768
set demandaInsatisfecha(value: any) {
6869
this.desdeDemanda = value;
6970
}
71+
turnosPaciente: any;
72+
get paciente(): any {
73+
return this._paciente;
74+
}
7075

7176
@Input('solicitudPrestacion')
7277
set solicitudPrestacion(value: any) {
@@ -127,7 +132,7 @@ export class DarTurnosComponent implements OnInit {
127132
public organizacion = this.auth.organizacion;
128133
public _pacienteSeleccionado: any;
129134
public _solicitudPrestacion: any; // TODO: cambiar por IPrestacion cuando esté
130-
public paciente: IPaciente;
135+
public _paciente: IPaciente;
131136
public opciones: any = {};
132137
public agenda: IAgenda;
133138
public agendas: IAgenda[];
@@ -216,6 +221,8 @@ export class DarTurnosComponent implements OnInit {
216221
) { }
217222

218223
ngOnInit() {
224+
this.todaysdate = new Date();
225+
this.todaysdate.setHours(0, 0, 0, 0);
219226
this.hoy = new Date();
220227
this.autorizado = this.auth.getPermissions('turnos:darTurnos:?').length > 0;
221228
this.puedeDarSobreturno = this.auth.check('turnos:puntoInicio:darSobreturno');
@@ -251,11 +258,24 @@ export class DarTurnosComponent implements OnInit {
251258
this.actualizar();
252259
}
253260

261+
cargarTurnos() {
262+
if (this._paciente?.id) {
263+
this.serviceTurno.getHistorial({ pacienteId: this._paciente.id }).subscribe(turnos => {
264+
const turnosFiltrados = turnos.filter(t => t.estado !== 'liberado' && moment(t.horaInicio).isSameOrAfter(this.todaysdate, 'day'));
265+
this.turnosPaciente = turnosFiltrados.sort((a, b) => {
266+
const inia = a.horaInicio ? new Date(a.horaInicio) : null;
267+
const inib = b.horaInicio ? new Date(b.horaInicio) : null;
268+
return ((inia && inib) ? (inib.getTime() - inia.getTime()) : 0);
269+
});
270+
});
271+
}
272+
}
254273
actualizarDatosPaciente(paciente) {
255274
const idPaciente = paciente._id || paciente.id;
256275
this.servicePaciente.getById(idPaciente).subscribe(
257276
pacienteMPI => {
258-
this.paciente = pacienteMPI;
277+
this._paciente = pacienteMPI;
278+
this.cargarTurnos();
259279
this.verificarTelefono(pacienteMPI);
260280
this.obtenerCarpetaPaciente();
261281
if (this.paciente.documento) {

src/app/components/turnos/dar-turnos/dar-turnos.html

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,52 @@
7474
<paciente-detalle [paciente]="paciente" orientacion="horizontal" [fields]="pacienteFields">
7575
</paciente-detalle>
7676
</ng-container>
77+
<plex-title titulo="Turnos futuros" size="sm"></plex-title>
78+
<plex-list *ngIf="turnosPaciente?.length">
79+
<plex-item *ngFor="let turno of turnosPaciente">
80+
<plex-icon name="calendario" type="info" size="md"></plex-icon>
81+
<div>
82+
<plex-grid cols="3" size="md" type="auto">
83+
<plex-label size="md" [tituloBold]="true"
84+
titulo="{{ turno.horaInicio | date:'dd/MM/yyyy HH:mm' }}"
85+
subtitulo="{{ turno.tipoPrestacion?.term }}">
86+
</plex-label>
87+
88+
<div *ngIf="turno.profesionales?.length">
89+
<plex-label size="md" [tituloBold]="true" titulo="Equipo de Salud">
90+
</plex-label>
91+
<div *ngFor="let profesional of turno.profesionales" class="small">
92+
{{profesional | nombre}}
93+
</div>
94+
</div>
95+
<div *ngIf="!turno.profesionales?.length">
96+
<plex-label size="md" [tituloBold]="true" titulo="Equipo de Salud"
97+
subtitulo="Profesional no asignado">
98+
</plex-label>
99+
</div>
100+
101+
<plex-label size="md" [tituloBold]="true" titulo="Espacio Físico"
102+
subtitulo="{{ turno.espacioFisico?.nombre || turno.otroEspacioFisico?.nombre || 'No asignado' }}">
103+
</plex-label>
104+
105+
<plex-label size="md" [tituloBold]="true" titulo="Efector"
106+
subtitulo="{{ turno.organizacion?.nombre }}">
107+
</plex-label>
108+
109+
<div *ngIf="turno.paciente?.obraSocial">
110+
<plex-label size="md" [tituloBold]="true" titulo="Obra Social"
111+
subtitulo="{{ turno.paciente.obraSocial.nombre }}">
112+
</plex-label>
113+
</div>
114+
</plex-grid>
115+
</div>
116+
</plex-item>
117+
</plex-list>
118+
<div *ngIf="turnosPaciente && !turnosPaciente.length" justify="center" class="mt-4" style="margin-bottom: 2em;">
119+
<plex-label class="flex-column" icon="informacion" size="md" direction="column"
120+
titulo="No existen turnos futuros para este paciente">
121+
</plex-label>
122+
</div>
77123
<plex-title *ngIf="estadoT === 'noSeleccionada' && !_solicitudPrestacion?.solicitud"
78124
titulo="Búsquedas recientes" size="sm"></plex-title>
79125
<plex-list *ngIf="estadoT === 'noSeleccionada' && !_solicitudPrestacion?.solicitud" [selectable]="true">

0 commit comments

Comments
 (0)