api chat, send summary, health sertificate, callback duitku
This commit is contained in:
@@ -2,17 +2,22 @@
|
||||
|
||||
namespace Modules\Linksehat\Http\Controllers\Api;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\Channel;
|
||||
use App\Events\ChatMessageSent;
|
||||
use App\Models\UserChannel;
|
||||
use App\Models\Message;
|
||||
use App\Models\File;
|
||||
use App\Models\Livechat;
|
||||
use App\Models\Person;
|
||||
use App\Models\OLDLMS\User;
|
||||
use App\Models\OLDLMS\UserDetail;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Dompdf\Dompdf;
|
||||
use Dompdf\Options;
|
||||
use Pusher\Pusher;
|
||||
|
||||
class ChatController extends Controller
|
||||
@@ -36,7 +41,6 @@ class ChatController extends Controller
|
||||
'type' => $request->type,
|
||||
'member_id' => $request->member_id,
|
||||
'doctor_id' => $request->doctor_id,
|
||||
// Jika ada kolom tambahan, tambahkan di sini
|
||||
]);
|
||||
|
||||
// Menggunakan updateOrCreate untuk menambahkan data UserChannel untuk member_id
|
||||
@@ -166,34 +170,144 @@ class ChatController extends Controller
|
||||
public function getMessage(Request $request)
|
||||
{
|
||||
// Buat instance Pusher dengan konfigurasi yang sesuai
|
||||
$pusher = new Pusher(
|
||||
env('PUSHER_APP_KEY'),
|
||||
env('PUSHER_APP_SECRET'),
|
||||
env('PUSHER_APP_ID'),
|
||||
[
|
||||
'cluster' => env('PUSHER_APP_CLUSTER'),
|
||||
'useTLS' => true,
|
||||
]
|
||||
);
|
||||
$channel = Channel::where('id',$request->channel_id)->first();
|
||||
$livechat = Livechat::where([
|
||||
'doctor_id' => $channel->doctor_id,
|
||||
'patient_id' => $channel->member_id,
|
||||
])->latest('created_at')->first();
|
||||
|
||||
if($channel->member_id == $request->user_id){
|
||||
// Get nama dokter
|
||||
$person = Person::where('id', $channel->doctor_id)->first();
|
||||
$name = $person->name;
|
||||
$avatar = '';
|
||||
$age = '';
|
||||
$gender = '';
|
||||
$question = '';
|
||||
|
||||
$consultationStart = $livechat->start_date;
|
||||
$consultationEnd = $livechat->end_date;
|
||||
$work = '';
|
||||
$address = '';
|
||||
} else {
|
||||
// Get nama pasien
|
||||
$person = User::where('nID', $channel->member_id)->first();
|
||||
$name = $person->sFirstName . ' ' . $person->sLastName;
|
||||
$user = User::where('nID', $channel->member_id)->with('detail')->first();
|
||||
$name = $user->sFirstName . ' ' . $user->sLastName;
|
||||
$urlAvatarDefault = $user->detail->nIDJenisKelamin == 1 ? 'https://linksehat.dev/assets/img/users/male-avatar.png' : 'https://linksehat.dev/assets/img/users/female-avatar.png';
|
||||
$avatar = $user->detail->sImage ?? $urlAvatarDefault;
|
||||
$gender = DB::connection('oldlms')->table('tm_jenis_kelamin')->where('nID', $user->detail->nIDJenisKelamin)->first('sJenisKelamin');
|
||||
if ($gender){
|
||||
$gender = $gender->sJenisKelamin;
|
||||
}
|
||||
$age = Helper::calculateAge($user->detail->dTanggalLahir);
|
||||
$question = $livechat->descriptions;
|
||||
$consultationStart = $livechat->start_date;
|
||||
$consultationEnd = $livechat->end_date;
|
||||
$work = DB::connection('oldlms')->table('tm_pekerjaan')->where('nID', $user->detail->nIDPekerjaan)->first('sPekerjaan');
|
||||
|
||||
if($work){
|
||||
$work = $work->sPekerjaan;
|
||||
}
|
||||
$address = DB::connection('oldlms')->table('tm_users_address')->where('nIDUser', $user->nID)->first('sAlamat');
|
||||
if($address){
|
||||
$address = $address->sAlamat;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Ini Untul Chat
|
||||
$data = Message::where('channel_id', $request->channel_id)->get()->toArray();
|
||||
|
||||
// Data Consultation Summary
|
||||
$consultationSummary = [
|
||||
'subject' => $livechat->subject,
|
||||
'object' => $livechat->object,
|
||||
'assessment' => $livechat->assessment,
|
||||
'plan' => $livechat->plan,
|
||||
];
|
||||
|
||||
$healthSertificate = false;
|
||||
if ($livechat->health_certificate_start && $livechat->health_certificate_end){
|
||||
$healthSertificate = True;
|
||||
}
|
||||
|
||||
$data = Message::where('channel_id', $request->channel_id)->get()->toArray();
|
||||
// Berikan respons yang sesuai ke klien
|
||||
return response()->json([
|
||||
'message' => 'Message sent successfully',
|
||||
'data' => [
|
||||
'header' => $name,
|
||||
'chat' => $data
|
||||
'avatar' => $avatar,
|
||||
'gender' => $gender,
|
||||
'age' => $age,
|
||||
'question' => $question,
|
||||
'start' => $consultationStart,
|
||||
'end' => $consultationEnd,
|
||||
'work' => $work,
|
||||
'address' => $address,
|
||||
'chat' => $data,
|
||||
'summary' => $consultationSummary,
|
||||
'livechat_id' => $livechat->id,
|
||||
'health_sertificate' => $healthSertificate
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
public function downloadHealtcare($id){
|
||||
$pdf = new Dompdf();
|
||||
|
||||
$options = new Options();
|
||||
$options->set('isHtml5ParserEnabled', true);
|
||||
$options->set('isPhpEnabled', true);
|
||||
$options->set(['isRemoteEnabled' => true]);
|
||||
$pdf->setOptions($options);
|
||||
|
||||
$pdf->setPaper('A4', 'portrait');
|
||||
|
||||
$livechat = Livechat::where([
|
||||
'id' => $id
|
||||
])->latest('created_at')->first();
|
||||
|
||||
$user = User::where('nID', $livechat->patient_id)->with('detail')->first();
|
||||
$name = $user->sFirstName . ' ' . $user->sLastName;
|
||||
$age = Helper::calculateAge($user->detail->dTanggalLahir);
|
||||
|
||||
$person = Person::where('id', $livechat->doctor_id)->first();
|
||||
$doctorName = $person->name;
|
||||
|
||||
$work = DB::connection('oldlms')->table('tm_pekerjaan')->where('nID', $user->detail->nIDPekerjaan)->first('sPekerjaan');
|
||||
if($work){
|
||||
$work = $work->sPekerjaan;
|
||||
}
|
||||
$address = DB::connection('oldlms')->table('tm_users_address')->where('nIDUser', $user->nID)->first('sAlamat');
|
||||
if($address){
|
||||
$address = $address->sAlamat;
|
||||
}
|
||||
// Memuat view pdf_view.php ke dalam variabel
|
||||
$calculateDate = Helper::calculateDateDifference($livechat->health_certificate_start, $livechat->health_certificate_end);
|
||||
|
||||
$data = [
|
||||
'name' => $name,
|
||||
'age' => $age,
|
||||
'work' => $work,
|
||||
'address' => $address,
|
||||
'doctor_name' => $doctorName,
|
||||
'date' => $livechat->created_at,
|
||||
'start_date' => $livechat->health_certificate_start,
|
||||
'end_date' => $livechat->health_certificate_end,
|
||||
'calculate_date' => $calculateDate
|
||||
];
|
||||
// Halaman 1
|
||||
$html1 = view('pdf.health_sertificate', $data);
|
||||
$htmlCombined = $html1 ;
|
||||
|
||||
$pdf->loadHtml($htmlCombined);
|
||||
$pdf->render();
|
||||
|
||||
$headers = [
|
||||
'Content-Type' => 'application/pdf',
|
||||
'Content-Disposition' => 'inline; filename="file.pdf"',
|
||||
];
|
||||
|
||||
return response($pdf->output(), 200, $headers);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,12 @@ namespace Modules\Linksehat\Http\Controllers\Api\Doctor;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\User;
|
||||
use App\Models\OLDLMS\User as UserLMS;
|
||||
use App\Models\Livechat;
|
||||
use App\Models\Channel;
|
||||
use App\Models\Message;
|
||||
use App\Models\Prescription;
|
||||
use App\Models\PrescriptionItem;
|
||||
use Crypt;
|
||||
use Error;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -32,42 +37,165 @@ class ChatDoctorController extends Controller
|
||||
$chat = Livechat::where([
|
||||
'doctor_id'=> $user->person_id,
|
||||
'accept_date'=> null,
|
||||
])->get()->toArray();
|
||||
dd($chat);
|
||||
'status' => 1
|
||||
])->get();
|
||||
|
||||
return ApiResponse::apiResponse("Success", $res_data, trans('Message.success'), 200);
|
||||
$dataIncomingChat = [];
|
||||
if($chat) {
|
||||
foreach($chat as $c){
|
||||
$patient = UserLMS::where('nID',$c->patient_id)->with('detail')->first();
|
||||
$urlAvatarDefault = $patient->detail->nIDJenisKelamin == 1 ? 'https://linksehat.dev/assets/img/users/male-avatar.png' : 'https://linksehat.dev/assets/img/users/female-avatar.png';
|
||||
$avatarMember = $patient->detail->sImage ?? $urlAvatarDefault;
|
||||
$arr['id'] = $c->id;
|
||||
$arr['patient_id'] = $patient->nID;
|
||||
$arr['avatar'] = $avatarMember;
|
||||
$arr['name'] = $patient->sFirstName .' '.$patient->sLastName; ;
|
||||
array_push($dataIncomingChat, $arr);
|
||||
}
|
||||
}
|
||||
|
||||
$dataChannel = Channel::where('doctor_id',$user->person_id)->get()->toArray();
|
||||
$dataOnGoing = [];
|
||||
if ($dataChannel){
|
||||
foreach($dataChannel as $d){
|
||||
$user = UserLMS::with('detail')->where('nID', $d['member_id'])->first();
|
||||
$lastMessage = Message::where('channel_id', $d['id'])
|
||||
->latest('created_at')
|
||||
->first();
|
||||
$urlAvatarDefault = $user->detail->nIDJenisKelamin == 1 ? 'https://linksehat.dev/assets/img/users/male-avatar.png' : 'https://linksehat.dev/assets/img/users/female-avatar.png';
|
||||
$avatarMember = $user->detail->sImage ?? $urlAvatarDefault;
|
||||
|
||||
$arr['id'] = $d['id'];
|
||||
$arr['avatar'] = $avatarMember;
|
||||
$arr['name'] = $user->sFirstName .' '.$user->sLastName;
|
||||
$arr['last_message'] = $lastMessage;
|
||||
|
||||
array_push($dataOnGoing, $arr);
|
||||
}
|
||||
}
|
||||
$channel = $data;
|
||||
|
||||
$data = [
|
||||
'incoming_chat' => $dataIncomingChat,
|
||||
'ongoing_chat' => $dataOnGoing
|
||||
];
|
||||
|
||||
return ApiResponse::apiResponse("Success", $data, trans('Message.success'), 200);
|
||||
|
||||
}
|
||||
public function fWorkExperience($start, $end)
|
||||
|
||||
public function getChatDetail($id){
|
||||
$livechat = Livechat::find($id);
|
||||
$user = UserLMS::with('detail')->where('nID', $livechat->patient_id)->first();
|
||||
$urlAvatarDefault = $user->detail->nIDJenisKelamin == 1 ? 'https://linksehat.dev/assets/img/users/male-avatar.png' : 'https://linksehat.dev/assets/img/users/female-avatar.png';
|
||||
$avatarMember = $user->detail->sImage ?? $urlAvatarDefault;
|
||||
$gender = DB::connection('oldlms')->table('tm_jenis_kelamin')->where('nID', $user->detail->nIDJenisKelamin)->first('sJenisKelamin');
|
||||
$maritalStaus = DB::connection('oldlms')->table('tm_status_pernikahan')->where('nID', $user->detail->sMartialStatus)->first('sStatusPernikahan');
|
||||
$data = [];
|
||||
if ($livechat->status != 2){
|
||||
$data = [
|
||||
'id' => $user->nID,
|
||||
'name' => $user->sFirstName . ' ' . $user->sLastName,
|
||||
'avatar' => $avatarMember,
|
||||
'gender' => $gender->sJenisKelamin,
|
||||
'marital_status' => $maritalStaus->sStatusPernikahan,
|
||||
'age' => Helper::calculateAge($user->detail->dTanggalLahir),
|
||||
'weight' => $user->detail->sWeight,
|
||||
'height' => $user->detail->sHeight,
|
||||
'question' => $livechat->descriptions,
|
||||
'diseases' => [],
|
||||
'medications' => [],
|
||||
'allergy' => [],
|
||||
'family_history' => []
|
||||
];
|
||||
} else if ($livechat->status == 2){ // sudah accept, tinggal tunggu bayar pasient
|
||||
$data = [
|
||||
'message' => 'waiting payment'
|
||||
];
|
||||
}
|
||||
return ApiResponse::apiResponse("Success", $data, trans('Message.success'), 200);
|
||||
}
|
||||
|
||||
public function declineChat(Request $request)
|
||||
{
|
||||
$startDateString = $start; // Tanggal dan waktu awal
|
||||
$endDateString = $end ; // Tanggal dan waktu akhir
|
||||
|
||||
// Mengubah string tanggal ke timestamp UNIX
|
||||
$startTime = strtotime($startDateString);
|
||||
$endTime = strtotime($endDateString);
|
||||
|
||||
// Menghitung selisih waktu dalam detik
|
||||
$timeDifference = $endTime - $startTime;
|
||||
|
||||
// Menghitung jumlah tahun, bulan, dan hari dari selisih waktu
|
||||
$years = floor($timeDifference / (365 * 24 * 60 * 60));
|
||||
$months = floor(($timeDifference - ($years * 365 * 24 * 60 * 60)) / (30 * 24 * 60 * 60));
|
||||
$days = floor(($timeDifference - ($years * 365 * 24 * 60 * 60) - ($months * 30 * 24 * 60 * 60)) / (24 * 60 * 60));
|
||||
|
||||
// Formatkan hasilnya
|
||||
$experience = '';
|
||||
if ($years > 0) {
|
||||
$experience .= $years . ' years ';
|
||||
}
|
||||
if ($months > 0) {
|
||||
$experience .= $months . ' months ';
|
||||
}
|
||||
if ($days > 0) {
|
||||
$experience .= $days . ' days';
|
||||
$livechat = Livechat::find($request->id);
|
||||
if ($livechat) {
|
||||
// Memperbarui atribut model
|
||||
$livechat->status = 3; // Decline
|
||||
// Menyimpan perubahan ke database
|
||||
$livechat->save();
|
||||
return ApiResponse::apiResponse("Success",['message' => 'Livechat updated successfully'], trans('Message.success'), 200);
|
||||
} else {
|
||||
return response()->json(['message' => 'Livechat not found'], 404);
|
||||
}
|
||||
}
|
||||
|
||||
return $experience;
|
||||
public function approveChat(Request $request)
|
||||
{
|
||||
$livechat = Livechat::find($request->id);
|
||||
if ($livechat) {
|
||||
// Memperbarui atribut model
|
||||
$livechat->status = 2; // Accept
|
||||
$livechat->accept_date = date('Y-m-d H:i:s'); // Accept
|
||||
// Menyimpan perubahan ke database
|
||||
$livechat->save();
|
||||
return ApiResponse::apiResponse("Success",['message' => 'Livechat updated successfully'], trans('Message.success'), 200);
|
||||
} else {
|
||||
return response()->json(['message' => 'Livechat not found'], 404);
|
||||
}
|
||||
}
|
||||
|
||||
public function endChat(Request $request)
|
||||
{
|
||||
$livechat = Livechat::find($request->id);
|
||||
if ($livechat) {
|
||||
// Memperbarui atribut model
|
||||
$livechat->status = 6; // End Chat
|
||||
$livechat->end_date = date('Y-m-d H:i:s'); // Accept
|
||||
// Menyimpan perubahan ke database
|
||||
$livechat->save();
|
||||
return ApiResponse::apiResponse("Success",['message' => 'Livechat updated successfully'], trans('Message.success'), 200);
|
||||
} else {
|
||||
return response()->json(['message' => 'Livechat not found'], 404);
|
||||
}
|
||||
}
|
||||
|
||||
public function summaryChat(Request $request)
|
||||
{
|
||||
|
||||
$livechat = Livechat::find($request->id);
|
||||
if ($livechat) {
|
||||
// Memperbarui atribut model
|
||||
$livechat->subject = $request->subject; // Subject
|
||||
$livechat->object = $request->object; // Object
|
||||
$livechat->assessment = $request->assessment; // Assessment
|
||||
$livechat->plan = $request->plan; // Plan
|
||||
|
||||
$livechat->health_certificate_start = $request->health_certificate_start; // start
|
||||
$livechat->health_certificate_end = $request->health_certificate_end; // end
|
||||
// Menyimpan perubahan ke database
|
||||
$livechat->save();
|
||||
|
||||
$prescriptions = Prescription::create([
|
||||
'livechat_id' => $livechat->id,
|
||||
'organization_id' => $livechat->organization_id,
|
||||
]);
|
||||
|
||||
if ($request->prescriptions) {
|
||||
foreach ($request->prescriptions as $prescription) {
|
||||
$prescriptionItem = PrescriptionItem::create([
|
||||
'prescription_id' => $prescriptions->id,
|
||||
'drug_id' => $prescription['medicine'],
|
||||
'signa' => $prescription['dosis'],
|
||||
'direction' => $prescription['direction'],
|
||||
'note' => $prescription['note'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return ApiResponse::apiResponse("Success",['message' => 'Livechat updated successfully'], trans('Message.success'), 200);
|
||||
} else {
|
||||
return response()->json(['message' => 'Livechat not found'], 404);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,9 @@ namespace Modules\Linksehat\Http\Controllers\Api;
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\Organization;
|
||||
use App\Models\Speciality;
|
||||
use App\Models\Livechat;
|
||||
use App\Models\Channel;
|
||||
use App\Models\UserChannel;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -271,6 +274,8 @@ class DuitkuController extends Controller
|
||||
header('Content-Type: application/json');
|
||||
$notif = json_decode($callback);
|
||||
|
||||
// $notif = $request; ini untuk di local
|
||||
|
||||
DB::table('api_logs')
|
||||
->insert([
|
||||
'type' => 'in',
|
||||
@@ -280,12 +285,57 @@ class DuitkuController extends Controller
|
||||
'created_at' => date('Y-m-d H:i:s')
|
||||
]);
|
||||
|
||||
|
||||
if ($notif->resultCode == "00") {
|
||||
// Action Success
|
||||
return Redirect::to('https://linksehat.com/');
|
||||
$livechat = Livechat::where('uuid', $notif->merchantOrderId)->first();
|
||||
// Update status pembayaran
|
||||
$livechat->payment_method = $notif->paymentCode;
|
||||
$livechat->status = 5; // success payment
|
||||
$livechat->save();
|
||||
|
||||
// Update start chat
|
||||
$livechat->start_date = date('Y-m-d H:i:s');
|
||||
// Buat dan simpan data channel ke dalam tabel
|
||||
$channel = Channel::updateOrCreate([
|
||||
'name' => $livechat->patient_id .'_' . $request->doctor_id,
|
||||
],
|
||||
[
|
||||
'name' => $livechat->patient_id .'_' . $livechat->doctor_id,
|
||||
'type' => 'Private',
|
||||
'member_id' => $livechat->patient_id,
|
||||
'doctor_id' => $livechat->doctor_id,
|
||||
]);
|
||||
|
||||
// Menggunakan updateOrCreate untuk menambahkan data UserChannel untuk member_id
|
||||
$userChannelMember = UserChannel::updateOrCreate(
|
||||
[
|
||||
'user_id' => $livechat->patient_id,
|
||||
'channel_id' => $channel->id
|
||||
],
|
||||
[
|
||||
'user_id' => $livechat->patient_id,
|
||||
'channel_id' => $channel->id
|
||||
]
|
||||
);
|
||||
|
||||
// Menggunakan updateOrCreate untuk menambahkan data UserChannel untuk doctor_id
|
||||
$userChannelDoctor = UserChannel::updateOrCreate(
|
||||
[
|
||||
'user_id' => $livechat->doctor_id,
|
||||
'channel_id' => $channel->id
|
||||
],
|
||||
[
|
||||
'user_id' => $livechat->doctor_id,
|
||||
'channel_id' => $channel->id
|
||||
]
|
||||
);
|
||||
|
||||
// Berikan respons yang sesuai ke klien
|
||||
return response()->json(['message' => 'Channel created successfully', 'channel' => $channel]);
|
||||
|
||||
} else if ($notif->resultCode == "01") {
|
||||
// Action Failed
|
||||
return response()->json(['message' => 'User Gagal melakukan pembayaran']);
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
|
||||
@@ -143,10 +143,17 @@ class LivechatController extends Controller
|
||||
);
|
||||
} else {
|
||||
// insert table livechat
|
||||
|
||||
/**
|
||||
* Status Livechat
|
||||
* 1=Request, 2=Accept, 3=Decline, 4=Waiting Payment, 5=Success Payment, 6 = End Chat
|
||||
*/
|
||||
|
||||
$timezone = date_default_timezone_get();
|
||||
$data['request_date'] = date('Y-m-d H:i:s');
|
||||
$data['timezone'] = $timezone;
|
||||
$data['uuid'] = (string) Str::orderedUuid();
|
||||
$data['status'] = 1;
|
||||
$livechat = Livechat::create($data);
|
||||
$doctor = $livechat->doctor;
|
||||
$data = [
|
||||
@@ -159,6 +166,7 @@ class LivechatController extends Controller
|
||||
return Helper::responseJson(data: $data);
|
||||
}
|
||||
}
|
||||
|
||||
public function consultation_request_show($id){
|
||||
$livechat = Livechat::where('id', $id)->with(['doctor', 'practitioner'])->first();
|
||||
$practitionerRole = PractitionerRole::where('id',$livechat->practitioner->id)->first();
|
||||
@@ -229,44 +237,62 @@ class LivechatController extends Controller
|
||||
return Helper::responseJson(data: $data);
|
||||
}
|
||||
|
||||
public function consultation_payment(Request $request){
|
||||
public function consultation_payment(Request $request)
|
||||
{
|
||||
try {
|
||||
// Mengambil data Livechat dengan relasi doctor dan practitioner
|
||||
$livechat = Livechat::with(['doctor', 'practitioner'])->find($request->consultation_id);
|
||||
|
||||
$livechat = Livechat::where('id', $request->consultation_id)->with(['doctor', 'practitioner'])->first();
|
||||
|
||||
$practitionerRole = PractitionerRole::where('id',$livechat->practitioner->id)->first();
|
||||
$price = $practitionerRole->price ? $practitionerRole->price : 30000;
|
||||
$adminFee = 5000;
|
||||
$discount = 0;
|
||||
$totalPay = $price + $adminFee - $discount;
|
||||
if (!$livechat) {
|
||||
return response()->json(['success' => false, 'message' => 'Consultation not found'], 404);
|
||||
}
|
||||
|
||||
// From database linksehat
|
||||
$user = User::with('detail')
|
||||
->where('nId', $livechat->patient_id)
|
||||
->first();
|
||||
|
||||
$data['paymentMethod'] = $request->payment_code;
|
||||
$data['paymentAmount'] = $totalPay;
|
||||
$data['email'] = $user->sEmail;
|
||||
$data['phoneNumber'] = $user->sPhone;
|
||||
$data['productDetails'] = $user->sEmail;
|
||||
$data['merchantOrderId'] = $livechat->uuid;
|
||||
$data['additionalParam'] = '';
|
||||
$data['merchantUserInfo'] = '';
|
||||
$data['customerVaName'] = $user->sFirstName . ' ' . $user->sLastName;
|
||||
$data['callbackUrl'] = 'htpps://google.com';
|
||||
$data['returnUrl'] = 'htpps://linksehat.com';
|
||||
$data['expiryPeriod'] = 60;
|
||||
$data['firstName'] = $user->sFirstName;
|
||||
$data['lastName'] = $user->sLastName;
|
||||
// Update status
|
||||
$livechat->status = 4;
|
||||
$livechat->save();
|
||||
|
||||
// dd($user);
|
||||
$data['alamat'] = '';
|
||||
$data['city'] = '';
|
||||
$data['postalCode'] = '';
|
||||
$practitionerRole = PractitionerRole::find($livechat->practitioner->id);
|
||||
$price = $practitionerRole->price ?? 30000; // Gunakan null coalescing operator
|
||||
$adminFee = 5000;
|
||||
$discount = 0;
|
||||
$totalPay = $price + $adminFee - $discount;
|
||||
|
||||
$duitku = DuitkuHelper::createInvoice($data);
|
||||
// Mengambil user dari database
|
||||
$user = User::with('detail')->where('nId', $livechat->patient_id)->first();
|
||||
|
||||
return $duitku;
|
||||
if (!$user) {
|
||||
return response()->json(['success' => false, 'message' => 'User not found'], 404);
|
||||
}
|
||||
|
||||
// Menyiapkan data untuk invoice
|
||||
$data = [
|
||||
'paymentMethod' => $request->payment_code,
|
||||
'paymentAmount' => $totalPay,
|
||||
'email' => $user->sEmail,
|
||||
'phoneNumber' => $user->sPhone,
|
||||
'productDetails' => 'Telekonsul Livechat LMS',
|
||||
'merchantOrderId' => $livechat->uuid,
|
||||
'additionalParam' => '',
|
||||
'merchantUserInfo' => '',
|
||||
'customerVaName' => $user->sFirstName . ' ' . $user->sLastName,
|
||||
'callbackUrl' => 'https://google.com',
|
||||
'returnUrl' => 'https://linksehat.com',
|
||||
'expiryPeriod' => 60,
|
||||
'firstName' => $user->sFirstName,
|
||||
'lastName' => $user->sLastName,
|
||||
'alamat' => '',
|
||||
'city' => '',
|
||||
'postalCode' => ''
|
||||
];
|
||||
|
||||
// Membuat invoice menggunakan DuitkuHelper
|
||||
$duitku = DuitkuHelper::createInvoice($data);
|
||||
|
||||
return response()->json(['success' => true, 'data' => $duitku], 200);
|
||||
} catch (Exception $e) {
|
||||
// Menangkap error dan mengembalikan respon error
|
||||
return response()->json(['success' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function consultation_check_payment($id){
|
||||
|
||||
@@ -107,11 +107,15 @@ Route::prefix('linksehat')->group(function () {
|
||||
|
||||
Route::post('livechat/consultation-payment', 'consultation_payment');
|
||||
});
|
||||
|
||||
Route::controller(ChatController::class)->group(function () {
|
||||
Route::post('livechat/send-message', 'sendMessage');
|
||||
Route::get('livechat/get-message', 'getMessage');
|
||||
Route::post('livechat/channel','createChannel');
|
||||
Route::get('livechat/channel','listChannel');
|
||||
Route::get('livechat/{id}/health-sertificate','downloadHealtcare');
|
||||
});
|
||||
|
||||
Route::post('livechat/send-message', [ChatController::class, 'sendMessage']);
|
||||
Route::get('livechat/get-message', [ChatController::class, 'getMessage']);
|
||||
Route::post('livechat/channel',[ChatController::class, 'createChannel']);
|
||||
Route::get('livechat/channel',[ChatController::class, 'listChannel']);
|
||||
|
||||
Route::post('create-invoice-duitku', [DuitkuController::class, 'createInvoice']);
|
||||
Route::post('check-status-duitku', [DuitkuController::class, 'checkStatus']);
|
||||
@@ -142,6 +146,11 @@ Route::prefix('linksehat')->group(function () {
|
||||
});
|
||||
Route::controller(ChatDoctorController::class)->group(function () {
|
||||
Route::get('chat', 'getChat');
|
||||
Route::post('decline', 'declineChat');
|
||||
Route::post('approve', 'approveChat');
|
||||
Route::post('end', 'endChat');
|
||||
Route::post('summary', 'summaryChat');
|
||||
Route::get('chat/{id}', 'getChatDetail');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -490,4 +490,13 @@ class Helper
|
||||
return $umur . ' years old';
|
||||
}
|
||||
|
||||
public static function calculateDateDifference($startDate, $endDate)
|
||||
{
|
||||
$start = Carbon::parse($startDate);
|
||||
$end = Carbon::parse($endDate);
|
||||
|
||||
return $start->diffInDays($end) + 1;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -23,6 +23,13 @@ class Livechat extends Model
|
||||
'accept_date',
|
||||
'start_date',
|
||||
'end_date',
|
||||
'status',
|
||||
'subject',
|
||||
'object',
|
||||
'assessment',
|
||||
'plan',
|
||||
'health_certificate_start',
|
||||
'health_certificate_end',
|
||||
];
|
||||
|
||||
public function doctor() {
|
||||
|
||||
@@ -14,6 +14,7 @@ class PrescriptionItem extends Model
|
||||
'qty',
|
||||
'unit_id',
|
||||
'note',
|
||||
'signa'
|
||||
'signa',
|
||||
'direction'
|
||||
];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('livechats', function (Blueprint $table) {
|
||||
$table->integer('status')->after('end_date')->comment('1=Request, 2=Accept, 3=Decline, 4=Waiting Payment, 5=Success Payment, 6 = End Chat');
|
||||
$table->string('subject')->after('status')->nullable();
|
||||
$table->string('object')->after('subject')->nullable();
|
||||
$table->string('assessment')->after('object')->nullable();
|
||||
$table->text('plan')->after('assessment')->nullable();
|
||||
$table->date('health_certificate_start')->after('end_date')->nullable();
|
||||
$table->date('health_certificate_end')->after('health_certificate_start')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('livechats', function (Blueprint $table) {
|
||||
$table->dropColumn('status');
|
||||
$table->dropColumn('subject');
|
||||
$table->dropColumn('object');
|
||||
$table->dropColumn('assessment');
|
||||
$table->dropColumn('plan');
|
||||
$table->dropColumn('health_certificate_start');
|
||||
$table->dropColumn('health_certificate_end');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('prescription_items', function (Blueprint $table) {
|
||||
$table->string('direction')->after('signa')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('prescription_items', function (Blueprint $table) {
|
||||
$table->dropColumn('direction');
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user