Renombrar opciones de egreso, cambiar Dar Alta a Registrar Egreso y agregar opción Pase servicio con campo dinámico

This commit is contained in:
2026-08-12 00:18:10 +00:00
parent cce8a0b4c8
commit ac9d1a5acf
4 changed files with 32 additions and 10 deletions
+1
View File
@@ -392,6 +392,7 @@ export async function createInternacion(internacion) {
diagnosticoEgreso: internacion.diagnosticoEgreso || null, diagnosticoEgreso: internacion.diagnosticoEgreso || null,
medicoIngresante: internacion.medicoIngresante || null, medicoIngresante: internacion.medicoIngresante || null,
motivoEgreso: internacion.motivoEgreso || null, motivoEgreso: internacion.motivoEgreso || null,
servicioAlQuePasa: internacion.servicioAlQuePasa || null,
activa: internacion.activa ? 1 : 0, activa: internacion.activa ? 1 : 0,
apache: internacion.apache || null, apache: internacion.apache || null,
derivacion: internacion.derivacion || null derivacion: internacion.derivacion || null
+2 -1
View File
@@ -420,7 +420,8 @@ const agregarCama = useCallback(async (cama: Omit<Cama, 'id'>) => {
const finalizarInternacion = useCallback(async (internacionId: string, datos: { const finalizarInternacion = useCallback(async (internacionId: string, datos: {
fechaEgreso: string; fechaEgreso: string;
diagnosticoEgreso: string; diagnosticoEgreso: string;
motivoEgreso: Internacion['motivoEgreso'] motivoEgreso: Internacion['motivoEgreso'];
servicioAlQuePasa?: string;
}) => { }) => {
const internacion = state.internaciones.find(i => i.id === internacionId); const internacion = state.internaciones.find(i => i.id === internacionId);
if (!internacion) return; if (!internacion) return;
+27 -8
View File
@@ -26,7 +26,8 @@ interface InternacionesProps {
onFinalizarInternacion: (internacionId: string, datos: { onFinalizarInternacion: (internacionId: string, datos: {
fechaEgreso: string; fechaEgreso: string;
diagnosticoEgreso: string; diagnosticoEgreso: string;
motivoEgreso: Internacion['motivoEgreso'] motivoEgreso: Internacion['motivoEgreso'];
servicioAlQuePasa?: string;
}) => void; }) => void;
onEliminarInternacion?: (internacionId: string) => Promise<void> | void; onEliminarInternacion?: (internacionId: string) => Promise<void> | void;
getPacienteById: (id: string) => Paciente | undefined; getPacienteById: (id: string) => Paciente | undefined;
@@ -75,6 +76,7 @@ export function Internaciones({
const [fechaEgreso, setFechaEgreso] = useState(''); const [fechaEgreso, setFechaEgreso] = useState('');
const [diagnosticoEgreso, setDiagnosticoEgreso] = useState(''); const [diagnosticoEgreso, setDiagnosticoEgreso] = useState('');
const [motivoEgreso, setMotivoEgreso] = useState<Internacion['motivoEgreso']>('Alta médica'); const [motivoEgreso, setMotivoEgreso] = useState<Internacion['motivoEgreso']>('Alta médica');
const [servicioAlQuePasa, setServicioAlQuePasa] = useState('');
const resetFormularioNueva = () => { const resetFormularioNueva = () => {
setPacienteSeleccionado(''); setPacienteSeleccionado('');
@@ -89,6 +91,7 @@ export function Internaciones({
setFechaEgreso(''); setFechaEgreso('');
setDiagnosticoEgreso(''); setDiagnosticoEgreso('');
setMotivoEgreso('Alta médica'); setMotivoEgreso('Alta médica');
setServicioAlQuePasa('');
setInternacionSeleccionada(null); setInternacionSeleccionada(null);
}; };
@@ -119,10 +122,15 @@ export function Internaciones({
const handleFinalizarInternacion = () => { const handleFinalizarInternacion = () => {
if (internacionSeleccionada && fechaEgreso && diagnosticoEgreso && motivoEgreso) { 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, { onFinalizarInternacion(internacionSeleccionada.id, {
fechaEgreso, fechaEgreso,
diagnosticoEgreso, diagnosticoEgreso,
motivoEgreso, motivoEgreso,
servicioAlQuePasa: motivoEgreso === 'Pase servicio' ? servicioAlQuePasa : undefined,
}); });
resetFormularioEgreso(); resetFormularioEgreso();
setDialogoEgresoAbierto(false); setDialogoEgresoAbierto(false);
@@ -565,7 +573,7 @@ export function Internaciones({
<Dialog open={dialogoEgresoAbierto} onOpenChange={(open) => { if (!open) resetFormularioEgreso(); setDialogoEgresoAbierto(open); }}> <Dialog open={dialogoEgresoAbierto} onOpenChange={(open) => { if (!open) resetFormularioEgreso(); setDialogoEgresoAbierto(open); }}>
<DialogContent className="sm:max-w-lg"> <DialogContent className="sm:max-w-lg">
<DialogHeader> <DialogHeader>
<DialogTitle>Dar Alta</DialogTitle> <DialogTitle>Registrar Egreso</DialogTitle>
</DialogHeader> </DialogHeader>
<div className="space-y-4"> <div className="space-y-4">
<div> <div>
@@ -589,19 +597,30 @@ export function Internaciones({
</div> </div>
<div> <div>
<Label>Motivo de Egreso *</Label> <Label>Motivo de Egreso *</Label>
<Select value={motivoEgreso} onValueChange={(v) => setMotivoEgreso(v as Internacion['motivoEgreso'])}> <Select value={motivoEgreso} onValueChange={(v) => { setMotivoEgreso(v as Internacion['motivoEgreso']); if (v !== 'Pase servicio') setServicioAlQuePasa(''); }}>
<SelectTrigger> <SelectTrigger>
<SelectValue /> <SelectValue />
</SelectTrigger> </SelectTrigger>
<SelectContent> <SelectContent>
<SelectItem value="Alta médica">Alta médica</SelectItem> <SelectItem value="Alta médica">Alta médica</SelectItem>
<SelectItem value="Alta voluntaria">Alta voluntaria</SelectItem> <SelectItem value="Egreso Voluntario">Egreso Voluntario</SelectItem>
<SelectItem value="Derivación">Derivación</SelectItem> <SelectItem value="Derivación">Derivación</SelectItem>
<SelectItem value="Fallecimiento">Fallecimiento</SelectItem> <SelectItem value="Obito">Obito</SelectItem>
<SelectItem value="Pase servicio">Pase servicio</SelectItem>
<SelectItem value="Otro">Otro</SelectItem> <SelectItem value="Otro">Otro</SelectItem>
</SelectContent> </SelectContent>
</Select> </Select>
</div> </div>
{motivoEgreso === 'Pase servicio' && (
<div>
<Label>Servicio al que pasa *</Label>
<Input
value={servicioAlQuePasa}
onChange={(e) => setServicioAlQuePasa(e.target.value)}
placeholder="Ej. Terapia Intensiva, Quirófano, etc."
/>
</div>
)}
<div> <div>
<Label>Diagnóstico de Egreso *</Label> <Label>Diagnóstico de Egreso *</Label>
<textarea <textarea
@@ -612,9 +631,9 @@ export function Internaciones({
/> />
</div> </div>
<Button variant="outline" <Button variant="outline"
className="w-full" className="w-full"
onClick={handleFinalizarInternacion} onClick={handleFinalizarInternacion}
disabled={!fechaEgreso || !diagnosticoEgreso || !motivoEgreso} disabled={!fechaEgreso || !diagnosticoEgreso || !motivoEgreso || (motivoEgreso === 'Pase servicio' && !servicioAlQuePasa.trim())}
> >
<CheckCircle2 className="h-4 w-4 mr-2" /> <CheckCircle2 className="h-4 w-4 mr-2" />
Confirmar Egreso Confirmar Egreso
+2 -1
View File
@@ -55,7 +55,8 @@ export interface Internacion {
antecedentesEnfermedadActual?: string; antecedentesEnfermedadActual?: string;
diagnosticoEgreso?: string; diagnosticoEgreso?: string;
medicoIngresante: string; medicoIngresante: string;
motivoEgreso?: 'Alta médica' | 'Alta voluntaria' | 'Derivación' | 'Fallecimiento' | 'Otro'; motivoEgreso?: 'Alta médica' | 'Egreso Voluntario' | 'Derivación' | 'Obito' | 'Pase servicio' | 'Otro';
servicioAlQuePasa?: string;
activa: boolean; activa: boolean;
apache?: string; apache?: string;
derivacion?: string; derivacion?: string;