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

* добавлена выборка и подсчет по датам для роли зав.
* переключатель ролей
* выбор отделений для роли зав.
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

@@ -24,6 +24,22 @@ class MisMedicalHistory extends Model
'DateRecipient' => 'datetime'
];
public function observationPatient()
{
return $this->belongsTo(ObservationPatient::class, 'MedicalHistoryID', 'rf_medicalhistory_id');
}
public function surgicalOperations()
{
return $this->hasMany(MisSurgicalOperation::class, 'rf_MedicalHistoryID', 'MedicalHistoryID');
}
public function scopeCurrentlyHospitalized($query)
{
return $query->whereDate('DateExtract', '1900-01-01')
->where('MedicalHistoryID', '<>', 0);
}
/*
* Истории со срочностью - Плановая
*/

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;
}
}

View File

@@ -0,0 +1,16 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class MisServiceMedical extends Model
{
protected $table = 'oms_servicemedical';
protected $primaryKey = 'ServiceMedicalID';
public function surgicalOperations()
{
return $this->hsaMany(MisServiceMedical::class, 'ServiceMedicalID', 'rf_ServiceMedicalID');
}
}

View File

@@ -0,0 +1,16 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class MisSurgicalOperation extends Model
{
protected $table = 'stt_surgicaloperation';
protected $primaryKey = 'SurgicalOperationID';
public function serviceMedical()
{
return $this->belongsTo(MisServiceMedical::class, 'rf_kl_ServiceMedicalID', 'ServiceMedicalID');
}
}

View File

@@ -14,6 +14,7 @@ class ObservationPatient extends Model
'rf_mkab_id',
'rf_department_id',
'rf_report_id',
'comment'
];
public function history()

View File

@@ -0,0 +1,15 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class UnwantedEvent extends Model
{
protected $primaryKey = 'unwanted_event_id';
protected $fillable = [
'rf_report_id',
'comment'
];
}

View File

@@ -28,6 +28,7 @@ class User extends Authenticatable
'password',
'rf_lpudoctor_id',
'rf_department_id',
'current_role_id'
];
/**
@@ -78,7 +79,8 @@ class User extends Authenticatable
public function currentRole()
{
$defaultRoleId = $this->roles()->where('is_default', true)->first()->role_id;
$roleId = session('currentRoleId', $defaultRoleId);
$sessionKey = 'user_' . $this->id . '_current_role';
$roleId = $this->current_role_id ?? $defaultRoleId;
$role = Role::where('role_id', $roleId)->first();
@@ -101,11 +103,6 @@ class User extends Authenticatable
return $this->currentRole()->slug === 'head_of_department';
}
public function isStatistician()
{
return $this->currentRole()->slug === 'statistician';
}
// Получение доступных отделений
public function availableDepartments()
{
@@ -134,11 +131,6 @@ class User extends Authenticatable
$permissions['manage_users'] = $this->isAdmin();
}
if ($this->isStatistician()) {
$permissions['view_statistics'] = true;
$permissions['export_data'] = true;
}
return $permissions;
}
}