49 lines
1.5 KiB
PHP
Executable File
49 lines
1.5 KiB
PHP
Executable File
<?php
|
|
|
|
namespace Modules\Client\Transformers\AlarmCenter;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
use App\Models\Service;
|
|
use App\Models\Organization;
|
|
|
|
class DataListClaimMemberResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request
|
|
* @return array
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
$serviceData = Service::where('code', $this->service_code)->first();
|
|
$organization = Organization::where('id', $this->organization_id)->first();
|
|
$organizationName = '-';
|
|
if ($organization){
|
|
$organizationName = $organization->name;
|
|
}
|
|
if ($serviceData) {
|
|
$serviceName = $serviceData->name;
|
|
} else {
|
|
$serviceName = $this->service_code;
|
|
}
|
|
|
|
if ($this->status == 'approved' && $this->status_final_log ){
|
|
$status = 'Done';
|
|
} else if ($this->status == 'declined' || $this->status_final_log == 'declined') {
|
|
$status = 'Declined';
|
|
} else {
|
|
$status = 'Ongoing';
|
|
}
|
|
return [
|
|
'id' => $this->id,
|
|
'admission_date' => $this->submission_date ?? null,
|
|
'discharge_date' => $this->discharge_date ?? null,
|
|
'code' => $this->code ?? null,
|
|
'provider_name' => $organizationName ?? null,
|
|
'service_type' => $serviceName,
|
|
'status' => $status,
|
|
];
|
|
}
|
|
}
|