Actualizacion de sistema: mejoras en seleccion de categorias de cultivos, optimizacion responsive de listado de cultivos e historia clinica, y correccion de componentes
This commit is contained in:
@@ -12,6 +12,7 @@ import { initDb,
|
||||
getAllGlucemias, createGlucemia, updateGlucemia, deleteGlucemia,
|
||||
getAllAcidosBase, createAcidoBase, updateAcidoBase, deleteAcidoBase,
|
||||
getAllCultivos, createCultivo, updateCultivo, deleteCultivo,
|
||||
getAllTiposCultivo, createTipoCultivo, updateTipoCultivo, deleteTipoCultivo, restablecerTiposCultivo,
|
||||
getAllEstudiosComplementarios, createEstudioComplementario, updateEstudioComplementario, deleteEstudioComplementario,
|
||||
getAllInterconsultas, createInterconsulta, updateInterconsulta, deleteInterconsulta,
|
||||
getAllAtb, createAtb, updateAtb, deleteAtb,
|
||||
@@ -95,6 +96,7 @@ app.get('/api/state', async (req, res) => {
|
||||
glucemias: await getAllGlucemias(),
|
||||
acidosBase: await getAllAcidosBase(),
|
||||
cultivos: await getAllCultivos(),
|
||||
tiposCultivo: await getAllTiposCultivo(),
|
||||
estudiosComplementarios: await getAllEstudiosComplementarios(),
|
||||
interconsultas: (await getAllInterconsultas()).map(ic => ({ ...ic, realizada: !!ic.realizada })),
|
||||
atb: await getAllAtb(),
|
||||
@@ -580,6 +582,51 @@ app.delete('/api/cultivos/:id', async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
// ========== TIPOS DE CULTIVO ==========
|
||||
app.get('/api/tipos-cultivo', async (req, res) => {
|
||||
try {
|
||||
res.json(await getAllTiposCultivo());
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: 'Error al obtener tipos de cultivo' });
|
||||
}
|
||||
});
|
||||
|
||||
app.post('/api/tipos-cultivo', async (req, res) => {
|
||||
try {
|
||||
const nuevo = await createTipoCultivo(req.body);
|
||||
res.json(nuevo);
|
||||
} catch (err) {
|
||||
res.status(400).json({ error: err.message || 'Error al crear tipo de cultivo' });
|
||||
}
|
||||
});
|
||||
|
||||
app.put('/api/tipos-cultivo/:id', async (req, res) => {
|
||||
try {
|
||||
const updated = await updateTipoCultivo(req.params.id, req.body);
|
||||
res.json(updated);
|
||||
} catch (err) {
|
||||
res.status(400).json({ error: err.message || 'Error al actualizar tipo de cultivo' });
|
||||
}
|
||||
});
|
||||
|
||||
app.delete('/api/tipos-cultivo/:id', async (req, res) => {
|
||||
try {
|
||||
await deleteTipoCultivo(req.params.id);
|
||||
res.json({ ok: true });
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: 'Error al eliminar tipo de cultivo' });
|
||||
}
|
||||
});
|
||||
|
||||
app.post('/api/tipos-cultivo/reset', async (req, res) => {
|
||||
try {
|
||||
const list = await restablecerTiposCultivo();
|
||||
res.json(list);
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: 'Error al restablecer tipos de cultivo' });
|
||||
}
|
||||
});
|
||||
|
||||
// ========== ESTUDIOS COMPLEMENTARIOS ==========
|
||||
app.get('/api/estudios-complementarios', async (req, res) => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user