import { useState } from 'react'; import { ArrowLeft, Save, X, Bed, Calendar, Stethoscope, User, ClipboardList } from 'lucide-react'; import { Card, CardContent } from '@/components/ui/card'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'; import { Badge } from '@/components/ui/badge'; import type { Paciente, Cama, Area, Internacion } from '@/types'; interface NuevoIngresoProps { pacientes: Paciente[]; camas: Cama[]; areas: Area[]; onIniciarInternacion: (internacion: Omit) => void; onAgregarPaciente?: (paciente: Omit) => void; onActualizarPaciente?: (id: string, datos: Partial) => void; onVolver: () => void; getAreaName: (areaId: string | undefined) => string; } export function NuevoIngreso({ pacientes, camas, areas, onIniciarInternacion, onVolver, getAreaName }: NuevoIngresoProps) { const [pacienteSeleccionado, setPacienteSeleccionado] = useState(''); const [busqueda, setBusqueda] = useState(''); const [camaSeleccionada, setCamaSeleccionada] = useState(''); const [medico, setMedico] = useState(''); const [fechaIngresoHospital, setFechaIngresoHospital] = useState(''); const [fechaIngresoClinica, setFechaIngresoClinica] = useState(''); const [motivoConsulta, setMotivoConsulta] = useState(''); const [diagnosticoIngreso, setDiagnosticoIngreso] = useState(''); const [enfermedadActual, setEnfermedadActual] = useState(''); const [antecedentesEnfermedadActual, setAntecedentesEnfermedadActual] = useState(''); const [apache, setApache] = useState(''); const [derivacion, setDerivacion] = useState(''); const resetFormulario = () => { setPacienteSeleccionado(''); setBusqueda(''); setCamaSeleccionada(''); setMedico(''); setFechaIngresoHospital(''); setFechaIngresoClinica(''); setMotivoConsulta(''); setDiagnosticoIngreso(''); setEnfermedadActual(''); setAntecedentesEnfermedadActual(''); setApache(''); setDerivacion(''); }; const pacientesSinInternar = pacientes; const handleSubmit = () => { if (!pacienteSeleccionado || !camaSeleccionada || !medico || !diagnosticoIngreso || !enfermedadActual) { alert('Por favor complete los campos obligatorios'); return; } onIniciarInternacion({ pacienteId: pacienteSeleccionado, camaId: camaSeleccionada, medicoIngresante: medico, diagnosticoIngreso, motivoConsulta: motivoConsulta || undefined, enfermedadActual, antecedentesEnfermedadActual: antecedentesEnfermedadActual || undefined, fechaIngresoHospital: fechaIngresoHospital || undefined, fechaIngresoClinica: fechaIngresoClinica || undefined, apache: apache || undefined, derivacion: derivacion || undefined, }); resetFormulario(); onVolver(); }; const selectedPaciente = pacientes.find(p => p.id === pacienteSeleccionado); return (

Nuevo Ingreso

Formulario de internación

{/* Columna 1: Datos del Paciente */}

Datos del Paciente

{!pacienteSeleccionado ? ( <> setBusqueda(e.target.value)} />
{(() => { const q = busqueda.trim().toLowerCase(); if (!q) { return
Escriba para buscar
; } const matches = pacientesSinInternar.filter(p => p.apellido.toLowerCase().includes(q) || p.nombre.toLowerCase().includes(q) || p.dni.includes(q) ); if (matches.length === 0) { return
Sin resultados
; } return matches.map(p => ( )); })()}
) : (
{selectedPaciente?.apellido}, {selectedPaciente?.nombre} DNI: {selectedPaciente?.dni}
)}
{/* Columna 2: Cama */}

Asignación de Cama

Datos de Ingreso

setFechaIngresoHospital(e.target.value)} />
setFechaIngresoClinica(e.target.value)} />
setDerivacion(e.target.value)} />
setApache(e.target.value)} />

Datos Clínicos