Перевел добавление пациентов для мед. сестры из МИС
This commit is contained in:
@@ -9,33 +9,47 @@ use App\Models\MedicalHistoryNurse;
|
||||
use App\Models\MigrationPatient;
|
||||
use App\Models\MigrationPatientCorrection;
|
||||
use App\Models\MigrationPatientNurse;
|
||||
use App\Models\MisMKSB;
|
||||
use App\Models\MisStationarBranch;
|
||||
use App\Models\ReportNurse;
|
||||
use App\Models\ReportNurseMigrationPatient;
|
||||
use App\Models\ReportNursePatient;
|
||||
use App\Models\UnifiedMedicalHistory;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class NurseController extends Controller
|
||||
{
|
||||
public function getPatient($id, Request $request)
|
||||
{
|
||||
return UnifiedMedicalHistory::where('id', $id)->first();
|
||||
return Cache::remember("nurse_patient:{$id}", 120, function () use ($id, $request) {
|
||||
return MisMKSB::where('MedicalHistoryID', $id)->select(MisMKSB::workColumns())->first();
|
||||
});
|
||||
}
|
||||
|
||||
public function searchPatients(Request $request)
|
||||
{
|
||||
$search = $request->search;
|
||||
|
||||
return MedicalHistory::whereLike('full_name', $search . '%')
|
||||
->orderBy('recipient_date', 'desc')
|
||||
->get()->map(function ($item) {
|
||||
return [
|
||||
'label' => "$item->medical_card_number - $item->full_name",
|
||||
'value' => $item->id
|
||||
];
|
||||
});
|
||||
$results = Cache::remember('patients_search_' . $search, 120, function () use ($search) {
|
||||
return MisMKSB::select([
|
||||
'MedicalHistoryID as original_id', 'MedCardNum as medical_card_number', DB::raw('(FAMILY + \' \' + Name + \' \' + OT) as full_name'),
|
||||
])
|
||||
->findByFIO($search)
|
||||
->limit(10)
|
||||
->orderBy('DateExtract', 'desc')
|
||||
->get()->map(function ($item) {
|
||||
$fullName = Str::title($item->full_name);
|
||||
return [
|
||||
'label' => "$item->medical_card_number - $fullName",
|
||||
'value' => $item->original_id
|
||||
];
|
||||
});
|
||||
});
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
public function storePatient(Request $request)
|
||||
|
||||
42
app/Models/MisMKSB.php
Normal file
42
app/Models/MisMKSB.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?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%");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user