adding insurance
This commit is contained in:
parent
647878881a
commit
aa6a7b2ed1
38
helpers.php
Normal file
38
helpers.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once __DIR__ . '/lang.php';
|
||||
|
||||
if (!isset($_SESSION['lang'])) {
|
||||
$_SESSION['lang'] = 'en';
|
||||
}
|
||||
|
||||
if (isset($_GET['lang'])) {
|
||||
if ($_GET['lang'] === 'ar' || $_GET['lang'] === 'en') {
|
||||
$_SESSION['lang'] = $_GET['lang'];
|
||||
// Redirect to remove lang param
|
||||
header("Location: " . strtok($_SERVER["REQUEST_URI"], '?'));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function __($key) {
|
||||
global $translations;
|
||||
$lang = $_SESSION['lang'];
|
||||
return $translations[$lang][$key] ?? $key;
|
||||
}
|
||||
|
||||
function is_rtl() {
|
||||
return $_SESSION['lang'] === 'ar';
|
||||
}
|
||||
|
||||
function get_dir() {
|
||||
return is_rtl() ? 'rtl' : 'ltr';
|
||||
}
|
||||
|
||||
function get_lang_name() {
|
||||
return $_SESSION['lang'] === 'ar' ? 'English' : 'العربية';
|
||||
}
|
||||
|
||||
function get_lang_code() {
|
||||
return $_SESSION['lang'] === 'ar' ? 'en' : 'ar';
|
||||
}
|
||||
162
init_db.php
Normal file
162
init_db.php
Normal file
@ -0,0 +1,162 @@
|
||||
<?php
|
||||
require 'db/config.php';
|
||||
|
||||
try {
|
||||
$db = db();
|
||||
|
||||
// Create tables
|
||||
$sql = "
|
||||
CREATE TABLE IF NOT EXISTS departments (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
name_en VARCHAR(255) NOT NULL,
|
||||
name_ar VARCHAR(255) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS doctors (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
name_en VARCHAR(255) NOT NULL,
|
||||
name_ar VARCHAR(255) NOT NULL,
|
||||
specialization_en VARCHAR(255),
|
||||
specialization_ar VARCHAR(255),
|
||||
department_id INT,
|
||||
FOREIGN KEY (department_id) REFERENCES departments(id) ON DELETE SET NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS insurance_companies (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
name_en VARCHAR(255) NOT NULL,
|
||||
name_ar VARCHAR(255) NOT NULL,
|
||||
email VARCHAR(255),
|
||||
phone VARCHAR(50),
|
||||
contact_info TEXT,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS patients (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
phone VARCHAR(50),
|
||||
dob DATE,
|
||||
gender VARCHAR(10),
|
||||
blood_group VARCHAR(5),
|
||||
address TEXT,
|
||||
insurance_company_id INT NULL,
|
||||
policy_number VARCHAR(100) NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (insurance_company_id) REFERENCES insurance_companies(id) ON DELETE SET NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS appointments (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
patient_id INT,
|
||||
doctor_id INT,
|
||||
appointment_date DATETIME,
|
||||
status ENUM('Scheduled', 'Completed', 'Cancelled') DEFAULT 'Scheduled',
|
||||
reason TEXT,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (patient_id) REFERENCES patients(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (doctor_id) REFERENCES doctors(id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS visits (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
patient_id INT,
|
||||
doctor_id INT,
|
||||
appointment_id INT NULL,
|
||||
visit_date DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
weight VARCHAR(50),
|
||||
blood_pressure VARCHAR(50),
|
||||
heart_rate VARCHAR(50),
|
||||
temperature VARCHAR(50),
|
||||
symptoms TEXT,
|
||||
diagnosis TEXT,
|
||||
treatment_plan TEXT,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (patient_id) REFERENCES patients(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (doctor_id) REFERENCES doctors(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (appointment_id) REFERENCES appointments(id) ON DELETE SET NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS provisional_reports (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
visit_id INT,
|
||||
report_type VARCHAR(255),
|
||||
findings TEXT,
|
||||
recommendations TEXT,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (visit_id) REFERENCES visits(id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS bills (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
patient_id INT,
|
||||
visit_id INT NULL,
|
||||
total_amount DECIMAL(10, 2) DEFAULT 0.00,
|
||||
insurance_covered DECIMAL(10, 2) DEFAULT 0.00,
|
||||
patient_payable DECIMAL(10, 2) DEFAULT 0.00,
|
||||
status ENUM('Pending', 'Paid') DEFAULT 'Pending',
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (patient_id) REFERENCES patients(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (visit_id) REFERENCES visits(id) ON DELETE SET NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS bill_items (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
bill_id INT,
|
||||
description VARCHAR(255),
|
||||
amount DECIMAL(10, 2),
|
||||
FOREIGN KEY (bill_id) REFERENCES bills(id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
";
|
||||
|
||||
$db->exec($sql);
|
||||
|
||||
// Migration for existing tables
|
||||
try {
|
||||
$db->exec("ALTER TABLE insurance_companies ADD COLUMN IF NOT EXISTS email VARCHAR(255)");
|
||||
$db->exec("ALTER TABLE insurance_companies ADD COLUMN IF NOT EXISTS phone VARCHAR(50)");
|
||||
} catch (Exception $e) {}
|
||||
|
||||
try {
|
||||
$db->exec("ALTER TABLE patients ADD COLUMN IF NOT EXISTS insurance_company_id INT NULL");
|
||||
$db->exec("ALTER TABLE patients ADD COLUMN IF NOT EXISTS policy_number VARCHAR(100) NULL");
|
||||
$db->exec("ALTER TABLE patients ADD CONSTRAINT fk_patient_insurance FOREIGN KEY (insurance_company_id) REFERENCES insurance_companies(id) ON DELETE SET NULL");
|
||||
} catch (Exception $e) {}
|
||||
|
||||
try {
|
||||
$db->exec("ALTER TABLE bills ADD COLUMN IF NOT EXISTS insurance_covered DECIMAL(10, 2) DEFAULT 0.00");
|
||||
$db->exec("ALTER TABLE bills ADD COLUMN IF NOT EXISTS patient_payable DECIMAL(10, 2) DEFAULT 0.00");
|
||||
} catch (Exception $e) {}
|
||||
|
||||
// Seed departments
|
||||
$stmt = $db->query("SELECT COUNT(*) FROM departments");
|
||||
if ($stmt->fetchColumn() == 0) {
|
||||
$db->exec("INSERT INTO departments (id, name_en, name_ar) VALUES
|
||||
(1, 'Cardiology', 'قسم القلب'),
|
||||
(2, 'Pediatrics', 'طب الأطفال'),
|
||||
(3, 'Emergency', 'الطوارئ'),
|
||||
(4, 'Neurology', 'الأعصاب')");
|
||||
}
|
||||
|
||||
// Seed doctors
|
||||
$stmt = $db->query("SELECT COUNT(*) FROM doctors");
|
||||
if ($stmt->fetchColumn() == 0) {
|
||||
$db->exec("INSERT INTO doctors (id, name_en, name_ar, specialization_en, specialization_ar, department_id) VALUES
|
||||
(1, 'Dr. Ahmed Ali', 'د. أحمد علي', 'Cardiologist', 'طبيب قلب', 1),
|
||||
(2, 'Dr. Sarah Smith', 'د. سارة سميث', 'Pediatrician', 'طبيب أطفال', 2),
|
||||
(3, 'Dr. John Doe', 'د. جون دو', 'Neurologist', 'طبيب أعصاب', 4)");
|
||||
}
|
||||
|
||||
// Seed insurance companies
|
||||
$stmt = $db->query("SELECT COUNT(*) FROM insurance_companies");
|
||||
if ($stmt->fetchColumn() == 0) {
|
||||
$db->exec("INSERT INTO insurance_companies (name_en, name_ar, contact_info) VALUES
|
||||
('Bupa Arabia', 'بوبا العربية', '920000456'),
|
||||
('Tawuniya', 'التعاونية', '920019990'),
|
||||
('MedGulf', 'ميدغلف', '8004414444')");
|
||||
}
|
||||
|
||||
echo "Database setup completed successfully.";
|
||||
} catch (PDOException $e) {
|
||||
die("Database setup failed: " . $e->getMessage());
|
||||
}
|
||||
183
lang.php
Normal file
183
lang.php
Normal file
@ -0,0 +1,183 @@
|
||||
<?php
|
||||
$translations = [
|
||||
'en' => [
|
||||
'dashboard' => 'Dashboard',
|
||||
'patients' => 'Patients',
|
||||
'doctors' => 'Doctors',
|
||||
'appointments' => 'Appointments',
|
||||
'departments' => 'Departments',
|
||||
'add_patient' => 'Add Patient',
|
||||
'book_appointment' => 'Book Appointment',
|
||||
'name' => 'Name',
|
||||
'phone' => 'Phone',
|
||||
'dob' => 'Date of Birth',
|
||||
'gender' => 'Gender',
|
||||
'blood_group' => 'Blood Group',
|
||||
'address' => 'Address',
|
||||
'save' => 'Save',
|
||||
'cancel' => 'Cancel',
|
||||
'doctor' => 'Doctor',
|
||||
'patient' => 'Patient',
|
||||
'date' => 'Date',
|
||||
'status' => 'Status',
|
||||
'reason' => 'Reason',
|
||||
'actions' => 'Actions',
|
||||
'total_patients' => 'Total Patients',
|
||||
'today_appointments' => 'Today\'s Appointments',
|
||||
'hospital_management' => 'Hospital Management System',
|
||||
'male' => 'Male',
|
||||
'female' => 'Female',
|
||||
'other' => 'Other',
|
||||
'scheduled' => 'Scheduled',
|
||||
'completed' => 'Completed',
|
||||
'cancelled' => 'Cancelled',
|
||||
'welcome' => 'Welcome',
|
||||
'search' => 'Search',
|
||||
'profile' => 'Profile',
|
||||
'logout' => 'Logout',
|
||||
'language' => 'Language',
|
||||
'arabic' => 'Arabic',
|
||||
'english' => 'English',
|
||||
'department' => 'Department',
|
||||
'specialization' => 'Specialization',
|
||||
'visits' => 'Visits',
|
||||
'new_visit' => 'New Visit',
|
||||
'vitals' => 'Vitals',
|
||||
'weight' => 'Weight (kg)',
|
||||
'blood_pressure' => 'Blood Pressure',
|
||||
'heart_rate' => 'Heart Rate (bpm)',
|
||||
'temperature' => 'Temperature (°C)',
|
||||
'symptoms' => 'Symptoms',
|
||||
'diagnosis' => 'Diagnosis',
|
||||
'treatment_plan' => 'Treatment Plan',
|
||||
'provisional_reports' => 'Provisional Reports',
|
||||
'new_report' => 'New Report',
|
||||
'report_type' => 'Report Type',
|
||||
'findings' => 'Findings',
|
||||
'recommendations' => 'Recommendations',
|
||||
'billing' => 'Billing',
|
||||
'view_visit' => 'View Visit',
|
||||
'add_visit' => 'Record Visit',
|
||||
'appointment' => 'Appointment',
|
||||
'visit_recorded' => 'Visit recorded successfully',
|
||||
'report_created' => 'Provisional report created successfully',
|
||||
'bill' => 'Bill',
|
||||
'amount' => 'Amount',
|
||||
'description' => 'Description',
|
||||
'total' => 'Total',
|
||||
'paid' => 'Paid',
|
||||
'pending' => 'Pending',
|
||||
'create_bill' => 'Create Bill',
|
||||
'view_bill' => 'View Bill',
|
||||
'bill_created' => 'Bill created successfully',
|
||||
'bill_paid' => 'Bill marked as paid',
|
||||
'payment_status' => 'Payment Status',
|
||||
'revenue' => 'Revenue',
|
||||
'items' => 'Items',
|
||||
'add_item' => 'Add Item',
|
||||
'consultation_fee' => 'Consultation Fee',
|
||||
'mark_as_paid' => 'Mark as Paid',
|
||||
'insurance_companies' => 'Insurance Companies',
|
||||
'insurance_company' => 'Insurance Company',
|
||||
'policy_number' => 'Policy Number',
|
||||
'contact_info' => 'Contact Info',
|
||||
'add_insurance' => 'Add Insurance',
|
||||
'insurance' => 'Insurance',
|
||||
'not_insured' => 'Not Insured',
|
||||
'insurance_covered' => 'Insurance Covered',
|
||||
'patient_payable' => 'Patient Payable',
|
||||
'successfully' => 'successfully',
|
||||
'optional' => 'Optional',
|
||||
'email' => 'Email'
|
||||
],
|
||||
'ar' => [
|
||||
'dashboard' => 'لوحة القيادة',
|
||||
'patients' => 'المرضى',
|
||||
'doctors' => 'الأطباء',
|
||||
'appointments' => 'المواعيد',
|
||||
'departments' => 'الأقسام',
|
||||
'add_patient' => 'إضافة مريض',
|
||||
'book_appointment' => 'حجز موعد',
|
||||
'name' => 'الاسم',
|
||||
'phone' => 'الهاتف',
|
||||
'dob' => 'تاريخ الميلاد',
|
||||
'gender' => 'الجنس',
|
||||
'blood_group' => 'فصيلة الدم',
|
||||
'address' => 'العنوان',
|
||||
'save' => 'حفظ',
|
||||
'cancel' => 'إلغاء',
|
||||
'doctor' => 'الطبيب',
|
||||
'patient' => 'المريض',
|
||||
'date' => 'التاريخ',
|
||||
'status' => 'الحالة',
|
||||
'reason' => 'السبب',
|
||||
'actions' => 'الإجراءات',
|
||||
'total_patients' => 'إجمالي المرضى',
|
||||
'today_appointments' => 'مواعيد اليوم',
|
||||
'hospital_management' => 'نظام إدارة المستشفى',
|
||||
'male' => 'ذكر',
|
||||
'female' => 'أنثى',
|
||||
'other' => 'آخر',
|
||||
'scheduled' => 'مجدول',
|
||||
'completed' => 'مكتمل',
|
||||
'cancelled' => 'ملغي',
|
||||
'welcome' => 'أهلاً بك',
|
||||
'search' => 'بحث',
|
||||
'profile' => 'الملف الشخصي',
|
||||
'logout' => 'تسجيل الخروج',
|
||||
'language' => 'اللغة',
|
||||
'arabic' => 'العربية',
|
||||
'english' => 'الإنجليزية',
|
||||
'department' => 'القسم',
|
||||
'specialization' => 'التخصص',
|
||||
'visits' => 'الزيارات',
|
||||
'new_visit' => 'زيارة جديدة',
|
||||
'vitals' => 'العلامات الحيوية',
|
||||
'weight' => 'الوزن (كجم)',
|
||||
'blood_pressure' => 'ضغط الدم',
|
||||
'heart_rate' => 'نبض القلب',
|
||||
'temperature' => 'درجة الحرارة',
|
||||
'symptoms' => 'الأعراض',
|
||||
'diagnosis' => 'التشخيص',
|
||||
'treatment_plan' => 'خطة العلاج',
|
||||
'provisional_reports' => 'التقارير المؤقتة',
|
||||
'new_report' => 'تقرير جديد',
|
||||
'report_type' => 'نوع التقرير',
|
||||
'findings' => 'النتائج',
|
||||
'recommendations' => 'التوصيات',
|
||||
'billing' => 'الفواتير',
|
||||
'view_visit' => 'عرض الزيارة',
|
||||
'add_visit' => 'تسجيل زيارة',
|
||||
'appointment' => 'الموعد',
|
||||
'visit_recorded' => 'تم تسجيل الزيارة بنجاح',
|
||||
'report_created' => 'تم إنشاء التقرير المؤقت بنجاح',
|
||||
'bill' => 'فاتورة',
|
||||
'amount' => 'المبلغ',
|
||||
'description' => 'الوصف',
|
||||
'total' => 'الإجمالي',
|
||||
'paid' => 'تم الدفع',
|
||||
'pending' => 'قيد الانتظار',
|
||||
'create_bill' => 'إنشاء فاتورة',
|
||||
'view_bill' => 'عرض الفاتورة',
|
||||
'bill_created' => 'تم إنشاء الفاتورة بنجاح',
|
||||
'bill_paid' => 'تم تحديد الفاتورة كمكتملة الدفع',
|
||||
'payment_status' => 'حالة الدفع',
|
||||
'revenue' => 'الإيرادات',
|
||||
'items' => 'العناصر',
|
||||
'add_item' => 'إضافة عنصر',
|
||||
'consultation_fee' => 'رسوم الاستشارة',
|
||||
'mark_as_paid' => 'تحديد كمكتمل الدفع',
|
||||
'insurance_companies' => 'شركات التأمين',
|
||||
'insurance_company' => 'شركة التأمين',
|
||||
'policy_number' => 'رقم البوليصة',
|
||||
'contact_info' => 'معلومات الاتصال',
|
||||
'add_insurance' => 'إضافة تأمين',
|
||||
'insurance' => 'التأمين',
|
||||
'not_insured' => 'غير مؤمن',
|
||||
'insurance_covered' => 'مغطى بالتأمين',
|
||||
'patient_payable' => 'مبلغ المريض',
|
||||
'successfully' => 'بنجاح',
|
||||
'optional' => 'اختياري',
|
||||
'email' => 'البريد الإلكتروني'
|
||||
]
|
||||
];
|
||||
Loading…
x
Reference in New Issue
Block a user