bestPracticesFirebase = {
const { initializeApp, getApps, getApp } = await import("https://www.gstatic.com/firebasejs/10.14.1/firebase-app.js");
const { getFirestore, collection, onSnapshot } = await import("https://www.gstatic.com/firebasejs/10.14.1/firebase-firestore.js");
const firebaseConfig = {
apiKey: "AIzaSyD1FLnIrd86qOsFPLi5y1q_EIU0lhL5gxc",
authDomain: "evdtoolkit.firebaseapp.com",
projectId: "evdtoolkit",
storageBucket: "evdtoolkit.firebasestorage.app",
messagingSenderId: "1002374431151",
appId: "1:1002374431151:web:fe3724bb1f39eb4744af5a"
};
const app = getApps().length ? getApp() : initializeApp(firebaseConfig);
return { db: getFirestore(app), collection, onSnapshot };
}โ๏ธ Best Practices
Quick-reference guide for safe EVD management
A quick-reference guide to safe, high-quality care when managing external ventricular drains.
function watchCollection(name) {
return Generators.observe(notify => {
const unsubscribe = bestPracticesFirebase.onSnapshot(
bestPracticesFirebase.collection(bestPracticesFirebase.db, name),
snapshot => notify(snapshot.docs.map(d => d.data()).sort((a, b) => (a.order ?? 0) - (b.order ?? 0)))
);
return unsubscribe;
});
}// BestPracticesContent docs don't carry their own `id` field in
// Firestore (it's the document key) โ read directly instead.
bestPracticesById = {
const { doc, onSnapshot } = await import("https://www.gstatic.com/firebasejs/10.14.1/firebase-firestore.js");
const ids = ["csf_caveat", "key_takeaway"];
const result = {};
return Generators.observe(notify => {
const unsubscribes = ids.map(id =>
onSnapshot(doc(bestPracticesFirebase.db, "BestPracticesContent", id), snap => {
result[id] = snap.exists() ? snap.data() : {};
notify({ ...result });
})
);
return () => unsubscribes.forEach(u => u());
});
}function renderCitations(block) {
if (!block) return "";
const citations = [];
if (block.citationAuthors && block.citationTitle) {
citations.push({ authors: block.citationAuthors, title: block.citationTitle, journal: block.citationJournalInfo, pmid: block.citationPmid });
}
if (block.citationAuthors2 && block.citationTitle2) {
citations.push({ authors: block.citationAuthors2, title: block.citationTitle2, journal: block.citationJournalInfo2, pmid: block.citationPmid2 });
}
if (citations.length === 0) {
return `<div class="fs-source" style="color:#c00;">โ ๏ธ Citation needed</div>`;
}
return citations.map(c => `
<div class="fs-source">
๐ ${c.authors ? c.authors + " โ " : ""}<strong>${c.title ?? ""}</strong>${c.journal ? " " + c.journal : ""}
${c.pmid ? ` <a href="https://pubmed.ncbi.nlm.nih.gov/${c.pmid}/" target="_blank" rel="noopener">[PMID: ${c.pmid}]</a>` : ""}
</div>
`).join("");
}Doโs and Donโts
doDonts.length === 0
? html`<div class="fs-empty">Loadingโฆ</div>`
: html`<table>
<thead><tr><th>Do</th><th>Don't</th></tr></thead>
<tbody>
${doDonts.map(row => `
<tr>
<td><span class="mark-do">โ</span> ${row.doText ?? ""}</td>
<td><span class="mark-dont">โ</span> ${row.dontText ?? ""}</td>
</tr>
`).join("")}
</tbody>
</table>`CSF Color Interpretation
csfColors.length === 0
? html`<div class="fs-empty">Loadingโฆ</div>`
: html`<table>
<thead><tr><th>CSF Appearance</th><th>Clinical Interpretation</th></tr></thead>
<tbody>
${csfColors.map(row => `
<tr><td><strong>${row.appearance ?? ""}</strong></td><td>${row.interpretation ?? ""}</td></tr>
`).join("")}
</tbody>
</table>`Key Takeaway
html`<div class="callout-tip" style="padding:12px 16px;border-radius:8px;">
<strong>Clinical Pearl:</strong> ${bestPracticesById.key_takeaway?.text ?? ""}
</div>
<div class="callout-note" style="padding:12px 16px;border-radius:8px;margin-top:10px;">
<strong>Source:</strong>
${renderCitations(bestPracticesById.key_takeaway)}
</div>`