Skip to content

Commit

Permalink
feat(RUP-415): Concepto Receta Autorización
Browse files Browse the repository at this point in the history
  • Loading branch information
aldoEMatamala committed Sep 20, 2024
1 parent 4369e2e commit d28cd27
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 4 deletions.
55 changes: 53 additions & 2 deletions src/app/modules/rup/components/ejecucion/buscador.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { RupEjecucionService } from '../../services/ejecucion.service';
import { FrecuentesProfesionalService } from '../../services/frecuentesProfesional.service';
import { PrestacionesService } from '../../services/prestaciones.service';
import { ISnomedSearchResult } from './../../interfaces/snomedSearchResult.interface';
import { ProfesionalService } from 'src/app/services/profesional.service';


@Component({
Expand Down Expand Up @@ -73,7 +74,8 @@ export class BuscadorComponent implements OnInit, OnChanges {
private buscadorService: SnomedBuscarService,
public renderer: Renderer2,
private ejecucionService: RupEjecucionService,
private plex: Plex
private plex: Plex,
public profesionalService: ProfesionalService
) {
}

Expand Down Expand Up @@ -361,7 +363,7 @@ export class BuscadorComponent implements OnInit, OnChanges {

if (this.semanticTags) {
this.results[busquedaActual]['todos'] = [];
this.filtroActual =this.semanticTags[0] as any;
this.filtroActual = this.semanticTags[0] as any;
}
}
}
Expand Down Expand Up @@ -414,6 +416,55 @@ export class BuscadorComponent implements OnInit, OnChanges {
*
* @param {any} concepto Concepto SNOMED
*/
public verificarProfesional(concepto, index) {
let permiso = false;
if (concepto.conceptId === '16076005') {// receta
if (this.auth.profesional) {
this.profesionalService.get({ documento: this.auth.usuario.documento }).subscribe(profesional => {
if (profesional.length) {
const codigosPermitidos = [1, 2, 23]; // medico, odontologo, obstetra
let motivoRechazo = null;
permiso = (profesional[0].formacionGrado.find(item => {
const profesionHabilitada = codigosPermitidos.includes(item.profesion?.codigo);
const estadoMatricula = this.verificarEstadoMatricula(item);
if (profesionHabilitada) {
motivoRechazo = estadoMatricula.value;
}
return profesionHabilitada && estadoMatricula.key;
})) !== undefined;
if (permiso) {
this.seleccionarConcepto(concepto, index);
} else {
this.plex.info('warning', motivoRechazo ? `Su matrícula se encuentra ${motivoRechazo} para emitir una Receta` : 'Sin profesión habilitada para emitir una Receta');
}
}
});
}
} else {
this.seleccionarConcepto(concepto, index);
}
}

verificarEstadoMatricula(formacionGrado) {
const estado = {
value: 'vigente',
key: false
};
if (formacionGrado.matriculacion) {
if (!formacionGrado.matriculado && new Date < formacionGrado.matriculacion[formacionGrado.matriculacion.length - 1].fin) {
estado.value = 'suspendida';
} else {
if (new Date > formacionGrado.matriculacion[formacionGrado.matriculacion.length - 1].fin) {
estado.value = 'vencida';
} else {
estado.key = true;
}
}
} else {
estado.value = 'inhabilitada';
}
return estado;
}

public seleccionarConcepto(concepto, index) {
gtag('add-concept', this.busquedaActual, this.search, index);
Expand Down
5 changes: 3 additions & 2 deletions src/app/modules/rup/components/ejecucion/buscador.html
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,12 @@ <h4 class="pt-3 pb-3 text-center">No se han encontrado resultados.</h4>
</div>
<div class="col-6 p-0 m-0">
<div class="d-flex justify-content-end">
<plex-badge size="sm" [type]="item | semanticClass: filtroActual === 'planes' || item.esSolicitud">
<plex-badge size="sm"
[type]="item | semanticClass: filtroActual === 'planes' || item.esSolicitud">
{{ (item.esSolicitud || filtroActual === 'planes') ? 'solicitud' :
item.semanticTag }}
</plex-badge>
<plex-button type="info" size="sm" icon="plus" (click)="seleccionarConcepto(item, i)"
<plex-button type="info" size="sm" icon="plus" (click)="verificarProfesional(item, i)"
tooltip="agregar a la consulta" tooltipPosition="left">
</plex-button>
<plex-button class="ml-1" type="info" size="sm" icon="graph"
Expand Down

0 comments on commit d28cd27

Please sign in to comment.