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:
+12
-12
@@ -164,7 +164,7 @@ app.get('/api/pacientes', async (req, res) => {
|
|||||||
|
|
||||||
app.post('/api/pacientes', async (req, res) => {
|
app.post('/api/pacientes', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const paciente = { ...req.body, id: generateUUID() };
|
const paciente = { ...req.body, id: req.body.id || generateUUID() };
|
||||||
await createPaciente(paciente);
|
await createPaciente(paciente);
|
||||||
res.json(paciente);
|
res.json(paciente);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -278,7 +278,7 @@ app.get('/api/internaciones', async (req, res) => {
|
|||||||
|
|
||||||
app.post('/api/internaciones', async (req, res) => {
|
app.post('/api/internaciones', async (req, res) => {
|
||||||
try {
|
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);
|
await createInternacion(internacion);
|
||||||
res.json(internacion);
|
res.json(internacion);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -315,7 +315,7 @@ app.get('/api/evoluciones', async (req, res) => {
|
|||||||
|
|
||||||
app.post('/api/evoluciones', async (req, res) => {
|
app.post('/api/evoluciones', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const evolucion = { ...req.body, id: generateUUID() };
|
const evolucion = { ...req.body, id: req.body.id || generateUUID() };
|
||||||
await createEvolucion(evolucion);
|
await createEvolucion(evolucion);
|
||||||
res.json(evolucion);
|
res.json(evolucion);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -352,7 +352,7 @@ app.get('/api/laboratorios', async (req, res) => {
|
|||||||
|
|
||||||
app.post('/api/laboratorios', async (req, res) => {
|
app.post('/api/laboratorios', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const laboratorio = { ...req.body, id: generateUUID() };
|
const laboratorio = { ...req.body, id: req.body.id || generateUUID() };
|
||||||
await createLaboratorio(laboratorio);
|
await createLaboratorio(laboratorio);
|
||||||
res.json(laboratorio);
|
res.json(laboratorio);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -389,7 +389,7 @@ app.get('/api/glucemias', async (req, res) => {
|
|||||||
|
|
||||||
app.post('/api/glucemias', async (req, res) => {
|
app.post('/api/glucemias', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const glucemia = { ...req.body, id: generateUUID() };
|
const glucemia = { ...req.body, id: req.body.id || generateUUID() };
|
||||||
await createGlucemia(glucemia);
|
await createGlucemia(glucemia);
|
||||||
res.json(glucemia);
|
res.json(glucemia);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -426,7 +426,7 @@ app.get('/api/acid-os-base', async (req, res) => {
|
|||||||
|
|
||||||
app.post('/api/acid-os-base', async (req, res) => {
|
app.post('/api/acid-os-base', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const acido = { ...req.body, id: generateUUID() };
|
const acido = { ...req.body, id: req.body.id || generateUUID() };
|
||||||
await createAcidoBase(acido);
|
await createAcidoBase(acido);
|
||||||
res.json(acido);
|
res.json(acido);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -463,7 +463,7 @@ app.get('/api/cultivos', async (req, res) => {
|
|||||||
|
|
||||||
app.post('/api/cultivos', async (req, res) => {
|
app.post('/api/cultivos', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const cultivo = { ...req.body, id: generateUUID() };
|
const cultivo = { ...req.body, id: req.body.id || generateUUID() };
|
||||||
await createCultivo(cultivo);
|
await createCultivo(cultivo);
|
||||||
res.json(cultivo);
|
res.json(cultivo);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -500,7 +500,7 @@ app.get('/api/estudios-complementarios', async (req, res) => {
|
|||||||
|
|
||||||
app.post('/api/estudios-complementarios', async (req, res) => {
|
app.post('/api/estudios-complementarios', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const estudio = { ...req.body, id: generateUUID() };
|
const estudio = { ...req.body, id: req.body.id || generateUUID() };
|
||||||
await createEstudioComplementario(estudio);
|
await createEstudioComplementario(estudio);
|
||||||
res.json(estudio);
|
res.json(estudio);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -537,7 +537,7 @@ app.get('/api/interconsultas', async (req, res) => {
|
|||||||
|
|
||||||
app.post('/api/interconsultas', async (req, res) => {
|
app.post('/api/interconsultas', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const interconsulta = { ...req.body, id: generateUUID() };
|
const interconsulta = { ...req.body, id: req.body.id || generateUUID() };
|
||||||
await createInterconsulta(interconsulta);
|
await createInterconsulta(interconsulta);
|
||||||
res.json(interconsulta);
|
res.json(interconsulta);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -574,7 +574,7 @@ app.get('/api/atb', async (req, res) => {
|
|||||||
|
|
||||||
app.post('/api/atb', async (req, res) => {
|
app.post('/api/atb', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const atb = { ...req.body, id: generateUUID() };
|
const atb = { ...req.body, id: req.body.id || generateUUID() };
|
||||||
await createAtb(atb);
|
await createAtb(atb);
|
||||||
res.json(atb);
|
res.json(atb);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -611,7 +611,7 @@ app.get('/api/indicaciones', async (req, res) => {
|
|||||||
|
|
||||||
app.post('/api/indicaciones', async (req, res) => {
|
app.post('/api/indicaciones', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const indicacion = { ...req.body, id: generateUUID() };
|
const indicacion = { ...req.body, id: req.body.id || generateUUID() };
|
||||||
await createIndicacion(indicacion);
|
await createIndicacion(indicacion);
|
||||||
res.json(indicacion);
|
res.json(indicacion);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -648,7 +648,7 @@ app.get('/api/movimientos-indicaciones', async (req, res) => {
|
|||||||
|
|
||||||
app.post('/api/movimientos-indicaciones', async (req, res) => {
|
app.post('/api/movimientos-indicaciones', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const movimiento = { ...req.body, id: generateUUID() };
|
const movimiento = { ...req.body, id: req.body.id || generateUUID() };
|
||||||
console.log('Creating movimiento:', movimiento);
|
console.log('Creating movimiento:', movimiento);
|
||||||
await createMovimientoIndicacion(movimiento);
|
await createMovimientoIndicacion(movimiento);
|
||||||
res.json(movimiento);
|
res.json(movimiento);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useState } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import { ClipboardList, Plus, Search, LogOut, CheckCircle2, MoreHorizontal, FileText, Trash2, Bed, User, Calendar, IdCard, Activity, CalendarDays, Clock, Settings, ListTodo } from 'lucide-react';
|
import { ClipboardList, Plus, Search, LogOut, CheckCircle2, MoreHorizontal, FileText, Trash2, Bed, User, Calendar, IdCard, Activity, CalendarDays, Clock, Settings, ListTodo } from 'lucide-react';
|
||||||
import { Card, CardContent } from '@/components/ui/card';
|
import { Card, CardContent } from '@/components/ui/card';
|
||||||
import { Badge } from '@/components/ui/badge';
|
import { Badge } from '@/components/ui/badge';
|
||||||
@@ -50,7 +50,11 @@ export function Internaciones({
|
|||||||
onNuevoIngreso,
|
onNuevoIngreso,
|
||||||
onVerPendientesDeSala,
|
onVerPendientesDeSala,
|
||||||
}: InternacionesProps) {
|
}: InternacionesProps) {
|
||||||
const { currentUser } = useHospitalStore();
|
const { currentUser, refreshState } = useHospitalStore();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
refreshState();
|
||||||
|
}, [refreshState]);
|
||||||
const [filtroEstado, setFiltroEstado] = useState<'todas' | 'activas' | 'finalizadas'>('todas');
|
const [filtroEstado, setFiltroEstado] = useState<'todas' | 'activas' | 'finalizadas'>('todas');
|
||||||
const [dialogoNuevaAbierto, setDialogoNuevaAbierto] = useState(false);
|
const [dialogoNuevaAbierto, setDialogoNuevaAbierto] = useState(false);
|
||||||
const [dialogoEgresoAbierto, setDialogoEgresoAbierto] = useState(false);
|
const [dialogoEgresoAbierto, setDialogoEgresoAbierto] = useState(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user