118 lines
3.9 KiB
PHP
118 lines
3.9 KiB
PHP
<?php
|
|
|
|
namespace App\Application\Reports\DTO;
|
|
|
|
use App\Domain\Reports\Models\ReportContext;
|
|
use App\Domain\Reports\Models\ReportSnapshot;
|
|
use DateTimeImmutable;
|
|
|
|
final readonly class GenerateReportInput
|
|
{
|
|
/**
|
|
* @param array<int|string, int|float|string|null> $metrics
|
|
* @param array<int, array<string, mixed>> $observationPatients
|
|
* @param array<int, array<string, mixed>> $unwantedEvents
|
|
* @param array<string, mixed>|null $rawPayload
|
|
*/
|
|
public function __construct(
|
|
public int $departmentId,
|
|
public int $userId,
|
|
public ?int $actorUserId,
|
|
public DateTimeImmutable $periodStart,
|
|
public DateTimeImmutable $periodEnd,
|
|
public array $metrics = [],
|
|
public array $observationPatients = [],
|
|
public array $unwantedEvents = [],
|
|
public ?int $reportId = null,
|
|
public string $status = 'draft',
|
|
public string $reportType = 'daily',
|
|
public bool $autoFill = false,
|
|
public ?array $rawPayload = null,
|
|
public ?int $persistedReportId = null,
|
|
public ?DateTimeImmutable $createdAt = null,
|
|
public ?DateTimeImmutable $sentAt = null,
|
|
) {}
|
|
|
|
public function toContext(): ReportContext
|
|
{
|
|
return new ReportContext(
|
|
departmentId: $this->departmentId,
|
|
userId: $this->userId,
|
|
actorUserId: $this->actorUserId,
|
|
periodStart: $this->periodStart,
|
|
periodEnd: $this->periodEnd,
|
|
reportType: $this->reportType,
|
|
metadata: [
|
|
'auto_fill' => $this->autoFill,
|
|
],
|
|
);
|
|
}
|
|
|
|
public function toSnapshot(): ReportSnapshot
|
|
{
|
|
return new ReportSnapshot(
|
|
departmentId: $this->departmentId,
|
|
userId: $this->userId,
|
|
actorUserId: $this->actorUserId,
|
|
periodStart: $this->periodStart,
|
|
periodEnd: $this->periodEnd,
|
|
status: $this->status,
|
|
autoFill: $this->autoFill,
|
|
metrics: $this->metrics,
|
|
observationPatients: $this->observationPatients,
|
|
unwantedEvents: $this->unwantedEvents,
|
|
reportId: $this->reportId,
|
|
createdAt: $this->createdAt,
|
|
sentAt: $this->sentAt,
|
|
reportType: $this->reportType,
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @param array<string, mixed> $payload
|
|
*/
|
|
public function withRawPayload(array $payload): self
|
|
{
|
|
return new self(
|
|
departmentId: $this->departmentId,
|
|
userId: $this->userId,
|
|
actorUserId: $this->actorUserId,
|
|
periodStart: $this->periodStart,
|
|
periodEnd: $this->periodEnd,
|
|
metrics: $this->metrics,
|
|
observationPatients: $this->observationPatients,
|
|
unwantedEvents: $this->unwantedEvents,
|
|
reportId: $this->reportId,
|
|
status: $this->status,
|
|
reportType: $this->reportType,
|
|
autoFill: $this->autoFill,
|
|
rawPayload: $payload,
|
|
persistedReportId: $this->persistedReportId,
|
|
createdAt: $this->createdAt,
|
|
sentAt: $this->sentAt,
|
|
);
|
|
}
|
|
|
|
public function withPersistedReportId(int $reportId): self
|
|
{
|
|
return new self(
|
|
departmentId: $this->departmentId,
|
|
userId: $this->userId,
|
|
actorUserId: $this->actorUserId,
|
|
periodStart: $this->periodStart,
|
|
periodEnd: $this->periodEnd,
|
|
metrics: $this->metrics,
|
|
observationPatients: $this->observationPatients,
|
|
unwantedEvents: $this->unwantedEvents,
|
|
reportId: $this->reportId,
|
|
status: $this->status,
|
|
reportType: $this->reportType,
|
|
autoFill: $this->autoFill,
|
|
rawPayload: $this->rawPayload,
|
|
persistedReportId: $reportId,
|
|
createdAt: $this->createdAt,
|
|
sentAt: $this->sentAt,
|
|
);
|
|
}
|
|
}
|