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,
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
+2 -1
View File
@@ -420,7 +420,8 @@ const agregarCama = useCallback(async (cama: Omit<Cama, 'id'>) => {
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;
+27 -8
View File
@@ -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> | 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<Internacion['motivoEgreso']>('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({
<Dialog open={dialogoEgresoAbierto} onOpenChange={(open) => { if (!open) resetFormularioEgreso(); setDialogoEgresoAbierto(open); }}>
<DialogContent className="sm:max-w-lg">
<DialogHeader>
<DialogTitle>Dar Alta</DialogTitle>
<DialogTitle>Registrar Egreso</DialogTitle>
</DialogHeader>
<div className="space-y-4">
<div>
@@ -589,19 +597,30 @@ export function Internaciones({
</div>
<div>
<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>
<SelectValue />
</SelectTrigger>
<SelectContent>
<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="Fallecimiento">Fallecimiento</SelectItem>
<SelectItem value="Obito">Obito</SelectItem>
<SelectItem value="Pase servicio">Pase servicio</SelectItem>
<SelectItem value="Otro">Otro</SelectItem>
</SelectContent>
</Select>
</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>
<Label>Diagnóstico de Egreso *</Label>
<textarea
@@ -612,9 +631,9 @@ export function Internaciones({
/>
</div>
<Button variant="outline"
className="w-full"
onClick={handleFinalizarInternacion}
disabled={!fechaEgreso || !diagnosticoEgreso || !motivoEgreso}
className="w-full"
onClick={handleFinalizarInternacion}
disabled={!fechaEgreso || !diagnosticoEgreso || !motivoEgreso || (motivoEgreso === 'Pase servicio' && !servicioAlQuePasa.trim())}
>
<CheckCircle2 className="h-4 w-4 mr-2" />
Confirmar Egreso
+2 -1
View File
@@ -55,7 +55,8 @@ export interface Internacion {
antecedentesEnfermedadActual?: string;
diagnosticoEgreso?: 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;
apache?: string;
derivacion?: string;