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

ORGANIZACIONES - Deshabilitar boton de eliminar UO que esta en uso en una cama #1770

Merged
merged 2 commits into from
Aug 27, 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
2 changes: 0 additions & 2 deletions src/app/apps/rup/mapa-camas/mapa-camas.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import { InternacionListadoComponent } from './views/listado-internacion/listado
import { InternacionListaEsperaComponent } from './views/lista-espera/lista-espera.component';

import { MapaCamasService } from './services/mapa-camas.service';
import { MapaCamasHTTP } from './services/mapa-camas.http';
import { MitosModule } from '../../mitos';
import { OrganizacionLibModule } from '../../../components/organizacion/organizacion-lib.module';
import { ElegirPacienteComponent } from './sidebar/ingreso/elegir-paciente.component';
Expand Down Expand Up @@ -79,7 +78,6 @@ export const INTERNACION_COMPONENTS = [

export const INTERNACION_PROVIDERS = [
MapaCamasService,
MapaCamasHTTP,
MaquinaEstadosHTTP,
ListadoInternacionService
];
Expand Down
8 changes: 4 additions & 4 deletions src/app/apps/rup/mapa-camas/services/mapa-camas.http.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Injectable } from '@angular/core';
import { Server } from '@andes/shared';
import { Observable, throwError } from 'rxjs';
import { Observable } from 'rxjs';
import { ISnapshot } from '../interfaces/ISnapshot';
import { ICama } from '../interfaces/ICama';
import { IMaquinaEstados } from '../interfaces/IMaquinaEstados';
import { map } from 'rxjs/operators';

export type IFiltrosHistorial = any;

@Injectable()
@Injectable({
providedIn: 'root',
})
export class MapaCamasHTTP {
private url = '/modules/rup/internacion';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import { IContacto } from './../../interfaces/IContacto';
import { IOrganizacion } from './../../interfaces/IOrganizacion';
import { ITipoEstablecimiento } from './../../interfaces/ITipoEstablecimiento';
import { Router } from '@angular/router';
import { MapaCamasHTTP } from '../../apps/rup/mapa-camas/services/mapa-camas.http';
import { ISnapshot } from '../../apps/rup/mapa-camas/interfaces/ISnapshot';
import { Observable, Subject, of } from 'rxjs';
import { switchMap, startWith } from 'rxjs/operators';
import { cache } from '@andes/shared';
Expand Down Expand Up @@ -130,6 +132,9 @@ export class OrganizacionCreateUpdateComponent implements OnInit {
public puedeEditarCompleto = false;
public puedeEditarBasico = false;
public botonGuardarDisabled = false;

public camas: ISnapshot[];

constructor(
private organizacionService: OrganizacionService,
private paisService: PaisService,
Expand All @@ -139,13 +144,18 @@ export class OrganizacionCreateUpdateComponent implements OnInit {
public plex: Plex,
public snomed: SnomedService,
private auth: Auth,
private router: Router
private router: Router,
public mapaCamasService: MapaCamasHTTP,
) { }

ngOnInit() {
this.puedeEditarBasico = this.auth.check('tm:organizacion:editBasico');
this.puedeEditarCompleto = this.auth.check('tm:organizacion:editCompleto');

this.mapaCamasService.snapshot('internacion', 'medica', moment().toDate()).subscribe((snapshot) => {
this.camas = snapshot.filter(s => s.estado !== 'inactiva');
});

if ((this.seleccion && this.seleccion.id && !(this.puedeEditarBasico || this.puedeEditarCompleto)) ||
(!this.seleccion && !this.auth.check('tm:organizacion:create'))) {
this.router.navigate(['inicio']);
Expand Down Expand Up @@ -415,6 +425,15 @@ export class OrganizacionCreateUpdateComponent implements OnInit {
});
}

// Verifica si la Unidad Organizativa está siendo utilizada en alguna cama de internación
checkUnidadOrganizativaCama(unidadOrganizativa) {
if (this.camas) {
const aux = this.camas.filter(cama => cama.unidadOrganizativa.conceptId === unidadOrganizativa.conceptId);
return (aux.length > 0);
}
return false;
}

/**
* Setea las coordenadas de la organización a la ubicación donde se soltó el marcador en el mapa
* @param {*} event
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@
<span *ngIf="unidadOrganizativa?.term">{{unidadOrganizativa.term}}</span>
</div>
<plex-button icon="delete" type="danger" (click)="deleteUO(unidadOrganizativa)"
*ngIf="puedeEditarCompleto">
*ngIf="puedeEditarCompleto" [disabled]="checkUnidadOrganizativaCama(unidadOrganizativa)">
</plex-button>
</div>
</div>
Expand Down