From 4610dc5595cfd3c1c8717410c53076e850194c75 Mon Sep 17 00:00:00 2001 From: AgustinRodriguez-Andes <63318331+agustin1996ra@users.noreply.github.com> Date: Thu, 19 Mar 2026 15:38:22 -0300 Subject: [PATCH] (fix)REC-216: Fecha de nacieminto --- src/controllers/prescription.controller.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/controllers/prescription.controller.ts b/src/controllers/prescription.controller.ts index d03a724..3f6a4df 100644 --- a/src/controllers/prescription.controller.ts +++ b/src/controllers/prescription.controller.ts @@ -169,6 +169,17 @@ class PrescriptionController implements BaseController { } else { myPatient = await Patient.schema.methods.findOrCreate(patient, ambito); } + + // Completa fecha de nacimiento solo cuando el paciente existente no la tiene. + const payloadBirthDate = patient?.fechaNac || patient?.fechaNacimiento; + if (myPatient && !myPatient.fechaNac && payloadBirthDate) { + const parsedBirthDate = new Date(payloadBirthDate); + if (!Number.isNaN(parsedBirthDate.getTime())) { + myPatient.fechaNac = parsedBirthDate; + await myPatient.save(); + } + } + if (myProfessional && patient && myPatient) { try { const allPrescription: IPrescription[] = [];