Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
<plex-bool type="checkbox" name="alergia" [(ngModel)]="excluirLaboratorio" label="Excluir Laboratorios">
</plex-bool>
</div>
<plex-select [data]="organizaciones$ | async" label="Organización"
[(ngModel)]="organizacion" name="organizacion">
</plex-select>
<plex-select grow="full" label="Prestaciones" name="prestacion" idField="conceptId"
[(ngModel)]="prestacion" tmPrestaciones [preload]="true">
</plex-select>
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -28,6 +30,8 @@ export class ExportarHudsComponent implements OnInit {
public turnosPrestaciones = false;
public excluirVacunas;
public excluirLaboratorio;
public organizaciones$: Observable<any>;
public organizacion: any;


constructor(
Expand All @@ -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();
}
}
Expand All @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export class ExportHudsService {
return this.server.post(this.exportHudsUrl, data, { responseType: 'blob' } as any);
}

checkHistory(data): Observable<any> {
return this.server.post(this.exportHudsUrl + '/check-history', data);
}

descargaHuds(params): Observable<any> {
return this.server.post(this.exportHudsUrl + '/' + params.id, params, { responseType: 'blob' } as any).pipe(
saveAs(params.name, 'zip')
Expand Down
Loading