list dan show appointment
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Http\Controllers\Api;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\OLDLMS\Appointment;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Modules\Internal\Transformers\AppointmentResource;
|
||||
|
||||
class AppointmentController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$appointments = Appointment::query()
|
||||
->with('doctor.user', 'doctor.speciality', 'appointmentDetail', 'healthCare')
|
||||
->paginate(15);
|
||||
return response()->json(Helper::paginateResources(AppointmentResource::collection($appointments)));
|
||||
}
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('internal::create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
* @param Request $request
|
||||
* @return Renderable
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$appointments = Appointment::query()
|
||||
->with('doctor.user', 'doctor.speciality', 'appointmentDetail', 'healthCare')
|
||||
->where('nID', $id)
|
||||
->first();
|
||||
return response()->json(new AppointmentResource($appointments));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return view('internal::edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
* @param Request $request
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
89
Modules/Internal/Http/Controllers/Api/LivechatController.php
Normal file
89
Modules/Internal/Http/Controllers/Api/LivechatController.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Http\Controllers\Api;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\OLDLMS\Livechat;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Modules\Internal\Transformers\LivechatResource;
|
||||
|
||||
class LivechatController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$livechat = Livechat::with('doctor.user', 'doctor.speciality', 'appointment.appointmentDetail', 'healthCare')
|
||||
->where('nIDAppointment', '!=', null)->where('nIDAppointment', '!=', '')
|
||||
->paginate(15);
|
||||
|
||||
return response()->json(Helper::paginateResources(LivechatResource::collection($livechat)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
* @return Renderable
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('internal::create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
* @param Request $request
|
||||
* @return Renderable
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the specified resource.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$livechat = Livechat::with('doctor.user', 'doctor.speciality', 'appointment.appointmentDetail', 'healthCare')
|
||||
->where('nIDAppointment', '!=', null)->where('nIDAppointment', '!=', '')
|
||||
->where('nID', $id)
|
||||
->first();
|
||||
return response()->json(new LivechatResource($livechat));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
return view('internal::edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
* @param Request $request
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
* @param int $id
|
||||
* @return Renderable
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
use App\Http\Controllers\Api\MemberController as ApiMemberController;
|
||||
use Modules\Internal\Http\Controllers\Api\AuthController;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Internal\Http\Controllers\Api\AppointmentController;
|
||||
use Modules\Internal\Http\Controllers\Api\BenefitController;
|
||||
use Modules\Internal\Http\Controllers\Api\ClaimController;
|
||||
use Modules\Internal\Http\Controllers\Api\CorporateBenefitController;
|
||||
@@ -17,6 +18,7 @@ use Modules\Internal\Http\Controllers\Api\DivisionController;
|
||||
use Modules\Internal\Http\Controllers\Api\DoctorController;
|
||||
use Modules\Internal\Http\Controllers\Api\DrugController;
|
||||
use Modules\Internal\Http\Controllers\Api\FormulariumController;
|
||||
use Modules\Internal\Http\Controllers\Api\LivechatController;
|
||||
use Modules\Internal\Http\Controllers\Api\MemberController;
|
||||
use Modules\Internal\Http\Controllers\Api\OrganizationController;
|
||||
use Modules\Internal\Http\Controllers\Api\PlanController;
|
||||
@@ -119,9 +121,12 @@ Route::prefix('internal')->group(function () {
|
||||
Route::get('search-organizations', [OrganizationController::class, 'searchOrganization']);
|
||||
Route::get('search-specialities', [SpecialityController::class, 'searchSpeciality']);
|
||||
Route::resource('organizations', OrganizationController::class);
|
||||
Route::resource('appointments', AppointmentController::class);
|
||||
Route::resource('live-chat', LivechatController::class);
|
||||
|
||||
Route::resource('doctors', DoctorController::class);
|
||||
|
||||
|
||||
|
||||
Route::get('generate-log/{member_id}', [CorporateMemberController::class, 'generateLog']);
|
||||
});
|
||||
|
||||
|
||||
45
Modules/Internal/Transformers/AppointmentResource.php
Normal file
45
Modules/Internal/Transformers/AppointmentResource.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Transformers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class AppointmentResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$appointment = [
|
||||
'id' => $this->nID,
|
||||
'doctor_name' => isset($this->doctor->user->sFirstName) ? $this->doctor->user->sFirstName . ' ' . $this->doctor->user->sLastName : null,
|
||||
'speciality' => $this->doctor->speciality->sKeterangan,
|
||||
'date_appointment' => Carbon::parse($this->appointmentDetail->dTanggalAppointment)->format('d-m-Y') . ' ' . $this->appointmentDetail->tTimeAppointment,
|
||||
'date_created' => Carbon::parse($this->dCreateOn)->format('d-m-Y H:i:s') ?? null,
|
||||
'appointment_media' => $this->sMedia,
|
||||
'status' => $this->status_name,
|
||||
'health_care' => $this->healthCare->sHealthCare ?? null,
|
||||
'payment_method' => $this->payment_method ?? null,
|
||||
];
|
||||
|
||||
$payment_detail = null;
|
||||
if ($this->appointmentDetail->sPaymentDetails != null) {
|
||||
$payment_detail = [
|
||||
'payment_type' => $this->appointmentDetail->sPaymentDetails['payment_type'],
|
||||
'transaction_time' => $this->appointmentDetail->sPaymentDetails['transaction_time'],
|
||||
'gross_amount' => $this->appointmentDetail->sPaymentDetails['gross_amount'],
|
||||
'currency' => $this->appointmentDetail->sPaymentDetails['currency'],
|
||||
'status_message' => $this->appointmentDetail->sPaymentDetails['status_message'],
|
||||
];
|
||||
}
|
||||
|
||||
$appointment['payment_detail'] = $payment_detail;
|
||||
|
||||
return $appointment;
|
||||
}
|
||||
}
|
||||
62
Modules/Internal/Transformers/LivechatResource.php
Normal file
62
Modules/Internal/Transformers/LivechatResource.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Transformers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class LivechatResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$livechat = [
|
||||
'id' => $this->nID,
|
||||
'doctor_name' => isset($this->doctor->user->sFirstName) ? $this->doctor->user->sFirstName . ' ' . $this->doctor->user->sLastName : null,
|
||||
'speciality' => $this->doctor->speciality->sKeterangan ?? null,
|
||||
'health_care' => $this->healthCare->sHealthCare ?? null,
|
||||
'date_appointment' => Carbon::parse($this->appointment->appointmentDetail->dTanggalAppointment)->format('d-m-Y')
|
||||
. ' ' . $this->appointment->appointmentDetail->tTimeAppointment ?? null,
|
||||
'status_appointment' => $this->appointment->status_name ?? null,
|
||||
'date_created' => Carbon::parse($this->appointment->dCreateOn)->format('d-m-Y H:i:s') ?? null,
|
||||
'patient_media' => $this->sMedia ?? null,
|
||||
'doctor_media' => $this->sMediaDokter ?? null,
|
||||
'appointment_media' => $this->appointment->sMedia ?? null,
|
||||
'status_chat' => $this->status_name ?? null,
|
||||
'payment_method' => $this->appointment->payment_method ?? null,
|
||||
];
|
||||
|
||||
$start_time = $this->dStartTime;
|
||||
$end_time = $this->dEndTime;
|
||||
$data_duration = 0 . ' jam ' . 0 . ' menit ' . 0 . ' detik';
|
||||
if ($start_time != null && $end_time != null) {
|
||||
$duration = Carbon::parse($start_time)->diffInMinutes(Carbon::parse($end_time));
|
||||
$hours = floor($duration / 60);
|
||||
$minutes = $duration % 60;
|
||||
$seconds = ($duration - ($hours * 60) - $minutes) * 60;
|
||||
|
||||
$data_duration = $hours . ' jam ' . $minutes . ' menit ' . $seconds . ' detik';
|
||||
}
|
||||
|
||||
$livechat['duration'] = $data_duration;
|
||||
|
||||
$payment_detail = null;
|
||||
if ($this->appointment->appointmentDetail->sPaymentDetails != null) {
|
||||
$payment_detail = [
|
||||
'payment_type' => $this->appointment->appointmentDetail->sPaymentDetails['payment_type'],
|
||||
'transaction_time' => $this->appointment->appointmentDetail->sPaymentDetails['transaction_time'],
|
||||
'gross_amount' => $this->appointment->appointmentDetail->sPaymentDetails['gross_amount'],
|
||||
'currency' => $this->appointment->appointmentDetail->sPaymentDetails['currency'],
|
||||
'status_message' => $this->appointment->appointmentDetail->sPaymentDetails['status_message'],
|
||||
];
|
||||
}
|
||||
|
||||
$livechat['payment_detail'] = $payment_detail;
|
||||
return $livechat;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user