Изменил привязку id при добавлении пациента
Изменил приоритет вывода карты после репликации
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Http\Controllers\Api;
|
namespace App\Http\Controllers\Api;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Department;
|
||||||
use App\Models\MedicalHistory;
|
use App\Models\MedicalHistory;
|
||||||
use App\Models\MedicalHistoryCorrection;
|
use App\Models\MedicalHistoryCorrection;
|
||||||
use App\Models\MedicalHistoryNurse;
|
use App\Models\MedicalHistoryNurse;
|
||||||
@@ -10,6 +11,7 @@ use App\Models\MigrationPatient;
|
|||||||
use App\Models\MigrationPatientCorrection;
|
use App\Models\MigrationPatientCorrection;
|
||||||
use App\Models\MigrationPatientNurse;
|
use App\Models\MigrationPatientNurse;
|
||||||
use App\Models\MisMKSB;
|
use App\Models\MisMKSB;
|
||||||
|
use App\Models\MisMKSBMigration;
|
||||||
use App\Models\MisStationarBranch;
|
use App\Models\MisStationarBranch;
|
||||||
use App\Models\ReportNurse;
|
use App\Models\ReportNurse;
|
||||||
use App\Models\ReportNurseMigrationPatient;
|
use App\Models\ReportNurseMigrationPatient;
|
||||||
@@ -55,8 +57,14 @@ class NurseController extends Controller
|
|||||||
public function storePatient(Request $request)
|
public function storePatient(Request $request)
|
||||||
{
|
{
|
||||||
$user = auth()->user();
|
$user = auth()->user();
|
||||||
$department = auth()->user()->department;
|
$misUserId = $request->query('userId') ? (int) $request->query('userId') : null;
|
||||||
$misUserId = $user->rf_lpudoctor_id;
|
$departmentId = $request->query('departmentId') ? (int) $request->query('departmentId') : null;
|
||||||
|
$sourceType = $request->query('sourceType', 'manual');
|
||||||
|
|
||||||
|
$departmentCacheKey = 'app:department:' . $departmentId;
|
||||||
|
$department = Cache::remember($departmentCacheKey, 21600, function () use ($departmentId) {
|
||||||
|
return Department::find($departmentId);
|
||||||
|
});
|
||||||
|
|
||||||
$data = $request->validate([
|
$data = $request->validate([
|
||||||
'source_type' => 'nullable',
|
'source_type' => 'nullable',
|
||||||
@@ -72,13 +80,39 @@ class NurseController extends Controller
|
|||||||
'visit_result_id' => 'required',
|
'visit_result_id' => 'required',
|
||||||
'mis_user_id' => 'nullable',
|
'mis_user_id' => 'nullable',
|
||||||
'comment' => 'nullable',
|
'comment' => 'nullable',
|
||||||
|
'mis_id' => 'nullable'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$data['mis_user_id'] = $misUserId;
|
||||||
$data['user_id'] = $user->id;
|
$data['user_id'] = $user->id;
|
||||||
|
|
||||||
$branch = MisStationarBranch::where('rf_DepartmentID', $department->rf_mis_department_id)
|
$branchCacheKey = 'app:department:' . $departmentId . ':branch';
|
||||||
|
$branch = Cache::remember($branchCacheKey, 21600, function () use ($department) {
|
||||||
|
return MisStationarBranch::where('rf_DepartmentID', $department->rf_mis_department_id)
|
||||||
->first();
|
->first();
|
||||||
|
});
|
||||||
|
|
||||||
|
if ($sourceType === 'mis') {
|
||||||
|
$migrationMisQuery = MisMKSBMigration::query();
|
||||||
|
$cacheKey = "mis:migration:patient:" . $data['mis_id'] . ':branch:' . $branch->StationarBranchID;
|
||||||
|
$migration = Cache::remember($cacheKey, 300, function () use ($migrationMisQuery, $data, $branch) {
|
||||||
|
return $migrationMisQuery->select(MisMKSBMigration::workColumns())
|
||||||
|
->where('rf_MedicalHistoryID', $data['mis_id'])
|
||||||
|
->where('rf_StationarBranchID', $branch->StationarBranchID)
|
||||||
|
->orderBy('DateIngoing', 'desc')
|
||||||
|
->first()->toArray();
|
||||||
|
});
|
||||||
|
$migrationData = [
|
||||||
|
'ingoing_date' => $data['recipient_date'],
|
||||||
|
'out_date' => $data['extract_date'],
|
||||||
|
'department_id' => $department->rf_mis_department_id,
|
||||||
|
'stationar_branch_id' => $branch->StationarBranchID,
|
||||||
|
'visit_result_id' => $data['visit_result_id'],
|
||||||
|
'user_id' => $data['user_id'],
|
||||||
|
'mis_user_id' => $misUserId,
|
||||||
|
'mis_id' => $migration['id']
|
||||||
|
];
|
||||||
|
} else {
|
||||||
$migrationData = [
|
$migrationData = [
|
||||||
'ingoing_date' => $data['recipient_date'],
|
'ingoing_date' => $data['recipient_date'],
|
||||||
'out_date' => $data['extract_date'],
|
'out_date' => $data['extract_date'],
|
||||||
@@ -88,6 +122,7 @@ class NurseController extends Controller
|
|||||||
'user_id' => $data['user_id'],
|
'user_id' => $data['user_id'],
|
||||||
'mis_user_id' => $misUserId
|
'mis_user_id' => $misUserId
|
||||||
];
|
];
|
||||||
|
}
|
||||||
|
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class NurseReportController extends Controller
|
|||||||
{
|
{
|
||||||
$user = Auth::user();
|
$user = Auth::user();
|
||||||
$selectedUserId = $request->query('userId') ? (int) $request->query('userId') : null;
|
$selectedUserId = $request->query('userId') ? (int) $request->query('userId') : null;
|
||||||
$departmentId = $request->query('departmentId', $user->department->department_id);
|
$departmentId = $request->query('departmentId') ? (int) $request->query('departmentId') : null;
|
||||||
$department = Department::where('department_id', $departmentId)->firstOrFail();
|
$department = Department::where('department_id', $departmentId)->firstOrFail();
|
||||||
$dateRange = $this->dateRangeService->getDateRangeFromRequest($request, $user);
|
$dateRange = $this->dateRangeService->getDateRangeFromRequest($request, $user);
|
||||||
|
|
||||||
@@ -45,26 +45,6 @@ class NurseReportController extends Controller
|
|||||||
|
|
||||||
$hasReport = $existsReport && $isPastPeriod;
|
$hasReport = $existsReport && $isPastPeriod;
|
||||||
|
|
||||||
// if ($hasReport) {
|
|
||||||
// $inDepartmentHistories = $this->nurseMedicalHistoryService->getDepartmentHistories($dateRange, $department->rf_mis_department_id);
|
|
||||||
// $recipientHistories = $this->nurseMedicalHistoryService->getRecipientHistories($dateRange, $department->rf_mis_department_id);
|
|
||||||
// $dischargedHistories = $this->nurseMedicalHistoryService->getDischargedHistories($dateRange, $department->rf_mis_department_id);
|
|
||||||
// $deceasedHistories = $this->nurseMedicalHistoryService->getDeceasedHistories($dateRange, $department->rf_mis_department_id);
|
|
||||||
// $transferredHistories = $this->nurseMedicalHistoryService->getTransferredHistories($dateRange, $department->rf_mis_department_id);
|
|
||||||
// } else if ($this->dateRangeService->isPastPeriod($dateRange)) {
|
|
||||||
// $inDepartmentHistories = collect([]);
|
|
||||||
// $recipientHistories = collect([]);
|
|
||||||
// $dischargedHistories = collect([]);
|
|
||||||
// $deceasedHistories = collect([]);
|
|
||||||
// $transferredHistories = collect([]);
|
|
||||||
// } else {
|
|
||||||
// $inDepartmentHistories = $this->unifiedMedicalHistoryService->getDepartmentHistories($dateRange, $department->rf_mis_department_id);
|
|
||||||
// $recipientHistories = $this->unifiedMedicalHistoryService->getRecipientHistories($dateRange, $department->rf_mis_department_id);
|
|
||||||
// $dischargedHistories = $this->unifiedMedicalHistoryService->getDischargedHistories($dateRange, $department->rf_mis_department_id);
|
|
||||||
// $deceasedHistories = $this->unifiedMedicalHistoryService->getDeceasedHistories($dateRange, $department->rf_mis_department_id);
|
|
||||||
// $transferredHistories = $this->unifiedMedicalHistoryService->getTransferredHistories($dateRange, $department->rf_mis_department_id);
|
|
||||||
// }
|
|
||||||
|
|
||||||
$data = $this->unifiedMedicalHistoryService->getGroupedHistories($dateRange, $department->rf_mis_department_id);
|
$data = $this->unifiedMedicalHistoryService->getGroupedHistories($dateRange, $department->rf_mis_department_id);
|
||||||
|
|
||||||
$currentReport = ReportNurse::where('rf_department_id', $departmentId)
|
$currentReport = ReportNurse::where('rf_department_id', $departmentId)
|
||||||
@@ -82,7 +62,7 @@ class NurseReportController extends Controller
|
|||||||
'canEditPastReport' => $user->currentRoleCan('nurse.report.edit.past'),
|
'canEditPastReport' => $user->currentRoleCan('nurse.report.edit.past'),
|
||||||
'department' => $department,
|
'department' => $department,
|
||||||
'selectedUserId' => $selectedUserId,
|
'selectedUserId' => $selectedUserId,
|
||||||
'selectedDepartmentId' => (int) $departmentId,
|
'selectedDepartmentId' => $departmentId,
|
||||||
'dates' => [
|
'dates' => [
|
||||||
$dateRange->startDate->getTimestampMs(),
|
$dateRange->startDate->getTimestampMs(),
|
||||||
$dateRange->endDate->getTimestampMs(),
|
$dateRange->endDate->getTimestampMs(),
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ class MedicalHistoryNurse extends Model
|
|||||||
'user_id',
|
'user_id',
|
||||||
'mis_user_id',
|
'mis_user_id',
|
||||||
'comment',
|
'comment',
|
||||||
'latest_migration_id'
|
'latest_migration_id',
|
||||||
|
'mis_id'
|
||||||
];
|
];
|
||||||
|
|
||||||
public function user()
|
public function user()
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ class MigrationPatientNurse extends Model
|
|||||||
'user_id',
|
'user_id',
|
||||||
'mis_user_id',
|
'mis_user_id',
|
||||||
'comment',
|
'comment',
|
||||||
|
'mis_id'
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
|
|||||||
36
app/Models/MisMKSBMigration.php
Normal file
36
app/Models/MisMKSBMigration.php
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Стационарная карта больного
|
||||||
|
*/
|
||||||
|
class MisMKSBMigration extends MaterializedViewModel
|
||||||
|
{
|
||||||
|
protected $connection = 'mis';
|
||||||
|
protected $table = 'stt_MigrationPatient';
|
||||||
|
protected $primaryKey = 'MigrationPatientID';
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'id' => 'int',
|
||||||
|
'ingoing_date' => 'datetime:Y-m-d H:i:s',
|
||||||
|
'out_date' => 'datetime:Y-m-d H:i:s',
|
||||||
|
'diagnosis_id' => 'int',
|
||||||
|
'interrupted_event_id' => 'int',
|
||||||
|
'stationar_branch_id' => 'int',
|
||||||
|
'visit_result_id' => 'int',
|
||||||
|
'hospital_result_id' => 'int',
|
||||||
|
];
|
||||||
|
|
||||||
|
public static function workColumns() {
|
||||||
|
return [
|
||||||
|
'MigrationPatientID as id', 'rf_MedicalHistoryID as medical_history_id', 'DateIngoing as ingoing_date',
|
||||||
|
'DateOut as out_date', 'rf_DiagnosID as diagnosis_id', 'rf_InterruptEventID as interrupted_event_id',
|
||||||
|
'rf_StationarBranchID as stationar_branch_id', 'rf_kl_VisitResultID as visit_result_id',
|
||||||
|
'rf_kl_StatCureResultID as hospital_result_id'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('medical_history_nurses', function (Blueprint $table) {
|
||||||
|
$table->bigInteger('mis_id')->unsigned()->index()->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('medical_history_nurses', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('mis_id');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('migration_patient_nurses', function (Blueprint $table) {
|
||||||
|
$table->bigInteger('mis_id')->unsigned()->index()->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('migration_patient_nurses', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('mis_id');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -4,7 +4,7 @@ import {computed, ref, watch} from "vue";
|
|||||||
import AppRadio from "../../../Components/AppRadio.vue";
|
import AppRadio from "../../../Components/AppRadio.vue";
|
||||||
import {useDebounceFn} from "@vueuse/core";
|
import {useDebounceFn} from "@vueuse/core";
|
||||||
import {format} from "date-fns";
|
import {format} from "date-fns";
|
||||||
import {router} from "@inertiajs/vue3";
|
import {router, usePage} from "@inertiajs/vue3";
|
||||||
import AppPanel from "../../../Components/AppPanel.vue"
|
import AppPanel from "../../../Components/AppPanel.vue"
|
||||||
const show = defineModel('show', { default: false })
|
const show = defineModel('show', { default: false })
|
||||||
|
|
||||||
@@ -23,7 +23,8 @@ const form = ref({
|
|||||||
birth_date: null,
|
birth_date: null,
|
||||||
recipient_date: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
recipient_date: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
||||||
death_date: null,
|
death_date: null,
|
||||||
extract_date: null
|
extract_date: null,
|
||||||
|
mis_id: null
|
||||||
})
|
})
|
||||||
|
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
@@ -37,7 +38,8 @@ const resetForm = () => {
|
|||||||
birth_date: null,
|
birth_date: null,
|
||||||
recipient_date: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
recipient_date: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
||||||
death_date: null,
|
death_date: null,
|
||||||
extract_date: null
|
extract_date: null,
|
||||||
|
mis_id: null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,7 +118,9 @@ const next = () => {
|
|||||||
|
|
||||||
const submit = () => {
|
const submit = () => {
|
||||||
buttonLoading.value = true
|
buttonLoading.value = true
|
||||||
axios.post('/api/nurse/patients', {
|
const departmentId = usePage().props.selectedDepartmentId
|
||||||
|
const userId = usePage().props.selectedUserId
|
||||||
|
axios.post(`/api/nurse/patients?departmentId=${departmentId}&userId=${userId}`, {
|
||||||
...form.value
|
...form.value
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
router.reload({
|
router.reload({
|
||||||
@@ -216,7 +220,7 @@ const onAfterLeave = () => {
|
|||||||
<AppPanel :loading="loadingChangeSelect" class="border-none!" no-padding>
|
<AppPanel :loading="loadingChangeSelect" class="border-none!" no-padding>
|
||||||
<NGrid cols="2" x-gap="8">
|
<NGrid cols="2" x-gap="8">
|
||||||
<NFormItemGi v-if="form.patient_source === 'mis'" span="2" label="Поиск пациента">
|
<NFormItemGi v-if="form.patient_source === 'mis'" span="2" label="Поиск пациента">
|
||||||
<NSelect v-model:value="form.id"
|
<NSelect v-model:value="form.mis_id"
|
||||||
filterable
|
filterable
|
||||||
placeholder="Найти пациента по ФИО"
|
placeholder="Найти пациента по ФИО"
|
||||||
remote
|
remote
|
||||||
|
|||||||
Reference in New Issue
Block a user