Перевел добавление пациентов для мед. сестры из МИС

This commit is contained in:
brusnitsyn
2026-06-02 14:32:52 +09:00
parent 99fd47e5ad
commit 540ffc4f2b
3 changed files with 125 additions and 47 deletions

View File

@@ -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')
$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 - $item->full_name",
'value' => $item->id
'label' => "$item->medical_card_number - $fullName",
'value' => $item->original_id
];
});
});
return $results;
}
public function storePatient(Request $request)

42
app/Models/MisMKSB.php Normal file
View 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%");
}
}

View File

@@ -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 = []
}
</script>
<template>
@@ -181,6 +199,7 @@ watch(() => currentStep.value, (val) => {
draggable
:close-on-esc="!buttonLoading"
:closable="!buttonLoading"
@afterLeave="onAfterLeave"
>
<NSteps size="small" :current="currentStep" :status="currentStatus">
<NStep title="Тип пациента" description="Укажите тип пациента" />
@@ -194,12 +213,14 @@ watch(() => currentStep.value, (val) => {
</NRadioGroup>
</NTabPane>
<NTabPane :name="2">
<AppPanel :loading="loadingChangeSelect" class="border-none!" no-padding>
<NGrid cols="2" x-gap="8">
<NFormItemGi v-if="form.patient_source === 'mis'" span="2" label="Поиск пациента">
<NSelect v-model:value="form.id"
filterable
placeholder="Найти пациента по ФИО"
remote
:loading="loadingSelect"
:options="searchOptions"
@search="debounceSearch"
@change="onChangeSearch"
@@ -231,6 +252,7 @@ watch(() => currentStep.value, (val) => {
<NDatePicker v-model:formatted-value="form.death_date" type="datetime" class="w-full" format="dd.MM.yyyy HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss" clearable />
</NFormItemGi>
</NGrid>
</AppPanel>
</NTabPane>
</NTabs>
<template #action>