Skip to content

Commit

Permalink
feat(RUP): pide conceptos asociados a solicitudes
Browse files Browse the repository at this point in the history
  • Loading branch information
ma7payne committed Nov 4, 2024
1 parent 50b0b9f commit e2c13ba
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 18 deletions.
16 changes: 12 additions & 4 deletions src/app/modules/rup/components/core/rup.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Auth } from '@andes/auth';
import { Plex, PlexVisualizadorService } from '@andes/plex';
import { calcularEdad } from '@andes/shared';
import { AfterViewInit, Component, ComponentFactoryResolver, ElementRef, EventEmitter, Input, OnDestroy, OnInit, Optional, Output, QueryList, ViewChild, ViewChildren, ViewContainerRef, ViewEncapsulation } from '@angular/core';
import { AfterViewInit, Component, ComponentFactoryResolver, ElementRef, EventEmitter, Input, OnChanges, OnDestroy, OnInit, Optional, Output, QueryList, SimpleChanges, ViewChild, ViewChildren, ViewContainerRef, ViewEncapsulation } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
import { ActivatedRoute } from '@angular/router';
import { Engine } from 'json-rules-engine';
Expand Down Expand Up @@ -38,7 +38,7 @@ import { PrestacionesService } from './../../services/prestaciones.service';
encapsulation: ViewEncapsulation.None,
template: ''
})
export class RUPComponent implements OnInit, AfterViewInit, OnDestroy {
export class RUPComponent implements OnInit, AfterViewInit, OnDestroy, OnChanges {
@ViewChildren(RUPComponent) rupElements: QueryList<RUPComponent>;
@ViewChild('form', { static: false }) formulario: any;
public rupInstance: any;
Expand All @@ -53,6 +53,7 @@ export class RUPComponent implements OnInit, AfterViewInit, OnDestroy {
@Input() params: any;
@Input() style: any;
@Input() habilitado: any;
@Input() public conceptosAsociados: any = [];

public mensaje: any = {};

Expand Down Expand Up @@ -104,6 +105,7 @@ export class RUPComponent implements OnInit, AfterViewInit, OnDestroy {
componentReference.instance['params'] = this.params;
componentReference.instance['style'] = this.style;
componentReference.instance['habilitado'] = this.habilitado;
componentReference.instance['conceptosAsociados'] = this.conceptosAsociados || [];

// Event bubbling
componentReference.instance['change'].subscribe(value => {
Expand Down Expand Up @@ -150,10 +152,10 @@ export class RUPComponent implements OnInit, AfterViewInit, OnDestroy {
public plantillasService: PlantillasService,
public vacunasService: VacunasService,
public driveService: DriveService,
@Optional() public ejecucionService: RupEjecucionService,
public pacienteService: PacienteService,
public plexVisualizador: PlexVisualizadorService,
public constantesService: ConstantesService
public constantesService: ConstantesService,
@Optional() public ejecucionService: RupEjecucionService
) {
}

Expand All @@ -172,6 +174,12 @@ export class RUPComponent implements OnInit, AfterViewInit, OnDestroy {
}
}

ngOnChanges(changes: SimpleChanges): void {
if (this.rupInstance) {
this.rupInstance['conceptosAsociados'] = changes.conceptosAsociados.currentValue[0] || [];
}
}

ngAfterViewInit() {
if (!this.soloValores) {
const seccionElement = document.querySelectorAll('rup-seccionnado-component plex-panel div.collapse.show div.relacionado');
Expand Down
2 changes: 1 addition & 1 deletion src/app/modules/rup/components/core/rup.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class="col-{{ item.style.columns }} mr-{{ item.style?.offset ? item.style.offset : '0' }}">
<rup [elementoRUP]="item.elementoRUP" [paciente]="paciente" [params]="item.params"
[prestacion]="prestacion" [registro]="registro.registros[i]" [soloValores]="soloValores"
[style]="item.style" (change)="emitChange($event)">
[style]="item.style" (change)="emitChange($event)" [conceptosAsociados]="conceptosAsociados">
</rup>
</div>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { Plex } from '@andes/plex';
import { PlexHelpComponent } from '@andes/plex/src/lib/help/help.component';
import { Component, OnDestroy, OnInit, QueryList, ViewChildren, ViewEncapsulation } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { of } from 'rxjs';
import { Subject } from 'rxjs';
import { of, Subject } from 'rxjs';
import { filter, map, switchMap, takeUntil, tap } from 'rxjs/operators';
import { SnomedService } from 'src/app/apps/mitos/services/snomed.service';
import { ConstantesService } from 'src/app/services/constantes.service';
import { HeaderPacienteComponent } from '../../../../components/paciente/headerPaciente.component';
import { SnomedBuscarService } from '../../../../components/snomed/snomed-buscar.service';
import { IPaciente } from '../../../../core/mpi/interfaces/IPaciente';
Expand Down Expand Up @@ -98,6 +99,8 @@ export class PrestacionEjecucionComponent implements OnInit, OnDestroy {

public hasPacs = false;

public conceptosAsociados;

constructor(
public servicioPrestacion: PrestacionesService,
public elementosRUPService: ElementosRUPService,
Expand All @@ -108,9 +111,11 @@ export class PrestacionEjecucionComponent implements OnInit, OnDestroy {
private servicioPaciente: PacienteService,
private conceptObserverService: ConceptObserverService,
private buscadorService: SnomedBuscarService,
private SNOMED: SnomedService,
public huds: HUDSService,
public ps: PlantillasService,
public ejecucionService: RupEjecucionService,
public constantesService: ConstantesService
) { }

/**
Expand Down Expand Up @@ -237,6 +242,8 @@ export class PrestacionEjecucionComponent implements OnInit, OnDestroy {
}
}

this.buscarRelaciones();

}, (err) => {
if (err) {
this.plex.info('danger', err, 'Error');
Expand All @@ -260,6 +267,23 @@ export class PrestacionEjecucionComponent implements OnInit, OnDestroy {
});
}

buscarRelaciones() {
const registros = getRegistros(this.prestacion);

this.constantesService.search({ source: 'solicitud:conceptosAsociados' }).subscribe(async (constantes) => {
const query = constantes[0].query;
// buscar conceptos snomes a partirde la constante recibida
this.SNOMED.get({
search: query
}).subscribe((resultados) => {
const conceptos = resultados.map(concepto => concepto.conceptId);

this.conceptosAsociados = registros.filter((registro) => conceptos.includes(registro.concepto.conceptId));
});
});

}

cargarPrestacionAsociada() {
this.servicioPrestacion.getByPaciente(this.paciente.id, false).subscribe(prestaciones => {
const validadas = prestaciones.filter(p => p.estados[p.estados.length - 1].tipo === 'validada');
Expand Down Expand Up @@ -440,6 +464,7 @@ export class PrestacionEjecucionComponent implements OnInit, OnDestroy {
this.indexEliminar = null;
this.confirmarEliminar = false;
this.scopeEliminar = '';
this.buscarRelaciones();
}
}

Expand Down Expand Up @@ -499,6 +524,9 @@ export class PrestacionEjecucionComponent implements OnInit, OnDestroy {
// Agregamos al array de registros
this.prestacion.ejecucion.registros = [...this.prestacion.ejecucion.registros, nuevoRegistro];
this.activeIndex = 0;

this.buscarRelaciones();

return nuevoRegistro;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@
<rup [elementoRUP]="elementosRUPService.elementoRegistro(registro)"
[prestacion]="prestacion" [paciente]="paciente" [registro]="registro"
[soloValores]="false" (ejecutarAccion)="recibirAccion($event, 'tab')"
[params]="elementosRUPService.getParams(registro)">
[params]="elementosRUPService.getParams(registro)"
[conceptosAsociados]="conceptosAsociados">
</rup>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AfterViewInit, Component, OnInit } from '@angular/core';
import { Component, Input, OnInit } from '@angular/core';
import { RupElement } from '.';
import { RUPComponent } from './../core/rup.component';

Expand All @@ -7,21 +7,17 @@ import { RUPComponent } from './../core/rup.component';
templateUrl: 'solicitudPrestacionDefault.html'
})
@RupElement('SolicitudPrestacionDefaultComponent')
export class SolicitudPrestacionDefaultComponent extends RUPComponent implements OnInit, AfterViewInit {

export class SolicitudPrestacionDefaultComponent extends RUPComponent implements OnInit {
public reglasMatch = [];
public reglaSelected = null;
public formulario = null;
public profesionales = '';
public organizaciones: any[] = [];
public conceptoDestacado: any;

data = {};

ngAfterViewInit() {
setTimeout(() => {
}, 300);
}

@Input() public conceptosAsociados: any;

ngOnInit() {
if (!this.registro.valor) {
Expand Down Expand Up @@ -85,4 +81,8 @@ export class SolicitudPrestacionDefaultComponent extends RUPComponent implements
const value = this.registro.valor.solicitudPrestacion;
return !value.motivo && !value.indicaciones && !value.organizacionDestino;
}

onSelect(event) {

}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<ng-container *ngIf="!soloValores">
<div class="row">
<div class="col-md">
<plex-text label="Diagnóstico/Motivo" multiline="true" [autoFocus]="true"
[(ngModel)]="registro.valor.solicitudPrestacion.motivo" name="motivo"></plex-text>
<plex-select [(ngModel)]="conceptoDestacado" [data]="conceptosAsociados" name="conceptoAsociado"
[required]="false" label="Diagnóstico/Motivo" (change)="onSelect($event)">
</plex-select>
</div>
</div>
<div class="row">
Expand Down

0 comments on commit e2c13ba

Please sign in to comment.