-- https://www.phpmyadmin.net/
--

START TRANSACTION;



-- --------------------------------------------------------

--
-- Table structure for table `failed_jobs`
--

CREATE TABLE `failed_jobs` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `uuid` varchar(255) NOT NULL,
  `connection` text NOT NULL,
  `queue` text NOT NULL,
  `payload` longtext NOT NULL,
  `exception` longtext NOT NULL,
  `failed_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `jobs`
--

CREATE TABLE `jobs` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `queue` varchar(255) NOT NULL,
  `payload` longtext NOT NULL,
  `attempts` tinyint(3) UNSIGNED NOT NULL,
  `reserved_at` int(10) UNSIGNED DEFAULT NULL,
  `available_at` int(10) UNSIGNED NOT NULL,
  `created_at` int(10) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `job_batches`
--

CREATE TABLE `job_batches` (
  `id` varchar(255) NOT NULL,
  `name` varchar(255) NOT NULL,
  `total_jobs` int(11) NOT NULL,
  `pending_jobs` int(11) NOT NULL,
  `failed_jobs` int(11) NOT NULL,
  `failed_job_ids` longtext NOT NULL,
  `options` mediumtext DEFAULT NULL,
  `cancelled_at` int(11) DEFAULT NULL,
  `created_at` int(11) NOT NULL,
  `finished_at` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `kategoris`
--

CREATE TABLE `kategoris` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `nama` varchar(255) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `kategoris`
--

INSERT INTO `kategoris` (`id`, `nama`, `created_at`, `updated_at`) VALUES
(1, 'Obat Bebas', '2025-08-19 05:21:31', '2025-08-19 05:21:31'),
(2, 'Obat Keras', '2025-08-19 05:21:39', '2025-08-19 05:21:39'),
(3, 'Obat Paten', '2025-08-19 05:21:54', '2025-08-19 05:21:54');

-- --------------------------------------------------------

--
-- Table structure for table `master_obats`
--

CREATE TABLE `master_obats` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `nama` varchar(255) NOT NULL,
  `kategori_id` bigint(20) UNSIGNED NOT NULL,
  `status` enum('aktif','tidak aktif') NOT NULL DEFAULT 'aktif',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `master_obats`
--

INSERT INTO `master_obats` (`id`, `nama`, `kategori_id`, `status`, `created_at`, `updated_at`) VALUES
(5, 'Paracetamol', 2, 'aktif', '2025-08-23 08:59:19', '2025-08-23 08:59:19'),
(6, 'Vitacid Tretinoin 0,025', 2, 'aktif', '2025-08-29 22:08:00', '2025-08-29 22:08:00'),
(7, 'Niacef 4%', 1, 'aktif', '2025-09-01 08:19:07', '2025-09-01 08:19:07'),
(8, 'Amoxidin', 1, 'tidak aktif', '2025-09-03 06:47:39', '2025-09-04 21:31:15');

-- --------------------------------------------------------

--
-- Table structure for table `migrations`
--

CREATE TABLE `migrations` (
  `id` int(10) UNSIGNED NOT NULL,
  `migration` varchar(255) NOT NULL,
  `batch` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `migrations`
--

INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES
(1, '0001_01_01_000000_create_users_table', 1),
(2, '0001_01_01_000001_create_cache_table', 1),
(3, '0001_01_01_000002_create_jobs_table', 1),
(4, '2025_07_16_231243_create_kategoris_table', 1),
(5, '2025_07_16_231324_create_obats_table', 1),
(6, '2025_07_19_031850_create_suppliers_table', 1),
(7, '2025_07_19_062957_create_reseps_table', 1),
(9, '2025_07_20_151646_create_transaksis_table', 1),
(11, '2025_07_26_044121_add_dosis_aturan_pakai_to_transaksi_items_table', 1),
(12, '2025_07_29_145050_add_status_to_obats_table', 1),
(13, '2025_08_07_132033_create_pembelians_table', 1),
(14, '2025_08_14_130556_create_master_obats_table', 2),
(15, '2025_08_07_134642_create_pembelian_details_table', 3),
(16, '2025_08_19_134515_add_total_to_pembelians_table', 4),
(18, '2025_09_01_124336_add_kode_barcode_to_pembelian_details_table', 5),
(19, '2025_09_06_024009_create_rekam_mediks_table', 5),
(20, '2025_07_19_064533_create_resep_obats_table', 6),
(21, '2025_09_08_142820_add_rekam_medik_id_to_transaksis_table', 7),
(22, '2025_07_20_151653_create_transaksi_items_table', 8),
(23, '2025_09_12_085723_add_jumlah_to_resep_obats_table', 9);

-- --------------------------------------------------------

--
-- Table structure for table `obats`
--

CREATE TABLE `obats` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `nama` varchar(255) NOT NULL,
  `kategori_id` bigint(20) UNSIGNED NOT NULL,
  `satuan` varchar(255) NOT NULL,
  `stok` int(11) NOT NULL,
  `harga` decimal(10,2) NOT NULL,
  `expired_at` date NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `status` enum('aktif','tidak aktif') NOT NULL DEFAULT 'aktif'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `pembelians`
--

CREATE TABLE `pembelians` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `supplier_id` bigint(20) UNSIGNED NOT NULL,
  `tanggal_pembelian` date NOT NULL,
  `total` decimal(15,2) NOT NULL DEFAULT 0.00,
  `total_pembayaran` decimal(15,2) NOT NULL DEFAULT 0.00,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `pembelians`
--

INSERT INTO `pembelians` (`id`, `supplier_id`, `tanggal_pembelian`, `total`, `total_pembayaran`, `created_at`, `updated_at`) VALUES
(2, 1, '2025-08-30', 0.00, 5000000.00, '2025-08-29 22:08:32', '2025-08-29 22:08:32'),
(3, 1, '2025-09-03', 0.00, 3000000.00, '2025-09-03 06:06:46', '2025-09-03 06:06:46'),
(4, 1, '2025-09-03', 0.00, 250000.00, '2025-09-03 06:55:29', '2025-09-03 06:55:29');

-- --------------------------------------------------------

--
-- Table structure for table `pembelian_details`
--

CREATE TABLE `pembelian_details` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `pembelian_id` bigint(20) UNSIGNED NOT NULL,
  `master_obat_id` bigint(20) UNSIGNED NOT NULL,
  `kode_barcode` varchar(255) DEFAULT NULL,
  `jumlah` int(11) NOT NULL,
  `satuan` varchar(255) NOT NULL,
  `harga_beli` decimal(15,2) NOT NULL,
  `harga_jual` decimal(15,2) NOT NULL,
  `expired_at` date DEFAULT NULL,
  `subtotal` decimal(15,2) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `pembelian_details`
--

INSERT INTO `pembelian_details` (`id`, `pembelian_id`, `master_obat_id`, `kode_barcode`, `jumlah`, `satuan`, `harga_beli`, `harga_jual`, `expired_at`, `subtotal`, `created_at`, `updated_at`) VALUES
(2, 2, 6, NULL, 99, 'pcs', 50000.00, 55000.00, '2025-12-30', 5000000.00, '2025-08-29 22:08:32', '2025-09-13 01:31:12'),
(3, 3, 7, NULL, 7, 'pcs', 50000.00, 66000.00, '2025-12-03', 3000000.00, '2025-09-03 06:06:46', '2025-09-13 01:10:37'),
(4, 4, 8, NULL, 5, 'pcs', 50000.00, 66000.00, '2025-09-01', 250000.00, '2025-09-03 06:55:29', '2025-09-03 06:55:29');

-- --------------------------------------------------------

--
-- Table structure for table `rekam_mediks`
--

CREATE TABLE `rekam_mediks` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `nama_pasien` varchar(255) NOT NULL,
  `umur` int(11) NOT NULL,
  `alamat` varchar(255) DEFAULT NULL,
  `keluhan` text DEFAULT NULL,
  `indikasi` text DEFAULT NULL,
  `penanganan` text DEFAULT NULL,
  `dokter_id` bigint(20) UNSIGNED NOT NULL,
  `resep_id` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `rekam_mediks`
--

INSERT INTO `rekam_mediks` (`id`, `nama_pasien`, `umur`, `alamat`, `keluhan`, `indikasi`, `penanganan`, `dokter_id`, `resep_id`, `created_at`, `updated_at`) VALUES
(1, 'Andika', 12, 'Barong Tongkok', 'Sakit Kepala', 'Sakit Kepala', 'Istirahat dan minum obat', 3, 1, '2025-09-07 00:00:01', '2025-09-07 00:00:01'),
(2, 'Gege', 12, 'Samarinda', 'Jerawat', 'Jerawat', 'Salycid acid', 3, 2, '2025-09-13 01:30:45', '2025-09-13 01:30:45');

-- --------------------------------------------------------

--
-- Table structure for table `reseps`
--

CREATE TABLE `reseps` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `dokter_id` bigint(20) UNSIGNED NOT NULL,
  `kode_resep` varchar(255) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `reseps`
--

INSERT INTO `reseps` (`id`, `dokter_id`, `kode_resep`, `created_at`, `updated_at`) VALUES
(1, 3, 'RSP-3XQBML', '2025-09-07 00:00:01', '2025-09-07 00:00:01'),
(2, 3, 'RSP-THNCOB', '2025-09-13 01:30:45', '2025-09-13 01:30:45');

-- --------------------------------------------------------

--
-- Table structure for table `resep_obats`
--

CREATE TABLE `resep_obats` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `resep_id` bigint(20) UNSIGNED NOT NULL,
  `obat_id` bigint(20) UNSIGNED NOT NULL,
  `jumlah` int(11) NOT NULL,
  `dosis` varchar(255) NOT NULL,
  `aturan_pakai` text NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `resep_obats`
--

INSERT INTO `resep_obats` (`id`, `resep_id`, `obat_id`, `jumlah`, `dosis`, `aturan_pakai`, `created_at`, `updated_at`) VALUES
(1, 1, 5, 0, '3 x sehari', 'Makan 3 kali sehari jika kambuh', '2025-09-07 00:00:01', '2025-09-07 00:00:01'),
(2, 2, 6, 1, 'seminggu 2x', 'Malam hari', '2025-09-13 01:30:45', '2025-09-13 01:30:45');

-- --------------------------------------------------------

--
-- Table structure for table `sessions`
--

CREATE TABLE `sessions` (
  `id` varchar(255) NOT NULL,
  `user_id` bigint(20) UNSIGNED DEFAULT NULL,
  `ip_address` varchar(45) DEFAULT NULL,
  `user_agent` text DEFAULT NULL,
  `payload` longtext NOT NULL,
  `last_activity` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `sessions`
--

INSERT INTO `sessions` (`id`, `user_id`, `ip_address`, `user_agent`, `payload`, `last_activity`) VALUES
('2scp86rxuZgndmmpsMb9dCT7qP5u7MaJhHOKV7Ct', 2, '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36', 'YTo0OntzOjY6Il90b2tlbiI7czo0MDoiSkVFcVhFR2pVUXpUOFNHTmVrcTR5a0RuRko2VmU4amlWN0tzcmRTZyI7czo2OiJfZmxhc2giO2E6Mjp7czozOiJvbGQiO2E6MDp7fXM6MzoibmV3IjthOjA6e319czo5OiJfcHJldmlvdXMiO2E6MTp7czozOiJ1cmwiO3M6NDI6Imh0dHA6Ly8xMjcuMC4wLjE6ODAwMC9rYXJ5YXdhbi90cmFuc2Frc2kvNSI7fXM6NTA6ImxvZ2luX3dlYl81OWJhMzZhZGRjMmIyZjk0MDE1ODBmMDE0YzdmNThlYTRlMzA5ODlkIjtpOjI7fQ==', 1757753201),
('6ECoDJOU5RxL33vUNZ1bA8pKAKkyjm0pBa1oERDO', 2, '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36', 'YTo0OntzOjY6Il90b2tlbiI7czo0MDoibm9TSzFPT1diMG10Y21lQ290NnN6Y3pGaTA5RUw4ZjFwdzRHOTM4eiI7czo2OiJfZmxhc2giO2E6Mjp7czozOiJvbGQiO2E6MDp7fXM6MzoibmV3IjthOjA6e319czo5OiJfcHJldmlvdXMiO2E6MTp7czozOiJ1cmwiO3M6NTA6Imh0dHA6Ly8xMjcuMC4wLjE6ODAwMC9rYXJ5YXdhbi9yZWthbS1tZWRpay8xL3RlYnVzIjt9czo1MDoibG9naW5fd2ViXzU5YmEzNmFkZGMyYjJmOTQwMTU4MGYwMTRjN2Y1OGVhNGUzMDk4OWQiO2k6Mjt9', 1757812829),
('B4SyjxtUXNPz5OpCilGxXWqRfXtr7kWoO6bEo9WT', 2, '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36', 'YTo0OntzOjY6Il90b2tlbiI7czo0MDoiQmxxb1RUcUZBekNjcmpET1VKZElDRkw4bTVIbThQV2gzZlNRRzA1YSI7czo2OiJfZmxhc2giO2E6Mjp7czozOiJvbGQiO2E6MDp7fXM6MzoibmV3IjthOjA6e319czo5OiJfcHJldmlvdXMiO2E6MTp7czozOiJ1cmwiO3M6NDI6Imh0dHA6Ly8xMjcuMC4wLjE6ODAwMC9rYXJ5YXdhbi9yZWthbS1tZWRpayI7fXM6NTA6ImxvZ2luX3dlYl81OWJhMzZhZGRjMmIyZjk0MDE1ODBmMDE0YzdmNThlYTRlMzA5ODlkIjtpOjI7fQ==', 1757826990),
('gT9Y67rJ5qUVCuc47g0nUPi6zYgLLug7UHVhvBjr', 2, '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36', 'YTo0OntzOjY6Il90b2tlbiI7czo0MDoiN3VIMG9lNlV4SXVmaTlPMTZ3OEEyM0o1dkJad1p1Y2NyZmlnV1FaTyI7czo2OiJfZmxhc2giO2E6Mjp7czozOiJvbGQiO2E6MDp7fXM6MzoibmV3IjthOjA6e319czo1MDoibG9naW5fd2ViXzU5YmEzNmFkZGMyYjJmOTQwMTU4MGYwMTRjN2Y1OGVhNGUzMDk4OWQiO2k6MjtzOjk6Il9wcmV2aW91cyI7YToxOntzOjM6InVybCI7czo0MDoiaHR0cDovLzEyNy4wLjAuMTo4MDAwL2thcnlhd2FuL3RyYW5zYWtzaSI7fX0=', 1757763421),
('tvZduSvzB47L6FeZVmAuIIH5J6uv39ytvmez7d9x', NULL, '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36', 'YTo0OntzOjY6Il90b2tlbiI7czo0MDoiNEVDVlJnQXc1SHlkMENnU3dkekZMU1dZUnUzbkQxV2tabTN0Y28xZiI7czozOiJ1cmwiO2E6MTp7czo4OiJpbnRlbmRlZCI7czozNzoiaHR0cDovLzEyNy4wLjAuMTo4MDAwL2FkbWluL3BlbWJlbGlhbiI7fXM6OToiX3ByZXZpb3VzIjthOjE6e3M6MzoidXJsIjtzOjI3OiJodHRwOi8vMTI3LjAuMC4xOjgwMDAvbG9naW4iO31zOjY6Il9mbGFzaCI7YToyOntzOjM6Im9sZCI7YTowOnt9czozOiJuZXciO2E6MDp7fX19', 1757750088),
('WeQLbdivPvcvo2pBd7WccktZE7OOCmF3gnOMEFb9', NULL, '127.0.0.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36', 'YTozOntzOjY6Il90b2tlbiI7czo0MDoiWGd1QVdDSzBqNXdjbkVpbXFqc1AyRTl2Q1MzaWp0MjdaakJFMTl6ZyI7czo5OiJfcHJldmlvdXMiO2E6MTp7czozOiJ1cmwiO3M6Mjc6Imh0dHA6Ly8xMjcuMC4wLjE6ODAwMC9sb2dpbiI7fXM6NjoiX2ZsYXNoIjthOjI6e3M6Mzoib2xkIjthOjA6e31zOjM6Im5ldyI7YTowOnt9fX0=', 1757750043),
('xPDBvplDquuLY0PfwfzTuk41uQ35phmOXokWRRfg', 2, '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36', 'YTo1OntzOjY6Il90b2tlbiI7czo0MDoiVzh0MU9SRTlMeGZocHhYb1RQWUUwSnFVNUhMaHFLdktCVXd2NnNqUCI7czozOiJ1cmwiO2E6MTp7czo4OiJpbnRlbmRlZCI7czo0MDoiaHR0cDovLzEyNy4wLjAuMTo4MDAwL2thcnlhd2FuL3RyYW5zYWtzaSI7fXM6OToiX3ByZXZpb3VzIjthOjE6e3M6MzoidXJsIjtzOjUwOiJodHRwOi8vMTI3LjAuMC4xOjgwMDAva2FyeWF3YW4vcml3YXlhdC1yZWthbS1tZWRpayI7fXM6NjoiX2ZsYXNoIjthOjI6e3M6Mzoib2xkIjthOjA6e31zOjM6Im5ldyI7YTowOnt9fXM6NTA6ImxvZ2luX3dlYl81OWJhMzZhZGRjMmIyZjk0MDE1ODBmMDE0YzdmNThlYTRlMzA5ODlkIjtpOjI7fQ==', 1757772548);

-- --------------------------------------------------------

--
-- Table structure for table `suppliers`
--

CREATE TABLE `suppliers` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `nama` varchar(255) NOT NULL,
  `alamat` varchar(255) DEFAULT NULL,
  `telepon` varchar(255) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `suppliers`
--

INSERT INTO `suppliers` (`id`, `nama`, `alamat`, `telepon`, `created_at`, `updated_at`) VALUES
(1, 'CV Anugrah', 'Samarinda', '+6285346726943', '2025-08-19 05:39:16', '2025-08-19 05:39:16');

-- --------------------------------------------------------

--
-- Table structure for table `transaksis`
--

CREATE TABLE `transaksis` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `user_id` bigint(20) UNSIGNED NOT NULL,
  `rekam_medik_id` bigint(20) UNSIGNED DEFAULT NULL,
  `tanggal_transaksi` datetime NOT NULL,
  `total` decimal(12,2) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `transaksis`
--

INSERT INTO `transaksis` (`id`, `user_id`, `rekam_medik_id`, `tanggal_transaksi`, `total`, `created_at`, `updated_at`) VALUES
(3, 2, NULL, '2025-09-13 03:53:00', 198000.00, '2025-09-12 20:56:35', '2025-09-12 20:56:35'),
(4, 2, NULL, '2025-09-13 08:10:00', 3300000.00, '2025-09-13 01:10:37', '2025-09-13 01:10:37'),
(5, 2, 2, '2025-09-13 08:31:12', 55000.00, '2025-09-13 01:31:12', '2025-09-13 01:31:12');

-- --------------------------------------------------------

--
-- Table structure for table `transaksi_items`
--

CREATE TABLE `transaksi_items` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `transaksi_id` bigint(20) UNSIGNED NOT NULL,
  `obat_id` bigint(20) UNSIGNED NOT NULL,
  `pembelian_detail_id` bigint(20) UNSIGNED DEFAULT NULL,
  `nama_obat` varchar(255) NOT NULL,
  `satuan` varchar(255) DEFAULT NULL,
  `jumlah` int(11) NOT NULL,
  `harga_satuan` decimal(15,2) NOT NULL,
  `subtotal` decimal(15,2) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `transaksi_items`
--

INSERT INTO `transaksi_items` (`id`, `transaksi_id`, `obat_id`, `pembelian_detail_id`, `nama_obat`, `satuan`, `jumlah`, `harga_satuan`, `subtotal`, `created_at`, `updated_at`) VALUES
(2, 3, 7, 3, 'Niacef 4%', 'pcs', 3, 66000.00, 198000.00, '2025-09-12 20:56:35', '2025-09-12 20:56:35'),
(3, 4, 7, 3, 'Niacef 4%', 'pcs', 50, 66000.00, 3300000.00, '2025-09-13 01:10:37', '2025-09-13 01:10:37'),
(4, 5, 6, 2, 'Vitacid Tretinoin 0,025', 'pcs', 1, 55000.00, 55000.00, '2025-09-13 01:31:12', '2025-09-13 01:31:12');

--
-- Indexes for table `failed_jobs`
--
ALTER TABLE `failed_jobs`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `failed_jobs_uuid_unique` (`uuid`);

--
-- Indexes for table `jobs`
--
ALTER TABLE `jobs`
  ADD PRIMARY KEY (`id`),
  ADD KEY `jobs_queue_index` (`queue`);

--
-- Indexes for table `job_batches`
--
ALTER TABLE `job_batches`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `kategoris`
--
ALTER TABLE `kategoris`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `master_obats`
--
ALTER TABLE `master_obats`
  ADD PRIMARY KEY (`id`),
  ADD KEY `master_obats_kategori_id_foreign` (`kategori_id`);

--
-- Indexes for table `migrations`
--
ALTER TABLE `migrations`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `obats`
--
ALTER TABLE `obats`
  ADD PRIMARY KEY (`id`),
  ADD KEY `obats_kategori_id_foreign` (`kategori_id`);

--
-- Indexes for table `pembelians`
--
ALTER TABLE `pembelians`
  ADD PRIMARY KEY (`id`),
  ADD KEY `pembelians_supplier_id_foreign` (`supplier_id`);

--
-- Indexes for table `pembelian_details`
--
ALTER TABLE `pembelian_details`
  ADD PRIMARY KEY (`id`),
  ADD KEY `pembelian_details_pembelian_id_foreign` (`pembelian_id`),
  ADD KEY `pembelian_details_master_obat_id_foreign` (`master_obat_id`);

--
-- Indexes for table `rekam_mediks`
--
ALTER TABLE `rekam_mediks`
  ADD PRIMARY KEY (`id`),
  ADD KEY `rekam_mediks_dokter_id_foreign` (`dokter_id`),
  ADD KEY `rekam_mediks_resep_id_foreign` (`resep_id`);

--
-- Indexes for table `reseps`
--
ALTER TABLE `reseps`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `reseps_kode_resep_unique` (`kode_resep`),
  ADD KEY `reseps_dokter_id_foreign` (`dokter_id`);

--
-- Indexes for table `resep_obats`
--
ALTER TABLE `resep_obats`
  ADD PRIMARY KEY (`id`),
  ADD KEY `resep_obats_resep_id_foreign` (`resep_id`),
  ADD KEY `resep_obats_obat_id_foreign` (`obat_id`);

--
-- Indexes for table `sessions`
--
ALTER TABLE `sessions`
  ADD PRIMARY KEY (`id`),
  ADD KEY `sessions_user_id_index` (`user_id`),
  ADD KEY `sessions_last_activity_index` (`last_activity`);

--
-- Indexes for table `suppliers`
--
ALTER TABLE `suppliers`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `transaksis`
--
ALTER TABLE `transaksis`
  ADD PRIMARY KEY (`id`),
  ADD KEY `transaksis_user_id_foreign` (`user_id`),
  ADD KEY `transaksis_rekam_medik_id_foreign` (`rekam_medik_id`);

--
-- Indexes for table `transaksi_items`
--
ALTER TABLE `transaksi_items`
  ADD PRIMARY KEY (`id`),
  ADD KEY `transaksi_items_transaksi_id_foreign` (`transaksi_id`),
  ADD KEY `transaksi_items_obat_id_foreign` (`obat_id`),
  ADD KEY `transaksi_items_pembelian_detail_id_foreign` (`pembelian_detail_id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `failed_jobs`
--
ALTER TABLE `failed_jobs`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `jobs`
--
ALTER TABLE `jobs`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `kategoris`
--
ALTER TABLE `kategoris`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT for table `master_obats`
--
ALTER TABLE `master_obats`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;

--
-- AUTO_INCREMENT for table `migrations`
--
ALTER TABLE `migrations`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=24;

--
-- AUTO_INCREMENT for table `obats`
--
ALTER TABLE `obats`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `pembelians`
--
ALTER TABLE `pembelians`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

--
-- AUTO_INCREMENT for table `pembelian_details`
--
ALTER TABLE `pembelian_details`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

--
-- AUTO_INCREMENT for table `rekam_mediks`
--
ALTER TABLE `rekam_mediks`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `reseps`
--
ALTER TABLE `reseps`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `resep_obats`
--
ALTER TABLE `resep_obats`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `suppliers`
--
ALTER TABLE `suppliers`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `transaksis`
--
ALTER TABLE `transaksis`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

--
-- AUTO_INCREMENT for table `transaksi_items`
--
ALTER TABLE `transaksi_items`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `master_obats`
--
ALTER TABLE `master_obats`
  ADD CONSTRAINT `master_obats_kategori_id_foreign` FOREIGN KEY (`kategori_id`) REFERENCES `kategoris` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `obats`
--
ALTER TABLE `obats`
  ADD CONSTRAINT `obats_kategori_id_foreign` FOREIGN KEY (`kategori_id`) REFERENCES `kategoris` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `pembelians`
--
ALTER TABLE `pembelians`
  ADD CONSTRAINT `pembelians_supplier_id_foreign` FOREIGN KEY (`supplier_id`) REFERENCES `suppliers` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `pembelian_details`
--
ALTER TABLE `pembelian_details`
  ADD CONSTRAINT `pembelian_details_master_obat_id_foreign` FOREIGN KEY (`master_obat_id`) REFERENCES `master_obats` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `pembelian_details_pembelian_id_foreign` FOREIGN KEY (`pembelian_id`) REFERENCES `pembelians` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `rekam_mediks`
--
ALTER TABLE `rekam_mediks`
  ADD CONSTRAINT `rekam_mediks_dokter_id_foreign` FOREIGN KEY (`dokter_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `rekam_mediks_resep_id_foreign` FOREIGN KEY (`resep_id`) REFERENCES `reseps` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `reseps`
--
ALTER TABLE `reseps`
  ADD CONSTRAINT `reseps_dokter_id_foreign` FOREIGN KEY (`dokter_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `resep_obats`
--
ALTER TABLE `resep_obats`
  ADD CONSTRAINT `resep_obats_obat_id_foreign` FOREIGN KEY (`obat_id`) REFERENCES `master_obats` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `resep_obats_resep_id_foreign` FOREIGN KEY (`resep_id`) REFERENCES `reseps` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `transaksis`
--
ALTER TABLE `transaksis`
  ADD CONSTRAINT `transaksis_rekam_medik_id_foreign` FOREIGN KEY (`rekam_medik_id`) REFERENCES `rekam_mediks` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `transaksis_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `transaksi_items`
--
ALTER TABLE `transaksi_items`
  ADD CONSTRAINT `transaksi_items_obat_id_foreign` FOREIGN KEY (`obat_id`) REFERENCES `master_obats` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `transaksi_items_pembelian_detail_id_foreign` FOREIGN KEY (`pembelian_detail_id`) REFERENCES `pembelian_details` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `transaksi_items_transaksi_id_foreign` FOREIGN KEY (`transaksi_id`) REFERENCES `transaksis` (`id`) ON DELETE CASCADE;
COMMIT;

