Files
onboard/app/Http/Resources/Mis/FormattedPatientResource.php
brusnitsyn eab78a0291 * переписал функции прототипов в сервисы
* оптимизация доставки контента до клиента
* переписал запросы выборок
* убрал из подсчета переведенных
* добавил сохранение метрикам для вывода в дашборд
2026-02-04 17:05:13 +09:00

37 lines
1.2 KiB
PHP

<?php
namespace App\Http\Resources\Mis;
use App\Models\MisSurgicalOperation;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Support\Carbon;
use Illuminate\Support\Str;
class FormattedPatientResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->MedicalHistoryID,
'num' => $this->num,
'mkb.ds' => $this->migrations->first()->diagnosis->first()?->mkb?->DS,
'operations' => $this->surgicalOperations->map(function ($operation) {
return [
'code' => $operation->serviceMedical->ServiceMedicalCode
];
}),
'fullname' => Str::ucwords(Str::lower("$this->FAMILY $this->Name $this->OT")),
'age' => Carbon::parse($this->BD)->diff(Carbon::now())->format('%y'),
'birth_date' => Carbon::parse($this->BD)->format('d.m.Y'),
'outcome_type' => $this->when($this->outcome_type, $this->outcome_type),
'comment' => $this->when($this->comment, $this->comment)
];
}
}