update report livechat
This commit is contained in:
@@ -63,7 +63,19 @@ class LivechatController extends Controller
|
||||
$startDate = $request->has('startDate') ? $request->input('startDate') : '';
|
||||
$endDate = $request->has('endDate') ? $request->input('endDate') : '';
|
||||
|
||||
$liveChats = Livechat::with('user:nID,sFirstName,sLastName,sEmail,sPhone,nIDUser', 'doctor:nID,nIDSpesialis,nIDUser', 'doctor.user:nID,sFirstName,sLastName', 'appointment:nID,sPaymentStatus,sPaymentMethod', 'appointment.appointmentDetail:nID,nIDAppointment,dTanggalAppointment,tTimeAppointment', 'healthCare:nID,sHealthCare')
|
||||
$liveChats = Livechat::with('userInsurance',
|
||||
'user:nID,sFirstName,sLastName,sEmail,sPhone,nIDUser,nIDHubunganKeluarga',
|
||||
'doctor:nID,nIDSpesialis,nIDUser', 'doctor.user:nID,sFirstName,sLastName',
|
||||
'appointment:nID,sPaymentStatus,sPaymentMethod',
|
||||
'appointment.appointmentDetail:nID,nIDAppointment,dTanggalAppointment,tTimeAppointment',
|
||||
'healthCare:nID,sHealthCare',
|
||||
'prescription',
|
||||
'rujukan'
|
||||
)
|
||||
->whereHas('userInsurance', function (Builder $query) {
|
||||
// Kondisi pada relasi userInsurance
|
||||
$query->where('nIDInsurance', 107); // khusus inhealth
|
||||
})
|
||||
->where(function (Builder $query) use ($startDate, $endDate) {
|
||||
// $query->where('nIDAppointment', '!=', null);
|
||||
// $query->where('nIDAppointment', '!=', '');
|
||||
@@ -76,7 +88,7 @@ class LivechatController extends Controller
|
||||
}
|
||||
})
|
||||
->orderBy('nID', 'desc')
|
||||
->get(['nID', 'nIDUser', 'nIDDokter', 'nIDHealthCare', 'nIDAppointment', 'sStatus', 'sMediaDokter', 'sMedia', 'dCreateOn']);
|
||||
->get(['nID', 'nIDUser', 'dRequestTime', 'dAcceptTime', 'dStartTime', 'dEndTime', 'nIDDokter', 'nIDHealthCare', 'nIDAppointment', 'sStatus', 'sMediaDokter', 'sMedia', 'dCreateOn']);
|
||||
|
||||
$headers = [
|
||||
['value' => 'No', 'cell' => 'A1', 'mergeCell' => true, 'mergeToCell' => 'A2'],
|
||||
@@ -93,10 +105,28 @@ class LivechatController extends Controller
|
||||
['value' => 'Nama Pasien', 'cell' => 'K1', 'mergeCell' => true, 'mergeToCell' => 'K2'],
|
||||
['value' => 'No Telepon Pasien', 'cell' => 'L1', 'mergeCell' => true, 'mergeToCell' => 'L2'],
|
||||
['value' => 'Email Pasien', 'cell' => 'M1', 'mergeCell' => true, 'mergeToCell' => 'M2'],
|
||||
['value' => 'Status', 'cell' => 'N1', 'mergeCell' => true, 'mergeToCell' => 'N2'],
|
||||
['value' => 'Record Type', 'cell' => 'O1', 'mergeCell' => true, 'mergeToCell' => 'O2'],
|
||||
['value' => 'nID Principal', 'cell' => 'P1', 'mergeCell' => true, 'mergeToCell' => 'P2'],
|
||||
['value' => 'Metode Pembayaran', 'cell' => 'Q1', 'mergeCell' => true, 'mergeToCell' => 'Q2'],
|
||||
['value' => 'No Kartu Insurance', 'cell' => 'N1', 'mergeCell' => true, 'mergeToCell' => 'N2'],
|
||||
['value' => 'Corporate ID', 'cell' => 'O1', 'mergeCell' => true, 'mergeToCell' => 'O2'],
|
||||
['value' => 'Corporate Name', 'cell' => 'P1', 'mergeCell' => true, 'mergeToCell' => 'P2'],
|
||||
['value' => 'Hubungan Pasien', 'cell' => 'Q1', 'mergeCell' => true, 'mergeToCell' => 'Q2'],
|
||||
['value' => 'Chanel', 'cell' => 'R1', 'mergeCell' => true, 'mergeToCell' => 'R2'],
|
||||
['value' => 'Status', 'cell' => 'S1', 'mergeCell' => true, 'mergeToCell' => 'S2'],
|
||||
['value' => 'Request Time', 'cell' => 'T1', 'mergeCell' => true, 'mergeToCell' => 'T2'],
|
||||
['value' => 'Accept Time', 'cell' => 'U1', 'mergeCell' => true, 'mergeToCell' => 'U2'],
|
||||
['value' => 'Start Time', 'cell' => 'V1', 'mergeCell' => true, 'mergeToCell' => 'V2'],
|
||||
['value' => 'End Time', 'cell' => 'W1', 'mergeCell' => true, 'mergeToCell' => 'W2'],
|
||||
['value' => 'Kode Diagnosa', 'cell' => 'X1', 'mergeCell' => true, 'mergeToCell' => 'X2'],
|
||||
['value' => 'Diagnosa', 'cell' => 'Y1', 'mergeCell' => true, 'mergeToCell' => 'Y2'],
|
||||
['value' => 'Kode Resep', 'cell' => 'Z1', 'mergeCell' => true, 'mergeToCell' => 'Z2'],
|
||||
['value' => 'Tanggal Resep', 'cell' => 'AA1', 'mergeCell' => true, 'mergeToCell' => 'AA2'],
|
||||
['value' => 'Obat', 'cell' => 'AB1', 'mergeCell' => true, 'mergeToCell' => 'AB2'],
|
||||
['value' => 'Tebus Resep', 'cell' => 'AC1', 'mergeCell' => true, 'mergeToCell' => 'AC2'],
|
||||
['value' => 'Tanggal Bayar', 'cell' => 'AD1', 'mergeCell' => true, 'mergeToCell' => 'AD2'],
|
||||
['value' => 'Provider Rujukan', 'cell' => 'AE1', 'mergeCell' => true, 'mergeToCell' => 'AE2'],
|
||||
['value' => 'Poli', 'cell' => 'AF1', 'mergeCell' => true, 'mergeToCell' => 'AF2'],
|
||||
['value' => 'Subjek', 'cell' => 'AG1', 'mergeCell' => true, 'mergeToCell' => 'AG2'],
|
||||
// ['value' => 'nID Principal', 'cell' => 'P1', 'mergeCell' => true, 'mergeToCell' => 'P2'],
|
||||
// ['value' => 'Metode Pembayaran', 'cell' => 'Q1', 'mergeCell' => true, 'mergeToCell' => 'Q2'],
|
||||
];
|
||||
|
||||
$spreadsheet = new Spreadsheet();
|
||||
@@ -162,6 +192,90 @@ class LivechatController extends Controller
|
||||
$statusLivechat = "Cancel by Patient";
|
||||
}
|
||||
|
||||
$requestTime = $liveChat->dRequestTime;
|
||||
$acceptTime = $liveChat->dAcceptTime;
|
||||
$startTime = $liveChat->dStartTime;
|
||||
$endTime = $liveChat->dEndTime;
|
||||
|
||||
$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 = '-';
|
||||
if($liveChat->prescription){
|
||||
if ($liveChat->prescription->items){
|
||||
$obatArray = [];
|
||||
foreach($liveChat->prescription->items as $data){
|
||||
$obatArray[] = $data->sItemName .' - '. $data->nQty;
|
||||
}
|
||||
|
||||
$obat = implode('; ',$obatArray);
|
||||
}
|
||||
};
|
||||
$sheet->setCellValue('A' . $startFrom, $indexLiveChat + 1);
|
||||
$sheet->setCellValue('B' . $startFrom, $liveChat->nID ?? '-');
|
||||
$sheet->setCellValue('C' . $startFrom, Carbon::parse($liveChat->dCreateOn)->format('d-m-Y'));
|
||||
@@ -176,14 +290,36 @@ class LivechatController extends Controller
|
||||
$sheet->setCellValue('K' . $startFrom, $liveChat->user->full_name ?? '-');
|
||||
$sheet->setCellValue('L' . $startFrom, preg_replace('/(\d{3})(\d{4})(\d{3})/', '$1$2$3', $phone));
|
||||
$sheet->setCellValue('M' . $startFrom, $liveChat->user->sEmail ?? '-');
|
||||
$sheet->setCellValue('N' . $startFrom, $statusLivechat);
|
||||
$sheet->setCellValue('O' . $startFrom, $recordType);
|
||||
$sheet->setCellValue('P' . $startFrom, $nIDUser ?? '-');
|
||||
$sheet->setCellValue('Q' . $startFrom, $paymentMethod ?? '-');
|
||||
$sheet->setCellValue('N' . $startFrom, (string)($liveChat->userInsurance->sNoPolis ?? '-'));
|
||||
$sheet->setCellValue('O' . $startFrom, (string)($liveChat->userInsurance->sCorporateCode ?? '-'));
|
||||
$sheet->setCellValue('P' . $startFrom, (string)($liveChat->userInsurance->sCorporateName ?? '-'));
|
||||
$sheet->setCellValue('Q' . $startFrom, (string)($nIDHubunganKeluarga ?? '-'));
|
||||
$sheet->setCellValue('R' . $startFrom, (string)($liveChat->userInsurance->sChannel ?? '-'));
|
||||
$sheet->setCellValue('S' . $startFrom, $statusLivechat);
|
||||
// $sheet->setCellValue('O' . $startFrom, $recordType);
|
||||
// $sheet->setCellValue('P' . $startFrom, $nIDUser ?? '-');
|
||||
// $sheet->setCellValue('Q' . $startFrom, $paymentMethod ?? '-');
|
||||
$sheet->setCellValue('T' . $startFrom, $requestTime);
|
||||
$sheet->setCellValue('U' . $startFrom, $acceptTime);
|
||||
$sheet->setCellValue('V' . $startFrom, $startTime);
|
||||
$sheet->setCellValue('W' . $startFrom, $endTime);
|
||||
|
||||
$sheet->setCellValue('X' . $startFrom, $diagnosaCode ?? '-');
|
||||
$sheet->setCellValue('Y' . $startFrom, $diagnosa ?? '-');
|
||||
|
||||
$sheet->setCellValue('Z' . $startFrom, $liveChat->prescription->sKodeResep ?? '-');
|
||||
$sheet->setCellValue('AA' . $startFrom, $liveChat->prescription->dCreateOn ?? '-');
|
||||
$sheet->setCellValue('AB' . $startFrom, $obat);
|
||||
$sheet->setCellValue('AC' . $startFrom, $tebusResep);
|
||||
|
||||
$sheet->setCellValue('AD' . $startFrom, $paymentTebus);
|
||||
$sheet->setCellValue('AE' . $startFrom, $liveChat->rujukan->nIDHealthcare ?? '-');
|
||||
$sheet->setCellValue('AF' . $startFrom, $liveChat->rujukan->sDepartement ?? '-');
|
||||
$sheet->setCellValue('AG' . $startFrom, $liveChat->summary->sSubjective ?? '-');
|
||||
$startFrom++;
|
||||
}
|
||||
|
||||
foreach (['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J','K', 'L', 'M', 'O', 'P'] as $header) {
|
||||
foreach (['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J','K', 'L', 'M', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'AA', 'AB', 'AC', 'AD', 'AF', 'AG'] as $header) {
|
||||
if ($header === 'A') {
|
||||
$spreadsheet->getActiveSheet()->getColumnDimension($header)->setWidth(35, 'px');
|
||||
} elseif ($header === 'H' || $header === 'I') {
|
||||
|
||||
Reference in New Issue
Block a user