* добавил исход спец контингенту
* оптимизация обновления при редактировании спец контингента * добавил поддержку заключительных диагнозов * изменил определение законченной операции * добавил поддержку исхода операции * добавил определение отмены для операции через назначение * работа над диапазонами календарей, подсчет статистики * добавил статусы отчетов и подкорректировал привязку спец контингента к отчету * добавил новые сервисы для будущего кеширования * частичное разделение логики подсчета пациентов
This commit is contained in:
@@ -10,6 +10,7 @@ class DepartmentPatient extends Model
|
||||
|
||||
protected $fillable = [
|
||||
'rf_department_id',
|
||||
'rf_report_id',
|
||||
'source_type',
|
||||
'rf_medicalhistory_id',
|
||||
'full_name',
|
||||
@@ -52,4 +53,9 @@ class DepartmentPatient extends Model
|
||||
{
|
||||
return $this->hasMany(DepartmentPatientOperation::class, 'rf_department_patient_id', 'department_patient_id');
|
||||
}
|
||||
|
||||
public function report()
|
||||
{
|
||||
return $this->belongsTo(Report::class, 'rf_report_id', 'report_id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,15 +152,15 @@ class MisMedicalHistory extends Model
|
||||
|
||||
public function outcomeMigration()
|
||||
{
|
||||
return $this->migrations()
|
||||
->whereDate('DateOut', '<>', '2222-01-01')
|
||||
->orderBy('DateOut', 'desc');
|
||||
return $this->hasOne(MisMigrationPatient::class, 'rf_MedicalHistoryID', 'MedicalHistoryID')
|
||||
->whereDate('DateOut', '=', '2222-01-01');
|
||||
}
|
||||
|
||||
public function latestMigration()
|
||||
{
|
||||
return $this->hasOne(MisMigrationPatient::class, 'rf_MedicalHistoryID', 'MedicalHistoryID')
|
||||
->ofMany('DateOut', 'max');
|
||||
->whereDate('DateOut', '=', '2222-01-01')
|
||||
->orderBy('DateOut', 'desc');
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -28,7 +28,11 @@ class MisMigrationPatient extends Model
|
||||
|
||||
public function mainDiagnosis()
|
||||
{
|
||||
return $this->hasOne(MisDiagnos::class, 'rf_MigrationPatientID', 'MigrationPatientID')->where('rf_DiagnosTypeID', 3);
|
||||
return $this->hasOne(MisDiagnos::class, 'rf_MigrationPatientID', 'MigrationPatientID')
|
||||
->where(function ($query) {
|
||||
$query->where('rf_DiagnosTypeID', 3)
|
||||
->orWhere('rf_DiagnosTypeID', 7);
|
||||
});
|
||||
}
|
||||
|
||||
public function mkb()
|
||||
|
||||
@@ -3,10 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use LaravelIdea\Helper\App\Models\_IH_MisSurgicalOperation_QB;
|
||||
|
||||
class MisSurgicalOperation extends Model
|
||||
{
|
||||
private const COMPLETED_OPERATION_STATUS_ID = 3;
|
||||
private const CANCELLED_OPERATION_STATUS_ID = 4;
|
||||
|
||||
protected $table = 'stt_surgicaloperation';
|
||||
protected $primaryKey = 'SurgicalOperationID';
|
||||
@@ -26,10 +28,47 @@ class MisSurgicalOperation extends Model
|
||||
return $this->hasOne(MisOperationPurpose::class, 'rf_SurgicalOperationID', 'SurgicalOperationID');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Получить операции у которых исход <> 0
|
||||
* @param $query
|
||||
* @return _IH_MisSurgicalOperation_QB|_IH_MisSurgicalOperation_QB
|
||||
*/
|
||||
public function scopeCompleted($query)
|
||||
{
|
||||
return $query->whereNot('rf_OperationResultID', 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить операции с благоприятным исходом
|
||||
* @param $query
|
||||
* @return _IH_MisSurgicalOperation_QB|_IH_MisSurgicalOperation_QB
|
||||
*/
|
||||
public function scopePositiveResult($query)
|
||||
{
|
||||
return $query->where('rf_OperationResultID', 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить операции с неблагоприятным исходом
|
||||
* @param $query
|
||||
* @return _IH_MisSurgicalOperation_QB|_IH_MisSurgicalOperation_QB
|
||||
*/
|
||||
public function scopeNotPositiveResult($query)
|
||||
{
|
||||
return $query->where('rf_OperationResultID', 2);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Получить отмененные операции через назначение
|
||||
* @param $query
|
||||
* @return _IH_MisSurgicalOperation_QB
|
||||
*/
|
||||
public function scopeCanceled($query)
|
||||
{
|
||||
return $query->whereHas('operationPurpose', function ($purposeQuery) {
|
||||
$purposeQuery->where('rf_OperationStatusID', self::COMPLETED_OPERATION_STATUS_ID);
|
||||
$purposeQuery->where('rf_OperationStatusID', self::CANCELLED_OPERATION_STATUS_ID);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
@@ -29,6 +30,32 @@ class Report extends Model
|
||||
'status',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'created_at' => 'datetime',
|
||||
'sent_at' => 'datetime',
|
||||
'period_start' => 'datetime',
|
||||
'period_end' => 'datetime',
|
||||
];
|
||||
|
||||
public function scopeWithinPeriod(Builder $query, string $startAt, string $endAt): Builder
|
||||
{
|
||||
return $query
|
||||
->where('period_start', '>=', $startAt)
|
||||
->where('period_start', '<=', $endAt);
|
||||
}
|
||||
|
||||
public function scopeExactPeriod(Builder $query, string $startAt, string $endAt): Builder
|
||||
{
|
||||
return $query
|
||||
->where('period_start', '>=', $startAt)
|
||||
->where('period_end', '<=', $endAt);
|
||||
}
|
||||
|
||||
public function scopeOnlySubmitted(Builder $query): Builder
|
||||
{
|
||||
return $query->where('status', 'submitted');
|
||||
}
|
||||
|
||||
public function metrikaResults(): \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
{
|
||||
return $this->hasMany(MetrikaResult::class, 'rf_report_id', 'report_id');
|
||||
|
||||
Reference in New Issue
Block a user