diff --git a/src/app/modules/visualizacion-informacion/components/exportar-huds/exportar-huds.component.html b/src/app/modules/visualizacion-informacion/components/exportar-huds/exportar-huds.component.html index 8f368d7f9d..a8dd2f1fbd 100644 --- a/src/app/modules/visualizacion-informacion/components/exportar-huds/exportar-huds.component.html +++ b/src/app/modules/visualizacion-informacion/components/exportar-huds/exportar-huds.component.html @@ -53,6 +53,9 @@ + + diff --git a/src/app/modules/visualizacion-informacion/components/exportar-huds/exportar-huds.component.ts b/src/app/modules/visualizacion-informacion/components/exportar-huds/exportar-huds.component.ts index 9c41a68819..2b9d32946b 100644 --- a/src/app/modules/visualizacion-informacion/components/exportar-huds/exportar-huds.component.ts +++ b/src/app/modules/visualizacion-informacion/components/exportar-huds/exportar-huds.component.ts @@ -1,5 +1,7 @@ import { Plex } from '@andes/plex'; import { Component, OnInit } from '@angular/core'; +import { Observable, EMPTY } from 'rxjs'; +import { switchMap } from 'rxjs/operators'; import { IPaciente } from 'src/app/core/mpi/interfaces/IPaciente'; import { ExportHudsService } from '../../services/export-huds.service'; import { Auth } from '@andes/auth'; @@ -28,6 +30,8 @@ export class ExportarHudsComponent implements OnInit { public turnosPrestaciones = false; public excluirVacunas; public excluirLaboratorio; + public organizaciones$: Observable; + public organizacion: any; constructor( @@ -46,6 +50,8 @@ export class ExportarHudsComponent implements OnInit { { route: '/', name: 'VISUALIZACIÓN DE INFORMACIÓN' }, { name: 'Exportar HUDS' } ]); + this.organizaciones$ = this.auth.organizaciones(); + this.organizacion = this.auth.organizacion; this.descargasPendientes(); } } @@ -70,6 +76,7 @@ export class ExportarHudsComponent implements OnInit { this.fechaDesde = null; this.fechaHasta = null; this.prestacion = null; + this.organizacion = this.auth.organizacion; } esPacienteRestringido(paciente: IPaciente) { @@ -109,9 +116,20 @@ export class ExportarHudsComponent implements OnInit { fechaDesde: this.fechaDesde, fechaHasta: this.fechaHasta, hudsCompleta: this.hudsCompleta, + organizacion: this.organizacion ? this.organizacion.id : null, excluye }; - this.exportHudsService.peticionHuds(params).subscribe((res) => { + // verifica primero que exista historial antes de crear el pedido + this.exportHudsService.checkHistory(params).pipe( + switchMap((resCheck) => { + if (resCheck.hasHistory) { + return this.exportHudsService.peticionHuds(params); + } else { + this.plex.info('warning', 'No existen registros y/o historial con los filtros seleccionados ', 'Atención'); + return EMPTY; + } + }) + ).subscribe((res) => { if (res) { this.plex.toast('success', 'Su pedido esta siendo procesado', 'Información', 2000); this.descargasPendientes(); diff --git a/src/app/modules/visualizacion-informacion/services/export-huds.service.ts b/src/app/modules/visualizacion-informacion/services/export-huds.service.ts index 01dc00f658..4c1ece2db7 100644 --- a/src/app/modules/visualizacion-informacion/services/export-huds.service.ts +++ b/src/app/modules/visualizacion-informacion/services/export-huds.service.ts @@ -21,6 +21,10 @@ export class ExportHudsService { return this.server.post(this.exportHudsUrl, data, { responseType: 'blob' } as any); } + checkHistory(data): Observable { + return this.server.post(this.exportHudsUrl + '/check-history', data); + } + descargaHuds(params): Observable { return this.server.post(this.exportHudsUrl + '/' + params.id, params, { responseType: 'blob' } as any).pipe( saveAs(params.name, 'zip')