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) {
|
if (cultivoSeleccionado && onActualizarCultivo && germen) {
|
||||||
onActualizarCultivo(cultivoSeleccionado.id, {
|
onActualizarCultivo(cultivoSeleccionado.id, {
|
||||||
estado: 'Parcial',
|
estado: 'Parcial',
|
||||||
|
protocolo: protocolo || undefined,
|
||||||
germen: germen || undefined,
|
germen: germen || undefined,
|
||||||
sensible: sensible || undefined,
|
sensible: sensible || undefined,
|
||||||
resistente: resistente || undefined,
|
resistente: resistente || undefined,
|
||||||
@@ -110,6 +111,7 @@ export function Cultivos({
|
|||||||
if (cultivoSeleccionado && onActualizarCultivo) {
|
if (cultivoSeleccionado && onActualizarCultivo) {
|
||||||
onActualizarCultivo(cultivoSeleccionado.id, {
|
onActualizarCultivo(cultivoSeleccionado.id, {
|
||||||
fechaResultado,
|
fechaResultado,
|
||||||
|
protocolo: protocolo || undefined,
|
||||||
estado: estadoResultado,
|
estado: estadoResultado,
|
||||||
germen: germen || undefined,
|
germen: germen || undefined,
|
||||||
sensible: sensible || undefined,
|
sensible: sensible || undefined,
|
||||||
@@ -122,6 +124,7 @@ export function Cultivos({
|
|||||||
|
|
||||||
const abrirParcial = (cultivo: Cultivo) => {
|
const abrirParcial = (cultivo: Cultivo) => {
|
||||||
setCultivoSeleccionado(cultivo);
|
setCultivoSeleccionado(cultivo);
|
||||||
|
setProtocolo(cultivo.protocolo || '');
|
||||||
setGermen(cultivo.germen || '');
|
setGermen(cultivo.germen || '');
|
||||||
setSensible(cultivo.sensible || '');
|
setSensible(cultivo.sensible || '');
|
||||||
setResistente(cultivo.resistente || '');
|
setResistente(cultivo.resistente || '');
|
||||||
@@ -130,6 +133,7 @@ export function Cultivos({
|
|||||||
|
|
||||||
const abrirDefinitivo = (cultivo: Cultivo) => {
|
const abrirDefinitivo = (cultivo: Cultivo) => {
|
||||||
setCultivoSeleccionado(cultivo);
|
setCultivoSeleccionado(cultivo);
|
||||||
|
setProtocolo(cultivo.protocolo || '');
|
||||||
setFechaResultado(cultivo.fechaResultado || new Date().toISOString().split('T')[0]);
|
setFechaResultado(cultivo.fechaResultado || new Date().toISOString().split('T')[0]);
|
||||||
setEstadoResultado(cultivo.estado === 'Parcial' || cultivo.estado === 'Positivo' ? 'Positivo' : cultivo.estado);
|
setEstadoResultado(cultivo.estado === 'Parcial' || cultivo.estado === 'Positivo' ? 'Positivo' : cultivo.estado);
|
||||||
setGermen(cultivo.germen || '');
|
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-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>
|
<p className="text-xs text-orange-600 mt-1">Ingrese resultado parcial. Esto puede modificarse posteriormente.</p>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<Label>Protocolo</Label>
|
||||||
|
<Input value={protocolo} onChange={(e) => setProtocolo(e.target.value)} placeholder="N° Protocolo" />
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<Label>Germen *</Label>
|
<Label>Germen *</Label>
|
||||||
<Input value={germen} onChange={(e) => setGermen(e.target.value)} placeholder="Ej: Staphylococcus aureus" />
|
<Input value={germen} onChange={(e) => setGermen(e.target.value)} placeholder="Ej: Staphylococcus aureus" />
|
||||||
@@ -334,6 +342,10 @@ export function Cultivos({
|
|||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="sm:col-span-2">
|
||||||
|
<Label>Protocolo</Label>
|
||||||
|
<Input value={protocolo} onChange={(e) => setProtocolo(e.target.value)} placeholder="N° Protocolo" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{estadoResultado === 'Positivo' && (
|
{estadoResultado === 'Positivo' && (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ export function Dashboard({
|
|||||||
<span className="text-3xl font-bold">{estadisticas.camasFueraDeArea}</span>
|
<span className="text-3xl font-bold">{estadisticas.camasFueraDeArea}</span>
|
||||||
</div>
|
</div>
|
||||||
<p className="text-xs text-gray-400 mt-1">
|
<p className="text-xs text-gray-400 mt-1">
|
||||||
outside of active service
|
Camas Fuera de Area
|
||||||
</p>
|
</p>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ import {
|
|||||||
Heart,
|
Heart,
|
||||||
Wind,
|
Wind,
|
||||||
Droplets,
|
Droplets,
|
||||||
Save
|
Save,
|
||||||
|
X
|
||||||
} from 'lucide-react';
|
} from 'lucide-react';
|
||||||
import { Card, CardContent } from '@/components/ui/card';
|
import { Card, CardContent } from '@/components/ui/card';
|
||||||
import { Badge } from '@/components/ui/badge';
|
import { Badge } from '@/components/ui/badge';
|
||||||
@@ -544,6 +545,11 @@ function SeccionLaboratorios({ lab, patientId, add, update, del }: {
|
|||||||
return r ? `${r.valor}` : '-';
|
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 getValorStyle = (l: Laboratorio, param: string) => {
|
||||||
const r = l.resultados.find(r => r.parametro === param);
|
const r = l.resultados.find(r => r.parametro === param);
|
||||||
if (!r) return '';
|
if (!r) return '';
|
||||||
@@ -586,6 +592,30 @@ function SeccionLaboratorios({ lab, patientId, add, update, del }: {
|
|||||||
setEdit(null);
|
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 handleGuardar = () => {
|
||||||
const resultadosLaboratorio = buildResultados();
|
const resultadosLaboratorio = buildResultados();
|
||||||
if (edit) {
|
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><Label>Observaciones</Label><textarea className="w-full p-2 border rounded-md" value={observaciones} onChange={e => setObservaciones(e.target.value)} /></div>
|
||||||
</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>
|
</DialogContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|
||||||
@@ -727,7 +757,7 @@ function SeccionLaboratorios({ lab, patientId, add, update, del }: {
|
|||||||
<TableCell>
|
<TableCell>
|
||||||
<div className="flex items-center gap-1">
|
<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>}
|
{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>
|
<Button size="sm" variant="ghost" className="text-red-600" onClick={() => del(l.id)}><Trash2 className="h-4 w-4" /></Button>
|
||||||
</div>
|
</div>
|
||||||
</TableCell>
|
</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>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><Label>Médico *</Label><Input value={medico} onChange={e => setMedico(e.target.value)} placeholder="Nombre del médico" /></div>
|
||||||
</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>
|
</DialogContent>
|
||||||
</Dialog>
|
</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> :
|
{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 = () => {
|
const resetRes = () => {
|
||||||
setFechaResultado(new Date().toISOString().split('T')[0]);
|
setFechaResultado(new Date().toISOString().split('T')[0]);
|
||||||
setEstadoResultado('Parcial');
|
setEstadoResultado('Positivo');
|
||||||
setGermen('');
|
setGermen('');
|
||||||
setSensible('');
|
setSensible('');
|
||||||
setResistente('');
|
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) => {
|
const openParcial = (c: Cultivo) => {
|
||||||
@@ -1122,14 +1172,14 @@ function SeccionCultivos({ cults, patient, add, update, del }: {
|
|||||||
|
|
||||||
const handleParcial = () => {
|
const handleParcial = () => {
|
||||||
if (!selected) return;
|
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);
|
setResDialog(false);
|
||||||
resetRes();
|
resetRes();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDefinitivo = () => {
|
const handleDefinitivo = () => {
|
||||||
if (!selected) return;
|
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);
|
setEditDialog(false);
|
||||||
resetRes();
|
resetRes();
|
||||||
};
|
};
|
||||||
@@ -1176,13 +1226,14 @@ function SeccionCultivos({ cults, patient, add, update, del }: {
|
|||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<div className="bg-orange-50 border border-orange-200 p-3 rounded-lg">
|
<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-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>
|
||||||
|
<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>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>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><Label>Resistente a:</Label><Input value={resistente} onChange={e => setResistente(e.target.value)} placeholder="Ej: Oxacilina" /></div>
|
||||||
</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>
|
</DialogContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|
||||||
@@ -1202,6 +1253,7 @@ function SeccionCultivos({ cults, patient, add, update, del }: {
|
|||||||
</Select>
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div><Label>Protocolo</Label><Input value={protocolo} onChange={e => setProtocolo(e.target.value)} placeholder="N° Protocolo" /></div>
|
||||||
{estadoResultado === 'Positivo' && (
|
{estadoResultado === 'Positivo' && (
|
||||||
<>
|
<>
|
||||||
<div><Label>Germen *</Label><Input value={germen} onChange={e => setGermen(e.target.value)} placeholder="Ej: Staphylococcus aureus" /></div>
|
<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>
|
||||||
<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>
|
</DialogContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user