modified: .gitignore
This commit is contained in:
@@ -87,13 +87,15 @@ class MisMedicalHistory extends Model
|
||||
|
||||
public function surgicalOperations()
|
||||
{
|
||||
return $this->hasMany(MisSurgicalOperation::class, 'rf_MedicalHistoryID', 'MedicalHistoryID');
|
||||
return $this->hasMany(MisSurgicalOperation::class, 'rf_MedicalHistoryID', 'MedicalHistoryID')
|
||||
->completed();
|
||||
}
|
||||
|
||||
public function surgicalOperationsInBranch($branchId)
|
||||
{
|
||||
$operations = MisSurgicalOperation::where('rf_MedicalHistoryID', $this->MedicalHistoryID)
|
||||
->where('rf_StationarBranchID', $branchId)
|
||||
->completed()
|
||||
->get();
|
||||
|
||||
return $operations;
|
||||
@@ -109,7 +111,10 @@ class MisMedicalHistory extends Model
|
||||
|
||||
public function scopeCurrentlyHospitalized($query)
|
||||
{
|
||||
return $query->whereDate('DateExtract', '1900-01-01')
|
||||
return $query->where(function ($builder) {
|
||||
$builder->whereDate('DateExtract', '1900-01-01')
|
||||
->orWhereDate('DateExtract', '2222-01-01');
|
||||
})
|
||||
->where('MedicalHistoryID', '<>', 0);
|
||||
}
|
||||
|
||||
@@ -126,7 +131,7 @@ class MisMedicalHistory extends Model
|
||||
*/
|
||||
public function scopeEmergency($query)
|
||||
{
|
||||
return $query->where('rf_EmerSignID', 2);
|
||||
return $query->whereIn('rf_EmerSignID', [2, 4]);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -152,6 +157,12 @@ class MisMedicalHistory extends Model
|
||||
->orderBy('DateOut', 'desc');
|
||||
}
|
||||
|
||||
public function latestMigration()
|
||||
{
|
||||
return $this->hasOne(MisMigrationPatient::class, 'rf_MedicalHistoryID', 'MedicalHistoryID')
|
||||
->ofMany('DateOut', 'max');
|
||||
}
|
||||
|
||||
/*
|
||||
* Движение по StationarBranch
|
||||
*/
|
||||
@@ -181,4 +192,9 @@ class MisMedicalHistory extends Model
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function operationPurpose()
|
||||
{
|
||||
return $this->belongsTo(MisOperationPurpose::class, 'MedicalHistoryID', 'rf_MedicalHistoryID');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user