Skip to content

Commit

Permalink
feat(elementos-rup): remove populate de requeridos
Browse files Browse the repository at this point in the history
  • Loading branch information
liquid36 committed Aug 5, 2020
1 parent d99f729 commit a318dae
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export class CamaDetalleComponent implements OnInit, OnDestroy {
public relacionesPosibles;
public especialidades;
public validadoColor;
public conceptosInternacion;
public titleColor;
public tabIndex = 0;
public editar = false;
Expand All @@ -59,7 +58,6 @@ export class CamaDetalleComponent implements OnInit, OnDestroy {
constructor(
private auth: Auth,
private router: Router,
private elementoRupService: ElementosRUPService,
private mapaCamasService: MapaCamasService
) {
}
Expand All @@ -69,11 +67,6 @@ export class CamaDetalleComponent implements OnInit, OnDestroy {

ngOnInit() {
this.permisoIngreso = this.auth.check('internacion:ingreso');

this.elementoRupService.ready.subscribe(() => {
this.conceptosInternacion = this.elementoRupService.getConceptosInternacion();
});

this.cama$ = this.mapaCamasService.selectedCama;
this.paciente$ = this.cama$.pipe(
filter(cama => !!cama.paciente),
Expand Down
4 changes: 2 additions & 2 deletions src/app/modules/rup/components/core/rup.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,8 @@ export class RUPComponent implements OnInit, AfterViewInit {
const requeridos = [];
for (let i = 0; i < this.registro.registros.length; i++) {
const concepto = this.registro.registros[i].concepto;
const requerido = this.elementoRUP.requeridos.find(r => r.concepto.conceptId === concepto.conceptId);
if (requerido) {
const requerido = this.elementoRUP.requeridos[i];
if (requerido && requerido.concepto.conceptId === concepto.conceptId) {
requeridos.push(requerido);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/modules/rup/interfaces/elementoRUP.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export interface IElementoRUP {
}

export interface IElementoRUPRequeridos {
elementoRUP: IElementoRUP;
elementoRUP?: IElementoRUP;
concepto: ISnomedConcept;
// Indica estilos para la instancia del elementoRUP
style: {
Expand Down
10 changes: 5 additions & 5 deletions src/app/modules/rup/interfaces/prestacion.registro.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ export class IPrestacionRegistro {
nombre: string;
concepto: ISnomedConcept;
// Indica si este registro está destacado
destacado: Boolean;
destacado: boolean;
// Indica si este registro es una solicitud
esSolicitud: Boolean;
esSolicitud: boolean;
// Almacena el valor del átomo, molécula o fórmula.
// Para el caso de las moléculas, el valor puede ser nulo.
valor: any;
Expand All @@ -40,9 +40,9 @@ export class IPrestacionRegistro {
transformado: any;
esPrimeraVez: boolean;

hasSections: Boolean;
isSection: Boolean;
noIndex: Boolean;
hasSections: boolean;
isSection: boolean;
noIndex: boolean;

createdAt: Date;

Expand Down
31 changes: 23 additions & 8 deletions src/app/modules/rup/services/elementosRUP.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Server } from '@andes/shared';
import { IElementoRUP } from './../interfaces/elementoRUP.interface';
import { IElementosRUPCache } from './../interfaces/elementosRUPCache.interface';
import { ISnomedConcept } from './../interfaces/snomed-concept.interface';
import { IPrestacionRegistro } from '../interfaces/prestacion.registro.interface';

const url = '/modules/rup/elementosRUP';

Expand Down Expand Up @@ -127,9 +128,9 @@ export class ElementosRUPService {
* @returns {IElementoRUP} Elemento que implementa el concepto
* @memberof ElementosRUPService
*/
elementoRegistro(registro) {
elementoRegistro(registro: IPrestacionRegistro) {
if (registro.elementoRUP) {
return this.cacheById[registro.elementoRUP];
return this.populateElemento(this.cacheById[registro.elementoRUP], registro.esSolicitud);
} else {
return this.buscarElemento(registro.concepto, registro.esSolicitud);
}
Expand Down Expand Up @@ -164,26 +165,40 @@ export class ElementosRUPService {
if (typeof concepto.conceptId === 'undefined') {
concepto = concepto[1];
}

// TODO: ver cómo resolver esto mejor...
concepto.semanticTag = concepto.semanticTag === 'plan' ? 'procedimiento' : concepto.semanticTag;
if (esSolicitud) {
let elemento = this.cacheParaSolicitud[concepto.conceptId];
if (elemento) {
return elemento;
return this.populateElemento(elemento, esSolicitud);
} else {
return this.defaultsParaSolicitud[concepto.semanticTag];
return this.populateElemento(this.defaultsParaSolicitud[concepto.semanticTag], esSolicitud);
}
} else {
let elemento = this.cache[concepto.conceptId];
if (elemento) {
return elemento;
return this.populateElemento(elemento, esSolicitud);
} else {
return this.defaults[concepto.semanticTag];
return this.populateElemento(this.defaults[concepto.semanticTag], esSolicitud);
}
}
}

/**
* Popula los requeridos de un elemento rup
*/

populateElemento(elemento: IElementoRUP, esSolicitud: boolean) {
elemento.requeridos.forEach((elem) => {
if (!elem.elementoRUP) {
elem.elementoRUP = this.buscarElemento(elem.concepto, esSolicitud);
elem.params = { ...elem.elementoRUP.params, ...(elem.params || {}) };
} else if (typeof (elem.elementoRUP as any) === 'string') {
elem.elementoRUP = this.populateElemento(this.cacheById[elem.elementoRUP as any], false);
}
});
return elemento;
}

getConceptosInternacion() {
let conceptosInternacion = {
// Lo pongo así porque no tiene sentido lo que hicieron con los otros conceptos
Expand Down

0 comments on commit a318dae

Please sign in to comment.