* добавлены операции и услуги операций

* добавлена выборка и подсчет по датам для роли зав.
* переключатель ролей
* выбор отделений для роли зав.
This commit is contained in:
brusnitsyn
2026-01-22 17:58:27 +09:00
parent 8a0fdf9470
commit cb43c74a72
28 changed files with 961 additions and 143 deletions

View File

@@ -3,6 +3,7 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Carbon;
class MisMigrationPatient extends Model
{
@@ -23,4 +24,45 @@ class MisMigrationPatient extends Model
{
return $this->hasOne(MisMKB::class, 'MKBID', 'rf_MKBID');
}
public function scopeCurrentlyInTreatment($query, $branchId = null)
{
$query->where('rf_kl_VisitResultID', 0)
->where('rf_MedicalHistoryID', '<>', 0);
if ($branchId) {
$query->where('rf_StationarBranchID', $branchId);
}
return $query;
}
public function scopeWhereInDepartment($query, $branchId = null)
{
$query->where('rf_MedicalHistoryID', '<>', 0);
if ($branchId) {
$query->where('rf_StationarBranchID', $branchId);
}
return $query;
}
public function scopeExtractedToday($query, $branchId = null, $startDate = null, $endDate = null)
{
if (is_null($startDate)) $startDate = Carbon::now()->addDays(-1)->format('Y-m-d');
if (is_null($endDate)) $endDate = Carbon::now()->format('Y-m-d');
$query->where('rf_kl_VisitResultID', '<>', 0)
->where('rf_MedicalHistoryID', '<>', 0)
->when($startDate && $endDate, function($query) use ($startDate, $endDate) {
return $query->whereBetween('DateOut', [$startDate, $endDate]);
});
if ($branchId) {
$query->where('rf_StationarBranchID', $branchId);
}
return $query;
}
}