Certainly! Enhancing your Doctor's Dashboard can significantly improve user experience, usability, and overall aesthetics. Below are several improvements and an updated version of your HTML, CSS, and JavaScript to create a more modern, responsive, and user-friendly dashboard.
Key Enhancements:
-
Modern Design with CSS Flexbox and Grid:
- Utilize CSS Flexbox and Grid for a more responsive and flexible layout.
-
Improved Visual Hierarchy:
- Use color schemes, spacing, and typography to create a clear visual hierarchy.
-
Enhanced Navigation:
- Implement a more intuitive sidebar with icons and tooltips.
-
Interactive Elements:
- Add transitions and hover effects to buttons and cards for better interactivity.
-
Accessibility:
- Ensure that the dashboard is accessible by using appropriate ARIA labels and ensuring sufficient color contrast.
-
Optimized Modals:
- Improve modal designs for better user interaction and clarity.
-
Consistent Styling:
- Ensure consistent padding, margins, and font sizes across components.
Updated Code:
Below is the revamped version of your Doctor's Dashboard with the aforementioned enhancements.
1. HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>AfyaChain: Doctor's Dashboard</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Font Awesome for icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;700&display=swap" rel="stylesheet">
<!-- Custom Stylesheet -->
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="container">
<!-- Header -->
<header>
<div class="logo">
<i class="fas fa-heartbeat"></i> AfyaChain
</div>
<nav>
<ul>
<li><a href="#home"><i class="fas fa-home"></i> Home</a></li>
<li><a href="#about"><i class="fas fa-info-circle"></i> About</a></li>
<li><a href="#contact"><i class="fas fa-envelope"></i> Contact</a></li>
</ul>
</nav>
</header>
<!-- Main Content -->
<main>
<!-- Sidebar -->
<aside class="sidebar">
<h2><i class="fas fa-history"></i> Patient History</h2>
<p>View recent medical history summaries.</p>
<button id="viewAllHistory" class="btn btn-primary">View All History</button>
</aside>
<!-- Content Area -->
<section class="content">
<!-- Dashboard Header -->
<div class="dashboard-header">
<div>
<h1>Doctor's Dashboard</h1>
<p>Welcome, Dr. James</p>
</div>
<button id="logout" class="btn btn-secondary"><i class="fas fa-sign-out-alt"></i> Logout</button>
</div>
<!-- Search Bar -->
<div class="search-bar">
<select id="patientSelect" aria-label="Select a patient">
<option value="">Select a patient</option>
<option value="seth">Seth Johnson</option>
<option value="vin">Vin Diesel</option>
<option value="ray">Ray Charles</option>
</select>
</div>
<!-- Patient Information -->
<div id="patientInfo" class="hidden"></div>
<!-- OTP Verification -->
<div id="otpVerification" class="hidden">
<button id="sendOTP" class="btn btn-primary"><i class="fas fa-paper-plane"></i> Send OTP</button>
<div id="otpInputArea" class="hidden">
<input type="text" id="otpInput" placeholder="Enter OTP" aria-label="Enter OTP">
<button id="verifyOTP" class="btn btn-success"><i class="fas fa-check"></i> Verify OTP</button>
</div>
</div>
<!-- Medical Information -->
<div id="medicalInfo" class="hidden"></div>
</section>
</main>
<!-- Footer -->
<footer>
<div class="footer-content">
<div class="logo">
<i class="fas fa-heartbeat"></i> AfyaChain
</div>
<p>© 2023 AfyaChain. All rights reserved.</p>
<nav>
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav>
</div>
</footer>
</div>
<!-- History Modal -->
<div id="historyModal" class="modal" aria-hidden="true">
<div class="modal-content" role="dialog" aria-labelledby="historyModalTitle">
<span class="close" aria-label="Close">×</span>
<h2 id="historyModalTitle">Full Medical History</h2>
<div id="fullHistory"></div>
</div>
</div>
<!-- Diagnosis Modal -->
<div id="diagnosisModal" class="modal" aria-hidden="true">
<div class="modal-content" role="dialog" aria-labelledby="diagnosisModalTitle">
<span class="close" aria-label="Close">×</span>
<h2 id="diagnosisModalTitle">New Diagnosis</h2>
<form id="diagnosisForm">
<label for="diagnosisDate">Date:</label>
<input type="date" id="diagnosisDate" name="diagnosisDate" required>
<label for="chiefComplaint">Chief Complaint:</label>
<input type="text" id="chiefComplaint" name="chiefComplaint" required>
<label for="symptoms">Symptoms:</label>
<textarea id="symptoms" name="symptoms" rows="3" required></textarea>
<label for="diagnosis">Diagnosis:</label>
<input type="text" id="diagnosis" name="diagnosis" required>
<label for="treatment">Treatment Plan:</label>
<textarea id="treatment" name="treatment" rows="3" required></textarea>
<label for="medications">Medications:</label>
<textarea id="medications" name="medications" rows="2"></textarea>
<label for="labTests">Lab Tests:</label>
<input type="text" id="labTests" name="labTests">
<label for="followUp">Follow-up Date:</label>
<input type="date" id="followUp" name="followUp">
<button type="submit" class="btn btn-primary"><i class="fas fa-paper-plane"></i> Submit Diagnosis</button>
</form>
</div>
</div>
<!-- JavaScript -->
<script src="script.js"></script>
</body>
</html>
2. CSS (styles.css)
/* Root Variables */
:root {
--primary-color: #007bff;
--secondary-color: #6c757d;
--background-color: #f8f9fa;
--text-color: #333;
--card-shadow: rgba(0, 0, 0, 0.1);
--modal-background: rgba(0, 0, 0, 0.5);
--font-family: 'Roboto', sans-serif;
}
/* Reset and Base Styles */
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: var(--font-family);
line-height: 1.6;
color: var(--text-color);
background-color: var(--background-color);
min-height: 100vh;
display: flex;
flex-direction: column;
}
a {
color: inherit;
text-decoration: none;
}
/* Container */
.container {
display: flex;
flex-direction: column;
flex: 1;
}
/* Header */
header {
background-color: var(--primary-color);
color: white;
padding: 1rem 2rem;
display: flex;
align-items: center;
justify-content: space-between;
}
.logo {
display: flex;
align-items: center;
font-size: 1.5rem;
font-weight: bold;
}
.logo i {
margin-right: 0.5rem;
}
nav ul {
display: flex;
list-style: none;
}
nav ul li {
margin-left: 1.5rem;
}
nav ul li a {
color: white;
font-size: 1rem;
transition: color 0.3s ease;
}
nav ul li a:hover {
color: #d4d4d4;
}
/* Main Content */
main {
display: flex;
flex: 1;
}
/* Sidebar */
.sidebar {
width: 250px;
background-color: #ffffff;
border-right: 1px solid #eaeaea;
padding: 2rem 1.5rem;
display: flex;
flex-direction: column;
justify-content: flex-start;
}
.sidebar h2 {
font-size: 1.2rem;
margin-bottom: 1rem;
color: var(--primary-color);
}
.sidebar p {
flex: 1;
margin-bottom: 1.5rem;
color: var(--secondary-color);
}
.sidebar .btn {
width: 100%;
}
/* Content Area */
.content {
flex: 1;
padding: 2rem;
background-color: #f8f9fa;
overflow-y: auto;
}
.dashboard-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 2rem;
}
.dashboard-header h1 {
font-size: 2rem;
}
.dashboard-header p {
color: var(--secondary-color);
}
.search-bar {
margin-bottom: 2rem;
}
.search-bar select {
width: 100%;
padding: 0.75rem 1rem;
border: 1px solid var(--secondary-color);
border-radius: 5px;
font-size: 1rem;
appearance: none;
background: url('data:image/svg+xml;charset=US-ASCII,<svg xmlns="http://www.w3.org/2000/svg" width="14" height="10"><path fill="%236c757d" d="M7 10L0 0h14z"/></svg>') no-repeat right 1rem center;
background-size: 14px 10px;
cursor: pointer;
}
.hidden {
display: none;
}
.patient-card {
background-color: #ffffff;
border-radius: 10px;
box-shadow: 0 4px 12px var(--card-shadow);
padding: 1.5rem;
display: flex;
align-items: center;
margin-bottom: 2rem;
transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.patient-card:hover {
transform: translateY(-5px);
box-shadow: 0 6px 16px var(--card-shadow);
}
.patient-photo {
width: 120px;
height: 120px;
border-radius: 50%;
object-fit: cover;
margin-right: 1.5rem;
border: 3px solid var(--primary-color);
}
.patient-info h2 {
font-size: 1.5rem;
margin-bottom: 0.5rem;
}
.patient-info p {
color: var(--secondary-color);
margin-bottom: 1rem;
}
.patient-info .btn {
padding: 0.5rem 1rem;
}
/* Medical Info Cards */
.medical-info-cards {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 1.5rem;
margin-bottom: 2rem;
}
.medical-info-card {
background-color: #ffffff;
border-radius: 10px;
box-shadow: 0 2px 8px var(--card-shadow);
padding: 1.5rem;
transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.medical-info-card:hover {
transform: translateY(-3px);
box-shadow: 0 4px 12px var(--card-shadow);
}
.medical-info-card h3 {
margin-bottom: 0.5rem;
color: var(--primary-color);
}
.medical-info-card p {
color: var(--secondary-color);
}
/* Medical History */
.medical-history {
background-color: #ffffff;
border-radius: 10px;
box-shadow: 0 2px 8px var(--card-shadow);
padding: 1.5rem;
}
.medical-history h3 {
margin-bottom: 1rem;
color: var(--primary-color);
}
.medical-history div {
margin-bottom: 1rem;
}
.medical-history h4 {
font-size: 1.1rem;
color: var(--secondary-color);
margin-bottom: 0.3rem;
}
.medical-history p {
margin-left: 1rem;
color: var(--text-color);
}
/* Buttons */
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
padding: 0.6rem 1.2rem;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 1rem;
transition: background-color 0.3s ease, transform 0.3s ease;
}
.btn-primary {
background-color: var(--primary-color);
color: white;
}
.btn-primary:hover {
background-color: darken(var(--primary-color), 10%);
}
.btn-secondary {
background-color: var(--secondary-color);
color: white;
}
.btn-secondary:hover {
background-color: darken(var(--secondary-color), 10%);
}
.btn-success {
background-color: #28a745;
color: white;
}
.btn-success:hover {
background-color: #218838;
}
.btn i {
margin-right: 0.5rem;
}
/* Modals */
.modal {
display: none;
position: fixed;
z-index: 1000;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: var(--modal-background);
transition: opacity 0.3s ease;
}
.modal-content {
background-color: #fefefe;
margin: 5% auto;
padding: 2rem;
border-radius: 10px;
width: 90%;
max-width: 600px;
position: relative;
box-shadow: 0 5px 15px var(--card-shadow);
animation: slideDown 0.3s ease;
}
@keyframes slideDown {
from { transform: translateY(-50px); opacity: 0; }
to { transform: translateY(0); opacity: 1; }
}
.close {
color: #aaa;
position: absolute;
top: 1rem;
right: 1.5rem;
font-size: 1.5rem;
font-weight: bold;
cursor: pointer;
transition: color 0.3s ease;
}
.close:hover {
color: #000;
}
.modal-content h2 {
margin-bottom: 1.5rem;
color: var(--primary-color);
}
/* Form Styles */
.modal-content form {
display: flex;
flex-direction: column;
}
.modal-content form label {
margin-bottom: 0.5rem;
font-weight: 500;
}
.modal-content form input,
.modal-content form textarea {
padding: 0.75rem 1rem;
margin-bottom: 1rem;
border: 1px solid #ced4da;
border-radius: 5px;
font-size: 1rem;
resize: vertical;
}
.modal-content form button[type="submit"] {
align-self: flex-end;
padding: 0.6rem 1.2rem;
}
/* Footer */
footer {
background-color: var(--primary-color);
color: white;
padding: 1.5rem 2rem;
}
.footer-content {
display: flex;
justify-content: space-between;
align-items: center;
flex-wrap: wrap;
}
.footer-content .logo {
font-size: 1.2rem;
}
.footer-content p {
margin: 0.5rem 0;
}
.footer-content nav ul {
display: flex;
list-style: none;
}
.footer-content nav ul li {
margin-left: 1.5rem;
}
.footer-content nav ul li a {
color: white;
font-size: 1rem;
transition: color 0.3s ease;
}
.footer-content nav ul li a:hover {
color: #d4d4d4;
}
/* Responsive Styles */
@media (max-width: 992px) {
main {
flex-direction: column;
}
.sidebar {
width: 100%;
border-right: none;
border-bottom: 1px solid #eaeaea;
}
}
@media (max-width: 576px) {
.dashboard-header {
flex-direction: column;
align-items: flex-start;
}
.dashboard-header button {
margin-top: 1rem;
width: 100%;
}
.modal-content {
padding: 1rem;
}
.close {
top: 0.5rem;
right: 1rem;
}
}
3. JavaScript (script.js)
// Patients Data
const patients = {
seth: {
name: "Seth Johnson",
photo: "https://randomuser.me/api/portraits/men/1.jpg",
age: 35,
height: 180,
weight: 75,
bloodType: "A+",
allergies: ["Peanuts", "Penicillin"],
medicalHistory: [
{ date: "2023-05-01", diagnosis: "Common Cold", treatment: "Rest and fluids" },
{ date: "2023-03-15", diagnosis: "Sprained Ankle", treatment: "RICE method" },
{ date: "2022-11-20", diagnosis: "Bronchitis", treatment: "Antibiotics and inhaler" }
]
},
vin: {
name: "Vin Diesel",
photo: "https://randomuser.me/api/portraits/men/2.jpg",
age: 45,
height: 182,
weight: 85,
bloodType: "O-",
allergies: ["Shellfish"],
medicalHistory: [
{ date: "2023-04-10", diagnosis: "Hypertension", treatment: "Prescribed ACE inhibitors" },
{ date: "2022-09-05", diagnosis: "Lower back pain", treatment: "Physical therapy" }
]
},
ray: {
name: "Ray Charles",
photo: "https://randomuser.me/api/portraits/men/3.jpg",
age: 55,
height: 175,
weight: 70,
bloodType: "B+",
allergies: ["Latex"],
medicalHistory: [
{ date: "2023-02-20", diagnosis: "Type 2 Diabetes", treatment: "Metformin and lifestyle changes" },
{ date: "2022-07-15", diagnosis: "Cataracts", treatment: "Scheduled for surgery" }
]
}
};
// DOM Elements
const patientSelect = document.getElementById("patientSelect");
const patientInfo = document.getElementById("patientInfo");
const otpVerification = document.getElementById("otpVerification");
const sendOTPBtn = document.getElementById("sendOTP");
const otpInputArea = document.getElementById("otpInputArea");
const verifyOTPBtn = document.getElementById("verifyOTP");
const medicalInfo = document.getElementById("medicalInfo");
const viewAllHistory = document.getElementById("viewAllHistory");
const historyModal = document.getElementById("historyModal");
const fullHistory = document.getElementById("fullHistory");
const closeHistoryModal = historyModal.querySelector(".close");
const logoutBtn = document.getElementById("logout");
const diagnosisModal = document.getElementById("diagnosisModal");
const diagnosisForm = document.getElementById("diagnosisForm");
const closeDiagnosisModal = diagnosisModal.querySelector(".close");
let currentPatient = null;
let otpSent = false;
// Event Listeners
patientSelect.addEventListener("change", handlePatientSelect);
sendOTPBtn.addEventListener("click", handleSendOTP);
verifyOTPBtn.addEventListener("click", handleVerifyOTP);
viewAllHistory.addEventListener("click", handleViewAllHistory);
closeHistoryModal.addEventListener("click", () => toggleModal(historyModal, false));
closeDiagnosisModal.addEventListener("click", () => toggleModal(diagnosisModal, false));
logoutBtn.addEventListener("click", handleLogout);
diagnosisForm.addEventListener("submit", handleDiagnosisSubmit);
window.addEventListener("click", handleWindowClick);
// Functions
function handlePatientSelect() {
const selectedPatient = patientSelect.value;
if (selectedPatient) {
currentPatient = patients[selectedPatient];
displayPatientInfo(currentPatient);
} else {
resetView();
}
}
function displayPatientInfo(patient) {
patientInfo.innerHTML = `
<div class="patient-card">
<img src="${patient.photo}" alt="${patient.name}" class="patient-photo">
<div class="patient-info">
<h2>${patient.name}</h2>
<p>Age: ${patient.age}</p>
<button id="addDiagnosisBtn" class="btn btn-primary"><i class="fas fa-plus"></i> Add New Diagnosis</button>
</div>
</div>
`;
patientInfo.classList.remove("hidden");
otpVerification.classList.remove("hidden");
medicalInfo.classList.add("hidden");
otpInputArea.classList.add("hidden");
otpSent = false;
const addDiagnosisBtn = document.getElementById("addDiagnosisBtn");
addDiagnosisBtn.addEventListener("click", () => {
if (otpSent) {
toggleModal(diagnosisModal, true);
} else {
alert("Please verify OTP to add a new diagnosis.");
}
});
}
function resetView() {
patientInfo.classList.add("hidden");
otpVerification.classList.add("hidden");
medicalInfo.classList.add("hidden");
currentPatient = null;
}
function handleSendOTP() {
if (!currentPatient) {
alert("Please select a patient first.");
return;
}
const otp = Math.floor(1000 + Math.random() * 9000);
// Simulate sending OTP (In real application, integrate with SMS/Email service)
alert(`OTP sent to patient: ${otp}`);
otpInputArea.classList.remove("hidden");
otpSent = true;
}
function handleVerifyOTP() {
if (otpSent) {
displayMedicalInfo(currentPatient);
toggleModal(otpInputArea, false); // Hide OTP input area after verification
} else {
alert("Please send OTP first.");
}
}
function displayMedicalInfo(patient) {
medicalInfo.innerHTML = `
<div class="medical-info-cards">
<div class="medical-info-card">
<h3>Height</h3>
<p>${patient.height} cm</p>
</div>
<div class="medical-info-card">
<h3>Weight</h3>
<p>${patient.weight} kg</p>
</div>
<div class="medical-info-card">
<h3>Blood Type</h3>
<p>${patient.bloodType}</p>
</div>
<div class="medical-info-card">
<h3>Allergies</h3>
<p>${patient.allergies.join(", ")}</p>
</div>
</div>
<div class="medical-history">
<h3>Recent Medical History</h3>
${patient.medicalHistory.slice(0, 2).map(record => `
<div>
<h4>${record.date}</h4>
<p>Diagnosis: ${record.diagnosis}</p>
<p>Treatment: ${record.treatment}</p>
</div>
`).join("")}
</div>
`;
medicalInfo.classList.remove("hidden");
otpVerification.classList.add("hidden");
}
function handleViewAllHistory() {
if (currentPatient && otpSent) {
fullHistory.innerHTML = currentPatient.medicalHistory.map(record => `
<div>
<h3>Date: ${record.date}</h3>
<p>Diagnosis: ${record.diagnosis}</p>
<p>Treatment: ${record.treatment}</p>
</div>
`).join("");
toggleModal(historyModal, true);
} else if (!currentPatient) {
alert("Please select a patient first.");
} else {
alert("Please verify OTP to access full medical records.");
}
}
function handleLogout() {
if (confirm("Are you sure you want to logout?")) {
alert("Logged out successfully.");
// Redirect to login page (ensure login.html exists)
window.location.href = "login.html";
}
}
function handleDiagnosisSubmit(e) {
e.preventDefault();
const formData = new FormData(diagnosisForm);
const newDiagnosis = {
date: formData.get("diagnosisDate"),
diagnosis: formData.get("diagnosis"),
treatment: formData.get("treatment")
};
currentPatient.medicalHistory.unshift(newDiagnosis);
alert("New diagnosis added successfully!");
diagnosisForm.reset();
toggleModal(diagnosisModal, false);
displayMedicalInfo(currentPatient);
}
function toggleModal(modal, show) {
if (show) {
modal.style.display = "block";
modal.setAttribute("aria-hidden", "false");
} else {
modal.style.display = "none";
modal.setAttribute("aria-hidden", "true");
}
}
function handleWindowClick(event) {
if (event.target === historyModal || event.target === diagnosisModal) {
toggleModal(historyModal, false);
toggleModal(diagnosisModal, false);
}
}
Explanation of Enhancements:
-
Separation of Concerns:
- The HTML, CSS, and JavaScript are separated into different files (
index.html, styles.css, and script.js) for better maintainability.
-
Improved Layout:
- The sidebar and content areas are more clearly defined and styled for better readability.
- Utilized CSS Grid in
.medical-info-cards for a responsive layout of medical info cards.
-
Responsive Design:
- Media queries ensure that the dashboard looks good on various screen sizes, including tablets and mobile devices.
-
Enhanced Aesthetics:
- Added hover effects and transitions to buttons and cards to create a more interactive experience.
- Consistent use of colors and spacing to ensure a cohesive look.
-
Accessibility:
- Added
aria-label and aria-hidden attributes to improve screen reader compatibility.
- Ensured sufficient color contrast for better readability.
-
User Feedback:
- Confirmation prompts for actions like logging out.
- Alerts notify the user about OTP actions and successful submissions.
-
Modal Improvements:
- Smooth animations for modals to make interactions feel more natural.
- Clear close buttons with accessible labels.
-
Form Enhancements:
- Improved form layout with better spacing and input styles for the diagnosis submission.
-
Iconography:
- Utilized Font Awesome icons to visually represent actions, making the interface more intuitive.
-
Code Optimization:
- Cleaned up CSS by using CSS variables and organized selectors for better readability.
- Optimized JavaScript by abstracting repetitive tasks like modal toggling.
Additional Recommendations:
-
Backend Integration:
- Currently, the dashboard uses static data. Integrate with a backend service or API to fetch and update real patient data dynamically.
-
Authentication:
- Implement secure authentication to ensure that only authorized users can access the dashboard.
-
State Management:
- Use state management libraries or frameworks (like React, Vue, or Angular) for more complex applications to manage the UI state efficiently.
-
Form Validation:
- Enhance form validation to ensure that all necessary fields are correctly filled out before submission.
-
Notifications:
- Implement a notification system for real-time updates, such as new diagnoses or messages.
-
Dark Mode:
- Offer a dark mode option to enhance user comfort during nighttime usage.
-
Performance Optimization:
- Minimize the use of large images and optimize assets to ensure fast loading times.
-
Testing:
- Implement thorough testing (unit, integration, and end-to-end) to ensure the reliability of the dashboard.
Conclusion
The updated dashboard provides a more modern, responsive, and user-friendly interface for doctors to manage patient information effectively. By following best practices in web development and focusing on user experience, the dashboard becomes a powerful tool for healthcare professionals.
If you have any specific features or further customizations in mind, feel free to ask!