From 1a6199360f9ef827ed3396d775102c5230a03305 Mon Sep 17 00:00:00 2001 From: aldoEMatamala Date: Wed, 23 Sep 2026 10:05:20 -0300 Subject: [PATCH] =?UTF-8?q?feat(RUP-555):=20Prescripci=C3=B3n=20de=20magis?= =?UTF-8?q?trales=20Otros?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../elementos-rup/receta-medica.component.ts | 22 ++++++++++++------- modules/recetas/receta-schema.ts | 15 ++++++++++++- modules/recetas/recetasController.ts | 11 +++++++--- modules/rup/controllers/rup.events.ts | 6 +++-- 4 files changed, 40 insertions(+), 14 deletions(-) diff --git a/modules/descargas/informe-rup/elementos-rup/receta-medica.component.ts b/modules/descargas/informe-rup/elementos-rup/receta-medica.component.ts index eb385e1806..6f6eb90cce 100644 --- a/modules/descargas/informe-rup/elementos-rup/receta-medica.component.ts +++ b/modules/descargas/informe-rup/elementos-rup/receta-medica.component.ts @@ -46,6 +46,7 @@ export class RecetaMedicaComponent extends HTMLComponent { Medicamento Cantidad Indicaciones + Dosis diaria Diagnóstico @@ -54,19 +55,24 @@ export class RecetaMedicaComponent extends HTMLComponent { {{#each registro.valor.medicamentos}} - {{#unless esMagistral}} - {{generico.term}} - {{/unless}} + {{#if esMagistralManual}} + {{ formulacionMagistral }} + {{else}} + {{#if esMagistral}} + {{ magistral.nombre }} + {{else}} + {{ generico.term }} + {{/if}} + {{/if}} {{#if esMagistral}} - {{magistral.nombre}} -
(Preparación Magistral) +
(Preparación Magistral{{#if esMagistralManual}} - Ingreso Manual{{/if}}) {{/if}} - {{ unidades }} {{presentacion.term }}(s) + {{#if esMagistralManual}}-{{else}}{{ unidades }} {{presentacion.term }}(s){{/if}} - {{ cantEnvases}} envase(s) de {{ cantidad }} {{presentacion.term }}(s) + {{#if esMagistralManual}}-{{else}}{{ cantEnvases}} envase(s){{#if cantidad}} de {{ cantidad }} {{presentacion.term }}(s){{/if}}{{/if}} {{#if dosisDiaria.dosis}} @@ -93,7 +99,7 @@ export class RecetaMedicaComponent extends HTMLComponent { {{/each}} - + {{#if esReceta}} Esta receta fue creada por emisor inscripto y valido en el Registro de Recetarios Electrónicos del Ministerio de Salud de la Nación - RL-2025-24026558-APN-SSVEIYES#MS diff --git a/modules/recetas/receta-schema.ts b/modules/recetas/receta-schema.ts index bcdee23ec0..96e0e5842d 100644 --- a/modules/recetas/receta-schema.ts +++ b/modules/recetas/receta-schema.ts @@ -107,7 +107,12 @@ const medicamentoSubschema = new mongoose.Schema({ presentacion: String, unidades: String, // (mg, cc, etc.) cantidad: Number, - cantEnvases: { type: Number, required: true }, + cantEnvases: { + type: Number, + required(this: any) { + return !this.esMagistralManual; + } + }, dosisDiaria: { dosis: { type: String, required: false }, intervalo: mongoose.SchemaTypes.Mixed, @@ -117,6 +122,8 @@ const medicamentoSubschema = new mongoose.Schema({ }, tratamientoProlongado: Boolean, esMagistral: { type: Boolean, default: false }, + esMagistralManual: { type: Boolean, default: false }, + formulacionMagistral: { type: String, required: false }, magistral: { type: { codigo: [ @@ -154,6 +161,9 @@ const medicamentoSubschema = new mongoose.Schema({ }); medicamentoSubschema.virtual('nombre').get(function (this: any) { + if (this.esMagistralManual) { + return this.formulacionMagistral || this.magistral?.nombre || ''; + } return this.esMagistral ? (this.magistral?.nombre || '') : (this.concepto?.term || ''); }); @@ -220,6 +230,9 @@ export const recetaSchema = new mongoose.Schema({ }); recetaSchema.virtual('nombre').get(function (this: any) { + if (this.medicamento?.esMagistralManual) { + return this.medicamento.formulacionMagistral || this.medicamento.magistral?.nombre || ''; + } return this.medicamento?.nombre || (this.medicamento?.esMagistral ? (this.medicamento?.magistral?.nombre || '') : (this.medicamento?.concepto?.term || '')); }); diff --git a/modules/recetas/recetasController.ts b/modules/recetas/recetasController.ts index 0203e2631b..5086e0467c 100644 --- a/modules/recetas/recetasController.ts +++ b/modules/recetas/recetasController.ts @@ -659,10 +659,12 @@ export async function create(req) { dataReceta.fechaRegistro = dataReceta.fechaRegistro ? moment(dataReceta.fechaRegistro).toDate() : moment().toDate(); dataReceta.fechaPrestacion = dataReceta.fechaPrestacion ? dataReceta.fechaPrestacion : dataReceta.fechaRegistro; const isMagistral = !!req.body.medicamento?.esMagistral; + const isMagistralManual = !!req.body.medicamento?.esMagistralManual; const medicamentoIncompleto = !req.body.medicamento || (!isMagistral && !req.body.medicamento.concepto?.conceptId) || - (isMagistral && !req.body.medicamento.magistral?.nombre) || - !req.body.medicamento.cantEnvases; + (isMagistral && !isMagistralManual && !req.body.medicamento.magistral?.nombre) || + (isMagistralManual && !req.body.medicamento.formulacionMagistral && !req.body.medicamento.magistral?.nombre) || + (!isMagistralManual && !req.body.medicamento.cantEnvases); dataReceta.origenExterno = { id: req.body.origenExterno?.id || '', app: req.user.app?.nombre.toLowerCase() || '', @@ -673,7 +675,7 @@ export async function create(req) { } else { const queryExistente: any = { idRegistro: dataReceta.idRegistro }; if (isMagistral) { - queryExistente['medicamento.magistral.nombre'] = dataReceta.medicamento.magistral?.nombre; + queryExistente['medicamento.magistral.nombre'] = dataReceta.medicamento.magistral?.nombre || dataReceta.medicamento.formulacionMagistral; } else { queryExistente['medicamento.concepto.conceptId'] = dataReceta.medicamento.concepto.conceptId; } @@ -749,6 +751,7 @@ export async function crearReceta(dataReceta, req) { const diag = medicamento.diagnostico; receta.diagnostico = (typeof diag === 'string') ? { descripcion: diag } : diag; const esMagistral = !!medicamento.esMagistral; + const esMagistralManual = !!medicamento.esMagistralManual; receta.medicamento = { concepto: esMagistral ? null : (medicamento.concepto || medicamento.generico), presentacion: medicamento.presentacion?.term || medicamento.presentacion, @@ -764,6 +767,8 @@ export async function crearReceta(dataReceta, req) { }, tratamientoProlongado, esMagistral, + esMagistralManual, + formulacionMagistral: medicamento.formulacionMagistral || null, magistral: esMagistral ? medicamento.magistral : null, tiempoTratamiento: tratamientoProlongado ? medicamento.tiempoTratamiento : null, ordenTratamiento: i, diff --git a/modules/rup/controllers/rup.events.ts b/modules/rup/controllers/rup.events.ts index 42ff8bc3be..e958337683 100644 --- a/modules/rup/controllers/rup.events.ts +++ b/modules/rup/controllers/rup.events.ts @@ -60,20 +60,22 @@ EventCore.on('prestacion:receta:create', async ({ prestacion, registro }) => { for (const medicamento of registro.valor.medicamentos) { try { const esMagistral = !!medicamento?.esMagistral; + const esMagistralManual = !!medicamento?.esMagistralManual; const conceptId = medicamento?.concepto?.conceptId || medicamento?.generico?.conceptId; + const nombreMagistral = medicamento?.formulacionMagistral || medicamento?.magistral?.nombre; if (!conceptId && !esMagistral) { logger.error('prestacion:receta:create', { idRegistro, medicamento }, 'No se pudo identificar conceptId del medicamento'); continue; } - if (esMagistral && !medicamento?.magistral?.nombre) { + if (esMagistral && !nombreMagistral) { logger.error('prestacion:receta:create', { idRegistro, medicamento }, 'No se pudo identificar nombre del medicamento magistral'); continue; } const queryReceta: any = { idRegistro }; if (esMagistral) { - queryReceta['medicamento.magistral.nombre'] = medicamento.magistral.nombre; + queryReceta['medicamento.magistral.nombre'] = nombreMagistral; } else { queryReceta['medicamento.concepto.conceptId'] = conceptId; }