Несколько отделений для врачей

Поправил подсчет операций
Закончил функцию наполнения отчетов
This commit is contained in:
brusnitsyn
2026-02-06 15:15:03 +09:00
parent 10fb138c30
commit 741781dcb3
9 changed files with 117 additions and 50 deletions

View File

@@ -5,6 +5,7 @@ namespace App\Services;
use App\Models\LifeMisMigrationPatient;
use App\Models\MisMedicalHistory;
use App\Models\MisMigrationPatient;
use App\Models\MisSurgicalOperation;
use App\Models\ObservationPatient;
use Carbon\Carbon;
@@ -219,16 +220,14 @@ class PatientService
DateRange $dateRange,
bool $countOnly = false
) {
$query = MisMedicalHistory::whereHas('surgicalOperations', function ($q) use ($type, $branchId, $dateRange) {
$q->where('rf_StationarBranchID', $branchId)
$query = MisSurgicalOperation::where('rf_StationarBranchID', $branchId)
->whereBetween('Date', [$dateRange->startSql(), $dateRange->endSql()]);
if ($type === 'plan') {
$q->where('rf_TypeSurgOperationInTimeID', 6);
} else {
$q->whereIn('rf_TypeSurgOperationInTimeID', [4, 5]);
}
});
if ($type === 'plan') {
$query->where('rf_TypeSurgOperationInTimeID', 6);
} else {
$query->whereIn('rf_TypeSurgOperationInTimeID', [4, 5]);
}
if ($countOnly) {
return $query->count();