From 76956507392cbf295eab8d394742bedd981b6f36 Mon Sep 17 00:00:00 2001 From: R Date: Fri, 19 Jan 2024 10:58:58 +0700 Subject: [PATCH] Add Seeder UpdateTarifLMSSeeder --- database/seeders/UpdateTarifLMSSeeder.php | 213 ++++++++++++++++++++++ 1 file changed, 213 insertions(+) create mode 100644 database/seeders/UpdateTarifLMSSeeder.php diff --git a/database/seeders/UpdateTarifLMSSeeder.php b/database/seeders/UpdateTarifLMSSeeder.php new file mode 100644 index 00000000..6c519d3e --- /dev/null +++ b/database/seeders/UpdateTarifLMSSeeder.php @@ -0,0 +1,213 @@ + "A", + // "sHealthCare" => "Rumah Sakit Awal Bros Sudirman Pekanbaru", + // ], + // [ + // "sKodeRS" => "B", + // "sHealthCare" => "Rumah Sakit Awal Bros Batam", + // ], + // [ + // "sKodeRS" => "BW", + // "sHealthCare" => "Primaya Hospital Bhakti Wara", + // ], + // [ + // "sKodeRS" => "C", + // "sHealthCare" => "Primaya Hospital Tangerang", + // ], + // [ + // "sKodeRS" => "D", + // "sHealthCare" => "Primaya Hospital Bekasi Barat", + // ], + // [ + // "sKodeRS" => "E", + // "sHealthCare" => "Primaya Evasari Hospital", + // ], + // [ + // "sKodeRS" => "F", + // "sHealthCare" => "Primaya Hospital Makassar", + // ], + // [ + // "sKodeRS" => "G", + // "sHealthCare" => "Rumah Sakit Awal Bros Ujung Batu", + // ], + // [ + // "sKodeRS" => "I", + // "sHealthCare" => "Rumah Sakit Awal Bros Panam", + // ], + // [ + // "sKodeRS" => "K", + // "sHealthCare" => "Rumah Sakit Awal Bros Ahmad Yani", + // ], + // [ + // "sKodeRS" => "M", + // "sHealthCare" => "Primaya Hospital Bekasi Timur", + // ], + // [ + // "sKodeRS" => "N", + // "sHealthCare" => "Primaya Hospital Betang Pambelum", + // ], + // [ + // "sKodeRS" => "O", + // "sHealthCare" => "Primaya Hospital Inco Sorowako", + // ], + // [ + // "sKodeRS" => "P", + // "sHealthCare" => "Primaya Hospital Bekasi Utara", + // ], + // [ + // "sKodeRS" => "PK", + // "sHealthCare" => "Primaya Hospital Pasar Kemis", + // ], + // [ + // "sKodeRS" => "Q", + // "sHealthCare" => "Primaya Hospital Karawang", + // ], + // [ + // "sKodeRS" => "SK", + // "sHealthCare" => "Primaya Hospital Sukabumi", + // ], + // ] + + $dataTarifs = [ + // [ + // 'adm_rajal' => null, + + // 'appt_umum' => null, + // 'walkin_umum' => null, + // 'telekonsul_umum' => null, + + // 'appt_spesialis' => 250000, + // 'walkin_spesialis' => 250000, + // 'telekonsul_spesialis' => 213000, + + // 'appt_subspesialis' => 345000, + // 'walkin_subspesialis' => 345000, + // 'telekonsul_subspesialis' => 293000, + + // 'applied_to' => ['A', 'KODERSLMS'] + // ], + [ + 'adm_rajal' => 100000, + + 'appt_umum' => 120000, + 'walkin_umum' => 120000, + 'telekonsul_umum' => 102000, + + 'appt_spesialis' => 250000, + 'walkin_spesialis' => 250000, + 'telekonsul_spesialis' => 213000, + + 'appt_subspesialis' => 345000, + 'walkin_subspesialis' => 345000, + 'telekonsul_subspesialis' => 293000, + + 'applied_to' => ['P'] + ] + ]; + + $spesialisUmum = Speciality::where('sSlug', 'general-practitioner')->first(); + + foreach ($dataTarifs as $tarif) { + // [MARK] : UMUM + // Update Tarif Dokter Umum + $updateUmum = []; + if ($tarif['walkin_umum'] != null) { + $updateUmum[] = ['nBiaya' => $tarif['walkin_umum']]; + } + if ($tarif['telekonsul_umum'] != null) { + $updateUmum[] = ['nBiayaTC' => $tarif['telekonsul_umum']]; + $updateUmum[] = ['nBiayaATC' => $tarif['telekonsul_umum']]; + } + // Updating + $dokUmum = JadwalDokter::query() + ->where('nIDSpesialis', $spesialisUmum->nID) + ->whereHas('healthcare', function($hc) use ($tarif) { + $hc->whereIn('sKodeRS', $tarif['applied_to']); + }) + ->update([ + 'nBiaya' => $tarif['walkin_umum'], + 'nBiayaTC' => $tarif['telekonsul_umum'], + 'nBiayaATC' => $tarif['telekonsul_umum'], + 'dUpdateOn' => now() + ]); + $this->command->info('Updating : Dokter Umum'); + + // [MARK] : SPESIALIS + // Update Tarif Dokter Spesialis + $updateSpesialis = []; + if ($tarif['walkin_spesialis'] != null) { + $updateUmum[] = ['nBiaya' => $tarif['walkin_spesialis']]; + } + if ($tarif['telekonsul_spesialis'] != null) { + $updateUmum[] = ['nBiayaTC' => $tarif['telekonsul_spesialis']]; + $updateUmum[] = ['nBiayaATC' => $tarif['telekonsul_spesialis']]; + } + + // Updating + $dokSpesialis = JadwalDokter::query() + ->whereNot(function ($q) use ($spesialisUmum) { + $q->where('nIDSpesialis', $spesialisUmum->nID); + }) + ->where('sIsSubSpesialis', 0) + ->whereHas('healthcare', function($hc) use ($tarif) { + $hc->whereIn('sKodeRS', $tarif['applied_to']); + }) + ->update([ + 'nBiaya' => $tarif['walkin_spesialis'], + 'nBiayaTC' => $tarif['telekonsul_spesialis'], + 'nBiayaATC' => $tarif['telekonsul_spesialis'], + 'dUpdateOn' => now() + ]); + $this->command->info('Updating : Dokter Spesialis'); + + + // [MARK] : SUBSPESIALIS + // Update Tarif Dokter Sub Spesialis + $updateSubSpesialis = []; + if ($tarif['walkin_subspesialis'] != null) { + $updateUmum[] = ['nBiaya' => $tarif['walkin_subspesialis']]; + } + if ($tarif['telekonsul_subspesialis'] != null) { + $updateUmum[] = ['nBiayaTC' => $tarif['telekonsul_subspesialis']]; + $updateUmum[] = ['nBiayaATC' => $tarif['telekonsul_subspesialis']]; + } + + // Updating + $dokSubSpesialis = JadwalDokter::query() + ->whereNot(function ($q) use ($spesialisUmum) { + $q->where('nIDSpesialis', $spesialisUmum->nID); + }) + ->where('sIsSubSpesialis', 1) + ->whereHas('healthcare', function($hc) use ($tarif) { + $hc->whereIn('sKodeRS', $tarif['applied_to']); + }) + ->update([ + 'nBiaya' => $tarif['walkin_subspesialis'], + 'nBiayaTC' => $tarif['telekonsul_subspesialis'], + 'nBiayaATC' => $tarif['telekonsul_subspesialis'], + 'dUpdateOn' => now() + ]); + $this->command->info('Updating : Dokter Sub Spesialis'); + } + } +}