Solucionar perdida de relacion entre internacion y paciente al actualizar pagina preservando IDs en backend y refrescando estado en Internaciones

This commit is contained in:
2026-08-11 21:19:59 +00:00
parent 51ae114a1e
commit 26869e4b39
2 changed files with 18 additions and 14 deletions
+12 -12
View File
@@ -164,7 +164,7 @@ app.get('/api/pacientes', async (req, res) => {
app.post('/api/pacientes', async (req, res) => {
try {
const paciente = { ...req.body, id: generateUUID() };
const paciente = { ...req.body, id: req.body.id || generateUUID() };
await createPaciente(paciente);
res.json(paciente);
} catch (err) {
@@ -278,7 +278,7 @@ app.get('/api/internaciones', async (req, res) => {
app.post('/api/internaciones', async (req, res) => {
try {
const internacion = { ...req.body, id: generateUUID(), activa: true };
const internacion = { ...req.body, id: req.body.id || generateUUID(), activa: req.body.activa !== undefined ? req.body.activa : true };
await createInternacion(internacion);
res.json(internacion);
} catch (err) {
@@ -315,7 +315,7 @@ app.get('/api/evoluciones', async (req, res) => {
app.post('/api/evoluciones', async (req, res) => {
try {
const evolucion = { ...req.body, id: generateUUID() };
const evolucion = { ...req.body, id: req.body.id || generateUUID() };
await createEvolucion(evolucion);
res.json(evolucion);
} catch (err) {
@@ -352,7 +352,7 @@ app.get('/api/laboratorios', async (req, res) => {
app.post('/api/laboratorios', async (req, res) => {
try {
const laboratorio = { ...req.body, id: generateUUID() };
const laboratorio = { ...req.body, id: req.body.id || generateUUID() };
await createLaboratorio(laboratorio);
res.json(laboratorio);
} catch (err) {
@@ -389,7 +389,7 @@ app.get('/api/glucemias', async (req, res) => {
app.post('/api/glucemias', async (req, res) => {
try {
const glucemia = { ...req.body, id: generateUUID() };
const glucemia = { ...req.body, id: req.body.id || generateUUID() };
await createGlucemia(glucemia);
res.json(glucemia);
} catch (err) {
@@ -426,7 +426,7 @@ app.get('/api/acid-os-base', async (req, res) => {
app.post('/api/acid-os-base', async (req, res) => {
try {
const acido = { ...req.body, id: generateUUID() };
const acido = { ...req.body, id: req.body.id || generateUUID() };
await createAcidoBase(acido);
res.json(acido);
} catch (err) {
@@ -463,7 +463,7 @@ app.get('/api/cultivos', async (req, res) => {
app.post('/api/cultivos', async (req, res) => {
try {
const cultivo = { ...req.body, id: generateUUID() };
const cultivo = { ...req.body, id: req.body.id || generateUUID() };
await createCultivo(cultivo);
res.json(cultivo);
} catch (err) {
@@ -500,7 +500,7 @@ app.get('/api/estudios-complementarios', async (req, res) => {
app.post('/api/estudios-complementarios', async (req, res) => {
try {
const estudio = { ...req.body, id: generateUUID() };
const estudio = { ...req.body, id: req.body.id || generateUUID() };
await createEstudioComplementario(estudio);
res.json(estudio);
} catch (err) {
@@ -537,7 +537,7 @@ app.get('/api/interconsultas', async (req, res) => {
app.post('/api/interconsultas', async (req, res) => {
try {
const interconsulta = { ...req.body, id: generateUUID() };
const interconsulta = { ...req.body, id: req.body.id || generateUUID() };
await createInterconsulta(interconsulta);
res.json(interconsulta);
} catch (err) {
@@ -574,7 +574,7 @@ app.get('/api/atb', async (req, res) => {
app.post('/api/atb', async (req, res) => {
try {
const atb = { ...req.body, id: generateUUID() };
const atb = { ...req.body, id: req.body.id || generateUUID() };
await createAtb(atb);
res.json(atb);
} catch (err) {
@@ -611,7 +611,7 @@ app.get('/api/indicaciones', async (req, res) => {
app.post('/api/indicaciones', async (req, res) => {
try {
const indicacion = { ...req.body, id: generateUUID() };
const indicacion = { ...req.body, id: req.body.id || generateUUID() };
await createIndicacion(indicacion);
res.json(indicacion);
} catch (err) {
@@ -648,7 +648,7 @@ app.get('/api/movimientos-indicaciones', async (req, res) => {
app.post('/api/movimientos-indicaciones', async (req, res) => {
try {
const movimiento = { ...req.body, id: generateUUID() };
const movimiento = { ...req.body, id: req.body.id || generateUUID() };
console.log('Creating movimiento:', movimiento);
await createMovimientoIndicacion(movimiento);
res.json(movimiento);