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 Jun 18, 2024
1 parent e6686dc commit af76ab4
Show file tree
Hide file tree
Showing 17 changed files with 194 additions and 108 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
12 changes: 9 additions & 3 deletions projects/shared/src/lib/shared.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { PopoverAuditComponent } from './components/popover-audit/popover-audit.
import { GaleriaArchivosComponent } from './components/galeria-archivos/galeria-archivos.component';
import { FormsModule } from '@angular/forms';
import { DocumentoPipe } from './pipes/documento.pipe';
import { PacienteRestringidoPipe } from 'src/app/pipes/pacienteRestringido';

@NgModule({
imports: [
Expand All @@ -38,7 +39,8 @@ import { DocumentoPipe } from './pipes/documento.pipe';
PopoverAuditComponent,
GaleriaArchivosComponent,
UploadFileComponent,
NotasComponent
NotasComponent,
PacienteRestringidoPipe
],
exports: [
FechaPipe,
Expand All @@ -54,8 +56,12 @@ import { DocumentoPipe } from './pipes/documento.pipe';
PopoverAuditComponent,
GaleriaArchivosComponent,
UploadFileComponent,
NotasComponent
]
NotasComponent,
PacienteRestringidoPipe
],
providers: [
PacienteRestringidoPipe
],
})
export class SharedModule {
static forRoot(host: string): ModuleWithProviders<SharedModule> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<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"
Expand Down Expand Up @@ -73,7 +73,7 @@
<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]="cama.paciente | pacienteRestringido" class="mr-1">
</plex-button>

<plex-button *ngIf="capa !== 'estadistica' && verIndicacion()" label="INDICACIONES" size="sm"
Expand Down Expand Up @@ -106,7 +106,7 @@

<fieldset>
<paciente-detalle [paciente]="paciente$ | async" orientacion="horizontal" [fields]="pacienteFields"
[accesoHuds]="true">
[accesoHuds]="!(cama.paciente | pacienteRestringido)">
<plex-badge class="pr-1" type="warning" *ngIf="hayRespirador$ | async as respirador"
tooltip="Desde {{ respirador.valor.fechaDesde | fecha }}">
Respirador
Expand Down Expand Up @@ -135,7 +135,7 @@
</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 @@ -60,8 +60,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="!(paciente | pacienteRestringido)"
(accion)="onAccion($event)"></app-registros-huds-detalle>
<plex-label *ngIf="paciente | pacienteRestringido" class="mt-4" type="warning" icon="informacion" justify="center"
direction="column">
No tiene permiso para ingresar a este paciente.
</plex-label>
</ng-container>


</div>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Plex, PlexOptionsComponent } from '@andes/plex';
import { Component, ContentChild, EventEmitter, OnInit, Output, AfterViewChecked, ChangeDetectorRef } from '@angular/core';
import { combineLatest, Observable, of } from 'rxjs';
import { AfterViewChecked, ChangeDetectorRef, Component, ContentChild, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { Observable, combineLatest, of } from 'rxjs';
import { auditTime, map, switchMap, take } from 'rxjs/operators';
import { PrestacionesService } from 'src/app/modules/rup/services/prestaciones.service';
import { MapaCamasHTTP } from '../../../services/mapa-camas.http';
Expand All @@ -24,6 +24,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 Down Expand Up @@ -232,5 +233,4 @@ export class InternacionDetalleComponent implements OnInit, AfterViewChecked {
puedeEditarEgreso() {
return (this.permisosMapaCamasService.egreso && this.estadoPrestacion !== 'validada' && this.existeEgreso);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ 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';
import { PacienteRestringidoPipe } from 'src/app/pipes/pacienteRestringido';

@Component({
selector: 'turnos-prestaciones',
Expand Down Expand Up @@ -98,6 +100,7 @@ export class TurnosPrestacionesComponent implements OnInit, OnDestroy {
private exportHudsService: ExportHudsService,
public obraSocialService: ObraSocialService,
private pacienteService: PacienteService,
private pacienteRestringido: PacienteRestringidoPipe

) { }

Expand Down Expand Up @@ -158,10 +161,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.esPacienteRestringido(paciente), {})),
takeUntil(this.onDestroy$),
cache()
);
Expand Down Expand Up @@ -467,4 +468,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');
}

esPacienteRestringido(paciente: IPaciente) {
return this.pacienteRestringido.transform(paciente);
}
}
42 changes: 26 additions & 16 deletions src/app/components/top/solicitudes/solicitudes.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ 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';
import { PacienteRestringidoPipe } from 'src/app/pipes/pacienteRestringido';

@Component({
selector: 'solicitudes',
Expand Down Expand Up @@ -158,7 +161,8 @@ export class SolicitudesComponent implements OnInit {
public router: Router,
private hudsService: HUDSService,
private pacienteService: PacienteService,
private routerService: RouterService
private routerService: RouterService,
private pacienteRestringido: PacienteRestringidoPipe
) {
}

Expand Down Expand Up @@ -525,22 +529,28 @@ export class SolicitudesComponent implements OnInit {
}
}

esPacienteRestringido(paciente) {
return this.pacienteRestringido.transform(paciente);
}

@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.esPacienteRestringido(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;
});
}

verFechaDateTimeEntrada() {
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="!(paciente | pacienteRestringido)">
<fieldset *plTab>
<ul class="list-group">
<li *ngFor="let turno of ultimosTurnos$ | async; let i=index" class="list-group-item"
Expand Down
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]="paciente | pacienteRestringido" 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
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { EMPTY } from 'rxjs';
import { PacienteService } from 'src/app/core/mpi/services/paciente.service';
import { AgendaService } from 'src/app/services/turnos/agenda.service';
import { ConceptosTurneablesService } from 'src/app/services/conceptos-turneables.service';
import { PacienteRestringidoPipe } from 'src/app/pipes/pacienteRestringido';

@Component({
selector: 'rup-asignar-turno',
Expand Down Expand Up @@ -46,7 +47,8 @@ export class RupAsignarTurnoComponent implements OnInit {
private obraSocialService: ObraSocialService,
private pacienteService: PacienteService,
private serviceAgenda: AgendaService,
private conceptosTurneablesService: ConceptosTurneablesService
private conceptosTurneablesService: ConceptosTurneablesService,
private pacienteRestringido: PacienteRestringidoPipe
) { }

ngOnInit() {
Expand Down Expand Up @@ -75,26 +77,34 @@ export class RupAsignarTurnoComponent implements OnInit {
this.pacienteActivo = null;
}

esPacienteRestringido(paciente: IPaciente) {
return this.pacienteRestringido.transform(paciente);
}

onPacienteSelected(paciente: IPaciente) {
// Si se seleccionó por error un paciente fallecido
this.pacienteService.checkFallecido(paciente);
this.pacienteActivo = paciente;
this.pacientes = null;
if (paciente) {
this.obraSocialPaciente = null;
if (paciente.id && paciente.documento) {
this.obraSocialService.getObrasSociales(paciente.documento).subscribe(
(resultado: IObraSocial[]) => {
if (resultado.length > 0) {
this.obraSocialPaciente = resultado[0];
}
this.setPacienteTurno(paciente);
},
() => {
this.setPacienteTurno(paciente);
});
if (!this.esPacienteRestringido(paciente)) {
this.pacienteActivo = paciente;
this.obraSocialPaciente = null;
if (paciente.id && paciente.documento) {
this.obraSocialService.getObrasSociales(paciente.documento).subscribe(
(resultado: IObraSocial[]) => {
if (resultado.length > 0) {
this.obraSocialPaciente = resultado[0];
}
this.setPacienteTurno(paciente);
},
() => {
this.setPacienteTurno(paciente);
});
} else {
this.setPacienteTurno(paciente);
}
} else {
this.setPacienteTurno(paciente);
this.plex.info('warning', 'No tiene permisos para acceder a este paciente.');
}

} else {
Expand Down Expand Up @@ -180,7 +190,7 @@ export class RupAsignarTurnoComponent implements OnInit {
paciente: paciente,
idAgenda: this.agenda.id
};
// guardamos el turno
// guardamos el turno
this.serviceTurno.saveDinamica(datosConfirma).pipe(
map(turnoDado => {
fechaTurno = turnoDado.horaInicio;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Auth } from '@andes/auth';
import { IPaciente } from '../../../../core/mpi/interfaces/IPaciente';
import { HUDSService } from '../../services/huds.service';
import { Location } from '@angular/common';
import { PacienteRestringidoPipe } from 'src/app/pipes/pacienteRestringido';

@Component({
selector: 'rup-hudsBusquedaPaciente',
Expand All @@ -18,7 +19,6 @@ export class HudsBusquedaPacienteComponent implements OnInit {
resultadoBusqueda = null;
loading = false;
routeParams: any;
// public motivoAccesoHuds;
showModalMotivo = false;
pacienteSelected = null;

Expand All @@ -27,7 +27,8 @@ export class HudsBusquedaPacienteComponent implements OnInit {
public plex: Plex,
public auth: Auth,
private router: Router,
private hudsService: HUDSService
private hudsService: HUDSService,
private pacienteRestringido: PacienteRestringidoPipe
) { }

ngOnInit() {
Expand Down Expand Up @@ -67,10 +68,18 @@ export class HudsBusquedaPacienteComponent implements OnInit {
this.resultadoBusqueda = [];
}

esPacienteRestringido(paciente: IPaciente) {
return this.pacienteRestringido.transform(paciente);
}

onSelect(paciente: IPaciente): void {
if (paciente) {
this.pacienteSelected = paciente;
this.showModalMotivo = true;
if (this.esPacienteRestringido(paciente)) {
this.plex.info('warning', 'No tiene permiso para ingresar a este paciente.', 'Atención');
} else {
this.pacienteSelected = paciente;
this.showModalMotivo = true;
}
}
}

Expand Down
Loading

0 comments on commit af76ab4

Please sign in to comment.