Files
aso/Modules/Internal/Transformers/ReportRujukanResource.php
Server D3 Linksehat 013c57d00a update
2024-10-14 10:35:21 +07:00

47 lines
1.6 KiB
PHP

<?php
namespace Modules\Internal\Transformers;
use Illuminate\Http\Resources\Json\JsonResource;
use Carbon\Carbon;
class ReportRujukanResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
$doctor_name = null;
if ($this->livechat->doctor && $this->livechat->doctor->user && $this->livechat->doctor->user->detail) {
$doctor_name = $this->livechat->doctor->user->detail->sTitlePrefix . ' ' . $this->livechat->doctor->user->fullname;
}
$diagnosis = null;
$plan = null;
if ($this->livechat->summary){
$diagnosis = $this->livechat->summary->sAssessment;
$plan = $this->livechat->summary->sPlan ? unserialize($this->livechat->summary->sPlan) : $this->livechat->summary->sPlan;
}
// dd($this->livechat->summary);
$data = [
'id' => $this->nID,
'no_rujukan' => $this->sNoRujukan ? $this->sNoRujukan : null,
'patient_name' => $this->livechat ? $this->livechat->user->sFirstName : null,
'healthcare' => $this->healthcare ? $this->healthcare->sHealthCare : null,
'doctor_name' => $doctor_name,
'departement' => $this->sDepartement ? $this->sDepartement : null,
'date_rujukan' => $this->dCreatedOn ? Carbon::parse($this->dCreateOn)->format('Y-m-d H:i:s') : null ,
'diagnosa' => $diagnosis,
'plan' => $plan,
];
return $data;
}
}