const modal = document.getElementById("prescriptionModal"); const addMedBtn = document.getElementById("addMed"); const medList = document.getElementById("medicineList"); const sendRxBtn = document.getElementById("sendRx"); const closeModal = document.querySelector(".close-modal"); const startRecordBtn = document.getElementById("startRecording"); const recordingStatus = document.getElementById("recordingStatus"); const aiInsightsBox = document.getElementById("aiInsights"); const insightText = document.getElementById("insightText"); // Open modal when clicking 'Prescribe' document.querySelectorAll(".btn-small").forEach(btn => { if (btn.innerText === "Prescribe") { btn.addEventListener("click", () => { modal.style.display = "block"; }); } }); closeModal.onclick = () => modal.style.display = "none"; window.onclick = (event) => { if (event.target == modal) modal.style.display = "none"; }; // Add new medicine row addMedBtn.onclick = () => { const row = document.createElement("div"); row.className = "med-row"; row.innerHTML = ` `; medList.appendChild(row); }; // Handle sending prescription sendRxBtn.onclick = () => { const diagnosis = document.getElementById("rxDiagnosis").value; const meds = []; document.querySelectorAll(".med-row").forEach(row => { const name = row.querySelector(".med-name").value; if (name) { meds.push({ name, dosage: row.querySelector(".med-dosage").value, frequency: row.querySelector(".med-freq").value }); } }); if (!diagnosis || meds.length === 0) { alert("Please enter diagnosis and at least one medicine."); return; } // Simulate sending to backend console.log("Sending Rx:", { diagnosis, meds }); // UI Feedback sendRxBtn.innerText = "Sent! ✅"; sendRxBtn.style.background = "#10B981"; setTimeout(() => { modal.style.display = "none"; sendRxBtn.innerText = "Send to WhatsApp"; sendRxBtn.style.background = ""; alert("Prescription has been sent to the patient's WhatsApp."); }, 1500); }; // Voice AI Logic startRecordBtn.onclick = () => { startRecordBtn.classList.add("hidden"); recordingStatus.classList.remove("hidden"); // Simulate recording for 3 seconds setTimeout(() => { recordingStatus.classList.add("hidden"); aiInsightsBox.classList.remove("hidden"); // Mock data filtering simulation const mockTranscript = "Hello Rahul, how is your family? The weather is very hot today. Regarding your cough, it seems like a viral infection. You should avoid cold drinks for 3 days. Take the paracetamol after meals. I'll see you in a week."; // Filter out small talk (AI simulation) const insights = "Viral infection detected. Avoid cold drinks for 3 days. Take paracetamol after meals. Follow-up in 1 week."; insightText.innerText = insights; // Auto-fill diagnosis if empty if (!document.getElementById("rxDiagnosis").value) { document.getElementById("rxDiagnosis").value = "Viral Infection"; } }, 3000); }; // Section Switching Logic window.showSection = (sectionId) => { // Hide all sections document.getElementById('overview-section').classList.add('hidden'); document.getElementById('patients-section').classList.add('hidden'); // Show target section if (sectionId === 'overview') { document.getElementById('overview-section').classList.remove('hidden'); } else if (sectionId === 'queue') { document.getElementById('overview-section').classList.remove('hidden'); document.getElementById('queue-section').scrollIntoView({ behavior: 'smooth' }); } else if (sectionId === 'patients') { document.getElementById('patients-section').classList.remove('hidden'); } // Update active state in nav document.querySelectorAll('.side-nav a').forEach(link => { link.classList.remove('active'); if (link.innerText.toLowerCase().includes(sectionId)) { link.classList.add('active'); } }); };