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
4 changes: 2 additions & 2 deletions core-v2/mpi/paciente/paciente.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ export const PacienteSubSchema: mongoose.Schema = new mongoose.Schema({
nombre: String,
apellido: String,
documento: String,
cuil: String,
fechaNacimiento: Date,
sexo: SEXO,
genero: String,
Expand All @@ -165,8 +166,7 @@ export const PacienteSubSchema: mongoose.Schema = new mongoose.Schema({
localidad: NombreSchemaV2,
zona: NombreSchemaV2,
areaPrograma: NombreSchemaV2,
addAt: Date

addAt: Date,

}, { _id: false });

Expand Down
2 changes: 1 addition & 1 deletion core-v2/mpi/validacion/validacion.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function identidadSinAcentos(ciudadano) {
* Busca en fuentes auntenticas los datos de un ciudadano.
*/

function generarCUIL(dni, sexo) {
export function generarCUIL(dni, sexo) {
const sexoNorm = (sexo || '').toString().trim().toLowerCase();
let sexoFinal = 'M';
if (sexoNorm.startsWith('f')) {
Expand Down
5 changes: 5 additions & 0 deletions modules/recetas/receta-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ const profesionalSubschema = new mongoose.Schema({
profesion: String,
matricula: Number,
especialidad: String,
efector: {
Copy link
Contributor

@MCele MCele Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me hace ruido que el dato del efector quede dentro del sub-esquema de profesional. De todos modos, me surge la duda si no se podría haber utilizado los datos de organización que ya contiene la receta (hoy en día las recetas recibidas desde recetar en organizacion sólo guardan { nombre: "recetar"} y ese dato también se encuentra en otros campos como origenExterno.
Incluso chusmeando un poco más el esquema de api veo que está la variable dentro de estados de la receta "organizacionExterna" no se usa para nada. No se si la usaría dentro de los estados, pero al menos se podría aprovecha para borrar (igual esto último tampoco es taaan necesario, solo se me ocurría como boys scouting)

id: String,
nombre: String,
direccion: String
}
});

const medicamentoSubschema = new mongoose.Schema({
Expand Down
3 changes: 2 additions & 1 deletion modules/recetas/recetasController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,8 @@ export async function create(req) {
documento: profAndes.documento,
profesion: profesionGrado,
especialidad: especialidades,
matricula: matriculaGrado
matricula: matriculaGrado,
efector: profRecetar.efector || null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idem anterior

};
}
return await crearReceta(dataReceta, req);
Expand Down
6 changes: 6 additions & 0 deletions modules/rup/controllers/rup.events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { getProfesionActualizada, crearReceta } from '../../recetas/recetasContr
import * as moment from 'moment';
import { Receta } from '../../recetas/receta-schema';
import { rupEventsLog as logger } from './rup.events.log';
import { generarCUIL } from '../../../core-v2/mpi/validacion/validacion.controller';

EventCore.on('prestacion:receta:create', async ({ prestacion, registro }) => {
try {
Expand All @@ -25,6 +26,8 @@ EventCore.on('prestacion:receta:create', async ({ prestacion, registro }) => {
nombre: prestacion.ejecucion.organizacion.nombre
};

const pacienteCUIL = prestacion.paciente.cuil || generarCUIL(prestacion.paciente.documento, prestacion.paciente.sexo);

const dataReceta = {
idPrestacion: prestacion.id,
idRegistro,
Expand All @@ -36,6 +39,9 @@ EventCore.on('prestacion:receta:create', async ({ prestacion, registro }) => {
medicamento: null,
diagnostico: null,
};

dataReceta.paciente.cuil = pacienteCUIL;

for (const medicamento of registro.valor.medicamentos) {
const receta: any = await Receta.findOne({
'medicamento.concepto.conceptId': medicamento.generico.conceptId,
Expand Down