From 178af77e4fd11504f6320345c17e09c56c2d3f90 Mon Sep 17 00:00:00 2001 From: aldoEMatamala Date: Mon, 23 Sep 2024 11:22:30 -0300 Subject: [PATCH] =?UTF-8?q?fix(RUP-395):=20Receta=20-=20modificar=20mol?= =?UTF-8?q?=C3=A9cula-2vuelta=20+=20dosis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../elementos/recetaMedica.component.ts | 131 +++++++++++++----- .../components/elementos/recetaMedica.html | 131 ++++++++++++------ .../components/elementos/recetaMedica.scss | 14 ++ 3 files changed, 200 insertions(+), 76 deletions(-) create mode 100644 src/app/modules/rup/components/elementos/recetaMedica.scss diff --git a/src/app/modules/rup/components/elementos/recetaMedica.component.ts b/src/app/modules/rup/components/elementos/recetaMedica.component.ts index bca9264467..723e6b666d 100644 --- a/src/app/modules/rup/components/elementos/recetaMedica.component.ts +++ b/src/app/modules/rup/components/elementos/recetaMedica.component.ts @@ -1,34 +1,52 @@ -import { Component, Output, Input, EventEmitter, OnInit } from '@angular/core'; +import { Component, Output, Input, EventEmitter, OnInit, AfterViewInit, ViewChild, ElementRef } from '@angular/core'; import { RUPComponent } from '../core/rup.component'; import { RupElement } from '.'; import { forkJoin } from 'rxjs'; import { Unsubscribe } from '@andes/shared'; +import { NgForm } from '@angular/forms'; @Component({ selector: 'rup-recetaMedica', - templateUrl: 'recetaMedica.html' + templateUrl: 'recetaMedica.html', + styleUrls: ['recetaMedica.scss'], }) + + @RupElement('RecetaMedicaComponent') export class RecetaMedicaComponent extends RUPComponent implements OnInit { + + @ViewChild('formMedicamento') formMedicamento: NgForm; + public medicamento: any = { generico: null, presentacion: null, - unidades: null, cantidad: null, + cantEnvases: null, diagnostico: '', - tipoReceta: 'simple', + tipoReceta: 'Simple', tratamientoProlongado: false, + tiempoTratamiento: null, dosisDiaria: { - cantidad: null, - dias: null + dosis: null, + frecuencia: null, + dias: null, + notaMedica: null } }; + public horas = []; + public collapse = false; + public diagnosticos = []; public unidades = []; public genericos = []; + public registros = []; + public comprimidosEditados = false; public opcionesTipoReceta = [ - { id: 'simple', label: 'Simple' }, { id: 'duplicado', label: 'Duplicado' }, { id: 'triplicado', label: 'Triplicado' } ]; + public tiemposTratamiento = [ + { id: '3meses', nombre: '3 meses' }, + { id: '6meses', nombre: '6 meses' } + ]; ngOnInit() { if (!this.registro.valor) { this.registro.valor = {}; @@ -36,10 +54,20 @@ export class RecetaMedicaComponent extends RUPComponent implements OnInit { if (!this.registro.valor.medicamentos) { this.registro.valor.medicamentos = []; } + this.registros = this.prestacion.ejecucion.registros.filter(reg => { + reg.nombre !== 'receta'; + } + ).map(reg => { if (reg.nombre !== 'receta') { return { id: reg.id, nombre: reg.nombre, elementoRUP: reg.elementoRUP }; } }); + for (let i = 1; i <= 24; i++) { + this.horas.push({ id: i, nombre: i + ' hora' + (i > 1 ? 's' : '') }); + } + } + @Unsubscribe() loadMedicamentoGenerico(event) { + this.comprimidosEditados = false; const input = event.query; if (input && input.length > 2) { const query: any = { @@ -51,11 +79,36 @@ export class RecetaMedicaComponent extends RUPComponent implements OnInit { event.callback([]); } } + loadRegistros() { + this.registros = this.prestacion.ejecucion.registros + .filter(reg => reg.nombre !== 'receta') + .map(reg => { + return { + id: reg.id, + nombre: reg.nombre, + elementoRUP: reg.elementoRUP + }; + }); + + }; + editarComprimidos() { + if (!this.comprimidosEditados) { + this.plex.confirm('La cantidad recetada no se encuentra en ninguna presentación comercial ¿Desea continuar?', 'Atención').then(confirmacion => { + if (confirmacion) { + this.medicamento.cantidad = 0; + this.comprimidosEditados = true; + } + }); + } else { + this.comprimidosEditados = false; + } + + } loadPresentaciones() { - this.medicamento.unidades = null; - this.medicamento.presentacion = null; this.medicamento.cantidad = null; + this.medicamento.presentacion = null; + this.medicamento.cantEnvases = null; this.unidades = []; if (this.medicamento.generico) { const queryPresentacion: any = { @@ -67,8 +120,9 @@ export class RecetaMedicaComponent extends RUPComponent implements OnInit { search: '' }; forkJoin( - [this.snomedService.get(queryPresentacion), - this.snomedService.get(queryUnidades)] + [ + this.snomedService.get(queryPresentacion), + this.snomedService.get(queryUnidades)] ).subscribe(([resultado, presentaciones]) => { this.medicamento.presentacion = resultado[0]; this.unidades = presentaciones.map(elto => { @@ -78,33 +132,35 @@ export class RecetaMedicaComponent extends RUPComponent implements OnInit { } } + agregarMedicamento(form) { if (form.formValid) { - if (this.registro.valor.medicamentos.length < this.params.limiteMedicamentos) { - if (this.medicamento.unidades.valor) { - this.medicamento.unidades = Number(this.medicamento.unidades.valor); - } - this.registro.valor.medicamentos.push(this.medicamento); - this.unidades = []; - this.medicamento = { - generico: null, - presentacion: null, - unidades: null, - cantidad: null, - diagnostico: '', - tipoReceta: 'simple', - tratamientoProlongado: false, - dosisDiaria: { - cantidad: null, - dias: null - } - }; - } else { - this.plex.toast('warning', `No se permite cargar más de ${this.params.limiteMedicamentos} medicamentos.`); + if (this.medicamento.cantidad?.valor) { + this.medicamento.cantidad = Number(this.medicamento.cantidad.valor); } + this.registro.valor.medicamentos.push(this.medicamento); + this.unidades = []; + this.medicamento = { + generico: null, + presentacion: null, + cantidad: null, + cantEnvases: null, + diagnostico: '', + tipoReceta: 'Simple', + tratamientoProlongado: false, + tiempoTratamiento: null, + dosisDiaria: { + frecuencia: null, + dias: null, + notaMedica: null + } + }; + this.formMedicamento.reset(); + this.formMedicamento.form.markAsPristine(); + this.formMedicamento.form.markAsUntouched(); + } } - borrarMedicamento(medicamento) { this.plex.confirm('¿Está seguro que desea eliminar el medicamento de la receta?').then((resultado) => { if (resultado) { @@ -113,4 +169,13 @@ export class RecetaMedicaComponent extends RUPComponent implements OnInit { } }); } + colapsar() { + this.collapse = !this.collapse; + } + truncateDiagnostico(nombre: string): string { + if (nombre.length > 20) { + return nombre.substring(0, 20) + '...'; + } + return nombre; + } } diff --git a/src/app/modules/rup/components/elementos/recetaMedica.html b/src/app/modules/rup/components/elementos/recetaMedica.html index 83cee0a73b..99a1541828 100644 --- a/src/app/modules/rup/components/elementos/recetaMedica.html +++ b/src/app/modules/rup/components/elementos/recetaMedica.html @@ -1,69 +1,114 @@ -
- + + + + + + + - - - + +
+ + + + + + +
+
+ + + - - - - - + + + + + + + + + +
+ + + - - - - +
+ + + + + - - - - + +
+
+ + + + + + + + +
+
- Agregar - +
+ + Agregar + +
- + - - Diagnóstico + + + + + {{ truncateDiagnostico(item.diagnostico.nombre) }} Tratamiento prolongado - {{item.tipoReceta}} + {{item.tipoReceta}}
- + - - Diagnóstico + + + {{ truncateDiagnostico(item.diagnostico.nombre) }} + Tratamiento prolongado - {{item.tipoReceta}} + {{item.tipoReceta}} -
+ \ No newline at end of file diff --git a/src/app/modules/rup/components/elementos/recetaMedica.scss b/src/app/modules/rup/components/elementos/recetaMedica.scss new file mode 100644 index 0000000000..76c27d1d7e --- /dev/null +++ b/src/app/modules/rup/components/elementos/recetaMedica.scss @@ -0,0 +1,14 @@ +.formEditar { + margin-right: 0; + display: inline-block; + width: 85%; +} + +.select-container { + display: flex; + align-items: center; +} + +.select-container plex-select { + margin-right: 10px; +} \ No newline at end of file