Files
onboard/app/Models/MisMKSB.php

43 lines
1.4 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
/**
* Стационарная карта больного
*/
class MisMKSB extends MaterializedViewModel
{
protected $connection = 'mis';
protected $table = 'stt_MedicalHistory';
protected $primaryKey = 'MedicalHistoryID';
protected $casts = [
'original_id' => 'int',
'birth_date' => 'date:Y-m-d',
'recipient_date' => 'datetime:Y-m-d H:i:s',
'extract_date' => 'datetime:Y-m-d H:i:s',
'death_date' => 'datetime:Y-m-d H:i:s',
'male' => 'boolean',
'urgency_id' => 'int',
'hospital_result_id' => 'int',
'visit_result_id' => 'int',
];
public static function workColumns() {
return [
'MedicalHistoryID as original_id', 'MedCardNum as medical_card_number',
DB::raw('(FAMILY + \' \' + Name + \' \' + OT) as full_name'), 'BD as birth_date',
'DateRecipient as recipient_date', 'DateExtract as extract_date', 'DateDeath as death_date', 'Sex as male',
'rf_EmerSignID as urgency_id', 'rf_kl_StatCureResultID as hospital_result_id', 'rf_kl_VisitResultID as visit_result_id'
];
}
public function scopeFindByFIO($query, $search)
{
$query->where(DB::raw('(FAMILY + \' \' + Name + \' \' + OT)'), 'like', "$search%");
}
}