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:
@@ -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;
|
||||
|
||||
@@ -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
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user