Работа над журналом для ст. мед сестер
This commit is contained in:
49
app/Models/MedicalHistory.php
Normal file
49
app/Models/MedicalHistory.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property string|null $medical_card_number
|
||||
* @property string|null $full_name
|
||||
* @property \Carbon\Carbon|null $birth_date
|
||||
* @property \Carbon\Carbon|null $recipient_date
|
||||
* @property \Carbon\Carbon|null $extract_date
|
||||
* @property \Carbon\Carbon|null $death_date
|
||||
* @property int|null $male
|
||||
* @property int|null $hospital_result_id
|
||||
* @property int|null $visit_result_id
|
||||
* @property int|null $latest_migration_id
|
||||
*/
|
||||
class MedicalHistory extends MaterializedViewModel
|
||||
{
|
||||
protected $table = 'mv_medicalhistory_summary';
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
public function migrations(): \Illuminate\Database\Eloquent\Relations\HasMany|MedicalHistory
|
||||
{
|
||||
return $this->hasMany(MigrationPatient::class, 'medical_history_id', 'id');
|
||||
}
|
||||
|
||||
public function operations(): \Illuminate\Database\Eloquent\Relations\HasMany|MedicalHistory
|
||||
{
|
||||
return $this->hasMany(SurgicalOperation::class, 'medical_history_id', 'id');
|
||||
}
|
||||
|
||||
public function latestMigration()
|
||||
{
|
||||
return $this->hasOne(MigrationPatient::class, 'medical_history_id', 'id')
|
||||
->latest('ingoing_date');
|
||||
}
|
||||
|
||||
public function operationsInDepartment($query, $departmentId)
|
||||
{
|
||||
return $this->operations()->where('department_id', $departmentId);
|
||||
}
|
||||
|
||||
// Скоупы
|
||||
public function scopeUrgency($query, $typeId) // 1 = Экстренно, 2 = Планово
|
||||
{
|
||||
return $query->where('urgency_id', $typeId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user