diff --git a/Modules/Linksehat/Http/Controllers/Api/DoctorController.php b/Modules/Linksehat/Http/Controllers/Api/DoctorController.php index 10379fa0..bf7ec224 100644 --- a/Modules/Linksehat/Http/Controllers/Api/DoctorController.php +++ b/Modules/Linksehat/Http/Controllers/Api/DoctorController.php @@ -149,4 +149,92 @@ class DoctorController extends Controller { // } + + public function schedule(Request $request, $id) + { + $request->validate([ + 'speciality_id' => 'required', + 'type' => 'required', + 'hospital_id' => 'required_if:type,walkin', + 'start_date' => ['required', 'date'] + ]); + + if ($request->type == 'walkin') { + + $practitionerRole = PractitionerRole::query() + ->where('practitioner_id', $id) + ->where('organization_id', $request->hospital_id) + ->where('speciality_id', $request->speciality_id) + ->with(['availabilities', 'availabilities.days']) + ->first(); + + if ($practitionerRole) { + + $schedules = [ + 'Senin' => [], + 'Selasa' => [], + 'Rabu' => [], + 'Kamis' => [], + 'Jumat' => [], + 'Sabtu' => [], + 'Minggu' => [] + ]; + + foreach ($practitionerRole->daily_availabilities as $day => $times) { + $schedules[$day] = array_unique( array_merge($schedules[$day], $times) ); + } + + } + + } else if ($request->type == 'teleconsultation') { + + $practitioner = Practitioner::query() + ->with([ + 'practitionerRoles' => function($practitionerRole) use ($request) { + if (!empty($request->hospital_id)) { + $practitionerRole->where('organization_id', $request->hospital_id); + } + }, + 'practitionerRoles.availabilities', + 'practitionerRoles.availabilities.days' + ]) + ->where('id', $id) + ->first(); + + $schedules = [ + 'Senin' => [], + 'Selasa' => [], + 'Rabu' => [], + 'Kamis' => [], + 'Jumat' => [], + 'Sabtu' => [], + 'Minggu' => [] + ]; + + foreach ($practitioner->practitionerRoles as $role) { + + foreach ($role->daily_availabilities as $day => $times) { + + // Merge All Role Availabilities + $schedules[$day] = array_unique( array_merge($schedules[$day], $times) ); + // $schedules[] = [ + // 'day' => $day, + // 'times' => array_unique( array_merge($schedules[$day], $times) ) + // ]; + + } + + } + + } + + + $datesAvailabilities = Helper::dailyAvailabilitiesToDate( $schedules, $request->start_date, $request->end_date ?? null); + + return response()->json($datesAvailabilities); + + return response()->json([ + 'message' => 'Jadwal praktek dokter tidak ditemukan' + ], 404); + } } diff --git a/Modules/Linksehat/Routes/api.php b/Modules/Linksehat/Routes/api.php index a3031daa..39487993 100644 --- a/Modules/Linksehat/Routes/api.php +++ b/Modules/Linksehat/Routes/api.php @@ -32,7 +32,7 @@ Route::prefix('linksehat')->group(function () { Route::get('doctors/online', [DoctorController::class, 'index'])->name('doctors.online'); Route::get('doctors', [DoctorController::class, 'index'])->name('doctors.index'); Route::get('doctors/{id}', [DoctorController::class, 'show'])->name('doctors.show'); - Route::get('doctors/{id}/schedule', [DoctorController::class, 'schedule'])->name('doctors.schedule'); + Route::post('doctors/{id}/schedule', [DoctorController::class, 'schedule'])->name('doctors.schedule'); // Route::middleware('auth:api')->get('/linksehat', function (Request $request) { // return $request->user(); diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.php index d3cf0576..2caf886e 100644 --- a/app/Helpers/Helper.php +++ b/app/Helpers/Helper.php @@ -2,6 +2,8 @@ namespace App\Helpers; +use Carbon\Carbon; +use Carbon\CarbonPeriod; use Illuminate\Support\Collection; class Helper{ @@ -33,4 +35,32 @@ class Helper{ 'next_page_url' => $resource->nextPageUrl(), ]; } + + public static function dailyAvailabilitiesToDate($dailyAvailabilities, $startDate, $endDate = null) { + + Carbon::setLocale('id'); + + $startDate = Carbon::parse($startDate); + if ( empty($endDate) ) { + $endDate = $startDate; + } else { + $endDate = Carbon::parse($endDate); + } + $ranges = CarbonPeriod::create($startDate, $endDate); + + $datesAvailabilities = []; + foreach ( $ranges as $date ) { + + $datesAvailabilities[] = [ + 'date' => $date->format('Y-m-d'), + 'day' => $date->dayName, + 'slot' => $dailyAvailabilities[$date->dayName], + 'timezone' => 'WIB' + ]; + + } + + return $datesAvailabilities; + + } } diff --git a/app/Models/Person.php b/app/Models/Person.php index ba495ab2..c1896c92 100644 --- a/app/Models/Person.php +++ b/app/Models/Person.php @@ -22,6 +22,8 @@ class Person extends Model 'is_deceased', 'deceased_at', 'marital_status', + 'main_address_id', + 'domicile_address_id', ]; public function getFullNameAttribute() @@ -43,6 +45,16 @@ class Person extends Model return $this->morphMany(Address::class, 'addressable'); } + public function currentAddress() + { + return $this->belongsTo(Address::class, 'main_address_id'); + } + + public function domicileAddress() + { + return $this->belongsTo(Address::class, 'main_address_id'); + } + public function metas() { return $this->morphMany(Meta::class, 'metaable'); @@ -52,4 +64,27 @@ class Person extends Model { return $this->belongsTo(User::class, 'owner_user_id'); } + + public function makeLmsApiData() + { + return [ + 'name' => $this->name, + 'birth_date' => $this->birth_date, + 'birth_place' => $this->birth_place, + 'gender' => $this->gender, + 'blood_type' => $this->blood_type, + 'religion' => $this->religion, + 'last_education' => $this->last_education, + 'current_employment' => $this->current_employment, + 'marital_status' => $this->marital_status, + 'nik' => $this->nik, + 'citizenship' => $this->citizenship, + 'address' => $this->currentAddress->text ?? null, + 'city_name' => $this->currentAddress->city->name ?? null, + 'domicile_address' => $this->domicileAddress->text ?? null, + 'domicile_city_name' => $this->domicileAddress->city->name ?? null, + 'email' => $this->email, + 'phone' => $this->phone, + ]; + } } diff --git a/app/Models/PractitionerRole.php b/app/Models/PractitionerRole.php index 8729d2cb..ae2363ec 100644 --- a/app/Models/PractitionerRole.php +++ b/app/Models/PractitionerRole.php @@ -38,6 +38,39 @@ class PractitionerRole extends Model { return $this->practices->where('service_code', 'instant-chat')->where('active', 1)->count() >= 1; } + + public function getDailyAvailabilitiesAttribute() + { + $schedules = [ + 'Senin' => [], + 'Selasa' => [], + 'Rabu' => [], + 'Kamis' => [], + 'Jumat' => [], + 'Sabtu' => [], + 'Minggu' => [] + ]; + + foreach ($this->availabilities as $availability) { + + if (count($availability->days)) { + + foreach ($availability->days as $day) { + $schedules[$day][] = $availability->start_time; + } + + } else { + + foreach ($schedules as $day => $times) { + $schedules[$day][] = $availability->start_time; + } + + } + + } + + return $schedules; + } public function metas() { diff --git a/app/Models/PractitionerRoleAvailability.php b/app/Models/PractitionerRoleAvailability.php index 8df3c54c..67387d94 100644 --- a/app/Models/PractitionerRoleAvailability.php +++ b/app/Models/PractitionerRoleAvailability.php @@ -18,7 +18,7 @@ class PractitionerRoleAvailability extends Model public function days() { - return $this->hasMany('days'); + return $this->hasMany(PractitionerRoleAvailabilityDay::class, 'availability_id'); } public function practitionerRole() diff --git a/app/Services/LmsApi.php b/app/Services/LmsApi.php new file mode 100644 index 00000000..a349eac1 --- /dev/null +++ b/app/Services/LmsApi.php @@ -0,0 +1,606 @@ + self::$headerKey + ]); + } + + public static function baseUrl() + { + return env('LMS_API_URL', 'http://lmsapidev.primaya.id'); + } + + /** + * jadwalDokter + * + * @param string $HISKodeRS HIS RS Code example: C for Primaya Tangerang + * @param string $HISKodeDokter HIS Doctor Code example: SPKG_01 + * @param string $type HIS Slot Type walkin, teleconsultation + * @return void + */ + public static function jadwalDokter($HISKodeRS, $HISKodeDokter, $type) + { + $data = [ + 'rs' => $HISKodeRS, + 'dr' => $HISKodeDokter, + ]; + if (!empty($type) && $type == 'walkin') { + $data['channel'] = 'Website'; + } + + $res = self::http()->post( self::baseUrl() . '/jadwaldokter', $data)->json(); + + // Reformat Jam Data + $res['data'] = collect($res['data'])->map(function($day) { + + $day['Jam'] = !empty($day['Jam']) ? explode(', ', $day['Jam']) : null; + return $day; + + })->toArray(); + + return $res; + } + + /** + * jadwalDokterTersedia + * + * @param string $HISKodeRS HIS RS Code example: C for Primaya Tangerang + * @param string $HISKodeDokter HIS Doctor Code example: SPKG_01 + * @param string $tanggalBooking + * @param string $type HIS Slot Type walkin, teleconsultation + * @return void + */ + public static function jadwalDokterTersedia($HISKodeRS, $HISKodeDokter, $tanggalBooking, $type) + { + $data = [ + 'rs' => $HISKodeRS, + 'dr' => $HISKodeDokter, + 'tanggalbooking' => $tanggalBooking + ]; + if (!empty($type) && $type == 'walkin') { + $data['channel'] = 'Website'; + } + + $res = self::http()->post( self::baseUrl() . '/jadwaldoktertersedia', $data)->json(); + + // Reformat Jam Data + $res['data'] = collect($res['data'])->map(function($day) { + + // Change jam to Jam to Standarize + $day['Jam'] = !empty($day['jam']) ? explode(', ', $day['jam']) : null; + unset($day['jam']); + return $day; + + })->toArray(); + + return $res; + } + + /** + * checkMedrec + * + * @param string $HISKodeRS + * @param array $patientData + * @return void + */ + public static function checkMedrec($HISKodeRS, $patientData) + { + $data = [ + 'rs' => $HISKodeRS, + 'nm' => $patientData['name'], + 'tgl' => $patientData['birth_date'], + 'ktp' => $patientData['nik'], + 'telp' => $patientData['phone'], + ]; + + if ( + empty($patientData['name']) || + empty($patientData['birth_date']) || + empty($patientData['nik']) || + empty($patientData['phone']) + ) { + throw new Exception('name, birth_date, nik, phone are required in $patientData'); + } + + $res = self::http()->post( self::baseUrl() . '/medrec_nama', $data)->json(); + + return $res; + } + + /** + * checkGantung + * + * @param string $HISKodeRS + * @param array $patientData + * @return void + */ + public static function checkGantung($HISKodeRS, $HISMedrec, $patientData) + { + $data = [ + 'rs' => $HISKodeRS, + 'rm' => $HISMedrec, + 'nm' => $patientData['name'], + 'tgllahir' => $patientData['birth_date'], + ]; + + if ( + empty($patientData['name']) || + empty($patientData['birth_date']) + ) { + throw new Exception('name, birth_date are required in $patientData'); + } + + $res = self::http()->post( self::baseUrl() . '/cek_gantung', $data)->json(); + + return $res; + } + + /** + * checkSlot + * + * @param string $HISKodeRS + * @param string $HISKodeDokter + * @param string $tanggalAppointment + * @param string $jamAppointment + * @param string $type HIS Slot Type walkin, teleconsultation + * @return void + */ + public static function checkSlot( $HISKodeRS, $HISKodeDokter, $tanggalAppointment, $jamAppointment, $type ) + { + + $data = [ + 'rs' => $HISKodeRS, + 'dr' => $HISKodeDokter, + 'tgl' => $tanggalAppointment, + 'jam' => $jamAppointment, + ]; + if (!empty($type) && $type == 'walkin') { + $data['channel'] = 'Website'; + } + + $res = self::http()->post( self::baseUrl() . '/cek_slot', $data)->json(); + + return $res; + } + + /** + * appointmentBaru + * + * @param string $HISKodeRS + * @param string $HISKodeDep + * @param string $HISKodeDokter + * @param string $jenisTC + * @param string $tanggalAppointment + * @param string $jamAppointment + * @param string $jumlahBayar + * @param string $kodePembayaran + * @param array $patientData + * @param mixed $userId + * @return void + */ + public static function appointmentBaru( $HISKodeRS, $HISKodeDep, $HISKodeDokter, $jenisTC, $tanggalAppointment, $jamAppointment, $jumlahBayar, $kodePembayaran, $patientData, $userId ) { + $data = [ + 'rs' => $HISKodeRS, + 'dep' => $HISKodeDep, + 'jenistc' => $jenisTC, + 'dr' => $HISKodeDokter, + 'uid' => $userId, + 'rm' => 'BARU', + 'nm' => $patientData['name'], + 'tgllahir' => $patientData['birth_date'], + 'tempatlahir' => $patientData['birth_place'], + 'jnskelamin' => $patientData['gender'], + 'goldar' => $patientData['blood_type'], + 'agama' => $patientData['religion'], + 'pendidikan' => $patientData['last_education'], + 'pekerjaan' => $patientData['current_employment'], + 'perkawinan' => $patientData['marital_status'], + 'nomorktp' => $patientData['nik'], + 'kewarganegaraan' => $patientData['citizenship'], + 'alamat' => $patientData['address'], + 'kota' => $patientData['city_name'], + 'alamatdomisili' => $patientData['domicile_address'], + 'kotadomisili' => $patientData['domicile_city_name'], + 'email' => $patientData['email'], + 'telepon' => $patientData['phone'], + 'byr' => $jumlahBayar, + 'id_bayar' => $kodePembayaran, + 'tgl' => $tanggalAppointment, + 'jam' => $jamAppointment, + ]; + + $res = self::http()->post( self::baseUrl() . '/appointment_baru', $data)->json(); + + return $res; + } + + /** + * appointment + * + * @param mixed $HISKodeRS + * @param mixed $HISKodeDep + * @param mixed $HISKodeDokter + * @param mixed $jenisTC + * @param mixed $tanggalAppointment + * @param mixed $jamAppointment + * @param mixed $jumlahBayar + * @param mixed $kodePembayaran + * @param mixed $HISMedrec + * @param mixed $patientData + * @param mixed $userId + * @return void + */ + public static function appointment( $HISKodeRS, $HISKodeDep, $HISKodeDokter, $jenisTC, $tanggalAppointment, $jamAppointment, $jumlahBayar, $kodePembayaran, $HISMedrec, $patientData, $userId ) { + $data = [ + 'rs' => $HISKodeRS, + 'dep' => $HISKodeDep, + 'dr' => $HISKodeDokter, + 'jenistc' => $jenisTC, + 'uid' => $userId, + 'rm' => $HISMedrec, + 'nm' => $patientData['name'], + 'tgllahir' => $patientData['birth_date'], + 'email' => $patientData['email'], + 'telepon' => $patientData['phone'], + 'byr' => $jumlahBayar, + 'id_bayar' => $kodePembayaran, + 'tgl' => $tanggalAppointment, + 'jam' => $jamAppointment, + ]; + + $res = self::http()->post( self::baseUrl() . '/appointment', $data)->json(); + + return $res; + } + + /** + * appointmentEdit + * + * @param mixed $HISRegid + * @param mixed $HISKodeRS + * @param mixed $HISKodeDep + * @param mixed $HISKodeDokter + * @param mixed $tanggalAppointment + * @param mixed $jamAppointment + * @param mixed $HISMedrec + * @param mixed $patientData + * @return void + */ + public static function appointmentEdit( $HISRegid, $HISKodeRS, $HISKodeDep, $HISKodeDokter, $tanggalAppointment, $jamAppointment, $HISMedrec, $patientData ) + { + $data = [ + 'regid' => $HISRegid, + 'rs' => $HISKodeRS, + 'dep' => $HISKodeDep, + 'dr' => $HISKodeDokter, + 'rm' => $HISMedrec, + 'nm' => $patientData['name'], + 'tgllahir' => $patientData['birth_date'], + 'email' => $patientData['email'], + 'telepon' => $patientData['phone'], + 'tgl' => $tanggalAppointment, + 'jam' => $jamAppointment, + ]; + + $res = self::http()->post( self::baseUrl() . '/appointment_edit', $data)->json(); + + return $res; + } + + /** + * booking + * + * @param mixed $HISKodeRS + * @param mixed $HISKodeDep + * @param mixed $HISKodeDokter + * @param mixed $tanggalAppointment + * @param mixed $jamAppointment + * @param mixed $HISMedrec + * @param mixed $patientData + * @param mixed $jenisPenjamin 0: Umum, 1: Perusahaan, 2: Asuransi, 3: BPJS + * @param mixed $namaPenjamin + * @param mixed $nomorKartuBPJS + * @param mixed $nomorRujukanBPJS + * @return void + */ + public static function booking( $HISKodeRS, $HISKodeDep, $HISKodeDokter, $tanggalAppointment, $jamAppointment, $HISMedrec, $patientData, $jenisPenjamin = 0, $namaPenjamin = '', $nomorKartuBPJS = null, $nomorRujukanBPJS = null ) { + $data = [ + 'rs' => $HISKodeRS, + 'dep' => $HISKodeDep, + 'dr' => $HISKodeDokter, + 'uid' => 'Website', + 'rm' => $HISMedrec, + 'nm' => $patientData['name'], + 'tgllahir' => $patientData['birth_date'], + 'email' => $patientData['email'], + 'telepon' => $patientData['phone'], + 'tgl' => $tanggalAppointment, + 'jam' => $jamAppointment, + 'jenispenjamin' => $jenisPenjamin, + 'penjamin' => $namaPenjamin, + 'ktp' => $patientData['nik'], + 'nokartu' => $nomorKartuBPJS, + 'norujukan' => $nomorRujukanBPJS + ]; + + $res = self::http()->post( self::baseUrl() . '/booking', $data)->json(); + + return $res; + } + + /** + * bookingBaru + * + * @param mixed $HISKodeRS + * @param mixed $HISKodeDep + * @param mixed $HISKodeDokter + * @param mixed $tanggalAppointment + * @param mixed $jamAppointment + * @param mixed $patientData + * @param mixed $jenisPenjamin + * @param mixed $namaPenjamin + * @param mixed $nomorKartuBPJS + * @param mixed $nomorRujukanBPJS + * @return void + */ + public static function bookingBaru( $HISKodeRS, $HISKodeDep, $HISKodeDokter, $tanggalAppointment, $jamAppointment, $patientData, $jenisPenjamin = 0, $namaPenjamin = '', $nomorKartuBPJS = null, $nomorRujukanBPJS = null) { + $data = [ + 'rs' => $HISKodeRS, + 'dep' => $HISKodeDep, + 'dr' => $HISKodeDokter, + 'uid' => 'Website', + 'nm' => $patientData['name'], + 'tgllahir' => $patientData['birth_date'], + 'tmptlahir' => $patientData['birth_place'], + 'jk' => $patientData['gender'], + 'goldar' => $patientData['blood_type'], + 'agama' => $patientData['religion'], + 'pendidikan' => $patientData['last_education'], + 'pekerjaan' => $patientData['current_employment'], + 'perkawinan' => $patientData['marital_status'], + 'nomorktp' => $patientData['nik'], + 'kewarganegaraan' => $patientData['citizenship'], + 'propinsi' => null, + 'kabupaten' => null, + 'kecamatan' => null, + 'kelurahan' => null, + 'alamat' => $patientData['address'], + 'email' => $patientData['email'], + 'telepon' => $patientData['phone'], + 'tgl' => $tanggalAppointment, + 'jam' => $jamAppointment, + 'jenispenjamin' => $jenisPenjamin, + 'penjamin' => $namaPenjamin, + 'nokartu' => $nomorKartuBPJS, + 'norujukan' => $nomorRujukanBPJS + ]; + + $res = self::http()->post( self::baseUrl() . '/booking_baru', $data)->json(); + + return $res; + } + + /** + * bookingEdit + * Used for Rescheduling appointment + * + * @param mixed $kodeBooking + * @param mixed $HISKodeRS + * @param mixed $HISKodeDep + * @param mixed $HISKodeDokter + * @param mixed $tanggalAppointment + * @param mixed $jamAppointment + * @param mixed $tanggalAppointmentBaru + * @param mixed $jamAppointmentBaru + * @param mixed $jenisPenjamin + * @param mixed $namaPenjamin + * @param mixed $nomorKartuBPJS + * @param mixed $nomorRujukanBPJS + * @return void + */ + public static function bookingEdit( $kodeBooking, $HISKodeRS, $HISKodeDep, $HISKodeDokter, $tanggalAppointment, $jamAppointment, $tanggalAppointmentBaru, $jamAppointmentBaru, $jenisPenjamin = 0, $namaPenjamin = '', $nomorKartuBPJS = null, $nomorRujukanBPJS = null ) { + $data = [ + 'kodebooking' => $kodeBooking, + 'rs' => $HISKodeRS, + 'dep' => $HISKodeDep, + 'dr' => $HISKodeDokter, + + 'jenispenjamin' => $jenisPenjamin, + 'penjamin' => $namaPenjamin, + 'uid' => 'Website', + 'tgllama' => $tanggalAppointment, + 'jamlama' => $jamAppointment, + 'tglbaru' => $tanggalAppointmentBaru, + 'jambaru' => $jamAppointmentBaru, + ]; + + $res = self::http()->post( self::baseUrl() . '/booking_edit', $data)->json(); + + return $res; + } + + public static function bookingPaket($kodeRs, $kodeDep, $rm, $ktp, $nama_pasien, $tgl_lahir, $email, $telp, $tgl, $jam, $jenis_penjamin, $penjamin, $paket, $jenis_paket) + { + throw new Exception("Not Implemented", 1); + + $url = Http::withHeaders([ + 'id' => 'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjE3NWZiNDI0LTA4MzMtNGZiMS1iOWNhLWQwMzQ5Nzc' + ])->post('http://lmsapidev.primaya.id/booking_paket', [ + 'rs' => $kodeRs, + 'dep' => $kodeDep, + 'uid' => 'Website', + 'rm' => $rm, + 'ktp' => $ktp, + 'nm' => $nama_pasien, + 'tgllahir' => $tgl_lahir, + 'email' => $email, + 'telepon' => $telp, + 'tgl' => $tgl, + 'jam' => $jam, + 'jenispenjamin' => $jenis_penjamin, + 'penjamin' => $penjamin, + 'paket' => $paket, + 'jenispaket' => $jenis_paket, + ])->json(); + + return $url; + } + public static function bookingBaruPaket( + $kodeRs, + $kodeDep, + $nm, + $tgl_lahir, + $tempat_lahir, + $jenis_kelamin, + $goldar, + $agama, + $pendidikan, + $pekerjaan, + $perkawinan, + $nomorktp, + $kewarganegaraan, + $propinsi, + $kabupaten, + $kecamatan, + $kelurahan, + $alamat, + $email, + $telepon, + $tgl, + $jam, + $jenis_penjamin, + $penjamin, + $paket, + $jenis_paket + ) { + throw new Exception("Not Implemented", 1); + + $url = Http::withHeaders([ + 'id' => 'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjE3NWZiNDI0LTA4MzMtNGZiMS1iOWNhLWQwMzQ5Nzc' + ])->post('http://lmsapidev.primaya.id/booking_baru_paket', [ + 'rs' => $kodeRs, + 'dep' => $kodeDep, + 'uid' => 'Website', + 'rm' => 'BARU', + 'nm' => $nm, + 'tgllahir' => $tgl_lahir, + 'tmptlahir' => $tempat_lahir, + 'jk' => $jenis_kelamin, + 'goldar' => $goldar, + 'agama' => $agama, + 'pendidikan' => $pendidikan, + 'pekerjaan' => $pekerjaan, + 'perkawinan' => $perkawinan, + 'nomorktp' => $nomorktp, + 'kewarganegaraan' => $kewarganegaraan, + 'propinsi' => $propinsi, + 'kabupaten' => $kabupaten, + 'kecamatan' => $kecamatan, + 'kelurahan' => $kelurahan, + 'alamat' => $alamat, + 'email' => $email, + 'telepon' => $telepon, + 'tgl' => $tgl, + 'jam' => $jam, + 'jenispenjamin' => $jenis_penjamin, + 'penjamin' => $penjamin, + 'paket' => $paket, + 'jenispaket' => $jenis_paket, + ])->json(); + + return $url; + } + + public static function bookingEditPaket( + $kodeRs, + $kodeDep, + + $kodeBooking, + $tgllama, + $jamlama, + $tglbaru, + $jambaru, + $jenis_penjamin, + $penjamin, + $paket, + $jenis_paket + ) { + throw new Exception("Not Implemented", 1); + + $url = Http::withHeaders([ + 'id' => 'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjE3NWZiNDI0LTA4MzMtNGZiMS1iOWNhLWQwMzQ5Nzc' + ])->post('http://lmsapidev.primaya.id/booking_edit_paket', [ + 'rs' => $kodeRs, + 'dep' => $kodeDep, + 'uid' => 'Website', + 'kodebooking' => $kodeBooking, + 'tgllama' => $tgllama, + 'jamlama' => $jamlama, + 'tglbaru' => $tglbaru, + 'jambaru' => $jambaru, + 'jenispenjamin' => $jenis_penjamin, + 'penjamin' => $penjamin, + 'paket' => $paket, + 'jenispaket' => $jenis_paket, + ])->json(); + + return $url; + } + + public static function bookingBayar( $kodeBooking, $HISKodeRS, $tanggalBooking, $jumlahBayar, $merchantCode, $merchantOrderId, $reference) + { + $data = [ + "rs" => $HISKodeRS, + "uid" => "Website", + "tglbooking" => $tanggalBooking, + "kodebooking" => $kodeBooking, + "amount" => $jumlahBayar, + "merchantCode" => $merchantCode, + 'merchantorderid' => $merchantOrderId, + 'reference' => $reference, + ]; + + $res = self::http()->post( self::baseUrl() . '/booking_bayar', $data)->json(); + + return $res; + } + + public static function bookingBatal($kodeRs, $kodeBooking, $tglBooking) + { + $url = Http::withHeaders([ + 'id' => 'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjE3NWZiNDI0LTA4MzMtNGZiMS1iOWNhLWQwMzQ5Nzc' + ])->post('http://lmsapidev.primaya.id/booking_batal', [ + "rs" => $kodeRs, + "channel" => "Website", + "kodebooking" => $kodeBooking, + "tgl" => $tglBooking, + ])->json(); + + return $url; + } + + public static function cekRujukan($kodeRs, $noKartu, $noRujukan) + { + $url = Http::withHeaders([ + 'id' => 'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjE3NWZiNDI0LTA4MzMtNGZiMS1iOWNhLWQwMzQ5Nzc' + ])->post('http://lmsapidev.primaya.id/cek_rujukan', [ + "rs" => $kodeRs, + "uid" => "Website", + "nokartu" => $noKartu, + "norujukan" => $noRujukan, + ])->json(); + + return $url; + } +} \ No newline at end of file diff --git a/config/app.php b/config/app.php index 73972155..d9b54f83 100644 --- a/config/app.php +++ b/config/app.php @@ -213,6 +213,7 @@ return [ 'aliases' => Facade::defaultAliases()->merge([ // 'ExampleClass' => App\Example\ExampleClass::class, 'Excel' => Maatwebsite\Excel\Facades\Excel::class, + 'LmsApi' => App\Services\LmsApi::class, ])->toArray(), ]; diff --git a/database/migrations/2022_09_26_083719_add_person_details_for_lms_api.php b/database/migrations/2022_09_26_083719_add_person_details_for_lms_api.php new file mode 100644 index 00000000..eeea1772 --- /dev/null +++ b/database/migrations/2022_09_26_083719_add_person_details_for_lms_api.php @@ -0,0 +1,48 @@ +foreignId('domicile_address_id')->nullable()->after('main_address_id'); + $table->string('blood_type', 2)->nullable()->after('birth_date'); + $table->string('religion')->nullable()->after('birth_date'); + $table->string('last_education')->nullable()->after('birth_date'); + $table->string('current_employment')->nullable()->after('birth_date'); + $table->string('citizenship')->nullable()->after('birth_date'); + $table->text('birth_place')->nullable()->after('birth_date'); + $table->string('email')->nullable()->after('name_suffix'); + $table->string('phone')->nullable()->after('name_suffix'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('persons', function (Blueprint $table) { + $table->dropColumn('domicile_address_id'); + $table->dropColumn('blood_type'); + $table->dropColumn('religion'); + $table->dropColumn('last_education'); + $table->dropColumn('current_employment'); + $table->dropColumn('citizenship'); + $table->dropColumn('birth_place'); + $table->dropColumn('email'); + $table->dropColumn('phone'); + }); + } +};