Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ export class RecetaMedicaComponent extends HTMLComponent {
<thead>
<tr>
<th>Medicamento</th>
<th>Presentación</th>
<th>Cantidad</th>
<th>Dosis diaria</th>
<th>Diagnóstico</th>
<th>Obra Social</th>
</tr>
</thead>
<tbody>
Expand All @@ -41,9 +41,6 @@ export class RecetaMedicaComponent extends HTMLComponent {
<tr>
<td> {{generico.term}} </td>
<td>
{{ unidades }} {{presentacion.term }}(s)
</td>
<td>
{{ cantEnvases}} envase(s) de {{ cantidad }} {{presentacion.term }}(s)
</td>
<td>
Expand All @@ -58,10 +55,20 @@ export class RecetaMedicaComponent extends HTMLComponent {
<td>
{{ diagnostico.term }}
</td>
<td>
{{#if obraSocial}}
{{obraSocial.nombre}}
{{#if obraSocial.numeroAfiliado}}
<br><small>Af. {{obraSocial.numeroAfiliado}}</small>
{{/if}}
{{else}}
-
{{/if}}
</td>
</tr>
{{/each}}
<tr>
<td colspan="6" style="font-weight: bold;font-style: italic;">
<td colspan="5" style="font-weight: bold;font-style: italic;">
{{#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
Expand Down Expand Up @@ -91,8 +98,40 @@ del Ministerio de Salud de la Nación - RL-2025-24026558-APN-SSVEIYES#MS

const finalIdReceta = idReceta || this.registro.id;

let obraSocial = this.prestacion.paciente?.obraSocial || null;
if (Array.isArray(obraSocial)) {
obraSocial = obraSocial[0];
}
let obraSocialObj = null;
if (obraSocial) {
if (typeof obraSocial === 'string') {
obraSocialObj = {
nombre: obraSocial,
numeroAfiliado: ''
};
} else {
obraSocialObj = {
nombre: obraSocial.nombre || obraSocial.financiador || '',
numeroAfiliado: obraSocial.numeroAfiliado || ''
};
}
}

const registroClone = this.registro.toObject ? this.registro.toObject() : JSON.parse(JSON.stringify(this.registro));
if (registroClone.valor?.medicamentos) {
registroClone.valor.medicamentos = registroClone.valor.medicamentos.map(med => {
return {
...med,
obraSocial: med.obraSocial || (obraSocialObj ? {
nombre: obraSocialObj.nombre,
numeroAfiliado: obraSocialObj.numeroAfiliado
} : null)
};
});
}

this.data = {
registro: this.registro,
registro: registroClone,
esReceta: this.depth ? 1 : 0, // Si es 0 no muestra el código de barras
idReceta: finalIdReceta,
barcodeBase64: await generateBarcodeBase64(finalIdReceta, 'code128')
Expand Down
4 changes: 4 additions & 0 deletions modules/recetas/receta-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ const medicamentoSubschema = new mongoose.Schema({
numero: {
type: Number,
required: false
},
obraSocial: {
type: mongoose.SchemaTypes.Mixed,
required: false
}
});

Expand Down
7 changes: 5 additions & 2 deletions modules/recetas/recetasController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -727,11 +727,14 @@ export async function crearReceta(dataReceta, req) {
tipoReceta: medicamento.tipoReceta?.id || medicamento.tipoReceta || 'simple',
serie: medicamento.serie,
numero: medicamento.numero,
obraSocial: medicamento.obraSocial || dataReceta.paciente?.obraSocial || null
};
receta.estados = i < 1 ? [{ tipo: 'vigente' }] : [{ tipo: 'pendiente' }];
receta.estadosDispensa = [{ tipo: 'sin-dispensa', fecha: moment().toDate() }];
receta.paciente = dataReceta.paciente;
receta.paciente.obraSocial = dataReceta.paciente.obraSocial;

const pacienteClone = dataReceta.paciente.toObject ? dataReceta.paciente.toObject() : JSON.parse(JSON.stringify(dataReceta.paciente));
receta.paciente = pacienteClone;
receta.paciente.obraSocial = null;
receta.paciente.id = dataReceta.paciente.id || dataReceta.paciente._id;
receta.profesional = dataReceta.profesional;
receta.profesional._id = dataReceta.profesional.id || dataReceta.profesional._id; // revisar como se generan ids en ambos casos
Expand Down
Loading