update schedule dokter

This commit is contained in:
pajri
2023-01-28 09:44:14 +07:00
parent 335e24b17c
commit 1ce2655b65
6 changed files with 280 additions and 50 deletions

View File

@@ -0,0 +1,27 @@
<?php
namespace App\Models\OLDLMS;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Dokter extends Model
{
use HasFactory, SoftDeletes;
const CREATED_AT = 'dCreateOn';
const UPDATED_AT = 'dUpdateOn';
const DELETED_AT = 'dDeleteOn';
protected $connection = 'oldlms';
protected $table = 'tm_dokter';
protected $primaryKey = 'nID';
public function jadwalDokter()
{
return $this->hasMany(JadwalDokter::class, 'nIDDokter', 'nID');
}
}

View File

@@ -17,4 +17,11 @@ class Healthcare extends Model
protected $connection = 'oldlms'; protected $connection = 'oldlms';
protected $table = 'tm_healthcare'; protected $table = 'tm_healthcare';
protected $primaryKey = 'nID';
public function jadwalDokter()
{
return $this->hasMany(JadwalDokter::class, 'nIDHealthCare', 'nID');
}
} }

View File

@@ -19,4 +19,14 @@ class JadwalDokter extends Model
protected $table = 'tx_jadwal_dokter'; protected $table = 'tx_jadwal_dokter';
protected $primaryKey = 'nID'; protected $primaryKey = 'nID';
public function jadwalDokterDay()
{
return $this->hasMany(JadwalDokterDay::class, 'nIDJadwalDokter', 'nID');
}
public function healthcare()
{
return $this->belongsTo(Healthcare::class, 'nIDHealthCare', 'nID');
}
} }

View File

@@ -0,0 +1,22 @@
<?php
namespace App\Models\OLDLMS;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class JadwalDokterDay extends Model
{
use HasFactory, SoftDeletes;
const CREATED_AT = 'dCreateOn';
const UPDATED_AT = 'dUpdateOn';
const DELETED_AT = 'dDeleteOn';
protected $connection = 'oldlms';
protected $table = 'tx_jadwal_dokter_detail';
protected $primaryKey = 'nID';
}

View File

@@ -39,19 +39,36 @@ class LmsApi
$data['channel'] = 'Website'; $data['channel'] = 'Website';
} }
$res = self::http()->post( self::baseUrl() . '/jadwaldokter', $data)->json(); $res = self::http()->post(self::baseUrl() . '/jadwaldokter', $data)->json();
// Reformat Jam Data // Reformat Jam Data
$res['data'] = collect($res['data'])->map(function($day) { $res['data'] = collect($res['data'])->map(function ($day) {
$day['Jam'] = !empty($day['Jam']) ? explode(', ', $day['Jam']) : null; $day['Jam'] = !empty($day['Jam']) ? explode(', ', $day['Jam']) : null;
return $day; return $day;
})->toArray(); })->toArray();
return $res; return $res;
} }
/**
* dokter
*
*
*/
public static function dokter($kodeRs, $channel = 'hospitaloka', $timeout = 30)
{
$data = [
'rs' => $kodeRs,
'channel' => $channel,
];
$res = self::http()->timeout($timeout)->post('http://lmsapi.primaya.id/dokter', $data)->json();
return $res;
}
/** /**
* jadwalDokterTersedia * jadwalDokterTersedia
* *
@@ -72,16 +89,15 @@ class LmsApi
$data['channel'] = 'Website'; $data['channel'] = 'Website';
} }
$res = self::http()->post( self::baseUrl() . '/jadwaldoktertersedia', $data)->json(); $res = self::http()->post(self::baseUrl() . '/jadwaldoktertersedia', $data)->json();
// Reformat Jam Data // Reformat Jam Data
$res['data'] = collect($res['data'])->map(function($day) { $res['data'] = collect($res['data'])->map(function ($day) {
// Change jam to Jam to Standarize // Change jam to Jam to Standarize
$day['Jam'] = !empty($day['jam']) ? explode(', ', $day['jam']) : null; $day['Jam'] = !empty($day['jam']) ? explode(', ', $day['jam']) : null;
unset($day['jam']); unset($day['jam']);
return $day; return $day;
})->toArray(); })->toArray();
return $res; return $res;
@@ -113,7 +129,7 @@ class LmsApi
throw new Exception('name, birth_date, nik, phone are required in $patientData'); throw new Exception('name, birth_date, nik, phone are required in $patientData');
} }
$res = self::http()->post( self::baseUrl() . '/medrec_nama', $data)->json(); $res = self::http()->post(self::baseUrl() . '/medrec_nama', $data)->json();
return $res; return $res;
} }
@@ -141,7 +157,7 @@ class LmsApi
throw new Exception('name, birth_date are required in $patientData'); throw new Exception('name, birth_date are required in $patientData');
} }
$res = self::http()->post( self::baseUrl() . '/cek_gantung', $data)->json(); $res = self::http()->post(self::baseUrl() . '/cek_gantung', $data)->json();
return $res; return $res;
} }
@@ -156,7 +172,7 @@ class LmsApi
* @param string $type HIS Slot Type walkin, teleconsultation * @param string $type HIS Slot Type walkin, teleconsultation
* @return void * @return void
*/ */
public static function checkSlot( $HISKodeRS, $HISKodeDokter, $tanggalAppointment, $jamAppointment, $type ) public static function checkSlot($HISKodeRS, $HISKodeDokter, $tanggalAppointment, $jamAppointment, $type)
{ {
$data = [ $data = [
@@ -169,7 +185,7 @@ class LmsApi
$data['channel'] = 'Website'; $data['channel'] = 'Website';
} }
$res = self::http()->post( self::baseUrl() . '/cek_slot', $data)->json(); $res = self::http()->post(self::baseUrl() . '/cek_slot', $data)->json();
return $res; return $res;
} }
@@ -189,7 +205,8 @@ class LmsApi
* @param mixed $userId * @param mixed $userId
* @return void * @return void
*/ */
public static function appointmentBaru( $HISKodeRS, $HISKodeDep, $HISKodeDokter, $jenisTC, $tanggalAppointment, $jamAppointment, $jumlahBayar, $kodePembayaran, $patientData, $userId ) { public static function appointmentBaru($HISKodeRS, $HISKodeDep, $HISKodeDokter, $jenisTC, $tanggalAppointment, $jamAppointment, $jumlahBayar, $kodePembayaran, $patientData, $userId)
{
$data = [ $data = [
'rs' => $HISKodeRS, 'rs' => $HISKodeRS,
'dep' => $HISKodeDep, 'dep' => $HISKodeDep,
@@ -220,7 +237,7 @@ class LmsApi
'jam' => $jamAppointment, 'jam' => $jamAppointment,
]; ];
$res = self::http()->post( self::baseUrl() . '/appointment_baru', $data)->json(); $res = self::http()->post(self::baseUrl() . '/appointment_baru', $data)->json();
return $res; return $res;
} }
@@ -241,7 +258,8 @@ class LmsApi
* @param mixed $userId * @param mixed $userId
* @return void * @return void
*/ */
public static function appointment( $HISKodeRS, $HISKodeDep, $HISKodeDokter, $jenisTC, $tanggalAppointment, $jamAppointment, $jumlahBayar, $kodePembayaran, $HISMedrec, $patientData, $userId ) { public static function appointment($HISKodeRS, $HISKodeDep, $HISKodeDokter, $jenisTC, $tanggalAppointment, $jamAppointment, $jumlahBayar, $kodePembayaran, $HISMedrec, $patientData, $userId)
{
$data = [ $data = [
'rs' => $HISKodeRS, 'rs' => $HISKodeRS,
'dep' => $HISKodeDep, 'dep' => $HISKodeDep,
@@ -259,7 +277,7 @@ class LmsApi
'jam' => $jamAppointment, 'jam' => $jamAppointment,
]; ];
$res = self::http()->post( self::baseUrl() . '/appointment', $data)->json(); $res = self::http()->post(self::baseUrl() . '/appointment', $data)->json();
return $res; return $res;
} }
@@ -277,7 +295,7 @@ class LmsApi
* @param mixed $patientData * @param mixed $patientData
* @return void * @return void
*/ */
public static function appointmentEdit( $HISRegid, $HISKodeRS, $HISKodeDep, $HISKodeDokter, $tanggalAppointment, $jamAppointment, $HISMedrec, $patientData ) public static function appointmentEdit($HISRegid, $HISKodeRS, $HISKodeDep, $HISKodeDokter, $tanggalAppointment, $jamAppointment, $HISMedrec, $patientData)
{ {
$data = [ $data = [
'regid' => $HISRegid, 'regid' => $HISRegid,
@@ -293,7 +311,7 @@ class LmsApi
'jam' => $jamAppointment, 'jam' => $jamAppointment,
]; ];
$res = self::http()->post( self::baseUrl() . '/appointment_edit', $data)->json(); $res = self::http()->post(self::baseUrl() . '/appointment_edit', $data)->json();
return $res; return $res;
} }
@@ -314,7 +332,8 @@ class LmsApi
* @param mixed $nomorRujukanBPJS * @param mixed $nomorRujukanBPJS
* @return void * @return void
*/ */
public static function booking( $HISKodeRS, $HISKodeDep, $HISKodeDokter, $tanggalAppointment, $jamAppointment, $HISMedrec, $patientData, $jenisPenjamin = 0, $namaPenjamin = '', $nomorKartuBPJS = null, $nomorRujukanBPJS = null ) { public static function booking($HISKodeRS, $HISKodeDep, $HISKodeDokter, $tanggalAppointment, $jamAppointment, $HISMedrec, $patientData, $jenisPenjamin = 0, $namaPenjamin = '', $nomorKartuBPJS = null, $nomorRujukanBPJS = null)
{
$data = [ $data = [
'rs' => $HISKodeRS, 'rs' => $HISKodeRS,
'dep' => $HISKodeDep, 'dep' => $HISKodeDep,
@@ -334,7 +353,7 @@ class LmsApi
'norujukan' => $nomorRujukanBPJS 'norujukan' => $nomorRujukanBPJS
]; ];
$res = self::http()->post( self::baseUrl() . '/booking', $data)->json(); $res = self::http()->post(self::baseUrl() . '/booking', $data)->json();
return $res; return $res;
} }
@@ -354,7 +373,8 @@ class LmsApi
* @param mixed $nomorRujukanBPJS * @param mixed $nomorRujukanBPJS
* @return void * @return void
*/ */
public static function bookingBaru( $HISKodeRS, $HISKodeDep, $HISKodeDokter, $tanggalAppointment, $jamAppointment, $patientData, $jenisPenjamin = 0, $namaPenjamin = '', $nomorKartuBPJS = null, $nomorRujukanBPJS = null) { public static function bookingBaru($HISKodeRS, $HISKodeDep, $HISKodeDokter, $tanggalAppointment, $jamAppointment, $patientData, $jenisPenjamin = 0, $namaPenjamin = '', $nomorKartuBPJS = null, $nomorRujukanBPJS = null)
{
$data = [ $data = [
'rs' => $HISKodeRS, 'rs' => $HISKodeRS,
'dep' => $HISKodeDep, 'dep' => $HISKodeDep,
@@ -386,7 +406,7 @@ class LmsApi
'norujukan' => $nomorRujukanBPJS 'norujukan' => $nomorRujukanBPJS
]; ];
$res = self::http()->post( self::baseUrl() . '/booking_baru', $data)->json(); $res = self::http()->post(self::baseUrl() . '/booking_baru', $data)->json();
return $res; return $res;
} }
@@ -409,7 +429,8 @@ class LmsApi
* @param mixed $nomorRujukanBPJS * @param mixed $nomorRujukanBPJS
* @return void * @return void
*/ */
public static function bookingEdit( $kodeBooking, $HISKodeRS, $HISKodeDep, $HISKodeDokter, $tanggalAppointment, $jamAppointment, $tanggalAppointmentBaru, $jamAppointmentBaru, $jenisPenjamin = 0, $namaPenjamin = '', $nomorKartuBPJS = null, $nomorRujukanBPJS = null ) { public static function bookingEdit($kodeBooking, $HISKodeRS, $HISKodeDep, $HISKodeDokter, $tanggalAppointment, $jamAppointment, $tanggalAppointmentBaru, $jamAppointmentBaru, $jenisPenjamin = 0, $namaPenjamin = '', $nomorKartuBPJS = null, $nomorRujukanBPJS = null)
{
$data = [ $data = [
'kodebooking' => $kodeBooking, 'kodebooking' => $kodeBooking,
'rs' => $HISKodeRS, 'rs' => $HISKodeRS,
@@ -425,7 +446,7 @@ class LmsApi
'jambaru' => $jamAppointmentBaru, 'jambaru' => $jamAppointmentBaru,
]; ];
$res = self::http()->post( self::baseUrl() . '/booking_edit', $data)->json(); $res = self::http()->post(self::baseUrl() . '/booking_edit', $data)->json();
return $res; return $res;
} }
@@ -558,7 +579,7 @@ class LmsApi
return $url; return $url;
} }
public static function bookingBayar( $kodeBooking, $HISKodeRS, $tanggalBooking, $jumlahBayar, $merchantCode, $merchantOrderId, $reference) public static function bookingBayar($kodeBooking, $HISKodeRS, $tanggalBooking, $jumlahBayar, $merchantCode, $merchantOrderId, $reference)
{ {
$data = [ $data = [
"rs" => $HISKodeRS, "rs" => $HISKodeRS,
@@ -571,7 +592,7 @@ class LmsApi
'reference' => $reference, 'reference' => $reference,
]; ];
$res = self::http()->post( self::baseUrl() . '/booking_bayar', $data)->json(); $res = self::http()->post(self::baseUrl() . '/booking_bayar', $data)->json();
return $res; return $res;
} }

View File

@@ -0,0 +1,143 @@
<?php
namespace Database\Seeders;
use App\Models\OLDLMS\Healthcare;
use App\Models\OLDLMS\JadwalDokter;
use App\Models\OLDLMS\JadwalDokterDay;
use App\Services\LmsApi;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class JadwalDokterSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$mapHealthcare = [
'Q',
'C',
'D',
'E',
'F',
'M',
'O',
'P',
'Q',
'N',
'SG',
'BW',
'SK',
'PK',
'CK',
'DE'
];
$healthcares = Healthcare::whereIn('sKodeRS', $mapHealthcare)->get();
foreach ($healthcares as $healthcare) {
$jadwalDokterDay = LmsApi::dokter($healthcare->sKodeRS, 'hospitaloka', 300);
if (empty($jadwalDokterDay['data'])) {
continue;
}
$listDokter = $jadwalDokterDay['data'];
foreach ($listDokter as $dokter) {
$jadwalDokter = JadwalDokter::where('sIDDokter', $dokter['id'])->where('sDepartmenID', $dokter['DepartemenID'])->first() ?? null;
if ($jadwalDokter == null) {
continue;
}
// if ($jadwalDokter->nID != 1901) {
// continue;
// }
$jadwalDokterDay = $jadwalDokter->jadwalDokterDay()->get() ?? null;
// JadwalDokterDay::where('nIDJadwalDokter', $jadwalDokter->nID)->get() ?? null;
if ($jadwalDokterDay == null) {
continue;
}
// dd($dokter);
$listShcedule = $dokter['JadwalDokter'];
foreach ($jadwalDokterDay as $day) {
$NewJam = "";
foreach ($listShcedule as $key => $schedule) {
$jam = $schedule['Jam'];
$cek = $schedule['Jam'];
//jika jam memiliki hurug A-Z
if (preg_match('/[A-Z]/', $jam)) {
$jam = $jam;
} else {
//jika terdapat titik
if (strpos($jam, ".") !== false) {
//ganti titik dengan : dan tambahkan 00
$jam = str_replace(".", ":", $jam);
//jika jam nya terdapat strip
if (strpos($jam, "-") !== false) {
//jika didepan strip dan belakang strip ada spasi
if (strpos($jam, " ") !== false) {
//hapus spasi
$jam = str_replace(" ", "", $jam);
}
// try{
$jam = explode("-", $jam);
$jam = $jam[0] . " - " . $jam[1];
// } catch (\Exception $e) {
// $this->command->error($cek . "Id dokter : " . $jadwalDokter->nID);
// }
} else {
$jam = $jam;
}
} else {
//jika terdapat strip
if (strpos($jam, "-") !== false) {
//jika hanya ada strip tidak ada yang lain
if (strlen($jam) > 1) {
//jika sudah ada : maka diabaikan
if (strpos($jam, ":") !== false) {
$jam = explode("-", $jam);
$jam = $jam[0] . " - " . $jam[1];
} else {
//jika didepan strip ada spasi
if (strpos($jam, " ") !== false) {
//hapus spasi
$jam = str_replace(" ", "", $jam);
}
$jam = explode("-", $jam);
$jam = $jam[0] . ":00 - " . $jam[1] . ":00";
}
}
} else if (strpos($jam, ":") !== false) {
$jam = $jam;
} else {
$jam = $jam . ":00";
}
}
}
if ($day->sHari == $schedule['Hari']) {
if ($schedule['Jam'] == null) {
$NewJam = "";
} else {
$NewJam = $jam;
}
} else {
continue;
}
}
$day->sJam = $NewJam;
$day->save();
}
}
}
}
}