modified: .gitignore
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\Api;
|
||||
|
||||
use App\Models\DepartmentPatientOperation;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class DepartmentPatientOperationResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
/** @var DepartmentPatientOperation $operation */
|
||||
$operation = $this->resource;
|
||||
|
||||
$serviceCode = $operation->serviceMedical?->ServiceMedicalCode ?? $operation->service_code;
|
||||
$serviceName = $operation->serviceMedical?->ServiceMedicalName ?? $operation->service_name;
|
||||
|
||||
return [
|
||||
'id' => $operation->department_patient_operation_id,
|
||||
'urgency' => $operation->urgency,
|
||||
'service' => [
|
||||
'id' => $operation->rf_kl_service_medical_id,
|
||||
'code' => $serviceCode,
|
||||
'name' => $serviceName,
|
||||
'label' => trim(($serviceCode ? "{$serviceCode} " : '') . ($serviceName ?? '')),
|
||||
],
|
||||
'startAt' => $operation->started_at?->toIso8601String(),
|
||||
'endAt' => $operation->ended_at?->toIso8601String(),
|
||||
'duration' => $operation->started_at && $operation->ended_at
|
||||
? Carbon::parse($operation->started_at)->diffInMinutes(Carbon::parse($operation->ended_at))
|
||||
: null,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user