Много чего
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Mis\SttMedicalHistory as MisMedicalHistory;
|
||||
use App\Models\SI\SttMedicalHistory as SiMedicalHistory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ArchiveHistory extends Model
|
||||
@@ -54,8 +56,9 @@ class ArchiveHistory extends Model
|
||||
}
|
||||
|
||||
protected $fillable = [
|
||||
'historyable_type',
|
||||
'historyable_id',
|
||||
'keyarhiv',
|
||||
'foxpro_history_id',
|
||||
'mis_history_id',
|
||||
'issue_at',
|
||||
'return_at',
|
||||
'comment',
|
||||
@@ -65,9 +68,19 @@ class ArchiveHistory extends Model
|
||||
'has_lost',
|
||||
];
|
||||
|
||||
public function historyable()
|
||||
public function foxproHistory()
|
||||
{
|
||||
return $this->morphTo();
|
||||
return $this->belongsTo(SiMedicalHistory::class, 'keykarta', 'foxpro_history_id');
|
||||
}
|
||||
|
||||
public function misHistory()
|
||||
{
|
||||
return $this->belongsTo(MisMedicalHistory::class, 'MedicalHistoryID', 'mis_history_id');
|
||||
}
|
||||
|
||||
public function historyType()
|
||||
{
|
||||
return $this->mis_history_id !== null ? 'mis' : 'foxpro';
|
||||
}
|
||||
|
||||
public function org(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Mis\SttMedicalHistory as MisMedicalHistory;
|
||||
use App\Models\SI\SttMedicalHistory as SiMedicalHistory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ArchiveInfo extends Model
|
||||
@@ -16,17 +18,30 @@ class ArchiveInfo extends Model
|
||||
|
||||
protected $connection = 'pgsql';
|
||||
protected $table = 'archive_infos';
|
||||
|
||||
protected $fillable = [
|
||||
'historyable_type',
|
||||
'historyable_id',
|
||||
'num',
|
||||
'foxpro_history_id',
|
||||
'mis_history_id',
|
||||
'foxpro_num',
|
||||
'mis_num',
|
||||
'archive_num',
|
||||
'post_in',
|
||||
'status_id'
|
||||
];
|
||||
|
||||
public function historyable()
|
||||
public function foxproHistory()
|
||||
{
|
||||
return $this->morphTo();
|
||||
return $this->belongsTo(SiMedicalHistory::class, 'foxpro_history_id', 'keykarta');
|
||||
}
|
||||
|
||||
public function misHistory()
|
||||
{
|
||||
return $this->belongsTo(MisMedicalHistory::class, 'mis_history_id', 'MedicalHistoryID');
|
||||
}
|
||||
|
||||
public function historyType()
|
||||
{
|
||||
return $this->mis_history_id !== null ? 'mis' : 'foxpro';
|
||||
}
|
||||
|
||||
public function status()
|
||||
|
||||
@@ -11,6 +11,11 @@ class SttMedicalHistory extends Model
|
||||
{
|
||||
protected $primaryKey = 'MedicalHistoryID';
|
||||
protected $table = 'stt_medicalhistory';
|
||||
protected $keyType = 'string';
|
||||
|
||||
protected $casts = [
|
||||
'MedicalHistoryID' => 'string',
|
||||
];
|
||||
|
||||
public function getFullNameAttribute()
|
||||
{
|
||||
@@ -19,12 +24,12 @@ class SttMedicalHistory extends Model
|
||||
|
||||
public function archiveHistory()
|
||||
{
|
||||
return $this->morphMany(ArchiveHistory::class, 'historyable');
|
||||
return $this->hasMany(ArchiveHistory::class, 'mis_history_id', 'MedicalHistoryID');
|
||||
}
|
||||
|
||||
public function archiveInfo()
|
||||
{
|
||||
return $this->morphOne(ArchiveInfo::class, 'historyable');
|
||||
return $this->hasOne(ArchiveInfo::class, 'mis_history_id', 'MedicalHistoryID');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -41,7 +46,6 @@ class SttMedicalHistory extends Model
|
||||
|
||||
$hasNotBadStatus = $this->archiveInfo()
|
||||
->whereNotNull('status_id')
|
||||
->whereNot('status_id', 1)
|
||||
->whereNot('status_id', 3)
|
||||
->whereNot('status_id', 4)
|
||||
->exists();
|
||||
|
||||
@@ -8,36 +8,43 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SttMedicalHistory extends Model
|
||||
{
|
||||
protected $table = 'si_stt_patients';
|
||||
protected $table = 'foxpro_original_patient';
|
||||
protected $primaryKey = 'keykarta';
|
||||
protected $connection = 'pgsql';
|
||||
protected $keyType = 'string';
|
||||
public $incrementing = false;
|
||||
|
||||
protected $casts = [
|
||||
'keykarta' => 'string',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'family', // Фамилия
|
||||
'name', // Имя
|
||||
'fam', // Фамилия
|
||||
'im', // Имя
|
||||
'ot', // Отчество
|
||||
'daterecipient', // Д. пост. (mpostdate)
|
||||
'dateextract', // Д. вып. (menddate)
|
||||
'mpostdate', // Д. пост. (mpostdate)
|
||||
'menddate', // Д. вып. (menddate)
|
||||
'narhiv', // № в архиве
|
||||
'datearhiv', // Д. архив
|
||||
'statgod', // Год нахождения в стационаре
|
||||
'snils', // Год нахождения в стационаре
|
||||
'enp', // ЕНП
|
||||
'medcardnum', // № карты
|
||||
'nkarta', // № карты
|
||||
'dr', // ДР
|
||||
];
|
||||
|
||||
public function getFullNameAttribute()
|
||||
{
|
||||
return "$this->family $this->name $this->ot";
|
||||
return "$this->fam $this->im $this->ot";
|
||||
}
|
||||
|
||||
public function archiveHistory()
|
||||
{
|
||||
return $this->morphMany(ArchiveHistory::class, 'historyable');
|
||||
return $this->hasMany(ArchiveHistory::class, 'foxpro_history_id', 'keykarta');
|
||||
}
|
||||
|
||||
public function archiveInfo()
|
||||
{
|
||||
return $this->morphOne(ArchiveInfo::class, 'historyable');
|
||||
return $this->hasOne(ArchiveInfo::class, 'foxpro_history_id', 'keykarta');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user