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

INT - Agrega columna 'obra social' en listado #2290

Merged
merged 2 commits into from
May 27, 2021
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
21 changes: 21 additions & 0 deletions projects/shared/src/lib/operators/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,24 @@ export function saveAs(fileName: string, type: Extensiones, timestamp = true) {

export * from './cache-storage';
export * from './not-null';

export function arrayToSet(array, key, itemFn) {
const listado = [];
array.forEach(elem => {
const item = itemFn(elem);
if (item && Array.isArray(item)) {
item.forEach(inside => {
const index = listado.findIndex(i => i[key] === inside[key]);
if (index < 0) {
listado.push(inside);
}
});
} else if (item) {
const index = listado.findIndex(i => i[key] === item[key]);
if (index < 0) {
listado.push(item);
}
}
});
return listado;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,14 @@ import { Observable, Subject, combineLatest, BehaviorSubject } from 'rxjs';
import { map, switchMap, take, tap, pluck, catchError } from 'rxjs/operators';
import { PrestacionesService } from '../../../../../modules/rup/services/prestaciones.service';
import { Auth } from '@andes/auth';
import { cache, notNull } from '@andes/shared';
import { arrayToSet, cache, notNull } from '@andes/shared';
import { Router } from '@angular/router';
import { IPrestacion } from '../../../../../modules/rup/interfaces/prestacion.interface';
import { RegistroHUDSItemAccion } from './registros-huds-item/registros-huds-item.component';
import { IMAQEstado } from '../../interfaces/IMaquinaEstados';
import { ModalMotivoAccesoHudsService } from '../../../../../modules/rup/components/huds/modal-motivo-acceso-huds.service';
import { IPaciente } from '../../../../../core/mpi/interfaces/IPaciente';

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-registros-huds-detalle',
templateUrl: './registros-huds-detalle.component.html'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,9 @@
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { MapaCamasService } from '../../../services/mapa-camas.service';
import { Component, OnInit } from '@angular/core';
import { Observable } from 'rxjs';
import { map, tap } from 'rxjs/operators';
import { map } from 'rxjs/operators';
import { IntegridadService } from '../integridad.service';
import { arrayToSet } from '@andes/shared';

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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@
<plex-datetime type="date" [(ngModel)]="filtros.fechaEgresoHasta" name='fechaEgresoHasta' label="Egreso hasta"
(change)="filtrarFecha()" [min]="filtros.fechaEgresoDesde" [debounce]="600">
</plex-datetime>
<plex-select [(ngModel)]="filtros.estado" [data]='estadosInternacion' label="Estado" (change)="filtrar()">
</plex-select>
<plex-button *ngIf="permisosMapaCamasService.descargarListado" type="warning" icon="download mdi-14px" title="Descargar Csv"
titlePosition="top" (click)="reporteInternaciones()" [disabled]="requestInProgress">
<div collapse>
<plex-select name="obraSocial" label="Obra Social" [(ngModel)]="filtros.obraSocial" (change)="filtrar()"
[data]="obraSociales$ | async" idField="_id">
</plex-select>
<plex-select [(ngModel)]="filtros.estado" [data]='estadosInternacion' label="Estado" (change)="filtrar()">
</plex-select>
</div>
<plex-button *ngIf="permisosMapaCamasService.descargarListado" type="warning" icon="download mdi-14px"
title="Descargar Csv" titlePosition="top" (click)="reporteInternaciones()"
[disabled]="requestInProgress">
</plex-button>
</plex-wrapper>
</plex-wrapper>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import { Auth } from '@andes/auth';
import { DocumentosService } from '../../../../../../services/documentos.service';
import { ListadoInternacionService } from '../listado-internacion.service';
import { PermisosMapaCamasService } from '../../../services/permisos-mapa-camas.service';
import { ObraSocialService } from 'src/app/services/obraSocial.service';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { arrayToSet } from '@andes/shared';

@Component({
selector: 'app-filtros-internacion',
Expand All @@ -20,24 +24,34 @@ export class FiltrosInternacionComponent implements OnInit {
estadosInternacion;
requestInProgress: boolean;

obraSociales$: Observable<any[]>;

constructor(
private auth: Auth,
private listadoInternacionService: ListadoInternacionService,
private servicioDocumentos: DocumentosService,
public permisosMapaCamasService: PermisosMapaCamasService,
public permisosMapaCamasService: PermisosMapaCamasService
) { }

ngOnInit() {
this.estadosInternacion = enumerados.getObjEstadoInternacion();

this.obraSociales$ = this.listadoInternacionService.listaInternacion$.pipe(
map((prestaciones) => {
const rs = arrayToSet(prestaciones, 'nombre', (item) => item.paciente.obraSocial);
rs.push({
_id: 'sin-obra-social',
nombre: 'SIN OBRA SOCIAL'
});
return rs;
})
);
}

filtrar() {
this.listadoInternacionService.pacienteText.next(this.filtros.paciente);
if (this.filtros.estado) {
this.listadoInternacionService.estado.next(this.filtros.estado.id);
} else {
this.listadoInternacionService.estado.next(null);
}
this.listadoInternacionService.estado.next(this.filtros.estado?.id);
this.listadoInternacionService.obraSocial.next(this.filtros.obraSocial);
}

filtrarFecha() {
Expand All @@ -57,8 +71,6 @@ export class FiltrosInternacionComponent implements OnInit {
const params = {
desde: moment(this.filtros.fechaIngresoDesde).startOf('d').format(),
hasta: moment(this.filtros.fechaIngresoHasta).endOf('d').format(),
// egresoDesde: moment(this.filtros.fechaEgresoDesde).startOf('d').format(),
// egresoHasta: moment(this.filtros.fechaEgresoHasta).endOf('d').format(),
organizacion: this.auth.organizacion.id
};
this.requestInProgress = true;
Expand All @@ -68,3 +80,4 @@ export class FiltrosInternacionComponent implements OnInit {
);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<th rowspan="2">Dni</th>
<th rowspan="2">Fecha de ingreso</th>
<th rowspan="2">Fecha de egreso</th>
<th rowspan="2" class="w-25">Obra Social</th>
<th rowspan="2">Estado</th>
</tr>
</thead>
Expand All @@ -43,6 +44,9 @@
{{devuelveFecha(internacion,"egreso") | fecha}}
{{devuelveFecha(internacion,"egreso") | hora}}</span>
</td>
<td>
{{ internacion.paciente.obraSocial?.nombre }}
</td>
<td>
<span> {{internacion.estados[internacion.estados.length - 1].tipo}}</span>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export class ListadoInternacionService {
public fechaIngresoHasta = new BehaviorSubject<Date>(moment().toDate());
public fechaEgresoDesde = new BehaviorSubject<Date>(null);
public fechaEgresoHasta = new BehaviorSubject<Date>(null);

public estado = new BehaviorSubject<any>(null);
public obraSocial = new BehaviorSubject<any[]>(null);

constructor(
private auth: Auth,
Expand Down Expand Up @@ -45,16 +45,16 @@ export class ListadoInternacionService {
this.listaInternacionFiltrada$ = combineLatest(
this.listaInternacion$,
this.pacienteText,
this.estado
this.estado,
this.obraSocial
).pipe(
map(([listaInternacion, paciente, estado]) =>
this.filtrarListaInternacion(listaInternacion, paciente, estado)
map(([listaInternacion, paciente, estado, obraSocial]) =>
this.filtrarListaInternacion(listaInternacion, paciente, estado, obraSocial)
)
);

}

filtrarListaInternacion(listaInternacion: IPrestacion[], paciente: string, estado: string) {
filtrarListaInternacion(listaInternacion: IPrestacion[], paciente: string, estado: string, obraSocial: any) {
let listaInternacionFiltrada = listaInternacion;

if (paciente) {
Expand All @@ -68,13 +68,21 @@ export class ListadoInternacionService {
);
}
}

if (estado) {
listaInternacionFiltrada = listaInternacionFiltrada.filter((internacion: IPrestacion) =>
internacion.estados[internacion.estados.length - 1].tipo === estado
);
}

if (obraSocial) {
listaInternacionFiltrada = listaInternacionFiltrada.filter(
(internacion: IPrestacion) => {
if (obraSocial._id === 'sin-obra-social') {
return !internacion.paciente.obraSocial;
}
return internacion.paciente.obraSocial?.nombre === obraSocial.nombre;
}
);
}
return listaInternacionFiltrada;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,9 @@ import { Component, OnInit } from '@angular/core';
import { MapaCamasService } from '../../../services/mapa-camas.service';
import { Observable, combineLatest } from 'rxjs';
import { map } from 'rxjs/operators';
import { arrayToSet } from '@andes/shared';


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-camas',
Expand Down