Skip to content

Commit

Permalink
feat(HUDS): controla permisos para ver la HUDS
Browse files Browse the repository at this point in the history
  • Loading branch information
ma7payne committed Apr 18, 2024
1 parent 4c944dc commit 2976844
Show file tree
Hide file tree
Showing 20 changed files with 178 additions and 97 deletions.
9 changes: 9 additions & 0 deletions projects/auth/src/lib/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ interface IUsuario {
documento: string;
nombreCompleto: string;
username: number;
pacienteRestringido?: {
idPaciente: string;
archivos: string[];
observaciones: string;
createdBy: any;
createdAt: Date;
}[];
}

export enum Estado { inProgress, active, logout }
Expand Down Expand Up @@ -48,6 +55,7 @@ export class Auth {
private arrayFiltros: any[];
public mobileUser: any;
private feature: { [key: string]: boolean };
public pacienteRestringido;


constructor(private server: Server) {
Expand All @@ -63,6 +71,7 @@ export class Auth {
this.permisos = payload.permisos;
this.feature = payload.feature;
this.estado = Estado.active;
this.pacienteRestringido = payload.pacienteRestringido;
this.initShiro();
}),
publishReplay(1),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@
<ng-container *ngFor="let relacion of relaciones$ | async">
<ng-container *ngIf="relacionesYcondiciones(relacion, cama)">
<plex-button tooltip="{{ relacion.nombre }}" [icon]="relacion.icon" [type]="relacion.color"
size="sm" (click)="accion(relacion)">
size="sm" (click)="accion(relacion)" class="mr-1">
</plex-button>
</ng-container>
<plex-dropdown #drop class="mr-1" *ngIf="puedeDesocupar(relacion)" [right]="true" size="sm"
type="danger" icon="menos" [items]="itemsDropdown" tooltip="Desocupar"
(onOpen)="setDropDown(relacion, drop)">
type="danger" icon="menos" [items]="itemsDropdown" tooltip="Desocupar"
(onOpen)="setDropDown(relacion, drop)">
</plex-dropdown>
</ng-container>
</ng-container>
<plex-button class="mr-1" *ngIf="puedeEditar(cama)" title="Editar Cama" icon="pencil" type="warning"
size="sm" (click)="goTo(cama)">
size="sm" (click)="goTo(cama)">
</plex-button>
<ng-container *ngIf="puedePrestar(cama, organizacionV2$ | async )">
<plex-button title="Prestar" icon="chevron-right" type="warning" size="sm" class="mr-1"
(click)="accion({accion: 'prestar'})"
*ngIf="cama.unidadOrganizativaOriginal?.conceptId === cama.unidadOrganizativa?.conceptId">
(click)="accion({accion: 'prestar'})"
*ngIf="cama.unidadOrganizativaOriginal?.conceptId === cama.unidadOrganizativa?.conceptId">
</plex-button>
<plex-button title="Devolver" icon="chevron-left" type="warning" size="sm" class="mr-1"
(click)="accion({accion: 'devolver'})"
*ngIf="cama.unidadOrganizativaOriginal?.conceptId !== cama.unidadOrganizativa?.conceptId">
(click)="accion({accion: 'devolver'})"
*ngIf="cama.unidadOrganizativaOriginal?.conceptId !== cama.unidadOrganizativa?.conceptId">
</plex-button>
</ng-container>
<plex-button tooltip="Volver" icon="arrow-left" type="info" size="sm" (click)="cancelar()">
Expand Down Expand Up @@ -57,27 +57,27 @@
<plex-label titulo="Unidad Organizativa" subtitulo="{{ cama.unidadOrganizativa.term }}">
</plex-label>
<plex-label titulo="Especialidades" subtitulo="{{ cama.especialidades | enumerar: ['term'] }}"
*ngIf="cama.especialidades">
*ngIf="cama.especialidades">
</plex-label>
<plex-label *ngIf="cama.tipoCama" titulo="Tipo de cama" subtitulo="{{ cama.tipoCama.term }}">
</plex-label>
<plex-label titulo="Sector" subtitulo="{{ sector(cama) }}"></plex-label>
<plex-label titulo="Equipamiento" subtitulo="{{ cama.equipamiento | enumerar: ['term'] }}"
*ngIf="cama.equipamiento">
*ngIf="cama.equipamiento">
</plex-label>
<plex-label *ngIf="estadoCama.key === 'bloqueada'" titulo="Motivo bloqueo"
subtitulo="{{ cama.observaciones }}"></plex-label>
subtitulo="{{ cama.observaciones }}"></plex-label>
</plex-detail>
</fieldset>
</ng-container>
<ng-container *ngIf="cama.paciente">
<plex-title size="sm" justify titulo="DATOS DE PACIENTE">
<plex-button *ngIf="puedeVerHuds" label="EXPLORACIÓN VISUAL" size="sm" type="info"
(click)="onVerResumen(cama)" class="mr-1">
(click)="onVerResumen(cama)" disabled="!pacienteRestringido(cama.paciente)" class="mr-1">
</plex-button>

<plex-button *ngIf="capa !== 'estadistica' && verIndicacion()" label="INDICACIONES" size="sm"
type="info" (click)="onVerIndicaciones(cama)" class="mr-1">
type="info" (click)="onVerIndicaciones(cama)" class="mr-1">
</plex-button>

<ng-container *ngIf="turnero$ | async as pantalla">
Expand All @@ -100,9 +100,9 @@
</plex-title>
<fieldset>
<paciente-detalle [paciente]="paciente$ | async" orientacion="horizontal" [fields]="pacienteFields"
[accesoHuds]="true">
[accesoHuds]="!pacienteRestringido(cama.paciente)">
<plex-badge class="pr-1" type="warning" *ngIf="hayRespirador$ | async as respirador"
tooltip="Desde {{ respirador.valor.fechaDesde | fecha }}">
tooltip="Desde {{ respirador.valor.fechaDesde | fecha }}">
Respirador
</plex-badge>
</paciente-detalle>
Expand All @@ -111,25 +111,25 @@
<ng-container *ngIf="cama.estado === 'ocupada' && !cama.sala">
<plex-title titulo="Nota" size="md">
<plex-button *ngIf="!editNota" size="sm" tooltip="Editar nota" tooltipPosition="left" type="warning"
icon="documento" (click)="toggleEditNota(true, cama.nota)">
icon="documento" (click)="toggleEditNota(true, cama.nota)">
</plex-button>
</plex-title>

<plex-label> {{ cama.nota }}</plex-label>

<ng-container *ngIf="editNota">
<textarea class="form-control" [(ngModel)]="nota" id="nota" name="nota"
placeholder="Agregar nota..."></textarea>
placeholder="Agregar nota..."></textarea>
<plex-button class="float-right" size="sm" tooltip="Guardar nota" type="success" icon="check"
(click)="guardarNota(cama)"></plex-button>
(click)="guardarNota(cama)"></plex-button>
<plex-button class="float-right" size="sm" tooltip="Cancelar" type="danger" icon="close"
(click)="toggleEditNota(false, cama.nota)">
(click)="toggleEditNota(false, cama.nota)">
</plex-button>
</ng-container>
</ng-container>
</plex-tab>
<plex-tab *ngIf="cama.paciente" label="INTERNACION">
<app-internacion-detalle (accion)="onAccion($event)">
<app-internacion-detalle (accion)="onAccion($event)" [paciente]="cama.paciente">
</app-internacion-detalle>
</plex-tab>
<plex-tab label="HISTORIAL" *ngIf="!cama.sala">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,4 +333,8 @@ export class CamaDetalleComponent implements OnInit {
puedePrestar(cama: ISnapshot, organizacion) {
return this.capa !== 'interconsultores' && !cama.sala && this.permisosMapaCamasService.camaPrestamo && (organizacion || cama.estado === 'disponible');
}

pacienteRestringido({ id }: IPaciente) {
return !!this.auth.pacienteRestringido?.find(p => p.idPaciente === id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,14 @@
egreso.
</plex-label>
</ng-container>

<ng-container *ngIf="mostrar === 'registros' && permisosMapaCamasService.registros">
<app-registros-huds-detalle (accion)="onAccion($event)"></app-registros-huds-detalle>
<app-registros-huds-detalle *ngIf="!pacienteRestringido(paciente)"
(accion)="onAccion($event)"></app-registros-huds-detalle>
<plex-label *ngIf="pacienteRestringido(paciente)" class="mt-4" type="warning" icon="informacion" justify="center"
direction="column">
Usted no tiene permiso para ingresar a este paciente
</plex-label>
</ng-container>


</div>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Plex, PlexOptionsComponent } from '@andes/plex';
import { Component, ContentChild, EventEmitter, OnInit, Output, AfterViewChecked, ChangeDetectorRef } from '@angular/core';
import { Auth } from '@andes/auth';
import { Component, ContentChild, EventEmitter, OnInit, Output, AfterViewChecked, ChangeDetectorRef, Input } from '@angular/core';
import { combineLatest, Observable, of } from 'rxjs';
import { auditTime, map, switchMap, take } from 'rxjs/operators';
import { PrestacionesService } from 'src/app/modules/rup/services/prestaciones.service';
Expand All @@ -10,6 +11,7 @@ import { ListadoInternacionCapasService } from '../../../views/listado-internaci
import { ListadoInternacionService } from '../../../views/listado-internacion/listado-internacion.service';
import { IngresoPacienteService } from '../../ingreso/ingreso-paciente-workflow/ingreso-paciente-workflow.service';

import { IPaciente } from 'src/app/core/mpi/interfaces/IPaciente';
@Component({
selector: 'app-internacion-detalle',
templateUrl: './internacion-detalle.component.html',
Expand All @@ -24,6 +26,7 @@ export class InternacionDetalleComponent implements OnInit, AfterViewChecked {
public existeEgreso;
view$ = this.mapaCamasService.view;

@Input() paciente;
@Output() cambiarCama = new EventEmitter<any>();
@Output() accion = new EventEmitter<any>();
@ContentChild(PlexOptionsComponent, { static: true }) plexOptions: PlexOptionsComponent;
Expand All @@ -49,7 +52,8 @@ export class InternacionDetalleComponent implements OnInit, AfterViewChecked {
private listadoInternacionCapasService: ListadoInternacionCapasService,
private listadoInternacion: ListadoInternacionService,
private cdr: ChangeDetectorRef,
private ingresoPacienteService: IngresoPacienteService
private ingresoPacienteService: IngresoPacienteService,
private auth: Auth,
) { }

ngAfterViewChecked() {
Expand Down Expand Up @@ -230,4 +234,7 @@ export class InternacionDetalleComponent implements OnInit, AfterViewChecked {
return (this.permisosMapaCamasService.egreso && this.estadoPrestacion !== 'validada' && this.existeEgreso);
}

pacienteRestringido({ id }: IPaciente) {
return !!this.auth.pacienteRestringido?.find(p => p.idPaciente === id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -238,4 +238,8 @@ export class RegistrosHudsDetalleComponent implements OnInit {
this.inProgress = true;
this.tipoPrestacion$.next(this.tipoPrestacion);
}

pacienteRestringido({ id }: IPaciente) {
return !!this.auth.pacienteRestringido?.find(p => p.idPaciente === id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import { Router } from '@angular/router';
import { BehaviorSubject, Observable, Subject, combineLatest, of } from 'rxjs';
import { map, takeUntil, tap } from 'rxjs/operators';
import { PacienteService } from 'src/app/core/mpi/services/paciente.service';
import { IFinanciador } from 'src/app/interfaces/IFinanciador';
import { HUDSService } from '../../modules/rup/services/huds.service';
import { ExportHudsService } from '../../modules/visualizacion-informacion/services/export-huds.service';
import { ObraSocialService } from '../../services/obraSocial.service';
import { ProfesionalService } from '../../services/profesional.service';
import { FacturacionAutomaticaService } from './../../services/facturacionAutomatica.service';
import { TurnosPrestacionesService } from './services/turnos-prestaciones.service';
import { cache } from '@andes/shared';
import { IFinanciador } from 'src/app/interfaces/IFinanciador';
import { IPaciente } from 'src/app/core/mpi/interfaces/IPaciente';

@Component({
selector: 'turnos-prestaciones',
Expand Down Expand Up @@ -158,10 +159,8 @@ export class TurnosPrestacionesComponent implements OnInit, OnDestroy {


this.busqueda$ = this.turnosPrestacionesService.prestacionesOrdenada$.pipe(
map(prestaciones => {
this.loader = false;
return prestaciones;
}), // Ocultar el loader cuando los datos estén disponibles
tap(() => this.loader = false), // Ocultar el loader cuando los datos estén disponibles
map((items) => items.filter(({ paciente }) => !this.pacienteRestringido(paciente), {})),
takeUntil(this.onDestroy$),
cache()
);
Expand Down Expand Up @@ -467,4 +466,8 @@ export class TurnosPrestacionesComponent implements OnInit, OnDestroy {
generarComprobante() {
return this.prestacionIniciada && this.puedeEmitirComprobante && this.financiador && ((!this.prestacion.estadoFacturacion) || this.prestacion.estadoFacturacion?.estado !== 'Comprobante con prestacion');
}

pacienteRestringido({ id }: IPaciente) {
return !!this.auth.pacienteRestringido?.find(p => p.idPaciente === id);
}
}
38 changes: 23 additions & 15 deletions src/app/components/top/solicitudes/solicitudes.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import { PlexModalComponent } from '@andes/plex/src/lib/modal/modal.component';
import { Unsubscribe } from '@andes/shared';
import { Component, ElementRef, HostBinding, Input, OnInit, ViewChild } from '@angular/core';
import { Router } from '@angular/router';
import { catchError, concatWith } from 'rxjs';
import { catchError, concatWith, map } from 'rxjs';
import { PacienteService } from 'src/app/core/mpi/services/paciente.service';
import { RouterService } from 'src/app/services/router.service';
import { HUDSService } from '../../../modules/rup/services/huds.service';
import { PrestacionesService } from '../../../modules/rup/services/prestaciones.service';
import { TurnoService } from '../../../services/turnos/turno.service';
import { PlexHelpComponent } from '@andes/plex/src/lib/help/help.component';
import { IPaciente } from 'src/app/core/mpi/interfaces/IPaciente';
import { IPrestacion } from 'src/app/interfaces/turnos/IPrestacion';

@Component({
selector: 'solicitudes',
Expand Down Expand Up @@ -538,22 +540,28 @@ export class SolicitudesComponent implements OnInit {
}
}

pacienteRestringido(paciente) {
return !!this.auth.pacienteRestringido?.find(p => p.idPaciente === paciente.id);
}

@Unsubscribe()
buscarSolicitudes() {
return this.servicioPrestacion.getSolicitudes(this.getParams()).subscribe(resultado => {
if (this.tipoSolicitud === 'entrada') {
this.prestacionesEntrada = this.prestacionesEntrada.concat(resultado);
this.skip = this.prestacionesEntrada.length;
} else if (this.tipoSolicitud === 'salida') {
this.prestacionesSalida = this.prestacionesSalida.concat(resultado);
this.skip = this.prestacionesSalida.length;
}
// si vienen menos solicitudes que la cantidad límite significa que ya se cargaron todas
if (!resultado.length || resultado.length < this.limit) {
this.scrollEnd = true;
}
this.loader = false;
});
return this.servicioPrestacion.getSolicitudes(this.getParams())
.pipe(map((resultado) => resultado.filter((solicitud) => !this.pacienteRestringido(solicitud.paciente))))
.subscribe(resultado => {
if (this.tipoSolicitud === 'entrada') {
this.prestacionesEntrada = this.prestacionesEntrada.concat(resultado);
this.skip = this.prestacionesEntrada.length;
} else if (this.tipoSolicitud === 'salida') {
this.prestacionesSalida = this.prestacionesSalida.concat(resultado);
this.skip = this.prestacionesSalida.length;
}
// si vienen menos solicitudes que la cantidad límite significa que ya se cargaron todas
if (!resultado.length || resultado.length < this.limit) {
this.scrollEnd = true;
}
this.loader = false;
});
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Auth } from '@andes/auth';
import { cache } from '@andes/shared';
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import * as moment from 'moment';
import { TurnoService } from '../../../services/turnos/turno.service';
import { Auth } from '@andes/auth';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { cache } from '@andes/shared';
import { IPaciente } from '../../../core/mpi/interfaces/IPaciente';
import { TurnoService } from '../../../services/turnos/turno.service';


@Component({
selector: 'estadisticas-pacientes',
Expand Down Expand Up @@ -48,6 +49,10 @@ export class EstadisticasPacientesComponent implements OnInit {
this.permisos = this.auth.getPermissions('turnos:darTurnos:prestacion:?');
}

public pacienteRestringido({ id }: IPaciente) {
return !!this.auth.pacienteRestringido?.find(p => p.idPaciente === id);
}

private sortByHoraInicio(turnos: any[]) {
return turnos.sort((a, b) => {
const inia = a.horaInicio ? new Date(a.horaInicio) : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</demandaInsatisfecha>
</ng-container>
</plex-tab>
<plex-tab icon="history" label="Historial">
<plex-tab icon="history" label="Historial" *ngIf="!pacienteRestringido(paciente)">
<fieldset *plTab>
<ul class="list-group">
<li *ngFor="let turno of ultimosTurnos$ | async; let i=index" class="list-group-item"
Expand Down
4 changes: 4 additions & 0 deletions src/app/core/mpi/components/busqueda-mpi.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,8 @@ export class BusquedaMpiComponent implements OnInit {
afterPacienteCru(paciente: IPaciente) {
this.updateTitle('Buscar pacientes');
}

pacienteRestringido({ id }: IPaciente) {
return !!this.auth.pacienteRestringido?.find(p => p.idPaciente === id);
}
}
2 changes: 1 addition & 1 deletion src/app/core/mpi/components/busqueda-mpi.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<!-- detalles del paciente a visualizar -->
<ng-container *ngIf="showDetallePaciente">
<plex-title titulo="Detalle paciente" size="sm">
<plex-button type="warning" size="sm" label="Editar Datos" (click)="toEdit(paciente)"></plex-button>
<plex-button [disabled]="pacienteRestringido(paciente)" type="warning" size="sm" label="Editar Datos" (click)="toEdit(paciente)"></plex-button>
<plex-button type="danger" icon="close" class="ml-2" size="sm" (click)="closeDetallePaciente()">
</plex-button>
</plex-title>
Expand Down
Loading

0 comments on commit 2976844

Please sign in to comment.