From 540ffc4f2b0bee19ec5df993e1f334b9a06775c0 Mon Sep 17 00:00:00 2001 From: brusnitsyn Date: Tue, 2 Jun 2026 14:32:52 +0900 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=B2=D0=B5=D0=BB=20?= =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=BF=D0=B0=D1=86=D0=B8=D0=B5=D0=BD=D1=82=D0=BE=D0=B2=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20=D0=BC=D0=B5=D0=B4.=20=D1=81=D0=B5=D1=81=D1=82?= =?UTF-8?q?=D1=80=D1=8B=20=D0=B8=D0=B7=20=D0=9C=D0=98=D0=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/NurseController.php | 32 ++++-- app/Models/MisMKSB.php | 42 ++++++++ .../Components/AddMedicalHistoryModal.vue | 98 ++++++++++++------- 3 files changed, 125 insertions(+), 47 deletions(-) create mode 100644 app/Models/MisMKSB.php diff --git a/app/Http/Controllers/Api/NurseController.php b/app/Http/Controllers/Api/NurseController.php index e45b2f5..ee516fa 100644 --- a/app/Http/Controllers/Api/NurseController.php +++ b/app/Http/Controllers/Api/NurseController.php @@ -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) diff --git a/app/Models/MisMKSB.php b/app/Models/MisMKSB.php new file mode 100644 index 0000000..7eaa36d --- /dev/null +++ b/app/Models/MisMKSB.php @@ -0,0 +1,42 @@ + '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%"); + } +} diff --git a/resources/js/Pages/Nurse/Components/AddMedicalHistoryModal.vue b/resources/js/Pages/Nurse/Components/AddMedicalHistoryModal.vue index a1e9530..8e571ff 100644 --- a/resources/js/Pages/Nurse/Components/AddMedicalHistoryModal.vue +++ b/resources/js/Pages/Nurse/Components/AddMedicalHistoryModal.vue @@ -5,6 +5,7 @@ import AppRadio from "../../../Components/AppRadio.vue"; import {useDebounceFn} from "@vueuse/core"; import {format} from "date-fns"; import {router} from "@inertiajs/vue3"; +import AppPanel from "../../../Components/AppPanel.vue" const show = defineModel('show', { default: false }) const currentStep = ref(1) @@ -69,7 +70,7 @@ const visitResultOptions = [ }, { label: '3 - Переведён в дневной стационар', - value: 2 + value: 3 }, { label: '4 - Переведён на другой профиль коек', @@ -139,9 +140,15 @@ const submit = () => { } const searchOptions = ref([]) +const loadingSelect = ref(false) +const loadingChangeSelect = ref(false) const debounceSearch = useDebounceFn((s) => { - if (s.length === 0 || s.length === 1) return + if (s.length === 0 || s.length === 1) { + searchOptions.value = [] + loadingSelect.value = false + } + loadingSelect.value = true search(s) }, 1000) @@ -150,10 +157,13 @@ const search = (search) => { search }).then(res => { searchOptions.value = res.data + }).finally((e) => { + loadingSelect.value = false }) } const onChangeSearch = (historyId) => { + loadingChangeSelect.value = true axios.get(`/api/nurse/patients/${historyId}`).then(res => { form.value.medical_card_number = res.data.medical_card_number form.value.full_name = res.data.full_name @@ -164,12 +174,20 @@ const onChangeSearch = (historyId) => { form.value.death_date = res.data.death_date form.value.extract_date = res.data.extract_date form.value.recipient_date = res.data.recipient_date + }).finally((e) => { + loadingChangeSelect.value = false }) } watch(() => currentStep.value, (val) => { if (val === 1) resetForm() }) + +const onAfterLeave = () => { + resetForm() + currentStep.value = 1 + searchOptions.value = [] +}