Add ATB tab for antibiotic treatment tracking
This commit is contained in:
@@ -183,6 +183,25 @@ try {
|
||||
console.log('Error tabla interconsultas:', e.message);
|
||||
}
|
||||
|
||||
try {
|
||||
const existingATB = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='atb'").get();
|
||||
if (!existingATB) {
|
||||
db.exec(`
|
||||
CREATE TABLE atb (
|
||||
id TEXT PRIMARY KEY,
|
||||
pacienteId TEXT NOT NULL,
|
||||
internacionId TEXT NOT NULL,
|
||||
antibiotico TEXT,
|
||||
fechaInicio TEXT,
|
||||
fechaFinalizacion TEXT
|
||||
)
|
||||
`);
|
||||
console.log('Tabla atb creada');
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('Error tabla atb:', e.message);
|
||||
}
|
||||
|
||||
const app = express();
|
||||
app.use(cors());
|
||||
app.use(express.json({ limit: '50mb' }));
|
||||
@@ -233,6 +252,7 @@ app.get('/api/state', (req, res) => {
|
||||
cultivos: queryAll('SELECT * FROM cultivos'),
|
||||
estudiosComplementarios: queryAll('SELECT * FROM estudiosComplementarios'),
|
||||
interconsultas: queryAll('SELECT * FROM interconsultas').map(ic => ({ ...ic, realizada: !!ic.realizada })),
|
||||
atb: queryAll('SELECT * FROM atb'),
|
||||
vistaActual: 'dashboard',
|
||||
currentInternacionId: null
|
||||
};
|
||||
@@ -323,6 +343,14 @@ if (state.laboratorios?.length) {
|
||||
}
|
||||
}
|
||||
|
||||
run('DELETE FROM atb');
|
||||
if (state.atb?.length) {
|
||||
const stmt = db.prepare('INSERT INTO atb (id, pacienteId, internacionId, antibiotico, fechaInicio, fechaFinalizacion) VALUES (?, ?, ?, ?, ?, ?)');
|
||||
for (const atb of state.atb) {
|
||||
stmt.run(atb.id, atb.pacienteId, atb.internacionId, atb.antibiotico, atb.fechaInicio, atb.fechaFinalizacion || null);
|
||||
}
|
||||
}
|
||||
|
||||
res.json({ ok: true });
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user