* добавлены операции и услуги операций
* добавлена выборка и подсчет по датам для роли зав. * переключатель ролей * выбор отделений для роли зав.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
* Истории со срочностью - Плановая
|
||||
*/
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
16
app/Models/MisServiceMedical.php
Normal file
16
app/Models/MisServiceMedical.php
Normal 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');
|
||||
}
|
||||
}
|
||||
16
app/Models/MisSurgicalOperation.php
Normal file
16
app/Models/MisSurgicalOperation.php
Normal 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');
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ class ObservationPatient extends Model
|
||||
'rf_mkab_id',
|
||||
'rf_department_id',
|
||||
'rf_report_id',
|
||||
'comment'
|
||||
];
|
||||
|
||||
public function history()
|
||||
|
||||
15
app/Models/UnwantedEvent.php
Normal file
15
app/Models/UnwantedEvent.php
Normal 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'
|
||||
];
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user