diff --git a/Modules/Internal/Http/Controllers/Api/Linksehat/PrescriptionController.php b/Modules/Internal/Http/Controllers/Api/Linksehat/PrescriptionController.php old mode 100644 new mode 100755 index 9b96b3e7..9af48110 --- a/Modules/Internal/Http/Controllers/Api/Linksehat/PrescriptionController.php +++ b/Modules/Internal/Http/Controllers/Api/Linksehat/PrescriptionController.php @@ -32,8 +32,11 @@ class PrescriptionController extends Controller 'tx_prescriptions.*', 'tx_prescription_orders.sStatus as status_prescription', 'tx_prescription_orders.sAddress as kirim_ke', + 'tx_prescription_orders.sDeliveryPrice as ongkir', 'tx_prescription_orders.sDeliveryMethod as delivery', - ); + 'tx_prescription_orders.nIDApotek', + ) + ->whereNotNull('nIDUser'); if ($request->has('search')) { $search = $request->search; $prescription->where(function ($query) use ($search) { @@ -164,6 +167,8 @@ class PrescriptionController extends Controller 'Patient', 'Doctor', 'Status', + 'Nama Apotek', + 'Harga Ongkir', 'Jenis Obat (Drugs)', 'Jumlah Obat (QTY)', 'Cara Minum Obat', @@ -176,7 +181,17 @@ class PrescriptionController extends Controller // Query prescription data $prescriptionQuery = Prescription::query() - ->with(['livechat', 'user', 'items']); + ->with(['livechat', 'user', 'items']) + ->join('tx_prescription_orders', 'tx_prescriptions.nID', '=', 'tx_prescription_orders.nIDPrescription') + ->select( + 'tx_prescriptions.*', + 'tx_prescription_orders.sStatus as status_prescription', + 'tx_prescription_orders.sAddress as kirim_ke', + 'tx_prescription_orders.sDeliveryPrice as ongkir', + 'tx_prescription_orders.sDeliveryMethod as delivery', + 'tx_prescription_orders.nIDApotek', + ) + ->whereNotNull('nIDUser'); if ($request->has('search')) { $search = $request->search; @@ -196,13 +211,18 @@ class PrescriptionController extends Controller if ($prescriptions->isNotEmpty()) { $no = 1; foreach ($prescriptions as $index => $row) { + $patientName = $row->user ? $row->user->sFirstName .' '. $row->user->sLastName : '-'; if ($row->items->isNotEmpty()) { $rowData = [ $no++, $row->sKodeResep ?? '-', $row->dTanggalResep ? Carbon::parse($row->dTanggalResep)->format('Y-m-d') : '-', - $row->user->name ?? '-', + $row->user->fullName ?? '-', $row->sDokterName ?? '-', + $row->status_prescription ?? '-', + $row->nIDApotek ? Helper::getOrganization($row->nIDApotek) : '-', + $row->ongkir ?? '-', + $row->sDeliveryPrice ?? '-', ]; // Create a row from the array and add it to the writer @@ -215,6 +235,9 @@ class PrescriptionController extends Controller '', '', '', + '', + '', + '', $item->sItemName ?? '-', $item->nQty ?? '-', $item->sSigna ?? '-' diff --git a/Modules/Internal/Transformers/ReportPrescriptionResource.php b/Modules/Internal/Transformers/ReportPrescriptionResource.php old mode 100644 new mode 100755 index e72099ef..e57ef80c --- a/Modules/Internal/Transformers/ReportPrescriptionResource.php +++ b/Modules/Internal/Transformers/ReportPrescriptionResource.php @@ -1,7 +1,8 @@ $this->dTanggalResep ? Carbon::parse($this->dTanggalResep)->format('Y-m-d H:i:s') : null, 'doctor_name' => $this->sDokterName ? $this->sDokterName : '-', 'items' => $this->items ? $this->items : [], - 'status_prescription' => $this->status_prescription + 'status_prescription' => $this->status_prescription, + 'price_delivery' => $this->ongkir, + 'apotek_name' => $this->nIDApotek ? Helper::getOrganization($this->nIDApotek) : '-', ]; return $data; diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.php index 01a10913..8530c8be 100755 --- a/app/Helpers/Helper.php +++ b/app/Helpers/Helper.php @@ -14,6 +14,7 @@ use App\Models\User; use App\Models\CorporatePolicy; use App\Models\Service; use App\Models\Icd; +use App\Models\Organization; use DateTime; class Helper @@ -669,5 +670,9 @@ class Helper return []; } + public static function getOrganization($organizationId){ + $organization = Organization::where('id', $organizationId)->first(); + return $organization->name; + } }