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 - Agrega componente de integridad de camas #1746

Merged
merged 1 commit into from
Oct 21, 2020
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
8 changes: 8 additions & 0 deletions src/app/apps/rup/mapa-camas/interfaces/IInconsistencia.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { ISnomedConcept } from '../../../../modules/rup/interfaces/snomed-concept.interface';
import { ISnapshot } from './ISnapshot';

export interface IInconsistencia {
_id: string;
source: ISnapshot;
target: ISnapshot;
}
10 changes: 10 additions & 0 deletions src/app/apps/rup/mapa-camas/mapa-camas.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ import { SalaComunComponent } from './views/sala-comun/sala-comun.component';
import { SalaComunService } from './views/sala-comun/sala-comun.service';
import { NgDragDropModule } from 'ng-drag-drop';
import { RUPLibModule } from '../../../modules/rup/rup-lib.module';
import { IntegridadCamasComponent } from './views/integridad/integridad-camas.component';
import { ItemInconsistenciaComponent } from './views/integridad/item-inconsistencia/item-inconsistencia.component';
import { IntegridadService } from './views/integridad/integridad.service';
import { DetalleIntegridadComponent } from './views/integridad/detalle/detalle-integridad.component';
import { FiltrosInconsistenciasComponent } from './views/integridad/filtros-inconsistencia/filtros-inconsistencias.component';

export const INTERNACION_COMPONENTS = [
MapaCamasMainComponent,
Expand Down Expand Up @@ -80,6 +85,10 @@ export const INTERNACION_COMPONENTS = [
RegistroHUDSItemComponent,
IngresoPacienteWorkflowComponent,
SalaComunComponent,
IntegridadCamasComponent,
ItemInconsistenciaComponent,
DetalleIntegridadComponent,
FiltrosInconsistenciasComponent,
];

export const INTERNACION_PROVIDERS = [
Expand All @@ -88,6 +97,7 @@ export const INTERNACION_PROVIDERS = [
ListadoInternacionService,
SalaComunService,
ScrollDispatcher,
IntegridadService
];

@NgModule({
Expand Down
1 change: 1 addition & 0 deletions src/app/apps/rup/mapa-camas/mapa-camas.routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { CensosMensualesComponent } from './views/censos/censo-mensual/censo-men
import { InternacionListadoComponent } from './views/listado-internacion/listado-internacion.component';
import { InternacionListaEsperaComponent } from './views/lista-espera/lista-espera.component';
import { SalaComunComponent } from './views/sala-comun/sala-comun.component';
import { IntegridadCamasComponent } from './views/integridad/integridad-camas.component';

export const INTERNACION_ROUTES = [
{ path: 'mapa-camas', component: MapaCamasMainComponent },
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<plex-tabs size="full" [activeIndex]="tabIndex" (change)="cambiarTab($event)" *ngIf="inconsistencia$ | async as inconsistencia">
<plex-tab label="ORIGEN">
<ng-container *ngIf="!accion">
<plex-title titulo="DETALLE DE ORIGEN">
<plex-button title="Volver" icon="arrow-left" type="info" size="sm" (click)="cancelar()">
</plex-button>
</plex-title>
<fieldset>
<plex-detail size="lg" direction="row">
<div title>
{{ inconsistencia.source.nombre }}
</div>
<plex-badge *ngIf="inconsistencia.source.estado === 'ocupada'" type="warning">Ocupada</plex-badge>
<plex-badge *ngIf="inconsistencia.source.estado === 'disponible'" type="success">Disponible</plex-badge>
<plex-badge *ngIf="inconsistencia.source.estado === 'bloqueada'" type="secondary">Bloqueada</plex-badge>
<plex-badge *ngIf="inconsistencia.source.estado === 'inactiva'" type="danger">Inactiva</plex-badge>
<plex-badge type="info">
{{ inconsistencia.source.fecha | fecha}}
</plex-badge>
</plex-detail>
<ng-container *ngIf="inconsistencia.source.estado === 'ocupada'">
<plex-button label="Resolver Inconsistencia" type="warning" size="block" (click)="accionar('desocuparCama')"></plex-button>
</ng-container>
<plex-title size="sm" justify titulo="DATOS DE PACIENTE"></plex-title>
<ng-container *ngIf="inconsistencia.source.paciente">
<paciente-detalle [paciente]="inconsistencia.source.paciente" orientacion="horizontal">
</paciente-detalle>
</ng-container>
</fieldset>
</ng-container>
<ng-container *ngIf="accion === 'desocuparCama'">
<app-desocupar-cama (cancel)="accionar(null)"
(accionDesocupar)="accionDesocupar($event)">
<plex-button title="Volver" icon="arrow-left" type="danger" size="sm" (click)="accionar(null)">
</plex-button>
</app-desocupar-cama>
</ng-container>
<ng-container *ngIf="accion === 'cambiarCama'">
<app-cambiar-cama cambiarUO="{{ cambiarUO }}" (onSave)="refresh()">
<plex-button title="Volver" icon="arrow-left" type="danger" size="sm" (click)="accionar('desocuparCama')">
</plex-button>
</app-cambiar-cama>
</ng-container>
<ng-container *ngIf="accion === 'egresarPaciente'">
<app-egresar-paciente (onSave)="refresh()"
(cancel)="accionar(null)">
<plex-button title="Volver" icon="arrow-left" type="danger" size="sm" (click)="accionar('desocuparCama')">
</plex-button>
</app-egresar-paciente>
</ng-container>
</plex-tab>
<plex-tab label="DESTINO">
<plex-title titulo="DETALLE DE DESTINO">
<plex-button title="Volver" icon="arrow-left" type="info" size="sm" (click)="cancelar()">
</plex-button>
</plex-title>
<fieldset>
<plex-detail size="lg" direction="row">
<plex-badge *ngIf="inconsistencia.target.estado === 'ocupada'" type="warning">Ocupada</plex-badge>
<plex-badge *ngIf="inconsistencia.target.estado === 'disponible'" type="success">Disponible</plex-badge>
<plex-badge *ngIf="inconsistencia.target.estado === 'bloqueada'" type="secondary">Bloqueada</plex-badge>
<plex-badge *ngIf="inconsistencia.target.estado === 'inactiva'" type="danger">Inactiva</plex-badge>
<plex-badge type="info">
{{ inconsistencia.target.fecha | fecha}}
</plex-badge>
<div title>
{{ inconsistencia.target.nombre }}
</div>
</plex-detail>
<plex-title size="sm" justify titulo="DATOS DE PACIENTE"></plex-title>
<ng-container *ngIf="inconsistencia.target.paciente">
<paciente-detalle [paciente]="inconsistencia.target.paciente" orientacion="horizontal">
</paciente-detalle>
</ng-container>
</fieldset>
</plex-tab>
</plex-tabs>
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { Component, OnInit, Output, EventEmitter } from '@angular/core';
import { Observable } from 'rxjs';
import { IInconsistencia } from '../../../interfaces/IInconsistencia';
import { IntegridadService } from '../integridad.service';
import { ISnapshot } from '../../../interfaces/ISnapshot';


@Component({
selector: 'app-detalle-integridad',
templateUrl: 'detalle-integridad.component.html'
})
export class DetalleIntegridadComponent implements OnInit {

// EVENTOS
@Output() cancel = new EventEmitter<any>();

// VARIABLES
public inconsistencia$: Observable<IInconsistencia>;
public accion = null;
public tabIndex = 0;
public cambiarUO = false;

constructor(
private integridadService: IntegridadService
) {
}

ngOnInit() {
this.inconsistencia$ = this.integridadService.selectedInconsistencia;
}

refresh() {
this.accion = null;
this.integridadService.setAmbito('internacion');
this.cancel.emit();
}

sector(cama: ISnapshot) {
return cama.sectores[cama.sectores.length - 1].nombre;
}

cancelar() {
this.cancel.emit();
}

cambiarTab(index) {
this.tabIndex = index;
}

accionar(accion: string) {
this.accion = accion;
}

accionDesocupar(accion) {
if (!accion.egresar) {
this.cambiarUO = accion.cambiarUO;
this.accion = 'cambiarCama';
} else {
this.accion = accion.egresar;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<plex-wrapper>
<plex-datetime type="date" [(ngModel)]="filtros.fechaOrigenDesde" name='fechaOrigenDesde' label="Origen desde"
(change)="filtrar()" [max]="filtros.fechaOrigenHasta" [debounce]="600">
</plex-datetime>
<plex-datetime type="date" [(ngModel)]="filtros.fechaOrigenHasta" name='fechaOrigenHasta' label="Origen hasta"
(change)="filtrar()" [min]="filtros.fechaOrigenDesde" [debounce]="600">
</plex-datetime>
<plex-datetime type="date" [(ngModel)]="filtros.fechaDestinoDesde" name='fechaDestinoDesde' label="Destino desde"
(change)="filtrar()" [max]="filtros.fechaDestinoHasta" [debounce]="600">
</plex-datetime>
<plex-datetime type="date" [(ngModel)]="filtros.fechaDestinoHasta" name='fechaDestinoHasta' label="Destino hasta"
(change)="filtrar()" [min]="filtros.fechaDestinoDesde" [debounce]="600">
</plex-datetime>
<plex-select label="Sector" [(ngModel)]="filtros.sector" idField="nombre" labelField="nombre"
[data]="sectorList$ | async" (change)="filtrar()">
</plex-select>
<plex-select label="Cama" [(ngModel)]="filtros.cama" idField="nombre" labelField="nombre"
[data]="camaList$ | async" (change)="filtrar()">
</plex-select>
</plex-wrapper>
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { MapaCamasService } from '../../../services/mapa-camas.service';
import { Observable } from 'rxjs';
import { map, tap } from 'rxjs/operators';
import { IntegridadService } from '../integridad.service';

function arrayToSet(array, key, itemFn) {
const listado = [];
array.forEach(elem => {
const item = itemFn(elem);
if (Array.isArray(item)) {
item.forEach(inside => {
const index = listado.findIndex(i => i[key] === inside[key]);
if (index < 0) {
listado.push(inside);
}
});
} else {
const index = listado.findIndex(i => i[key] === item[key]);
if (index < 0) {
listado.push(item);
}
}
});
return listado;
}

@Component({
selector: 'app-filtros-inconsistencias',
templateUrl: './filtros-inconsistencias.component.html',
})

export class FiltrosInconsistenciasComponent implements OnInit {

public sectorList$: Observable<any[]>;
public camaList$: Observable<any[]>;

filtros: any = {};
censables = [
{ id: 0, nombre: 'No censable' },
{ id: 1, nombre: 'Censable' }
];

constructor(
public integridadService: IntegridadService
) { }

ngOnInit() {
this.sectorList$ = this.integridadService.listaInconsistencias$.pipe(
map((inconsistencias) => arrayToSet(inconsistencias, 'nombre', (item) => item.source.sectores))
);

this.camaList$ = this.integridadService.listaInconsistencias$.pipe(
map((inconsistencias) => arrayToSet(inconsistencias, 'nombre', (item) => item.source))
);
this.clearFiltros();
}

private clearFiltros() {
this.integridadService.fechaOrigenDesde.next(null);
this.integridadService.fechaOrigenHasta.next(null);
this.integridadService.fechaDestinoDesde.next(null);
this.integridadService.fechaDestinoHasta.next(null);
this.integridadService.sectorSelected.next(null);
this.integridadService.camaSelected.next(null);
}

filtrar() {
this.integridadService.fechaOrigenDesde.next(this.filtros.fechaOrigenDesde);
this.integridadService.fechaOrigenHasta.next(this.filtros.fechaOrigenHasta);
this.integridadService.fechaDestinoDesde.next(this.filtros.fechaDestinoDesde);
this.integridadService.fechaDestinoHasta.next(this.filtros.fechaDestinoHasta);
this.integridadService.sectorSelected.next(this.filtros.sector);
this.integridadService.camaSelected.next(this.filtros.cama);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<plex-layout main="{{ (accion === 'verDetalle') ? 8 : 12 }}">
<plex-layout-main>
<header>
<plex-title titulo="LISTADO DE INCONSISTENCIAS" size="sm"></plex-title>
<app-filtros-inconsistencias></app-filtros-inconsistencias>
</header>
<fieldset>
<table class="table table-striped table-hover">
<thead>
<tr>
<th>CAMA</th>
<th>ORIGEN</th>
<th>DESTINO</th>
</tr>
</thead>
<tbody>
<ng-container *ngIf="(selectedInconsistencia$ | async) as selectedInconsistencia">
<tr app-item-inconsistencia
*ngFor="let item of listaInconsistencias$ | async" [inconsistencia]="item"
(click)="selectInconsistencia(item, selectedInconsistencia)" [class.invert]="item._id === selectedInconsistencia._id">
</tr>
</ng-container>
</tbody>
</table>
</fieldset>
</plex-layout-main>
<plex-layout-sidebar type="invert" *ngIf='accion'>
<app-detalle-integridad (cancel)="unselectInconsistencia()">
</app-detalle-integridad>
</plex-layout-sidebar>
</plex-layout>
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { Auth } from '@andes/auth';
import { Plex } from '@andes/plex';
import { Observable, Subject } from 'rxjs';
import { IntegridadService } from './integridad.service';
import { IInconsistencia } from '../../interfaces/IInconsistencia';
import { MapaCamasService } from '../../services/mapa-camas.service';
import * as moment from 'moment';

@Component({
selector: 'app-integridad-camas',
templateUrl: 'integridad-camas.component.html',
styleUrls: ['../mapa-camas-capa/mapa-camas-capa.component.scss']
})

export class IntegridadCamasComponent implements OnInit {
public lista = new Subject();
public listaInconsistencias$: Observable<any[]>;

public ambito = 'internacion';
public capa: string;
public selectedInconsistencia$: Observable<IInconsistencia>;

public accion = null;
constructor(
public auth: Auth,
private router: Router,
private plex: Plex,
private integridadService: IntegridadService,
private mapaCamasService: MapaCamasService,
) { }

ngOnInit() {
this.plex.updateTitle([{
route: '/inicio',
name: 'Andes'
}, {
route: '/internacion/mapa-camas',
name: 'Internacion'
}, {
name: 'Integridad'
}]);

const capaArr = this.auth.getPermissions('internacion:rol:?');
if (capaArr.length === 1) {
this.capa = capaArr[0];
this.integridadService.setAmbito(this.ambito);
this.integridadService.setCapa(this.capa);
this.listaInconsistencias$ = this.integridadService.listaInconsistenciasFiltrada$;
} else {
this.router.navigate(['/inicio']);
}

this.selectedInconsistencia$ = this.integridadService.selectedInconsistencia;
this.mapaCamasService.setView('mapa-camas');
this.mapaCamasService.setAmbito('internacion');
this.mapaCamasService.setCapa('estadistica');
}

selectInconsistencia(inconsistencia, selectedInconsistencia) {
if (!selectedInconsistencia.source._id || selectedInconsistencia.source.idCama !== inconsistencia.source.idCama) {
this.mapaCamasService.select(inconsistencia.source);
this.mapaCamasService.setFecha(moment(inconsistencia.target.fecha).subtract(1, 'hour').toDate());
this.integridadService.select(inconsistencia);
this.accion = 'verDetalle';
} else {
this.accion = null;
this.integridadService.select(null);
}
}

unselectInconsistencia() {
this.accion = null;
this.integridadService.select(null);
}
}
Loading