Update Indicaciones: new types PHP, Paralelo, Alterno with dual plans
This commit is contained in:
+15
-2
@@ -222,7 +222,9 @@ try {
|
||||
via TEXT,
|
||||
descripcion TEXT,
|
||||
tipoPlan TEXT,
|
||||
tipoPlan2 TEXT,
|
||||
cantidadMl INTEGER,
|
||||
cantidadMl2 INTEGER,
|
||||
tiempoHoras INTEGER,
|
||||
estado TEXT DEFAULT 'Activa',
|
||||
medicoCrea TEXT,
|
||||
@@ -232,6 +234,17 @@ try {
|
||||
)
|
||||
`);
|
||||
console.log('Tabla indicaciones creada');
|
||||
} else {
|
||||
try {
|
||||
db.exec("ALTER TABLE indicaciones ADD COLUMN tipoPlan2 TEXT");
|
||||
} catch (e) {
|
||||
// column may already exist
|
||||
}
|
||||
try {
|
||||
db.exec("ALTER TABLE indicaciones ADD COLUMN cantidadMl2 INTEGER");
|
||||
} catch (e) {
|
||||
// column may already exist
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('Error tabla indicaciones:', e.message);
|
||||
@@ -389,9 +402,9 @@ if (state.laboratorios?.length) {
|
||||
|
||||
run('DELETE FROM indicaciones');
|
||||
if (state.indicaciones?.length) {
|
||||
const stmt = db.prepare('INSERT INTO indicaciones (id, internacionId, tipo, droga, dosis, frecuenciaHoras, via, descripcion, tipoPlan, cantidadMl, tiempoHoras, estado, medicoCrea, fechaCrea, medicoSuspende, fechaSuspension) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
|
||||
const stmt = db.prepare('INSERT INTO indicaciones (id, internacionId, tipo, droga, dosis, frecuenciaHoras, via, descripcion, tipoPlan, tipoPlan2, cantidadMl, cantidadMl2, tiempoHoras, estado, medicoCrea, fechaCrea, medicoSuspende, fechaSuspension) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
|
||||
for (const ind of state.indicaciones) {
|
||||
stmt.run(ind.id, ind.internacionId, ind.tipo, ind.droga || null, ind.dosis || null, ind.frecuenciaHoras || null, ind.via || null, ind.descripcion || null, ind.tipoPlan || null, ind.cantidadMl || null, ind.tiempoHoras || null, ind.estado, ind.medicoCrea, ind.fechaCrea, ind.medicoSuspende || null, ind.fechaSuspension || null);
|
||||
stmt.run(ind.id, ind.internacionId, ind.tipo, ind.droga || null, ind.dosis || null, ind.frecuenciaHoras || null, ind.via || null, ind.descripcion || null, ind.tipoPlan || null, ind.tipoPlan2 || null, ind.cantidadMl || null, ind.cantidadMl2 || null, ind.tiempoHoras || null, ind.estado, ind.medicoCrea, ind.fechaCrea, ind.medicoSuspende || null, ind.fechaSuspension || null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,15 +26,17 @@ export function SeccionIndicaciones({ recomendaciones, internacionId, add, updat
|
||||
const [frecuenciaHoras, setFrecuenciaHoras] = useState<number | ''>('');
|
||||
const [via, setVia] = useState<ViaAdministracion>('EV');
|
||||
const [descripcion, setDescripcion] = useState('');
|
||||
const [tipoPlan, setTipoPlan] = useState<TipoPlanHidratacion>('SolucionFisiologica09');
|
||||
const [tipoPlan, setTipoPlan] = useState<TipoPlanHidratacion>('SF 0.9%');
|
||||
const [tipoPlan2, setTipoPlan2] = useState<TipoPlanHidratacion>('Ringer Lactato');
|
||||
const [cantidadMl, setCantidadMl] = useState<number | ''>('');
|
||||
const [cantidadMl2, setCantidadMl2] = useState<number | ''>('');
|
||||
const [tiempoHoras, setTiempoHoras] = useState<number | ''>(24);
|
||||
const [medico, setMedico] = useState('');
|
||||
const [showHistorial, setShowHistorial] = useState(false);
|
||||
|
||||
const vias: ViaAdministracion[] = ['Oral', 'EV', 'IM', 'SC', 'Por GGT', 'Por SNG'];
|
||||
const planes: TipoPlanHidratacion[] = ['SolucionFisiologica09', 'Dextrosa5', 'Dextrosa10', 'Dextrosa25', 'RingerLactato'];
|
||||
const tipos: IndicacionTipo[] = ['Farmacologica', 'NoFarmacologica', 'Hidratacion'];
|
||||
const planes: TipoPlanHidratacion[] = ['SF 0.9%', 'Dextrosa 5%', 'Dextrosa 10%', 'Dextrosa 25%', 'Ringer Lactato'];
|
||||
const tipos: IndicacionTipo[] = ['Farmacologica', 'No Farmacologica', 'PHP', 'Paralelo', 'Alterno'];
|
||||
|
||||
const reset = () => {
|
||||
setEdit(null);
|
||||
@@ -44,8 +46,10 @@ export function SeccionIndicaciones({ recomendaciones, internacionId, add, updat
|
||||
setFrecuenciaHoras('');
|
||||
setVia('EV');
|
||||
setDescripcion('');
|
||||
setTipoPlan('SolucionFisiologica09');
|
||||
setTipoPlan('SF 0.9%');
|
||||
setTipoPlan2('Ringer Lactato');
|
||||
setCantidadMl('');
|
||||
setCantidadMl2('');
|
||||
setTiempoHoras(24);
|
||||
setMedico('');
|
||||
};
|
||||
@@ -58,8 +62,10 @@ export function SeccionIndicaciones({ recomendaciones, internacionId, add, updat
|
||||
setFrecuenciaHoras(i.frecuenciaHoras || '');
|
||||
setVia(i.via || 'EV');
|
||||
setDescripcion(i.descripcion || '');
|
||||
setTipoPlan(i.tipoPlan || 'SolucionFisiologica09');
|
||||
setTipoPlan(i.tipoPlan || 'SF 0.9%');
|
||||
setTipoPlan2(i.tipoPlan2 || 'Ringer Lactato');
|
||||
setCantidadMl(i.cantidadMl || '');
|
||||
setCantidadMl2(i.cantidadMl2 || '');
|
||||
setTiempoHoras(i.tiempoHoras || 24);
|
||||
setMedico(i.medicoCrea);
|
||||
setDialog(true);
|
||||
@@ -69,7 +75,8 @@ export function SeccionIndicaciones({ recomendaciones, internacionId, add, updat
|
||||
if (!medico.trim()) return;
|
||||
if (tipo === 'Farmacologica' && (!droga.trim() || !dosis.trim())) return;
|
||||
if (tipo === 'No Farmacologica' && !descripcion.trim()) return;
|
||||
if (tipo === 'Hidratacion' && !cantidadMl) return;
|
||||
if ((tipo === 'PHP' || tipo === 'Paralelo') && !cantidadMl) return;
|
||||
if (tipo === 'Alterno' && (!cantidadMl || !cantidadMl2)) return;
|
||||
|
||||
const data: any = {
|
||||
internacionId,
|
||||
@@ -86,10 +93,16 @@ export function SeccionIndicaciones({ recomendaciones, internacionId, add, updat
|
||||
data.via = via;
|
||||
} else if (tipo === 'No Farmacologica') {
|
||||
data.descripcion = descripcion;
|
||||
} else {
|
||||
} else if (tipo === 'PHP' || tipo === 'Paralelo') {
|
||||
data.tipoPlan = tipoPlan;
|
||||
data.cantidadMl = cantidadMl;
|
||||
data.tiempoHoras = tiempoHoras;
|
||||
} else if (tipo === 'Alterno') {
|
||||
data.tipoPlan = tipoPlan;
|
||||
data.cantidadMl = cantidadMl;
|
||||
data.tipoPlan2 = tipoPlan2;
|
||||
data.cantidadMl2 = cantidadMl2;
|
||||
data.tiempoHoras = tiempoHoras;
|
||||
}
|
||||
|
||||
if (edit) {
|
||||
@@ -157,10 +170,10 @@ export function SeccionIndicaciones({ recomendaciones, internacionId, add, updat
|
||||
)}
|
||||
|
||||
{tipo === 'No Farmacologica' && (
|
||||
<div><Label>Descripción *</Label><textarea className="w-full p-2 border rounded-md text-sm min-h-[80px] bg-transparent dark:bg-input/30" value={descripcion} onChange={e => setDescripcion(e.target.value)} placeholder="Ej: Control de signos vitales cada 4hs, Dieta blanda, etc." /></div>
|
||||
<div><Label>Descripción *</Label><textarea className="w-full p-2 border rounded-md text-sm min-h-[80px] bg-transparent dark:bg-input/30" value={descripcion} onChange={e => setDescripcion(e.target.value)} placeholder="Ej: Control de signos vitales, Dieta, etc." /></div>
|
||||
)}
|
||||
|
||||
{tipo === 'Hidratacion' && (
|
||||
{(tipo === 'PHP' || tipo === 'Paralelo') && (
|
||||
<>
|
||||
<div><Label>Tipo de Plan</Label><Select value={tipoPlan} onValueChange={(v: TipoPlanHidratacion) => setTipoPlan(v)}><SelectTrigger><SelectValue /></SelectTrigger><SelectContent>{planes.map(p => <SelectItem key={p} value={p}>{p}</SelectItem>)}</SelectContent></Select></div>
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
@@ -169,6 +182,20 @@ export function SeccionIndicaciones({ recomendaciones, internacionId, add, updat
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
{tipo === 'Alterno' && (
|
||||
<>
|
||||
<div><Label>Plan 1</Label><Select value={tipoPlan} onValueChange={(v: TipoPlanHidratacion) => setTipoPlan(v)}><SelectTrigger><SelectValue /></SelectTrigger><SelectContent>{planes.map(p => <SelectItem key={p} value={p}>{p}</SelectItem>)}</SelectContent></Select></div>
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div><Label>Cantidad Plan 1 (ml) *</Label><Input type="number" value={cantidadMl} onChange={e => setCantidadMl(e.target.value ? parseInt(e.target.value) : '')} placeholder="ml" /></div>
|
||||
</div>
|
||||
<div><Label>Plan 2</Label><Select value={tipoPlan2} onValueChange={(v: TipoPlanHidratacion) => setTipoPlan2(v)}><SelectTrigger><SelectValue /></SelectTrigger><SelectContent>{planes.map(p => <SelectItem key={p} value={p}>{p}</SelectItem>)}</SelectContent></Select></div>
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div><Label>Cantidad Plan 2 (ml) *</Label><Input type="number" value={cantidadMl2} onChange={e => setCantidadMl2(e.target.value ? parseInt(e.target.value) : '')} placeholder="ml" /></div>
|
||||
<div><Label>Tiempo Total (hs)</Label><Input type="number" value={tiempoHoras} onChange={e => setTiempoHoras(e.target.value ? parseInt(e.target.value) : 24)} placeholder="24" /></div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</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>
|
||||
@@ -195,9 +222,12 @@ export function SeccionIndicaciones({ recomendaciones, internacionId, add, updat
|
||||
{ind.tipo === 'No Farmacologica' && (
|
||||
<div className="font-medium">{ind.descripcion}</div>
|
||||
)}
|
||||
{ind.tipo === 'Hidratacion' && (
|
||||
{(ind.tipo === 'PHP' || ind.tipo === 'Paralelo') && (
|
||||
<div className="font-medium">{ind.tipoPlan} {ind.cantidadMl}ml en {ind.tiempoHoras}hs</div>
|
||||
)}
|
||||
{ind.tipo === 'Alterno' && (
|
||||
<div className="font-medium">{ind.tipoPlan} {ind.cantidadMl}ml + {ind.tipoPlan2} {ind.cantidadMl2}ml en {ind.tiempoHoras}hs</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex gap-1">
|
||||
<Button size="sm" variant="outline" className="text-orange-600" onClick={() => {
|
||||
@@ -225,10 +255,10 @@ export function SeccionIndicaciones({ recomendaciones, internacionId, add, updat
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>Fecha Indicación</TableHead>
|
||||
<TableHead>Fecha</TableHead>
|
||||
<TableHead>Indicado por</TableHead>
|
||||
<TableHead>Fecha Suspensión</TableHead>
|
||||
<TableHead>Médico</TableHead>
|
||||
<TableHead>Suspenso Por</TableHead>
|
||||
<TableHead>Suspendido por</TableHead>
|
||||
<TableHead>Indicación</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
@@ -236,13 +266,14 @@ export function SeccionIndicaciones({ recomendaciones, internacionId, add, updat
|
||||
{historial.map(ind => (
|
||||
<TableRow key={ind.id}>
|
||||
<TableCell>{ind.fechaCrea}</TableCell>
|
||||
<TableCell>{ind.fechaSuspension}</TableCell>
|
||||
<TableCell>{ind.medicoCrea}</TableCell>
|
||||
<TableCell>{ind.fechaSuspension}</TableCell>
|
||||
<TableCell>{ind.medicoSuspende}</TableCell>
|
||||
<TableCell>
|
||||
{ind.tipo === 'Farmacologica' && `${ind.droga} ${ind.dosis}`}
|
||||
{ind.tipo === 'No Farmacologica' && ind.descripcion}
|
||||
{ind.tipo === 'Hidratacion' && `${ind.tipoPlan} ${ind.cantidadMl}ml`}
|
||||
{(ind.tipo === 'PHP' || ind.tipo === 'Paralelo') && `${ind.tipoPlan} ${ind.cantidadMl}ml`}
|
||||
{ind.tipo === 'Alterno' && `${ind.tipoPlan} ${ind.cantidadMl}ml + ${ind.tipoPlan2} ${ind.cantidadMl2}ml`}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
|
||||
+4
-2
@@ -172,9 +172,9 @@ export interface ATB {
|
||||
fechaFinalizacion?: string;
|
||||
}
|
||||
|
||||
export type IndicacionTipo = 'Farmacologica' | 'NoFarmacologica' | 'Hidratacion';
|
||||
export type IndicacionTipo = 'Farmacologica' | 'No Farmacologica' | 'PHP' | 'Paralelo' | 'Alterno';
|
||||
export type ViaAdministracion = 'Oral' | 'EV' | 'IM' | 'SC' | 'Por GGT' | 'Por SNG';
|
||||
export type TipoPlanHidratacion = 'SolucionFisiologica09' | 'Dextrosa5' | 'Dextrosa10' | 'Dextrosa25' | 'RingerLactato';
|
||||
export type TipoPlanHidratacion = 'SF 0.9%' | 'Dextrosa 5%' | 'Dextrosa 10%' | 'Dextrosa 25%' | 'Ringer Lactato';
|
||||
|
||||
export interface Indicacion {
|
||||
id: string;
|
||||
@@ -186,7 +186,9 @@ export interface Indicacion {
|
||||
via?: ViaAdministracion;
|
||||
descripcion?: string;
|
||||
tipoPlan?: TipoPlanHidratacion;
|
||||
tipoPlan2?: TipoPlanHidratacion;
|
||||
cantidadMl?: number;
|
||||
cantidadMl2?: number;
|
||||
tiempoHoras?: number;
|
||||
estado: 'Activa' | 'Suspendida';
|
||||
medicoCrea: string;
|
||||
|
||||
Reference in New Issue
Block a user