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
12 changes: 11 additions & 1 deletion core-v2/mpi/paciente/paciente.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
14 changes: 5 additions & 9 deletions core-v2/mpi/paciente/paciente.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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],
Expand Down