From e6e1582b258dec0fd91653bfa41855a3dd1c9b12 Mon Sep 17 00:00:00 2001 From: Sergio Nicolas Lavaise Date: Thu, 23 Apr 2026 02:18:42 -0300 Subject: [PATCH] =?UTF-8?q?feat:=20implementar=20permisos=20por=20=C3=A1re?= =?UTF-8?q?a=20de=20trabajo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Agregar funciones de verificación de área en useHospitalStore - canEditInArea, canEditCama, canEditInternacion, canEditPaciente - Leer datos de tablas individuales en lugar de tabla kv - Usar sessionStorage para persistir sesión de usuario - Agregar prop canEdit a componentes de secciones en HC - Ocultar botones de edición para usuarios sin permisos en el área - MapaCamas: ocultar botones de edición para camas fuera del área --- server/db.js | 91 +++++++++++++ server/index.js | 187 ++++++++++++++++++++++----- src/App.tsx | 1 + src/hooks/useHospitalStore.ts | 77 +++++++++-- src/sections/HistoriaClinica.tsx | 107 ++++++++------- src/sections/Login.tsx | 1 + src/sections/MapaCamas.tsx | 50 +++---- src/sections/SeccionIndicaciones.tsx | 15 ++- 8 files changed, 411 insertions(+), 118 deletions(-) diff --git a/server/db.js b/server/db.js index e9abd65..e2ef807 100644 --- a/server/db.js +++ b/server/db.js @@ -132,3 +132,94 @@ export async function verifyPassword(dni, password) { export async function hashPassword(password) { return bcrypt.hashSync(password, 10); } + +export async function getAllPacientes() { + const db = await openDb(); + const rows = await db.all('SELECT * FROM pacientes'); + await db.close(); + return rows; +} + +export async function getAllAreas() { + const db = await openDb(); + const rows = await db.all('SELECT * FROM areas'); + await db.close(); + return rows; +} + +export async function getAllCamas() { + const db = await openDb(); + const rows = await db.all('SELECT * FROM camas'); + await db.close(); + return rows; +} + +export async function getAllInternaciones() { + const db = await openDb(); + const rows = await db.all('SELECT * FROM internaciones'); + await db.close(); + return rows; +} + +export async function getAllEvoluciones() { + const db = await openDb(); + const rows = await db.all('SELECT * FROM evoluciones'); + await db.close(); + return rows; +} + +export async function getAllLaboratorios() { + const db = await openDb(); + const rows = await db.all('SELECT * FROM laboratorios'); + await db.close(); + return rows; +} + +export async function getAllAcidosBase() { + const db = await openDb(); + const rows = await db.all('SELECT * FROM acidosbase'); + await db.close(); + return rows; +} + +export async function getAllCultivos() { + const db = await openDb(); + const rows = await db.all('SELECT * FROM cultivos'); + await db.close(); + return rows; +} + +export async function getAllEstudiosComplementarios() { + const db = await openDb(); + const rows = await db.all('SELECT * FROM estudiosComplementarios'); + await db.close(); + return rows; +} + +export async function getAllInterconsultas() { + const db = await openDb(); + const rows = await db.all('SELECT * FROM interconsultas'); + await db.close(); + return rows; +} + +export async function getAllAtb() { + const db = await openDb(); + const rows = await db.all('SELECT * FROM atb'); + await db.close(); + return rows; +} + +export async function getAllIndicaciones() { + const db = await openDb(); + const rows = await db.all('SELECT * FROM indicaciones'); + await db.close(); + return rows; +} + +export async function getAllMovimientosIndicaciones() { + const db = await openDb(); + const rows = await db.all('SELECT * FROM movimientos_indicaciones'); + await db.close(); + return rows; +} diff --git a/server/index.js b/server/index.js index 8dd0b67..261bf2d 100644 --- a/server/index.js +++ b/server/index.js @@ -1,6 +1,6 @@ import express from 'express'; import cors from 'cors'; -import { getValue, setValue, getUsuarioByDni, getUsuarioById, getAllUsuarios, createUsuario, updateUsuario, deleteUsuario, verifyPassword, hashPassword } from './db.js'; +import { openDb, getValue, setValue, getUsuarioByDni, getUsuarioById, getAllUsuarios, createUsuario, updateUsuario, deleteUsuario, verifyPassword, hashPassword, getAllPacientes, getAllAreas, getAllCamas, getAllInternaciones, getAllEvoluciones, getAllLaboratorios, getAllAcidosBase, getAllCultivos, getAllEstudiosComplementarios, getAllInterconsultas, getAllAtb, getAllIndicaciones, getAllMovimientosIndicaciones } from './db.js'; const app = express(); app.use(cors()); @@ -11,9 +11,28 @@ const STORAGE_KEY = 'hospital-data-v1'; app.get('/api/state', async (req, res) => { try { - const v = await getValue(STORAGE_KEY); - if (!v) return res.json(null); - res.json(JSON.parse(v)); + const state = { + pacientes: await getAllPacientes(), + areas: await getAllAreas(), + camas: await getAllCamas(), + internaciones: (await getAllInternaciones()).map(i => ({ ...i, activa: !!i.activa })), + evoluciones: (await getAllEvoluciones()).map(e => ({ + ...e, + signosVitales: typeof e.signosVitales === 'string' ? JSON.parse(e.signosVitales) : e.signosVitales, + examenFisico: typeof e.examenFisico === 'string' ? JSON.parse(e.examenFisico) : e.examenFisico + })), + laboratorios: (await getAllLaboratorios()).map(l => ({ ...l, resultados: typeof l.resultados === 'string' ? JSON.parse(l.resultados) : l.resultados })), + acidosBase: await getAllAcidosBase(), + cultivos: await getAllCultivos(), + estudiosComplementarios: await getAllEstudiosComplementarios(), + interconsultas: (await getAllInterconsultas()).map(ic => ({ ...ic, realizada: !!ic.realizada })), + atb: await getAllAtb(), + indicaciones: await getAllIndicaciones(), + movimientosIndicaciones: await getAllMovimientosIndicaciones(), + vistaActual: 'dashboard', + currentInternacionId: null + }; + res.json(state); } catch (err) { console.error(err); res.status(500).json({ error: 'failed to read state' }); @@ -22,8 +41,135 @@ app.get('/api/state', async (req, res) => { app.put('/api/state', async (req, res) => { try { - const body = req.body; - await setValue(STORAGE_KEY, JSON.stringify(body)); + const state = req.body; + const db = await openDb(); + + await db.run('DELETE FROM evoluciones'); + await db.run('DELETE FROM acidosbase'); + await db.run('DELETE FROM cultivos'); + await db.run('DELETE FROM laboratorios'); + await db.run('DELETE FROM internaciones'); + await db.run('DELETE FROM camas'); + await db.run('DELETE FROM areas'); + await db.run('DELETE FROM pacientes'); + await db.run('DELETE FROM estudiosComplementarios'); + await db.run('DELETE FROM interconsultas'); + await db.run('DELETE FROM atb'); + await db.run('DELETE FROM indicaciones'); + await db.run('DELETE FROM movimientos_indicaciones'); + + if (state.pacientes?.length) { + for (const p of state.pacientes) { + await db.run( + 'INSERT INTO pacientes (id, apellido, nombre, dni, fechaNacimiento, sexo, telefono, email, direccion, obraSocial, nacionalidad, medicacionHabitual, antecedentes, alergias, grupoSanguineo, historiaClinica) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', + [p.id, p.apellido, p.nombre, p.dni, p.fechaNacimiento || null, p.sexo || null, p.telefono || null, p.email || null, p.direccion || null, p.obraSocial || null, p.nacionalidad || null, p.medicacionHabitual || null, p.antecedentes || null, p.alergias || null, p.grupoSanguineo || null, p.historiaClinica || null] + ); + } + } + + if (state.areas?.length) { + for (const a of state.areas) { + await db.run('INSERT INTO areas (id, nombre) VALUES (?, ?)', [a.id, a.nombre]); + } + } + + if (state.camas?.length) { + for (const c of state.camas) { + await db.run('INSERT INTO camas (id, numero, areaId, tipo, estado) VALUES (?, ?, ?, ?, ?)', [c.id, c.numero, c.areaId, c.tipo, c.estado]); + } + } + + if (state.internaciones?.length) { + for (const i of state.internaciones) { + await db.run( + 'INSERT INTO internaciones (id, pacienteId, camaId, fechaIngresoHospital, fechaIngresoClinica, fechaEgreso, diagnosticoIngreso, motivoConsulta, enfermedadActual, antecedentesEnfermedadActual, diagnosticoEgreso, medicoIngresante, motivoEgreso, activa, apache, derivacion) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', + [i.id, i.pacienteId, i.camaId, i.fechaIngresoHospital || null, i.fechaIngresoClinica || null, i.fechaEgreso || null, i.diagnosticoIngreso || null, i.motivoConsulta || null, i.enfermedadActual || null, i.antecedentesEnfermedadActual || null, i.diagnosticoEgreso || null, i.medicoIngresante || null, i.motivoEgreso || null, i.activa ? 1 : 0, i.apache || null, i.derivacion || null] + ); + } + } + + if (state.evoluciones?.length) { + for (const e of state.evoluciones) { + await db.run( + 'INSERT INTO evoluciones (id, internacionId, fecha, hora, medico, signosVitales, examenFisico, novedades, comentarios, pendientes) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', + [e.id, e.internacionId, e.fecha, e.hora || '', e.medico || '', JSON.stringify(e.signosVitales || {}), JSON.stringify(e.examenFisico || {}), e.novedades || '', e.comentarios || '', e.pendientes || ''] + ); + } + } + + if (state.laboratorios?.length) { + for (const l of state.laboratorios) { + await db.run( + 'INSERT INTO laboratorios (id, pacienteId, fecha, hora, tipo, resultados, observaciones) VALUES (?, ?, ?, ?, ?, ?, ?)', + [l.id, l.pacienteId, l.fecha, l.hora || null, l.tipo, JSON.stringify(l.resultados), l.observaciones || null] + ); + } + } + + if (state.acidosBase?.length) { + for (const a of state.acidosBase) { + await db.run( + 'INSERT INTO acidosbase (id, pacienteId, fecha, hora, ph, pco2, po2, hco3, be, sato2, lactato, interpretacion, fio2) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', + [a.id, a.pacienteId, a.fecha, a.hora, a.ph, a.pco2, a.po2, a.hco3, a.be, a.sato2, a.lactato || null, a.interpretacion || null, a.fio2 || null] + ); + } + } + + if (state.cultivos?.length) { + for (const c of state.cultivos) { + await db.run( + 'INSERT INTO cultivos (id, pacienteId, internacionId, fechaToma, protocolo, tipoMuestra, observaciones, estado, fechaResultado, germen, sensible, resistente) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', + [c.id, c.pacienteId, c.internacionId, c.fechaToma, c.protocolo, c.tipoMuestra, c.observaciones, c.estado, c.fechaResultado, c.germen, c.sensible, c.resistente] + ); + } + } + + if (state.estudiosComplementarios?.length) { + for (const e of state.estudiosComplementarios) { + await db.run( + 'INSERT INTO estudiosComplementarios (id, pacienteId, internacionId, fecha, tipo, resultado) VALUES (?, ?, ?, ?, ?, ?)', + [e.id, e.pacienteId, e.internacionId || null, e.fecha, e.tipo, e.resultado] + ); + } + } + + if (state.interconsultas?.length) { + for (const ic of state.interconsultas) { + await db.run( + 'INSERT INTO interconsultas (id, pacienteId, internacionId, fecha, servicioInterconsultado, motivo, respuestaInterconsulta, respuestaFecha) VALUES (?, ?, ?, ?, ?, ?, ?, ?)', + [ic.id, ic.pacienteId, ic.internacionId, ic.fecha, ic.servicioInterconsultado, ic.motivo || null, ic.respuestaInterconsulta || null, ic.respuestaFecha || null] + ); + } + } + + if (state.atb?.length) { + for (const atb of state.atb) { + await db.run( + 'INSERT INTO atb (id, pacienteId, internacionId, antibiotico, fechaInicio, fechaFinalizacion) VALUES (?, ?, ?, ?, ?, ?)', + [atb.id, atb.pacienteId, atb.internacionId, atb.antibiotico, atb.fechaInicio, atb.fechaFinalizacion || null] + ); + } + } + + if (state.indicaciones?.length) { + for (const ind of state.indicaciones) { + await db.run( + 'INSERT INTO indicaciones (id, internacionId, tipo, droga, dosis, frecuenciaHoras, via, tipoPlan, tipoPlan2, cantidadMl, cantidadMl2, tiempoHoras, estado, medicoCrea, fechaCrea, tipoInsulina, unidadesDesayuno, unidadesAlmuerzo, unidadesNoche, indicacionNoFco) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', + [ind.id, ind.internacionId, ind.tipo, ind.droga || null, ind.dosis || null, ind.frecuenciaHoras || null, ind.via || null, ind.tipoPlan || null, ind.tipoPlan2 || null, ind.cantidadMl || null, ind.cantidadMl2 || null, ind.tiempoHoras || null, ind.estado, ind.medicoCrea, ind.fechaCrea, ind.tipoInsulina || null, ind.unidadesDesayuno || null, ind.unidadesAlmuerzo || null, ind.unidadesNoche || null, ind.indicacionNoFco || null] + ); + } + } + + if (state.movimientosIndicaciones?.length) { + for (const mov of state.movimientosIndicaciones) { + await db.run( + 'INSERT INTO movimientos_indicaciones (id, indicacionId, internacionId, tipo, fecha, profesional, indicacionPrevia, indicacionNueva) VALUES (?, ?, ?, ?, ?, ?, ?, ?)', + [mov.id, mov.indicacionId, mov.internacionId, mov.tipo, mov.fecha, mov.profesional, mov.indicacionPrevia || null, mov.indicacionNueva || null] + ); + } + } + + await db.close(); res.json({ ok: true }); } catch (err) { console.error(err); @@ -35,35 +181,6 @@ app.listen(PORT, () => { console.log(`API server listening on http://localhost:${PORT}`); }); -// Crear usuario admin inicial si no existe -async function initAdminUser() { - try { - const adminExists = await getUsuarioByDni('12345678'); - if (!adminExists) { - const passwordHash = await hashPassword('admin123'); - const adminUser = { - id: generateUUID(), - apellido: 'Admin', - nombre: 'Sistema', - dni: '12345678', - fechaNacimiento: '1970-01-01', - email: 'admin@hospital.gob.ar', - rol: 'admin', - matriculaProfesional: null, - passwordHash, - areaId: null, - fechaCreacion: new Date().toISOString().split('T')[0] - }; - await createUsuario(adminUser); - console.log('Usuario admin creado: DNI 12345678, Password admin123'); - } - } catch (err) { - console.error('Error creating admin user:', err); - } -} - -initAdminUser(); - // === AUTENTICACIÓN === function generateUUID() { diff --git a/src/App.tsx b/src/App.tsx index 1d52565..4f10fe2 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -183,6 +183,7 @@ function AppContent() { onActualizarCama={store.actualizarCama} onVolver={() => store.setVista('internaciones')} onEditarIngreso={() => { store.setVista('editaringreso'); }} + canEdit={store.canEditInternacion(internacion.id)} /> ); } diff --git a/src/hooks/useHospitalStore.ts b/src/hooks/useHospitalStore.ts index a4d58c0..c43bd56 100644 --- a/src/hooks/useHospitalStore.ts +++ b/src/hooks/useHospitalStore.ts @@ -88,6 +88,8 @@ export function useHospitalStore() { const body = await res.json(); if (mounted && body) { const defaults = defaultState(); + const storedUser = sessionStorage.getItem('hospital_user'); + const currentUser = storedUser ? JSON.parse(storedUser) : null; const normalized = { ...defaults, ...body, @@ -95,6 +97,8 @@ export function useHospitalStore() { interconsultas: body.interconsultas || [], atb: body.atb || [], movimientosIndicaciones: body.movimientosIndicaciones || [], + currentUser, + isAuthenticated: !!currentUser, }; setState(normalized); } @@ -108,15 +112,24 @@ export function useHospitalStore() { }, []); // Persist state to backend when it changes (debounced) + const [initialLoadComplete, setInitialLoadComplete] = useState(false); + useEffect(() => { - if (!isLoaded) return; + if (isLoaded && !initialLoadComplete) { + setInitialLoadComplete(true); + } + }, [isLoaded, initialLoadComplete]); + + useEffect(() => { + if (!initialLoadComplete) return; const t = setTimeout(() => { (async () => { try { + const { currentUser, isAuthenticated, ...stateToSave } = state; await fetch(`${API_BASE}/state`, { method: 'PUT', headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify(state), + body: JSON.stringify(stateToSave), }); } catch (err) { // ignore save errors for now @@ -124,7 +137,7 @@ export function useHospitalStore() { })(); }, 300); return () => clearTimeout(t); - }, [state, isLoaded]); + }, [state, initialLoadComplete]); // Acciones de navegación const setVista = useCallback((vista: Vista) => { @@ -570,6 +583,7 @@ const getEstadisticas = useCallback(() => { throw new Error(err.error || 'Error en autenticación'); } const user = await res.json(); + sessionStorage.setItem('hospital_user', JSON.stringify(user)); setState(prev => ({ ...prev, currentUser: user, isAuthenticated: true })); return user; } catch (err) { @@ -578,13 +592,9 @@ const getEstadisticas = useCallback(() => { }, []); const logout = useCallback(() => { + sessionStorage.removeItem('hospital_user'); setState(prev => { const newState = { ...prev, currentUser: null, isAuthenticated: false }; - fetch(`${API_BASE}/state`, { - method: 'PUT', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ ...newState }), - }).catch(() => {}); return newState; }); }, []); @@ -644,6 +654,50 @@ const getEstadisticas = useCallback(() => { return rol === 'admin'; }, [state.currentUser, state.internaciones, state.camas]); + const getCamaAreaId = useCallback((camaId: string): string | null => { + const cama = state.camas.find(c => c.id === camaId); + return cama?.areaId || null; + }, [state.camas]); + + const getInternacionAreaId = useCallback((internacionId: string): string | null => { + const internacion = state.internaciones.find(i => i.id === internacionId); + if (!internacion) return null; + return getCamaAreaId(internacion.camaId); + }, [state.internaciones, getCamaAreaId]); + + const getPacienteAreaId = useCallback((pacienteId: string): string | null => { + const internacion = state.internaciones.find(i => i.pacienteId === pacienteId && i.activa); + if (!internacion) { + const anyInternacion = state.internaciones.find(i => i.pacienteId === pacienteId); + if (anyInternacion) return getCamaAreaId(anyInternacion.camaId); + return null; + } + return getCamaAreaId(internacion.camaId); + }, [state.internaciones, getCamaAreaId]); + + const canEditInArea = useCallback((areaId: string | null | undefined): boolean => { + const user = state.currentUser; + if (!user) return false; + if (user.rol === 'admin') return true; + if (!areaId) return false; + return user.areaId === areaId; + }, [state.currentUser]); + + const canEditCama = useCallback((camaId: string): boolean => { + const areaId = getCamaAreaId(camaId); + return canEditInArea(areaId); + }, [getCamaAreaId, canEditInArea]); + + const canEditInternacion = useCallback((internacionId: string): boolean => { + const areaId = getInternacionAreaId(internacionId); + return canEditInArea(areaId); + }, [getInternacionAreaId, canEditInArea]); + + const canEditPaciente = useCallback((pacienteId: string): boolean => { + const areaId = getPacienteAreaId(pacienteId); + return canEditInArea(areaId); + }, [getPacienteAreaId, canEditInArea]); + return { ...state, isLoaded, @@ -702,5 +756,12 @@ const getEstadisticas = useCallback(() => { updateEmail, hasPermission, canAccessInternacion, + canEditInArea, + canEditCama, + canEditInternacion, + canEditPaciente, + getCamaAreaId, + getInternacionAreaId, + getPacienteAreaId, }; } diff --git a/src/sections/HistoriaClinica.tsx b/src/sections/HistoriaClinica.tsx index c14ef57..deb646e 100644 --- a/src/sections/HistoriaClinica.tsx +++ b/src/sections/HistoriaClinica.tsx @@ -69,6 +69,7 @@ interface HistoriaClinicaProps { interconsultas: Interconsulta[]; atb: ATB[]; indicadores: Indicacion[]; + canEdit: boolean; onAgregarEvolucion: (evolucion: Omit) => void; onActualizarEvolucion: (id: string, datos: Partial) => void; onEliminarEvolucion: (id: string) => void; @@ -92,11 +93,8 @@ interface HistoriaClinicaProps { onActualizarATB: (id: string, datos: Partial) => void; onEliminarATB: (id: string) => void; onAgregarIndicacion: (indicacion: Omit) => void; - onActualizarIndicacion: (id: string, datos: Partial) => void; + onActualizarIndicacion: (indicacion: Indicacion) => void; onEliminarIndicacion: (id: string) => void; - movimientos?: any[]; - onAgregarMovimiento?: (m: any) => void; - onActualizarInternacion: (id: string, datos: Partial) => void; onActualizarCama: (id: string, datos: Partial) => void; onVolver: () => void; onEditarIngreso?: () => void; @@ -535,19 +533,19 @@ export function HistoriaClinica({ - + - + - + - + @@ -558,6 +556,7 @@ export function HistoriaClinica({ add={onAgregarATB} update={onActualizarATB} del={onEliminarATB} + canEdit={canEdit} /> @@ -570,6 +569,7 @@ export function HistoriaClinica({ del={onEliminarIndicacion} movimientos={movimientos} onAgregarMovimiento={onAgregarMovimiento} + canEdit={canEdit} /> @@ -581,6 +581,7 @@ export function HistoriaClinica({ add={onAgregarEstudioComplementario} update={onActualizarEstudioComplementario} del={onEliminarEstudioComplementario} + canEdit={canEdit} /> @@ -592,6 +593,7 @@ export function HistoriaClinica({ add={onAgregarInterconsulta} update={onActualizarInterconsulta} del={onEliminarInterconsulta} + canEdit={canEdit} /> @@ -601,13 +603,14 @@ export function HistoriaClinica({ ); } -function SeccionLaboratorios({ lab, patientId, add, update, del, addAcidoBase }: { +function SeccionLaboratorios({ lab, patientId, add, update, del, addAcidoBase, canEdit }: { lab: Laboratorio[]; patientId: string; add: (l: Omit) => void; update: (id: string, data: Partial) => void; del: (id: string) => void; addAcidoBase?: (a: Omit) => void; + canEdit?: boolean; }) { const [dialog, setDialog] = useState(false); const [obsDialog, setObsDialog] = useState(false); @@ -954,7 +957,7 @@ function SeccionLaboratorios({ lab, patientId, add, update, del, addAcidoBase }:
- + {canEdit && }
@@ -1279,12 +1282,13 @@ function SeccionLaboratorios({ lab, patientId, add, update, del, addAcidoBase }: ); } -function SeccionEvoluciones({ evos, internacionId, add, update, del }: { +function SeccionEvoluciones({ evos, internacionId, add, update, del, canEdit }: { evos: Evolucion[]; internacionId: string; add: (e: Omit) => void; update: (id: string, data: Partial) => void; del: (id: string) => void; + canEdit?: boolean; }) { const [dialog, setDialog] = useState(false); const [edit, setEdit] = useState(null); @@ -1376,7 +1380,7 @@ function SeccionEvoluciones({ evos, internacionId, add, update, del }: { return (
- + {canEdit && }
@@ -1431,8 +1435,8 @@ function SeccionEvoluciones({ evos, internacionId, add, update, del }: {

{e.fecha} {e.hora}

Médico: {e.medico}

- - + {canEdit && } + {canEdit && }
{svText &&

Signos Vitales: {svText}

} @@ -1459,12 +1463,13 @@ function SeccionEvoluciones({ evos, internacionId, add, update, del }: { ); } -function SeccionAcidosBase({ ab, patientId, add, update, del }: { +function SeccionAcidosBase({ ab, patientId, add, update, del, canEdit }: { ab: AcidoBase[]; patientId: string; add: (a: Omit) => void; update: (id: string, datos: Partial) => void; del: (id: string) => void; + canEdit?: boolean; }) { const [dialog, setDialog] = useState(false); const [editDialog, setEditDialog] = useState(false); @@ -1552,7 +1557,7 @@ function SeccionAcidosBase({ ab, patientId, add, update, del }: { return (
- + {canEdit && }
@@ -1691,12 +1696,13 @@ function SeccionAcidosBase({ ab, patientId, add, update, del }: { ); } -function SeccionCultivos({ cults, patient, add, update, del }: { +function SeccionCultivos({ cults, patient, add, update, del, canEdit }: { cults: Cultivo[]; patient: Paciente; add: (c: Omit) => void; update: (id: string, data: Partial) => void; del: (id: string) => void; + canEdit?: boolean; }) { const [dialog, setDialog] = useState(false); const [resDialog, setResDialog] = useState(false); @@ -1811,7 +1817,7 @@ function SeccionCultivos({ cults, patient, add, update, del }: { return (
- + {canEdit && }
@@ -1966,13 +1972,14 @@ function SeccionCultivos({ cults, patient, add, update, del }: { ); } -function SeccionEstudiosComplementarios({ estudios, internacionId, pacienteId, add, update, del }: { +function SeccionEstudiosComplementarios({ estudios, internacionId, pacienteId, add, update, del, canEdit }: { estudios: EstudioComplementario[]; internacionId: string; pacienteId: string; add: (e: Omit) => void; update: (id: string, datos: Partial) => void; del: (id: string) => void; + canEdit?: boolean; }) { const [dialog, setDialog] = useState(false); const [filtro, setFiltro] = useState<'todos' | 'internacion'>('internacion'); @@ -2021,10 +2028,10 @@ function SeccionEstudiosComplementarios({ estudios, internacionId, pacienteId, a
- + }