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

RUP - Quitar primera vez de trastornos inactivos o resueltos #3116

Closed
wants to merge 2 commits into from
Closed
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
11 changes: 10 additions & 1 deletion src/app/components/snomed/snomed-buscar.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import { BehaviorSubject, Observable } from 'rxjs';


export interface SnomedBuscadorParam {
term?: string;
Expand All @@ -11,6 +12,7 @@ export interface SnomedBuscadorParam {
export class SnomedBuscarService {

private dataSource = new BehaviorSubject<SnomedBuscadorParam>({});
private buscado: BehaviorSubject<string> = new BehaviorSubject<string>('');
onChange = this.dataSource.asObservable();

constructor() { }
Expand All @@ -26,4 +28,11 @@ export class SnomedBuscarService {
}
}

getBuscadoValue(): Observable<string> {
return this.buscado.asObservable();
}
setBuscado(search: string) {
this.buscado.next(search);
}

}
102 changes: 62 additions & 40 deletions src/app/components/top/reglas/visualizacionReglas.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import { PrestacionesService } from 'src/app/modules/rup/services/prestaciones.s
import { DocumentosService } from 'src/app/services/documentos.service';
import { IOrganizacion } from '../../../interfaces/IOrganizacion';
import { IRegla } from '../../../interfaces/IRegla';
import { Observable, of, debounceTime, distinctUntilChanged } from 'rxjs';
import { ITipoPrestacion } from '../../../interfaces/ITipoPrestacion';
import { ReglaService } from '../../../services/top/reglas.service';
import { UnidadEdad } from 'src/app/utils/enumerados';

@Component({
selector: 'visualizacion-reglas',
Expand Down Expand Up @@ -51,8 +53,10 @@ export class VisualizacionReglasComponent implements OnInit {
public arrayReglas: any = [];
public filas: any[];
public parametros;
public filas$: Observable<any[]>;
public loader = false;
private scrollEnd = false;
public search = '';

constructor(
private servicioReglas: ReglaService,
Expand All @@ -67,6 +71,7 @@ export class VisualizacionReglasComponent implements OnInit {
organizacionDestino: undefined,
prestacionDestino: undefined,
prestacionOrigen: this.prestacion?.conceptId || undefined,
search: this.search,
skip: 0,
limit: 10
};
Expand All @@ -88,64 +93,81 @@ export class VisualizacionReglasComponent implements OnInit {
this.parametros['prestacionOrigen'] = this.prestacionOrigen?.conceptId || undefined;

// cada vez que se modifican los filtros seteamos el skip en 0
this.parametros.skip = 0;
this.parametros['skip'] = 0;
this.scrollEnd = false;
if (this.parametros.organizacionOrigen || this.parametros.organizacionDestino || this.parametros.prestacionOrigen || this.parametros.prestacionDestino) {
this.actualizarTabla();
} else {
this.arrayReglas = [];
this.filas = null;
}
}

public onSearchStart(event: any) {
this.search = event.value;
this.parametros['search'] = this.search;
this.parametros['skip'] = 0;
this.actualizarTabla();
}

/**
* Recarga los datos de la tabla según los filtros ingresados. Debe tener por lo menos un filtro ingresado para que
* se actualice la tabla
* @memberof VisualizacionReglasComponent
*/
actualizarTabla() {
if (this.parametros.skip === 0) {
this.arrayReglas = [];
this.filas = [];
if (this.parametros['skip'] === 0) {
this.loader = true;
this.arrayReglas = [];
}
this.servicioReglas.get(this.parametros).subscribe((reglas: [IRegla]) => {
this.loader = false;
this.obtenerFilasTabla(reglas);
this.parametros.skip = this.arrayReglas.length;
if (!this.arrayReglas.length || this.arrayReglas.length < this.parametros.limit) {
this.scrollEnd = true;
}
});
}

/**
* Acomoda los datos de las reglas de forma que se pueda acceder facilmente desde la tabla
*
* @memberof VisualizacionReglasComponent
*/
obtenerFilasTabla(reglas: IRegla[]) {
for (const regla of reglas) {
this.arrayReglas.push(regla);
regla.origen.prestaciones?.forEach((prestacionAux: any) => { // prestacionAux es cada celda del arreglo de origen.prestaciones. Tiene la prestación y si es auditable
if (!this.prestacionOrigen || this.prestacionOrigen.conceptId === prestacionAux.prestacion.conceptId) {
/* Es necesaria esta validación porque una regla tiene un origen y un destino. El origen se compone de
* una organización y una lista de prestaciones. Entonces si filtra por prestación origen, que muestre
* solo aquellas partes de la regla que cumpla con los filtros ingresados. El destino es una organización
* y una sola prestación por lo que no< es necesario más validaciones. */
if (!this.prestacion || prestacionAux.prestacion.conceptId === this.prestacion.conceptId) {
this.filas.push({
organizacionOrigen: regla.origen.organizacion,
prestacionOrigen: prestacionAux,
organizacionDestino: regla.destino.organizacion,
prestacionDestino: regla.destino.prestacion
});
}
this.servicioReglas.get(this.parametros)
.pipe(
debounceTime(300),
distinctUntilChanged()
)
.subscribe((reglas: [IRegla]) => {
this.loader = false;
this.arrayReglas.push(...reglas);
this.generarFilasObservable();
this.parametros.skip = this.arrayReglas.length;
if (!this.arrayReglas.length || this.arrayReglas.length < this.parametros.limit) {
this.scrollEnd = true;
}
});
}
if (this.esParametrizado) {
this.filas.sort((fila1, fila2) => {

}

generarFilasObservable() {

this.filas$ = of(
this.arrayReglas.flatMap(regla =>
regla.origen.prestaciones?.flatMap((prestacionAux: any) => {

if (
!this.prestacionOrigen ||
this.prestacionOrigen.conceptId === prestacionAux.prestacion.conceptId
) {
if (
!this.prestacion ||
prestacionAux.prestacion.conceptId === this.prestacion.conceptId
) {

const fila = {
organizacionOrigen: regla.origen.organizacion,
prestacionOrigen: prestacionAux.prestacion,
organizacionDestino: regla.destino.organizacion,
prestacionDestino: regla.destino.prestacion,
};
return fila;
}
}
return []; // Devuelve un array vacío si no se cumple ninguna condición
})
)
);

this.filas$.subscribe(filas => {
filas.sort((fila1, fila2) => {
if (fila2.prestacionDestino.term < fila1.prestacionDestino.term) {
return 1;
}
Expand All @@ -154,7 +176,7 @@ export class VisualizacionReglasComponent implements OnInit {
}
return 0;
});
}
});
}

public seleccionarConcepto(concepto) {
Expand Down
36 changes: 19 additions & 17 deletions src/app/components/top/reglas/visualizacionReglas.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<plex-title titulo="Reglas Solicitudes">
<plex-text [(ngModel)]="search" name="search" (change)="onSearchStart($event)" placeholder=" Buscar ..."
[autoFocus]="true">
</plex-text>
</plex-title>

<plex-wrapper *ngIf="!esParametrizado">
<plex-select [(ngModel)]="organizacionOrigen" name="orgOrigen" tmOrganizaciones label="Organización origen"
placeholder="Seleccione la organización" (change)="refrescarFiltro()">
Expand All @@ -16,21 +22,16 @@
</plex-wrapper>

<div class="row">
<div class="col-12">
<plex-loader *ngIf="loader" type="ball-pulse"></plex-loader>
<div class="col-12" *ngIf="filas$ | async as filas">
<plex-loader *ngIf="loader && filas" type="ball-pulse"></plex-loader>
<div *ngIf="!loader && filas && !filas?.length" justify="center" class="mt-5">
<plex-label titulo="No hay resultados para esta búsqueda" direction="column"
subtitulo="Edite algún filtro para realizar una nueva" type="warning" size="xl" icon="close">
</plex-label>
</div>
<div *ngIf="!loader && !filas" justify="center" class="mt-5">
<plex-label class="flex-column" icon="magnify" size="xl" type="info" direction="column" titulo="Comience completando los filtros"
subtitulo="Elija las opciones de filtrado y se generará la búsqueda">
subtitulo="Edite el filtro para realizar una nueva búsqueda" type="warning" size="xl" icon="close">
</plex-label>
</div>
<ng-container *ngIf="filas?.length">
<ng-container *ngIf="filas$ | async as filas">
<plex-list [striped]="true" height="calc(100vh - 247px)" (scrolled)="onScroll()">
<plex-item>
<plex-item *ngIf="filas?.length ">
<b *ngIf="!esParametrizado">Organización origen</b>
<b label> Prestación origen </b>
<b label> Organización destino </b>
Expand All @@ -39,29 +40,30 @@
<plex-item *ngFor="let fila of filas">
<div class="elementos-graficos w-100" *ngIf="!esParametrizado">
<plex-icon name="hospital-building" type="info"></plex-icon>
<plex-label [tituloBold]="true" titulo="{{ fila.organizacionOrigen.nombre }}">
<plex-label [tituloBold]="true" titulo="{{ fila?.organizacionOrigen?.nombre }}">
</plex-label>
</div>
<plex-label [tituloBold]="!esParametrizado" titulo="{{ fila.prestacionOrigen.prestacion.term }}">
<plex-label [tituloBold]="!esParametrizado" titulo="{{ fila?.prestacionOrigen?.term }}">
</plex-label>
<div class="elementos-graficos w-100">
<plex-icon *ngIf="!esParametrizado" name="hospital-building" type="success"></plex-icon>
<plex-label [tituloBold]="!esParametrizado" titulo="{{ fila.organizacionDestino.nombre }}">
<plex-label [tituloBold]="!esParametrizado" titulo="{{ fila?.organizacionDestino?.nombre }}">
</plex-label>
</div>
<plex-label [tituloBold]="!esParametrizado" titulo="{{ fila.prestacionDestino.term }}"></plex-label>
<plex-label [tituloBold]="!esParametrizado"
titulo="{{ fila?.prestacionDestino?.term }}"></plex-label>


<plex-button *ngIf="prestacion"
[disabled]="prestacion?.conceptId !== fila.prestacionOrigen.prestacion.conceptId"
[disabled]="prestacion?.conceptId === fila?.prestacionOrigen?.prestacion?.conceptId"
type="primary" size="sm" icon="plus" tooltip="Agregar a la consulta"
(click)="seleccionarConcepto(fila.prestacionDestino)" tooltipPosition="left">
</plex-button>

<plex-badge *ngIf="fila.prestacionOrigen.auditable && !esParametrizado" type="success">
<plex-badge *ngIf="fila?.prestacionOrigen?.auditable && !esParametrizado" type="success">
auditable
</plex-badge>
<plex-badge *ngIf="!fila.prestacionOrigen.auditable && !esParametrizado" type="warning">
<plex-badge *ngIf="!fila?.prestacionOrigen?.auditable && !esParametrizado" type="warning">
no auditable
</plex-badge>
</plex-item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ export class PrestacionEjecucionComponent implements OnInit, OnDestroy {

public flagValid = true;

public search = '';

public scopePrivacy = [];
public registrosHUDS = [];
public tieneAccesoHUDS: Boolean;
Expand Down Expand Up @@ -284,6 +286,10 @@ export class PrestacionEjecucionComponent implements OnInit, OnDestroy {
}
}

buscar() {
this.buscadorService.setBuscado(this.search);
}

/**
* recorre los registros de una prestación que ya tiene registros en ejecución
* y los carga el array itemsRegistros para colapsar y para los registros que se puedan relacionar (items).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
</plex-button>

<ng-container ngProjectAs="plex-button" *ngIf="activeIndex === 0">
<plex-help #helpSolicitudes class="text-left" titulo="Reglas Solicitudes"
tituloBoton="Reglas Solicitudes" size="sm">
<visualizacion-reglas info [esParametrizado]="true"

<plex-help #helpSolicitudes class="text-left" tituloBoton="Reglas Solicitudes" size="sm" cardSize="full">
<visualizacion-reglas [esParametrizado]="true"
[prestacion]="prestacion.solicitud.tipoPrestacion" *plHelp
(addSolicitud)="agregarSolicitud($event, helpSolicitudes)">
</visualizacion-reglas>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<plex-layout-main>
<!-- Box header -->
<plex-title main titulo="Punto de inicio">
<plex-help type="info" titulo="Reglas Solicitudes" tituloBoton="Reglas Solicitudes">
<plex-help #helpSolicitudes class="text-left" tituloBoton="Reglas Solicitudes" size="sm" cardSize="full">
<visualizacion-reglas info [esParametrizado]="true" *plHelp></visualizacion-reglas>
</plex-help>
<plex-button type="warning" size="sm" (click)="irASolicitudes()"> Mis
Expand Down
14 changes: 13 additions & 1 deletion src/app/services/top/reglas.service.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { Server } from '@andes/shared';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { BehaviorSubject, Observable } from 'rxjs';
import { map } from 'rxjs/operators';

@Injectable()
export class ReglaService {

// URL to web api
private reglaUrl = '/modules/top/reglas';
private buscado: BehaviorSubject<string> = new BehaviorSubject<string>('');

constructor(private server: Server) { }

Expand All @@ -33,4 +35,14 @@ export class ReglaService {
return this.server.post('/modules/top/reglas-v2', regla);
}
}

getBuscadoValue(): Observable<string> {
return this.buscado.asObservable().pipe(
map(value => String(value))
);
}
setBuscado(search: string) {
this.buscado.next(search);
}

}
Loading