-- Bogsiiye — every table's structure for a new install (php artisan install:export, 2026-10-27)
-- @@
CREATE TABLE IF NOT EXISTS `acc_currencies` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(500) NOT NULL,
  `symbol` varchar(500) NOT NULL,
  `default` varchar(15) DEFAULT NULL,
  `exchange_rate` varchar(500) DEFAULT NULL,
  `status` varchar(50) NOT NULL,
  `created_by` int NOT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `type` enum('system','custom') DEFAULT NULL,
  `operation` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `acc_currencies_histories` (
  `id` int NOT NULL AUTO_INCREMENT,
  `currency_id` int NOT NULL,
  `exchange_rate` varchar(500) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `acc_payment_types` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(150) NOT NULL,
  `branch_id` int NOT NULL,
  `status` varchar(50) DEFAULT NULL,
  `hospital_id` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `acc_transfer_funds` (
  `id` int NOT NULL AUTO_INCREMENT,
  `from_account_id` int NOT NULL,
  `to_account_id` int NOT NULL,
  `amount` decimal(10,2) NOT NULL,
  `description` text,
  `branch_id` int NOT NULL,
  `hospital_id` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `admission_consultations` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `admission_id` bigint unsigned NOT NULL,
  `chief_complaint` text COLLATE utf8mb4_unicode_ci,
  `history` text COLLATE utf8mb4_unicode_ci,
  `physical_examination` text COLLATE utf8mb4_unicode_ci,
  `diagnoses` text COLLATE utf8mb4_unicode_ci,
  `treatment_plan` text COLLATE utf8mb4_unicode_ci,
  `created_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `admission_consultations_admission_id_index` (`admission_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `admission_details` (
  `id` int NOT NULL AUTO_INCREMENT,
  `appointment_id` int DEFAULT NULL,
  `date` date DEFAULT NULL,
  `admission_id` int DEFAULT NULL,
  `date_in` date DEFAULT NULL,
  `date_out` date DEFAULT NULL,
  `days` int DEFAULT NULL,
  `room` int DEFAULT NULL,
  `bed` int DEFAULT NULL,
  `type` varchar(150) DEFAULT NULL,
  `cost` decimal(10,2) DEFAULT NULL,
  `currency` int DEFAULT NULL,
  `exchange_rate` decimal(10,2) DEFAULT NULL,
  `payment` decimal(10,2) DEFAULT NULL,
  `discount` decimal(10,2) DEFAULT NULL,
  `promotion` decimal(10,2) DEFAULT NULL,
  `status` varchar(50) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `admission_discharges` (
  `id` int NOT NULL AUTO_INCREMENT,
  `admission_id` int NOT NULL,
  `discharge_date` date NOT NULL,
  `days` int DEFAULT NULL,
  `patient_condition` varchar(150) NOT NULL,
  `complication` varchar(50) NOT NULL,
  `complication_text` text,
  `diagnosis_admission` text,
  `discharge_diagnosis` text,
  `discharge_medication` text,
  `discharged_by` text,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `admission_doctor_orders` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `admission_id` bigint unsigned NOT NULL,
  `date` date NOT NULL,
  `time` time DEFAULT NULL,
  `order_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'other',
  `drug` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `dose` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `route` bigint unsigned DEFAULT NULL,
  `frequency_hours` smallint unsigned DEFAULT NULL,
  `duration_days` smallint unsigned NOT NULL DEFAULT '1',
  `dose_times` varchar(120) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `instruction` text COLLATE utf8mb4_unicode_ci,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Active',
  `completed_by` bigint unsigned DEFAULT NULL,
  `completed_at` datetime DEFAULT NULL,
  `completion_note` text COLLATE utf8mb4_unicode_ci,
  `doctor_id` bigint unsigned DEFAULT NULL,
  `hospital_id` bigint unsigned DEFAULT NULL,
  `branch_id` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `admission_doctor_orders_admission_id_index` (`admission_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `admission_fluid_charts` (
  `id` int NOT NULL AUTO_INCREMENT,
  `admission_id` int NOT NULL,
  `date` date DEFAULT NULL,
  `time` time DEFAULT NULL,
  `oral` text,
  `iv` text,
  `tube_feeding` text,
  `other_input` text,
  `urine` text,
  `vomit` text,
  `diarrhea` text,
  `other_output` text,
  `observation` text,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `admission_insulin_charts` (
  `id` int NOT NULL AUTO_INCREMENT,
  `date` date DEFAULT NULL,
  `time` time DEFAULT NULL,
  `result` text,
  `unit` text,
  `observation` text,
  `created_by` int NOT NULL,
  `admission_id` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `admission_medications` (
  `id` int NOT NULL AUTO_INCREMENT,
  `admission_id` int DEFAULT NULL,
  `date` date DEFAULT NULL,
  `time` time DEFAULT NULL,
  `drug` varchar(500) DEFAULT NULL,
  `product_id` bigint unsigned DEFAULT NULL,
  `quantity` decimal(12,2) DEFAULT NULL,
  `uom` bigint unsigned DEFAULT NULL,
  `prescription_detail_id` bigint unsigned DEFAULT NULL,
  `dose` varchar(150) DEFAULT NULL,
  `route` int DEFAULT NULL,
  `note` text,
  `created_by` int DEFAULT NULL,
  `status` varchar(50) DEFAULT NULL,
  `stoped_by` int DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `admission_order_doses` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `order_id` bigint unsigned NOT NULL,
  `admission_id` bigint unsigned NOT NULL,
  `due_at` datetime NOT NULL,
  `status` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Due',
  `given_at` datetime DEFAULT NULL,
  `given_by` bigint unsigned DEFAULT NULL,
  `note` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `admission_order_doses_order_id_index` (`order_id`),
  KEY `admission_order_doses_admission_id_index` (`admission_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `admission_products` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `admission_id` bigint unsigned NOT NULL,
  `product_id` bigint unsigned NOT NULL,
  `quantity` decimal(10,2) NOT NULL DEFAULT '1.00',
  `date` date NOT NULL,
  `note` text COLLATE utf8mb4_unicode_ci,
  `created_by` bigint unsigned DEFAULT NULL,
  `hospital_id` bigint unsigned DEFAULT NULL,
  `branch_id` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `admission_products_admission_id_index` (`admission_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `admission_settings` (
  `id` int NOT NULL AUTO_INCREMENT,
  `income_account` int NOT NULL,
  `cash_account` int NOT NULL,
  `discount_account` int NOT NULL,
  `promotion_account` int NOT NULL,
  `created_by` int NOT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `credit_account` int NOT NULL,
  `credit_allowed` enum('Yes','No') NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `admission_vitalsigns` (
  `id` int NOT NULL AUTO_INCREMENT,
  `admission_id` int NOT NULL,
  `date` date DEFAULT NULL,
  `time` time DEFAULT NULL,
  `blood_pressure` text,
  `pulse` text,
  `temperature` text,
  `respiratory` text,
  `oxygen` text,
  `weight` text,
  `glucose` text,
  `fhr` varchar(200) DEFAULT NULL,
  `observation` text,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `admissions` (
  `id` int NOT NULL AUTO_INCREMENT,
  `appointment_id` int DEFAULT NULL,
  `patient_id` int DEFAULT NULL,
  `date` date DEFAULT NULL,
  `days` int DEFAULT NULL,
  `type` varchar(50) DEFAULT NULL,
  `hospital_id` int DEFAULT NULL,
  `branch_id` int DEFAULT NULL,
  `doctor_id` int DEFAULT NULL,
  `created_by` int DEFAULT NULL,
  `notes` text,
  `status` varchar(50) DEFAULT NULL,
  `payment` decimal(10,2) DEFAULT NULL,
  `discount` decimal(10,2) DEFAULT NULL,
  `promotion` decimal(10,2) DEFAULT NULL,
  `room` int DEFAULT NULL,
  `date_in` date DEFAULT NULL,
  `date_out` date DEFAULT NULL,
  `time_in` time DEFAULT NULL,
  `cost` decimal(10,2) DEFAULT NULL,
  `guardian_name` varchar(500) DEFAULT NULL,
  `relationship` varchar(500) DEFAULT NULL,
  `guardian_number` varchar(500) DEFAULT NULL,
  `admitted_date` date DEFAULT NULL,
  `payment_status` varchar(50) DEFAULT NULL,
  `bed` int DEFAULT NULL,
  `exchange_rate` decimal(10,2) DEFAULT NULL,
  `currency` int DEFAULT NULL,
  `payment_method` int DEFAULT NULL,
  `admission_no` varchar(250) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `cash_account` int DEFAULT NULL,
  `income_account` int DEFAULT NULL,
  `discount_account` int DEFAULT NULL,
  `promotion_account` int DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `appointment_clinic_assessments` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `appointment_id` bigint unsigned NOT NULL,
  `patient_id` bigint unsigned DEFAULT NULL,
  `chief_complaint` text COLLATE utf8mb4_unicode_ci,
  `complaint_since` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `pain_score` tinyint unsigned DEFAULT NULL,
  `pain_area` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `pain_side` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `pain_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `pain_worse` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `joint_exam` json DEFAULT NULL,
  `posture` text COLLATE utf8mb4_unicode_ci,
  `gait` text COLLATE utf8mb4_unicode_ci,
  `special_tests` text COLLATE utf8mb4_unicode_ci,
  `functional_limits` text COLLATE utf8mb4_unicode_ci,
  `goals` text COLLATE utf8mb4_unicode_ci,
  `plan_sessions` smallint unsigned DEFAULT NULL,
  `plan_per_week` tinyint unsigned DEFAULT NULL,
  `plan_treatments` json DEFAULT NULL,
  `plan_notes` text COLLATE utf8mb4_unicode_ci,
  `physio_by` bigint unsigned DEFAULT NULL,
  `physio_at` datetime DEFAULT NULL,
  `safety` json DEFAULT NULL,
  `safety_notes` text COLLATE utf8mb4_unicode_ci,
  `consent` tinyint(1) NOT NULL DEFAULT '0',
  `safety_by` bigint unsigned DEFAULT NULL,
  `safety_at` datetime DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `hospital_id` bigint unsigned DEFAULT NULL,
  `branch_id` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `appointment_clinic_assessments_appointment_id_unique` (`appointment_id`),
  KEY `appointment_clinic_assessments_patient_id_index` (`patient_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `appointment_clinic_sessions` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `appointment_id` bigint unsigned NOT NULL,
  `patient_id` bigint unsigned DEFAULT NULL,
  `date` date NOT NULL,
  `treatment` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `pain_before` tinyint unsigned DEFAULT NULL,
  `pain_after` tinyint unsigned DEFAULT NULL,
  `notes` text COLLATE utf8mb4_unicode_ci,
  `created_by` bigint unsigned DEFAULT NULL,
  `hospital_id` bigint unsigned DEFAULT NULL,
  `branch_id` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `appointment_clinic_sessions_appointment_id_index` (`appointment_id`),
  KEY `appointment_clinic_sessions_patient_id_index` (`patient_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `appointment_consultations` (
  `id` int NOT NULL AUTO_INCREMENT,
  `appointment_id` int NOT NULL,
  `symptoms` text,
  `diagnoses` text,
  `note` text,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `chief_complaint` text,
  `physical_examination` longtext,
  `present_illness` text,
  `past_medical_history` text,
  `past_surgical_history` text,
  `drug_history` text,
  `social_history` text,
  `family_history` text,
  `differntial_diagnosis` text,
  `lmp` text,
  `parity` text,
  `gravidity` text,
  `abortion` text,
  `still_birth` text,
  `alive_birth` text,
  `ante_natal` text,
  `natal` text,
  `post_natal` text,
  `developement_history` text,
  `nutritional_history` text,
  `vaccination_history` text,
  `head_circumference` text,
  `mid_upper_circumference` text,
  `right_va` text,
  `right_pin_hole` text,
  `right_with_glass` text,
  `left_va` text,
  `left_pin_hole` text,
  `left_with_glass` text,
  `left_eye` text,
  `right_eye` text,
  `eye_examination` text,
  `eye_treatment` text,
  `eye_notes` text,
  `gestational_age` text,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `appointment_settings` (
  `id` int NOT NULL AUTO_INCREMENT,
  `income_account` int NOT NULL,
  `cash_account` int NOT NULL,
  `discount_account` int NOT NULL,
  `promotion_account` int NOT NULL,
  `created_by` int NOT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `credit_account` int NOT NULL,
  `credit_allowed` enum('Yes','No') NOT NULL,
  `promotion_allowed` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `appointment_types` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'enabled',
  `hospital_id` bigint unsigned DEFAULT NULL,
  `branch_id` bigint unsigned DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `appointment_vital_signs` (
  `id` int NOT NULL AUTO_INCREMENT,
  `appointment_id` int DEFAULT NULL,
  `body_temperature` varchar(250) DEFAULT NULL,
  `heart_rate` varchar(250) DEFAULT NULL,
  `blood_pressure_systolic` varchar(250) DEFAULT NULL,
  `blood_pressure_diastolic` varchar(250) DEFAULT NULL,
  `reflexes` int DEFAULT NULL,
  `respiratory_rate` varchar(250) DEFAULT NULL,
  `height_type` varchar(100) DEFAULT NULL,
  `height` varchar(500) DEFAULT NULL,
  `weight_type` varchar(100) DEFAULT NULL,
  `weight` varchar(100) DEFAULT NULL,
  `bmi` varchar(200) DEFAULT NULL,
  `lpt` varchar(200) DEFAULT NULL,
  `date` date DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `oxygen_concentration` varchar(150) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `appointments` (
  `id` int NOT NULL AUTO_INCREMENT,
  `patient_id` int NOT NULL,
  `department_id` int NOT NULL,
  `doctor_id` int NOT NULL,
  `date` date NOT NULL,
  `appointment_type_id` bigint unsigned DEFAULT NULL,
  `price` decimal(10,2) NOT NULL,
  `payment_type` int DEFAULT NULL,
  `branch_id` int NOT NULL,
  `hospital_id` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `payment_status` varchar(50) DEFAULT NULL,
  `payment` decimal(10,2) DEFAULT NULL,
  `discount` decimal(10,2) DEFAULT NULL,
  `promotion` decimal(10,2) DEFAULT NULL,
  `currency` int DEFAULT NULL,
  `exchange_rate` decimal(10,2) DEFAULT NULL,
  `queue` int DEFAULT NULL,
  `entry_status` varchar(50) NOT NULL DEFAULT 'Not Entered',
  `entry_confirmed_by` bigint unsigned DEFAULT NULL,
  `entry_confirmed_at` timestamp NULL DEFAULT NULL,
  `appointment_no` varchar(200) DEFAULT NULL,
  `income_account` int DEFAULT NULL,
  `cash_account` int DEFAULT NULL,
  `discount_account` int DEFAULT NULL,
  `promotion_account` int DEFAULT NULL,
  `journal_id` int DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `attendance_device_settings` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `device_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `sn` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `area` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `audits` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `user_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `event` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `auditable_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `auditable_id` bigint unsigned NOT NULL,
  `old_values` text COLLATE utf8mb4_unicode_ci,
  `new_values` text COLLATE utf8mb4_unicode_ci,
  `url` text COLLATE utf8mb4_unicode_ci,
  `ip_address` varchar(45) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `user_agent` varchar(1023) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `tags` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `audits_auditable_type_auditable_id_index` (`auditable_type`,`auditable_id`),
  KEY `audits_user_id_user_type_index` (`user_id`,`user_type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `avarage_costs` (
  `id` int NOT NULL AUTO_INCREMENT,
  `purchase_id` int NOT NULL,
  `purchase_receive_id` int NOT NULL,
  `product_id` int NOT NULL,
  `available_quantity` decimal(10,2) NOT NULL,
  `new_quantity` decimal(10,2) NOT NULL,
  `old_cost` decimal(10,2) NOT NULL,
  `new_cost` decimal(10,2) NOT NULL,
  `calculated_price` decimal(10,2) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `bank_accounts` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `holder_name` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `bank_name` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `account_number` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `opening_balance` double(15,2) NOT NULL DEFAULT '0.00',
  `contact_number` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `bank_address` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_by` int NOT NULL DEFAULT '0',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `birth_certficates` (
  `id` int NOT NULL AUTO_INCREMENT,
  `patient_id` int NOT NULL,
  `dob` date DEFAULT NULL,
  `tob` time DEFAULT NULL,
  `child_name` varchar(500) DEFAULT NULL,
  `fathers_name` varchar(500) DEFAULT NULL,
  `weight` varchar(500) DEFAULT NULL,
  `doctor` int DEFAULT NULL,
  `hospital_directory` varchar(500) DEFAULT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_by` int DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `child_gender` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `branches` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(250) NOT NULL,
  `hospital_id` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `cash_close_headers` (
  `id` int NOT NULL AUTO_INCREMENT,
  `date` varchar(200) DEFAULT NULL,
  `previous_cashier` int DEFAULT NULL,
  `shift_id` varchar(200) DEFAULT NULL,
  `total_open_balance` varchar(200) DEFAULT NULL,
  `total_payments` varchar(200) DEFAULT NULL,
  `total_expenses` varchar(200) DEFAULT NULL,
  `total_expected` varchar(200) DEFAULT NULL,
  `total_actual` varchar(200) DEFAULT NULL,
  `total_difference` varchar(200) DEFAULT NULL,
  `status` varchar(200) DEFAULT NULL,
  `created_by` int DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `desk` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `cash_closes` (
  `id` int NOT NULL AUTO_INCREMENT,
  `cash_close_header` varchar(200) DEFAULT NULL,
  `date` varchar(200) DEFAULT NULL,
  `cashier_id` varchar(200) DEFAULT NULL,
  `method_id` varchar(200) DEFAULT NULL,
  `opening` varchar(200) DEFAULT NULL,
  `payments` varchar(200) DEFAULT NULL,
  `expenses` varchar(200) DEFAULT NULL,
  `expected` varchar(200) DEFAULT NULL,
  `actual` varchar(200) DEFAULT NULL,
  `difference` varchar(200) DEFAULT NULL,
  `status` varchar(200) DEFAULT NULL,
  `created_by` varchar(200) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `cash_transfers` (
  `id` int NOT NULL AUTO_INCREMENT,
  `journal_id` int NOT NULL,
  `system_cash` decimal(10,2) NOT NULL,
  `actual_cash` decimal(10,2) NOT NULL,
  `description` text,
  `status` varchar(50) DEFAULT NULL,
  `created_by` int NOT NULL,
  `approved_by` int DEFAULT NULL,
  `approved_date` datetime DEFAULT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `chart_of_account_sub_types` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '1',
  `type` int NOT NULL DEFAULT '0',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `chart_of_account_types` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_by` int NOT NULL DEFAULT '0',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `chart_of_accounts` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `code` int NOT NULL DEFAULT '0',
  `type` int NOT NULL DEFAULT '0',
  `sub_type` int NOT NULL DEFAULT '0',
  `status` varchar(50) DEFAULT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `created_by` int NOT NULL DEFAULT '0',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `branch_id` int NOT NULL,
  `hospital_id` int NOT NULL,
  `parent` int DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `commissioners` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(500) NOT NULL,
  `status` varchar(50) NOT NULL,
  `telephone` varchar(50) NOT NULL,
  `created_by` int NOT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `commissions` (
  `id` int NOT NULL AUTO_INCREMENT,
  `payment_id` int NOT NULL,
  `commissioner_id` int NOT NULL,
  `value` decimal(10,2) DEFAULT NULL,
  `status` varchar(50) DEFAULT 'Paid',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `is_staff` int DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `cost_calcs` (
  `pos_id` int NOT NULL,
  `product_id` int NOT NULL,
  `cost` decimal(10,4) DEFAULT NULL,
  `quantity` decimal(10,2) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `death_certficates` (
  `id` int NOT NULL AUTO_INCREMENT,
  `patient_id` int NOT NULL,
  `dod` date DEFAULT NULL,
  `tod` time DEFAULT NULL,
  `death_reason` text,
  `hospital_directory` varchar(500) DEFAULT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_by` int DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `deliveries` (
  `id` int NOT NULL AUTO_INCREMENT,
  `date` date NOT NULL,
  `type` enum('Appointment','Outside','Admission') DEFAULT NULL,
  `patient_id` varchar(500) NOT NULL,
  `admission_id` bigint unsigned DEFAULT NULL,
  `delivery_mode` bigint unsigned DEFAULT NULL,
  `rate` decimal(10,2) NOT NULL DEFAULT '0.00',
  `payment_status` varchar(255) NOT NULL DEFAULT 'Pending',
  `notes` text,
  `created_by` int NOT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `deliveries_admission_id_index` (`admission_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `delivery_modes` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(500) NOT NULL,
  `rate` decimal(10,2) NOT NULL,
  `status` varchar(50) NOT NULL,
  `created_by` int NOT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `device_log` (
  `id` int NOT NULL AUTO_INCREMENT,
  `url` varchar(255) DEFAULT NULL,
  `data` varchar(800) DEFAULT NULL,
  `sn` varchar(800) DEFAULT NULL,
  `option` varchar(800) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `device_requests` (
  `id` int NOT NULL AUTO_INCREMENT,
  `device_id` int DEFAULT NULL,
  `device_sn` varchar(800) DEFAULT NULL,
  `emp_id` varchar(255) DEFAULT NULL,
  `created_by` varchar(255) DEFAULT NULL,
  `branch_id` varchar(255) DEFAULT NULL,
  `company_id` varchar(255) DEFAULT NULL,
  `command` text,
  `status` text,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `diagnoses` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(1000) NOT NULL,
  `status` varchar(50) NOT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `emergencies` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `emergency_no` bigint unsigned DEFAULT NULL,
  `patient_id` bigint unsigned NOT NULL,
  `doctor_id` bigint unsigned DEFAULT NULL,
  `department_id` bigint unsigned DEFAULT NULL,
  `date_in` datetime NOT NULL,
  `date_out` datetime DEFAULT NULL,
  `hours` decimal(8,2) DEFAULT NULL,
  `rate` decimal(12,2) NOT NULL DEFAULT '0.00',
  `cost` decimal(12,2) NOT NULL DEFAULT '0.00',
  `payment_status` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Unpaid',
  `status` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Active',
  `complaint` text COLLATE utf8mb4_unicode_ci,
  `notes` text COLLATE utf8mb4_unicode_ci,
  `admission_id` bigint unsigned DEFAULT NULL,
  `hospital_id` bigint unsigned DEFAULT NULL,
  `branch_id` bigint unsigned DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `emergencies_patient_id_status_index` (`patient_id`,`status`),
  KEY `emergencies_department_id_index` (`department_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `emergency_consultations` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `emergency_id` bigint unsigned NOT NULL,
  `chief_complaint` text COLLATE utf8mb4_unicode_ci,
  `history` text COLLATE utf8mb4_unicode_ci,
  `physical_examination` text COLLATE utf8mb4_unicode_ci,
  `diagnoses` text COLLATE utf8mb4_unicode_ci,
  `treatment_plan` text COLLATE utf8mb4_unicode_ci,
  `created_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `emergency_consultations_emergency_id_index` (`emergency_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `emergency_doctor_orders` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `emergency_id` bigint unsigned NOT NULL,
  `doctor_id` bigint unsigned DEFAULT NULL,
  `date` date NOT NULL,
  `time` time DEFAULT NULL,
  `order_type` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL,
  `drug` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `dose` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `route` bigint unsigned DEFAULT NULL,
  `frequency_hours` smallint unsigned DEFAULT NULL,
  `duration_days` smallint unsigned NOT NULL DEFAULT '1',
  `dose_times` varchar(120) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `instruction` text COLLATE utf8mb4_unicode_ci,
  `status` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Active',
  `completed_by` bigint unsigned DEFAULT NULL,
  `completed_at` datetime DEFAULT NULL,
  `completion_note` text COLLATE utf8mb4_unicode_ci,
  `hospital_id` bigint unsigned DEFAULT NULL,
  `branch_id` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `emergency_doctor_orders_emergency_id_index` (`emergency_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `emergency_medications` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `emergency_id` bigint unsigned NOT NULL,
  `date` date NOT NULL,
  `time` time NOT NULL,
  `drug` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `product_id` bigint unsigned DEFAULT NULL,
  `quantity` decimal(12,2) DEFAULT NULL,
  `uom` bigint unsigned DEFAULT NULL,
  `dose` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `route` bigint unsigned DEFAULT NULL,
  `note` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `prescription_detail_id` bigint unsigned DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `emergency_medications_emergency_id_index` (`emergency_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `emergency_order_doses` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `order_id` bigint unsigned NOT NULL,
  `emergency_id` bigint unsigned NOT NULL,
  `due_at` datetime NOT NULL,
  `status` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Due',
  `given_at` datetime DEFAULT NULL,
  `given_by` bigint unsigned DEFAULT NULL,
  `note` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `emergency_order_doses_order_id_index` (`order_id`),
  KEY `emergency_order_doses_emergency_id_index` (`emergency_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `emergency_settings` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `rate_per_hour` decimal(12,2) NOT NULL DEFAULT '0.00',
  `income_account` bigint unsigned DEFAULT NULL,
  `cash_account` bigint unsigned DEFAULT NULL,
  `discount_account` bigint unsigned DEFAULT NULL,
  `hospital_id` bigint unsigned DEFAULT NULL,
  `branch_id` bigint unsigned DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `emergency_vital_signs` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `emergency_id` bigint unsigned NOT NULL,
  `date` date NOT NULL,
  `time` time NOT NULL,
  `bp_systolic` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `bp_diastolic` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `pulse` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `temperature` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `respiratory_rate` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `spo2` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `weight` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `height` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `bmi` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `glucose` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `note` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `emergency_vital_signs_emergency_id_index` (`emergency_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `error_log` (
  `id` int NOT NULL AUTO_INCREMENT,
  `error` longtext,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- @@
CREATE TABLE IF NOT EXISTS `expense_categories` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(500) NOT NULL,
  `status` varchar(50) NOT NULL,
  `expense_account` int DEFAULT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `expense_settings` (
  `id` int NOT NULL AUTO_INCREMENT,
  `cash_account` int NOT NULL,
  `category_account` enum('Yes','No') DEFAULT NULL,
  `expense_account` int DEFAULT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `expense_sources` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(250) NOT NULL,
  `asset_account` int NOT NULL,
  `is_cash` varchar(50) NOT NULL,
  `branch_id` int NOT NULL,
  `hospital_id` int NOT NULL,
  `created_by` int DEFAULT NULL,
  `status` varchar(50) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `expense_subcategories` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(150) NOT NULL,
  `category` int NOT NULL,
  `status` varchar(50) NOT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `expenses` (
  `id` int NOT NULL AUTO_INCREMENT,
  `category` int NOT NULL,
  `subcategory` int DEFAULT NULL,
  `date` date NOT NULL,
  `type` enum('Staff','Other') NOT NULL,
  `expense_type` enum('Pitty','Cash') DEFAULT 'Pitty',
  `staff_id` int DEFAULT NULL,
  `amount` decimal(10,2) DEFAULT NULL,
  `description` varchar(500) DEFAULT NULL,
  `currency` int NOT NULL,
  `exchange_rate` decimal(10,2) DEFAULT NULL,
  `cash_account` int NOT NULL,
  `expense_account` int NOT NULL,
  `created_by` int NOT NULL,
  `payment_type` int NOT NULL,
  `journal` int NOT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `is_cash` varchar(10) NOT NULL,
  `source` int NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `eye_biometry` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `eye_surgical_procedure_id` bigint unsigned NOT NULL,
  `eye` enum('OD','OS') COLLATE utf8mb4_unicode_ci NOT NULL,
  `axial_length_mm` decimal(5,2) NOT NULL,
  `k1` decimal(5,2) NOT NULL,
  `k2` decimal(5,2) NOT NULL,
  `iol_power_calculated` decimal(5,2) NOT NULL,
  `iol_formula_used` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `target_refraction` decimal(5,2) DEFAULT NULL,
  `hospital_id` bigint unsigned DEFAULT NULL,
  `branch_id` bigint unsigned DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `eye_clinic_images` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `appointment_id` bigint unsigned NOT NULL,
  `eye_side` enum('OD','OS','both') COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `image_type` enum('fundus_photo','oct','topography','other') COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `image` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `hospital_id` bigint unsigned DEFAULT NULL,
  `branch_id` bigint unsigned DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `eye_contact_lens_fitting` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `appointment_id` bigint unsigned NOT NULL,
  `eye` enum('OD','OS') COLLATE utf8mb4_unicode_ci NOT NULL,
  `base_curve` decimal(4,2) NOT NULL,
  `diameter_mm` decimal(4,2) NOT NULL,
  `brand` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `wear_schedule` enum('daily','weekly','monthly','extended') COLLATE utf8mb4_unicode_ci NOT NULL,
  `notes` text COLLATE utf8mb4_unicode_ci,
  `hospital_id` bigint unsigned DEFAULT NULL,
  `branch_id` bigint unsigned DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `eye_diagnostic_tests` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `appointment_id` bigint unsigned NOT NULL,
  `test_type` enum('color_vision_ishihara','visual_field','other') COLLATE utf8mb4_unicode_ci NOT NULL,
  `eye` enum('OD','OS','both') COLLATE utf8mb4_unicode_ci NOT NULL,
  `result_summary` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `result_detail` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin,
  `file_id` bigint unsigned DEFAULT NULL,
  `hospital_id` bigint unsigned DEFAULT NULL,
  `branch_id` bigint unsigned DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  CONSTRAINT `eye_diagnostic_tests_chk_1` CHECK (json_valid(`result_detail`))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `eye_findings` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `appointment_id` bigint unsigned NOT NULL,
  `eye` enum('OD','OS','both') COLLATE utf8mb4_unicode_ci NOT NULL,
  `segment` enum('anterior','posterior') COLLATE utf8mb4_unicode_ci NOT NULL,
  `structure` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `finding` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `grade` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `notes` text COLLATE utf8mb4_unicode_ci,
  `hospital_id` bigint unsigned DEFAULT NULL,
  `branch_id` bigint unsigned DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `eye_iop_readings` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `appointment_id` bigint unsigned NOT NULL,
  `eye` enum('OD','OS') COLLATE utf8mb4_unicode_ci NOT NULL,
  `value_mmhg` decimal(5,2) NOT NULL,
  `method` enum('applanation','non_contact','icare','other') COLLATE utf8mb4_unicode_ci NOT NULL,
  `time_of_day` time DEFAULT NULL,
  `notes` text COLLATE utf8mb4_unicode_ci,
  `hospital_id` bigint unsigned DEFAULT NULL,
  `branch_id` bigint unsigned DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `eye_prescription_sales_order_items` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `sales_order_id` bigint unsigned NOT NULL,
  `product_id` bigint unsigned NOT NULL,
  `quantity` int NOT NULL DEFAULT '1',
  `unit_price` decimal(10,2) DEFAULT NULL,
  `is_free` tinyint(1) NOT NULL DEFAULT '0',
  `notes` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `eye_prescription_sales_orders` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `eye_presription_id` bigint unsigned NOT NULL,
  `appointment_id` bigint unsigned DEFAULT NULL,
  `patient_id` bigint unsigned NOT NULL,
  `status` enum('pending','confirmed','cancelled') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `phar_pos_id` bigint unsigned DEFAULT NULL,
  `notes` text COLLATE utf8mb4_unicode_ci,
  `hospital_id` bigint unsigned DEFAULT NULL,
  `branch_id` bigint unsigned DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `eye_presriptions` (
  `id` int NOT NULL AUTO_INCREMENT,
  `appointment_id` int DEFAULT NULL,
  `patient_id` bigint unsigned DEFAULT NULL,
  `date` date DEFAULT NULL,
  `lense_material` int DEFAULT NULL,
  `lenses_advised` varchar(1000) DEFAULT NULL,
  `lenses_specification` varchar(1000) DEFAULT NULL,
  `tinted` varchar(1000) DEFAULT NULL,
  `diameter` varchar(1000) DEFAULT NULL,
  `right_ucva` int DEFAULT NULL,
  `right_sph` varchar(500) DEFAULT NULL,
  `right_cyl` varchar(500) DEFAULT NULL,
  `right_axis` varchar(500) DEFAULT NULL,
  `right_add` varchar(500) DEFAULT NULL,
  `right_prisma` varchar(500) DEFAULT NULL,
  `right_cva` int DEFAULT NULL,
  `left_ucva` int DEFAULT NULL,
  `left_sph` varchar(500) DEFAULT NULL,
  `left_cyl` varchar(500) DEFAULT NULL,
  `left_axis` varchar(500) DEFAULT NULL,
  `left_add` varchar(500) DEFAULT NULL,
  `left_prisma` varchar(500) DEFAULT NULL,
  `left_cva` int DEFAULT NULL,
  `distance_pd` varchar(255) DEFAULT NULL,
  `near_pd` varchar(255) DEFAULT NULL,
  `notes` text,
  `hospital_id` int DEFAULT NULL,
  `branch_id` int DEFAULT NULL,
  `created_by` int DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `eye_presriptions_patient_id_index` (`patient_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `eye_pupil_exam` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `appointment_id` bigint unsigned NOT NULL,
  `eye` enum('OD','OS') COLLATE utf8mb4_unicode_ci NOT NULL,
  `size_mm` decimal(4,2) DEFAULT NULL,
  `reactivity` enum('brisk','sluggish','fixed') COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `rapd` tinyint(1) NOT NULL DEFAULT '0',
  `hospital_id` bigint unsigned DEFAULT NULL,
  `branch_id` bigint unsigned DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `eye_recalls` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `patient_id` bigint unsigned NOT NULL,
  `reason` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `due_date` date NOT NULL,
  `status` enum('pending','completed','missed','cancelled') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `hospital_id` bigint unsigned DEFAULT NULL,
  `branch_id` bigint unsigned DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `eye_surgical_procedures` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `patient_id` bigint unsigned NOT NULL,
  `appointment_id` bigint unsigned DEFAULT NULL,
  `eye` enum('OD','OS','both') COLLATE utf8mb4_unicode_ci NOT NULL,
  `procedure_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `scheduled_date` date NOT NULL,
  `status` enum('planned','completed','cancelled') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'planned',
  `pre_op_notes` text COLLATE utf8mb4_unicode_ci,
  `operative_note` text COLLATE utf8mb4_unicode_ci,
  `post_op_plan` text COLLATE utf8mb4_unicode_ci,
  `hospital_id` bigint unsigned DEFAULT NULL,
  `branch_id` bigint unsigned DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `eye_visual_acuity` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `appointment_id` bigint unsigned NOT NULL,
  `eye_presription_id` bigint unsigned DEFAULT NULL,
  `eye` enum('OD','OS') COLLATE utf8mb4_unicode_ci NOT NULL,
  `va_type` enum('uncorrected','corrected','pinhole') COLLATE utf8mb4_unicode_ci NOT NULL,
  `snellen_value` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `recorded_at` timestamp NULL DEFAULT NULL,
  `hospital_id` bigint unsigned DEFAULT NULL,
  `branch_id` bigint unsigned DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `eye_visual_acuity_eye_presription_id_index` (`eye_presription_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `failed_jobs` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `uuid` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `connection` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `queue` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `payload` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
  `exception` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
  `failed_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `failed_jobs_uuid_unique` (`uuid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `fingerprint_devices_settings` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(600) DEFAULT NULL,
  `sn` varchar(600) DEFAULT NULL,
  `location` varchar(400) DEFAULT NULL,
  `branch` varchar(400) DEFAULT NULL,
  `status` enum('enabled','disabled') DEFAULT NULL,
  `is_Online` varchar(500) NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_At` timestamp NULL DEFAULT NULL,
  `last_seen` varchar(200) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `fingerprint_operlog` (
  `id` int NOT NULL AUTO_INCREMENT,
  `raw` varchar(200) DEFAULT NULL,
  `sn` varchar(200) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- @@
CREATE TABLE IF NOT EXISTS `fitness_certficates` (
  `id` int NOT NULL AUTO_INCREMENT,
  `patient_id` int NOT NULL,
  `date` date DEFAULT NULL,
  `created_by` int DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `hospital_directory` varchar(250) DEFAULT NULL,
  `doctor` int DEFAULT NULL,
  `hospital_id` int DEFAULT NULL,
  `branch_id` int DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `help_videos` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `hospital_id` bigint unsigned DEFAULT NULL,
  `title` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `youtube_id` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
  `kind` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'video',
  `module` varchar(60) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `page` varchar(120) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `permission` varchar(120) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `roles` json DEFAULT NULL,
  `users` json DEFAULT NULL,
  `sort_order` int NOT NULL DEFAULT '0',
  `enabled` tinyint(1) NOT NULL DEFAULT '1',
  `created_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `help_videos_hospital_id_index` (`hospital_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `hospitals` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(250) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `created_by` int NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `hrm_appointment_schedules` (
  `id` int NOT NULL AUTO_INCREMENT,
  `doctor_id` int NOT NULL,
  `day` varchar(200) NOT NULL,
  `from` time NOT NULL,
  `to` time NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `hrm_att_devices` (
  `id` int NOT NULL AUTO_INCREMENT,
  `no_sn` varchar(255) DEFAULT NULL,
  `online` varchar(800) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `hrm_departments` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(250) NOT NULL,
  `type` enum('health','other') DEFAULT NULL,
  `branch_id` int NOT NULL,
  `hospital_id` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `hrm_job_titles` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(250) NOT NULL,
  `type` enum('health','other') DEFAULT NULL,
  `code` varchar(250) NOT NULL,
  `job_type` enum('system','custom') DEFAULT 'system',
  `branch_id` int NOT NULL,
  `hospital_id` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `hrm_leave_policies` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(250) NOT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `status` varchar(50) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `hrm_leave_policy_leaves` (
  `id` int NOT NULL AUTO_INCREMENT,
  `leave_policy_id` int NOT NULL,
  `leave_id` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `hrm_leave_types` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(250) NOT NULL,
  `branch_id` int NOT NULL,
  `hospital_id` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `hrm_shifts` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(200) DEFAULT NULL,
  `time_in` varchar(200) DEFAULT NULL,
  `late_time` varchar(200) DEFAULT NULL,
  `time_out` varchar(200) DEFAULT NULL,
  `created_by` int DEFAULT NULL,
  `hospital_id` int DEFAULT NULL,
  `branch_id` int DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- @@
CREATE TABLE IF NOT EXISTS `hrm_staffs` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(500) NOT NULL,
  `gender` enum('male','female') DEFAULT NULL,
  `phone` varchar(50) NOT NULL,
  `job_title` int NOT NULL,
  `department` varchar(200) NOT NULL,
  `branch_id` int NOT NULL,
  `hospital_id` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `email` varchar(250) DEFAULT NULL,
  `dob` date DEFAULT NULL,
  `hire_date` date DEFAULT NULL,
  `contract_type` varchar(50) DEFAULT NULL,
  `image` varchar(1000) DEFAULT NULL,
  `signiture` varchar(200) DEFAULT NULL,
  `basic_salary` decimal(10,2) DEFAULT NULL,
  `marital_status` varchar(100) DEFAULT NULL,
  `blood_group` varchar(10) DEFAULT NULL,
  `type` varchar(250) DEFAULT NULL,
  `appointment_price` decimal(10,2) DEFAULT NULL,
  `appointment_limit` int DEFAULT NULL,
  `leave_policy` int DEFAULT NULL,
  `status` varchar(150) DEFAULT 'Enabled',
  `card_commission` decimal(10,2) DEFAULT NULL,
  `laboratory_commission` decimal(10,2) DEFAULT NULL,
  `image_commission` decimal(10,2) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `image_image_types` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(250) NOT NULL,
  `status` enum('enabled','disabled') DEFAULT 'enabled',
  `result_format` varchar(50) NOT NULL,
  `price` decimal(10,2) DEFAULT '0.00',
  `branch_id` int NOT NULL,
  `hospital_id` int NOT NULL,
  `created_by` int DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `credit_account` int DEFAULT NULL,
  `debit_account` int DEFAULT NULL,
  `is_component` varchar(10) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `image_lab_type_routines` (
  `id` int NOT NULL AUTO_INCREMENT,
  `lab_type_id` int NOT NULL,
  `routine_name` varchar(500) DEFAULT NULL,
  `uom` int DEFAULT NULL,
  `normal_range` varchar(1000) DEFAULT NULL,
  `routine_price` decimal(10,2) DEFAULT '0.00',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `result_component` varchar(500) DEFAULT NULL,
  `initial_value` text,
  `type` varchar(250) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `image_request_payments` (
  `id` int NOT NULL AUTO_INCREMENT,
  `lab_request` int NOT NULL,
  `payment_method` int NOT NULL,
  `currency` int NOT NULL,
  `exchange_rate` decimal(10,2) DEFAULT NULL,
  `payment` decimal(10,2) DEFAULT NULL,
  `discount` decimal(10,2) DEFAULT NULL,
  `promotion` decimal(10,2) DEFAULT NULL,
  `credit` decimal(10,2) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `income_account` int DEFAULT NULL,
  `credit_account` int DEFAULT NULL,
  `asset_account` int DEFAULT NULL,
  `discount_account` int DEFAULT NULL,
  `promotion_account` int DEFAULT NULL,
  `journal_id` int DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `image_request_result_images` (
  `id` int NOT NULL AUTO_INCREMENT,
  `lab_request_id` int NOT NULL,
  `name` varchar(500) NOT NULL,
  `image` text NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `image_request_results` (
  `id` int NOT NULL AUTO_INCREMENT,
  `lab_request_id` int NOT NULL,
  `routine_id` int NOT NULL,
  `result` text NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `image_request_routines` (
  `id` int NOT NULL AUTO_INCREMENT,
  `lab_request_id` int NOT NULL,
  `routine_id` int NOT NULL,
  `price` decimal(10,2) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `image_requests` (
  `id` int NOT NULL AUTO_INCREMENT,
  `type` enum('appointment','outside') NOT NULL,
  `appointment_id` int DEFAULT NULL,
  `patient` int DEFAULT NULL,
  `lab_type` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `notes` text,
  `price` decimal(10,2) DEFAULT NULL,
  `date` date DEFAULT NULL,
  `branch_id` int DEFAULT NULL,
  `hospital_id` int DEFAULT NULL,
  `status` varchar(50) DEFAULT 'Pending',
  `payment_status` varchar(150) DEFAULT 'Unpaid',
  `prepared_date` date DEFAULT NULL,
  `request_no` int NOT NULL,
  `doctor_id` int DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `image_sample_types` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(250) NOT NULL,
  `branch_id` int NOT NULL,
  `hospital_id` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `image_settings` (
  `id` int NOT NULL AUTO_INCREMENT,
  `income_account` int DEFAULT NULL,
  `asset_account` int DEFAULT NULL,
  `discount_account` int DEFAULT NULL,
  `promotion_account` int DEFAULT NULL,
  `created_by` int NOT NULL,
  `branch_id` int DEFAULT NULL,
  `hospital_id` int DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `credit_allowed` varchar(20) DEFAULT NULL,
  `credit_account` int DEFAULT NULL,
  `promotion_allowed` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `image_test_uoms` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(250) NOT NULL,
  `status` enum('enabled','disabled') DEFAULT 'enabled',
  `branch_id` int NOT NULL,
  `hospital_id` int NOT NULL,
  `created_by` int DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `image_types` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(250) NOT NULL,
  `status` enum('enabled','disabled') DEFAULT 'enabled',
  `result_format` varchar(50) NOT NULL,
  `price` decimal(10,2) DEFAULT '0.00',
  `branch_id` int NOT NULL,
  `hospital_id` int NOT NULL,
  `created_by` int DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `credit_account` int DEFAULT NULL,
  `debit_account` int DEFAULT NULL,
  `is_component` varchar(10) DEFAULT NULL,
  `doctor_result` enum('No','Yes') DEFAULT NULL,
  `report_template` enum('ultrasound_obstetric','ultrasound_general','xray','generic') NOT NULL DEFAULT 'generic',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `imaging_reports` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `imaging_request_id` bigint unsigned NOT NULL,
  `report_category` enum('ultrasound_obstetric','ultrasound_general','xray','generic') COLLATE utf8mb4_unicode_ci NOT NULL,
  `reporting_doctor_id` bigint unsigned DEFAULT NULL,
  `findings` text COLLATE utf8mb4_unicode_ci,
  `impression` text COLLATE utf8mb4_unicode_ci,
  `conclusion` text COLLATE utf8mb4_unicode_ci,
  `next_appointment_date` date DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Draft',
  `created_by` bigint unsigned DEFAULT NULL,
  `branch_id` bigint unsigned DEFAULT NULL,
  `hospital_id` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `imaging_reports_imaging_request_id_index` (`imaging_request_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `income_types` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `income_account` bigint unsigned DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'enabled',
  `created_by` bigint unsigned DEFAULT NULL,
  `hospital_id` bigint unsigned DEFAULT NULL,
  `branch_id` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `incomes` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `category` bigint unsigned NOT NULL,
  `date` date NOT NULL,
  `description` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `amount` decimal(12,2) NOT NULL,
  `payment_type` bigint unsigned DEFAULT NULL,
  `currency` bigint unsigned DEFAULT NULL,
  `exchange_rate` decimal(12,4) DEFAULT NULL,
  `source` bigint unsigned DEFAULT NULL,
  `income_account` bigint unsigned DEFAULT NULL,
  `cash_account` bigint unsigned DEFAULT NULL,
  `is_cash` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `journal` bigint unsigned DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'enabled',
  `created_by` bigint unsigned DEFAULT NULL,
  `hospital_id` bigint unsigned DEFAULT NULL,
  `branch_id` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `inp_room_type_role` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `room_type_id` bigint unsigned NOT NULL,
  `role_id` bigint unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `inp_room_type_role_room_type_id_role_id_unique` (`room_type_id`,`role_id`),
  KEY `inp_room_type_role_room_type_id_index` (`room_type_id`),
  KEY `inp_room_type_role_role_id_index` (`role_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `inp_room_types` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(250) NOT NULL,
  `status` varchar(50) NOT NULL,
  `users` text,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `inp_rooms` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(250) NOT NULL,
  `room_type` int NOT NULL,
  `no_beds` int NOT NULL,
  `cost` decimal(10,2) NOT NULL,
  `status` varchar(50) NOT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `inventory_adjustments` (
  `id` int NOT NULL AUTO_INCREMENT,
  `product_id` int NOT NULL,
  `cost` decimal(10,2) NOT NULL,
  `type` varchar(50) NOT NULL,
  `adjustment_rate` decimal(10,2) NOT NULL,
  `reason` varchar(255) DEFAULT NULL,
  `uom` int NOT NULL,
  `store` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `invoice_settings` (
  `id` int NOT NULL AUTO_INCREMENT,
  `cash_account` int DEFAULT NULL,
  `receivable_account` int DEFAULT NULL,
  `income_account` int DEFAULT NULL,
  `discount_account` int NOT NULL,
  `promotion_account` int NOT NULL,
  `invoice_prefix` varchar(250) DEFAULT NULL,
  `created_by` int NOT NULL,
  `branch_id` int DEFAULT NULL,
  `company_id` int DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `promotion_allowed` varchar(200) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `journal_entries` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `date` date NOT NULL,
  `reference` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `journal_id` int NOT NULL DEFAULT '0',
  `created_by` int NOT NULL DEFAULT '0',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `branch_id` int NOT NULL,
  `hospital_id` int NOT NULL,
  `status` enum('open','posted') DEFAULT NULL,
  `reference_id` int DEFAULT NULL,
  `currency` int DEFAULT NULL,
  `exchange_rate` decimal(10,2) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `journal_items` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `journal` int NOT NULL DEFAULT '0',
  `account` int NOT NULL DEFAULT '0',
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `debit` decimal(10,2) DEFAULT NULL,
  `credit` decimal(10,2) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `journals` (
  `id` int NOT NULL AUTO_INCREMENT,
  `jour_date` date NOT NULL,
  `status` enum('open','posted') DEFAULT NULL,
  `branch_id` int NOT NULL,
  `hospital_id` int NOT NULL,
  `created_by` int NOT NULL COMMENT 'The person who always starts the work first',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `lab_analyzer_messages` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `device` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `remote_ip` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `raw_message` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'received',
  `lab_request_id` bigint unsigned DEFAULT NULL,
  `note` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `lab_lab_type_routines` (
  `id` int NOT NULL AUTO_INCREMENT,
  `lab_type_id` int NOT NULL,
  `routine_name` varchar(500) DEFAULT NULL,
  `uom` int DEFAULT NULL,
  `normal_range` varchar(1000) DEFAULT NULL,
  `routine_price` decimal(10,2) DEFAULT '0.00',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `result_component` varchar(500) DEFAULT NULL,
  `initial_value` text,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `lab_lab_types` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(250) NOT NULL,
  `status` enum('enabled','disabled') DEFAULT 'enabled',
  `result_format` varchar(50) NOT NULL,
  `sort_order` int unsigned DEFAULT NULL,
  `price` decimal(10,2) DEFAULT '0.00',
  `branch_id` int NOT NULL,
  `hospital_id` int NOT NULL,
  `created_by` int DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `credit_account` int DEFAULT NULL,
  `debit_account` int DEFAULT NULL,
  `is_component` varchar(10) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `lab_request_payments` (
  `id` int NOT NULL AUTO_INCREMENT,
  `lab_request` int NOT NULL,
  `payment_method` int NOT NULL,
  `currency` int NOT NULL,
  `exchange_rate` decimal(10,2) DEFAULT NULL,
  `payment` decimal(10,2) DEFAULT NULL,
  `discount` decimal(10,2) DEFAULT NULL,
  `promotion` decimal(10,2) DEFAULT NULL,
  `credit` decimal(10,2) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `income_account` int DEFAULT NULL,
  `credit_account` int DEFAULT NULL,
  `asset_account` int DEFAULT NULL,
  `discount_account` int DEFAULT NULL,
  `promotion_account` int DEFAULT NULL,
  `journal_id` int DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `lab_request_result_images` (
  `id` int NOT NULL AUTO_INCREMENT,
  `lab_request_id` int NOT NULL,
  `name` varchar(500) NOT NULL,
  `image` text NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `lab_request_results` (
  `id` int NOT NULL AUTO_INCREMENT,
  `lab_request_id` int NOT NULL,
  `routine_id` int NOT NULL,
  `result` text NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `lab_request_routines` (
  `id` int NOT NULL AUTO_INCREMENT,
  `lab_request_id` int NOT NULL,
  `routine_id` int NOT NULL,
  `price` decimal(10,2) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `lab_request_settings` (
  `id` int NOT NULL AUTO_INCREMENT,
  `income_account` int NOT NULL,
  `cash_account` int NOT NULL,
  `discount_account` int NOT NULL,
  `promotion_account` int NOT NULL,
  `credit_account` int NOT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `lab_requests` (
  `id` int NOT NULL AUTO_INCREMENT,
  `type` enum('appointment','outside') NOT NULL,
  `appointment_id` int DEFAULT NULL,
  `admission_id` bigint unsigned DEFAULT NULL,
  `emergency_id` bigint unsigned DEFAULT NULL,
  `patient` int DEFAULT NULL,
  `lab_type` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `notes` text,
  `price` decimal(10,2) DEFAULT NULL,
  `date` date DEFAULT NULL,
  `branch_id` int DEFAULT NULL,
  `hospital_id` int DEFAULT NULL,
  `status` varchar(50) DEFAULT 'Pending',
  `payment_status` varchar(150) DEFAULT 'Unpaid',
  `prepared_date` date DEFAULT NULL,
  `request_no` int NOT NULL,
  `sample_id` varchar(30) DEFAULT NULL,
  `doctor_id` int DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `lab_requests_sample_id_unique` (`sample_id`),
  KEY `lab_requests_admission_id_index` (`admission_id`),
  KEY `lab_requests_emergency_id_index` (`emergency_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `lab_sample_types` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(250) NOT NULL,
  `branch_id` int NOT NULL,
  `hospital_id` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `lab_settings` (
  `id` int NOT NULL AUTO_INCREMENT,
  `income_account` int DEFAULT NULL,
  `asset_account` int DEFAULT NULL,
  `discount_account` int DEFAULT NULL,
  `promotion_account` int DEFAULT NULL,
  `created_by` int NOT NULL,
  `branch_id` int DEFAULT NULL,
  `hospital_id` int DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `credit_allowed` varchar(20) DEFAULT NULL,
  `credit_account` int DEFAULT NULL,
  `promotion_allowed` varchar(50) DEFAULT NULL,
  `commission_account` int NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `lab_test_uoms` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(250) NOT NULL,
  `status` enum('enabled','disabled') DEFAULT 'enabled',
  `branch_id` int NOT NULL,
  `hospital_id` int NOT NULL,
  `created_by` int DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `leads` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `contact` varchar(250) COLLATE utf8mb4_unicode_ci NOT NULL,
  `company` varchar(250) COLLATE utf8mb4_unicode_ci NOT NULL,
  `address` varchar(250) COLLATE utf8mb4_unicode_ci NOT NULL,
  `lead_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `lead_priority` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `lead_source` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `flow_ups` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `intrests` varchar(250) COLLATE utf8mb4_unicode_ci NOT NULL,
  `notes` varchar(250) COLLATE utf8mb4_unicode_ci NOT NULL,
  `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `role` varchar(250) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email` varchar(250) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `website` varchar(250) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `phone` varchar(250) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `state` varchar(250) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `image` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `company_id` int DEFAULT NULL,
  `branch_id` int DEFAULT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_by` int DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `date` date DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `lense_materials` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(250) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `login_logs` (
  `id` int NOT NULL AUTO_INCREMENT,
  `user_id` int DEFAULT NULL,
  `session_id` varchar(255) DEFAULT NULL,
  `ip` varchar(200) DEFAULT NULL,
  `browser` varchar(200) DEFAULT NULL,
  `device` varchar(200) DEFAULT NULL,
  `login_at` timestamp NULL DEFAULT NULL,
  `logout_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- @@
CREATE TABLE IF NOT EXISTS `medical_reports` (
  `id` int NOT NULL AUTO_INCREMENT,
  `patient_id` int NOT NULL,
  `date` date DEFAULT NULL,
  `diagnosis` text,
  `treatment` text,
  `recommendation` text,
  `hospital_directory` varchar(500) DEFAULT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_by` int DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `migrations` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `migration` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `batch` int NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `mobile_push_tokens` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint unsigned NOT NULL,
  `token` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `platform` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `device_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `last_used_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `mobile_push_tokens_token_unique` (`token`),
  KEY `mobile_push_tokens_user_id_index` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `model_has_permissions` (
  `permission_id` bigint unsigned NOT NULL,
  `model_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `model_id` bigint unsigned NOT NULL,
  PRIMARY KEY (`permission_id`,`model_id`,`model_type`),
  KEY `model_has_permissions_model_id_model_type_index` (`model_id`,`model_type`),
  CONSTRAINT `model_has_permissions_permission_id_foreign` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `model_has_roles` (
  `role_id` bigint unsigned NOT NULL,
  `model_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `model_id` bigint unsigned NOT NULL,
  PRIMARY KEY (`role_id`,`model_id`,`model_type`),
  KEY `model_has_roles_model_id_model_type_index` (`model_id`,`model_type`),
  CONSTRAINT `model_has_roles_role_id_foreign` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `notification_rules` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `event` varchar(60) COLLATE utf8mb4_unicode_ci NOT NULL,
  `enabled` tinyint(1) NOT NULL DEFAULT '1',
  `roles` json DEFAULT NULL,
  `users` json DEFAULT NULL,
  `notify_doctor` tinyint(1) NOT NULL DEFAULT '0',
  `notify_requester` tinyint(1) NOT NULL DEFAULT '0',
  `updated_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `notification_rules_event_unique` (`event`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `notifications` (
  `id` char(36) COLLATE utf8mb4_unicode_ci NOT NULL,
  `type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `notifiable_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `notifiable_id` bigint unsigned NOT NULL,
  `data` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `read_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `notifications_notifiable_type_notifiable_id_index` (`notifiable_type`,`notifiable_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `operation_categories` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(250) NOT NULL,
  `status` varchar(50) NOT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `operation_intras` (
  `id` int NOT NULL AUTO_INCREMENT,
  `operation_id` int NOT NULL,
  `date` date NOT NULL,
  `time` time NOT NULL,
  `operating_doctor` int NOT NULL,
  `anesthetist` text NOT NULL,
  `assistant` int NOT NULL,
  `induction_drug` text,
  `maintenance_drug` text,
  `operative_drug` text,
  `surgery_time` time DEFAULT NULL,
  `blood_loss` text,
  `patient_condition` text,
  `special_instructions` text,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `assistant_2` int DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `operation_observations` (
  `id` int NOT NULL AUTO_INCREMENT,
  `operation_id` int NOT NULL,
  `date` date NOT NULL,
  `time` time NOT NULL,
  `blood_pressure` text,
  `pulse` text,
  `temperature` text,
  `respiratory` text,
  `notes` text,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `operation_payments` (
  `id` int NOT NULL AUTO_INCREMENT,
  `operation_id` int NOT NULL,
  `payment` decimal(10,2) DEFAULT NULL,
  `discount` decimal(10,2) DEFAULT NULL,
  `promotion` decimal(10,2) DEFAULT NULL,
  `credit` decimal(10,2) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `operation_posts` (
  `id` int NOT NULL AUTO_INCREMENT,
  `operation_id` int NOT NULL,
  `provisional_diagnosis` text,
  `definitive_diagnosis` text,
  `surgical_procedure` text,
  `procedure_report` text,
  `post_operative_order` text,
  `post_operative_intensive` text,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `operation_pres` (
  `id` int NOT NULL AUTO_INCREMENT,
  `operation_id` int NOT NULL,
  `date` date NOT NULL,
  `time` time NOT NULL,
  `anesthesia_type` varchar(150) DEFAULT NULL,
  `informed_consent` varchar(50) DEFAULT NULL,
  `shaving` varchar(50) DEFAULT NULL,
  `catheterisation` varchar(50) DEFAULT NULL,
  `fasting` varchar(50) DEFAULT NULL,
  `iv_line_fixed` varchar(50) DEFAULT NULL,
  `iv_line_running` varchar(50) DEFAULT NULL,
  `hb` text,
  `blood_group` text,
  `blood_units` text,
  `fasting_blood_sugar` text,
  `random_blood_sugar` text,
  `others` text,
  `allergy` text,
  `allergt_text` text,
  `chronic_illness` text,
  `chronic_illness_text` text,
  `anesthetic_risk` text,
  `anesthetic_risk_text` text,
  `blood_pressure` text,
  `pulse` text,
  `temperature` text,
  `respiratory` text,
  `weight` text,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `operation_settings` (
  `id` int NOT NULL AUTO_INCREMENT,
  `income_account` int NOT NULL,
  `cash_account` int NOT NULL,
  `discount_account` int NOT NULL,
  `promotion_account` int NOT NULL,
  `credit_account` int NOT NULL,
  `credit_allowed` enum('Yes','No') NOT NULL,
  `created_by` int NOT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `operation_subcategories` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(250) NOT NULL,
  `status` varchar(50) NOT NULL,
  `category` int NOT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `operation_types` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(250) NOT NULL,
  `rate` decimal(10,2) DEFAULT NULL,
  `category` int NOT NULL,
  `subcategory` int NOT NULL,
  `status` varchar(50) NOT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `operations` (
  `id` int NOT NULL AUTO_INCREMENT,
  `date` date NOT NULL,
  `appointment_id` int DEFAULT NULL,
  `admission_id` bigint unsigned DEFAULT NULL,
  `patient` int DEFAULT NULL,
  `dr` int DEFAULT NULL,
  `type` enum('appointment','Outside','admission') DEFAULT NULL,
  `operation` int NOT NULL,
  `rate` decimal(10,2) DEFAULT NULL,
  `notes` text,
  `payment_status` varchar(100) DEFAULT NULL,
  `status` varchar(100) DEFAULT NULL,
  `payment` decimal(10,2) DEFAULT NULL,
  `discount` decimal(10,2) DEFAULT NULL,
  `promotion` decimal(10,2) DEFAULT NULL,
  `credit` decimal(10,2) DEFAULT NULL,
  `payment_method` int DEFAULT NULL,
  `currency` int DEFAULT NULL,
  `exchange_rate` decimal(10,2) DEFAULT NULL,
  `operation_number` int NOT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `category` int DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `operations_admission_id_index` (`admission_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `orthodentic_categories` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(500) NOT NULL,
  `price` decimal(10,2) DEFAULT NULL,
  `status` varchar(50) DEFAULT NULL,
  `branch_id` int NOT NULL,
  `hospital_id` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `orthodentic_payments` (
  `id` int NOT NULL AUTO_INCREMENT,
  `orthodentic_id` int NOT NULL,
  `payment` decimal(10,2) DEFAULT NULL,
  `discount` decimal(10,2) DEFAULT NULL,
  `promotion` decimal(10,2) DEFAULT NULL,
  `currency` int DEFAULT NULL,
  `exchange_rate` decimal(10,2) DEFAULT NULL,
  `payment_method` int NOT NULL,
  `income_account` int NOT NULL,
  `cash_account` int NOT NULL,
  `discount_account` int NOT NULL,
  `promotion_account` int NOT NULL,
  `journal_id` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `orthodentic_settings` (
  `id` int NOT NULL AUTO_INCREMENT,
  `income_account` int NOT NULL,
  `cash_account` int NOT NULL,
  `discount_account` int NOT NULL,
  `promotion_account` int NOT NULL,
  `credit_account` int NOT NULL,
  `credit_allowed` enum('Yes','No') NOT NULL,
  `created_by` int NOT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `promotion_allowed` varchar(50) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `orthodentics` (
  `id` int NOT NULL AUTO_INCREMENT,
  `date` date NOT NULL,
  `type` varchar(500) DEFAULT NULL,
  `appointment_id` int DEFAULT NULL,
  `patient_id` int DEFAULT NULL,
  `category_id` int NOT NULL,
  `price` decimal(10,2) DEFAULT NULL,
  `notes` text,
  `status` varchar(200) DEFAULT NULL,
  `payment_status` varchar(200) DEFAULT NULL,
  `created_by` int NOT NULL,
  `branch_id` int NOT NULL,
  `hospital_id` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `password_reset_tokens` (
  `email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `token` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `patient_conditions` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(150) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `patient_payments` (
  `id` int NOT NULL AUTO_INCREMENT,
  `reference_id` int NOT NULL,
  `reference` text,
  `payment_amount` decimal(10,2) DEFAULT NULL,
  `discount` decimal(10,2) DEFAULT NULL,
  `promotion` decimal(10,2) DEFAULT NULL,
  `credit` decimal(10,2) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `patient_progress_notes` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `patient_id` bigint unsigned DEFAULT NULL,
  `admission_id` bigint unsigned NOT NULL,
  `date` date NOT NULL,
  `time` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `doctor_id` bigint unsigned DEFAULT NULL,
  `subjective_note` text COLLATE utf8mb4_unicode_ci,
  `objective_note` text COLLATE utf8mb4_unicode_ci,
  `assessment` text COLLATE utf8mb4_unicode_ci,
  `treatment_plan` text COLLATE utf8mb4_unicode_ci,
  `blood_pressure` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `temperature` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `pulse` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `respiratory_rate` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `oxygen_saturation` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `medications_given` text COLLATE utf8mb4_unicode_ci,
  `procedures_done` text COLLATE utf8mb4_unicode_ci,
  `note` text COLLATE utf8mb4_unicode_ci,
  `follow_up_date` date DEFAULT NULL,
  `status` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `hospital_id` bigint unsigned DEFAULT NULL,
  `branch_id` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `patient_progress_notes_patient_id_index` (`patient_id`),
  KEY `patient_progress_notes_admission_id_index` (`admission_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `patient_settings` (
  `id` int NOT NULL AUTO_INCREMENT,
  `patient_id` varchar(500) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `patients` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(500) NOT NULL,
  `patient_id` varchar(150) DEFAULT NULL,
  `gender` enum('male','female') DEFAULT NULL,
  `phone` varchar(200) DEFAULT NULL,
  `dob` date NOT NULL,
  `address` varchar(1000) DEFAULT NULL,
  `marital_status` varchar(50) DEFAULT NULL,
  `gravida` smallint unsigned DEFAULT NULL,
  `para` smallint unsigned DEFAULT NULL,
  `para_plus` tinyint unsigned DEFAULT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `image` varchar(500) DEFAULT NULL,
  `age` decimal(10,2) DEFAULT NULL,
  `age_type` varchar(50) DEFAULT NULL,
  `type` varchar(50) DEFAULT 'patient',
  `credit_limit` decimal(10,2) DEFAULT '0.00',
  `opening_balance` decimal(10,2) DEFAULT '0.00',
  `status` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `payments` (
  `id` int NOT NULL AUTO_INCREMENT,
  `reference_id` int NOT NULL,
  `reference` varchar(100) NOT NULL,
  `payment` decimal(10,2) DEFAULT NULL,
  `discount` decimal(10,2) DEFAULT NULL,
  `promotion` decimal(10,2) DEFAULT NULL,
  `commissions` decimal(10,2) DEFAULT NULL,
  `sponsor` decimal(10,2) DEFAULT NULL,
  `description` text,
  `status` varchar(50) DEFAULT NULL,
  `currency` int DEFAULT NULL,
  `exchange_rate` decimal(10,2) DEFAULT NULL,
  `payment_method` int NOT NULL,
  `income_account` int NOT NULL,
  `cash_account` int NOT NULL,
  `discount_account` int NOT NULL,
  `promotion_account` int NOT NULL,
  `credit_account` int DEFAULT NULL,
  `journal_id` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `payroll_attendances` (
  `id` int NOT NULL AUTO_INCREMENT,
  `staff_id` varchar(200) DEFAULT NULL,
  `shift_id` varchar(200) DEFAULT NULL,
  `date` varchar(200) DEFAULT NULL,
  `time_in` varchar(200) DEFAULT NULL,
  `time_out` varchar(200) DEFAULT NULL,
  `overtime_minutes` varchar(200) DEFAULT NULL,
  `late_minutes` varchar(200) DEFAULT NULL,
  `early_minutes` varchar(200) DEFAULT NULL,
  `worked_hours` varchar(200) DEFAULT NULL,
  `remaining_minutes` varchar(200) DEFAULT NULL,
  `status` varchar(200) DEFAULT NULL,
  `created_by` varchar(200) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `payroll_run_details` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `payroll_run_id` bigint unsigned NOT NULL,
  `staff_id` bigint unsigned NOT NULL,
  `basic_salary` decimal(12,2) NOT NULL DEFAULT '0.00',
  `commission_percent` decimal(5,2) NOT NULL DEFAULT '0.00',
  `commission_amount` decimal(12,2) NOT NULL DEFAULT '0.00',
  `deduction_percent` decimal(5,2) NOT NULL DEFAULT '0.00',
  `deduction_amount` decimal(12,2) NOT NULL DEFAULT '0.00',
  `total` decimal(12,2) NOT NULL DEFAULT '0.00',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `payroll_run_details_payroll_run_id_foreign` (`payroll_run_id`),
  CONSTRAINT `payroll_run_details_payroll_run_id_foreign` FOREIGN KEY (`payroll_run_id`) REFERENCES `payroll_runs` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `payroll_runs` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `commission_percent` decimal(5,2) NOT NULL DEFAULT '0.00',
  `deduction_percent` decimal(5,2) NOT NULL DEFAULT '0.00',
  `notes` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `hospital_id` bigint unsigned DEFAULT NULL,
  `branch_id` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `permissions` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `guard_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `title` varchar(250) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `group` varchar(250) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `module` varchar(150) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `permissions_name_guard_name_unique` (`name`,`guard_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `personal_access_tokens` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `tokenable_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `tokenable_id` bigint unsigned NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `token` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
  `abilities` text COLLATE utf8mb4_unicode_ci,
  `last_used_at` timestamp NULL DEFAULT NULL,
  `expires_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `personal_access_tokens_token_unique` (`token`),
  KEY `personal_access_tokens_tokenable_type_tokenable_id_index` (`tokenable_type`,`tokenable_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `phar_customer_payments` (
  `id` int NOT NULL AUTO_INCREMENT,
  `customer_id` int NOT NULL,
  `payment` decimal(10,2) NOT NULL,
  `discount` decimal(10,2) NOT NULL,
  `receivable_account` int DEFAULT NULL,
  `cash_account` int DEFAULT NULL,
  `discount_account` int DEFAULT NULL,
  `currency` int DEFAULT NULL,
  `exchange_rate` decimal(10,2) DEFAULT NULL,
  `payment_method` int NOT NULL,
  `journal_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `hospital_id` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `pos_date` date DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `phar_customers` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(500) NOT NULL,
  `phone` varchar(100) NOT NULL,
  `opening_balance` decimal(10,2) DEFAULT NULL,
  `credit_limit` decimal(10,2) DEFAULT NULL,
  `status` varchar(50) DEFAULT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `journal_id` int DEFAULT NULL,
  `receivable_account` int DEFAULT NULL,
  `income_account` int DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `phar_dosage_forms` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(250) NOT NULL,
  `status` varchar(50) NOT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `phar_dosages` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(250) NOT NULL,
  `status` varchar(50) NOT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `phar_pos` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `pos_id` bigint unsigned NOT NULL DEFAULT '0',
  `customer_id` bigint unsigned NOT NULL DEFAULT '0',
  `pos_date` date DEFAULT NULL,
  `status` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `is_complete` int DEFAULT '0',
  `cash_close_id` int DEFAULT NULL,
  `journal_id` int DEFAULT NULL,
  `is_deleted` int DEFAULT '0',
  `deleted_by` int DEFAULT '0',
  `prescription_id` int DEFAULT '0',
  `description` text COLLATE utf8mb4_unicode_ci,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `phar_pos_payments` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `pos_id` int NOT NULL,
  `date` date DEFAULT NULL,
  `amount` decimal(10,2) DEFAULT NULL,
  `debit` decimal(10,2) DEFAULT NULL,
  `discount` decimal(10,2) DEFAULT NULL,
  `promotion` decimal(10,2) DEFAULT NULL,
  `tax` decimal(10,2) DEFAULT NULL,
  `created_by` int NOT NULL DEFAULT '0',
  `payment_method` varchar(200) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `currency` int NOT NULL,
  `exchange_rate` decimal(10,2) DEFAULT NULL,
  `cash_account` int DEFAULT NULL,
  `receivable_account` int DEFAULT NULL,
  `inventory_account` int DEFAULT NULL,
  `income_account` int DEFAULT NULL,
  `discount_account` int DEFAULT NULL,
  `cogs_account` int DEFAULT NULL,
  `journal_id` int DEFAULT NULL,
  `refund_of` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `phar_pos_payments_refund_of_index` (`refund_of`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `phar_pos_products` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `pos_id` int NOT NULL DEFAULT '0',
  `store_id` int DEFAULT '0',
  `product_id` int NOT NULL DEFAULT '0',
  `quantity` decimal(10,2) DEFAULT NULL,
  `tax` varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0.00',
  `discount` double(8,2) NOT NULL DEFAULT '0.00',
  `price` text,
  `cost` decimal(10,4) DEFAULT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `uom` int NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `phar_pos_taxes` (
  `id` int NOT NULL AUTO_INCREMENT,
  `pos_id` int NOT NULL,
  `tax_id` int NOT NULL,
  `rate` float NOT NULL,
  `amount` float NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `phar_sales_return_details` (
  `id` int NOT NULL AUTO_INCREMENT,
  `po_id` int NOT NULL,
  `product` int NOT NULL,
  `quantity` decimal(10,2) NOT NULL,
  `uom` int NOT NULL,
  `unit_price` decimal(10,2) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `product_id_fk_idx` (`product`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `phar_sales_returns` (
  `id` int NOT NULL AUTO_INCREMENT,
  `date` date NOT NULL,
  `name` varchar(500) NOT NULL,
  `status` varchar(50) NOT NULL,
  `customer` int NOT NULL,
  `invoice_id` int DEFAULT NULL,
  `description` text,
  `created_by` int NOT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `phar_stores` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(250) NOT NULL,
  `manager` int NOT NULL,
  `users` text,
  `status` varchar(50) NOT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `po_settings` (
  `id` int NOT NULL AUTO_INCREMENT,
  `cash_account` int DEFAULT NULL,
  `inventory_account` int DEFAULT NULL,
  `payable_account` int DEFAULT NULL,
  `inventory_by_product` varchar(50) DEFAULT NULL,
  `created_by` int NOT NULL,
  `branch_id` int DEFAULT NULL,
  `hospital_id` int DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `pos_settings` (
  `id` int NOT NULL AUTO_INCREMENT,
  `cash_account` int NOT NULL,
  `income_account` int NOT NULL,
  `inventory_account` int NOT NULL,
  `cogs_account` int NOT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `discount_account` int NOT NULL,
  `receivable_account` int NOT NULL,
  `bulk_account` int NOT NULL,
  `adjustment_account` int DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `post_deliveries` (
  `id` int NOT NULL AUTO_INCREMENT,
  `delivery_id` int NOT NULL,
  `delivery_mode` int NOT NULL,
  `dob` date DEFAULT NULL,
  `dob_time` time DEFAULT NULL,
  `baby_weight` text,
  `baby_sex` text,
  `apgar_score` text,
  `placenta_expressed` text,
  `episiotomy` text,
  `repaired` text,
  `complication` text,
  `complication_text` text,
  `midwife` int DEFAULT NULL,
  `supervisor` int DEFAULT NULL,
  `created_by` int NOT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `pre_deliveries` (
  `id` int NOT NULL AUTO_INCREMENT,
  `delivery_id` int NOT NULL,
  `date` date NOT NULL,
  `time` time NOT NULL,
  `fhr` text,
  `vulva_condition` text,
  `cervical_dilation` text,
  `cervical_effacement` text,
  `descent` text,
  `membrane_condition` text,
  `presentation` text,
  `notes` text,
  `created_by` int NOT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `pres_prescription_details` (
  `id` int NOT NULL AUTO_INCREMENT,
  `head_id` varchar(250) NOT NULL,
  `drug` int NOT NULL,
  `quantity` decimal(10,2) DEFAULT NULL,
  `price` varchar(200) DEFAULT NULL,
  `dose` varchar(350) DEFAULT NULL,
  `duration` varchar(200) DEFAULT NULL,
  `dosage_form` int DEFAULT NULL,
  `instruction` text,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `frequency` int DEFAULT NULL,
  `uom` int NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `pres_prescription_heads` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(250) NOT NULL,
  `type` varchar(20) NOT NULL DEFAULT 'OP',
  `appointment_id` int DEFAULT NULL,
  `admission_id` bigint unsigned DEFAULT NULL,
  `emergency_id` bigint unsigned DEFAULT NULL,
  `date` date DEFAULT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `prescription_no` varchar(550) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `pres_prescription_heads_admission_id_index` (`admission_id`),
  KEY `pres_prescription_heads_emergency_id_index` (`emergency_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `refferel_letters` (
  `id` int NOT NULL AUTO_INCREMENT,
  `patient_id` int NOT NULL,
  `date` date DEFAULT NULL,
  `to` text,
  `type` text,
  `description` text,
  `hospital_directory` varchar(500) DEFAULT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_by` int DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `report_centers` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(500) NOT NULL,
  `description` text,
  `procedure_name` text NOT NULL,
  `permission` varchar(150) DEFAULT NULL,
  `meta` varchar(1000) DEFAULT NULL,
  `category` varchar(200) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `report_prameters` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(500) NOT NULL,
  `label` varchar(500) NOT NULL,
  `type` enum('text','select','date') NOT NULL,
  `placeholder` text,
  `report_id` int NOT NULL,
  `value_type` enum('raw','qeury') NOT NULL,
  `values` text NOT NULL,
  `parent_id` int NOT NULL,
  `default_value` varchar(500) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `report_recipients` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL,
  `staff_id` bigint unsigned DEFAULT NULL,
  `phone` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `send_sms` tinyint(1) NOT NULL DEFAULT '1',
  `send_email` tinyint(1) NOT NULL DEFAULT '0',
  `reports` json DEFAULT NULL,
  `income_types` json DEFAULT NULL,
  `frequency` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'daily',
  `weekday` tinyint unsigned DEFAULT NULL,
  `covers` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'today',
  `send_time` varchar(5) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '21:00',
  `branch_id` bigint unsigned DEFAULT NULL,
  `enabled` tinyint(1) NOT NULL DEFAULT '1',
  `last_sent_on` date DEFAULT NULL,
  `hospital_id` bigint unsigned NOT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `report_send_logs` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `recipient_id` bigint unsigned DEFAULT NULL,
  `channel` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL,
  `to` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `subject` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `message` text COLLATE utf8mb4_unicode_ci,
  `status` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL,
  `response` text COLLATE utf8mb4_unicode_ci,
  `hospital_id` bigint unsigned DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `report_send_logs_hospital_id_created_at_index` (`hospital_id`,`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `role_has_permissions` (
  `permission_id` bigint unsigned NOT NULL,
  `role_id` bigint unsigned NOT NULL,
  PRIMARY KEY (`permission_id`,`role_id`),
  KEY `role_has_permissions_role_id_foreign` (`role_id`),
  CONSTRAINT `role_has_permissions_permission_id_foreign` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`id`) ON DELETE CASCADE,
  CONSTRAINT `role_has_permissions_role_id_foreign` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `roles` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `guard_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `cash_desk` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `roles_name_guard_name_unique` (`name`,`guard_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `scm_Subcategories` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(250) NOT NULL,
  `category_id` int NOT NULL,
  `status` varchar(50) NOT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `scm_categories` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(250) NOT NULL,
  `status` varchar(50) NOT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `scm_po_payments` (
  `id` int NOT NULL AUTO_INCREMENT,
  `po_id` int DEFAULT NULL,
  `payment_amount` text NOT NULL,
  `payment_method` int NOT NULL,
  `currency` int NOT NULL,
  `exchange_rate` decimal(10,2) DEFAULT NULL,
  `created_by` varchar(200) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `scm_product_measurements` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(500) NOT NULL,
  `status` varchar(50) NOT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `scm_product_types` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(250) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `scm_products` (
  `id` int NOT NULL AUTO_INCREMENT,
  `barcode` varchar(500) DEFAULT NULL,
  `generic_name` varchar(1000) DEFAULT NULL,
  `name` varchar(500) NOT NULL,
  `type` int NOT NULL,
  `category_id` int NOT NULL,
  `subcategory_id` int DEFAULT NULL,
  `image` varchar(1000) DEFAULT NULL,
  `status` varchar(50) NOT NULL,
  `track_expiration` enum('yes','no') NOT NULL DEFAULT 'no',
  `reorder_level` decimal(12,2) DEFAULT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `measurement` int DEFAULT NULL,
  `selling_measurement` int DEFAULT NULL,
  `selling_conversion` decimal(10,2) DEFAULT NULL,
  `purchase_conversion` decimal(10,2) DEFAULT NULL,
  `purchase_measurement` int DEFAULT NULL,
  `selling_price` decimal(10,2) DEFAULT NULL,
  `cost_price` decimal(10,2) DEFAULT NULL,
  `description` varchar(500) DEFAULT NULL,
  `discount_price` decimal(10,2) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `scm_purchase_order_details` (
  `id` int NOT NULL AUTO_INCREMENT,
  `po_id` int NOT NULL,
  `product` int NOT NULL,
  `quantity` decimal(10,2) NOT NULL,
  `uom` int NOT NULL,
  `unit_price` decimal(10,2) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `product_id_fk_idx` (`product`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `scm_purchase_orders` (
  `id` int NOT NULL AUTO_INCREMENT,
  `date` date NOT NULL,
  `name` varchar(500) NOT NULL,
  `status` varchar(50) NOT NULL,
  `supplier` int NOT NULL,
  `store_id` bigint unsigned DEFAULT NULL,
  `notes` text,
  `invoice_file` varchar(255) DEFAULT NULL,
  `payment_status` varchar(50) NOT NULL,
  `created_by` int NOT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `scm_purchase_receive_details` (
  `id` int NOT NULL AUTO_INCREMENT,
  `receive_id` int NOT NULL,
  `product` int NOT NULL,
  `quantity` decimal(10,2) NOT NULL,
  `store_id` int DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `expiration_date` varchar(250) DEFAULT NULL,
  `status` enum('Received','Returned') DEFAULT 'Received',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `scm_purchase_receives` (
  `id` int NOT NULL AUTO_INCREMENT,
  `date` date NOT NULL,
  `name` varchar(500) NOT NULL,
  `po_id` int NOT NULL,
  `created_by` int NOT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `scm_purchase_return_details` (
  `id` int NOT NULL AUTO_INCREMENT,
  `po_id` int NOT NULL,
  `product` int NOT NULL,
  `quantity` decimal(10,2) NOT NULL,
  `uom` int NOT NULL,
  `unit_price` decimal(10,2) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `product_id_fk_idx` (`product`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `scm_purchase_returns` (
  `id` int NOT NULL AUTO_INCREMENT,
  `date` date NOT NULL,
  `name` varchar(500) NOT NULL,
  `status` varchar(50) NOT NULL,
  `supplier` int NOT NULL,
  `reference` text,
  `description` text,
  `created_by` int NOT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `scm_subcategories` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(250) NOT NULL,
  `category_id` int NOT NULL,
  `status` varchar(50) NOT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `scm_supplier_payments` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `supplier_id` bigint unsigned NOT NULL,
  `payment_amount` decimal(12,2) NOT NULL,
  `discount` decimal(12,2) NOT NULL DEFAULT '0.00',
  `currency` bigint unsigned DEFAULT NULL,
  `exchange_rate` decimal(12,4) DEFAULT NULL,
  `payment_method` bigint unsigned DEFAULT NULL,
  `cash_account` bigint unsigned DEFAULT NULL,
  `payable_account` bigint unsigned DEFAULT NULL,
  `discount_account` bigint unsigned DEFAULT NULL,
  `journal_id` bigint unsigned DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `hospital_id` bigint unsigned DEFAULT NULL,
  `branch_id` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `scm_suppliers` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(500) NOT NULL,
  `opening_balance` decimal(12,2) NOT NULL DEFAULT '0.00',
  `status` varchar(50) NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `service_categories` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(250) NOT NULL,
  `status` varchar(50) NOT NULL,
  `created_by` int NOT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `service_details` (
  `id` int NOT NULL AUTO_INCREMENT,
  `request_id` int NOT NULL,
  `service_id` int NOT NULL,
  `rate` decimal(10,2) DEFAULT NULL,
  `quantity` varchar(200) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `service_payments` (
  `id` int NOT NULL AUTO_INCREMENT,
  `service_id` int NOT NULL,
  `payment` decimal(10,2) DEFAULT NULL,
  `discount` decimal(10,2) DEFAULT NULL,
  `promotion` decimal(10,2) DEFAULT NULL,
  `credit` decimal(10,2) DEFAULT NULL,
  `payment_method` decimal(10,2) NOT NULL,
  `currency` int NOT NULL,
  `exchange_rate` decimal(10,2) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `service_settings` (
  `id` int NOT NULL AUTO_INCREMENT,
  `income_account` int NOT NULL,
  `cash_account` int NOT NULL,
  `discount_account` int NOT NULL,
  `promotion_account` int NOT NULL,
  `credit_account` int NOT NULL,
  `credit_allowed` enum('Yes','No') NOT NULL,
  `created_by` int NOT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `promotion_allowed` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `service_types` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(250) NOT NULL,
  `category` int NOT NULL,
  `rate` decimal(10,2) NOT NULL,
  `status` varchar(50) NOT NULL,
  `created_by` int NOT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `services` (
  `id` int NOT NULL AUTO_INCREMENT,
  `service_number` int NOT NULL,
  `date` date NOT NULL,
  `appointment_id` int DEFAULT NULL,
  `admission_id` bigint unsigned DEFAULT NULL,
  `emergency_id` bigint unsigned DEFAULT NULL,
  `patient` int DEFAULT NULL,
  `type` enum('appointment','outside','emergency','admission') DEFAULT NULL,
  `service` int DEFAULT NULL,
  `category` int DEFAULT NULL,
  `rate` decimal(10,2) DEFAULT NULL,
  `quantity` varchar(200) DEFAULT NULL,
  `notes` text,
  `payment_status` varchar(100) DEFAULT NULL,
  `status` varchar(100) DEFAULT NULL,
  `payment` decimal(10,2) DEFAULT NULL,
  `discount` decimal(10,2) DEFAULT NULL,
  `promotion` decimal(10,2) DEFAULT NULL,
  `credit` decimal(10,2) DEFAULT NULL,
  `payment_method` int DEFAULT NULL,
  `currency` int DEFAULT NULL,
  `exchange_rate` decimal(10,2) DEFAULT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `doctor_id` int DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `services_emergency_id_index` (`emergency_id`),
  KEY `services_admission_id_index` (`admission_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `settings` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(500) DEFAULT NULL,
  `value` text,
  `hospital_id` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `branch_id` int DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `unqkey` (`name`,`hospital_id`,`branch_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `sponsors` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(500) DEFAULT NULL,
  `contact_person` varchar(500) DEFAULT NULL,
  `contact_phone` varchar(100) DEFAULT NULL,
  `status` varchar(50) DEFAULT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_by` int DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `store_inventories` (
  `id` int NOT NULL AUTO_INCREMENT,
  `batch` int DEFAULT NULL,
  `store_id` int NOT NULL,
  `product_id` int NOT NULL,
  `balance` text,
  `cost` decimal(10,2) DEFAULT NULL,
  `expiration_date` varchar(50) DEFAULT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `purchase_measurement` int DEFAULT NULL,
  `selling_measurement` int DEFAULT NULL,
  `conversion` decimal(10,2) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `store_inventory_details` (
  `id` int NOT NULL AUTO_INCREMENT,
  `inv_id` int NOT NULL,
  `in_quantity` decimal(10,2) DEFAULT NULL,
  `out_quantity` decimal(10,2) DEFAULT NULL,
  `reference` varchar(500) DEFAULT NULL,
  `reference_id` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `uom` int DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `store_transfers` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `from_store_id` bigint unsigned NOT NULL,
  `to_store_id` bigint unsigned NOT NULL,
  `product_id` bigint unsigned NOT NULL,
  `batch` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `quantity` decimal(15,4) NOT NULL,
  `uom` bigint unsigned NOT NULL,
  `cost` decimal(15,4) NOT NULL DEFAULT '0.0000',
  `reason` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `hospital_id` bigint unsigned DEFAULT NULL,
  `branch_id` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `store_transfers_from_store_id_index` (`from_store_id`),
  KEY `store_transfers_to_store_id_index` (`to_store_id`),
  KEY `store_transfers_product_id_index` (`product_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `symptoms` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(1000) NOT NULL,
  `status` varchar(50) NOT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `treatment_schedules` (
  `id` int NOT NULL AUTO_INCREMENT,
  `treatment_id` int NOT NULL,
  `date` date NOT NULL,
  `time` time NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `treatment_types` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(250) NOT NULL,
  `rate` decimal(10,2) NOT NULL,
  `one_day_rate` decimal(10,2) NOT NULL,
  `status` varchar(50) NOT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `treatments` (
  `id` int NOT NULL AUTO_INCREMENT,
  `patient_id` int NOT NULL,
  `dr_id` int NOT NULL,
  `treatment` int NOT NULL,
  `days` int NOT NULL,
  `rate` decimal(10,2) NOT NULL,
  `date` date NOT NULL,
  `time` time NOT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `created_by` int NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `payment_status` varchar(50) DEFAULT 'pending',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `ucva` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(250) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `ultrasound_general_findings` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `imaging_report_id` bigint unsigned NOT NULL,
  `liver_gallbladder` text COLLATE utf8mb4_unicode_ci,
  `spleen` text COLLATE utf8mb4_unicode_ci,
  `kidneys_urinary_tract` text COLLATE utf8mb4_unicode_ci,
  `uterus_adnexa` text COLLATE utf8mb4_unicode_ci,
  `other_findings` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `ultrasound_general_findings_imaging_report_id_unique` (`imaging_report_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `ultrasound_obstetric_details` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `imaging_report_id` bigint unsigned NOT NULL,
  `gravida` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `para` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `fetal_condition` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `fetal_sex` enum('male','female','undetermined') COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `fhr` int DEFAULT NULL,
  `gestational_age_weeks` decimal(4,1) DEFAULT NULL,
  `presentation` enum('cephalic','breech','transverse','twins') COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `amniotic_fluid` enum('normal','oligo','poly') COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `placenta_condition` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `placenta_position` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `placenta_other` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `hc_cm` decimal(5,2) DEFAULT NULL,
  `bpd` decimal(5,2) DEFAULT NULL,
  `ac_cm` decimal(5,2) DEFAULT NULL,
  `fl_cm` decimal(5,2) DEFAULT NULL,
  `edd` date DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `ultrasound_obstetric_details_imaging_report_id_unique` (`imaging_report_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `users` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `email_verified_at` timestamp NULL DEFAULT NULL,
  `password` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `remember_token` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `hospital_id` int NOT NULL,
  `branch_id` int NOT NULL,
  `employee_id` int DEFAULT NULL,
  `status` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `username` varchar(250) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `role` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `receipt_print_type` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `users_email_unique` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `vital_reflexes` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(250) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- @@
CREATE TABLE IF NOT EXISTS `xray_findings` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `imaging_report_id` bigint unsigned NOT NULL,
  `region_examined` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `view_projection` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `findings` text COLLATE utf8mb4_unicode_ci,
  `impression` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `xray_findings_imaging_report_id_unique` (`imaging_report_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
