53 lines
2.7 KiB
PHP
53 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace Modules\Client\Transformers\AlarmCenter;
|
|
|
|
use App\Helpers\Helper;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class DataServiceMonitoring extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request
|
|
* @return array
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
return [
|
|
'companyName' => $this->member->currentCorporate->name ?? null,
|
|
'memberId' => $this->member->member_id ?? null,
|
|
'fullName' => $this->member->full_name ?? null,
|
|
'dateOfBirth' => $this->member->birth_date ?? null,
|
|
'dateOfBirth' => $this->member->birth_date ?? null,
|
|
'phoneNumber' => $this->person->phone ?? null,
|
|
'email' => $this->member->email ?? ($this->member->person->email ?? null),
|
|
'serviceName' => $this->service_code === 'IP' ? 'Inpatient' : ($this->service_code === 'OP' ? 'Outpatient' : null),
|
|
'benefitName' => $this->requestLogBenefit->benefit->description ?? null,
|
|
'hospital' => $this->organization->name ?? null,
|
|
'admissionDate' => $this->submission_date ?? null,
|
|
'dischargeDate' => $this->discharge_date ?? null,
|
|
'dailyMonitorings' => $this->when($this->service_code === 'IP', collect($this->requesLogDailyMonitorings)->map(function ($requesLogDailyMonitoring) {
|
|
return [
|
|
'date' => Helper::formatDateOnly($requesLogDailyMonitoring->created_at) ?? null,
|
|
'time' => Helper::formatTimeOnly($requesLogDailyMonitoring->created_at) ?? null,
|
|
'status' => 'Done' ?? null,
|
|
'subject' => $requesLogDailyMonitoring->subject ?? null,
|
|
'bodyTemperature' => $requesLogDailyMonitoring->body_temperature ?? null,
|
|
'sistole' => $requesLogDailyMonitoring->sistole . 'mm[Hg]' ?? null,
|
|
'diastole' => $requesLogDailyMonitoring->diastole . 'mm[Hg]' ?? null,
|
|
'respirationRate' => $requesLogDailyMonitoring->respiration_rate . '/min' ?? null,
|
|
'analysis' => $requesLogDailyMonitoring->analysis ?? null,
|
|
'plan' => collect($requesLogDailyMonitoring->requestLogMedicalPlans)->map(function ($requestLogMedicalPlan) {
|
|
return $requestLogMedicalPlan->type == 1 ? $requestLogMedicalPlan->plan : null;
|
|
})->all(),
|
|
];
|
|
})->all()),
|
|
// 'laboratoriumResults' => collect($this->dailyMonitorings)->map(function ($dailyMonitoring) {
|
|
// $data['date'][Helper::formatDateOnly($dailyMonitoring->created_at)]
|
|
// })->all() ?? null
|
|
];
|
|
}
|
|
}
|