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 id="overview-section">
|
||||
<div id="overview-section" class="hidden">
|
||||
<section class="stats-row">
|
||||
<div class="stat-card">
|
||||
<span>In Queue</span>
|
||||
|
|
@ -376,6 +376,6 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<script src="dashboard.js?v=2"></script>
|
||||
<script src="dashboard.js?v=3"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
271
dashboard.js
271
dashboard.js
|
|
@ -1,3 +1,4 @@
|
|||
// Core Modal & UI Elements
|
||||
const modal = document.getElementById("consultationModal");
|
||||
const addMedBtn = document.getElementById("addMed");
|
||||
const medList = document.getElementById("medicineList");
|
||||
|
|
@ -9,181 +10,143 @@ const aiInsightsBox = document.getElementById("aiInsights");
|
|||
const insightText = document.getElementById("insightText");
|
||||
const queueDateInput = document.getElementById("queueDate");
|
||||
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 addLabBtn = document.getElementById("addLabTest");
|
||||
|
||||
// Add new medicine row
|
||||
addMedBtn.onclick = () => {
|
||||
const row = document.createElement("div");
|
||||
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);
|
||||
};
|
||||
// 1. Initialize View on Load
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const userRole = localStorage.getItem('userRole') || 'OWNER';
|
||||
const userEmail = localStorage.getItem('userEmail') || 'admin@curio.app';
|
||||
|
||||
// Set Sidebar Profile
|
||||
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;
|
||||
|
||||
// Add new lab test row
|
||||
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 (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
|
||||
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,
|
||||
duration: row.querySelector(".med-duration").value
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (!diagnosis || meds.length === 0) {
|
||||
alert("Please enter diagnosis and at least one medicine.");
|
||||
return;
|
||||
// Apply Role-Based Filtering
|
||||
if (userRole === 'DOCTOR') {
|
||||
document.querySelectorAll('.side-nav a').forEach(link => {
|
||||
const text = link.innerText;
|
||||
if (text.includes('Billing') || text.includes('Staff') || text.includes('Overview')) {
|
||||
link.style.display = 'none';
|
||||
}
|
||||
});
|
||||
showSection('zen');
|
||||
} else if (userRole === 'RECEPTIONIST') {
|
||||
document.querySelectorAll('.side-nav a').forEach(link => {
|
||||
const text = link.innerText;
|
||||
if (text.includes('Lab') || text.includes('Staff')) {
|
||||
link.style.display = 'none';
|
||||
}
|
||||
});
|
||||
showSection('overview');
|
||||
} else {
|
||||
showSection('overview');
|
||||
}
|
||||
|
||||
// Simulate sending to backend
|
||||
console.log("Sending Rx:", { diagnosis, meds });
|
||||
// Set Default Date
|
||||
if (queueDateInput) {
|
||||
const today = new Date().toISOString().split('T')[0];
|
||||
queueDateInput.value = today;
|
||||
}
|
||||
});
|
||||
|
||||
// 2. Section Switching Logic
|
||||
window.showSection = (sectionId) => {
|
||||
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');
|
||||
});
|
||||
|
||||
// UI Feedback
|
||||
sendRxBtn.innerText = "Sent! ✅";
|
||||
sendRxBtn.style.background = "#10B981";
|
||||
|
||||
setTimeout(() => {
|
||||
modal.style.display = "none";
|
||||
sendRxBtn.innerText = "Send to WhatsApp";
|
||||
sendRxBtn.style.background = "";
|
||||
|
||||
const note = document.getElementById("deptNote").value;
|
||||
if (note) {
|
||||
console.log("Dept Note:", note);
|
||||
alert("Prescription sent. Note forwarded to Pharmacy/Lab.");
|
||||
if (sectionId === 'overview') {
|
||||
document.getElementById('overview-section').classList.remove('hidden');
|
||||
} else if (sectionId === 'zen') {
|
||||
document.getElementById('doctor-zen-section').classList.remove('hidden');
|
||||
} else if (sectionId === 'queue') {
|
||||
const role = localStorage.getItem('userRole');
|
||||
if (role === 'DOCTOR') {
|
||||
document.getElementById('doctor-zen-section').classList.remove('hidden');
|
||||
} 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) => {
|
||||
const tips = {
|
||||
diabetes: "🥗 Healthy Diet Tip: Reduce white rice, add more greens.",
|
||||
hypertension: "🧘 BP Control: Limit salt intake to 5g/day.",
|
||||
viral: "💧 Hydration: Drink 3L of warm water daily."
|
||||
// 3. Clinical Consultation Logic
|
||||
if (addMedBtn) {
|
||||
addMedBtn.onclick = () => {
|
||||
const row = document.createElement("div");
|
||||
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 = () => {
|
||||
alert("🖨️ Printing General Health Guidelines for this patient...");
|
||||
};
|
||||
if (addLabBtn) {
|
||||
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
|
||||
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) {
|
||||
// 4. Voice AI Simulation
|
||||
if (startRecordBtn) {
|
||||
startRecordBtn.onclick = () => {
|
||||
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);
|
||||
};
|
||||
}
|
||||
|
||||
// 5. Sidebar Toggle
|
||||
window.toggleSidebar = () => {
|
||||
const sidebar = document.getElementById('sidebar');
|
||||
if (!sidebar) return;
|
||||
if (sidebar.style.display === 'flex') {
|
||||
sidebar.style.display = 'none';
|
||||
} else {
|
||||
sidebar.style.display = 'flex';
|
||||
sidebar.style.position = 'fixed';
|
||||
sidebar.style.top = '50px';
|
||||
sidebar.style.left = '0';
|
||||
sidebar.style.width = '100%';
|
||||
sidebar.style.height = 'calc(100vh - 50px)';
|
||||
sidebar.style.zIndex = '999';
|
||||
}
|
||||
};
|
||||
|
||||
// Role-Based UI Filtering (Run on Load)
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const userRole = localStorage.getItem('userRole') || 'OWNER';
|
||||
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');
|
||||
}
|
||||
});
|
||||
// Close Modals
|
||||
if (closeModal) closeModal.onclick = () => modal.style.display = "none";
|
||||
window.onclick = (e) => { if (e.target == modal) modal.style.display = "none"; };
|
||||
|
|
|
|||
Loading…
Reference in New Issue