Работа над журналом для ст. мед сестер

This commit is contained in:
brusnitsyn
2026-05-04 17:11:16 +09:00
parent f107ebd167
commit 7a58812072
61 changed files with 3532 additions and 1163 deletions

View File

@@ -10,6 +10,7 @@ use App\Domain\Reports\Models\StayInterval;
use App\Domain\Reports\ValueObjects\MetrikaConfig;
use App\Models\MedicalHistorySnapshot;
use App\Models\Report;
use DateTimeInterface;
use DateTimeImmutable;
use Illuminate\Support\Facades\DB;
@@ -82,12 +83,12 @@ class ReportMetricsFinalizer
$endRaw = null;
if ($snapshot->patient_type === 'deceased') {
if ($history->DateDeath && ! in_array($history->DateDeath->format('Y-m-d'), ['1900-01-01', '2222-01-01'], true)) {
if ($this->isRealDate($history->DateDeath)) {
$endRaw = $history->DateDeath;
} elseif ($history->DateExtract && ! in_array($history->DateExtract->format('Y-m-d'), ['1900-01-01', '2222-01-01'], true)) {
} elseif ($this->isRealDate($history->DateExtract)) {
$endRaw = $history->DateExtract;
}
} elseif ($history->DateExtract && ! in_array($history->DateExtract->format('Y-m-d'), ['1900-01-01', '2222-01-01'], true)) {
} elseif ($this->isRealDate($history->DateExtract)) {
$endRaw = $history->DateExtract;
}
@@ -104,6 +105,19 @@ class ReportMetricsFinalizer
return $intervals;
}
private function isRealDate(mixed $value): bool
{
if (! $value) {
return false;
}
$date = $value instanceof DateTimeInterface
? $value->format('Y-m-d')
: (new DateTimeImmutable((string) $value))->format('Y-m-d');
return ! in_array($date, ['1900-01-01', '2222-01-01'], true);
}
/**
* @return array<int, OperationInterval>
*/