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, ]; } }