From ac9d1a5acf36311857479cc49ee26fb26b75c745 Mon Sep 17 00:00:00 2001 From: snlavaise Date: Wed, 12 Aug 2026 00:18:10 +0000 Subject: [PATCH] =?UTF-8?q?Renombrar=20opciones=20de=20egreso,=20cambiar?= =?UTF-8?q?=20Dar=20Alta=20a=20Registrar=20Egreso=20y=20agregar=20opci?= =?UTF-8?q?=C3=B3n=20Pase=20servicio=20con=20campo=20din=C3=A1mico?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/db-mongodb.js | 1 + src/hooks/useHospitalStore.ts | 3 ++- src/sections/Internaciones.tsx | 35 ++++++++++++++++++++++++++-------- src/types/index.ts | 3 ++- 4 files changed, 32 insertions(+), 10 deletions(-) diff --git a/server/db-mongodb.js b/server/db-mongodb.js index 3144467..ba657ff 100644 --- a/server/db-mongodb.js +++ b/server/db-mongodb.js @@ -392,6 +392,7 @@ export async function createInternacion(internacion) { diagnosticoEgreso: internacion.diagnosticoEgreso || null, medicoIngresante: internacion.medicoIngresante || null, motivoEgreso: internacion.motivoEgreso || null, + servicioAlQuePasa: internacion.servicioAlQuePasa || null, activa: internacion.activa ? 1 : 0, apache: internacion.apache || null, derivacion: internacion.derivacion || null diff --git a/src/hooks/useHospitalStore.ts b/src/hooks/useHospitalStore.ts index 9b1fd8f..4494f6e 100644 --- a/src/hooks/useHospitalStore.ts +++ b/src/hooks/useHospitalStore.ts @@ -420,7 +420,8 @@ const agregarCama = useCallback(async (cama: Omit) => { const finalizarInternacion = useCallback(async (internacionId: string, datos: { fechaEgreso: string; diagnosticoEgreso: string; - motivoEgreso: Internacion['motivoEgreso'] + motivoEgreso: Internacion['motivoEgreso']; + servicioAlQuePasa?: string; }) => { const internacion = state.internaciones.find(i => i.id === internacionId); if (!internacion) return; diff --git a/src/sections/Internaciones.tsx b/src/sections/Internaciones.tsx index 1b08270..89ffd84 100644 --- a/src/sections/Internaciones.tsx +++ b/src/sections/Internaciones.tsx @@ -26,7 +26,8 @@ interface InternacionesProps { onFinalizarInternacion: (internacionId: string, datos: { fechaEgreso: string; diagnosticoEgreso: string; - motivoEgreso: Internacion['motivoEgreso'] + motivoEgreso: Internacion['motivoEgreso']; + servicioAlQuePasa?: string; }) => void; onEliminarInternacion?: (internacionId: string) => Promise | void; getPacienteById: (id: string) => Paciente | undefined; @@ -75,6 +76,7 @@ export function Internaciones({ const [fechaEgreso, setFechaEgreso] = useState(''); const [diagnosticoEgreso, setDiagnosticoEgreso] = useState(''); const [motivoEgreso, setMotivoEgreso] = useState('Alta médica'); + const [servicioAlQuePasa, setServicioAlQuePasa] = useState(''); const resetFormularioNueva = () => { setPacienteSeleccionado(''); @@ -89,6 +91,7 @@ export function Internaciones({ setFechaEgreso(''); setDiagnosticoEgreso(''); setMotivoEgreso('Alta médica'); + setServicioAlQuePasa(''); setInternacionSeleccionada(null); }; @@ -119,10 +122,15 @@ export function Internaciones({ const handleFinalizarInternacion = () => { if (internacionSeleccionada && fechaEgreso && diagnosticoEgreso && motivoEgreso) { + if (motivoEgreso === 'Pase servicio' && !servicioAlQuePasa.trim()) { + toast.error('Por favor indique el servicio al que pasa'); + return; + } onFinalizarInternacion(internacionSeleccionada.id, { fechaEgreso, diagnosticoEgreso, motivoEgreso, + servicioAlQuePasa: motivoEgreso === 'Pase servicio' ? servicioAlQuePasa : undefined, }); resetFormularioEgreso(); setDialogoEgresoAbierto(false); @@ -565,7 +573,7 @@ export function Internaciones({ { if (!open) resetFormularioEgreso(); setDialogoEgresoAbierto(open); }}> - Dar Alta + Registrar Egreso
@@ -589,19 +597,30 @@ export function Internaciones({
- { setMotivoEgreso(v as Internacion['motivoEgreso']); if (v !== 'Pase servicio') setServicioAlQuePasa(''); }}> Alta médica - Alta voluntaria + Egreso Voluntario Derivación - Fallecimiento + Obito + Pase servicio Otro
+ {motivoEgreso === 'Pase servicio' && ( +
+ + setServicioAlQuePasa(e.target.value)} + placeholder="Ej. Terapia Intensiva, Quirófano, etc." + /> +
+ )}