Skip to content

Commit 6335774

Browse files
committed
feat(MPI-465): "Ajuste en formato de fecha de nacimiento"
1 parent 329841b commit 6335774

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

modules/cda/routes/cda.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,15 @@ router.post('/', async (req: any, res, next) => {
108108
}
109109

110110
cdaData.fecha = moment(cdaData.fecha, 'YYYYMMDDhhmmss').toDate();
111-
cdaData.paciente.fechaNacimiento = moment(cdaData.paciente.fechaNacimiento, 'YYYYMMDDhhmmss');
111+
const fechaLocal = moment(cdaData.paciente.fechaNacimiento, 'YYYYMMDDhhmmss');
112+
if (fechaLocal.isValid()) {
113+
cdaData.paciente.fechaNacimiento = moment.utc({
114+
year: fechaLocal.year(),
115+
month: fechaLocal.month(),
116+
date: fechaLocal.date()
117+
}).toDate();
118+
}
119+
112120
cdaData.paciente.sexo = cdaData.paciente.sexo === 'M' ? 'masculino' : 'femenino';
113121

114122
const yaExiste = await cdaCtr.CDAExists(cdaData.id, cdaData.fecha, orgId);

0 commit comments

Comments
 (0)