fix(HistoriaClinica): agregar handlers de otrosLaboratorios en store y corregir ReferenceError

This commit is contained in:
2026-08-12 22:18:27 +00:00
parent ed31b23159
commit 6fb825778f
12 changed files with 851 additions and 32 deletions
+61
View File
@@ -56,6 +56,7 @@ const memStore = {
internaciones: [],
evoluciones: [],
laboratorios: [],
otrosLaboratorios: [],
glucemias: [],
acidosbase: [],
cultivos: [],
@@ -1058,3 +1059,63 @@ export async function importAllData(dump) {
}
}
}
export async function getAllOtrosLaboratorios() {
if (db) {
const records = await db.collection('otros-laboratorios').find().toArray();
return cleanDocs(records);
}
return [...memStore.otrosLaboratorios];
}
export async function createOtroLaboratorio(record) {
const doc = {
id: record.id,
pacienteId: record.pacienteId,
internacionId: record.internacionId,
fecha: record.fecha,
hora: record.hora,
observaciones: record.observaciones,
createdAt: new Date().toISOString()
};
if (db) {
await db.collection('otros-laboratorios').insertOne(doc);
return cleanDoc(doc);
}
memStore.otrosLaboratorios.push(doc);
return doc;
}
export async function updateOtroLaboratorio(id, updates) {
if (db) {
await db.collection('otros-laboratorios').updateOne(
{ id },
{ $set: { ...updates, updatedAt: new Date().toISOString() } }
);
return { success: true };
}
const idx = memStore.otrosLaboratorios.findIndex(x => x.id === id);
if (idx !== -1) {
memStore.otrosLaboratorios[idx] = { ...memStore.otrosLaboratorios[idx], ...updates, updatedAt: new Date().toISOString() };
return { success: true };
}
return { success: false };
}
export async function deleteOtroLaboratorio(id) {
if (db) {
await db.collection('otros-laboratorios').deleteOne({ id });
return { success: true };
}
const idx = memStore.otrosLaboratorios.findIndex(x => x.id === id);
if (idx !== -1) {
memStore.otrosLaboratorios.splice(idx, 1);
return { success: true };
}
return { success: false };
}