Agregar hora a laboratorios: modal importar, save con hora seleccionada
This commit is contained in:
+332
-368
@@ -1,5 +1,13 @@
|
||||
import { useState } from 'react';
|
||||
import { PDFDocument } from 'pdf-lib';
|
||||
import { User } from 'lucide-react';
|
||||
import {
|
||||
Accordion,
|
||||
AccordionContent,
|
||||
AccordionItem,
|
||||
AccordionTrigger,
|
||||
} from "@/components/ui/accordion";
|
||||
|
||||
import {
|
||||
FlaskConical,
|
||||
Microscope,
|
||||
@@ -117,10 +125,10 @@ const RANGOS_LABORATORIO: Record<string, { min: number; max: number }> = {
|
||||
function calcularEstadoLaboratorio(parametro: string, valor: string): 'Normal' | 'Alto' | 'Bajo' {
|
||||
const rango = RANGOS_LABORATORIO[parametro];
|
||||
if (!rango) return 'Normal';
|
||||
|
||||
|
||||
const num = parseFloat(valor);
|
||||
if (isNaN(num)) return 'Normal';
|
||||
|
||||
|
||||
if (num < rango.min) return 'Bajo';
|
||||
if (num > rango.max) return 'Alto';
|
||||
return 'Normal';
|
||||
@@ -130,7 +138,7 @@ function wrapText(text: string, font: any, fontSize: number, maxWidth: number):
|
||||
const words = text.split(' ');
|
||||
const lines: string[] = [];
|
||||
let currentLine = '';
|
||||
|
||||
|
||||
for (const word of words) {
|
||||
const testLine = currentLine ? `${currentLine} ${word}` : word;
|
||||
const testWidth = font.widthOfTextAtSize(testLine, fontSize);
|
||||
@@ -145,6 +153,8 @@ function wrapText(text: string, font: any, fontSize: number, maxWidth: number):
|
||||
return lines;
|
||||
}
|
||||
|
||||
|
||||
|
||||
export function HistoriaClinica({
|
||||
internacion,
|
||||
paciente,
|
||||
@@ -203,40 +213,23 @@ export function HistoriaClinica({
|
||||
return Math.floor(diff / (1000 * 60 * 60 * 24));
|
||||
};
|
||||
|
||||
const handleGuardarEdicion = () => {
|
||||
if (editCamaId && editCamaId !== internacion.camaId && cama) {
|
||||
onActualizarCama(cama.id, { estado: 'Disponible', pacienteId: undefined, internacionId: undefined });
|
||||
}
|
||||
if (editCamaId) {
|
||||
onActualizarCama(editCamaId, { estado: 'Ocupada', pacienteId: paciente.id, internacionId: internacion.id });
|
||||
}
|
||||
onActualizarInternacion(internacion.id, {
|
||||
fechaIngresoClinica: editFechaIngreso,
|
||||
motivoConsulta: editMotivoConsulta,
|
||||
diagnosticoIngreso: editDiagnostico,
|
||||
enfermedadActual: editEnfermedadActual,
|
||||
antecedentesEnfermedadActual: editAntecedentes,
|
||||
medicoIngresante: editMedico,
|
||||
camaId: editCamaId || undefined,
|
||||
});
|
||||
setEditIngresoDialog(false);
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<div className="space-y-6 dark:text-white">
|
||||
<div>
|
||||
<div className="flex items-center gap-4 mb-4">
|
||||
|
||||
<div>
|
||||
<h1 className="text-2xl font-bold text-gray-900 dark:text-white flex items-center gap-2"><ClipboardList className="h-6 w-6" />Historia Clínica</h1>
|
||||
<p className="text-gray-500">
|
||||
Cama: {cama?.numero || 'N/A'} | {paciente.apellido}, {paciente.nombre} | {paciente.fechaNacimiento ? calcularEdad(paciente.fechaNacimiento) + ' años' : ''} | DNI: {paciente.dni}
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4">
|
||||
|
||||
<div>
|
||||
<h1 className="text-2xl font-bold text-gray-900 dark:text-white flex items-center gap-2">
|
||||
<ClipboardList className="h-6 w-6 text-blue-600" />
|
||||
{cama?.numero || 'N/A'} - Historia Clínica
|
||||
</h1>
|
||||
<p className="text-gray-500 dark:text-gray-400">Módulo de Historia Clínica de Internación</p>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-2 flex-wrap">
|
||||
<div className="flex items-center gap-2">
|
||||
|
||||
<Button variant="outline" onClick={onVolver}>
|
||||
<ArrowLeft className="h-4 w-4 mr-2" />
|
||||
Volver
|
||||
@@ -246,253 +239,224 @@ export function HistoriaClinica({
|
||||
Editar Ingreso
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<Dialog open={editIngresoDialog} onOpenChange={setEditIngresoDialog}>
|
||||
<DialogContent className="sm:max-w-2xl max-h-[90vh] overflow-y-auto">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Editar Ingreso</DialogTitle>
|
||||
</DialogHeader>
|
||||
<Card className="bg-muted/50">
|
||||
<CardContent className="p-4">
|
||||
<div className="flex flex-wrap gap-2 mb-2">
|
||||
<Badge variant="outline" className="bg-primary/10 text-primary border-primary/30">
|
||||
{paciente.apellido}, {paciente.nombre}
|
||||
</Badge>
|
||||
<Badge variant="outline" className="bg-primary/10 text-primary border-primary/30">
|
||||
{paciente.fechaNacimiento ? calcularEdad(paciente.fechaNacimiento) + ' años' : ''}
|
||||
</Badge>
|
||||
<Badge variant="outline" className="bg-primary/10 text-primary border-primary/30">
|
||||
DNI: {paciente.dni}
|
||||
</Badge>
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<Badge variant="secondary">
|
||||
HC: {paciente.historiaClinica || 'N/A'}
|
||||
</Badge>
|
||||
<Badge variant="secondary">
|
||||
{paciente.obraSocial || 'Sin obra social'}
|
||||
</Badge>
|
||||
<Badge variant="secondary">
|
||||
{paciente.nacionalidad || 'N/A'}
|
||||
</Badge>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
<div className="space-y-4">
|
||||
<div className="grid grid-cols-3 gap-4">
|
||||
<div>
|
||||
<Label>Fecha de Ingreso *</Label>
|
||||
<Input type="date" value={editFechaIngreso} onChange={e => setEditFechaIngreso(e.target.value)} />
|
||||
</div>
|
||||
<div>
|
||||
<Label>Médico Ingresante *</Label>
|
||||
<Input value={editMedico} onChange={e => setEditMedico(e.target.value)} placeholder="Nombre del médico" />
|
||||
</div>
|
||||
<div>
|
||||
<Label>Cama</Label>
|
||||
<Select value={editCamaId} onValueChange={setEditCamaId}>
|
||||
<SelectTrigger><SelectValue placeholder="Seleccionar cama" /></SelectTrigger>
|
||||
<SelectContent>
|
||||
{(allCamas || []).filter((c: Cama) => c.estado === 'Disponible' || c.id === cama?.id).map((c: Cama) => (
|
||||
<SelectItem key={c.id} value={c.id}>{c.numero}</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<Label>Motivo de Consulta</Label>
|
||||
<textarea className="w-full p-2 border rounded-md text-sm min-h-[60px]" value={editMotivoConsulta} onChange={e => setEditMotivoConsulta(e.target.value)} />
|
||||
</div>
|
||||
<div>
|
||||
<Label>Diagnóstico de Ingreso *</Label>
|
||||
<textarea className="w-full p-2 border rounded-md text-sm min-h-[60px]" value={editDiagnostico} onChange={e => setEditDiagnostico(e.target.value)} />
|
||||
</div>
|
||||
<div>
|
||||
<Label>Enfermedad Actual</Label>
|
||||
<textarea className="w-full p-2 border rounded-md text-sm min-h-[80px]" value={editEnfermedadActual} onChange={e => setEditEnfermedadActual(e.target.value)} />
|
||||
</div>
|
||||
<div>
|
||||
<Label>Antecedentes de la Enfermedad Actual</Label>
|
||||
<textarea className="w-full p-2 border rounded-md text-sm min-h-[80px]" value={editAntecedentes} onChange={e => setEditAntecedentes(e.target.value)} />
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex justify-end gap-2 mt-4">
|
||||
<Button variant="outline" onClick={() => setEditIngresoDialog(false)}><X className="h-4 w-4 mr-2" />Cancelar</Button>
|
||||
<Button onClick={handleGuardarEdicion} disabled={!editFechaIngreso || !editDiagnostico || !editMedico}><Save className="h-4 w-4 mr-2" />Guardar</Button>
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
<Card>
|
||||
<CardContent className="p-0">
|
||||
<button type="button" className="w-full p-4 flex items-center justify-between hover:bg-gray-50" onClick={() => setDetalleExpandido(!detalleExpandido)}>
|
||||
<div className="grid grid-cols-2 sm:grid-cols-4 gap-4 text-sm w-full">
|
||||
|
||||
<CardContent className="p-4">
|
||||
<div className="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4">
|
||||
<div><h2 className="font-bold text-lg text-gray-900 flex items-center gap-2">
|
||||
<User className="h-4 w-4" />
|
||||
{paciente.apellido}, {paciente.nombre}
|
||||
</h2>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Badge className={internacion.fechaIngresoClinica && calcularDiasInternado(internacion.fechaIngresoClinica) > 7 ? 'bg-red-100 text-red-800' : 'bg-blue-100 text-blue-800'}>
|
||||
{internacion.fechaIngresoClinica ? calcularDiasInternado(internacion.fechaIngresoClinica) : 0} días internado
|
||||
</Badge>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<Badge variant="outline" className="text-sm px-3 py-1 bg-green-50 text-green-700 dark:bg-green-950 dark:text-green-300">
|
||||
{paciente.fechaNacimiento ? calcularEdad(paciente.fechaNacimiento) + ' años' : ''}
|
||||
</Badge>
|
||||
|
||||
<Badge variant="outline" className="text-sm px-3 py-1 bg-blue-50 text-blue-700 border-blue-200">
|
||||
DNI: {paciente.dni}
|
||||
</Badge>
|
||||
|
||||
</div>
|
||||
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<Badge variant="secondary" className="text-sm px-3 py-1">
|
||||
HC: {paciente.historiaClinica || 'No posee'}
|
||||
</Badge>
|
||||
<Badge variant="secondary" className="text-sm px-3 py-1">
|
||||
OS: {paciente.obraSocial || 'No posee'}
|
||||
</Badge>
|
||||
<Badge variant="secondary" className="text-sm px-3 py-1">
|
||||
Nacionalidad: {paciente.nacionalidad || 'N/A'}
|
||||
</Badge>
|
||||
</div>
|
||||
|
||||
<div className="border-t p-4 space-y-4">
|
||||
|
||||
|
||||
<div>
|
||||
<p className="text-gray-500">Antecedentes</p>
|
||||
<p className="font-medium truncate">{paciente.antecedentes || 'No constan'}</p>
|
||||
<p className="text-gray-500 text-sm">Antecedentes</p>
|
||||
<p className="font-medium">{paciente.antecedentes || 'No refiere'}</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div>
|
||||
<p className="text-gray-500 text-sm">MH</p>
|
||||
<p className="font-medium">{paciente.medicacionHabitual || 'No refiere'}</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p className="text-gray-500">Fecha de Ingreso</p>
|
||||
<p className="font-medium">{internacion.fechaIngresoClinica ? formatDateDDMMYYYY(internacion.fechaIngresoClinica) : 'N/A'}</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p className="text-gray-500">Diagnóstico de Ingreso</p>
|
||||
<p className="font-medium truncate">{internacion.diagnosticoIngreso}</p>
|
||||
<p className="font-medium">{internacion.diagnosticoIngreso}</p>
|
||||
</div>
|
||||
<div>
|
||||
<p className="text-gray-500">Días de Internación</p>
|
||||
<Badge className={internacion.fechaIngresoClinica && calcularDiasInternado(internacion.fechaIngresoClinica) > 7 ? 'bg-red-100 text-red-800' : 'bg-blue-100 text-blue-800'}>
|
||||
{internacion.fechaIngresoClinica ? calcularDiasInternado(internacion.fechaIngresoClinica) : 0} días
|
||||
</Badge>
|
||||
</div>
|
||||
|
||||
|
||||
<Accordion type="single" collapsible defaultValue="item-1">
|
||||
<AccordionItem value="item-1">
|
||||
<AccordionTrigger>Detalle Episodio Actual</AccordionTrigger>
|
||||
<AccordionContent className="p4">
|
||||
<div className="border-t p-4 space-y-4">
|
||||
|
||||
|
||||
<div>
|
||||
<p className="text-gray-500 text-sm">Motivo de Consulta</p>
|
||||
<p className="font-medium">{internacion.motivoConsulta || 'Sin motivo registrado'}</p>
|
||||
</div>
|
||||
<div>
|
||||
<p className="text-gray-500 text-sm">Enfermedad Actual</p>
|
||||
<p className="font-medium">{internacion.enfermedadActual || 'Sin información'}</p>
|
||||
</div>
|
||||
<div>
|
||||
<p className="text-gray-500 text-sm">Antecedentes de Enfermedad Actual</p>
|
||||
<p className="font-medium">{internacion.antecedentesEnfermedadActual || 'Sin antecedentes registrados'}</p>
|
||||
</div>
|
||||
<Button variant="outline" className="bg-blue-50 border-blue-300 text-blue-700 hover:bg-blue-100" onClick={async (e) => {
|
||||
e.stopPropagation();
|
||||
try {
|
||||
const { PDFDocument, StandardFonts, rgb } = await import('pdf-lib');
|
||||
const pdfDoc = await PDFDocument.create();
|
||||
const page = pdfDoc.addPage([595, 842]);
|
||||
const { width, height } = page.getSize();
|
||||
|
||||
const font = await pdfDoc.embedFont(StandardFonts.Helvetica);
|
||||
const fontBold = await pdfDoc.embedFont(StandardFonts.HelveticaBold);
|
||||
|
||||
const colorPrimary = rgb(0.18, 0.34, 0.55);
|
||||
const colorText = rgb(0.13, 0.13, 0.13);
|
||||
const colorGray = rgb(0.45, 0.45, 0.45);
|
||||
const colorLightGray = rgb(0.92, 0.92, 0.92);
|
||||
|
||||
const edad = paciente.fechaNacimiento ? calcularEdad(paciente.fechaNacimiento) : '';
|
||||
const fechaFormateada = internacion.fechaIngresoClinica ? formatDateDDMMYYYY(internacion.fechaIngresoClinica) : 'N/A';
|
||||
const fechaHospital = internacion.fechaIngresoHospital ? formatDateDDMMYYYY(internacion.fechaIngresoHospital) : '';
|
||||
|
||||
// Header
|
||||
page.drawRectangle({ x: 0, y: height - 100, width, height: 100, color: colorPrimary });
|
||||
page.drawText('HOSPITAL DONACIÓN F. SANTOJANNI – DIVISIÓN CLÍNICA MÉDICA', { x: 60, y: height - 35, size: 14, font: fontBold, color: rgb(1, 1, 1) });
|
||||
page.drawText('HISTORIA CLÍNICA DE INGRESO', { x: 170, y: height - 55, size: 12, font: fontBold, color: rgb(1, 1, 1) });
|
||||
|
||||
let y = height - 140;
|
||||
|
||||
// Datos Filiatorios
|
||||
page.drawRectangle({ x: 45, y: y - 8, width: 505, height: 24, color: colorLightGray });
|
||||
page.drawText('DATOS FILIATORIOS', { x: 50, y: y, size: 12, font: fontBold, color: colorPrimary });
|
||||
y -= 35;
|
||||
|
||||
// Primera línea: Fechas y cama
|
||||
const fechaIngresoHospText = fechaHospital ? `Fecha ingreso al hospital: ${fechaHospital}` : '';
|
||||
const fechaIngresoClinText = fechaFormateada ? `Fecha ingreso a clínica: ${fechaFormateada}` : '';
|
||||
const camaText = `Cama: ${cama?.numero || 'N/A'}`;
|
||||
|
||||
page.drawText(fechaIngresoHospText, { x: 50, y, size: 10, font: fontBold, color: colorGray });
|
||||
page.drawText(fechaIngresoClinText, { x: 260, y, size: 10, font: fontBold, color: colorGray });
|
||||
y -= 18;
|
||||
page.drawText(camaText, { x: 50, y, size: 10, font: fontBold, color: colorGray });
|
||||
y -= 25;
|
||||
|
||||
// Segunda línea: Apellido, Nombre y DNI
|
||||
page.drawText(`Apellido y Nombre: ${paciente.apellido || ''}, ${paciente.nombre || ''}`, { x: 50, y, size: 10, font: fontBold, color: colorGray });
|
||||
y -= 18;
|
||||
page.drawText(`DNI: ${paciente.dni || ''}`, { x: 50, y, size: 10, font: fontBold, color: colorGray });
|
||||
page.drawText(`Edad: ${edad ? `${edad} años` : ''}`, { x: 280, y, size: 10, font: fontBold, color: colorGray });
|
||||
y -= 40;
|
||||
|
||||
// Datos Clínicos
|
||||
page.drawRectangle({ x: 45, y: y - 8, width: 505, height: 24, color: colorLightGray });
|
||||
page.drawText('DATOS CLÍNICOS', { x: 50, y: y, size: 12, font: fontBold, color: colorPrimary });
|
||||
y -= 35;
|
||||
|
||||
page.drawText('Motivo de Consulta:', { x: 50, y, size: 10, font: fontBold, color: colorGray });
|
||||
y -= 18;
|
||||
const motivoLines = wrapText(internacion.motivoConsulta || 'Sin información', font, 10, 480);
|
||||
for (const line of motivoLines.slice(0, 4)) {
|
||||
page.drawText(line, { x: 50, y, size: 10, font, color: colorText });
|
||||
y -= 14;
|
||||
}
|
||||
y -= 10;
|
||||
if (motivoLines.length > 4) y -= (motivoLines.length - 4) * 14;
|
||||
|
||||
page.drawText('Enfermedad Actual:', { x: 50, y, size: 10, font: fontBold, color: colorGray });
|
||||
y -= 18;
|
||||
const enfermedadLines = wrapText(internacion.enfermedadActual || 'Sin información', font, 10, 480);
|
||||
for (const line of enfermedadLines.slice(0, 4)) {
|
||||
page.drawText(line, { x: 50, y, size: 10, font, color: colorText });
|
||||
y -= 14;
|
||||
}
|
||||
y -= 10;
|
||||
if (enfermedadLines.length > 4) y -= (enfermedadLines.length - 4) * 14;
|
||||
|
||||
page.drawText('Antecedentes de la Enfermedad Actual:', { x: 50, y, size: 10, font: fontBold, color: colorGray });
|
||||
y -= 18;
|
||||
const antecedentesLines = wrapText(internacion.antecedentesEnfermedadActual || 'Sin antecedentes registrados', font, 10, 480);
|
||||
for (const line of antecedentesLines.slice(0, 4)) {
|
||||
page.drawText(line, { x: 50, y, size: 10, font, color: colorText });
|
||||
y -= 14;
|
||||
}
|
||||
y -= 10;
|
||||
if (antecedentesLines.length > 4) y -= (antecedentesLines.length - 4) * 14;
|
||||
|
||||
page.drawText('Diagnóstico de Ingreso:', { x: 50, y, size: 10, font: fontBold, color: colorGray });
|
||||
y -= 18;
|
||||
const diagnosticoLines = wrapText(internacion.diagnosticoIngreso || 'Sin diagnóstico', font, 10, 480);
|
||||
for (const line of diagnosticoLines.slice(0, 3)) {
|
||||
page.drawText(line, { x: 50, y, size: 10, font, color: colorText });
|
||||
y -= 14;
|
||||
}
|
||||
|
||||
// Footer
|
||||
y -= 20;
|
||||
page.drawLine({ start: { x: 50, y }, end: { x: 250, y }, thickness: 0.5, color: colorGray });
|
||||
page.drawText('Firma del Médico', { x: 50, y: y - 15, size: 9, font, color: colorGray });
|
||||
page.drawLine({ start: { x: 320, y }, end: { x: 520, y }, thickness: 0.5, color: colorGray });
|
||||
page.drawText('Aclaración / Sello', { x: 320, y: y - 15, size: 9, font, color: colorGray });
|
||||
page.drawText('v2.0', { x: width - 60, y: 30, size: 8, font, color: colorGray });
|
||||
|
||||
const pdfBytes = await pdfDoc.save();
|
||||
const blob = new Blob([new Uint8Array(pdfBytes)], { type: 'application/pdf' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.download = `FormularioIngreso_${paciente.apellido}_${paciente.dni}.pdf`;
|
||||
link.click();
|
||||
URL.revokeObjectURL(url);
|
||||
} catch (err) {
|
||||
console.error('Error generating PDF:', err);
|
||||
}
|
||||
}}>
|
||||
<FileDown className="h-4 w-4 mr-2" />
|
||||
Descargar Formulario de Ingreso
|
||||
</Button>
|
||||
</div>
|
||||
</AccordionContent>
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
|
||||
</div>
|
||||
{detalleExpandido ? <ChevronUp className="h-5 w-5 text-gray-400" /> : <ChevronDown className="h-5 w-5 text-gray-400" />}
|
||||
</button>
|
||||
{detalleExpandido && (
|
||||
<div className="border-t p-4 space-y-4">
|
||||
<div>
|
||||
<p className="text-gray-500 text-sm">Motivo de Consulta</p>
|
||||
<p className="font-medium">{internacion.motivoConsulta || 'Sin motivo registrado'}</p>
|
||||
</div>
|
||||
<div>
|
||||
<p className="text-gray-500 text-sm">Enfermedad Actual</p>
|
||||
<p className="font-medium">{internacion.enfermedadActual || 'Sin información'}</p>
|
||||
</div>
|
||||
<div>
|
||||
<p className="text-gray-500 text-sm">Antecedentes de Enfermedad Actual</p>
|
||||
<p className="font-medium">{internacion.antecedentesEnfermedadActual || 'Sin antecedentes registrados'}</p>
|
||||
</div>
|
||||
<Button variant="outline" className="bg-blue-50 border-blue-300 text-blue-700 hover:bg-blue-100" onClick={async (e) => {
|
||||
e.stopPropagation();
|
||||
try {
|
||||
const { PDFDocument, StandardFonts, rgb } = await import('pdf-lib');
|
||||
const pdfDoc = await PDFDocument.create();
|
||||
const page = pdfDoc.addPage([595, 842]);
|
||||
const { width, height } = page.getSize();
|
||||
|
||||
const font = await pdfDoc.embedFont(StandardFonts.Helvetica);
|
||||
const fontBold = await pdfDoc.embedFont(StandardFonts.HelveticaBold);
|
||||
|
||||
const colorPrimary = rgb(0.18, 0.34, 0.55);
|
||||
const colorText = rgb(0.13, 0.13, 0.13);
|
||||
const colorGray = rgb(0.45, 0.45, 0.45);
|
||||
const colorLightGray = rgb(0.92, 0.92, 0.92);
|
||||
|
||||
const edad = paciente.fechaNacimiento ? calcularEdad(paciente.fechaNacimiento) : '';
|
||||
const fechaFormateada = internacion.fechaIngresoClinica ? formatDateDDMMYYYY(internacion.fechaIngresoClinica) : 'N/A';
|
||||
const fechaHospital = internacion.fechaIngresoHospital ? formatDateDDMMYYYY(internacion.fechaIngresoHospital) : '';
|
||||
</div>
|
||||
|
||||
// Header
|
||||
page.drawRectangle({ x: 0, y: height - 100, width, height: 100, color: colorPrimary });
|
||||
page.drawText('HOSPITAL DONACIÓN F. SANTOJANNI – DIVISIÓN CLÍNICA MÉDICA', { x: 60, y: height - 35, size: 14, font: fontBold, color: rgb(1, 1, 1) });
|
||||
page.drawText('HISTORIA CLÍNICA DE INGRESO', { x: 170, y: height - 55, size: 12, font: fontBold, color: rgb(1, 1, 1) });
|
||||
|
||||
let y = height - 140;
|
||||
|
||||
// Datos Filiatorios
|
||||
page.drawRectangle({ x: 45, y: y - 8, width: 505, height: 24, color: colorLightGray });
|
||||
page.drawText('DATOS FILIATORIOS', { x: 50, y: y, size: 12, font: fontBold, color: colorPrimary });
|
||||
y -= 35;
|
||||
|
||||
// Primera línea: Fechas y cama
|
||||
const fechaIngresoHospText = fechaHospital ? `Fecha ingreso al hospital: ${fechaHospital}` : '';
|
||||
const fechaIngresoClinText = fechaFormateada ? `Fecha ingreso a clínica: ${fechaFormateada}` : '';
|
||||
const camaText = `Cama: ${cama?.numero || 'N/A'}`;
|
||||
|
||||
page.drawText(fechaIngresoHospText, { x: 50, y, size: 10, font: fontBold, color: colorGray });
|
||||
page.drawText(fechaIngresoClinText, { x: 260, y, size: 10, font: fontBold, color: colorGray });
|
||||
y -= 18;
|
||||
page.drawText(camaText, { x: 50, y, size: 10, font: fontBold, color: colorGray });
|
||||
y -= 25;
|
||||
|
||||
// Segunda línea: Apellido, Nombre y DNI
|
||||
page.drawText(`Apellido y Nombre: ${paciente.apellido || ''}, ${paciente.nombre || ''}`, { x: 50, y, size: 10, font: fontBold, color: colorGray });
|
||||
y -= 18;
|
||||
page.drawText(`DNI: ${paciente.dni || ''}`, { x: 50, y, size: 10, font: fontBold, color: colorGray });
|
||||
page.drawText(`Edad: ${edad ? `${edad} años` : ''}`, { x: 280, y, size: 10, font: fontBold, color: colorGray });
|
||||
y -= 40;
|
||||
|
||||
// Datos Clínicos
|
||||
page.drawRectangle({ x: 45, y: y - 8, width: 505, height: 24, color: colorLightGray });
|
||||
page.drawText('DATOS CLÍNICOS', { x: 50, y: y, size: 12, font: fontBold, color: colorPrimary });
|
||||
y -= 35;
|
||||
|
||||
page.drawText('Motivo de Consulta:', { x: 50, y, size: 10, font: fontBold, color: colorGray });
|
||||
y -= 18;
|
||||
const motivoLines = wrapText(internacion.motivoConsulta || 'Sin información', font, 10, 480);
|
||||
for (const line of motivoLines.slice(0, 4)) {
|
||||
page.drawText(line, { x: 50, y, size: 10, font, color: colorText });
|
||||
y -= 14;
|
||||
}
|
||||
y -= 10;
|
||||
if (motivoLines.length > 4) y -= (motivoLines.length - 4) * 14;
|
||||
|
||||
page.drawText('Enfermedad Actual:', { x: 50, y, size: 10, font: fontBold, color: colorGray });
|
||||
y -= 18;
|
||||
const enfermedadLines = wrapText(internacion.enfermedadActual || 'Sin información', font, 10, 480);
|
||||
for (const line of enfermedadLines.slice(0, 4)) {
|
||||
page.drawText(line, { x: 50, y, size: 10, font, color: colorText });
|
||||
y -= 14;
|
||||
}
|
||||
y -= 10;
|
||||
if (enfermedadLines.length > 4) y -= (enfermedadLines.length - 4) * 14;
|
||||
|
||||
page.drawText('Antecedentes de la Enfermedad Actual:', { x: 50, y, size: 10, font: fontBold, color: colorGray });
|
||||
y -= 18;
|
||||
const antecedentesLines = wrapText(internacion.antecedentesEnfermedadActual || 'Sin antecedentes registrados', font, 10, 480);
|
||||
for (const line of antecedentesLines.slice(0, 4)) {
|
||||
page.drawText(line, { x: 50, y, size: 10, font, color: colorText });
|
||||
y -= 14;
|
||||
}
|
||||
y -= 10;
|
||||
if (antecedentesLines.length > 4) y -= (antecedentesLines.length - 4) * 14;
|
||||
|
||||
page.drawText('Diagnóstico de Ingreso:', { x: 50, y, size: 10, font: fontBold, color: colorGray });
|
||||
y -= 18;
|
||||
const diagnosticoLines = wrapText(internacion.diagnosticoIngreso || 'Sin diagnóstico', font, 10, 480);
|
||||
for (const line of diagnosticoLines.slice(0, 3)) {
|
||||
page.drawText(line, { x: 50, y, size: 10, font, color: colorText });
|
||||
y -= 14;
|
||||
}
|
||||
|
||||
// Footer
|
||||
y -= 20;
|
||||
page.drawLine({ start: { x: 50, y }, end: { x: 250, y }, thickness: 0.5, color: colorGray });
|
||||
page.drawText('Firma del Médico', { x: 50, y: y - 15, size: 9, font, color: colorGray });
|
||||
page.drawLine({ start: { x: 320, y }, end: { x: 520, y }, thickness: 0.5, color: colorGray });
|
||||
page.drawText('Aclaración / Sello', { x: 320, y: y - 15, size: 9, font, color: colorGray });
|
||||
page.drawText('v2.0', { x: width - 60, y: 30, size: 8, font, color: colorGray });
|
||||
|
||||
const pdfBytes = await pdfDoc.save();
|
||||
const blob = new Blob([new Uint8Array(pdfBytes)], { type: 'application/pdf' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.download = `FormularioIngreso_${paciente.apellido}_${paciente.dni}.pdf`;
|
||||
link.click();
|
||||
URL.revokeObjectURL(url);
|
||||
} catch (err) {
|
||||
console.error('Error generating PDF:', err);
|
||||
}
|
||||
}}>
|
||||
<FileDown className="h-4 w-4 mr-2" />
|
||||
Descargar Formulario de Ingreso
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<Tabs value={tabActivo} onValueChange={setTabActivo}>
|
||||
<TabsList className="flex w-full overflow-x-auto gap-1 pb-2">
|
||||
<TabsTrigger value="evoluciones" className="flex-shrink-0 flex items-center gap-1 text-xs sm:text-sm">
|
||||
@@ -544,12 +508,12 @@ export function HistoriaClinica({
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="estudios" className="mt-4">
|
||||
<SeccionEstudiosComplementarios
|
||||
estudios={estudiosComplementarios}
|
||||
internacionId={internacion.id}
|
||||
<SeccionEstudiosComplementarios
|
||||
estudios={estudiosComplementarios}
|
||||
internacionId={internacion.id}
|
||||
pacienteId={paciente.id}
|
||||
add={onAgregarEstudioComplementario}
|
||||
del={onEliminarEstudioComplementario}
|
||||
add={onAgregarEstudioComplementario}
|
||||
del={onEliminarEstudioComplementario}
|
||||
/>
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
@@ -665,7 +629,7 @@ function SeccionLaboratorios({ lab, patientId, add, update, del, addAcidoBase }:
|
||||
if (tp) res.push({ parametro: 'Tiempo de Protrombina', valor: tp, unidad: 'seg', estado: calcularEstadoLaboratorio('Tiempo de Protrombina', tp) });
|
||||
if (kptt) res.push({ parametro: 'KPTT', valor: kptt, unidad: 'seg', estado: calcularEstadoLaboratorio('KPTT', kptt) });
|
||||
if (rin) res.push({ parametro: 'INR', valor: rin, unidad: '', estado: calcularEstadoLaboratorio('INR', rin) });
|
||||
return res;
|
||||
return res;
|
||||
};
|
||||
|
||||
const reset = () => {
|
||||
@@ -683,7 +647,7 @@ return res;
|
||||
const parseLaboratorioTexto = (texto: string): { resultados: ResultadoLaboratorio[]; observaciones: string } => {
|
||||
const resultados: ResultadoLaboratorio[] = [];
|
||||
const observacionesExtra: string[] = [];
|
||||
|
||||
|
||||
const mapeoParametros: Record<string, { nombre: string; unidad: string; esPrincipal: boolean }> = {
|
||||
'hematíes': { nombre: 'Hematíes', unidad: '10⁶/µl', esPrincipal: false },
|
||||
'hematocrito': { nombre: 'Hematocrito', unidad: '%', esPrincipal: true },
|
||||
@@ -725,10 +689,10 @@ return res;
|
||||
};
|
||||
|
||||
const lineas = texto.split('\n');
|
||||
|
||||
for (const linea of lineas) {
|
||||
|
||||
for (const linea of lineas) {
|
||||
const lineaLower = linea.toLowerCase().trim();
|
||||
|
||||
|
||||
for (const [clave, info] of Object.entries(mapeoParametros)) {
|
||||
if (lineaLower.includes(clave)) {
|
||||
// buscar primer valor numérico después de cualquier texto (letra o palabra)
|
||||
@@ -741,7 +705,7 @@ for (const linea of lineas) {
|
||||
if (nombreNormalizado === 'Leucocitos' || nombreNormalizado === 'Plaquetas') {
|
||||
valorFinal = valor * 1000;
|
||||
}
|
||||
|
||||
|
||||
if (info.esPrincipal) {
|
||||
resultados.push({
|
||||
parametro: nombreNormalizado,
|
||||
@@ -757,13 +721,13 @@ for (const linea of lineas) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return { resultados, observaciones: observacionesExtra.join('\n') };
|
||||
};
|
||||
|
||||
const parseAcidoBaseTexto = (texto: string): Omit<AcidoBase, 'id'> | null => {
|
||||
const lineas = texto.split('\n');
|
||||
|
||||
|
||||
let ph: number | undefined;
|
||||
let pco2: number | undefined;
|
||||
let po2: number | undefined;
|
||||
@@ -773,10 +737,10 @@ for (const linea of lineas) {
|
||||
let lactato: number | undefined;
|
||||
let fio2: number | undefined;
|
||||
let fecha = importFecha;
|
||||
|
||||
|
||||
for (const linea of lineas) {
|
||||
const cleanLinea = linea.replace(/show_chart|list_alt|\t+/g, ' ').replace(/,/g, '.').replace(/\s+/g, ' ').trim().toLowerCase();
|
||||
|
||||
|
||||
const getValue = (param: string): number | undefined => {
|
||||
const idx = cleanLinea.indexOf(param);
|
||||
if (idx === -1) return undefined;
|
||||
@@ -788,7 +752,7 @@ for (const linea of lineas) {
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
|
||||
|
||||
if (cleanLinea.includes('estado') && cleanLinea.includes('ácido') || cleanLinea.includes('base')) {
|
||||
ph = getValue('ph') || (cleanLinea.match(/ph\s+(\d+\.?\d*)/)?.[1] ? parseFloat(cleanLinea.match(/ph\s+(\d+\.?\d*)/)![1]) : undefined);
|
||||
pco2 = getValue('pco2') || getValue('pco₂');
|
||||
@@ -801,7 +765,7 @@ for (const linea of lineas) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!ph) {
|
||||
for (const linea of lineas) {
|
||||
const cleanLinea = linea.replace(/show_chart|list_alt|\t+/g, ' ').replace(/,/g, '.').replace(/\s+/g, ' ').trim().toLowerCase();
|
||||
@@ -816,7 +780,7 @@ for (const linea of lineas) {
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
|
||||
|
||||
if (cleanLinea.includes('ph') && !cleanLinea.includes('pco2') && !cleanLinea.includes('pco')) { ph = getValue('ph'); }
|
||||
else if (cleanLinea.includes('pco2') || cleanLinea.includes('pco₂')) { pco2 = getValue('pco2'); }
|
||||
else if (cleanLinea.includes('po2') || cleanLinea.includes('po₂')) { po2 = getValue('po2'); }
|
||||
@@ -827,7 +791,7 @@ for (const linea of lineas) {
|
||||
else if (cleanLinea.includes('fio2')) { fio2 = getValue('fio2'); }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ph) {
|
||||
return { pacienteId: patientId, fecha, hora: '', ph, pco2: pco2 || 40, po2: po2 || 85, hco3: hco3 || 24, be: be || 0, sato2: sato2 || 97, lactato, fio2, interpretacion: '' };
|
||||
}
|
||||
@@ -837,7 +801,7 @@ for (const linea of lineas) {
|
||||
const handleProcesarTexto = () => {
|
||||
const { resultados, observaciones } = parseLaboratorioTexto(importTexto);
|
||||
const acidoBase = parseAcidoBaseTexto(importTexto);
|
||||
|
||||
|
||||
setImportResultados(resultados);
|
||||
setImportObservaciones(observaciones);
|
||||
setImportAcidoBase(acidoBase);
|
||||
@@ -846,11 +810,11 @@ for (const linea of lineas) {
|
||||
const handleImportarLaboratorio = () => {
|
||||
if (!addAcidoBase) return;
|
||||
if (importResultados.length === 0 && !importObservaciones && !importAcidoBase) return;
|
||||
|
||||
|
||||
if (importAcidoBase) {
|
||||
addAcidoBase({ ...importAcidoBase, fecha: importFecha, hora: importHora });
|
||||
}
|
||||
|
||||
|
||||
add({
|
||||
pacienteId: patientId,
|
||||
fecha: importFecha,
|
||||
@@ -858,7 +822,7 @@ for (const linea of lineas) {
|
||||
resultados: importResultados,
|
||||
observaciones: importObservaciones
|
||||
});
|
||||
|
||||
|
||||
setImportDialog(false);
|
||||
setImportTexto('');
|
||||
setImportResultados([]);
|
||||
@@ -1023,17 +987,17 @@ for (const linea of lineas) {
|
||||
<CartesianGrid strokeDasharray="3 3" className="opacity-30" />
|
||||
<XAxis dataKey="fecha" tick={{ fontSize: 12 }} />
|
||||
<YAxis tick={{ fontSize: 12 }} domain={['auto', 'auto']} />
|
||||
<Tooltip
|
||||
contentStyle={{
|
||||
backgroundColor: 'hsl(var(--card))',
|
||||
<Tooltip
|
||||
contentStyle={{
|
||||
backgroundColor: 'hsl(var(--card))',
|
||||
border: '1px solid hsl(var(--border))',
|
||||
borderRadius: '8px'
|
||||
}}
|
||||
/>
|
||||
<Line
|
||||
type="monotone"
|
||||
dataKey="valor"
|
||||
stroke="hsl(var(--primary))"
|
||||
<Line
|
||||
type="monotone"
|
||||
dataKey="valor"
|
||||
stroke="hsl(var(--primary))"
|
||||
strokeWidth={2}
|
||||
dot={{ fill: 'hsl(var(--primary))', r: 4 }}
|
||||
/>
|
||||
@@ -1075,7 +1039,7 @@ for (const linea of lineas) {
|
||||
</div>
|
||||
<div>
|
||||
<Label>Pegar texto del resultado de laboratorio</Label>
|
||||
<textarea
|
||||
<textarea
|
||||
className="w-full p-2 border rounded-md text-sm min-h-[200px] font-mono"
|
||||
placeholder="Pegue aquí el texto del resultado de laboratorio..."
|
||||
value={importTexto}
|
||||
@@ -1086,7 +1050,7 @@ for (const linea of lineas) {
|
||||
<FileText className="h-4 w-4 mr-2" />
|
||||
Procesar Texto
|
||||
</Button>
|
||||
|
||||
|
||||
{importResultados.length > 0 && (
|
||||
<div className="border rounded-md max-h-48 overflow-y-auto">
|
||||
<Table>
|
||||
@@ -1109,7 +1073,7 @@ for (const linea of lineas) {
|
||||
</Table>
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
{importAcidoBase && (
|
||||
<div className="border rounded-md p-3 bg-green-50">
|
||||
<p className="text-sm font-medium mb-2 flex items-center gap-2">
|
||||
@@ -1128,14 +1092,14 @@ for (const linea of lineas) {
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
{importObservaciones && (
|
||||
<div className="border rounded-md p-3 bg-muted/50">
|
||||
<p className="text-sm font-medium mb-1">Valores adicionales en observaciones:</p>
|
||||
<p className="text-sm whitespace-pre-wrap">{importObservaciones}</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
{importResultados.length === 0 && !importObservaciones && !importAcidoBase && importTexto && (
|
||||
<div className="text-center py-4 text-gray-500">
|
||||
<p>No se detectaron parámetros. Verifique que el texto contenga los nombres correctos.</p>
|
||||
@@ -1146,7 +1110,7 @@ for (const linea of lineas) {
|
||||
<Button variant="outline" onClick={() => setImportDialog(false)}>Cancelar</Button>
|
||||
<Button onClick={handleImportarLaboratorio} disabled={importResultados.length === 0 && !importObservaciones && !importAcidoBase}>
|
||||
<Save className="h-4 w-4 mr-2" />
|
||||
{(importAcidoBase ? 'Guardar Gasometría' : 'Guardar Laboratorio')}
|
||||
{(importAcidoBase ? 'Guardar' : 'Guardar Laboratorio')}
|
||||
</Button>
|
||||
</div>
|
||||
</DialogContent>
|
||||
@@ -1156,9 +1120,9 @@ for (const linea of lineas) {
|
||||
<div className="text-center py-8 text-gray-400"><FlaskConical className="h-12 w-12 mx-auto mb-2 opacity-50" /><p>No hay laboratorios</p></div>
|
||||
) : (
|
||||
<div className="relative w-full overflow-auto grid grid-cols-1">
|
||||
|
||||
<Table>
|
||||
<TableHeader>
|
||||
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead className="cursor-pointer hover:bg-muted" onClick={() => setLabSortAsc(!labSortAsc)}>
|
||||
Fecha {labSortAsc ? '↑' : '↓'}
|
||||
@@ -1231,8 +1195,8 @@ for (const linea of lineas) {
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
@@ -1567,8 +1531,8 @@ function SeccionAcidosBase({ ab, patientId, add, update, del }: {
|
||||
<div className="flex items-start justify-between">
|
||||
<div><p className="font-medium">{a.fecha} {a.hora}</p></div>
|
||||
<div className="flex items-center gap-2">
|
||||
|
||||
<Badge variant="outline" className="text-xs">{a.fio2 && a.po2 &&<span className="mr-1">PaFiO2: {Math.round(a.po2 / a.fio2 * 100) / 100}</span>}</Badge>
|
||||
|
||||
<Badge variant="outline" className="text-xs">{a.fio2 && a.po2 && <span className="mr-1">PaFiO2: {Math.round(a.po2 / a.fio2 * 100) / 100}</span>}</Badge>
|
||||
<Badge variant="outline" className="text-xs">{a.fio2 && <span className="mr-1">FiO₂:{a.fio2}</span>}</Badge>
|
||||
<Badge className={getColorPh(a.ph)}>pH: {a.ph}</Badge>
|
||||
<Button size="sm" variant="ghost" className="text-blue-600" onClick={() => loadEdit(a)}><Edit /></Button>
|
||||
@@ -1583,7 +1547,7 @@ function SeccionAcidosBase({ ab, patientId, add, update, del }: {
|
||||
<div className="bg-gray-50 p-2 rounded text-center"><p className="text-xs text-gray-500">BE</p><p className="font-bold">{a.be}</p></div>
|
||||
<div className="bg-gray-50 p-2 rounded text-center"><p className="text-xs text-gray-500">SatO2</p><p className="font-bold">{a.sato2}%</p></div>
|
||||
{a.lactato && <div className="bg-gray-50 p-2 rounded text-center"><p className="text-xs text-gray-500">Lactato</p><p className="font-bold">{a.lactato}</p></div>}
|
||||
|
||||
|
||||
{a.fio2 && <div className="bg-gray-50 p-2 rounded text-center"><p className="text-xs text-gray-500">FiO2</p><p className="font-bold">{a.fio2}</p></div>}
|
||||
</div>
|
||||
{a.interpretacion && <div className="bg-teal-50 p-3 rounded-lg border border-teal-200"><p className="text-sm font-medium text-teal-800">Interpretación: {a.interpretacion}</p></div>}
|
||||
@@ -1626,7 +1590,7 @@ function SeccionCultivos({ cults, patient, add, update, del }: {
|
||||
setSelected(null);
|
||||
};
|
||||
|
||||
const resetRes = () => {
|
||||
const resetRes = () => {
|
||||
setFechaResultado(new Date().toISOString().split('T')[0]);
|
||||
setEstadoResultado('Positivo');
|
||||
setGermen('');
|
||||
@@ -1798,73 +1762,73 @@ const resetRes = () => {
|
||||
<div>
|
||||
<div className="grid grid-cols-1 gap-4">
|
||||
{cs.length === 0 ? <div className="text-center py-8 text-gray-400"><Microscope className="h-12 w-12 mx-auto mb-2 opacity-50" /><p>No hay cultivos</p></div> :
|
||||
cs.map(c => (
|
||||
<Card key={c.id} className="hover:shadow-md transition-shadow"><CardContent className="p-4">
|
||||
<div className="flex flex-col gap-3">
|
||||
<div className="flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className={`h-10 w-10 rounded-full flex items-center justify-center flex-shrink-0 ${c.estado === 'NAF/Pendiente' ? 'bg-amber-100' : c.estado === 'Parcial' ? 'bg-orange-100' : c.estado === 'Positivo' ? 'bg-red-100' : 'bg-green-100'}`}>
|
||||
<Microscope className={`h-5 w-5 ${c.estado === 'NAF/Pendiente' ? 'text-amber-600' : c.estado === 'Parcial' ? 'text-orange-600' : c.estado === 'Positivo' ? 'text-red-600' : 'text-green-600'}`} />
|
||||
</div>
|
||||
<div>
|
||||
<p className="font-medium">{c.fechaToma}</p>
|
||||
<div className="flex items-center gap-2 text-sm text-gray-500">
|
||||
<Badge variant="outline">{c.tipoMuestra}</Badge>
|
||||
<Badge className={getEstadoColor(c.estado)}>{getEstadoLabel(c.estado)}</Badge>
|
||||
cs.map(c => (
|
||||
<Card key={c.id} className="hover:shadow-md transition-shadow"><CardContent className="p-4">
|
||||
<div className="flex flex-col gap-3">
|
||||
<div className="flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className={`h-10 w-10 rounded-full flex items-center justify-center flex-shrink-0 ${c.estado === 'NAF/Pendiente' ? 'bg-amber-100' : c.estado === 'Parcial' ? 'bg-orange-100' : c.estado === 'Positivo' ? 'bg-red-100' : 'bg-green-100'}`}>
|
||||
<Microscope className={`h-5 w-5 ${c.estado === 'NAF/Pendiente' ? 'text-amber-600' : c.estado === 'Parcial' ? 'text-orange-600' : c.estado === 'Positivo' ? 'text-red-600' : 'text-green-600'}`} />
|
||||
</div>
|
||||
<div>
|
||||
<p className="font-medium">{c.fechaToma}</p>
|
||||
<div className="flex items-center gap-2 text-sm text-gray-500">
|
||||
<Badge variant="outline">{c.tipoMuestra}</Badge>
|
||||
<Badge className={getEstadoColor(c.estado)}>{getEstadoLabel(c.estado)}</Badge>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
{c.estado === 'NAF/Pendiente' && (
|
||||
<>
|
||||
<Button size="sm" variant="outline" onClick={() => openParcial(c)}><AlertCircle className="h-4 w-4 mr-1" />Parcial</Button>
|
||||
<Button size="sm" variant="outline" onClick={() => { openDefinitivo(c); setIsParcialMode(false); }}><CheckCircle2 className="h-4 w-4 mr-1" />Definitivo</Button>
|
||||
</>
|
||||
)}
|
||||
{c.estado === 'Parcial' && (
|
||||
<>
|
||||
<Button size="sm" variant="outline" onClick={() => openParcial(c)}><Pencil className="h-4 w-4 mr-1" />Editar Parcial</Button>
|
||||
<Button size="sm" variant="outline" onClick={() => openDefinitivo(c)}><CheckCircle2 className="h-4 w-4 mr-1" />Definitivo</Button>
|
||||
</>
|
||||
)}
|
||||
{(c.estado === 'Positivo' || c.estado === 'Negativo') && <Button size="sm" variant="outline" onClick={() => openDefinitivo(c)}><Pencil className="h-4 w-4" /></Button>}
|
||||
<Button size="sm" variant="outline" className="text-red-600" onClick={() => del(c.id)}><Trash2 /></Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
{c.estado === 'NAF/Pendiente' && (
|
||||
<>
|
||||
<Button size="sm" variant="outline" onClick={() => openParcial(c)}><AlertCircle className="h-4 w-4 mr-1" />Parcial</Button>
|
||||
<Button size="sm" variant="outline" onClick={() => { openDefinitivo(c); setIsParcialMode(false); }}><CheckCircle2 className="h-4 w-4 mr-1" />Definitivo</Button>
|
||||
</>
|
||||
{c.protocolo && <p className="text-xs text-gray-500">Protocolo: {c.protocolo}</p>}
|
||||
{c.observaciones && <p className="text-sm text-gray-600 bg-gray-50 p-2 rounded">{c.observaciones}</p>}
|
||||
{c.estado === 'Parcial' && c.germen && (
|
||||
<div className="bg-orange-50 p-3 rounded-lg border border-orange-200">
|
||||
<p className="text-sm font-medium text-orange-800 flex items-center gap-2"><AlertCircle className="h-4 w-4" />PARCIAL - Germen: {c.germen}</p>
|
||||
{(c.sensible || c.resistente) && (
|
||||
<div className="mt-2 space-y-1">
|
||||
{c.sensible && <p className="text-xs text-orange-700">Sensible: {c.sensible}</p>}
|
||||
{c.resistente && <p className="text-xs text-orange-700">Resistente: {c.resistente}</p>}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{c.estado === 'Parcial' && (
|
||||
<>
|
||||
<Button size="sm" variant="outline" onClick={() => openParcial(c)}><Pencil className="h-4 w-4 mr-1" />Editar Parcial</Button>
|
||||
<Button size="sm" variant="outline" onClick={() => openDefinitivo(c)}><CheckCircle2 className="h-4 w-4 mr-1" />Definitivo</Button>
|
||||
</>
|
||||
{c.estado === 'Positivo' && c.germen && (
|
||||
<div className="bg-red-50 p-3 rounded-lg border border-red-200">
|
||||
<p className="text-sm font-medium text-red-800 flex items-center gap-2"><AlertCircle className="h-4 w-4" />Germen: {c.germen}</p>
|
||||
{c.fechaResultado && <p className="text-xs text-red-600 mt-1">Resultado: {c.fechaResultado}</p>}
|
||||
{(c.sensible || c.resistente) && (
|
||||
<div className="mt-2 space-y-2">
|
||||
{c.sensible && <div><p className="text-xs font-medium text-green-700 mb-1">Sensible a:</p><p className="text-sm text-green-800">{c.sensible}</p></div>}
|
||||
{c.resistente && <div><p className="text-xs font-medium text-red-700 mb-1">Resistente a:</p><p className="text-sm text-red-800">{c.resistente}</p></div>}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{(c.estado === 'Positivo' || c.estado === 'Negativo') && <Button size="sm" variant="outline" onClick={() => openDefinitivo(c)}><Pencil className="h-4 w-4" /></Button>}
|
||||
<Button size="sm" variant="outline" className="text-red-600" onClick={() => del(c.id)}><Trash2 /></Button>
|
||||
</div>
|
||||
</div>
|
||||
{c.protocolo && <p className="text-xs text-gray-500">Protocolo: {c.protocolo}</p>}
|
||||
{c.observaciones && <p className="text-sm text-gray-600 bg-gray-50 p-2 rounded">{c.observaciones}</p>}
|
||||
{c.estado === 'Parcial' && c.germen && (
|
||||
<div className="bg-orange-50 p-3 rounded-lg border border-orange-200">
|
||||
<p className="text-sm font-medium text-orange-800 flex items-center gap-2"><AlertCircle className="h-4 w-4" />PARCIAL - Germen: {c.germen}</p>
|
||||
{(c.sensible || c.resistente) && (
|
||||
<div className="mt-2 space-y-1">
|
||||
{c.sensible && <p className="text-xs text-orange-700">Sensible: {c.sensible}</p>}
|
||||
{c.resistente && <p className="text-xs text-orange-700">Resistente: {c.resistente}</p>}
|
||||
{c.estado === 'Negativo' && (
|
||||
<div className="bg-green-50 dark:bg-green-900/30 p-3 rounded-lg border border-green-200 dark:border-green-700">
|
||||
<p className="text-sm font-medium text-green-800 flex items-center gap-2"><CheckCircle2 className="h-4 w-4" />Sin crecimiento de microorganismos</p>
|
||||
{c.fechaResultado && <p className="text-xs text-green-600 mt-1">Resultado: {c.fechaResultado}</p>}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{c.estado === 'Positivo' && c.germen && (
|
||||
<div className="bg-red-50 p-3 rounded-lg border border-red-200">
|
||||
<p className="text-sm font-medium text-red-800 flex items-center gap-2"><AlertCircle className="h-4 w-4" />Germen: {c.germen}</p>
|
||||
{c.fechaResultado && <p className="text-xs text-red-600 mt-1">Resultado: {c.fechaResultado}</p>}
|
||||
{(c.sensible || c.resistente) && (
|
||||
<div className="mt-2 space-y-2">
|
||||
{c.sensible && <div><p className="text-xs font-medium text-green-700 mb-1">Sensible a:</p><p className="text-sm text-green-800">{c.sensible}</p></div>}
|
||||
{c.resistente && <div><p className="text-xs font-medium text-red-700 mb-1">Resistente a:</p><p className="text-sm text-red-800">{c.resistente}</p></div>}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{c.estado === 'Negativo' && (
|
||||
<div className="bg-green-50 dark:bg-green-900/30 p-3 rounded-lg border border-green-200 dark:border-green-700">
|
||||
<p className="text-sm font-medium text-green-800 flex items-center gap-2"><CheckCircle2 className="h-4 w-4" />Sin crecimiento de microorganismos</p>
|
||||
{c.fechaResultado && <p className="text-xs text-green-600 mt-1">Resultado: {c.fechaResultado}</p>}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</CardContent></Card>
|
||||
))}
|
||||
</CardContent></Card>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1884,7 +1848,7 @@ function SeccionEstudiosComplementarios({ estudios, internacionId, pacienteId, a
|
||||
const [tipo, setTipo] = useState('');
|
||||
const [resultado, setResultado] = useState('');
|
||||
|
||||
const estudiosFiltrados = filtro === 'internacion'
|
||||
const estudiosFiltrados = filtro === 'internacion'
|
||||
? estudios.filter(e => e.internacionId === internacionId)
|
||||
: estudios;
|
||||
|
||||
@@ -1939,15 +1903,15 @@ function SeccionEstudiosComplementarios({ estudios, internacionId, pacienteId, a
|
||||
</div>
|
||||
<div>
|
||||
<Label>Tipo de Estudio</Label>
|
||||
<Input
|
||||
value={tipo}
|
||||
onChange={e => setTipo(e.target.value)}
|
||||
<Input
|
||||
value={tipo}
|
||||
onChange={e => setTipo(e.target.value)}
|
||||
placeholder="Ej: Radiografía de tórax, ECG, Tomografía, etc."
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<Label>Resultado</Label>
|
||||
<textarea
|
||||
<textarea
|
||||
className="w-full p-2 border rounded-md text-sm min-h-[100px]"
|
||||
value={resultado}
|
||||
onChange={e => setResultado(e.target.value)}
|
||||
|
||||
Reference in New Issue
Block a user