Работа над журналом для ст. мед сестер
This commit is contained in:
@@ -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>
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user