Skip to content

Commit a03751c

Browse files
semantic-release-botaldoEMatamala
authored andcommitted
chore(release): 5.170.2 [skip ci]
* **CIT:** bloques con turno con llave en calendario de top ([#3304](#3304)) ([c2b3fb9](c2b3fb9)) * **MPI:** cuil no requerido ([#3308](#3308)) ([585e26e](585e26e)) * **TOP-211:** Listado: Error de visualización datos del paciente ([#3296](#3296)) ([19e5ce7](19e5ce7))
1 parent fe18d9e commit a03751c

2 files changed

Lines changed: 40 additions & 19 deletions

File tree

src/app/apps/rup/mapa-camas/services/mapa-camas.http.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,14 @@ export class MapaCamasHTTP {
8585
}
8686

8787
// [TODO] ver interfaz e ID
88-
updateEstados(ambito: string, capa: string, fecha: Date, data): Observable<ICama> {
89-
const params = {
88+
updateEstados(ambito: string, capa: string, fecha: Date, data, options: any = {}): Observable<ICama> {
89+
const body = {
9090
...data,
9191
ambito: ambito,
9292
capa: capa,
9393
fecha
9494
};
95-
return this.server.patch(`${this.url}/camaEstados/${data._id}`, params);
95+
return this.server.patch(`${this.url}/camaEstados/${data._id}`, body, { params: options });
9696
}
9797

9898
deshacerInternacion(ambito: string, capa: string, idInternacion: string, completo: boolean): Observable<{ status: boolean }> {

src/app/apps/rup/mapa-camas/sidebar/ingreso/ingresar-paciente.component.ts

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Auth } from '@andes/auth';
22
import { Plex } from '@andes/plex';
33
import { Component, EventEmitter, OnDestroy, OnInit, Output, QueryList, ViewChildren } from '@angular/core';
4-
import { combineLatest, Observable, of, Subscription } from 'rxjs';
4+
import { combineLatest, forkJoin, Observable, of, Subscription } from 'rxjs';
55
import { auditTime, filter, map, switchMap, take } from 'rxjs/operators';
66
import { IPaciente } from 'src/app/core/mpi/interfaces/IPaciente';
77
import { ElementosRUPService } from 'src/app/modules/rup/services/elementosRUP.service';
@@ -25,6 +25,7 @@ import { cache } from '@andes/shared';
2525
import { IMaquinaEstados } from '../../interfaces/IMaquinaEstados';
2626
import { ListadoInternacionCapasService } from '../../views/listado-internacion-capas/listado-internacion-capas.service';
2727
import { IObraSocial } from 'src/app/interfaces/IObraSocial';
28+
import { MapaCamasHTTP } from '../../services/mapa-camas.http';
2829

2930
@Component({
3031
selector: 'app-ingresar-paciente',
@@ -94,6 +95,7 @@ export class IngresarPacienteComponent implements OnInit, OnDestroy {
9495
private subscription2: Subscription;
9596
public selectedOS = false;
9697
public financiador;
98+
public edicionFinanciador = false;
9799
public selectorFinanciadores: IObraSocial[] = [];
98100
public obrasSociales: IObraSocial[] = [];
99101
public OSPrivada = false;
@@ -107,6 +109,7 @@ export class IngresarPacienteComponent implements OnInit, OnDestroy {
107109
private organizacionService: OrganizacionService,
108110
private servicioPrestacion: PrestacionesService,
109111
public mapaCamasService: MapaCamasService,
112+
private camasHTTP: MapaCamasHTTP,
110113
private listadoInternacionService: ListadoInternacionService,
111114
private historialInternacionService: ListadoInternacionCapasService,
112115
private auth: Auth,
@@ -472,25 +475,39 @@ export class IngresarPacienteComponent implements OnInit, OnDestroy {
472475

473476
// Sincroniza las fechas editadas entre la cama y elresumen/prestacion
474477
private sincronizarCamaInternacion(idInternacion, fechaIngresoOriginal, fechaIngreso): Observable<IResumenInternacion> {
475-
return this.mapaCamasService.snapshot(this.fechaIngresoOriginal, idInternacion).pipe(
476-
switchMap(snapshot => {
477-
const primeraCama = snapshot[0];
478-
return this.mapaCamasService.changeTime(primeraCama, fechaIngresoOriginal, fechaIngreso, idInternacion);
479-
}),
478+
const obs$ = (fechaIngresoOriginal.getTime() !== fechaIngreso.getTime()) ?
479+
this.mapaCamasService.snapshot(this.fechaIngresoOriginal, idInternacion).pipe(
480+
switchMap(snapshot => {
481+
const primeraCama = snapshot[0];
482+
return this.mapaCamasService.changeTime(primeraCama, fechaIngresoOriginal, fechaIngreso, idInternacion);
483+
})
484+
) : of(this.cama);
485+
486+
return obs$.pipe(
480487
switchMap(cama => {
481-
if (!cama.id) {
488+
if (!cama?.id) {
482489
// algun error en changeTime
483490
throw new Error();
484491
}
485-
if (this.capa === 'estadistica') {
486-
return of(null);
487-
}
488492
this.cama = cama;
489-
// Prestacion creada por capa estadistica-v2. Puede estar siendo actualizada por medica/enfermeria
490-
return this.internacionResumenService.update(cama.idInternacion, {
491-
idPrestacion: this.prestacion?.id,
492-
fechaIngreso: this.informeIngreso.fechaIngreso
493-
});
493+
494+
const nextOps$: Observable<any>[] = [];
495+
if (this.capa === 'estadistica' && this.edicionFinanciador) {
496+
nextOps$.push(this.camasHTTP.updateEstados(this.mapaCamasService.ambito, this.capa, this.informeIngreso.fechaIngreso, this.cama, { edicionFinanciador: true }));
497+
}
498+
499+
if (this.capa !== 'estadistica') {
500+
// Prestacion creada por capa estadistica-v2. Puede estar siendo actualizada por medica/enfermeria
501+
nextOps$.push(this.internacionResumenService.update(cama.idInternacion, {
502+
idPrestacion: this.prestacion?.id,
503+
fechaIngreso: this.informeIngreso.fechaIngreso
504+
}));
505+
}
506+
507+
if (nextOps$.length > 0) {
508+
return forkJoin(nextOps$).pipe(map(() => cama));
509+
}
510+
return of(cama);
494511
})
495512
) as Observable<IResumenInternacion>;
496513
}
@@ -510,7 +527,10 @@ export class IngresarPacienteComponent implements OnInit, OnDestroy {
510527
if (this.prestacion && this.poseeMovimientos) {
511528
// Se actualiza fecha y hora en camas
512529
this.cama.idInternacion = idInternacion;
513-
if (this.informeIngreso.fechaIngreso.getTime() !== this.fechaIngresoOriginal.getTime()) {
530+
const fechaChange = this.informeIngreso.fechaIngreso.getTime() !== this.fechaIngresoOriginal.getTime();
531+
const financiadorChange = this.capa === 'estadistica' && this.edicionFinanciador;
532+
533+
if (fechaChange || financiadorChange) {
514534
// Recuperamos snapshot inicial, por si hay un cambio de cama
515535
this.sincronizarCamaInternacion(idInternacion, this.fechaIngresoOriginal, this.informeIngreso.fechaIngreso).subscribe(() => {
516536
this.plex.info('success', 'Los datos se actualizaron correctamente');
@@ -895,5 +915,6 @@ export class IngresarPacienteComponent implements OnInit, OnDestroy {
895915
financiador: financiadorSeleccionado.financiador
896916
};
897917
}
918+
this.edicionFinanciador = true;
898919
}
899920
}

0 commit comments

Comments
 (0)