diff --git a/src/app/modules/rup/components/ejecucion/hudsBusqueda.component.ts b/src/app/modules/rup/components/ejecucion/hudsBusqueda.component.ts index aca4b11606..312aacfcb6 100644 --- a/src/app/modules/rup/components/ejecucion/hudsBusqueda.component.ts +++ b/src/app/modules/rup/components/ejecucion/hudsBusqueda.component.ts @@ -42,6 +42,14 @@ export class HudsBusquedaComponent implements AfterContentInit, OnInit, OnDestro hallazgosNoActivosAux: any; filtroActual; filtroTrastornos = true; + public tabIndexLaboratorio = 0; + public filtrosLaboratorio = [ + { key: 0, label: 'Laboratorio' }, + { key: 1, label: 'Microbiología' }, + { key: 2, label: 'CDA' } + ]; + public filtroTipoMuestra = ''; + public filtroPracticaSolicitada = ''; public disabledBtnCDA = false; public token: string; public secondsToUpdate = 0; @@ -82,6 +90,70 @@ export class HudsBusquedaComponent implements AfterContentInit, OnInit, OnDestro return this._prestaciones; } + get laboratoriosFiltrados() { + if (!this.laboratorios) { return []; } + + let filtrados = this.laboratorios.filter(lab => { + if (this.tabIndexLaboratorio === 0) { + return lab.TipoServicio === 'LABORATORIO'; + } else if (this.tabIndexLaboratorio === 1) { + return lab.TipoServicio === 'MICROBIOLOGIA'; + } else if (this.tabIndexLaboratorio === 2) { + return lab.tipo === 'cda'; + } + return true; + }); + + if (this.tabIndexLaboratorio !== 2) { + if (this.tabIndexLaboratorio === 1 && this.filtroTipoMuestra && this.filtroTipoMuestra.length >= 5) { + filtrados = filtrados.filter(lab => lab.tipoMuestra && lab.tipoMuestra.toLowerCase().includes(this.filtroTipoMuestra.toLowerCase())); + } + if (this.filtroPracticaSolicitada && this.filtroPracticaSolicitada.length >= 5) { + filtrados = filtrados.filter(lab => lab.practicasSolicitadas && lab.practicasSolicitadas.toLowerCase().includes(this.filtroPracticaSolicitada.toLowerCase())); + } + } + + return filtrados; + } + + getMedicoSolicitante(laboratorio: any) { + if (laboratorio?.medicoSolicitante) { + return laboratorio.medicoSolicitante; + } + + const prof = laboratorio?.data?.profesional || laboratorio?.profesional; + if (!prof) { + return null; + } + + if (typeof prof === 'string') { + if (prof.includes('NO INFORMADO') || prof === '-, ') { + return 'NO INFORMADO'; + } + return prof; + } + + if (prof.nombre === 'NO INFORMADO' || prof.apellido === 'NO INFORMADO') { + return 'NO INFORMADO'; + } + + const nombre = prof.nombre || ''; + const apellido = prof.apellido || ''; + if (nombre && apellido && apellido !== '-') { + return `${apellido}, ${nombre}`; + } else if (nombre) { + return nombre; + } else if (apellido && apellido !== '-') { + return apellido; + } + + return null; + } + + onChangeTabLaboratorio(index) { + this.tabIndexLaboratorio = index; + } + set prestaciones(value) { this._prestaciones = value.sort((a, b) => { return moment(b.fecha).diff(a.fecha); @@ -312,6 +384,8 @@ export class HudsBusquedaComponent implements AfterContentInit, OnInit, OnDestro this.fechaInicio = this.fechaFin = this.prestacionSeleccionada = null; this.fechaInicioRecetas = this.fechaFinRecetas = null; this.tipoPrescripcionSeleccionado = this.tiposPrescripcion[0]; + this.filtroTipoMuestra = ''; + this.filtroPracticaSolicitada = ''; this.filtrar(); if (this.filtroActual === 'recetas') { this.filtrarRecetas(); diff --git a/src/app/modules/rup/components/ejecucion/hudsBusqueda.html b/src/app/modules/rup/components/ejecucion/hudsBusqueda.html index 527905031d..738c06ddea 100644 --- a/src/app/modules/rup/components/ejecucion/hudsBusqueda.html +++ b/src/app/modules/rup/components/ejecucion/hudsBusqueda.html @@ -25,13 +25,19 @@