fix: repair corrupted dashboard.js and hide overview by default
Build Curio HMS / build-and-deploy (push) Successful in 44s
Details
Build Curio HMS / build-and-deploy (push) Successful in 44s
Details
This commit is contained in:
parent
cb4e4406d1
commit
004339ee9f
|
|
@ -109,7 +109,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="overview-section">
|
<div id="overview-section" class="hidden">
|
||||||
<section class="stats-row">
|
<section class="stats-row">
|
||||||
<div class="stat-card">
|
<div class="stat-card">
|
||||||
<span>In Queue</span>
|
<span>In Queue</span>
|
||||||
|
|
@ -376,6 +376,6 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="dashboard.js?v=2"></script>
|
<script src="dashboard.js?v=3"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
265
dashboard.js
265
dashboard.js
|
|
@ -1,3 +1,4 @@
|
||||||
|
// Core Modal & UI Elements
|
||||||
const modal = document.getElementById("consultationModal");
|
const modal = document.getElementById("consultationModal");
|
||||||
const addMedBtn = document.getElementById("addMed");
|
const addMedBtn = document.getElementById("addMed");
|
||||||
const medList = document.getElementById("medicineList");
|
const medList = document.getElementById("medicineList");
|
||||||
|
|
@ -9,181 +10,143 @@ const aiInsightsBox = document.getElementById("aiInsights");
|
||||||
const insightText = document.getElementById("insightText");
|
const insightText = document.getElementById("insightText");
|
||||||
const queueDateInput = document.getElementById("queueDate");
|
const queueDateInput = document.getElementById("queueDate");
|
||||||
const newWalkinBtn = document.getElementById("newWalkinBtn");
|
const newWalkinBtn = document.getElementById("newWalkinBtn");
|
||||||
|
|
||||||
// Initialize Date Picker to Today
|
|
||||||
if (queueDateInput) {
|
|
||||||
const today = new Date().toISOString().split('T')[0];
|
|
||||||
queueDateInput.value = today;
|
|
||||||
queueDateInput.min = today; // Prevent past dates
|
|
||||||
|
|
||||||
queueDateInput.addEventListener("change", (e) => {
|
|
||||||
console.log(`Switching view to date: ${e.target.value}`);
|
|
||||||
// In a real app, this would fetch the queue for that specific date
|
|
||||||
alert(`Now viewing appointments for: ${e.target.value}`);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle New Walk-in for selected date
|
|
||||||
if (newWalkinBtn) {
|
|
||||||
newWalkinBtn.addEventListener("click", () => {
|
|
||||||
const selectedDate = queueDateInput.value;
|
|
||||||
const name = prompt("Enter Patient Name:");
|
|
||||||
if (name) {
|
|
||||||
console.log(`Booking walk-in for ${name} on ${selectedDate}`);
|
|
||||||
alert(`Token generated for ${name} on ${selectedDate}. \n\nPlease print the token and hand it to the patient.`);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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";
|
|
||||||
};
|
|
||||||
|
|
||||||
const labList = document.getElementById("labTestList");
|
const labList = document.getElementById("labTestList");
|
||||||
const addLabBtn = document.getElementById("addLabTest");
|
const addLabBtn = document.getElementById("addLabTest");
|
||||||
|
|
||||||
// Add new medicine row
|
// 1. Initialize View on Load
|
||||||
addMedBtn.onclick = () => {
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
const row = document.createElement("div");
|
const userRole = localStorage.getItem('userRole') || 'OWNER';
|
||||||
row.className = "med-row";
|
const userEmail = localStorage.getItem('userEmail') || 'admin@curio.app';
|
||||||
row.innerHTML = `
|
|
||||||
<input type="text" placeholder="Medicine Name" class="med-name">
|
|
||||||
<input type="text" placeholder="Dosage (e.g. 1-0-1)" class="med-dosage">
|
|
||||||
<input type="text" placeholder="Duration" class="med-duration">
|
|
||||||
`;
|
|
||||||
medList.appendChild(row);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Add new lab test row
|
// Set Sidebar Profile
|
||||||
addLabBtn.onclick = () => {
|
const roleDisplay = document.querySelector(".user-profile .info strong");
|
||||||
const row = document.createElement("div");
|
const emailDisplay = document.querySelector(".user-profile .info span");
|
||||||
row.className = "lab-row";
|
if (roleDisplay) roleDisplay.innerText = userRole.charAt(0) + userRole.slice(1).toLowerCase();
|
||||||
row.style = "display: flex; gap: 0.5rem; margin-bottom: 0.5rem;";
|
if (emailDisplay) emailDisplay.innerText = userEmail;
|
||||||
row.innerHTML = `
|
|
||||||
<input type="text" placeholder="Test Name (e.g. CBC, Lipid)" class="lab-test-name" style="flex: 1; padding: 0.6rem; border-radius: 8px; border: 1px solid var(--border);">
|
|
||||||
`;
|
|
||||||
labList.appendChild(row);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Handle sending prescription
|
// Apply Role-Based Filtering
|
||||||
sendRxBtn.onclick = () => {
|
if (userRole === 'DOCTOR') {
|
||||||
const diagnosis = document.getElementById("rxDiagnosis").value;
|
document.querySelectorAll('.side-nav a').forEach(link => {
|
||||||
const meds = [];
|
const text = link.innerText;
|
||||||
document.querySelectorAll(".med-row").forEach(row => {
|
if (text.includes('Billing') || text.includes('Staff') || text.includes('Overview')) {
|
||||||
const name = row.querySelector(".med-name").value;
|
link.style.display = 'none';
|
||||||
if (name) {
|
}
|
||||||
meds.push({
|
});
|
||||||
name,
|
showSection('zen');
|
||||||
dosage: row.querySelector(".med-dosage").value,
|
} else if (userRole === 'RECEPTIONIST') {
|
||||||
duration: row.querySelector(".med-duration").value
|
document.querySelectorAll('.side-nav a').forEach(link => {
|
||||||
});
|
const text = link.innerText;
|
||||||
}
|
if (text.includes('Lab') || text.includes('Staff')) {
|
||||||
});
|
link.style.display = 'none';
|
||||||
|
}
|
||||||
if (!diagnosis || meds.length === 0) {
|
});
|
||||||
alert("Please enter diagnosis and at least one medicine.");
|
showSection('overview');
|
||||||
return;
|
} else {
|
||||||
|
showSection('overview');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simulate sending to backend
|
// Set Default Date
|
||||||
console.log("Sending Rx:", { diagnosis, meds });
|
if (queueDateInput) {
|
||||||
|
const today = new Date().toISOString().split('T')[0];
|
||||||
|
queueDateInput.value = today;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// UI Feedback
|
// 2. Section Switching Logic
|
||||||
sendRxBtn.innerText = "Sent! ✅";
|
window.showSection = (sectionId) => {
|
||||||
sendRxBtn.style.background = "#10B981";
|
const sections = ['overview-section', 'patients-section', 'pharmacy-section', 'lab-section', 'doctor-zen-section'];
|
||||||
|
sections.forEach(id => {
|
||||||
|
const el = document.getElementById(id);
|
||||||
|
if (el) el.classList.add('hidden');
|
||||||
|
});
|
||||||
|
|
||||||
setTimeout(() => {
|
if (sectionId === 'overview') {
|
||||||
modal.style.display = "none";
|
document.getElementById('overview-section').classList.remove('hidden');
|
||||||
sendRxBtn.innerText = "Send to WhatsApp";
|
} else if (sectionId === 'zen') {
|
||||||
sendRxBtn.style.background = "";
|
document.getElementById('doctor-zen-section').classList.remove('hidden');
|
||||||
|
} else if (sectionId === 'queue') {
|
||||||
const note = document.getElementById("deptNote").value;
|
const role = localStorage.getItem('userRole');
|
||||||
if (note) {
|
if (role === 'DOCTOR') {
|
||||||
console.log("Dept Note:", note);
|
document.getElementById('doctor-zen-section').classList.remove('hidden');
|
||||||
alert("Prescription sent. Note forwarded to Pharmacy/Lab.");
|
|
||||||
} else {
|
} else {
|
||||||
alert("Prescription has been sent to the patient's WhatsApp.");
|
document.getElementById('overview-section').classList.remove('hidden');
|
||||||
|
document.getElementById('queue-section').scrollIntoView({ behavior: 'smooth' });
|
||||||
}
|
}
|
||||||
}, 1500);
|
} else if (sectionId === 'patients') {
|
||||||
|
document.getElementById('patients-section').classList.remove('hidden');
|
||||||
|
} else if (sectionId === 'pharmacy') {
|
||||||
|
document.getElementById('pharmacy-section').classList.remove('hidden');
|
||||||
|
} else if (sectionId === 'lab') {
|
||||||
|
document.getElementById('lab-section').classList.remove('hidden');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Nav Active State
|
||||||
|
document.querySelectorAll('.side-nav a').forEach(link => {
|
||||||
|
link.classList.remove('active');
|
||||||
|
if (link.innerText.toLowerCase().includes(sectionId)) link.classList.add('active');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Mobile Auto-hide Sidebar
|
||||||
|
if (window.innerWidth <= 768) {
|
||||||
|
const sb = document.getElementById('sidebar');
|
||||||
|
if (sb) sb.style.display = 'none';
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
window.shareTip = (type) => {
|
// 3. Clinical Consultation Logic
|
||||||
const tips = {
|
if (addMedBtn) {
|
||||||
diabetes: "🥗 Healthy Diet Tip: Reduce white rice, add more greens.",
|
addMedBtn.onclick = () => {
|
||||||
hypertension: "🧘 BP Control: Limit salt intake to 5g/day.",
|
const row = document.createElement("div");
|
||||||
viral: "💧 Hydration: Drink 3L of warm water daily."
|
row.className = "med-row";
|
||||||
|
row.innerHTML = `
|
||||||
|
<input type="text" placeholder="Medicine Name" class="med-name">
|
||||||
|
<input type="text" placeholder="Dosage (e.g. 1-0-1)" class="med-dosage">
|
||||||
|
<input type="text" placeholder="Duration" class="med-duration">
|
||||||
|
`;
|
||||||
|
medList.appendChild(row);
|
||||||
};
|
};
|
||||||
alert(`📤 Sent to Patient's WhatsApp:\n\n${tips[type]}`);
|
}
|
||||||
};
|
|
||||||
|
|
||||||
window.printTips = () => {
|
if (addLabBtn) {
|
||||||
alert("🖨️ Printing General Health Guidelines for this patient...");
|
addLabBtn.onclick = () => {
|
||||||
};
|
const row = document.createElement("div");
|
||||||
|
row.className = "lab-row";
|
||||||
|
row.style = "display: flex; gap: 0.5rem; margin-bottom: 0.5rem;";
|
||||||
|
row.innerHTML = `<input type="text" placeholder="Test Name" class="lab-test-name" style="flex: 1; padding: 0.6rem; border-radius: 8px; border: 1px solid var(--border);">`;
|
||||||
|
labList.appendChild(row);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// Voice AI Logic
|
// 4. Voice AI Simulation
|
||||||
startRecordBtn.onclick = () => {
|
if (startRecordBtn) {
|
||||||
startRecordBtn.classList.add("hidden");
|
startRecordBtn.onclick = () => {
|
||||||
recordingStatus.classList.remove("hidden");
|
startRecordBtn.classList.add("hidden");
|
||||||
|
recordingStatus.classList.remove("hidden");
|
||||||
|
setTimeout(() => {
|
||||||
|
recordingStatus.classList.add("hidden");
|
||||||
|
aiInsightsBox.classList.remove("hidden");
|
||||||
|
insightText.innerText = "Viral infection detected. Avoid cold drinks for 3 days. Follow-up in 1 week.";
|
||||||
|
document.getElementById("rxDiagnosis").value = "Viral Infection";
|
||||||
|
}, 2000);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// Simulate recording for 3 seconds
|
// 5. Sidebar Toggle
|
||||||
setTimeout(() => {
|
window.toggleSidebar = () => {
|
||||||
recordingStatus.classList.add("hidden");
|
const sidebar = document.getElementById('sidebar');
|
||||||
aiInsightsBox.classList.remove("hidden");
|
if (!sidebar) return;
|
||||||
|
if (sidebar.style.display === 'flex') {
|
||||||
// Mock data filtering simulation
|
sidebar.style.display = 'none';
|
||||||
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) {
|
|
||||||
} else {
|
} else {
|
||||||
sidebar.style.display = 'flex';
|
sidebar.style.display = 'flex';
|
||||||
sidebar.style.position = 'fixed';
|
sidebar.style.position = 'fixed';
|
||||||
sidebar.style.top = '50px';
|
sidebar.style.top = '50px';
|
||||||
sidebar.style.left = '0';
|
|
||||||
sidebar.style.width = '100%';
|
sidebar.style.width = '100%';
|
||||||
sidebar.style.height = 'calc(100vh - 50px)';
|
sidebar.style.height = 'calc(100vh - 50px)';
|
||||||
sidebar.style.zIndex = '999';
|
sidebar.style.zIndex = '999';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Role-Based UI Filtering (Run on Load)
|
// Close Modals
|
||||||
document.addEventListener("DOMContentLoaded", () => {
|
if (closeModal) closeModal.onclick = () => modal.style.display = "none";
|
||||||
const userRole = localStorage.getItem('userRole') || 'OWNER';
|
window.onclick = (e) => { if (e.target == modal) modal.style.display = "none"; };
|
||||||
const userEmail = localStorage.getItem('userEmail') || 'admin@curio.app';
|
|
||||||
|
|
||||||
const roleDisplay = document.querySelector(".user-profile .info strong");
|
|
||||||
const emailDisplay = document.querySelector(".user-profile .info span");
|
|
||||||
if (roleDisplay) roleDisplay.innerText = userRole.charAt(0) + userRole.slice(1).toLowerCase();
|
|
||||||
if (emailDisplay) emailDisplay.innerText = userEmail;
|
|
||||||
|
|
||||||
if (userRole === 'DOCTOR') {
|
|
||||||
document.querySelectorAll('.side-nav a').forEach(link => {
|
|
||||||
if (link.innerText.includes('Billing') || link.innerText.includes('Staff') || link.innerText.includes('Overview')) {
|
|
||||||
link.style.display = 'none';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
showSection('zen'); // Primary view for doctors
|
|
||||||
} else if (userRole === 'RECEPTIONIST') {
|
|
||||||
document.querySelectorAll('.side-nav a').forEach(link => {
|
|
||||||
if (link.innerText.includes('Lab') || link.innerText.includes('Staff')) {
|
|
||||||
link.style.display = 'none';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
showSection('overview');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue