diff --git a/src/app/modules/rup/components/elementos/recetaMedica.component.ts b/src/app/modules/rup/components/elementos/recetaMedica.component.ts index 3280821edc..ca34bf01f9 100644 --- a/src/app/modules/rup/components/elementos/recetaMedica.component.ts +++ b/src/app/modules/rup/components/elementos/recetaMedica.component.ts @@ -27,6 +27,7 @@ export class RecetaMedicaComponent extends RUPComponent implements OnInit, OnCha tiempoTratamiento: null, serie: null, numero: null, + esMagistral: false, dosisDiaria: { dosis: null, frecuencia: null, @@ -118,17 +119,39 @@ export class RecetaMedicaComponent extends RUPComponent implements OnInit, OnCha @Unsubscribe() loadMedicamentoGenerico(event) { const input = event.query; - if (input && input.length > 2 && this.eclMedicamentos) { - const query: any = { - expression: this.eclMedicamentos.valor, - search: input - }; - this.snomedService.get(query).subscribe(event.callback); + if (input && input.length > 2) { + if (this.medicamento.esMagistral) { + this.recetasService.getInsumos({ termino: input, tipo: 'magistral' }).subscribe(insumos => { + const mappedInsumos = insumos.map(i => { + return { + ...i, + term: i.nombre, + conceptId: i.id + }; + }); + event.callback(mappedInsumos); + }); + } else if (this.eclMedicamentos) { + const query = { + expression: this.eclMedicamentos.valor, + search: input + }; + this.snomedService.get(query).subscribe(event.callback); + } else { + event.callback([]); + } } else { event.callback([]); } } + onChangeMagistral() { + this.medicamento.generico = null; + this.medicamento.presentacion = null; + this.unidades = []; + this.deshacerCantidadManual(); + } + loadRegistros() { this.registros = [ ...this.prestacion.ejecucion.registros @@ -142,9 +165,16 @@ export class RecetaMedicaComponent extends RUPComponent implements OnInit, OnCha loadPresentaciones() { this.deshacerCantidadManual(); this.loading = true; - this.medicamento.cantidad = null; this.medicamento.presentacion = null; this.medicamento.cantEnvases = null; + + if (this.medicamento.esMagistral) { + this.unidades = []; + this.ingresoCantidadManual = true; + this.loading = false; + return; + } + if (this.medicamento.generico && this.eclPresentaciones && this.eclMedicamentosComerciales) { const queryPresentacion: any = { expression: this.eclPresentaciones.valor.replace('#MG#', this.medicamento.generico.conceptId), @@ -279,6 +309,7 @@ export class RecetaMedicaComponent extends RUPComponent implements OnInit, OnCha tiempoTratamiento: null, serie: null, numero: null, + esMagistral: false, dosisDiaria: { frecuencia: null, dias: null, diff --git a/src/app/modules/rup/components/elementos/recetaMedica.html b/src/app/modules/rup/components/elementos/recetaMedica.html index 3d76d87231..344c20782f 100644 --- a/src/app/modules/rup/components/elementos/recetaMedica.html +++ b/src/app/modules/rup/components/elementos/recetaMedica.html @@ -37,10 +37,20 @@ +
@@ -157,6 +160,9 @@