Skip to content

Commit

Permalink
feat(mapa-camas): deshacer internacion si tiene ingreso solamente
Browse files Browse the repository at this point in the history
  • Loading branch information
GaboCancellieri authored and liquid36 committed Oct 15, 2020
1 parent 2eaeba2 commit 4ded35d
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 3 deletions.
10 changes: 10 additions & 0 deletions src/app/apps/rup/mapa-camas/services/mapa-camas.http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ export class MapaCamasHTTP {
}
}

deshacerInternacion(ambito: string, capa: string, fecha: Date, data): Observable<ISnapshot> {
const params = {
...data,
ambito: ambito,
capa: capa,
fecha,
};
return this.server.patch(`${this.url}/deshacer`, params);
}

changeTime(ambito: string, capa: string, cama, idInternacion, fechaOriginal, nuevaFecha) {
let params = {
ambito: ambito,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@
<ng-container *ngIf="(accionesEstado$ | async)?.length > 0">
<plex-button size="sm" type="info" (click)="onNuevoRegistrio()"> NUEVO REGISTRO </plex-button>
</ng-container>
<ng-container *ngIf="hayMovimientosAt$ | async as hayMovimientos">
<plex-button title="Deshacer Internacion" icon="account-off" type="danger" size="sm" (click)="deshacerInternacion(cama)">
</plex-button>
</ng-container>
</plex-title>
<fieldset>
<paciente-detalle [paciente]="paciente$ | async" orientacion="horizontal" [fields]="pacienteFields">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { Router } from '@angular/router';
import { ActivatedRoute, Router } from '@angular/router';
import { ElementosRUPService } from '../../../../../modules/rup/services/elementosRUP.service';
import { MapaCamasService } from '../../services/mapa-camas.service';
import { IPrestacion } from '../../../../../modules/rup/interfaces/prestacion.interface';
import { ISnapshot } from '../../interfaces/ISnapshot';
import { map, switchMap, pluck, filter } from 'rxjs/operators';
import { Observable } from 'rxjs';
import { combineLatest, Observable, of } from 'rxjs';
import { IMAQEstado, IMAQRelacion } from '../../interfaces/IMaquinaEstados';
import { Auth } from '@andes/auth';
import { notNull } from '@andes/shared';
import { cache, notNull } from '@andes/shared';
import { Plex } from '@andes/plex';
import { MapaCamasHTTP } from '../../services/mapa-camas.http';

Expand Down Expand Up @@ -53,15 +53,22 @@ export class CamaDetalleComponent implements OnInit {
public permisoIngreso = false;
canEdit = this.auth.check('internacion:cama:edit');
canMovimientos = this.auth.check('internacion:movimientos');
canUndo = false;
pacienteFields = ['sexo', 'fechaNacimiento', 'edad', 'cuil', 'financiador', 'numeroAfiliado', 'direccion', 'telefono'];
public nota: String;
public editNota = false;

public historial$: Observable<any[]>;
public fechaMin$: Observable<Date>;
public hayMovimientosAt$: Observable<Boolean>;
public camaSelectedSegunView$: Observable<ISnapshot> = this.mapaCamasService.camaSelectedSegunView$;

constructor(
private auth: Auth,
public plex: Plex,
private router: Router,
private mapaCamasService: MapaCamasService,
private mapaCamasHTTP: MapaCamasHTTP,
) {
}

Expand All @@ -83,6 +90,19 @@ export class CamaDetalleComponent implements OnInit {
pluck('acciones'),
map(acciones => acciones.filter(acc => acc.tipo === 'nuevo-registro'))
);

this.hayMovimientosAt$ = combineLatest(
this.camaSelectedSegunView$,
this.mapaCamasService.historialInternacion$,
).pipe(
map(([cama, historial]) => {
if (cama.extras && cama.extras.ingreso) {
return historial.length === 1 && historial[0].extras.ingreso;
} else {
return false;
}
})
);
}

sector(cama: ISnapshot) {
Expand Down Expand Up @@ -142,4 +162,18 @@ export class CamaDetalleComponent implements OnInit {
this.editNota = false;
});
}

deshacerInternacion(cama) {
this.plex.confirm('Esta acción deshace una internación, es decir, ya no figurará en el listado. ¡Esta acción no se puede revertir!', '¿Quiere deshacer esta internación?').then((resultado) => {
if (resultado) {
this.mapaCamasHTTP.deshacerInternacion(this.mapaCamasService.ambito, this.mapaCamasService.capa, cama.fecha, cama)
.subscribe((internacion) => {
this.plex.info('success', 'Se deshizo la internacion', 'Éxito');
this.mapaCamasService.select(null);
this.mapaCamasService.setFecha(this.mapaCamasService.fecha);
this.cancel.emit();
});
}
});
}
}

0 comments on commit 4ded35d

Please sign in to comment.