Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

INTERNACION - Nuevo pase de UO configurable por maquina de estados #2074

Merged
merged 2 commits into from
Feb 9, 2021
Merged
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
5 changes: 4 additions & 1 deletion src/app/apps/rup/mapa-camas/interfaces/IMaquinaEstados.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ export interface IMaquinaEstados {
columns: MapaCamaListadoColumns;
ingresos: { [key: string]: string };
turnero: { [key: string]: string };

historialMedico?: boolean;
configPases: {
sala: string;
allowCama: boolean;
};
}

export interface IMAQEstado {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export class CamaDestinoGenericoComponent implements OnInit, OnDestroy {
guardar(form) {
if (form.formValid) {
if (this.selectedCama) {
this.selectedCama.extras = null;
if (this.selectedCama.estado === 'bloqueada') {
this.selectedCama.observaciones = '';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,38 @@
<ng-content></ng-content>
</plex-title>
<fieldset>
<ng-container *ngIf="camasDisponibles$ | async as camasDisponibles">
<plex-select [required]="true" [(ngModel)]="nuevaCama" name="cama"
[data]="(cambiarUO) ? camasDisponibles.camasDistintaUO : camasDisponibles.camasMismaUO"
placeholder="Elija cama" label="Cama" idField="id"
labelField="nombre + '(' + sectorName + ')'">
</plex-select>
<ng-container *ngIf="cambiarUO; else cambioNormal">
<ng-container *ngIf="paseConfig; else cambioNormal">
<plex-bool *ngIf="allowCama" label="¿Desea elegir cama destino?" [(ngModel)]="selectCama"
name="selectCama" type="slide" (click)="nuevaCama = null"></plex-bool>
<ng-container *ngIf="selectCama; else onlySala">
<ng-container *ngIf="camasParaPases$ | async as camasParaPases">
<ng-container *ngIf="camasParaPases.length > 0; else noHayCamas">
<plex-select [required]="true" [(ngModel)]="nuevaCama" name="cama" [data]="camasParaPases"
placeholder="Elija cama" label="Cama" idField="id"
labelField="nombre + '(' + sectorName + ')'">
</plex-select>
</ng-container>
<ng-template #noHayCamas>
<plex-label titulo="No hay camas disponibles."></plex-label>
</ng-template>
</ng-container>
</ng-container>
<ng-template #onlySala>
<ng-container *ngIf="salaPases$ | async as salaPases">
<plex-label size="lg" type="info" titulo="Destino" [subtitulo]="salaPases.nombre"></plex-label>
</ng-container>
</ng-template>
</ng-container>
</ng-container>
<ng-template #cambioNormal>
<ng-container *ngIf="camasDisponibles$ | async as camasDisponibles">
<plex-select [required]="true" [(ngModel)]="nuevaCama" name="cama"
[data]="(cambiarUO) ? camasDisponibles.camasDistintaUO : camasDisponibles.camasMismaUO"
placeholder="Elija cama" label="Cama" idField="id"
labelField="nombre + '(' + sectorName + ')'">
</plex-select>
</ng-container>
</ng-template>
</fieldset>
</form>
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import { Component, OnInit, Input, Output, EventEmitter, OnDestroy } from '@angu
import { Auth } from '@andes/auth';
import { MapaCamasService } from '../../services/mapa-camas.service';
import { Plex } from '@andes/plex';
import { Observable, combineLatest, Subscription, forkJoin } from 'rxjs';
import { Observable, combineLatest, Subscription, forkJoin, of } from 'rxjs';
import { ISnapshot } from '../../interfaces/ISnapshot';
import { switchMap, take } from 'rxjs/operators';
import { filter, map, switchMap, take } from 'rxjs/operators';
import { IMaquinaEstados } from '../../interfaces/IMaquinaEstados';

@Component({
selector: 'app-cambiar-cama',
Expand All @@ -27,6 +28,11 @@ export class CambiarCamaComponent implements OnInit, OnDestroy {
public disableButton = false;

public camaSelectedSegunView$: Observable<ISnapshot> = this.mapaCamasService.camaSelectedSegunView$;
public salaPases$: Observable<any>;
public camasParaPases$: Observable<ISnapshot[]>;
public paseConfig = false;
public allowCama = false;
public selectCama = false;

constructor(
public auth: Auth,
Expand All @@ -35,26 +41,60 @@ export class CambiarCamaComponent implements OnInit, OnDestroy {
) { }

ngOnDestroy() {

}

ngOnInit() {
this.camasDisponibles$ = this.camaSelectedSegunView$.pipe(
switchMap(cama => this.mapaCamasService.getCamasDisponibles(cama))
);
combineLatest([
this.mapaCamasService.maquinaDeEstado$,
this.camaSelectedSegunView$
]).pipe(take(1)).subscribe(([maquinaEstados, camaActual]) => {
this.camasDisponibles$ = this.camaSelectedSegunView$.pipe(
switchMap(cama => this.mapaCamasService.getCamasDisponibles(cama))
);

this.salaPases$ = of({});

if (maquinaEstados.configPases && maquinaEstados.configPases.allowCama) {
this.allowCama = true;
}

if (maquinaEstados.configPases && maquinaEstados.configPases.sala) {
if (maquinaEstados.configPases.sala !== camaActual.id) {
this.paseConfig = true;
this.salaPases$ = this.camasDisponibles$.pipe(
map(cama => {
const sala = cama.camasDistintaUO.filter((c: ISnapshot) => c.sala && c.id === maquinaEstados.configPases.sala)[0];
return sala;
})
);

this.camasParaPases$ = combineLatest([
this.camasDisponibles$,
this.salaPases$,
]).pipe(
map(([camasDisp, sala]) => {
return camasDisp.camasDistintaUO.filter((c: ISnapshot) => c.id !== sala.id);
})
);
}
}

});
}

guardar(valid) {
if (valid.formValid) {
this.disableButton = true;
combineLatest(
this.mapaCamasService.fecha2,
this.camaSelectedSegunView$
this.camaSelectedSegunView$,
this.salaPases$,
).pipe(
take(1),
switchMap(([fechaCambio, camaActual]) => {
switchMap(([fechaCambio, camaActual, salaPases]) => {
this.fecha = fechaCambio;
return this.cambiarCama(camaActual, this.nuevaCama, fechaCambio);
const proximaCama = this.nuevaCama || salaPases;
return this.cambiarCama(camaActual, proximaCama, fechaCambio);
})
).subscribe(
() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@
<plex-bool label="Documento" [(ngModel)]="columns.documento" (change)="toggleColumns()">
</plex-bool>
<plex-bool label="Sexo" [(ngModel)]="columns.sexo" (change)="toggleColumns()"></plex-bool>
<plex-bool label="Prioridad" [(ngModel)]="columns.prioridad" (change)="toggleColumns()">
<plex-bool *ngIf="(ambito$ | async) === 'guardia'" label="Prioridad"
[(ngModel)]="columns.prioridad" (change)="toggleColumns()">
</plex-bool>
<plex-bool label="Guardia" [(ngModel)]="columns.guardia" (change)="toggleColumns()">
<plex-bool *ngIf="(ambito$ | async) === 'guardia'" label="Guardia" [(ngModel)]="columns.guardia"
(change)="toggleColumns()">
</plex-bool>
</plex-grid>
</plex-dropdown>
Expand Down