From 2cdf1f6e6d29330fd1b708fc806d49a637263d99 Mon Sep 17 00:00:00 2001 From: nicolasarana <90768149+nicolasarana@users.noreply.github.com> Date: Thu, 22 Jan 2026 14:13:47 -0300 Subject: [PATCH] feat(MPI):"Cambiar objeto en relaciones por ID" --- core-v2/mpi/paciente/paciente.controller.ts | 12 +++++++++++- core-v2/mpi/paciente/paciente.schema.ts | 14 +++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/core-v2/mpi/paciente/paciente.controller.ts b/core-v2/mpi/paciente/paciente.controller.ts index 6a75a82e35..6d12c0232d 100644 --- a/core-v2/mpi/paciente/paciente.controller.ts +++ b/core-v2/mpi/paciente/paciente.controller.ts @@ -112,6 +112,10 @@ export async function findById(id: string | String | Types.ObjectId, options = n if (fields) { queryFind.select(fields); } + queryFind.populate({ + path: 'relaciones.referencia', + select: 'nombre apellido documento numeroIdentificacion fechaNacimiento fechaFallecimiento fotoId sexo genero activo' + }); const paciente = await queryFind; EventCore.emitAsync('mpi:pacientes:findById', paciente); return paciente; @@ -218,7 +222,13 @@ export async function multimatch(searchText: string, filter: any, options?: any) }; const skip = parseInt(options.skip || 0, 10); const limit = parseInt(options.limit || 30, 10); - const pacientes = await Paciente.find(query).skip(skip).limit(limit); + const pacientes = await Paciente.find(query) + .skip(skip) + .limit(limit) + .populate({ + path: 'relaciones.referencia', + select: 'nombre apellido documento numeroIdentificacion fechaNacimiento fechaFallecimiento fotoId sexo genero activo' + }); return pacientes; } diff --git a/core-v2/mpi/paciente/paciente.schema.ts b/core-v2/mpi/paciente/paciente.schema.ts index e783b66e1c..bc896a048b 100644 --- a/core-v2/mpi/paciente/paciente.schema.ts +++ b/core-v2/mpi/paciente/paciente.schema.ts @@ -71,7 +71,8 @@ export const PacienteSchema: mongoose.Schema = new mongoose.Schema({ id: mongoose.Schema.Types.ObjectId, nombre: String, apellido: String, - documento: Number }, + documento: Number + }, registradoEn: Date }, estadoCivil: ESTADOCIVIL, @@ -91,19 +92,14 @@ export const PacienteSchema: mongoose.Schema = new mongoose.Schema({ required: false }, // -------------------- + relaciones: [{ relacion: ParentescoSchema, referencia: { type: mongoose.Schema.Types.ObjectId, - ref: 'paciente' + ref: 'paciente_2', + required: true }, - nombre: String, - apellido: String, - documento: String, - fechaNacimiento: Date, - fechaFallecimiento: Date, - numeroIdentificacion: String, - fotoId: mongoose.Schema.Types.ObjectId, activo: Boolean }], financiador: [FinanciadorSchema],