Add debug logging for movimientos-indicaciones API errors
This commit is contained in:
@@ -577,10 +577,12 @@ app.get('/api/movimientos-indicaciones', async (req, res) => {
|
||||
app.post('/api/movimientos-indicaciones', async (req, res) => {
|
||||
try {
|
||||
const movimiento = { ...req.body, id: generateUUID() };
|
||||
console.log('Creating movimiento:', movimiento);
|
||||
await createMovimientoIndicacion(movimiento);
|
||||
res.json(movimiento);
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: 'Error al crear movimiento' });
|
||||
console.error('Error creating movimiento:', err);
|
||||
res.status(500).json({ error: err.message || 'Error al crear movimiento' });
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -656,10 +656,16 @@ export async function getAllMovimientosIndicaciones() {
|
||||
}
|
||||
|
||||
export async function createMovimientoIndicacion(movimiento) {
|
||||
console.log('DB: createMovimientoIndicacion:', movimiento);
|
||||
try {
|
||||
await query(
|
||||
'INSERT INTO movimientos_indicaciones (id, indicacionId, internacionId, tipo, fecha, profesional, indicacionPrevia, indicacionNueva) VALUES (?, ?, ?, ?, ?, ?, ?, ?)',
|
||||
[movimiento.id, movimiento.indicacionId, movimiento.internacionId, movimiento.tipo, movimiento.fecha, movimiento.profesional, movimiento.indicacionPrevia || null, movimiento.indicacionNueva || null]
|
||||
);
|
||||
} catch (err) {
|
||||
console.error('DB Error createMovimientoIndicacion:', err);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
// ========== KV STORE ==========
|
||||
|
||||
Reference in New Issue
Block a user