Fix edición laboratorio, agregar icons a formularios, protocolo en cultivos
This commit is contained in:
@@ -97,6 +97,7 @@ export function Cultivos({
|
||||
if (cultivoSeleccionado && onActualizarCultivo && germen) {
|
||||
onActualizarCultivo(cultivoSeleccionado.id, {
|
||||
estado: 'Parcial',
|
||||
protocolo: protocolo || undefined,
|
||||
germen: germen || undefined,
|
||||
sensible: sensible || undefined,
|
||||
resistente: resistente || undefined,
|
||||
@@ -110,6 +111,7 @@ export function Cultivos({
|
||||
if (cultivoSeleccionado && onActualizarCultivo) {
|
||||
onActualizarCultivo(cultivoSeleccionado.id, {
|
||||
fechaResultado,
|
||||
protocolo: protocolo || undefined,
|
||||
estado: estadoResultado,
|
||||
germen: germen || undefined,
|
||||
sensible: sensible || undefined,
|
||||
@@ -122,6 +124,7 @@ export function Cultivos({
|
||||
|
||||
const abrirParcial = (cultivo: Cultivo) => {
|
||||
setCultivoSeleccionado(cultivo);
|
||||
setProtocolo(cultivo.protocolo || '');
|
||||
setGermen(cultivo.germen || '');
|
||||
setSensible(cultivo.sensible || '');
|
||||
setResistente(cultivo.resistente || '');
|
||||
@@ -130,6 +133,7 @@ export function Cultivos({
|
||||
|
||||
const abrirDefinitivo = (cultivo: Cultivo) => {
|
||||
setCultivoSeleccionado(cultivo);
|
||||
setProtocolo(cultivo.protocolo || '');
|
||||
setFechaResultado(cultivo.fechaResultado || new Date().toISOString().split('T')[0]);
|
||||
setEstadoResultado(cultivo.estado === 'Parcial' || cultivo.estado === 'Positivo' ? 'Positivo' : cultivo.estado);
|
||||
setGermen(cultivo.germen || '');
|
||||
@@ -285,6 +289,10 @@ export function Cultivos({
|
||||
<p className="text-sm font-medium text-orange-800">Resultado Parcial - Sujeto a modificación</p>
|
||||
<p className="text-xs text-orange-600 mt-1">Ingrese resultado parcial. Esto puede modificarse posteriormente.</p>
|
||||
</div>
|
||||
<div>
|
||||
<Label>Protocolo</Label>
|
||||
<Input value={protocolo} onChange={(e) => setProtocolo(e.target.value)} placeholder="N° Protocolo" />
|
||||
</div>
|
||||
<div>
|
||||
<Label>Germen *</Label>
|
||||
<Input value={germen} onChange={(e) => setGermen(e.target.value)} placeholder="Ej: Staphylococcus aureus" />
|
||||
@@ -334,6 +342,10 @@ export function Cultivos({
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<div className="sm:col-span-2">
|
||||
<Label>Protocolo</Label>
|
||||
<Input value={protocolo} onChange={(e) => setProtocolo(e.target.value)} placeholder="N° Protocolo" />
|
||||
</div>
|
||||
</div>
|
||||
{estadoResultado === 'Positivo' && (
|
||||
<>
|
||||
|
||||
@@ -95,7 +95,7 @@ export function Dashboard({
|
||||
<span className="text-3xl font-bold">{estadisticas.camasFueraDeArea}</span>
|
||||
</div>
|
||||
<p className="text-xs text-gray-400 mt-1">
|
||||
outside of active service
|
||||
Camas Fuera de Area
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
@@ -21,7 +21,8 @@ import {
|
||||
Heart,
|
||||
Wind,
|
||||
Droplets,
|
||||
Save
|
||||
Save,
|
||||
X
|
||||
} from 'lucide-react';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
@@ -544,6 +545,11 @@ function SeccionLaboratorios({ lab, patientId, add, update, del }: {
|
||||
return r ? `${r.valor}` : '-';
|
||||
};
|
||||
|
||||
const getValorRaw = (l: Laboratorio, param: string) => {
|
||||
const r = l.resultados.find(r => r.parametro === param);
|
||||
return r ? `${r.valor}` : '';
|
||||
};
|
||||
|
||||
const getValorStyle = (l: Laboratorio, param: string) => {
|
||||
const r = l.resultados.find(r => r.parametro === param);
|
||||
if (!r) return '';
|
||||
@@ -586,6 +592,30 @@ function SeccionLaboratorios({ lab, patientId, add, update, del }: {
|
||||
setEdit(null);
|
||||
};
|
||||
|
||||
const loadEdit = (l: Laboratorio) => {
|
||||
setEdit(l);
|
||||
setFecha(l.fecha);
|
||||
setObservaciones(l.observaciones || '');
|
||||
setHto(getValorRaw(l, 'Hematocrito'));
|
||||
setHb(getValorRaw(l, 'Hemoglobina'));
|
||||
setGb(getValorRaw(l, 'Leucocitos'));
|
||||
setPlaq(getValorRaw(l, 'Plaquetas'));
|
||||
setGluc(getValorRaw(l, 'Glucemia'));
|
||||
setUrea(getValorRaw(l, 'Urea'));
|
||||
setCreat(getValorRaw(l, 'Creatinina'));
|
||||
setNa(getValorRaw(l, 'Sodio'));
|
||||
setK(getValorRaw(l, 'Potasio'));
|
||||
setCl(getValorRaw(l, 'Cloro'));
|
||||
setBt(getValorRaw(l, 'Bilirrubina Total'));
|
||||
setBd(getValorRaw(l, 'Bilirrubina Directa'));
|
||||
setGot(getValorRaw(l, 'GOT'));
|
||||
setGpt(getValorRaw(l, 'GPT'));
|
||||
setTp(getValorRaw(l, 'Tiempo de Protrombina'));
|
||||
setKptt(getValorRaw(l, 'KPTT'));
|
||||
setRin(getValorRaw(l, 'INR'));
|
||||
setDialog(true);
|
||||
};
|
||||
|
||||
const handleGuardar = () => {
|
||||
const resultadosLaboratorio = buildResultados();
|
||||
if (edit) {
|
||||
@@ -659,7 +689,7 @@ function SeccionLaboratorios({ lab, patientId, add, update, del }: {
|
||||
|
||||
<div><Label>Observaciones</Label><textarea className="w-full p-2 border rounded-md" value={observaciones} onChange={e => setObservaciones(e.target.value)} /></div>
|
||||
</div>
|
||||
<div className="flex justify-end gap-2 mt-4"><Button variant="outline" onClick={() => setDialog(false)}>Cancelar</Button><Button onClick={handleGuardar}><Plus />Guardar</Button></div>
|
||||
<div className="flex justify-end gap-2 mt-4"><Button variant="outline" onClick={() => setDialog(false)}><X className="h-4 w-4 mr-2" />Cancelar</Button><Button onClick={handleGuardar}><Save className="h-4 w-4 mr-2" />Guardar</Button></div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
@@ -727,7 +757,7 @@ function SeccionLaboratorios({ lab, patientId, add, update, del }: {
|
||||
<TableCell>
|
||||
<div className="flex items-center gap-1">
|
||||
{l.observaciones && <Button size="sm" variant="ghost" onClick={() => { setObsLab(l); setObsDialog(true); }}><ChevronRight className="h-4 w-4" /></Button>}
|
||||
<Button size="sm" variant="ghost" onClick={() => { setEdit(l); setDialog(true); }}><Pencil className="h-4 w-4" /></Button>
|
||||
<Button size="sm" variant="ghost" onClick={() => loadEdit(l)}><Pencil className="h-4 w-4" /></Button>
|
||||
<Button size="sm" variant="ghost" className="text-red-600" onClick={() => del(l.id)}><Trash2 className="h-4 w-4" /></Button>
|
||||
</div>
|
||||
</TableCell>
|
||||
@@ -876,7 +906,7 @@ function SeccionEvoluciones({ evos, internacionId, add, update, del }: {
|
||||
<div><Label>Pendientes</Label><textarea className="w-full p-2 border rounded-md text-sm min-h-[80px]" value={pendientes} onChange={e => setPendientes(e.target.value)} placeholder="Pendientes..." /></div>
|
||||
<div><Label>Médico *</Label><Input value={medico} onChange={e => setMedico(e.target.value)} placeholder="Nombre del médico" /></div>
|
||||
</div>
|
||||
<div className="flex justify-end gap-2 mt-4"><Button variant="outline" onClick={() => { reset(); setDialog(false); }}>Cancelar</Button><Button onClick={handle} disabled={!medico}><Plus className="h-4 w-4 mr-2" />Guardar Evolución</Button></div>
|
||||
<div className="flex justify-end gap-2 mt-4"><Button variant="outline" onClick={() => { reset(); setDialog(false); }}><X className="h-4 w-4 mr-2" />Cancelar</Button><Button onClick={handle} disabled={!medico}><Save className="h-4 w-4 mr-2" />Guardar Evolución</Button></div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
{evosFiltered.length === 0 ? <div className="text-center py-8 text-gray-400"><FileText className="h-12 w-12 mx-auto mb-2 opacity-50" /><p>No hay evoluciones</p></div> :
|
||||
@@ -1071,11 +1101,31 @@ function SeccionCultivos({ cults, patient, add, update, del }: {
|
||||
|
||||
const resetRes = () => {
|
||||
setFechaResultado(new Date().toISOString().split('T')[0]);
|
||||
setEstadoResultado('Parcial');
|
||||
setEstadoResultado('Positivo');
|
||||
setGermen('');
|
||||
setSensible('');
|
||||
setResistente('');
|
||||
setIsParcialMode(false);
|
||||
setSelected(null);
|
||||
};
|
||||
|
||||
const abrirParcial = (c: Cultivo) => {
|
||||
setSelected(c);
|
||||
setProtocolo(c.protocolo || '');
|
||||
setGermen(c.germen || '');
|
||||
setSensible(c.sensible || '');
|
||||
setResistente(c.resistente || '');
|
||||
setResDialog(true);
|
||||
};
|
||||
|
||||
const abrirDefinitivo = (c: Cultivo) => {
|
||||
setSelected(c);
|
||||
setProtocolo(c.protocolo || '');
|
||||
setFechaResultado(c.fechaResultado || new Date().toISOString().split('T')[0]);
|
||||
setEstadoResultado(c.estado === 'Parcial' || c.estado === 'Positivo' ? 'Positivo' : c.estado);
|
||||
setGermen(c.germen || '');
|
||||
setSensible(c.sensible || '');
|
||||
setResistente(c.resistente || '');
|
||||
setEditDialog(true);
|
||||
};
|
||||
|
||||
const openParcial = (c: Cultivo) => {
|
||||
@@ -1122,14 +1172,14 @@ function SeccionCultivos({ cults, patient, add, update, del }: {
|
||||
|
||||
const handleParcial = () => {
|
||||
if (!selected) return;
|
||||
update(selected.id, { estado: 'Parcial', germen: germen || undefined, sensible: sensible || undefined, resistente: resistente || undefined });
|
||||
update(selected.id, { protocolo: protocolo || undefined, estado: 'Parcial', germen: germen || undefined, sensible: sensible || undefined, resistente: resistente || undefined });
|
||||
setResDialog(false);
|
||||
resetRes();
|
||||
};
|
||||
|
||||
const handleDefinitivo = () => {
|
||||
if (!selected) return;
|
||||
update(selected.id, { fechaResultado, estado: estadoResultado, germen: germen || undefined, sensible: sensible || undefined, resistente: resistente || undefined });
|
||||
update(selected.id, { protocolo: protocolo || undefined, fechaResultado, estado: estadoResultado, germen: germen || undefined, sensible: sensible || undefined, resistente: resistente || undefined });
|
||||
setEditDialog(false);
|
||||
resetRes();
|
||||
};
|
||||
@@ -1176,13 +1226,14 @@ function SeccionCultivos({ cults, patient, add, update, del }: {
|
||||
<div className="space-y-4">
|
||||
<div className="bg-orange-50 border border-orange-200 p-3 rounded-lg">
|
||||
<p className="text-sm font-medium text-orange-800">Resultado Parcial - Sujeto a modificación</p>
|
||||
<p className="text-xs text-orange-600 mt-1">Ingrese el germen crecido para tomar conducta. Podrá editarse posteriormente.</p>
|
||||
<p className="text-xs text-orange-600 mt-1">Ingrese resultado parcial. Esto puede modificarse posteriormente.</p>
|
||||
</div>
|
||||
<div><Label>Protocolo</Label><Input value={protocolo} onChange={e => setProtocolo(e.target.value)} placeholder="N° Protocolo" /></div>
|
||||
<div><Label>Germen *</Label><Input value={germen} onChange={e => setGermen(e.target.value)} placeholder="Ej: Staphylococcos aureus" /></div>
|
||||
<div><Label>Sensible a:</Label><Input value={sensible} onChange={e => setSensible(e.target.value)} placeholder="Ej: Amikacina, Vancomicina" /></div>
|
||||
<div><Label>Resistente a:</Label><Input value={resistente} onChange={e => setResistente(e.target.value)} placeholder="Ej: Oxacilina" /></div>
|
||||
</div>
|
||||
<div className="flex justify-end gap-2 mt-4"><Button variant="outline" onClick={() => { resetRes(); setResDialog(false); }}>Cancelar</Button><Button onClick={handleParcial} disabled={!germen}><Save className="h-4 w-4 mr-2" />Guardar Parcial</Button></div>
|
||||
<div className="flex justify-end gap-2 mt-4"><Button variant="outline" onClick={() => { resetRes(); setResDialog(false); }}><X className="h-4 w-4 mr-2" />Cancelar</Button><Button onClick={handleParcial} disabled={!germen}><Save className="h-4 w-4 mr-2" />Guardar Parcial</Button></div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
@@ -1202,6 +1253,7 @@ function SeccionCultivos({ cults, patient, add, update, del }: {
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
<div><Label>Protocolo</Label><Input value={protocolo} onChange={e => setProtocolo(e.target.value)} placeholder="N° Protocolo" /></div>
|
||||
{estadoResultado === 'Positivo' && (
|
||||
<>
|
||||
<div><Label>Germen *</Label><Input value={germen} onChange={e => setGermen(e.target.value)} placeholder="Ej: Staphylococcus aureus" /></div>
|
||||
@@ -1210,7 +1262,7 @@ function SeccionCultivos({ cults, patient, add, update, del }: {
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex justify-end gap-2 mt-4"><Button variant="outline" onClick={() => { resetRes(); setEditDialog(false); }}>Cancelar</Button><Button onClick={handleDefinitivo} disabled={estadoResultado === 'Positivo' && !germen}><Save className="h-4 w-4 mr-2" />Guardar Definitivo</Button></div>
|
||||
<div className="flex justify-end gap-2 mt-4"><Button variant="outline" onClick={() => { resetRes(); setEditDialog(false); }}><X className="h-4 w-4 mr-2" />Cancelar</Button><Button onClick={handleDefinitivo} disabled={estadoResultado === 'Positivo' && !germen}><Save className="h-4 w-4 mr-2" />Guardar Definitivo</Button></div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user