-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dashboard.js b/dashboard.js
index 3c2263b..ae086ed 100644
--- a/dashboard.js
+++ b/dashboard.js
@@ -131,13 +131,19 @@ if (startRecordBtn) {
};
}
-// 6. AI Scribe & Context Switching Logic
+// 6. AI Scribe, Summarization & Context Switching Logic
let isScribing = false;
+let currentPatientId = "#012";
+const patientDataStore = {
+ "#012": { notes: "", summary: "" },
+ "#013": { notes: "", summary: "" },
+ "#014": { notes: "", summary: "" }
+};
window.toggleZenScribe = () => {
const btn = document.getElementById("zenScribeBtn");
const status = document.getElementById("scribeStatus");
- const notes = document.querySelector(".zen-textarea");
+ const notesArea = document.getElementById("consultationNotes");
isScribing = !isScribing;
@@ -146,42 +152,90 @@ window.toggleZenScribe = () => {
btn.style.background = "#EF4444";
status.classList.remove("hidden");
- // Simulate AI Scribe capturing notes
+ // Simulate AI capturing notes
setTimeout(() => {
if (isScribing) {
- notes.value += "Patient reports symptoms of fatigue and persistent dry cough for 3 days. No fever recorded today. \n";
+ notesArea.value += "Patient reports symptoms of fatigue and persistent dry cough for 3 days. No fever recorded today. \n";
}
}, 3000);
} else {
btn.innerText = "🎙️ Start AI Scribe";
btn.style.background = "";
status.classList.add("hidden");
+ generateSummary();
}
};
+function generateSummary() {
+ const notes = document.getElementById("consultationNotes").value;
+ if (!notes) return;
+
+ const summaryCard = document.getElementById("aiSummaryCard");
+ const summaryText = document.getElementById("summaryText");
+
+ // AI Summarization simulation
+ const summary = `📋 CLINICAL SUMMARY: Patient presents with persistent dry cough (3 days). Fatigue noted. No fever. Recommended hydration and follow-up if symptoms persist.`;
+
+ summaryText.innerText = summary;
+ summaryCard.classList.remove("hidden");
+
+ // Persist in store
+ patientDataStore[currentPatientId].notes = notes;
+ patientDataStore[currentPatientId].summary = summary;
+ console.log(`Saved summary for ${currentPatientId}`);
+}
+
window.switchPatientContext = (name, token, triage) => {
- // 1. Reset Scribe State
+ // 1. Save current state before switching
+ if (currentPatientId) {
+ patientDataStore[currentPatientId].notes = document.getElementById("consultationNotes").value;
+ }
+
+ // 2. Reset UI for new context
isScribing = false;
const btn = document.getElementById("zenScribeBtn");
- if (btn) {
- btn.innerText = "🎙️ Start AI Scribe";
- btn.style.background = "";
- }
+ if (btn) { btn.innerText = "🎙️ Start AI Scribe"; btn.style.background = ""; }
const status = document.getElementById("scribeStatus");
if (status) status.classList.add("hidden");
- // 2. Clear Current Workspace
- const notes = document.querySelector(".zen-textarea");
- if (notes) notes.value = "";
+ // 3. Update Current Patient ID
+ currentPatientId = token;
+
+ // 4. Load or Clear Workspace
+ const notesArea = document.getElementById("consultationNotes");
+ const summaryCard = document.getElementById("aiSummaryCard");
+ const summaryText = document.getElementById("summaryText");
+
+ if (patientDataStore[token] && patientDataStore[token].notes) {
+ notesArea.value = patientDataStore[token].notes;
+ if (patientDataStore[token].summary) {
+ summaryText.innerText = patientDataStore[token].summary;
+ summaryCard.classList.remove("hidden");
+ } else {
+ summaryCard.classList.add("hidden");
+ }
+ } else {
+ notesArea.value = "";
+ summaryCard.classList.add("hidden");
+ // Initialize new store entry if needed
+ if (!patientDataStore[token]) patientDataStore[token] = { notes: "", summary: "" };
+ }
- // 3. Update Headers
+ // 5. Update Headers
const h1 = document.querySelector(".current-patient h1");
if (h1) h1.innerHTML = `${name} (32y, Female)`;
-
const meta = document.querySelector(".patient-meta");
if (meta) meta.innerHTML = `${token} • ${triage} • 00:00`;
-
- alert(`Switched context to: ${name}. AI Scribe reset.`);
+};
+
+window.shareSummary = () => {
+ const summary = document.getElementById("summaryText").innerText;
+ alert(`📤 Sent to Patient's WhatsApp:\n\n${summary}`);
+};
+
+window.printSummary = () => {
+ const summary = document.getElementById("summaryText").innerText;
+ alert(`🖨️ Printing Handover Note:\n\n${summary}`);
};