update
This commit is contained in:
@@ -5,6 +5,7 @@ namespace Modules\Internal\Http\Controllers\Api;
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\OLDLMS\Livechat;
|
||||
use App\Models\OLDLMS\Appointment;
|
||||
use App\Models\Organization;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -25,12 +26,18 @@ class LivechatController extends Controller
|
||||
{
|
||||
$startDate = $request->startDate;
|
||||
$endDate = $request->endDate;
|
||||
$search = $request->search;
|
||||
|
||||
$livechat = Livechat::with('doctor.user', 'doctor.speciality', 'appointment.appointmentDetail', 'healthCare');
|
||||
$livechat = Livechat::with('doctor.user', 'doctor.speciality', 'appointment.appointmentDetail', 'healthCare', 'user');
|
||||
// ->where('nIDAppointment', '!=', null)
|
||||
// ->where('nIDAppointment', '!=', '');
|
||||
|
||||
|
||||
if ($search) {
|
||||
$livechat = $livechat->whereHas('user', function ($query) use ($search) {
|
||||
$query->where('sFirstName', 'like', '%' . $search . '%')
|
||||
->orWhere('sLastName', 'like', '%' . $search . '%');
|
||||
});
|
||||
}
|
||||
if ($startDate) {
|
||||
$livechat = $livechat->where('dCreateOn', '>=', $startDate);
|
||||
}
|
||||
@@ -443,9 +450,10 @@ class LivechatController extends Controller
|
||||
['value' => 'Poli', 'cell' => 'Y1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'Total', 'cell' => 'Z1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'Obat', 'cell' => 'AA1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'Nama Obat', 'cell' => 'AB1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'Jumlah Obat', 'cell' => 'AC1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'By', 'cell' => 'AD1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'Apotek', 'cell' => 'AB1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'Nama Obat', 'cell' => 'AC1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'Jumlah Obat', 'cell' => 'AD1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'By', 'cell' => 'AE1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
];
|
||||
|
||||
$spreadsheet = new Spreadsheet();
|
||||
@@ -472,197 +480,227 @@ class LivechatController extends Controller
|
||||
$startFromSheet1 = 2;
|
||||
$startFromSheet2 = 2;
|
||||
foreach ($liveChats as $indexLiveChat => $liveChat) {
|
||||
//###################### SHEET 1 ##########
|
||||
$phone = $liveChat->user->sPhone ?? '-';
|
||||
$status = $liveChat->sStatus;
|
||||
$nIDUser = $liveChat->user->nIDUser ?? 0; // Principal or Dependent
|
||||
$paymentMethod = $liveChat->appointment ? Helper::sPaymentMethod($liveChat->appointment->sPaymentMethod) : 'N/A';
|
||||
$fullNameDoctor = '-';
|
||||
if (!empty($liveChat->doctor->user)) {
|
||||
$fullNameDoctor = '';
|
||||
|
||||
if ($liveChat->doctor->user->detail !== null) {
|
||||
if ($liveChat->doctor->user->detail->sTitlePrefix !== null) {
|
||||
$fullNameDoctor .= $liveChat->doctor->user->detail->sTitlePrefix . '. ';
|
||||
}
|
||||
|
||||
if ($liveChat->doctor->user->full_name !== null) {
|
||||
$fullNameDoctor .= $liveChat->doctor->user->full_name . ' ';
|
||||
}
|
||||
|
||||
if ($liveChat->doctor->user->detail->sTitleSuffix !== null) {
|
||||
$fullNameDoctor .= $liveChat->doctor->user->detail->sTitleSuffix;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$recordType = 'P';
|
||||
if ($nIDUser){
|
||||
$recordType = 'D';
|
||||
}
|
||||
switch ($status) {
|
||||
case 0:
|
||||
$statusLivechat = "Request TC";
|
||||
break;
|
||||
case 1:
|
||||
$statusLivechat = "Accepted by Doctor but User not Payment";
|
||||
break;
|
||||
case 2:
|
||||
$statusLivechat = "Payment Success";
|
||||
break;
|
||||
case 3:
|
||||
$statusLivechat = "Decline by Doctor";
|
||||
break;
|
||||
case 4:
|
||||
$statusLivechat = "Payment Expired";
|
||||
break;
|
||||
default:
|
||||
$statusLivechat = "Cancel by Patient";
|
||||
}
|
||||
|
||||
$requestTime = Carbon::parse($liveChat->dRequestTime);
|
||||
$acceptTime = Carbon::parse($liveChat->dAcceptTime);
|
||||
$startTime = Carbon::parse($liveChat->dStartTime);
|
||||
$endTime = Carbon::parse($liveChat->dEndTime);
|
||||
|
||||
// Hitung selisih waktu response
|
||||
if ($requestTime && $acceptTime) {
|
||||
$diff = $requestTime->diff($acceptTime);
|
||||
$responseTimeDiff = sprintf('%02d:%02d:%02d', $diff->h, $diff->i, $diff->s);
|
||||
} else {
|
||||
$responseTimeDiff = '00:00:00'; // Default jika data kosong
|
||||
}
|
||||
|
||||
// Hitung selisih waktu chat
|
||||
if ($startTime && $endTime) {
|
||||
$diffChatTime = $startTime->diff($endTime);
|
||||
$chatTimeDiff = sprintf('%02d:%02d:%02d', $diffChatTime->h, $diffChatTime->i, $diffChatTime->s);
|
||||
} else {
|
||||
$chatTimeDiff = '00:00:00'; // Default jika data kosong
|
||||
}
|
||||
|
||||
// Set nilai responseTime dan chatTime
|
||||
$responseTime = $responseTimeDiff;
|
||||
$chatTime = $chatTimeDiff;
|
||||
|
||||
|
||||
$diagnosa = '-';
|
||||
$diagnosaCode = '-';
|
||||
if($liveChat->summary){
|
||||
$diagnosis = explode(', ', $liveChat->summary->sAssessment);
|
||||
|
||||
if ($diagnosis) {
|
||||
$diagnosaArray = [];
|
||||
$diagnosaCodeArray = [];
|
||||
foreach($diagnosis as $data){
|
||||
$diagnosaArray[] = Helper::diagnosisName($data); // Tambahkan diagnosis ke array
|
||||
$diagnosaCodeArray[] = $data; // Tambahkan diagnosis ke array
|
||||
}
|
||||
|
||||
$diagnosa = implode('; ', $diagnosaArray); // Gabungkan array dengan tanda koma
|
||||
$diagnosaCode = implode('; ', $diagnosaCodeArray); // Gabungkan array dengan tanda koma
|
||||
}
|
||||
}
|
||||
|
||||
$tebusResep = 'Belum Ditebus';
|
||||
$paymentTebus = '-';
|
||||
$obat = '-';
|
||||
$obatQty = '-';
|
||||
$qtyTotal = 0;
|
||||
// Nama Apotek
|
||||
$apotek = '-';
|
||||
if ($liveChat->prescription){
|
||||
// Tanggal target (misalnya, dari database atau input)
|
||||
$tanggalResep = Carbon::parse($liveChat->prescription->dTanggalResep);
|
||||
|
||||
// Tanggal hari ini
|
||||
$tanggalNow = Carbon::now();
|
||||
|
||||
// Menghitung selisih hari
|
||||
$selisihHari = $tanggalNow->diffInDays($tanggalResep);
|
||||
if ($selisihHari > 1){
|
||||
$tebusResep = 'Resep Kadaluarsa';
|
||||
}
|
||||
|
||||
if ($liveChat->prescription->sIsDownload == 1){
|
||||
$tebusResep = 'Offline';
|
||||
}
|
||||
if($liveChat->prescription->payment){
|
||||
$tebusResep = 'Online';
|
||||
$apotek = Organization::where('code', $liveChat->prescription->payment->nIDApotek)->first();
|
||||
if ($apotek){
|
||||
$apotek = $apotek->name;
|
||||
} else {
|
||||
$apotek = '-';
|
||||
}
|
||||
|
||||
if ($liveChat->prescription->payment->sPaymentStatus == 'paid'){
|
||||
$paymentTebus = Carbon::parse($liveChat->prescription->payment->dCreateOn)->format('d-m-Y H:i:s');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
if ($liveChat->prescription->items){
|
||||
$obatArray = [];
|
||||
$obatQtyArray = [];
|
||||
foreach($liveChat->prescription->items as $data){
|
||||
$obatArray[] = $data->sItemName;
|
||||
$obatQtyArray[] = $data->nQty;
|
||||
$qtyTotal += $data->nQty;
|
||||
}
|
||||
|
||||
$obat = implode('; ',$obatArray);
|
||||
$obatQty = implode('; ',$obatQtyArray);
|
||||
}
|
||||
} else {
|
||||
$tebusResep = '-';
|
||||
}
|
||||
|
||||
switch ($liveChat->user->nIDHubunganKeluarga) {
|
||||
case 9:
|
||||
$nIDHubunganKeluarga = "Peserta"; // Parent
|
||||
break;
|
||||
case 4:
|
||||
$nIDHubunganKeluarga = 'Istri'; // Spouse
|
||||
break;
|
||||
case 5:
|
||||
$nIDHubunganKeluarga = 'Anak'; // Child
|
||||
break;
|
||||
case 3:
|
||||
$nIDHubunganKeluarga = 'Suami'; // Husband
|
||||
break;
|
||||
default:
|
||||
$nIDHubunganKeluarga = '-'; // No need to set $nIDHubunganKeluarga as it's already set to default value
|
||||
break;
|
||||
}
|
||||
|
||||
if ($liveChat->user->relation && $nIDHubunganKeluarga == '-'){
|
||||
$nIDHubunganKeluarga = $liveChat->user->relation->sHubunganKeluarga;
|
||||
}
|
||||
|
||||
$sheet->setCellValue('A' . $startFromSheet1, $liveChat->nID ?? '-');
|
||||
$sheet->setCellValue('B' . $startFromSheet1, $liveChat->sNoSpj ?? '-');
|
||||
$sheet->setCellValue('C' . $startFromSheet1, (string)($liveChat->userInsurance->sCorporateCode ?? '-'));
|
||||
$sheet->setCellValue('D' . $startFromSheet1, (string)($liveChat->userInsurance->sCorporateName ?? '-'));
|
||||
$sheet->setCellValue('E' . $startFromSheet1, (string)($liveChat->userInsurance->sNoPolis ?? '-'));
|
||||
$sheet->setCellValue('F' . $startFromSheet1, $liveChat->user->full_name ?? '-');
|
||||
$sheet->setCellValue('G' . $startFromSheet1, $liveChat->user->detail->dTanggalLahir ?? '-');
|
||||
$sheet->setCellValue('H' . $startFromSheet1, $liveChat->user->detail->nIDJenisKelamin == 1 ? 'Laki-laki' : 'Wanita');
|
||||
$sheet->setCellValue('I' . $startFromSheet1, Helper::calculateAge($liveChat->user->detail->dTanggalLahir) ?? '-');
|
||||
$sheet->setCellValue('J' . $startFromSheet1, (string)($liveChat->userInsurance->sProductCode ?? '-'));
|
||||
$sheet->setCellValue('K' . $startFromSheet1, (string)($liveChat->userInsurance->sPlanCode ?? '-'));
|
||||
$sheet->setCellValue('L' . $startFromSheet1, $nIDHubunganKeluarga ?? '-');
|
||||
$sheet->setCellValue('M' . $startFromSheet1, $requestTime->format('Y-m-d'));
|
||||
$sheet->setCellValue('N' . $startFromSheet1, $liveChat->summary->sSubjective ?? '-');
|
||||
$sheet->setCellValue('O' . $startFromSheet1, $diagnosaCode ?? '-');
|
||||
$sheet->setCellValue('P' . $startFromSheet1, $diagnosa ?? '-');
|
||||
$sheet->setCellValue('Q' . $startFromSheet1, $startTime->format('H:i:s'));
|
||||
$sheet->setCellValue('R' . $startFromSheet1, $endTime->format('H:i:s'));
|
||||
$sheet->setCellValue('S' . $startFromSheet1, $chatTime);
|
||||
// $sheet->setCellValue('O' . $startFromSheet1, $recordType);
|
||||
// $sheet->setCellValue('P' . $startFromSheet1, $nIDUser ?? '-');
|
||||
// $sheet->setCellValue('Q' . $startFromSheet1, $paymentMethod ?? '-');
|
||||
$sheet->setCellValue('T' . $startFromSheet1, $statusLivechat);
|
||||
$sheet->setCellValue('U' . $startFromSheet1, $liveChat->prescription->sKodeResep ?? '-');
|
||||
$sheet->setCellValue('V' . $startFromSheet1, $fullNameDoctor);
|
||||
$sheet->setCellValue('W' . $startFromSheet1, $liveChat->doctor->speciality->sSpesialis ?? '-');
|
||||
$sheet->setCellValue('X' . $startFromSheet1, $liveChat->rujukan ? 'Ya' : 'Tidak');
|
||||
$sheet->setCellValue('Y' . $startFromSheet1, $liveChat->rujukan->sDepartement ?? '-' );
|
||||
|
||||
$sheet->setCellValue('Z' . $startFromSheet1, $qtyTotal);
|
||||
$sheet->setCellValue('AA' . $startFromSheet1, $tebusResep);
|
||||
|
||||
$sheet->setCellValue('AB' . $startFromSheet1, $apotek);
|
||||
$sheet->setCellValue('AC' . $startFromSheet1, $obat);
|
||||
$sheet->setCellValue('AD' . $startFromSheet1, $obatQty);
|
||||
$sheet->setCellValue('AE' . $startFromSheet1, 'LMS');
|
||||
// $sheet->setCellValue('AC' . $startFrom, $liveChat->prescription->dCreateOn ?? '-');
|
||||
// $sheet->setCellValue('AD' . $startFrom, $obat);
|
||||
// $sheet->setCellValue('AE' . $startFrom, $tebusResep);
|
||||
|
||||
// $sheet->setCellValue('AF' . $startFrom, $paymentTebus);
|
||||
// $sheet->setCellValue('AG' . $startFrom, $liveChat->rujukan->nIDHealthcare ?? '-');
|
||||
// $sheet->setCellValue('AH' . $startFrom, $liveChat->rujukan->sDepartement ?? '-');
|
||||
// $sheet->setCellValue('AI' . $startFrom, $liveChat->summary->sSubjective ?? '-');
|
||||
// $sheet->setCellValue('AJ' . $startFrom, $liveChat->sNoSpj ?? '-');
|
||||
$startFromSheet1++;
|
||||
//###################### END SHEET 1 ##########
|
||||
if (!$liveChat->prescription) {
|
||||
$phone = $liveChat->user->sPhone ?? '-';
|
||||
$status = $liveChat->sStatus;
|
||||
$nIDUser = $liveChat->user->nIDUser ?? 0; // Principal or Dependent
|
||||
$paymentMethod = $liveChat->appointment ? Helper::sPaymentMethod($liveChat->appointment->sPaymentMethod) : 'N/A';
|
||||
$fullNameDoctor = '-';
|
||||
if (!empty($liveChat->doctor->user)) {
|
||||
$fullNameDoctor = '';
|
||||
|
||||
if ($liveChat->doctor->user->detail !== null) {
|
||||
if ($liveChat->doctor->user->detail->sTitlePrefix !== null) {
|
||||
$fullNameDoctor .= $liveChat->doctor->user->detail->sTitlePrefix . '. ';
|
||||
}
|
||||
|
||||
if ($liveChat->doctor->user->full_name !== null) {
|
||||
$fullNameDoctor .= $liveChat->doctor->user->full_name . ' ';
|
||||
}
|
||||
|
||||
if ($liveChat->doctor->user->detail->sTitleSuffix !== null) {
|
||||
$fullNameDoctor .= $liveChat->doctor->user->detail->sTitleSuffix;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$recordType = 'P';
|
||||
if ($nIDUser){
|
||||
$recordType = 'D';
|
||||
}
|
||||
switch ($status) {
|
||||
case 0:
|
||||
$statusLivechat = "Request TC";
|
||||
break;
|
||||
case 1:
|
||||
$statusLivechat = "Accepted by Doctor but User not Payment";
|
||||
break;
|
||||
case 2:
|
||||
$statusLivechat = "Payment Success";
|
||||
break;
|
||||
case 3:
|
||||
$statusLivechat = "Decline by Doctor";
|
||||
break;
|
||||
case 4:
|
||||
$statusLivechat = "Payment Expired";
|
||||
break;
|
||||
default:
|
||||
$statusLivechat = "Cancel by Patient";
|
||||
}
|
||||
|
||||
$requestTime = Carbon::parse($liveChat->dRequestTime);
|
||||
$acceptTime = Carbon::parse($liveChat->dAcceptTime);
|
||||
$startTime = Carbon::parse($liveChat->dStartTime);
|
||||
$endTime = Carbon::parse($liveChat->dEndTime);
|
||||
|
||||
// Hitung selisih waktu response
|
||||
if ($requestTime && $acceptTime) {
|
||||
$diff = $requestTime->diff($acceptTime);
|
||||
$responseTimeDiff = sprintf('%02d:%02d:%02d', $diff->h, $diff->i, $diff->s);
|
||||
} else {
|
||||
$responseTimeDiff = '00:00:00'; // Default jika data kosong
|
||||
}
|
||||
|
||||
// Hitung selisih waktu chat
|
||||
if ($startTime && $endTime) {
|
||||
$diffChatTime = $startTime->diff($endTime);
|
||||
$chatTimeDiff = sprintf('%02d:%02d:%02d', $diffChatTime->h, $diffChatTime->i, $diffChatTime->s);
|
||||
} else {
|
||||
$chatTimeDiff = '00:00:00'; // Default jika data kosong
|
||||
}
|
||||
|
||||
// Set nilai responseTime dan chatTime
|
||||
$responseTime = $responseTimeDiff;
|
||||
$chatTime = $chatTimeDiff;
|
||||
|
||||
|
||||
$diagnosa = '-';
|
||||
$diagnosaCode = '-';
|
||||
if($liveChat->summary){
|
||||
$diagnosis = explode(', ', $liveChat->summary->sAssessment);
|
||||
|
||||
if ($diagnosis) {
|
||||
$diagnosaArray = [];
|
||||
$diagnosaCodeArray = [];
|
||||
foreach($diagnosis as $data){
|
||||
$diagnosaArray[] = Helper::diagnosisName($data); // Tambahkan diagnosis ke array
|
||||
$diagnosaCodeArray[] = $data; // Tambahkan diagnosis ke array
|
||||
}
|
||||
|
||||
$diagnosa = implode('; ', $diagnosaArray); // Gabungkan array dengan tanda koma
|
||||
$diagnosaCode = implode('; ', $diagnosaCodeArray); // Gabungkan array dengan tanda koma
|
||||
}
|
||||
}
|
||||
|
||||
$tebusResep = 'Belum Ditebus';
|
||||
$paymentTebus = '-';
|
||||
if ($liveChat->prescription){
|
||||
// Tanggal target (misalnya, dari database atau input)
|
||||
$tanggalResep = Carbon::parse($liveChat->prescription->dTanggalResep);
|
||||
|
||||
// Tanggal hari ini
|
||||
$tanggalNow = Carbon::now();
|
||||
|
||||
// Menghitung selisih hari
|
||||
$selisihHari = $tanggalNow->diffInDays($tanggalResep);
|
||||
if ($selisihHari > 1){
|
||||
$tebusResep = 'Resep Kadaluarsa';
|
||||
}
|
||||
|
||||
if ($liveChat->prescription->sIsDownload == 1){
|
||||
$tebusResep = 'Offline';
|
||||
}
|
||||
if($liveChat->prescription->payment){
|
||||
$tebusResep = 'Online';
|
||||
if ($liveChat->prescription->payment->sPaymentStatus == 'paid'){
|
||||
$paymentTebus = Carbon::parse($liveChat->prescription->payment->dCreateOn)->format('d-m-Y H:i:s');
|
||||
}
|
||||
};
|
||||
} else {
|
||||
$tebusResep = '-';
|
||||
}
|
||||
|
||||
switch ($liveChat->user->nIDHubunganKeluarga) {
|
||||
case 9:
|
||||
$nIDHubunganKeluarga = "Peserta"; // Parent
|
||||
break;
|
||||
case 4:
|
||||
$nIDHubunganKeluarga = 'Istri'; // Spouse
|
||||
break;
|
||||
case 5:
|
||||
$nIDHubunganKeluarga = 'Anak'; // Child
|
||||
break;
|
||||
case 3:
|
||||
$nIDHubunganKeluarga = 'Suami'; // Husband
|
||||
break;
|
||||
default:
|
||||
$nIDHubunganKeluarga = '-'; // No need to set $nIDHubunganKeluarga as it's already set to default value
|
||||
break;
|
||||
}
|
||||
|
||||
if ($liveChat->user->relation && $nIDHubunganKeluarga == '-'){
|
||||
$nIDHubunganKeluarga = $liveChat->user->relation->sHubunganKeluarga;
|
||||
}
|
||||
|
||||
$obat = '-';
|
||||
|
||||
$sheet->setCellValue('A' . $startFromSheet1, $liveChat->nID ?? '-');
|
||||
$sheet->setCellValue('B' . $startFromSheet1, $liveChat->sNoSpj ?? '-');
|
||||
$sheet->setCellValue('C' . $startFromSheet1, (string)($liveChat->userInsurance->sCorporateCode ?? '-'));
|
||||
$sheet->setCellValue('D' . $startFromSheet1, (string)($liveChat->userInsurance->sCorporateName ?? '-'));
|
||||
$sheet->setCellValue('E' . $startFromSheet1, (string)($liveChat->userInsurance->sNoPolis ?? '-'));
|
||||
$sheet->setCellValue('F' . $startFromSheet1, $liveChat->user->full_name ?? '-');
|
||||
$sheet->setCellValue('G' . $startFromSheet1, $liveChat->user->detail->dTanggalLahir ?? '-');
|
||||
$sheet->setCellValue('H' . $startFromSheet1, $liveChat->user->detail->nIDJenisKelamin == 1 ? 'Laki-laki' : 'Wanita');
|
||||
$sheet->setCellValue('I' . $startFromSheet1, Helper::calculateAge($liveChat->user->detail->dTanggalLahir) ?? '-');
|
||||
$sheet->setCellValue('J' . $startFromSheet1, (string)($liveChat->userInsurance->sProductCode ?? '-'));
|
||||
$sheet->setCellValue('K' . $startFromSheet1, (string)($liveChat->userInsurance->sPlanCode ?? '-'));
|
||||
$sheet->setCellValue('L' . $startFromSheet1, $nIDHubunganKeluarga ?? '-');
|
||||
$sheet->setCellValue('M' . $startFromSheet1, $requestTime->format('Y-m-d'));
|
||||
$sheet->setCellValue('N' . $startFromSheet1, $liveChat->summary->sSubjective ?? '-');
|
||||
$sheet->setCellValue('O' . $startFromSheet1, $diagnosaCode ?? '-');
|
||||
$sheet->setCellValue('P' . $startFromSheet1, $diagnosa ?? '-');
|
||||
$sheet->setCellValue('Q' . $startFromSheet1, $startTime->format('H:i:s'));
|
||||
$sheet->setCellValue('R' . $startFromSheet1, $endTime->format('H:i:s'));
|
||||
$sheet->setCellValue('S' . $startFromSheet1, $chatTime);
|
||||
// $sheet->setCellValue('O' . $startFromSheet1, $recordType);
|
||||
// $sheet->setCellValue('P' . $startFromSheet1, $nIDUser ?? '-');
|
||||
// $sheet->setCellValue('Q' . $startFromSheet1, $paymentMethod ?? '-');
|
||||
$sheet->setCellValue('T' . $startFromSheet1, $statusLivechat);
|
||||
$sheet->setCellValue('U' . $startFromSheet1, $liveChat->prescription->sKodeResep ?? '-');
|
||||
$sheet->setCellValue('V' . $startFromSheet1, $fullNameDoctor);
|
||||
$sheet->setCellValue('W' . $startFromSheet1, $liveChat->doctor->speciality->sSpesialis ?? '-');
|
||||
$sheet->setCellValue('X' . $startFromSheet1, $liveChat->rujukan ? 'Ya' : 'Tidak');
|
||||
$sheet->setCellValue('Y' . $startFromSheet1, $liveChat->rujukan->sDepartement ?? '-' );
|
||||
|
||||
$sheet->setCellValue('Z' . $startFromSheet1, '-');
|
||||
$sheet->setCellValue('AA' . $startFromSheet1, $tebusResep);
|
||||
|
||||
$sheet->setCellValue('AB' . $startFromSheet1, '-');
|
||||
$sheet->setCellValue('AC' . $startFromSheet1, '-');
|
||||
$sheet->setCellValue('AD' . $startFromSheet1, 'LMS');
|
||||
// $sheet->setCellValue('AC' . $startFrom, $liveChat->prescription->dCreateOn ?? '-');
|
||||
// $sheet->setCellValue('AD' . $startFrom, $obat);
|
||||
// $sheet->setCellValue('AE' . $startFrom, $tebusResep);
|
||||
|
||||
// $sheet->setCellValue('AF' . $startFrom, $paymentTebus);
|
||||
// $sheet->setCellValue('AG' . $startFrom, $liveChat->rujukan->nIDHealthcare ?? '-');
|
||||
// $sheet->setCellValue('AH' . $startFrom, $liveChat->rujukan->sDepartement ?? '-');
|
||||
// $sheet->setCellValue('AI' . $startFrom, $liveChat->summary->sSubjective ?? '-');
|
||||
// $sheet->setCellValue('AJ' . $startFrom, $liveChat->sNoSpj ?? '-');
|
||||
$startFromSheet1++;
|
||||
} else {
|
||||
if ($liveChat->prescription->items){
|
||||
$obatArray = [];
|
||||
$obatQtyArray = [];
|
||||
foreach($liveChat->prescription->items as $data){
|
||||
$phone = $liveChat->user->sPhone ?? '-';
|
||||
$status = $liveChat->sStatus;
|
||||
@@ -767,7 +805,7 @@ class LivechatController extends Controller
|
||||
|
||||
// Tanggal hari ini
|
||||
$tanggalNow = Carbon::now();
|
||||
|
||||
|
||||
// Menghitung selisih hari
|
||||
$selisihHari = $tanggalNow->diffInDays($tanggalResep);
|
||||
if ($selisihHari > 1){
|
||||
@@ -779,6 +817,13 @@ class LivechatController extends Controller
|
||||
}
|
||||
if($liveChat->prescription->payment){
|
||||
$tebusResep = 'Online';
|
||||
$apotek = Organization::where('id', $liveChat->prescription->payment->nIDApotek)->first();
|
||||
if ($apotek){
|
||||
$apotek = $apotek->name;
|
||||
} else {
|
||||
$apotek = '-';
|
||||
}
|
||||
|
||||
if ($liveChat->prescription->payment->sPaymentStatus == 'paid'){
|
||||
$paymentTebus = Carbon::parse($liveChat->prescription->payment->dCreateOn)->format('d-m-Y H:i:s');
|
||||
}
|
||||
@@ -808,8 +853,11 @@ class LivechatController extends Controller
|
||||
if ($liveChat->user->relation && $nIDHubunganKeluarga == '-'){
|
||||
$nIDHubunganKeluarga = $liveChat->user->relation->sHubunganKeluarga;
|
||||
}
|
||||
|
||||
$obat = '-';
|
||||
|
||||
$obat = $data->sItemName;
|
||||
$obatQty = $data->nQty;
|
||||
|
||||
|
||||
$sheet2->setCellValue('A' . $startFromSheet2, $liveChat->nID ?? '-');
|
||||
$sheet2->setCellValue('B' . $startFromSheet2, $liveChat->sNoSpj ?? '-');
|
||||
$sheet2->setCellValue('C' . $startFromSheet2, (string)($liveChat->userInsurance->sCorporateCode ?? '-'));
|
||||
@@ -842,9 +890,10 @@ class LivechatController extends Controller
|
||||
$sheet2->setCellValue('Z' . $startFromSheet2, '-');
|
||||
$sheet2->setCellValue('AA' . $startFromSheet2, $tebusResep);
|
||||
|
||||
$sheet2->setCellValue('AB' . $startFromSheet2, $data->sItemName);
|
||||
$sheet2->setCellValue('AC' . $startFromSheet2, $data->nQty);
|
||||
$sheet2->setCellValue('AD' . $startFromSheet2, 'LMS');
|
||||
$sheet2->setCellValue('AB' . $startFromSheet2, $apotek );
|
||||
$sheet2->setCellValue('AC' . $startFromSheet2, $obat);
|
||||
$sheet2->setCellValue('AD' . $startFromSheet2, $obatQty);
|
||||
$sheet2->setCellValue('AE' . $startFromSheet2, 'LMS');
|
||||
// $sheet->setCellValue('AC' . $startFromSheet2, $liveChat->prescription->dCreateOn ?? '-');
|
||||
// $sheet->setCellValue('AD' . $startFromSheet2, $obat);
|
||||
// $sheet->setCellValue('AE' . $startFromSheet2, $tebusResep);
|
||||
|
||||
Reference in New Issue
Block a user