/*M!999999\- enable the sandbox mode */ 
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*M!100616 SET @OLD_NOTE_VERBOSITY=@@NOTE_VERBOSITY, NOTE_VERBOSITY=0 */;
DROP TABLE IF EXISTS `appointment_mcu_item`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `appointment_mcu_item` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `appointment_id` bigint unsigned NOT NULL,
  `mcu_item_id` bigint unsigned NOT NULL,
  `status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'menunggu',
  `current_station` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `processed_at` timestamp NULL DEFAULT NULL,
  `assigned_at` timestamp NULL DEFAULT NULL,
  `verified_by_doctor_id` bigint unsigned DEFAULT NULL,
  `verified_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `processed_by` bigint unsigned DEFAULT NULL,
  `assigned_by` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `appointment_mcu_item_appointment_id_foreign` (`appointment_id`),
  KEY `appointment_mcu_item_verified_by_doctor_id_foreign` (`verified_by_doctor_id`),
  KEY `appointment_mcu_item_processed_by_foreign` (`processed_by`),
  KEY `appointment_mcu_item_assigned_by_foreign` (`assigned_by`),
  CONSTRAINT `appointment_mcu_item_appointment_id_foreign` FOREIGN KEY (`appointment_id`) REFERENCES `appointments` (`id`) ON DELETE CASCADE,
  CONSTRAINT `appointment_mcu_item_assigned_by_foreign` FOREIGN KEY (`assigned_by`) REFERENCES `users` (`id`),
  CONSTRAINT `appointment_mcu_item_processed_by_foreign` FOREIGN KEY (`processed_by`) REFERENCES `users` (`id`),
  CONSTRAINT `appointment_mcu_item_verified_by_doctor_id_foreign` FOREIGN KEY (`verified_by_doctor_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `appointment_mcu_items`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `appointment_mcu_items` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `appointment_id` bigint unsigned NOT NULL,
  `mcu_item_id` bigint unsigned NOT NULL,
  `status` enum('menunggu','antrian','sedang_diproses','selesai','dibatalkan','menunggu_verifikasi','sample_collected','sample_failed') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'menunggu',
  `current_station` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `queue_number` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `assigned_at` timestamp NULL DEFAULT NULL,
  `assigned_by` bigint unsigned DEFAULT NULL,
  `processed_at` timestamp NULL DEFAULT NULL,
  `processed_by` bigint unsigned DEFAULT NULL,
  `verified_by_doctor_id` bigint unsigned DEFAULT NULL,
  `verified_at` timestamp NULL DEFAULT NULL,
  `completed_at` timestamp NULL DEFAULT NULL,
  `notes` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `appointment_mcu_items_assigned_by_foreign` (`assigned_by`),
  KEY `appointment_mcu_items_processed_by_foreign` (`processed_by`),
  KEY `idx_ami_appointment_status_assigned` (`appointment_id`,`status`,`assigned_at`),
  KEY `idx_ami_item_status_assigned` (`mcu_item_id`,`status`,`assigned_at`),
  KEY `idx_ami_status_times` (`status`,`assigned_at`,`processed_at`),
  KEY `idx_ami_status_completed` (`status`,`completed_at`),
  KEY `appointment_mcu_items_verified_by_doctor_id_foreign` (`verified_by_doctor_id`),
  CONSTRAINT `appointment_mcu_items_appointment_id_foreign` FOREIGN KEY (`appointment_id`) REFERENCES `appointments` (`id`) ON DELETE CASCADE,
  CONSTRAINT `appointment_mcu_items_assigned_by_foreign` FOREIGN KEY (`assigned_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `appointment_mcu_items_mcu_item_id_foreign` FOREIGN KEY (`mcu_item_id`) REFERENCES `mcu_items` (`id`) ON DELETE CASCADE,
  CONSTRAINT `appointment_mcu_items_processed_by_foreign` FOREIGN KEY (`processed_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `appointment_mcu_items_verified_by_doctor_id_foreign` FOREIGN KEY (`verified_by_doctor_id`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `appointments`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `appointments` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `patient_id` bigint unsigned NOT NULL,
  `mcu_package_id` bigint unsigned NOT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  `appointment_date` date NOT NULL,
  `appointment_time` time NOT NULL,
  `status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pemeriksaan',
  `current_station` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `progress_tracking` json DEFAULT NULL,
  `registration_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `is_walkin` tinyint(1) NOT NULL DEFAULT '0',
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `referral_source` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `updated_by` bigint unsigned DEFAULT NULL,
  `dokter_utama_id` bigint unsigned DEFAULT NULL,
  `final_signed_at` timestamp NULL DEFAULT NULL,
  `rescheduled_date` date DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `appointments_registration_number_unique` (`registration_number`),
  KEY `appointments_patient_id_foreign` (`patient_id`),
  KEY `appointments_mcu_package_id_foreign` (`mcu_package_id`),
  KEY `appointments_company_id_foreign` (`company_id`),
  KEY `appointments_created_by_foreign` (`created_by`),
  KEY `appointments_updated_by_foreign` (`updated_by`),
  KEY `appointments_dokter_utama_id_foreign` (`dokter_utama_id`),
  KEY `idx_appointments_date_status` (`appointment_date`,`status`),
  KEY `idx_appointments_datetime` (`appointment_date`,`appointment_time`),
  CONSTRAINT `appointments_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE SET NULL,
  CONSTRAINT `appointments_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `appointments_dokter_utama_id_foreign` FOREIGN KEY (`dokter_utama_id`) REFERENCES `users` (`id`),
  CONSTRAINT `appointments_mcu_package_id_foreign` FOREIGN KEY (`mcu_package_id`) REFERENCES `mcu_packages` (`id`) ON DELETE RESTRICT,
  CONSTRAINT `appointments_patient_id_foreign` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`) ON DELETE CASCADE,
  CONSTRAINT `appointments_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `audiometry_frequencies`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `audiometry_frequencies` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `frequency_hz` int NOT NULL,
  `is_standard` tinyint(1) NOT NULL DEFAULT '1',
  `display_order` int NOT NULL DEFAULT '0',
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `audiometry_frequencies_frequency_hz_unique` (`frequency_hz`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `audiometry_results`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `audiometry_results` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `appointment_id` bigint unsigned NOT NULL,
  `appointment_mcu_item_id` bigint unsigned DEFAULT NULL,
  `patient_id` bigint unsigned NOT NULL,
  `right_ear_results` json DEFAULT NULL,
  `left_ear_results` json DEFAULT NULL,
  `right_bc_results` json DEFAULT NULL,
  `left_bc_results` json DEFAULT NULL,
  `right_ear_condition` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `left_ear_condition` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `additional_exams` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `conclusion` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `notes` text COLLATE utf8mb4_unicode_ci,
  `technician_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `selected_technician_id` bigint unsigned DEFAULT NULL,
  `selected_doctor_id` bigint unsigned DEFAULT NULL,
  `audiologist` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` enum('pending','in_progress','sample_collected','completed','verified','rejected','cancelled','partial') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `audiogram_image_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `is_integrated` tinyint(1) NOT NULL DEFAULT '0',
  `integration_source` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `raw_data` json DEFAULT NULL,
  `verified_by` bigint unsigned DEFAULT NULL,
  `verified_at` datetime DEFAULT NULL,
  `doctor_notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `final_interpretation` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `final_recommendations` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `rejection_reason` text COLLATE utf8mb4_unicode_ci,
  `examination_time` datetime DEFAULT NULL,
  `completed_at` timestamp NULL DEFAULT NULL,
  `completed_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `audiometry_results_appointment_id_foreign` (`appointment_id`),
  KEY `audiometry_results_patient_id_foreign` (`patient_id`),
  KEY `audiometry_results_verified_by_foreign` (`verified_by`),
  KEY `audiometry_results_appointment_mcu_item_id_foreign` (`appointment_mcu_item_id`),
  KEY `audiometry_results_selected_technician_id_foreign` (`selected_technician_id`),
  KEY `audiometry_results_selected_doctor_id_foreign` (`selected_doctor_id`),
  KEY `audiometry_results_completed_by_foreign` (`completed_by`),
  KEY `idx_audiometry_appointment_status` (`appointment_id`,`status`),
  KEY `idx_audiometry_status_examination` (`status`,`examination_time`),
  KEY `idx_audiometry_status_verified` (`status`,`verified_at`),
  CONSTRAINT `audiometry_results_appointment_id_foreign` FOREIGN KEY (`appointment_id`) REFERENCES `appointments` (`id`) ON DELETE CASCADE,
  CONSTRAINT `audiometry_results_appointment_mcu_item_id_foreign` FOREIGN KEY (`appointment_mcu_item_id`) REFERENCES `appointment_mcu_items` (`id`) ON DELETE CASCADE,
  CONSTRAINT `audiometry_results_completed_by_foreign` FOREIGN KEY (`completed_by`) REFERENCES `users` (`id`),
  CONSTRAINT `audiometry_results_patient_id_foreign` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`) ON DELETE CASCADE,
  CONSTRAINT `audiometry_results_selected_doctor_id_foreign` FOREIGN KEY (`selected_doctor_id`) REFERENCES `audiometry_staff` (`id`),
  CONSTRAINT `audiometry_results_selected_technician_id_foreign` FOREIGN KEY (`selected_technician_id`) REFERENCES `audiometry_staff` (`id`),
  CONSTRAINT `audiometry_results_verified_by_foreign` FOREIGN KEY (`verified_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `audiometry_staff`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `audiometry_staff` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `employee_id` bigint unsigned NOT NULL,
  `role` enum('doctor','technician') COLLATE utf8mb4_unicode_ci NOT NULL,
  `license_number` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `specialization` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `signature_path` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `stamp_path` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `notes` text COLLATE utf8mb4_unicode_ci,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `is_default` tinyint(1) NOT NULL DEFAULT '0',
  `created_by` bigint unsigned DEFAULT NULL,
  `updated_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `audiometry_staff_employee_id_unique` (`employee_id`),
  KEY `audiometry_staff_created_by_foreign` (`created_by`),
  KEY `audiometry_staff_updated_by_foreign` (`updated_by`),
  KEY `audiometry_staff_role_is_active_index` (`role`,`is_active`),
  KEY `audiometry_staff_is_default_role_index` (`is_default`,`role`),
  CONSTRAINT `audiometry_staff_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`),
  CONSTRAINT `audiometry_staff_employee_id_foreign` FOREIGN KEY (`employee_id`) REFERENCES `employees` (`id`) ON DELETE CASCADE,
  CONSTRAINT `audiometry_staff_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `cache`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `cache` (
  `key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `value` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `expiration` int NOT NULL,
  PRIMARY KEY (`key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `cache_locks`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `cache_locks` (
  `key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `owner` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `expiration` int NOT NULL,
  PRIMARY KEY (`key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `client_job_positions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `client_job_positions` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `client_job_positions_name_unique` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `companies`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `companies` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `phone_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `contact_person` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `contact_person_phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `pic_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `pic_phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `pic_email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `npwp` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `billing_address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `payment_method` enum('cash','transfer','credit') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'transfer',
  `payment_term_days` int NOT NULL DEFAULT '30',
  `contract_start_date` date DEFAULT NULL,
  `contract_end_date` date DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `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;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `company_mcu_packages`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `company_mcu_packages` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `mcu_package_id` bigint unsigned NOT NULL,
  `is_default` tinyint(1) NOT NULL DEFAULT '0',
  `custom_price` decimal(10,2) DEFAULT NULL,
  `male_price` decimal(10,2) DEFAULT NULL,
  `female_price` decimal(10,2) DEFAULT NULL,
  `pricing_notes` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `company_mcu_packages_company_id_mcu_package_id_unique` (`company_id`,`mcu_package_id`),
  KEY `company_mcu_packages_mcu_package_id_foreign` (`mcu_package_id`),
  KEY `company_mcu_packages_company_id_mcu_package_id_is_default_index` (`company_id`,`mcu_package_id`,`is_default`),
  CONSTRAINT `company_mcu_packages_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE,
  CONSTRAINT `company_mcu_packages_mcu_package_id_foreign` FOREIGN KEY (`mcu_package_id`) REFERENCES `mcu_packages` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `corporate_invitation_employees`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `corporate_invitation_employees` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `corporate_invitation_id` bigint unsigned NOT NULL,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `birth_date` date NOT NULL,
  `gender` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `position` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `position_id` bigint unsigned DEFAULT NULL,
  `nik` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `patient_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `corporate_invitation_employees_corporate_invitation_id_foreign` (`corporate_invitation_id`),
  KEY `corporate_invitation_employees_position_id_foreign` (`position_id`),
  KEY `corporate_invitation_employees_patient_id_foreign` (`patient_id`),
  CONSTRAINT `corporate_invitation_employees_corporate_invitation_id_foreign` FOREIGN KEY (`corporate_invitation_id`) REFERENCES `corporate_invitations` (`id`) ON DELETE CASCADE,
  CONSTRAINT `corporate_invitation_employees_patient_id_foreign` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`) ON DELETE SET NULL,
  CONSTRAINT `corporate_invitation_employees_position_id_foreign` FOREIGN KEY (`position_id`) REFERENCES `client_job_positions` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `corporate_invitations`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `corporate_invitations` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `created_by_admin_id` bigint unsigned NOT NULL,
  `mcu_date` date NOT NULL,
  `mcu_time` time NOT NULL DEFAULT '08:00:00',
  `token` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `expires_at` timestamp NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `mcu_package_id` bigint unsigned DEFAULT NULL,
  `package_price` decimal(12,2) DEFAULT NULL,
  `notes` text COLLATE utf8mb4_unicode_ci,
  PRIMARY KEY (`id`),
  UNIQUE KEY `corporate_invitations_token_unique` (`token`),
  KEY `corporate_invitations_company_id_foreign` (`company_id`),
  KEY `corporate_invitations_created_by_admin_id_foreign` (`created_by_admin_id`),
  KEY `corporate_invitations_mcu_package_id_foreign` (`mcu_package_id`),
  CONSTRAINT `corporate_invitations_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`),
  CONSTRAINT `corporate_invitations_created_by_admin_id_foreign` FOREIGN KEY (`created_by_admin_id`) REFERENCES `users` (`id`),
  CONSTRAINT `corporate_invitations_mcu_package_id_foreign` FOREIGN KEY (`mcu_package_id`) REFERENCES `mcu_packages` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `corporate_invoices`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `corporate_invoices` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `corporate_invitation_id` bigint unsigned NOT NULL,
  `company_id` bigint unsigned NOT NULL,
  `invoice_number` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `subtotal` decimal(12,2) NOT NULL,
  `tax_amount` decimal(12,2) NOT NULL DEFAULT '0.00',
  `discount_amount` decimal(12,2) NOT NULL DEFAULT '0.00',
  `total_amount` decimal(12,2) NOT NULL,
  `total_employees` int NOT NULL,
  `status` enum('draft','sent','paid','overdue','cancelled') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'draft',
  `due_date` date DEFAULT NULL,
  `paid_at` datetime DEFAULT NULL,
  `payment_method` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `notes` text COLLATE utf8mb4_unicode_ci,
  `pdf_path` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `corporate_invoices_invoice_number_unique` (`invoice_number`),
  KEY `corporate_invoices_corporate_invitation_id_foreign` (`corporate_invitation_id`),
  KEY `corporate_invoices_company_id_foreign` (`company_id`),
  CONSTRAINT `corporate_invoices_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE,
  CONSTRAINT `corporate_invoices_corporate_invitation_id_foreign` FOREIGN KEY (`corporate_invitation_id`) REFERENCES `corporate_invitations` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `departments`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `departments` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `ekg_staff`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `ekg_staff` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `employee_id` bigint unsigned NOT NULL,
  `role` enum('doctor','technician') COLLATE utf8mb4_unicode_ci NOT NULL,
  `signature_image` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `stamp_image` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `is_default` tinyint(1) NOT NULL DEFAULT '0',
  `notes` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `ekg_staff_employee_id_unique` (`employee_id`),
  KEY `ekg_staff_role_is_active_index` (`role`,`is_active`),
  KEY `ekg_staff_role_is_default_index` (`role`,`is_default`),
  CONSTRAINT `ekg_staff_employee_id_foreign` FOREIGN KEY (`employee_id`) REFERENCES `employees` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `elektrokardiograms`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `elektrokardiograms` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `appointment_id` bigint unsigned NOT NULL,
  `rhythm` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `frequency` int DEFAULT NULL,
  `axis` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `transition_zone` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `p_wave_morphology` int DEFAULT NULL,
  `pr_interval` int DEFAULT NULL,
  `qrs` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `qt_interval` int DEFAULT NULL,
  `st_segment` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `t_wave` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `others` text COLLATE utf8mb4_unicode_ci,
  `ekg_images` json DEFAULT NULL COMMENT 'Array of EKG image filenames',
  `technician_notes` text COLLATE utf8mb4_unicode_ci COMMENT 'Notes from technician during examination',
  `conclusion` text COLLATE utf8mb4_unicode_ci,
  `doctor_notes` text COLLATE utf8mb4_unicode_ci,
  `examiner` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` enum('pending','in_progress','completed','verified','rejected') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `verified_by` bigint unsigned DEFAULT NULL,
  `verified_doctor_id` bigint unsigned DEFAULT NULL,
  `verified_technician_id` bigint unsigned DEFAULT NULL,
  `verified_at` timestamp NULL DEFAULT NULL,
  `verification_notes` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `elektrokardiograms_verified_by_foreign` (`verified_by`),
  KEY `elektrokardiograms_appointment_id_status_index` (`appointment_id`,`status`),
  KEY `elektrokardiograms_status_index` (`status`),
  KEY `elektrokardiograms_verified_doctor_id_foreign` (`verified_doctor_id`),
  KEY `elektrokardiograms_verified_technician_id_foreign` (`verified_technician_id`),
  CONSTRAINT `elektrokardiograms_appointment_id_foreign` FOREIGN KEY (`appointment_id`) REFERENCES `appointments` (`id`) ON DELETE CASCADE,
  CONSTRAINT `elektrokardiograms_verified_by_foreign` FOREIGN KEY (`verified_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `elektrokardiograms_verified_doctor_id_foreign` FOREIGN KEY (`verified_doctor_id`) REFERENCES `ekg_staff` (`id`) ON DELETE SET NULL,
  CONSTRAINT `elektrokardiograms_verified_technician_id_foreign` FOREIGN KEY (`verified_technician_id`) REFERENCES `ekg_staff` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `employees`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `employees` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint unsigned DEFAULT NULL,
  `full_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `employee_id_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `phone_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email_address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `employment_status` enum('tetap','kontrak','magang','paruh_waktu') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'tetap',
  `hiring_date` date DEFAULT NULL,
  `birth_date` date DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `photo` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `address` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `emergency_contact_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `emergency_contact_phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `position_id` bigint unsigned DEFAULT NULL,
  `department_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `employees_user_id_foreign` (`user_id`),
  KEY `employees_position_id_foreign` (`position_id`),
  KEY `employees_department_id_foreign` (`department_id`),
  CONSTRAINT `employees_department_id_foreign` FOREIGN KEY (`department_id`) REFERENCES `departments` (`id`) ON DELETE SET NULL,
  CONSTRAINT `employees_position_id_foreign` FOREIGN KEY (`position_id`) REFERENCES `positions` (`id`) ON DELETE SET NULL,
  CONSTRAINT `employees_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `eye_health_letters`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `eye_health_letters` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `patient_id` bigint unsigned NOT NULL,
  `examination_date` date NOT NULL,
  `right_eye_vision` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `right_eye_glasses` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `left_eye_vision` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `left_eye_glasses` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `color_vision` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `color_vision_od` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `color_vision_os` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `intraocular_pressure` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `intraocular_pressure_od` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `intraocular_pressure_os` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `anterior_segment` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `anterior_segment_od` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `anterior_segment_os` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `funduscopy` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `funduscopy_od` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `funduscopy_os` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `fundus_details` text COLLATE utf8mb4_unicode_ci,
  `fundus_details_od` text COLLATE utf8mb4_unicode_ci,
  `fundus_details_os` text COLLATE utf8mb4_unicode_ci,
  `conclusion` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `suggestions` text COLLATE utf8mb4_unicode_ci,
  `requirements` text COLLATE utf8mb4_unicode_ci,
  `name_snapshot` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `birth_date_snapshot` date DEFAULT NULL,
  `medical_record_snapshot` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `job_position_snapshot` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `address_snapshot` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `eye_health_letters_patient_id_foreign` (`patient_id`),
  CONSTRAINT `eye_health_letters_patient_id_foreign` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `failed_jobs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `failed_jobs` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `uuid` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `connection` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `queue` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `payload` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `exception` longtext CHARACTER SET utf8mb4 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;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `family_health_histories`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `family_health_histories` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `patient_id` bigint unsigned NOT NULL,
  `appointment_id` bigint unsigned DEFAULT NULL,
  `father_diabetes` enum('-','Ya','Tidak','Tidak Tahu') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '-',
  `father_hypertension` enum('-','Ya','Tidak','Tidak Tahu') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '-',
  `father_other_diseases` text COLLATE utf8mb4_unicode_ci,
  `mother_diabetes` enum('-','Ya','Tidak','Tidak Tahu') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '-',
  `mother_hypertension` enum('-','Ya','Tidak','Tidak Tahu') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '-',
  `mother_other_diseases` text COLLATE utf8mb4_unicode_ci,
  `siblings_diabetes` enum('-','Ya','Tidak','Tidak Tahu') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '-',
  `siblings_hypertension` enum('-','Ya','Tidak','Tidak Tahu') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '-',
  `siblings_other_diseases` text COLLATE utf8mb4_unicode_ci,
  `others_diabetes` enum('-','Ya','Tidak','Tidak Tahu') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '-',
  `others_hypertension` enum('-','Ya','Tidak','Tidak Tahu') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '-',
  `others_other_diseases` text COLLATE utf8mb4_unicode_ci,
  `status` enum('incomplete','completed','verified') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'incomplete',
  `filled_by` bigint unsigned DEFAULT NULL,
  `verified_by` bigint unsigned DEFAULT NULL,
  `notes` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `family_health_histories_patient_id_foreign` (`patient_id`),
  KEY `family_health_histories_appointment_id_foreign` (`appointment_id`),
  KEY `family_health_histories_filled_by_foreign` (`filled_by`),
  KEY `family_health_histories_verified_by_foreign` (`verified_by`),
  CONSTRAINT `family_health_histories_appointment_id_foreign` FOREIGN KEY (`appointment_id`) REFERENCES `appointments` (`id`) ON DELETE CASCADE,
  CONSTRAINT `family_health_histories_filled_by_foreign` FOREIGN KEY (`filled_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `family_health_histories_patient_id_foreign` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`) ON DELETE CASCADE,
  CONSTRAINT `family_health_histories_verified_by_foreign` FOREIGN KEY (`verified_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `health_letters`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `health_letters` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `patient_id` bigint unsigned NOT NULL,
  `recipient_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `recipient_address` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `main_content` text COLLATE utf8mb4_unicode_ci,
  `job_position` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `notes` text COLLATE utf8mb4_unicode_ci,
  `gender_snapshot` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `name_snapshot` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `age_snapshot` int DEFAULT NULL,
  `detailed_age_snapshot` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `address_snapshot` text COLLATE utf8mb4_unicode_ci,
  `height` decimal(5,2) DEFAULT NULL COMMENT 'Tinggi badan dalam cm',
  `weight` decimal(5,2) DEFAULT NULL COMMENT 'Berat badan dalam kg',
  `blood_pressure` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Tekanan darah (sistolik/diastolik)',
  `color_vision` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Hasil tes buta warna',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `health_letters_patient_id_foreign` (`patient_id`),
  CONSTRAINT `health_letters_patient_id_foreign` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `health_questionnaires`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `health_questionnaires` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `patient_id` bigint unsigned NOT NULL,
  `appointment_id` bigint unsigned DEFAULT NULL,
  `has_heart_disease` tinyint(1) NOT NULL DEFAULT '0',
  `heart_disease_details` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `has_lung_disease` tinyint(1) NOT NULL DEFAULT '0',
  `lung_disease_details` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `has_diabetes` tinyint(1) NOT NULL DEFAULT '0',
  `has_diabetes_mellitus` tinyint(1) NOT NULL DEFAULT '0',
  `diabetes_details` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `has_hypertension` tinyint(1) NOT NULL DEFAULT '0',
  `hypertension_details` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `has_allergies` tinyint(1) NOT NULL DEFAULT '0',
  `has_allergy_issue` tinyint(1) NOT NULL DEFAULT '0',
  `allergies_details` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `is_taking_medication` tinyint(1) NOT NULL DEFAULT '0',
  `medication_details` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `has_surgery_history` tinyint(1) NOT NULL DEFAULT '0',
  `surgery_details` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `has_family_disease_history` tinyint(1) NOT NULL DEFAULT '0',
  `has_head_injury` tinyint(1) DEFAULT NULL,
  `has_seizure` tinyint(1) NOT NULL DEFAULT '0',
  `has_vision_disorder` tinyint(1) DEFAULT NULL,
  `has_hearing_disorder` tinyint(1) DEFAULT NULL,
  `has_ear_nose_problem` tinyint(1) DEFAULT NULL,
  `has_ear_nose_throat_problem` tinyint(1) NOT NULL DEFAULT '0',
  `has_chronic_ear_problem` tinyint(1) DEFAULT NULL,
  `has_ear_problem_4weeks` tinyint(1) NOT NULL DEFAULT '0',
  `has_female_health_problem` tinyint(1) DEFAULT NULL,
  `has_womens_health_issue` tinyint(1) NOT NULL DEFAULT '0',
  `has_chronic_skin_disease` tinyint(1) DEFAULT NULL,
  `has_chronic_skin_problem` tinyint(1) NOT NULL DEFAULT '0',
  `has_chronic_diarrhea` tinyint(1) DEFAULT NULL,
  `has_chronic_diarrhea_issue` tinyint(1) NOT NULL DEFAULT '0',
  `has_appetite_loss` tinyint(1) DEFAULT NULL,
  `has_appetite_loss_4weeks` tinyint(1) NOT NULL DEFAULT '0',
  `has_gastritis` tinyint(1) DEFAULT NULL,
  `has_gastritis_ulcer` tinyint(1) NOT NULL DEFAULT '0',
  `has_hepatitis` tinyint(1) DEFAULT NULL,
  `has_yellow_fever_hepatitis` tinyint(1) NOT NULL DEFAULT '0',
  `has_chronic_cough` tinyint(1) DEFAULT NULL,
  `has_chronic_cough_issue` tinyint(1) NOT NULL DEFAULT '0',
  `has_hemorrhoids` tinyint(1) DEFAULT NULL,
  `has_hemorrhoids_issue` tinyint(1) NOT NULL DEFAULT '0',
  `has_chronic_stomach_pain` tinyint(1) DEFAULT NULL,
  `has_chronic_abdominal_pain` tinyint(1) NOT NULL DEFAULT '0',
  `has_sexual_disease` tinyint(1) DEFAULT NULL,
  `has_sexual_transmitted_disease` tinyint(1) NOT NULL DEFAULT '0',
  `has_asthma` tinyint(1) DEFAULT NULL,
  `has_asthma_shortness` tinyint(1) NOT NULL DEFAULT '0',
  `has_tb` tinyint(1) DEFAULT NULL,
  `has_tuberculosis` tinyint(1) NOT NULL DEFAULT '0',
  `has_mental_disorder` tinyint(1) DEFAULT NULL,
  `has_mental_health_problem` tinyint(1) NOT NULL DEFAULT '0',
  `has_high_blood_pressure` tinyint(1) DEFAULT NULL,
  `has_hypertension_issue` tinyint(1) NOT NULL DEFAULT '0',
  `has_chest_pain` tinyint(1) DEFAULT NULL,
  `has_heart_chest_pain` tinyint(1) NOT NULL DEFAULT '0',
  `has_malaria` tinyint(1) DEFAULT NULL,
  `has_malaria_disease` tinyint(1) NOT NULL DEFAULT '0',
  `has_surgery` tinyint(1) DEFAULT NULL,
  `has_surgical_operation` tinyint(1) NOT NULL DEFAULT '0',
  `has_weight_change` tinyint(1) DEFAULT NULL,
  `has_abnormal_weight_change` tinyint(1) NOT NULL DEFAULT '0',
  `has_chronic_back_pain` tinyint(1) DEFAULT NULL,
  `has_back_pain_4weeks` tinyint(1) NOT NULL DEFAULT '0',
  `has_thyroid_fever` tinyint(1) DEFAULT NULL,
  `has_typhoid_fever` tinyint(1) NOT NULL DEFAULT '0',
  `has_joint_pain` tinyint(1) DEFAULT NULL,
  `has_joint_swelling_pain` tinyint(1) NOT NULL DEFAULT '0',
  `has_kidney_stone` tinyint(1) DEFAULT NULL,
  `has_kidney_stone_disease` tinyint(1) NOT NULL DEFAULT '0',
  `other_chronic_diseases` text COLLATE utf8mb4_unicode_ci,
  `family_disease_details` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `is_smoker` tinyint(1) NOT NULL DEFAULT '0',
  `smoking_frequency` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `consumes_alcohol` tinyint(1) NOT NULL DEFAULT '0',
  `alcohol_consumption_frequency` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `additional_questions` json DEFAULT NULL,
  `custom_fields` json DEFAULT NULL,
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `status` enum('incomplete','completed','verified') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'incomplete',
  `filled_by` bigint unsigned DEFAULT NULL,
  `verified_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `health_questionnaires_patient_id_foreign` (`patient_id`),
  KEY `health_questionnaires_appointment_id_foreign` (`appointment_id`),
  KEY `health_questionnaires_filled_by_foreign` (`filled_by`),
  KEY `health_questionnaires_verified_by_foreign` (`verified_by`),
  CONSTRAINT `health_questionnaires_appointment_id_foreign` FOREIGN KEY (`appointment_id`) REFERENCES `appointments` (`id`) ON DELETE CASCADE,
  CONSTRAINT `health_questionnaires_filled_by_foreign` FOREIGN KEY (`filled_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `health_questionnaires_patient_id_foreign` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`) ON DELETE CASCADE,
  CONSTRAINT `health_questionnaires_verified_by_foreign` FOREIGN KEY (`verified_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `hearing_loss_types`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `hearing_loss_types` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `severity` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `min_db_threshold` int DEFAULT NULL,
  `max_db_threshold` int DEFAULT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `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;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `invoice_items`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `invoice_items` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `invoice_id` bigint unsigned NOT NULL,
  `appointment_id` bigint unsigned DEFAULT NULL,
  `corporate_invitation_employee_id` bigint unsigned DEFAULT NULL,
  `patient_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `patient_nik` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `medical_record_number` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `mcu_date` date NOT NULL,
  `mcu_package_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `package_price` decimal(10,2) NOT NULL,
  `total_amount` decimal(10,2) NOT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `invoice_items_appointment_id_foreign` (`appointment_id`),
  KEY `invoice_items_invoice_id_mcu_date_index` (`invoice_id`,`mcu_date`),
  KEY `invoice_items_corporate_invitation_employee_id_index` (`corporate_invitation_employee_id`),
  CONSTRAINT `invoice_items_appointment_id_foreign` FOREIGN KEY (`appointment_id`) REFERENCES `appointments` (`id`) ON DELETE CASCADE,
  CONSTRAINT `invoice_items_corporate_invitation_employee_id_foreign` FOREIGN KEY (`corporate_invitation_employee_id`) REFERENCES `corporate_invitation_employees` (`id`) ON DELETE CASCADE,
  CONSTRAINT `invoice_items_invoice_id_foreign` FOREIGN KEY (`invoice_id`) REFERENCES `invoices` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `invoices`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `invoices` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `invoice_number` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `company_id` bigint unsigned NOT NULL,
  `corporate_invitation_id` bigint unsigned DEFAULT NULL,
  `invoice_date` date NOT NULL,
  `period_start` date DEFAULT NULL,
  `period_end` date DEFAULT NULL,
  `total_patients` int NOT NULL,
  `total_amount` decimal(15,2) NOT NULL,
  `status` enum('draft','sent','paid','overdue') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'draft',
  `due_date` date NOT NULL,
  `sent_date` date DEFAULT NULL,
  `paid_date` date DEFAULT NULL,
  `notes` text COLLATE utf8mb4_unicode_ci,
  `created_by` bigint unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `invoices_invoice_number_unique` (`invoice_number`),
  KEY `invoices_created_by_foreign` (`created_by`),
  KEY `invoices_company_id_invoice_date_index` (`company_id`,`invoice_date`),
  KEY `invoices_corporate_invitation_id_index` (`corporate_invitation_id`),
  KEY `invoices_status_due_date_index` (`status`,`due_date`),
  CONSTRAINT `invoices_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE,
  CONSTRAINT `invoices_corporate_invitation_id_foreign` FOREIGN KEY (`corporate_invitation_id`) REFERENCES `corporate_invitations` (`id`) ON DELETE CASCADE,
  CONSTRAINT `invoices_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `job_batches`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `job_batches` (
  `id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `total_jobs` int NOT NULL,
  `pending_jobs` int NOT NULL,
  `failed_jobs` int NOT NULL,
  `failed_job_ids` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `options` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `cancelled_at` int DEFAULT NULL,
  `created_at` int NOT NULL,
  `finished_at` int DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `jobs`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `jobs` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `queue` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `payload` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `attempts` tinyint unsigned NOT NULL,
  `reserved_at` int unsigned DEFAULT NULL,
  `available_at` int unsigned NOT NULL,
  `created_at` int unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `jobs_queue_index` (`queue`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `lab_result_items`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `lab_result_items` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `lab_result_id` bigint unsigned NOT NULL,
  `appointment_mcu_item_id` bigint unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `lab_result_item_unique` (`lab_result_id`,`appointment_mcu_item_id`),
  KEY `lab_result_items_appointment_mcu_item_id_foreign` (`appointment_mcu_item_id`),
  CONSTRAINT `lab_result_items_appointment_mcu_item_id_foreign` FOREIGN KEY (`appointment_mcu_item_id`) REFERENCES `appointment_mcu_items` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `lab_results`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `lab_results` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `appointment_id` bigint unsigned NOT NULL,
  `appointment_mcu_item_id` bigint unsigned DEFAULT NULL,
  `patient_id` bigint unsigned NOT NULL,
  `lab_reference_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `results_data` json DEFAULT NULL,
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `qr_token` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `qr_token_expires_at` timestamp NULL DEFAULT NULL,
  `technician_id` bigint unsigned DEFAULT NULL,
  `doctor_id` bigint unsigned DEFAULT NULL,
  `selected_doctor_staff_id` bigint unsigned DEFAULT NULL,
  `selected_technician_staff_id` bigint unsigned DEFAULT NULL,
  `doctor_notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `cancellation_reason` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `cancellation_notes` text COLLATE utf8mb4_unicode_ci,
  `cancellation_priority` enum('normal','urgent','critical') COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `cancelled_at` timestamp NULL DEFAULT NULL,
  `cancelled_by` bigint unsigned DEFAULT NULL,
  `test_results` json DEFAULT NULL,
  `abnormal_results` json DEFAULT NULL,
  `lab_notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `lab_technician` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` enum('pending','in_progress','completed','verified','rejected','cancelled','sample_collected','sample_failed') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `completed_at` timestamp NULL DEFAULT NULL,
  `sample_collected_at` datetime DEFAULT NULL,
  `result_received_at` datetime DEFAULT NULL,
  `is_integrated` tinyint(1) NOT NULL DEFAULT '0',
  `integration_source` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `raw_data` json DEFAULT NULL,
  `normal_ranges` json DEFAULT NULL,
  `verified_by` bigint unsigned DEFAULT NULL,
  `verified_at` datetime DEFAULT NULL,
  `hiv_consent_received` tinyint(1) NOT NULL DEFAULT '0',
  `hiv_consent_document_path` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `lab_results_qr_token_unique` (`qr_token`),
  KEY `lab_results_appointment_id_foreign` (`appointment_id`),
  KEY `lab_results_patient_id_foreign` (`patient_id`),
  KEY `lab_results_verified_by_foreign` (`verified_by`),
  KEY `lab_results_appointment_mcu_item_id_foreign` (`appointment_mcu_item_id`),
  KEY `lab_results_technician_id_foreign` (`technician_id`),
  KEY `lab_results_doctor_id_foreign` (`doctor_id`),
  KEY `idx_lab_appointment_status` (`appointment_id`,`status`),
  KEY `idx_lab_status_completed` (`status`,`completed_at`),
  KEY `idx_lab_status_verified` (`status`,`verified_at`),
  KEY `lab_results_selected_doctor_staff_id_foreign` (`selected_doctor_staff_id`),
  KEY `lab_results_selected_technician_staff_id_foreign` (`selected_technician_staff_id`),
  KEY `lab_results_cancelled_by_foreign` (`cancelled_by`),
  CONSTRAINT `lab_results_appointment_id_foreign` FOREIGN KEY (`appointment_id`) REFERENCES `appointments` (`id`) ON DELETE CASCADE,
  CONSTRAINT `lab_results_appointment_mcu_item_id_foreign` FOREIGN KEY (`appointment_mcu_item_id`) REFERENCES `appointment_mcu_item` (`id`) ON DELETE SET NULL,
  CONSTRAINT `lab_results_cancelled_by_foreign` FOREIGN KEY (`cancelled_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `lab_results_doctor_id_foreign` FOREIGN KEY (`doctor_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `lab_results_patient_id_foreign` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`) ON DELETE CASCADE,
  CONSTRAINT `lab_results_selected_doctor_staff_id_foreign` FOREIGN KEY (`selected_doctor_staff_id`) REFERENCES `lab_staff` (`id`) ON DELETE SET NULL,
  CONSTRAINT `lab_results_selected_technician_staff_id_foreign` FOREIGN KEY (`selected_technician_staff_id`) REFERENCES `lab_staff` (`id`) ON DELETE SET NULL,
  CONSTRAINT `lab_results_technician_id_foreign` FOREIGN KEY (`technician_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `lab_results_verified_by_foreign` FOREIGN KEY (`verified_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `lab_staff`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `lab_staff` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `employee_id` bigint unsigned NOT NULL,
  `role` enum('doctor','technician') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `signature_image` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `stamp_image` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `is_default` tinyint(1) NOT NULL DEFAULT '0',
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `lab_staff_employee_id_foreign` (`employee_id`),
  KEY `lab_staff_role_is_active_index` (`role`,`is_active`),
  KEY `lab_staff_is_default_role_index` (`is_default`,`role`),
  CONSTRAINT `lab_staff_employee_id_foreign` FOREIGN KEY (`employee_id`) REFERENCES `employees` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `lab_test_references`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `lab_test_references` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `lab_test_id` bigint unsigned NOT NULL,
  `gender` enum('male','female','both') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'both',
  `age_min` int DEFAULT NULL,
  `age_max` int DEFAULT NULL,
  `min_value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `max_value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `normal_value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `lab_test_references_lab_test_id_foreign` (`lab_test_id`),
  CONSTRAINT `lab_test_references_lab_test_id_foreign` FOREIGN KEY (`lab_test_id`) REFERENCES `lab_tests` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `lab_tests`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `lab_tests` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `unit` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `category` enum('hematologi','kimia_darah','serologi','urinalisis','feses','mikrobiologi','lainnya') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'lainnya',
  `data_type` enum('numeric','text','dropdown','boolean') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'numeric',
  `dropdown_options` json DEFAULT NULL,
  `lis_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `display_order` int NOT NULL DEFAULT '0',
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `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;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `laboratory_parameters`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `laboratory_parameters` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `code` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Kode parameter lab',
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Nama parameter',
  `category` enum('hematologi','led','golongan_darah','kimia_darah','imunoserologi','urinalisa','narkoba') COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Kategori pemeriksaan',
  `subcategory` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Sub kategori (makroskopis, mikroskopis, dll)',
  `unit` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Satuan pengukuran',
  `data_type` enum('number','text','dropdown','boolean') COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Tipe data',
  `normal_value_male` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Nilai normal pria',
  `normal_value_female` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Nilai normal wanita',
  `normal_value_general` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Nilai normal umum',
  `min_normal_male` decimal(10,3) DEFAULT NULL COMMENT 'Nilai minimum normal pria',
  `max_normal_male` decimal(10,3) DEFAULT NULL COMMENT 'Nilai maksimum normal pria',
  `min_normal_female` decimal(10,3) DEFAULT NULL COMMENT 'Nilai minimum normal wanita',
  `max_normal_female` decimal(10,3) DEFAULT NULL COMMENT 'Nilai maksimum normal wanita',
  `min_normal_general` decimal(10,3) DEFAULT NULL COMMENT 'Nilai minimum normal umum',
  `max_normal_general` decimal(10,3) DEFAULT NULL COMMENT 'Nilai maksimum normal umum',
  `dropdown_options` json DEFAULT NULL COMMENT 'Opsi dropdown dalam format JSON',
  `display_order` int NOT NULL DEFAULT '0' COMMENT 'Urutan tampilan',
  `is_required` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Wajib diisi',
  `is_active` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'Status aktif',
  `description` text COLLATE utf8mb4_unicode_ci COMMENT 'Deskripsi parameter',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `laboratory_parameters_code_unique` (`code`),
  KEY `laboratory_parameters_category_subcategory_index` (`category`,`subcategory`),
  KEY `laboratory_parameters_is_active_display_order_index` (`is_active`,`display_order`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `locations`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `locations` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `address` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `phone_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `pic_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `pic_phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `opening_hour` time DEFAULT NULL,
  `closing_hour` time DEFAULT NULL,
  `working_days` json DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `google_maps_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `latitude` decimal(10,7) DEFAULT NULL,
  `longitude` decimal(10,7) DEFAULT 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;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `matrix_rules`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `matrix_rules` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `client_job_position_id` bigint unsigned NOT NULL,
  `mcu_item_id` bigint unsigned NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `matrix_rule_unique` (`company_id`,`client_job_position_id`,`mcu_item_id`),
  KEY `matrix_rules_client_job_position_id_foreign` (`client_job_position_id`),
  KEY `matrix_rules_mcu_item_id_foreign` (`mcu_item_id`),
  CONSTRAINT `matrix_rules_client_job_position_id_foreign` FOREIGN KEY (`client_job_position_id`) REFERENCES `client_job_positions` (`id`) ON DELETE CASCADE,
  CONSTRAINT `matrix_rules_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE,
  CONSTRAINT `matrix_rules_mcu_item_id_foreign` FOREIGN KEY (`mcu_item_id`) REFERENCES `mcu_items` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `mcu_items`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `mcu_items` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `department` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `mcu_items_name_unique` (`name`),
  KEY `idx_mcu_items_department` (`department`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `mcu_package_addons`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `mcu_package_addons` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `price` decimal(12,2) NOT NULL,
  `type` enum('addon','package','discount') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `gender_specific` enum('male','female','both') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'both',
  `has_tax` tinyint(1) NOT NULL DEFAULT '0',
  `tax_percentage` decimal(5,2) NOT NULL DEFAULT '0.00',
  `company_id` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `mcu_package_addons_code_unique` (`code`),
  KEY `mcu_package_addons_company_id_foreign` (`company_id`),
  CONSTRAINT `mcu_package_addons_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `mcu_packages`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `mcu_packages` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `package_notes` text COLLATE utf8mb4_unicode_ci,
  `additional_examinations` json DEFAULT NULL,
  `price` decimal(12,2) NOT NULL,
  `male_price` decimal(10,2) DEFAULT NULL,
  `female_price` decimal(10,2) DEFAULT NULL,
  `includes_lab_tests` tinyint(1) NOT NULL DEFAULT '1',
  `includes_radiology` tinyint(1) NOT NULL DEFAULT '1',
  `includes_audiometry` tinyint(1) NOT NULL DEFAULT '1',
  `includes_visus` tinyint(1) NOT NULL DEFAULT '1',
  `includes_physical_exam` tinyint(1) NOT NULL DEFAULT '1',
  `includes_spirometry` tinyint(1) NOT NULL DEFAULT '0',
  `lab_tests_included` json DEFAULT NULL,
  `radiology_exams_included` json DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `package_type` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'custom',
  `estimated_duration_minutes` int NOT NULL DEFAULT '60',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `mcu_packages_code_unique` (`code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `mcu_results`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `mcu_results` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `appointment_id` bigint unsigned NOT NULL,
  `patient_id` bigint unsigned NOT NULL,
  `result_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `health_status` enum('fit','fit_with_treatment','temporary_unfit','unfit','fit_for_the_job','fit_for_the_job_with_treatment','fit_with_note','fit_for_the_job_with_note') COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `examination_summary` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `mcu_suggestions` json DEFAULT NULL,
  `doctor_notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `recommendations` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `abnormal_findings` json DEFAULT NULL,
  `examination_date` date NOT NULL,
  `status` enum('draft','finalized','reviewed','published') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'draft',
  `is_released_to_patient` tinyint(1) NOT NULL DEFAULT '0',
  `released_at` datetime DEFAULT NULL,
  `doctor_id` bigint unsigned DEFAULT NULL,
  `finalized_by` bigint unsigned DEFAULT NULL,
  `finalized_at` datetime DEFAULT NULL,
  `pdf_file_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `metadata` json DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `mcu_results_result_number_unique` (`result_number`),
  UNIQUE KEY `mcu_results_appointment_id_unique` (`appointment_id`),
  KEY `mcu_results_appointment_id_foreign` (`appointment_id`),
  KEY `mcu_results_patient_id_foreign` (`patient_id`),
  KEY `mcu_results_doctor_id_foreign` (`doctor_id`),
  KEY `mcu_results_finalized_by_foreign` (`finalized_by`),
  CONSTRAINT `mcu_results_appointment_id_foreign` FOREIGN KEY (`appointment_id`) REFERENCES `appointments` (`id`) ON DELETE CASCADE,
  CONSTRAINT `mcu_results_doctor_id_foreign` FOREIGN KEY (`doctor_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `mcu_results_finalized_by_foreign` FOREIGN KEY (`finalized_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `mcu_results_patient_id_foreign` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `migrations`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `migrations` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `migration` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `batch` int NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `model_has_permissions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `model_has_permissions` (
  `permission_id` bigint unsigned NOT NULL,
  `model_type` varchar(255) CHARACTER SET utf8mb4 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;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `model_has_roles`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `model_has_roles` (
  `role_id` bigint unsigned NOT NULL,
  `model_type` varchar(255) CHARACTER SET utf8mb4 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;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `password_reset_tokens`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `password_reset_tokens` (
  `email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `token` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `patient_lifestyle_data`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `patient_lifestyle_data` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `patient_id` bigint unsigned NOT NULL,
  `appointment_id` bigint unsigned DEFAULT NULL,
  `alcohol_consumption_weekly` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `consumes_alcohol` tinyint(1) DEFAULT NULL COMMENT 'Konsumsi alkohol: 0=TIDAK, 1=YA',
  `alcohol_frequency` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Frekuensi konsumsi alkohol per minggu',
  `smoking_daily` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `is_smoker` tinyint(1) DEFAULT NULL COMMENT 'Merokok: 0=TIDAK, 1=YA',
  `smoking_amount` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Jumlah rokok per hari',
  `medications_consumed` text COLLATE utf8mb4_unicode_ci,
  `medication_prescription` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Status resep obat: DENGAN RESEP DOKTER / TANPA RESEP DOKTER',
  `health_notes` text COLLATE utf8mb4_unicode_ci,
  `status` enum('incomplete','completed','verified') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'incomplete',
  `filled_by` bigint unsigned DEFAULT NULL,
  `verified_by` bigint unsigned DEFAULT NULL,
  `notes` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `patient_lifestyle_data_patient_id_foreign` (`patient_id`),
  KEY `patient_lifestyle_data_appointment_id_foreign` (`appointment_id`),
  KEY `patient_lifestyle_data_filled_by_foreign` (`filled_by`),
  KEY `patient_lifestyle_data_verified_by_foreign` (`verified_by`),
  CONSTRAINT `patient_lifestyle_data_appointment_id_foreign` FOREIGN KEY (`appointment_id`) REFERENCES `appointments` (`id`) ON DELETE CASCADE,
  CONSTRAINT `patient_lifestyle_data_filled_by_foreign` FOREIGN KEY (`filled_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `patient_lifestyle_data_patient_id_foreign` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`) ON DELETE CASCADE,
  CONSTRAINT `patient_lifestyle_data_verified_by_foreign` FOREIGN KEY (`verified_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `patients`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `patients` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `nik` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `medical_record_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `nickname` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `gender` enum('male','female') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `birth_date` date NOT NULL,
  `birth_place` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `phone_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `religion` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `ethnicity` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `marital_status` enum('single','married','divorced','widowed') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `number_of_children` int DEFAULT NULL,
  `mcu_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `blood_type` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `occupation` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  `job_position` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `emergency_contact_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `emergency_contact_phone` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `photo` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `ktp_photo` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `signature_path` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `registration_status` enum('temporary','complete') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'complete',
  `is_quick_registration` tinyint(1) NOT NULL DEFAULT '0',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `patients_nik_unique` (`nik`),
  UNIQUE KEY `patients_medical_record_number_unique` (`medical_record_number`),
  UNIQUE KEY `patients_email_unique` (`email`),
  KEY `patients_company_id_foreign` (`company_id`),
  KEY `idx_patients_mrn` (`medical_record_number`),
  KEY `idx_patients_name` (`name`),
  CONSTRAINT `patients_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `payments`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `payments` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `appointment_id` bigint unsigned NOT NULL,
  `patient_id` bigint unsigned NOT NULL,
  `company_id` bigint unsigned DEFAULT NULL,
  `invoice_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `amount` decimal(12,2) NOT NULL,
  `tax_amount` decimal(12,2) NOT NULL DEFAULT '0.00',
  `discount_amount` decimal(12,2) NOT NULL DEFAULT '0.00',
  `total_amount` decimal(12,2) NOT NULL,
  `payment_method` enum('cash','credit_card','debit_card','transfer','corporate','insurance') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'cash',
  `payment_status` enum('pending','partially_paid','paid','failed','refunded','cancelled') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `payment_date` date DEFAULT NULL,
  `due_date` date DEFAULT NULL,
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `receipt_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `transaction_reference` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `payment_proof_path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `insurance_claim_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `insurance_provider` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `updated_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `payments_invoice_number_unique` (`invoice_number`),
  KEY `payments_appointment_id_foreign` (`appointment_id`),
  KEY `payments_patient_id_foreign` (`patient_id`),
  KEY `payments_company_id_foreign` (`company_id`),
  KEY `payments_created_by_foreign` (`created_by`),
  KEY `payments_updated_by_foreign` (`updated_by`),
  CONSTRAINT `payments_appointment_id_foreign` FOREIGN KEY (`appointment_id`) REFERENCES `appointments` (`id`) ON DELETE CASCADE,
  CONSTRAINT `payments_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE SET NULL,
  CONSTRAINT `payments_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `payments_patient_id_foreign` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`) ON DELETE CASCADE,
  CONSTRAINT `payments_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `permissions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `permissions` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `guard_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `permissions_name_guard_name_unique` (`name`,`guard_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `physical_exam_parameters`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `physical_exam_parameters` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `unit` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `min_normal_value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `max_normal_value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `data_type` enum('numeric','text','dropdown','boolean','range') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'numeric',
  `dropdown_options` json DEFAULT NULL,
  `display_group` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `display_order` int NOT NULL DEFAULT '0',
  `is_required` tinyint(1) NOT NULL DEFAULT '0',
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `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;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `physical_exam_results`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `physical_exam_results` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `patient_id` bigint unsigned NOT NULL,
  `appointment_id` bigint unsigned NOT NULL,
  `appointment_mcu_item_id` bigint unsigned DEFAULT NULL,
  `height` decimal(5,2) DEFAULT NULL,
  `weight` decimal(5,2) DEFAULT NULL,
  `heart_rate` int DEFAULT NULL,
  `respiratory_rate` int DEFAULT NULL,
  `body_temperature` decimal(4,1) DEFAULT NULL,
  `bmi` decimal(5,2) DEFAULT NULL,
  `waist_circumference` decimal(5,2) DEFAULT NULL,
  `vision_left_uncorrected` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `vision_right_uncorrected` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `vision_left_corrected` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `vision_right_corrected` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `visual_field_left` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `visual_field_right` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `color_vision` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `physical_examination_data` json DEFAULT NULL,
  `general_appearance` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `consciousness_level` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `blood_pressure_systolic` int DEFAULT NULL,
  `blood_pressure_diastolic` int DEFAULT NULL,
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `doctor_notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `verification_notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `rejection_reason` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `examiner_id` bigint unsigned DEFAULT NULL,
  `doctor_id` bigint unsigned DEFAULT NULL,
  `verifier_id` bigint unsigned DEFAULT NULL,
  `selected_doctor_staff_id` bigint unsigned DEFAULT NULL,
  `selected_technician_staff_id` bigint unsigned DEFAULT NULL,
  `status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `completed_at` timestamp NULL DEFAULT NULL,
  `verified_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `physical_exam_results_patient_id_foreign` (`patient_id`),
  KEY `physical_exam_results_appointment_id_foreign` (`appointment_id`),
  KEY `physical_exam_results_appointment_mcu_item_id_foreign` (`appointment_mcu_item_id`),
  KEY `physical_exam_results_examiner_id_foreign` (`examiner_id`),
  KEY `physical_exam_results_doctor_id_foreign` (`doctor_id`),
  KEY `physical_exam_results_verifier_id_foreign` (`verifier_id`),
  KEY `idx_physical_appointment_status` (`appointment_id`,`status`),
  KEY `idx_physical_status_completed` (`status`,`completed_at`),
  KEY `idx_physical_status_verified` (`status`,`verified_at`),
  KEY `physical_exam_results_selected_doctor_staff_id_foreign` (`selected_doctor_staff_id`),
  KEY `physical_exam_results_selected_technician_staff_id_foreign` (`selected_technician_staff_id`),
  CONSTRAINT `physical_exam_results_appointment_id_foreign` FOREIGN KEY (`appointment_id`) REFERENCES `appointments` (`id`),
  CONSTRAINT `physical_exam_results_appointment_mcu_item_id_foreign` FOREIGN KEY (`appointment_mcu_item_id`) REFERENCES `appointment_mcu_item` (`id`) ON DELETE SET NULL,
  CONSTRAINT `physical_exam_results_doctor_id_foreign` FOREIGN KEY (`doctor_id`) REFERENCES `users` (`id`),
  CONSTRAINT `physical_exam_results_examiner_id_foreign` FOREIGN KEY (`examiner_id`) REFERENCES `users` (`id`),
  CONSTRAINT `physical_exam_results_patient_id_foreign` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`),
  CONSTRAINT `physical_exam_results_selected_doctor_staff_id_foreign` FOREIGN KEY (`selected_doctor_staff_id`) REFERENCES `physical_exam_staff` (`id`) ON DELETE SET NULL,
  CONSTRAINT `physical_exam_results_selected_technician_staff_id_foreign` FOREIGN KEY (`selected_technician_staff_id`) REFERENCES `physical_exam_staff` (`id`) ON DELETE SET NULL,
  CONSTRAINT `physical_exam_results_verifier_id_foreign` FOREIGN KEY (`verifier_id`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `physical_exam_staff`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `physical_exam_staff` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `employee_id` bigint unsigned NOT NULL,
  `role` enum('doctor','nurse','technician') COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'doctor=Dokter Penanggung Jawab, nurse=Perawat, technician=Petugas Pemeriksaan',
  `signature_image` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Path file tanda tangan',
  `stamp_image` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Path file stempel',
  `is_active` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'Status aktif staff',
  `is_default` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Staff default untuk role',
  `notes` text COLLATE utf8mb4_unicode_ci COMMENT 'Catatan tambahan',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `physical_exam_staff_employee_id_foreign` (`employee_id`),
  KEY `physical_exam_staff_role_is_active_index` (`role`,`is_active`),
  KEY `physical_exam_staff_is_default_role_index` (`is_default`,`role`),
  CONSTRAINT `physical_exam_staff_employee_id_foreign` FOREIGN KEY (`employee_id`) REFERENCES `employees` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `positions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `positions` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `radiology_conclusion_templates`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `radiology_conclusion_templates` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `radiology_exam_type_id` bigint unsigned DEFAULT NULL,
  `content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `is_normal` tinyint(1) NOT NULL DEFAULT '1',
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `created_by` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `radiology_conclusion_templates_radiology_exam_type_id_foreign` (`radiology_exam_type_id`),
  CONSTRAINT `radiology_conclusion_templates_radiology_exam_type_id_foreign` FOREIGN KEY (`radiology_exam_type_id`) REFERENCES `radiology_exam_types` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `radiology_exam_types`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `radiology_exam_types` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `body_part` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `modality` enum('x-ray','ct','mri','ultrasound','mammography','other') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'other',
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `display_order` int NOT NULL DEFAULT '0',
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `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;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `radiology_results`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `radiology_results` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `appointment_id` bigint unsigned NOT NULL,
  `appointment_mcu_item_id` bigint unsigned DEFAULT NULL,
  `patient_id` bigint unsigned NOT NULL,
  `examination_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Rontgen Thorax',
  `clinical_diagnosis` text COLLATE utf8mb4_unicode_ci COMMENT 'Diagnosis klinis',
  `findings` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `conclusion` text COLLATE utf8mb4_unicode_ci COMMENT 'Kesimpulan',
  `technician_id` bigint unsigned DEFAULT NULL,
  `doctor_id` bigint unsigned DEFAULT NULL,
  `doctor_notes` text COLLATE utf8mb4_unicode_ci COMMENT 'Catatan dokter saat verifikasi',
  `completed_at` timestamp NULL DEFAULT NULL COMMENT 'Waktu selesai pemeriksaan',
  `notes` text COLLATE utf8mb4_unicode_ci COMMENT 'Catatan tambahan',
  `recommendations` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `radiologist` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` enum('pending','in_progress','completed','verified','rejected','cancelled') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `image_paths` json DEFAULT NULL,
  `pacs_reference` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `is_integrated` tinyint(1) NOT NULL DEFAULT '0',
  `integration_source` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `metadata` json DEFAULT NULL,
  `raw_data` json DEFAULT NULL,
  `verified_by` bigint unsigned DEFAULT NULL,
  `selected_doctor_staff_id` bigint unsigned DEFAULT NULL,
  `selected_technician_staff_id` bigint unsigned DEFAULT NULL,
  `verified_at` datetime DEFAULT NULL,
  `examination_time` datetime DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `radiology_results_appointment_id_foreign` (`appointment_id`),
  KEY `radiology_results_patient_id_foreign` (`patient_id`),
  KEY `radiology_results_verified_by_foreign` (`verified_by`),
  KEY `radiology_results_appointment_mcu_item_id_foreign` (`appointment_mcu_item_id`),
  KEY `idx_radiology_appointment_status` (`appointment_id`,`status`),
  KEY `idx_radiology_status_examination` (`status`,`examination_time`),
  KEY `idx_radiology_status_verified` (`status`,`verified_at`),
  KEY `radiology_results_selected_doctor_staff_id_foreign` (`selected_doctor_staff_id`),
  KEY `radiology_results_selected_technician_staff_id_foreign` (`selected_technician_staff_id`),
  KEY `radiology_results_technician_id_foreign` (`technician_id`),
  KEY `radiology_results_doctor_id_foreign` (`doctor_id`),
  CONSTRAINT `radiology_results_appointment_id_foreign` FOREIGN KEY (`appointment_id`) REFERENCES `appointments` (`id`) ON DELETE CASCADE,
  CONSTRAINT `radiology_results_appointment_mcu_item_id_foreign` FOREIGN KEY (`appointment_mcu_item_id`) REFERENCES `appointment_mcu_item` (`id`) ON DELETE SET NULL,
  CONSTRAINT `radiology_results_doctor_id_foreign` FOREIGN KEY (`doctor_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `radiology_results_patient_id_foreign` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`) ON DELETE CASCADE,
  CONSTRAINT `radiology_results_selected_doctor_staff_id_foreign` FOREIGN KEY (`selected_doctor_staff_id`) REFERENCES `radiology_staff` (`id`) ON DELETE SET NULL,
  CONSTRAINT `radiology_results_selected_technician_staff_id_foreign` FOREIGN KEY (`selected_technician_staff_id`) REFERENCES `radiology_staff` (`id`) ON DELETE SET NULL,
  CONSTRAINT `radiology_results_technician_id_foreign` FOREIGN KEY (`technician_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `radiology_results_verified_by_foreign` FOREIGN KEY (`verified_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `radiology_staff`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `radiology_staff` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `employee_id` bigint unsigned NOT NULL,
  `role` enum('doctor','technician') COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'doctor = Dokter Penanggung Jawab, technician = Petugas Radiologi',
  `signature_image` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Path tanda tangan digital',
  `stamp_image` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Path stempel digital',
  `is_active` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'Status aktif',
  `is_default` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Staff default untuk role ini',
  `notes` text COLLATE utf8mb4_unicode_ci COMMENT 'Catatan tambahan',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `radiology_staff_employee_id_foreign` (`employee_id`),
  KEY `radiology_staff_role_is_active_index` (`role`,`is_active`),
  KEY `radiology_staff_role_is_default_index` (`role`,`is_default`),
  CONSTRAINT `radiology_staff_employee_id_foreign` FOREIGN KEY (`employee_id`) REFERENCES `employees` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `report_templates`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `report_templates` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `type` enum('mcu_final','lab_result','radiology','audiometry','visus','spirometry') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `version` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_by` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `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;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `role_has_permissions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `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;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `roles`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `roles` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `guard_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `roles_name_guard_name_unique` (`name`,`guard_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `sessions`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `sessions` (
  `id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `user_id` bigint unsigned DEFAULT NULL,
  `ip_address` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `user_agent` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `payload` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `last_activity` int NOT NULL,
  PRIMARY KEY (`id`),
  KEY `sessions_user_id_index` (`user_id`),
  KEY `sessions_last_activity_index` (`last_activity`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `sick_letters`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `sick_letters` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `patient_id` bigint unsigned NOT NULL,
  `total_days` int unsigned NOT NULL,
  `start_date` date NOT NULL,
  `end_date` date NOT NULL,
  `notes` text COLLATE utf8mb4_unicode_ci,
  `gender_snapshot` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `name_snapshot` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `age_snapshot` int unsigned DEFAULT NULL,
  `detailed_age_snapshot` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `address_snapshot` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `job_position` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `sick_letters_patient_id_foreign` (`patient_id`),
  CONSTRAINT `sick_letters_patient_id_foreign` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `spirometry_parameters`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `spirometry_parameters` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `unit` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `reference_male_min` decimal(8,2) DEFAULT NULL,
  `reference_male_max` decimal(8,2) DEFAULT NULL,
  `reference_female_min` decimal(8,2) DEFAULT NULL,
  `reference_female_max` decimal(8,2) DEFAULT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `display_order` int NOT NULL DEFAULT '0',
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `is_required` tinyint(1) NOT NULL DEFAULT '0',
  `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;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `spirometry_results`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `spirometry_results` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `appointment_id` bigint unsigned NOT NULL,
  `patient_id` bigint unsigned NOT NULL,
  `fvc_predicted` decimal(8,2) DEFAULT NULL,
  `fvc_actual` decimal(8,2) DEFAULT NULL,
  `fvc_percentage` decimal(8,2) DEFAULT NULL,
  `fev1_predicted` decimal(8,2) DEFAULT NULL,
  `fev1_actual` decimal(8,2) DEFAULT NULL,
  `fev1_percentage` decimal(8,2) DEFAULT NULL,
  `fev1_fvc_ratio` decimal(8,2) DEFAULT NULL,
  `pef` decimal(8,2) DEFAULT NULL,
  `mef25` decimal(8,2) DEFAULT NULL,
  `mef50` decimal(8,2) DEFAULT NULL,
  `mef75` decimal(8,2) DEFAULT NULL,
  `interpretation` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `recommendations` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `result_file_path` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `original_file_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `technician_id` bigint unsigned DEFAULT NULL,
  `status` enum('pending','in_progress','sample_collected','completed','verified','rejected','cancelled','partial') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `verification_status` enum('verified','rejected') COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `verification_notes` text COLLATE utf8mb4_unicode_ci,
  `rejection_reason` text COLLATE utf8mb4_unicode_ci,
  `completed_at` timestamp NULL DEFAULT NULL,
  `verified_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `verified_by` bigint unsigned DEFAULT NULL,
  `selected_doctor_id` bigint unsigned DEFAULT NULL,
  `selected_technician_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `spirometry_results_appointment_id_foreign` (`appointment_id`),
  KEY `spirometry_results_patient_id_foreign` (`patient_id`),
  KEY `spirometry_results_technician_id_foreign` (`technician_id`),
  KEY `idx_spirometry_appointment_status` (`appointment_id`,`status`),
  KEY `idx_spirometry_status_completed` (`status`,`completed_at`),
  KEY `idx_spirometry_status_verified` (`status`,`verified_at`),
  KEY `spirometry_results_verified_by_foreign` (`verified_by`),
  KEY `spirometry_results_selected_doctor_id_foreign` (`selected_doctor_id`),
  KEY `spirometry_results_selected_technician_id_foreign` (`selected_technician_id`),
  KEY `spirometry_results_status_completed_at_index` (`status`,`completed_at`),
  KEY `spirometry_results_verification_status_verified_at_index` (`verification_status`,`verified_at`),
  CONSTRAINT `spirometry_results_appointment_id_foreign` FOREIGN KEY (`appointment_id`) REFERENCES `appointments` (`id`) ON DELETE CASCADE,
  CONSTRAINT `spirometry_results_patient_id_foreign` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`) ON DELETE CASCADE,
  CONSTRAINT `spirometry_results_selected_doctor_id_foreign` FOREIGN KEY (`selected_doctor_id`) REFERENCES `spirometry_staff` (`id`) ON DELETE SET NULL,
  CONSTRAINT `spirometry_results_selected_technician_id_foreign` FOREIGN KEY (`selected_technician_id`) REFERENCES `spirometry_staff` (`id`) ON DELETE SET NULL,
  CONSTRAINT `spirometry_results_technician_id_foreign` FOREIGN KEY (`technician_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `spirometry_results_verified_by_foreign` FOREIGN KEY (`verified_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `spirometry_staff`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `spirometry_staff` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `employee_id` bigint unsigned NOT NULL,
  `role` enum('doctor','technician') COLLATE utf8mb4_unicode_ci NOT NULL,
  `license_number` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `specialization` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `notes` text COLLATE utf8mb4_unicode_ci,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `is_default` tinyint(1) NOT NULL DEFAULT '0',
  `signature_path` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `stamp_path` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_by` bigint unsigned DEFAULT NULL,
  `updated_by` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique_employee_spirometry_staff` (`employee_id`),
  KEY `spirometry_staff_created_by_foreign` (`created_by`),
  KEY `spirometry_staff_updated_by_foreign` (`updated_by`),
  KEY `spirometry_staff_role_is_active_index` (`role`,`is_active`),
  KEY `spirometry_staff_is_default_role_index` (`is_default`,`role`),
  CONSTRAINT `spirometry_staff_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `spirometry_staff_employee_id_foreign` FOREIGN KEY (`employee_id`) REFERENCES `employees` (`id`) ON DELETE CASCADE,
  CONSTRAINT `spirometry_staff_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `users`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `users` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `email_verified_at` timestamp NULL DEFAULT NULL,
  `password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `remember_token` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `users_email_unique` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `usg_conclusion_templates`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `usg_conclusion_templates` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `usg_exam_area_id` bigint unsigned DEFAULT NULL,
  `content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `is_normal` tinyint(1) NOT NULL DEFAULT '1',
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `created_by` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `usg_conclusion_templates_usg_exam_area_id_foreign` (`usg_exam_area_id`),
  CONSTRAINT `usg_conclusion_templates_usg_exam_area_id_foreign` FOREIGN KEY (`usg_exam_area_id`) REFERENCES `usg_exam_areas` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `usg_exam_areas`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `usg_exam_areas` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `gender_specific` enum('male','female','both') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'both',
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `display_order` int NOT NULL DEFAULT '0',
  `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;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `vision_acuity_types`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `vision_acuity_types` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `snellen_value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `decimal_value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `is_normal` tinyint(1) NOT NULL DEFAULT '0',
  `display_order` int NOT NULL DEFAULT '0',
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `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;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `vision_correction_types`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `vision_correction_types` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `display_order` int NOT NULL DEFAULT '0',
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `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;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `vision_diagnosis_categories`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `vision_diagnosis_categories` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
  `code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `display_order` int NOT NULL DEFAULT '0',
  `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;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `visus_results`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `visus_results` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `appointment_id` bigint unsigned NOT NULL,
  `appointment_mcu_item_id` bigint unsigned DEFAULT NULL,
  `patient_id` bigint unsigned NOT NULL,
  `right_eye_uncorrected` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `left_eye_uncorrected` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `right_eye_corrected` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `left_eye_corrected` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `visual_field_left` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `visual_field_right` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `color_vision` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `visual_field_left_corrected` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `visual_field_right_corrected` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `color_vision_corrected` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `notes` text COLLATE utf8mb4_unicode_ci,
  `right_eye_correction` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `left_eye_correction` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `needs_glasses` tinyint(1) NOT NULL DEFAULT '0',
  `uses_glasses` tinyint(1) NOT NULL DEFAULT '0',
  `color_blindness_test_passed` tinyint(1) DEFAULT NULL,
  `color_blindness_notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `color_blindness_test_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `interpretation` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `recommendations` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `examiner` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` enum('pending','in_progress','completed','cancelled','verified','rejected') COLLATE utf8mb4_unicode_ci DEFAULT 'pending',
  `is_integrated` tinyint(1) NOT NULL DEFAULT '0',
  `integration_source` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `raw_data` json DEFAULT NULL,
  `verified_by` bigint unsigned DEFAULT NULL,
  `verified_at` datetime DEFAULT NULL,
  `doctor_notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `final_interpretation` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `final_recommendations` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `verification_notes` text COLLATE utf8mb4_unicode_ci,
  `rejection_reason` text COLLATE utf8mb4_unicode_ci,
  `selected_doctor_staff_id` bigint unsigned DEFAULT NULL,
  `selected_technician_staff_id` bigint unsigned DEFAULT NULL,
  `examination_time` datetime DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `visus_results_appointment_id_foreign` (`appointment_id`),
  KEY `visus_results_patient_id_foreign` (`patient_id`),
  KEY `visus_results_verified_by_foreign` (`verified_by`),
  KEY `visus_results_appointment_mcu_item_id_foreign` (`appointment_mcu_item_id`),
  KEY `idx_visus_appointment_status` (`appointment_id`,`status`),
  KEY `idx_visus_status_examination` (`status`,`examination_time`),
  KEY `idx_visus_status_verified` (`status`,`verified_at`),
  KEY `visus_results_selected_doctor_staff_id_foreign` (`selected_doctor_staff_id`),
  KEY `visus_results_selected_technician_staff_id_foreign` (`selected_technician_staff_id`),
  CONSTRAINT `visus_results_appointment_id_foreign` FOREIGN KEY (`appointment_id`) REFERENCES `appointments` (`id`) ON DELETE CASCADE,
  CONSTRAINT `visus_results_appointment_mcu_item_id_foreign` FOREIGN KEY (`appointment_mcu_item_id`) REFERENCES `appointment_mcu_item` (`id`) ON DELETE SET NULL,
  CONSTRAINT `visus_results_patient_id_foreign` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`) ON DELETE CASCADE,
  CONSTRAINT `visus_results_selected_doctor_staff_id_foreign` FOREIGN KEY (`selected_doctor_staff_id`) REFERENCES `visus_staff` (`id`) ON DELETE SET NULL,
  CONSTRAINT `visus_results_selected_technician_staff_id_foreign` FOREIGN KEY (`selected_technician_staff_id`) REFERENCES `visus_staff` (`id`) ON DELETE SET NULL,
  CONSTRAINT `visus_results_verified_by_foreign` FOREIGN KEY (`verified_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `visus_staff`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `visus_staff` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `employee_id` bigint unsigned NOT NULL,
  `role` enum('doctor','nurse','technician') COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'doctor=Dokter Penanggung Jawab, nurse=Perawat, technician=Petugas Pemeriksaan Mata',
  `signature_image` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Path file tanda tangan',
  `stamp_image` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Path file stempel',
  `is_active` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'Status aktif staff',
  `is_default` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Staff default untuk role',
  `notes` text COLLATE utf8mb4_unicode_ci COMMENT 'Catatan tambahan',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `visus_staff_employee_id_foreign` (`employee_id`),
  KEY `visus_staff_role_is_active_index` (`role`,`is_active`),
  KEY `visus_staff_is_default_role_index` (`is_default`,`role`),
  CONSTRAINT `visus_staff_employee_id_foreign` FOREIGN KEY (`employee_id`) REFERENCES `employees` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `work_activities`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `work_activities` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `patient_id` bigint unsigned NOT NULL,
  `appointment_id` bigint unsigned DEFAULT NULL,
  `operates_moving_equipment` tinyint(1) NOT NULL DEFAULT '0',
  `uses_moving_equipment_protection` tinyint(1) NOT NULL DEFAULT '0',
  `moving_equipment_protection_details` text COLLATE utf8mb4_unicode_ci,
  `uses_protection_equipment` tinyint(1) NOT NULL DEFAULT '0',
  `protection_equipment_details` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `works_at_height` tinyint(1) NOT NULL DEFAULT '0',
  `uses_height_protection` tinyint(1) NOT NULL DEFAULT '0',
  `height_protection_details` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `works_in_office` tinyint(1) NOT NULL DEFAULT '0',
  `uses_office_protection` tinyint(1) NOT NULL DEFAULT '0',
  `office_protection_details` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `works_in_dusty_place` tinyint(1) NOT NULL DEFAULT '0',
  `uses_dusty_protection` tinyint(1) NOT NULL DEFAULT '0',
  `dusty_protection_details` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `works_in_noisy_place` tinyint(1) NOT NULL DEFAULT '0',
  `uses_noise_protection` tinyint(1) NOT NULL DEFAULT '0',
  `noise_protection_details` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `needs_color_accuracy` tinyint(1) NOT NULL DEFAULT '0',
  `uses_color_protection` tinyint(1) NOT NULL DEFAULT '0',
  `color_protection_details` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `is_catering_staff` tinyint(1) NOT NULL DEFAULT '0',
  `uses_catering_protection` tinyint(1) NOT NULL DEFAULT '0',
  `catering_protection_details` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `handles_dangerous_materials` tinyint(1) NOT NULL DEFAULT '0',
  `uses_dangerous_protection` tinyint(1) NOT NULL DEFAULT '0',
  `dangerous_protection_details` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `work_start_year` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `occupation` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `hobby` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `activities` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `status` enum('incomplete','completed','verified') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'incomplete',
  `filled_by` bigint unsigned DEFAULT NULL,
  `verified_by` bigint unsigned DEFAULT NULL,
  `notes` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `work_activities_patient_id_foreign` (`patient_id`),
  KEY `work_activities_appointment_id_foreign` (`appointment_id`),
  KEY `work_activities_filled_by_foreign` (`filled_by`),
  KEY `work_activities_verified_by_foreign` (`verified_by`),
  CONSTRAINT `work_activities_appointment_id_foreign` FOREIGN KEY (`appointment_id`) REFERENCES `appointments` (`id`) ON DELETE CASCADE,
  CONSTRAINT `work_activities_filled_by_foreign` FOREIGN KEY (`filled_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `work_activities_patient_id_foreign` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`) ON DELETE CASCADE,
  CONSTRAINT `work_activities_verified_by_foreign` FOREIGN KEY (`verified_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*M!100616 SET NOTE_VERBOSITY=@OLD_NOTE_VERBOSITY */;

/*M!999999\- enable the sandbox mode */ 
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (1,'0001_01_01_000000_create_users_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (2,'0001_01_01_000001_create_cache_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (3,'0001_01_01_000002_create_jobs_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (4,'2025_06_17_012814_create_companies_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (5,'2025_06_17_012815_create_patients_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (6,'2025_06_17_012822_create_mcu_packages_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (7,'2025_06_17_012834_create_appointments_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (8,'2025_06_17_012841_create_mcu_results_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (9,'2025_06_17_012848_create_lab_results_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (10,'2025_06_17_012853_create_radiology_results_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (11,'2025_06_17_012905_create_audiometry_results_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (12,'2025_06_17_012912_create_visus_results_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (13,'2025_06_17_012917_create_payments_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (14,'2025_06_17_012931_create_health_questionnaires_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (15,'2025_06_17_014707_create_permission_tables',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (16,'2025_06_17_020737_create_mcu_package_addons_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (17,'2025_06_18_000001_create_employees_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (18,'2025_06_18_000002_create_locations_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (19,'2025_06_18_000003_create_report_templates_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (20,'2025_06_18_000004_create_physical_exam_parameters_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (21,'2025_06_18_000005_create_spirometry_parameters_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (22,'2025_06_18_000006_create_audiometry_frequencies_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (23,'2025_06_18_000007_create_hearing_loss_types_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (24,'2025_06_18_000008_create_lab_tests_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (25,'2025_06_18_000009_create_lab_test_references_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (26,'2025_06_18_000010_create_usg_exam_areas_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (27,'2025_06_18_000011_create_usg_conclusion_templates_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (28,'2025_06_18_000012_create_vision_acuity_types_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (29,'2025_06_18_000013_create_vision_correction_types_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (30,'2025_06_18_000014_create_vision_diagnosis_categories_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (31,'2025_06_18_000015_create_radiology_exam_types_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (32,'2025_06_18_000016_create_radiology_conclusion_templates_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (33,'2025_06_22_111217_add_status_fields_to_appointment_mcu_item_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (34,'2025_06_22_111227_add_tracking_fields_to_appointments_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (35,'2025_06_22_111233_create_corporate_invitations_and_employees_tables',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (36,'2025_06_22_115611_add_birth_date_to_employees_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (37,'2025_06_22_143400_create_positions_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (38,'2025_06_22_143407_create_departments_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (39,'2025_06_22_143413_add_position_and_department_foreign_keys_to_employees_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (40,'2025_06_22_173310_create_mcu_items_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (41,'2025_06_22_173829_create_client_job_positions_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (42,'2025_06_22_205530_create_matrix_rules_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (43,'2025_06_23_000222_add_position_id_to_corporate_invitation_employees',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (44,'2025_06_23_055427_add_photo_to_patients_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (45,'2025_06_23_100000_add_department_to_mcu_items',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (46,'2025_06_23_100001_add_is_active_to_mcu_items',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (47,'2025_06_23_200000_add_processing_fields_to_appointment_mcu_item',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (48,'2025_06_23_300000_add_appointment_mcu_item_id_to_lab_results',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (49,'2025_06_23_300001_add_appointment_mcu_item_id_to_radiology_results',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (50,'2025_06_23_300002_create_physical_exam_results_table',1);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (51,'2025_07_01_031529_add_hiv_consent_to_lab_results_table',2);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (52,'2025_07_01_032439_add_results_data_to_lab_results_table',3);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (53,'2025_07_01_040351_add_notes_to_lab_results_table',4);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (54,'2025_07_01_044238_add_notes_to_lab_results_table',5);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (55,'2025_07_01_044928_add_missing_columns_to_lab_results_table',6);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (56,'2025_07_01_050522_add_foreign_keys_to_lab_result_items_table',7);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (57,'2025_07_01_080330_add_job_position_to_patients_table',8);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (58,'2025_01_07_010000_add_ktp_photo_to_patients_table',9);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (59,'2025_07_01_081755_add_ktp_photo_to_patients_table',10);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (60,'2025_01_02_999999_fix_patients_phone_number_nullable',11);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (61,'2025_07_01_172238_create_spirometry_results_table',12);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (62,'2025_07_01_172430_add_appointment_mcu_item_id_to_audiometry_and_visus_results',12);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (63,'2025_07_01_175250_add_assignment_fields_to_appointment_mcu_item_table',13);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (64,'2025_07_01_192628_create_lab_staff_table',14);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (65,'2025_07_01_194041_remove_license_specialization_from_lab_staff_table',15);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (66,'2025_07_01_201103_update_physical_exam_results_table',16);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (67,'2025_07_02_015003_add_verification_fields_to_physical_exam_results_table',16);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (68,'2025_07_04_015547_add_mcu_time_to_corporate_invitations_table',17);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (69,'2025_07_04_015833_create_work_activities_table',18);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (70,'2024_01_15_000000_create_invoices_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (71,'2024_01_15_000001_create_invoice_items_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (72,'2024_03_14_000001_add_patient_id_to_corporate_invitation_employees_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (73,'2024_03_19_create_appointment_mcu_items_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (74,'2024_12_20_000000_create_audiometry_staff_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (75,'2024_12_20_000001_add_staff_columns_to_audiometry_results_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (76,'2025_01_01_000000_create_sick_letters_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (77,'2025_01_15_000000_add_performance_indexes',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (78,'2025_07_04_024819_create_family_health_histories_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (79,'2025_07_04_024925_add_detailed_health_history_to_health_questionnaires_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (80,'2025_07_04_124000_update_health_questionnaire_fields_exact',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (81,'2025_07_04_130000_fix_work_activities_column_names',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (82,'2025_07_04_174343_add_missing_protection_columns_to_work_activities_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (83,'2025_07_04_200100_create_patient_lifestyle_data_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (84,'2025_07_04_200200_fix_family_health_histories_structure',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (85,'2025_07_04_200300_add_work_info_columns_to_work_activities_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (86,'2025_07_04_200400_fix_appointment_id_nullable_in_tables',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (87,'2025_07_07_065840_add_selected_staff_to_lab_results_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (88,'2025_07_07_071104_create_physical_exam_staff_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (89,'2025_07_07_074310_add_selected_staff_to_physical_exam_results_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (90,'2025_07_07_095315_create_radiology_staff_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (91,'2025_07_07_095930_add_staff_fields_to_radiology_results_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (92,'2025_07_10_112638_create_laboratory_parameters_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (93,'2025_07_12_095848_add_hiv_consent_document_path_to_lab_results_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (94,'2025_07_12_105826_fix_lab_result_items_foreign_key',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (95,'2025_07_12_110700_add_verification_columns_to_appointment_mcu_items_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (96,'2025_07_14_110903_create_visus_staff_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (97,'2025_07_14_120101_add_vision_fields_to_visus_results_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (98,'2025_07_14_122234_add_staff_selection_fields_to_visus_results_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (99,'2025_07_14_123307_update_visus_results_status_enum',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (100,'2025_07_14_163414_remove_impression_column_from_radiology_results_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (101,'2025_07_14_165939_create_spirometry_staff_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (102,'2025_07_14_165954_update_spirometry_results_table_for_new_structure',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (103,'2025_07_14_191231_update_spirometry_results_status_enum',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (104,'2025_07_17_223027_add_corrected_vision_fields_to_visus_results_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (105,'2025_07_19_070544_fix_audiometry_results_foreign_key',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (106,'2025_07_19_124010_update_audiometry_results_status_enum',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (107,'2025_07_22_000001_add_mcu_package_to_corporate_invitations_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (108,'2025_07_22_000002_create_corporate_invoices_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (109,'2025_07_25_000001_create_company_mcu_packages_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (110,'2025_07_27_182430_rename_date_of_birth_to_birth_date_in_corporate_invitation_employees_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (111,'2025_07_27_185937_update_lab_results_status_enum_add_verified',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (112,'2025_07_27_185947_update_radiology_results_status_enum_add_verified_rejected',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (113,'2025_07_28_030742_update_mcu_results_health_status_enum',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (114,'2025_07_28_031122_add_unique_appointment_id_to_mcu_results_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (115,'2025_08_01_232019_add_new_lifestyle_fields_to_patient_lifestyle_data_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (116,'2025_08_01_235730_add_new_lifestyle_fields_to_patient_lifestyle_data_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (117,'2025_08_03_231948_add_signature_path_to_patients_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (118,'2025_08_04_120000_update_fecalysis_to_pemeriksaan_feses',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (119,'2025_08_06_114013_add_mcu_suggestions_to_mcu_results_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (120,'2025_08_08_000001_add_gender_pricing_to_company_mcu_packages',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (121,'2025_08_08_113516_add_dynamic_package_fields_to_mcu_packages_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (122,'2025_08_14_000001_normalize_permission_names',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (123,'2025_08_15_034812_clear_medical_record_number_from_soft_deleted_patients',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (124,'2025_08_15_113621_add_sample_collection_statuses_to_appointment_mcu_items',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (125,'2025_08_15_114138_add_sample_collection_statuses_to_lab_results_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (126,'2025_08_15_214058_create_ekg_staff_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (127,'2025_08_15_214059_create_elektrokardiograms_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (128,'2025_08_15_214100_add_staff_verification_to_elektrokardiograms_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (129,'2025_08_22_093120_add_ekg_images_and_technician_notes_to_elektrokardiograms_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (130,'2025_08_22_101038_add_sample_collected_status_to_spirometry',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (131,'2025_08_22_101908_add_quick_registration_fields_to_patients_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (132,'2025_08_23_100414_add_missing_fields_to_patient_lifestyle_data_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (133,'2025_08_23_100433_add_signature_path_to_patients_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (134,'2025_08_23_141959_update_radiology_results_examination_type_default',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (135,'2025_08_23_161649_add_sample_collected_status_to_audiometry_results',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (136,'2025_08_30_085728_fix_radiology_exam_type_codes',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (137,'2025_09_02_161323_add_qr_fields_to_lab_results_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (138,'2025_09_07_152948_add_cancellation_fields_to_lab_results_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (139,'2025_09_09_235921_add_detailed_age_snapshot_to_sick_letters_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (140,'2025_09_10_001553_update_existing_sick_letters_detailed_age',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (141,'2025_09_10_002658_add_job_position_to_sick_letters_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (142,'2025_09_10_005608_update_existing_sick_letters_job_position',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (143,'2025_09_10_010533_create_health_letters_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (144,'2025_09_10_013501_update_existing_health_letters_job_position',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (145,'2025_09_10_020531_create_eye_health_letters_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (146,'2025_09_10_135414_fix_invoice_due_dates_to_first_of_month',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (147,'2025_09_10_142809_add_eye_selection_fields_to_eye_health_letters_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (148,'2025_09_10_144041_add_additional_fields_to_health_letters_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (149,'2025_09_15_000000_rename_interpretation_fields_in_audiometry_results_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (150,'2025_09_15_000100_add_bc_results_to_audiometry_results_table',19);
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES (151,'2025_09_15_200000_fix_migrations_batch_column_type',19);
