modified: .gitignore
This commit is contained in:
44
app/Services/ReportPageService.php
Normal file
44
app/Services/ReportPageService.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Department;
|
||||
use App\Models\MetrikaItem;
|
||||
use App\Models\User;
|
||||
|
||||
class ReportPageService
|
||||
{
|
||||
public function __construct(
|
||||
protected ReportService $reportService,
|
||||
) {}
|
||||
|
||||
public function build(Department $department, User $user, DateRange $dateRange): array
|
||||
{
|
||||
$statistics = $this->reportService->getReportStatistics($department, $user, $dateRange);
|
||||
$reportInfo = $this->reportService->getCurrentReportInfo($department, $user, $dateRange);
|
||||
$recipientPlanOfYear = $this->reportService->getRecipientPlanOfYear($department, $dateRange);
|
||||
|
||||
return [
|
||||
'department' => [
|
||||
'department_name' => $department->name_full,
|
||||
'department_id' => $department->department_id,
|
||||
'beds' => $department->beds,
|
||||
'percentLoadedBeds' => ($statistics['beds'] ?? 0) > 0
|
||||
? round((($statistics['currentCount'] ?? 0) * 100) / $statistics['beds'])
|
||||
: 0,
|
||||
'recipientPlanOfYear' => $recipientPlanOfYear['plan'],
|
||||
'progressPlanOfYear' => $recipientPlanOfYear['progress'],
|
||||
...$statistics,
|
||||
],
|
||||
'dates' => [
|
||||
'startAt' => $dateRange->startTimestamp(),
|
||||
'endAt' => $dateRange->endTimestamp(),
|
||||
],
|
||||
'report' => $reportInfo,
|
||||
'metrikaItems' => MetrikaItem::whereIn('metrika_item_id', [3, 7, 8, 17])->get(),
|
||||
'patients' => [],
|
||||
'userId' => $reportInfo['userId'],
|
||||
'userName' => $reportInfo['userName'],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user