From 6b89af3084ef9fc91a8d2f9ddd864aa47c33ad8d Mon Sep 17 00:00:00 2001 From: nicolasarana <90768149+nicolasarana@users.noreply.github.com> Date: Thu, 9 Apr 2026 16:03:16 -0300 Subject: [PATCH] =?UTF-8?q?MPI=20-=20Correcci=C3=B3n=20error=20Fallecimien?= =?UTF-8?q?to=20Manual?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core-v2/mpi/paciente/paciente.interface.ts | 13 +++++++++++++ core-v2/mpi/paciente/paciente.routes.ts | 16 +++++++++++++++- core-v2/mpi/paciente/paciente.schema.ts | 10 ++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/core-v2/mpi/paciente/paciente.interface.ts b/core-v2/mpi/paciente/paciente.interface.ts index 84d0ad6044..6cd5774c65 100644 --- a/core-v2/mpi/paciente/paciente.interface.ts +++ b/core-v2/mpi/paciente/paciente.interface.ts @@ -9,6 +9,18 @@ export interface ICarpetaEfector { nroCarpeta: String; } +export interface IFallecimientoManual { + fecha: Date | moment.Moment; + registradoPor: { + id: Schema.Types.ObjectId; + nombre: String; + apellido: String; + documento: Number; + }; + registradoEn: Date | moment.Moment; +} + + export interface INota { fecha: Date | moment.Moment; nota: String; @@ -49,6 +61,7 @@ export interface IPaciente { activo?: Boolean; alias?: String; fechaFallecimiento?: Date | moment.Moment; + fallecimientoManual?: IFallecimientoManual | Boolean | null; estadoCivil?: String; foto?: String; fotoId?: Schema.Types.ObjectId; diff --git a/core-v2/mpi/paciente/paciente.routes.ts b/core-v2/mpi/paciente/paciente.routes.ts index 58504003e6..a14e9be222 100644 --- a/core-v2/mpi/paciente/paciente.routes.ts +++ b/core-v2/mpi/paciente/paciente.routes.ts @@ -229,14 +229,28 @@ export const patch = async (req: Request, res: Response) => { const body = req.body; let paciente = await findById(id); if (paciente) { - await extractFoto(body, req); + const borrarFallecimiento = body.hasOwnProperty('fallecimientoManual') && !body.fallecimientoManual; + if (borrarFallecimiento) { + delete body.fechaFallecimiento; + } + paciente = set(paciente, body); + if (paciente.direccion?.[0]?.situacionCalle) { paciente.direccion[0].geoReferencia = null; } + const updated = await PacienteCtr.update(id, paciente, req); + + if (borrarFallecimiento) { + await Paciente.updateOne( + { _id: id }, + { $unset: { fallecimientoManual: '', fechaFallecimiento: '' } } + ); + } + return res.json(updated); } throw new PatientNotFound(); diff --git a/core-v2/mpi/paciente/paciente.schema.ts b/core-v2/mpi/paciente/paciente.schema.ts index 81fafe510b..9d135df71d 100644 --- a/core-v2/mpi/paciente/paciente.schema.ts +++ b/core-v2/mpi/paciente/paciente.schema.ts @@ -152,6 +152,16 @@ export const PacienteSubSchema: mongoose.Schema = new mongoose.Schema({ sexo: SEXO, genero: String, fechaFallecimiento: Date, + fallecimientoManual: { + fecha: Date, + registradoPor: { + id: mongoose.Schema.Types.ObjectId, + nombre: String, + apellido: String, + documento: Number + }, + registradoEn: Date + }, numeroIdentificacion: String, tipoIdentificacion: IDENTIFICACION, alias: String,