-- Host: 127.0.0.1:3306
-- Generation Time: Oct 19, 2024 at 08:09 AM
-- Server version: 10.11.9-MariaDB
-- PHP Version: 7.2.34
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT /;
/!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS /;
/!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION /;
/!40101 SET NAMES utf8mb4 */;
--
-- Database: u406552082_info
--
-- Table structure for table admins
CREATE TABLE admins (
id int(11) NOT NULL,
username varchar(50) NOT NULL,
password varchar(255) NOT NULL,
email varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table appointments
CREATE TABLE appointments (
id int(11) NOT NULL,
package_id int(11) NOT NULL,
appointment_date datetime NOT NULL,
proposed_appointment_date datetime DEFAULT NULL,
name varchar(255) NOT NULL,
email varchar(255) NOT NULL,
phone varchar(20) NOT NULL,
age int(3) DEFAULT NULL,
gender enum('Male','Female','Other') DEFAULT NULL,
address varchar(255) DEFAULT NULL,
preferred_contact_method enum('Email','Phone','WhatsApp') DEFAULT NULL,
additional_notes text DEFAULT NULL,
admin_notes text DEFAULT NULL,
status enum('Pending','Confirmed','Completed','Cancelled') DEFAULT 'Pending',
created_at timestamp NULL DEFAULT current_timestamp(),
patient_id int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table budgets
CREATE TABLE budgets (
id int(11) NOT NULL,
month varchar(7) DEFAULT NULL,
budgeted_revenue decimal(10,2) DEFAULT NULL,
budgeted_expenses decimal(10,2) DEFAULT NULL,
notes text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table
Assistant
comments
CREATE TABLE comments (
id int(11) NOT NULL,
patient_id int(11) NOT NULL,
sender enum('patient','doctor','admin') NOT NULL,
message text NOT NULL,
timestamp datetime DEFAULT current_timestamp(),
parent_id int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table doctors
CREATE TABLE doctors (
id int(11) NOT NULL,
employee_id int(11) NOT NULL,
name varchar(255) NOT NULL,
username varchar(100) NOT NULL,
password varchar(255) NOT NULL,
email varchar(255) NOT NULL,
specialization varchar(255) DEFAULT NULL,
phone varchar(20) DEFAULT NULL,
registration_date date DEFAULT curdate(),
profile_picture varchar(255) DEFAULT NULL,
department varchar(100) DEFAULT NULL,
date_of_joining date DEFAULT NULL,
status enum('active','inactive') DEFAULT 'active'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table doctor_patient
CREATE TABLE doctor_patient (
id int(11) NOT NULL,
doctor_id int(11) NOT NULL,
patient_id int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table employees
CREATE TABLE employees (
id int(11) NOT NULL,
name varchar(255) NOT NULL,
role enum('admin','doctor','staff','accountant') NOT NULL,
email varchar(255) NOT NULL,
phone varchar(20) DEFAULT NULL,
department varchar(100) DEFAULT NULL,
date_of_joining date DEFAULT NULL,
status enum('active','inactive') DEFAULT 'active',
username varchar(100) NOT NULL,
password varchar(255) NOT NULL,
created_at timestamp NULL DEFAULT current_timestamp(),
updated_at timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
profile_picture varchar(255) DEFAULT NULL,
specialization varchar(255) DEFAULT NULL,
is_online tinyint(1) DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table expenses
CREATE TABLE expenses (
id int(11) NOT NULL,
expense_date date NOT NULL,
category varchar(100) NOT NULL,
description varchar(255) DEFAULT NULL,
amount decimal(10,2) NOT NULL,
created_at timestamp NULL DEFAULT current_timestamp(),
updated_at timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table health_records
CREATE TABLE health_records (
id int(11) NOT NULL,
patient_id int(11) NOT NULL,
blood_pressure varchar(20) DEFAULT NULL,
weight decimal(5,2) DEFAULT NULL,
bmi decimal(4,2) DEFAULT NULL,
cholesterol decimal(5,2) DEFAULT NULL,
prescription text DEFAULT NULL,
treatment_progress text DEFAULT NULL,
record_date date NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table insurance_claims
CREATE TABLE insurance_claims (
id int(11) NOT NULL,
patient_id int(11) DEFAULT NULL,
invoice_id int(11) DEFAULT NULL,
claim_amount decimal(10,2) DEFAULT NULL,
status enum('Pending','Approved','Rejected') DEFAULT NULL,
submission_date date DEFAULT NULL,
processing_date date DEFAULT NULL,
notes text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table invoices
CREATE TABLE invoices (
id int(11) NOT NULL,
patient_id int(11) NOT NULL,
service_name varchar(255) NOT NULL,
service_description text DEFAULT NULL,
cost decimal(10,2) NOT NULL,
tax_rate decimal(5,2) DEFAULT 0.00,
discount decimal(5,2) DEFAULT 0.00,
total_amount decimal(10,2) NOT NULL,
invoice_date date DEFAULT curdate(),
due_date date DEFAULT NULL,
notes text DEFAULT NULL,
tax decimal(5,2) DEFAULT 0.00
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table invoice_services
CREATE TABLE invoice_services (
id int(11) NOT NULL,
invoice_id int(11) NOT NULL,
service_id int(11) NOT NULL,
service_name varchar(255) NOT NULL,
cost decimal(10,2) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table packages
CREATE TABLE packages (
id int(11) NOT NULL,
package_name varchar(255) NOT NULL,
description text DEFAULT NULL,
details text DEFAULT NULL,
created_at timestamp NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table patients
CREATE TABLE patients (
id int(11) NOT NULL,
name varchar(100) NOT NULL,
age int(3) DEFAULT NULL,
gender enum('Male','Female','Other') DEFAULT NULL,
phone varchar(20) DEFAULT NULL,
email varchar(100) DEFAULT NULL,
medical_history text DEFAULT NULL,
created_at timestamp NULL DEFAULT current_timestamp(),
updated_at timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
date_of_birth date DEFAULT NULL,
registration_datetime datetime DEFAULT current_timestamp(),
registration_date date DEFAULT NULL,
status enum('Initial Consultation','Diagnostic Phase','Treatment in Progress','Improving','Monitoring','Maintenance Phase','Awaiting Test Results','Follow-up Needed','Paused','Completed Program','Relapsed','Discontinued','Inactive') DEFAULT 'Initial Consultation',
doctor_id int(11) DEFAULT NULL,
address varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table patient_basic_info
CREATE TABLE patient_basic_info (
patient_id int(11) NOT NULL,
gender enum('Male','Female','Other') NOT NULL,
age int(3) NOT NULL,
weight decimal(5,2) NOT NULL,
height decimal(5,2) NOT NULL,
address varchar(255) DEFAULT NULL,
name varchar(100) NOT NULL,
email varchar(100) NOT NULL,
phone varchar(20) NOT NULL,
created_at timestamp NULL DEFAULT current_timestamp(),
updated_at timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table patient_consent
CREATE TABLE patient_consent (
patient_id int(11) NOT NULL,
consent enum('accepted','declined') NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table patient_consultation
CREATE TABLE patient_consultation (
patient_id int(11) NOT NULL,
scheduled_at datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table patient_goals
CREATE TABLE patient_goals (
patient_id int(11) NOT NULL,
primary_health_goals text NOT NULL,
health_concerns text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table patient_health_metrics
CREATE TABLE patient_health_metrics (
patient_id int(11) NOT NULL,
exercise_frequency enum('Daily','Weekly','Rarely','Never') NOT NULL,
diet enum('Yes','No') NOT NULL,
diet_specify varchar(255) DEFAULT NULL,
sleep_average enum('<5 Hours','5-7 Hours','7-9 Hours','>9 Hours') NOT NULL,
smoking_status enum('Yes','No','Occasionally') NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table patient_logins
CREATE TABLE patient_logins (
id int(11) NOT NULL,
patient_id int(11) NOT NULL,
username varchar(50) NOT NULL,
password varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table patient_medical_history
CREATE TABLE patient_medical_history (
patient_id int(11) NOT NULL,
chronic_conditions enum('Yes','No') NOT NULL,
chronic_conditions_specify varchar(255) DEFAULT NULL,
medications enum('Yes','No') NOT NULL,
medications_list text DEFAULT NULL,
major_surgeries enum('Yes','No') NOT NULL,
major_surgeries_specify varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table payments
CREATE TABLE payments (
id int(11) NOT NULL,
patient_id int(11) NOT NULL,
invoice_id int(11) NOT NULL,
amount_paid decimal(10,2) NOT NULL,
payment_date date NOT NULL,
payment_method varchar(50) DEFAULT NULL,
notes text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table prescriptions
CREATE TABLE prescriptions (
id int(11) NOT NULL,
patient_id int(11) NOT NULL,
doctor_id int(11) DEFAULT NULL,
medications text NOT NULL,
instructions text DEFAULT NULL,
date_prescribed datetime DEFAULT current_timestamp(),
status enum('active','inactive') DEFAULT 'active'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table questionnaire_responses
CREATE TABLE questionnaire_responses (
id int(11) NOT NULL,
session_id varchar(255) NOT NULL,
page_number int(2) NOT NULL,
question varchar(255) NOT NULL,
answer text NOT NULL,
submitted_at timestamp NULL DEFAULT current_timestamp(),
consent enum('Yes','No') DEFAULT 'No'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
--
-- Table structure for table salaries
CREATE TABLE salaries (
id int(11) NOT NULL,
employee_id int(11) NOT NULL,
basic_salary decimal(10,2) NOT NULL,
bonuses decimal(10,2) DEFAULT 0.00,
deductions decimal(10,2) DEFAULT 0.00,
overtime_hours int(11) DEFAULT 0,
overtime_rate decimal(10,2) DEFAULT 0.00,
tax decimal(10,2) DEFAULT 0.00,
payment_date date NOT NULL,
net_salary decimal(10,2) NOT NULL,
status enum('Pending','Paid') DEFAULT 'Pending',
notes text DEFAULT NULL,
payslip_path varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Table structure for table services
CREATE TABLE services (
service_id int(11) NOT NULL,
service_name varchar(255) NOT NULL,
service_price decimal(10,2) NOT NULL,
service_description text DEFAULT NULL,
created_at timestamp NULL DEFAULT current_timestamp(),
updated_at timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
ALTER TABLE invoice_services
ADD CONSTRAINT invoice_services_ibfk_1 FOREIGN KEY (invoice_id) REFERENCES invoices (id) ON DELETE CASCADE,
ADD CONSTRAINT invoice_services_ibfk_2 FOREIGN KEY (service_id) REFERENCES services (service_id) ON DELETE CASCADE;
--
-- Constraints for table patients
ALTER TABLE patients
ADD CONSTRAINT patients_ibfk_1 FOREIGN KEY (doctor_id) REFERENCES doctors (id) ON DELETE SET NULL ON UPDATE CASCADE;
--
-- Constraints for table patient_basic_info
ALTER TABLE patient_basic_info
ADD CONSTRAINT fk_patient_basic_info_patient FOREIGN KEY (patient_id) REFERENCES patients (id) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Constraints for table patient_logins
ALTER TABLE patient_logins
ADD CONSTRAINT patient_logins_ibfk_1 FOREIGN KEY (patient_id) REFERENCES patients (id) ON DELETE CASCADE;
--
-- Constraints for table payments
ALTER TABLE payments
ADD CONSTRAINT payments_ibfk_1 FOREIGN KEY (patient_id) REFERENCES patients (id) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT payments_ibfk_2 FOREIGN KEY (invoice_id) REFERENCES invoices (id) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Constraints for table prescriptions
ALTER TABLE prescriptions
ADD CONSTRAINT prescriptions_ibfk_1 FOREIGN KEY (patient_id) REFERENCES patients (id) ON DELETE CASCADE,
ADD CONSTRAINT prescriptions_ibfk_2 FOREIGN KEY (doctor_id) REFERENCES doctors (id) ON DELETE SET NULL;
--
-- Constraints for table salaries
ALTER TABLE salaries
ADD CONSTRAINT salaries_ibfk_1 FOREIGN KEY (employee_id) REFERENCES employees (id) ON DELETE CASCADE ON UPDATE CASCADE;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT /;
/!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS /;
/!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;) and this dasboard of doctor (<?php
// doctors/dashboard.php
// Enable error reporting for debugging (Disable in production)
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
session_start();
require_once '../db_connect.php'; // Ensure the path is correct
// Ensure the doctor is logged in
if (!isset(SESSION[′employeeid′])∣∣_SESSION['role'] !== 'doctor') {
header("Location: login.php");
exit();
}
employeeid=_SESSION['employee_id'];
// Fetch doctor information using the employee_id
stmt=pdo->prepare("SELECT * FROM doctors WHERE employee_id = ?");
stmt−>execute([employee_id]);
doctor=stmt->fetch();
if (!$doctor) {
// Invalid session or doctor not found
session_destroy();
header("Location: login.php");
exit();
}
// Get the doctor's id from the doctors table
doctorid=doctor['id'];
// Fetch patients assigned to the doctor
sql="SELECTp.∗,pl.username,hr.idAShealthrecordparams = ['doctor_id' => $doctor_id];
// Apply search filters
if (search) {
sql .= " AND (p.name LIKE :search OR pl.username LIKE :search OR p.phone LIKE :search OR p.email LIKE :search)";
params[′search′]="search%";
}
if (status_filter) {
sql .= " AND p.status = :status_filter";
params[′statusfilterstatus_filter;
}
if (start_date && end_date) {
sql.="ANDp.params['start_date'] = startdate.′00:00:00params['end_date'] = $end_date . ' 23:59:59';
}
// Order by registration time descending to have new patients at the top
$sql .= " ORDER BY reg_time DESC";
// Prepare and execute the query
stmt=pdo->prepare(sql);stmt->execute(params);patients = $stmt->fetchAll(PDO::FETCH_ASSOC);
// Fetch patient status distribution for the pie chart
statusstmt=pdo->prepare("
SELECT p.status, COUNT(*) as count
FROM patients p
JOIN doctor_patient dp ON p.id = dp.patient_id
WHERE dp.doctor_id = :doctor_id
GROUP BY p.status
");
statusstmt−>execute([′doctoridoctor_id]);
statusdata=status_stmt->fetchAll(PDO::FETCH_ASSOC);
// Fetch gender distribution for the bar chart
genderstmt=pdo->prepare("
SELECT p.gender, COUNT(*) as count
FROM patients p
JOIN doctor_patient dp ON p.id = dp.patient_id
WHERE dp.doctor_id = :doctor_id
GROUP BY p.gender
");
genderstmt−>execute([′doctoridoctor_id]);
genderdata=gender_stmt->fetchAll(PDO::FETCH_ASSOC);
// Fetch age data for the age distribution chart
agestmt=pdo->prepare("
SELECT p.age
FROM patients p
JOIN doctor_patient dp ON p.id = dp.patient_id
WHERE dp.doctor_id = :doctor_id
");
agestmt−>execute([′doctorid′=>doctor_id]);
agedata=age_stmt->fetchAll(PDO::FETCH_COLUMN);
Creating a comprehensive Notes Page for doctors to record and manage detailed notes about their patients involves several steps. This process includes updating the database, developing the backend and frontend of the notes page, integrating an advanced text editor for rich note-taking, and ensuring the interface is user-friendly and secure.
Below is a step-by-step guide to help you implement this feature effectively.
1. Database Update: Create medical_notes Table
First, you'll need to add a new table to your database to store medical notes. This table will link each note to a specific patient and the doctor who created it.
SQL Script to Create medical_notes Table
sql
-- --------------------------------------------------------
--
-- Table structure for table `medical_notes`
--
CREATE TABLE `medical_notes` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`patient_id` int(11) NOT NULL,
`doctor_id` int(11) NOT NULL,
`note` text NOT NULL,
`created_at` timestamp NULL DEFAULT current_timestamp(),
`updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
PRIMARY KEY (`id`),
KEY `patient_id` (`patient_id`),
KEY `doctor_id` (`doctor_id`),
CONSTRAINT `medical_notes_ibfk_1` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `medical_notes_ibfk_2` FOREIGN KEY (`doctor_id`) REFERENCES `doctors` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
Explanation:
Fields:
id: Unique identifier for each note.
patient_id: References the patient the note is about.
doctor_id: References the doctor who created the note.
note: The content of the medical note.
created_at: Timestamp when the note was created.
updated_at: Timestamp when the note was last updated.
Foreign Keys:
patient_id references the patients table.
doctor_id references the doctors table.
Execute the SQL Script
Run the above SQL script in your database management tool (e.g., phpMyAdmin) to create the medical_notes table.
2. Backend Development: Create notes.php Page
This PHP page will handle displaying existing notes, adding new notes, and editing or deleting existing notes.
This page will list all notes related to a specific patient and provide options to add new notes.
php
Explanation:
Session Validation: Ensures only logged-in doctors can access the page.
Patient Verification: Confirms the patient is assigned to the logged-in doctor.
Fetching Notes: Retrieves all medical notes related to the patient.
UI Design: Utilizes Bootstrap for a responsive and modern interface.
Actions: Provides options to add, edit, or delete notes. Only the doctor who created the note can edit or delete it.
Security: Escapes output to prevent XSS attacks. Further security measures should include prepared statements (already used) and proper session management.
2.2. Create add_note.php
This page allows doctors to add new medical notes using an advanced text editor.
php
Explanation:
Form Handling: Processes the form submission to insert a new medical note into the medical_notes table.
Advanced Text Editor: Utilizes TinyMCE for rich text editing, allowing formatting, embedding images, and more.
UI Design: Consistent with the dashboard's design for a seamless user experience.
Security: Ensures that only the assigned doctor can add notes for the patient.
2.3. Create edit_note.php
This page allows doctors to edit existing medical notes. Only the author of the note can edit it.
php
Explanation:
Ownership Verification: Ensures only the doctor who created the note can edit it.
Form Handling: Updates the existing note in the database.
Advanced Text Editor: Uses TinyMCE for a rich editing experience.
UI Design: Consistent with other pages for a seamless user experience.
2.4. Create delete_note.php
This script handles the deletion of medical notes. It ensures that only the author can delete their notes.
php
<?php
// doctors/delete_note.php
// Enable error reporting for debugging (Disable in production)
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
session_start();
require_once '../db_connect.php'; // Ensure the path is correct
// Ensure the doctor is logged in
if (!isset($_SESSION['employee_id']) || $_SESSION['role'] !== 'doctor') {
header("Location: login.php");
exit();
}
$employee_id = $_SESSION['employee_id'];
// Fetch doctor information using the employee_id
$stmt = $pdo->prepare("SELECT * FROM doctors WHERE employee_id = ?");
$stmt->execute([$employee_id]);
$doctor = $stmt->fetch();
if (!$doctor) {
// Invalid session or doctor not found
session_destroy();
header("Location: login.php");
exit();
}
$doctor_id = $doctor['id'];
// Get note ID from GET request
if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
echo "Invalid note ID.";
exit();
}
$note_id = (int)$_GET['id'];
// Fetch the note and verify ownership
$note_stmt = $pdo->prepare("SELECT * FROM medical_notes WHERE id = ?");
$note_stmt->execute([$note_id]);
$note = $note_stmt->fetch();
if (!$note) {
echo "Note not found.";
exit();
}
if ($note['doctor_id'] !== $doctor_id) {
echo "You do not have permission to delete this note.";
exit();
}
// Delete the note
$delete_stmt = $pdo->prepare("DELETE FROM medical_notes WHERE id = ?");
$delete_stmt->execute([$note_id]);
// Redirect back to notes page
header("Location: notes.php?patient_id=" . $note['patient_id']);
exit();
?>
Explanation:
Ownership Verification: Ensures only the creator of the note can delete it.
Deletion: Removes the note from the medical_notes table.
Redirection: Redirects back to the notes page for the respective patient.
3. Frontend Enhancements: Integrate Advanced Text Editor
To provide a rich text editing experience, we've integrated TinyMCE in both the Add Note and Edit Note pages. However, you can choose other editors like CKEditor based on your preference.
View Notes Button: Allows the doctor to navigate directly to the Notes Page for the selected patient.
7. Final Considerations
7.1. Responsive Design
Ensure that the Notes Page is responsive and functions well on various devices, including tablets and smartphones.
7.2. User Experience (UX)
Intuitive Navigation: Make it easy for doctors to navigate between patients and their respective notes.
Consistent Styling: Maintain consistent styling across all pages for a professional look.
Feedback Mechanisms: Provide feedback (e.g., success messages) upon successful creation, editing, or deletion of notes.
7.3. Performance Optimization
Efficient Queries: Optimize SQL queries to handle large datasets efficiently.
Caching: Implement caching strategies where appropriate to reduce server load and improve response times.
By following the above steps, you can successfully implement a robust and user-friendly Notes Page within your Doctor Dashboard. This feature will enhance the ability of doctors to document and manage patient information effectively, contributing to better patient care and streamlined workflows.
Feel free to customize and extend this functionality further based on your specific requirements and user feedback.