Новые таблицы миса

This commit is contained in:
brusnitsyn
2026-01-16 17:30:41 +09:00
parent a649eaf7c5
commit 62d7e9efd4
11 changed files with 217 additions and 39 deletions

View File

@@ -7,6 +7,7 @@ use App\Http\Resources\Mis\FormattedPatientResource;
use App\Models\MetrikaGroup; use App\Models\MetrikaGroup;
use App\Models\MetrikaResult; use App\Models\MetrikaResult;
use App\Models\MisMedicalHistory; use App\Models\MisMedicalHistory;
use App\Models\MisStationarBranch;
use App\Models\ObservationPatient; use App\Models\ObservationPatient;
use App\Models\Report; use App\Models\Report;
use Illuminate\Http\Request; use Illuminate\Http\Request;
@@ -102,30 +103,51 @@ class ReportController extends Controller
$status = $data['status']; $status = $data['status'];
$startDate = Carbon::now()->addDays(-1)->format('Y-m-d');
$endDate = Carbon::now()->format('Y-m-d');
$model = new MisMedicalHistory(); $model = new MisMedicalHistory();
$misDepartmentId = $request->user()->department->rf_mis_department_id;
$misStationarBranchId = MisStationarBranch::where('rf_DepartmentID', $misDepartmentId)->first()->StationarBranchID;
if ($status === 'plan') { if ($status === 'plan') {
$patients = MisMedicalHistory::select( $patients = MisMedicalHistory::select(
[ [
...$model->getFillable(), ...$model->getFillable(),
DB::raw('ROW_NUMBER() OVER (ORDER BY "DateRecipient" DESC) as num') DB::raw('ROW_NUMBER() OVER (ORDER BY "DateRecipient" DESC) as num')
]) ])
->where('rf_EmerSignID', 1) ->plan()
->whereDate('DateRecipient', '>=', Carbon::now()->format('Y-m-d')) ->inDepartment($misDepartmentId, $startDate, $endDate)
->orderBy('DateRecipient', 'DESC') ->orderBy('DateRecipient', 'DESC')
->get(); ->get()
->map(function ($item, $index) {
$item->num = $index + 1;
return $item;
});;
} else if ($status === 'emergency') { } else if ($status === 'emergency') {
$patients = MisMedicalHistory::select( $patients = MisMedicalHistory::select(
[ [
...$model->getFillable(), ...$model->getFillable(),
DB::raw('ROW_NUMBER() OVER (ORDER BY "DateRecipient" DESC) as num') DB::raw('ROW_NUMBER() OVER (ORDER BY "DateRecipient" DESC) as num')
]) ])
->where('rf_EmerSignID', 2) ->emergency()
->whereDate('DateRecipient', '>=', Carbon::now()->format('Y-m-d')) ->inDepartment($misDepartmentId, $startDate, $endDate)
->orderBy('DateRecipient', 'DESC') ->orderBy('DateRecipient', 'DESC')
->limit(20) ->get()
->get(); ->map(function ($item, $index) {
$item->num = $index + 1;
return $item;
});;
} else if ($status === 'deceased') {
} }
$patients->load(['migrations' => function ($query) use ($startDate, $endDate, $misStationarBranchId) {
$query->whereHas('diagnosis', function ($query) {
$query->where('rf_DiagnosTypeID', 3);
})->with('diagnosis.mkb')
->where('rf_StationarBranchID', $misStationarBranchId);
}]);
return response()->json(FormattedPatientResource::collection($patients)); return response()->json(FormattedPatientResource::collection($patients));
} }
@@ -137,17 +159,21 @@ class ReportController extends Controller
$status = $data['status']; $status = $data['status'];
$startDate = Carbon::now()->addDays(-1)->format('Y-m-d');
$endDate = Carbon::now()->format('Y-m-d');
$model = new MisMedicalHistory(); $model = new MisMedicalHistory();
$misDepartmentId = $request->user()->department->rf_mis_department_id;
if ($status === 'plan') { if ($status === 'plan') {
$count = MisMedicalHistory::select($model->getFillable()) $count = MisMedicalHistory::select($model->getFillable())
->where('rf_EmerSignID', 1) ->plan()
->whereDate('DateRecipient', '>=', Carbon::now()->format('Y-m-d')) ->inDepartment($misDepartmentId, $startDate, $endDate)
->orderBy('DateRecipient', 'DESC') ->orderBy('DateRecipient', 'DESC')
->count(); ->count();
} else if ($status === 'emergency') { } else if ($status === 'emergency') {
$count = MisMedicalHistory::select($model->getFillable()) $count = MisMedicalHistory::select($model->getFillable())
->where('rf_EmerSignID', 2) ->emergency()
->whereDate('DateRecipient', '>=', Carbon::now()->format('Y-m-d')) ->inDepartment($misDepartmentId, $startDate, $endDate)
->orderBy('DateRecipient', 'DESC') ->orderBy('DateRecipient', 'DESC')
->count(); ->count();
} }

View File

@@ -19,6 +19,12 @@ class FormattedPatientResource extends JsonResource
return [ return [
'id' => $this->MedicalHistoryID, 'id' => $this->MedicalHistoryID,
'num' => $this->num, 'num' => $this->num,
'mkb' => $this->whenLoaded('migrations', function () {
return [
'ds' => $this->migrations()->first()->diagnosis()->first()->mkb()->first()->DS ?? null,
'name' => $this->migrations()->first()->diagnosis()->first()->mkb()->first()->NAME ?? null,
];
}),
'fullname' => Str::ucwords(Str::lower("$this->FAMILY $this->Name $this->OT")), 'fullname' => Str::ucwords(Str::lower("$this->FAMILY $this->Name $this->OT")),
'age' => Carbon::parse($this->BD)->diff(Carbon::now())->format('%y'), 'age' => Carbon::parse($this->BD)->diff(Carbon::now())->format('%y'),
'birth_date' => Carbon::parse($this->BD)->format('d.m.Y'), 'birth_date' => Carbon::parse($this->BD)->format('d.m.Y'),

22
app/Models/MisDiagnos.php Normal file
View File

@@ -0,0 +1,22 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class MisDiagnos extends Model
{
protected $table = 'stt_diagnos';
protected $primaryKey = 'DiagnosID';
protected $fillable = [
'rf_MedicalHistoryID',
'rf_MigrationPatient',
'rf_MKBID',
];
public function mkb()
{
return $this->hasOne(MisMKB::class, 'MKBID', 'rf_MKBID');
}
}

16
app/Models/MisMKB.php Normal file
View File

@@ -0,0 +1,16 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class MisMKB extends Model
{
protected $table = 'oms_mkb';
protected $primaryKey = 'MKBID';
protected $fillable = [
'DS',
'NAME'
];
}

View File

@@ -3,6 +3,7 @@
namespace App\Models; namespace App\Models;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
class MisMedicalHistory extends Model class MisMedicalHistory extends Model
{ {
@@ -18,4 +19,60 @@ class MisMedicalHistory extends Model
'BD', 'BD',
'Address' 'Address'
]; ];
protected $casts = [
'DateRecipient' => 'datetime'
];
/*
* Истории со срочностью - Плановая
*/
public function scopePlan()
{
return $this->where('rf_EmerSignID', 1);
}
/*
* Истории со срочностью - Экстренная
*/
public function scopeEmergency()
{
return $this->where('rf_EmerSignID', 2);
}
/*
* Движения истории
*/
public function migrations()
{
return $this->hasMany(MisMigrationPatient::class, 'rf_MedicalHistoryID', 'MedicalHistoryID');
}
/*
* Движение по StationarBranch
*/
public function scopeInStationarBranch($query, $stationarBranchID)
{
return $this->whereHas('migrations', function ($query) use ($stationarBranchID) {
$query->where('rf_StationarBranchID', $stationarBranchID);
});
}
/*
* Истории в отделении ($departmentId)
*/
public function scopeInDepartment($query, $departmentId, $startDate, $endDate)
{
return $query->whereExists(function ($q) use ($departmentId, $startDate, $endDate) {
$q->select(DB::raw(1))
->from('stt_migrationpatient as mp')
->join('stt_stationarbranch as sb', 'sb.StationarBranchID', '=', 'mp.rf_StationarBranchID')
->whereColumn('mp.rf_MedicalHistoryID', 'stt_medicalhistory.MedicalHistoryID')
->where('sb.rf_DepartmentID', $departmentId);
if ($startDate && $endDate) {
$q->whereBetween('mp.DateIngoing', [$startDate, $endDate]);
}
});
}
} }

View File

@@ -0,0 +1,26 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class MisMigrationPatient extends Model
{
protected $table = 'stt_migrationpatient';
protected $primaryKey = 'MigrationPatientID';
public function branch()
{
return $this->hasOne(MisStationarBranch::class, 'StationarBranchID', 'rf_StationarBranchID');
}
public function diagnosis()
{
return $this->hasMany(MisDiagnos::class, 'rf_MigrationPatientID', 'MigrationPatientID');
}
public function mkb()
{
return $this->hasOne(MisMKB::class, 'MKBID', 'rf_MKBID');
}
}

View File

@@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class MisStationarBranch extends Model
{
protected $table = 'stt_stationarbranch';
protected $primaryKey = 'StationarBranchID';
}

View File

@@ -33,57 +33,68 @@ class TestDepartmentDataSeeder extends Seeder
Department::create([ Department::create([
'name_full' => 'Гинекологическое отделение', 'name_full' => 'Гинекологическое отделение',
'name_short' => 'Гинекологическое', 'name_short' => 'Гинекологическое',
'rf_department_type' => 1 'rf_department_type' => 1,
'rf_mis_department_id' => 1054
]); ]);
Department::create([ Department::create([
'name_full' => 'Нейрохирургическое отделение', 'name_full' => 'Нейрохирургическое отделение',
'name_short' => 'Нейрохирургическое', 'name_short' => 'Нейрохирургическое',
'rf_department_type' => 1 'rf_department_type' => 1,
'rf_mis_department_id' => 1049
]); ]);
Department::create([ Department::create([
'name_full' => 'Отделение термических поражений', 'name_full' => 'Отделение термических поражений',
'name_short' => 'Термических поражений', 'name_short' => 'Термических поражений',
'rf_department_type' => 1 'rf_department_type' => 1,
'rf_mis_department_id' => 1059
]); ]);
Department::create([ Department::create([
'name_full' => 'Отоларингологическое отделение', 'name_full' => 'Отоларингологическое отделение',
'name_short' => 'Отоларингологическое', 'name_short' => 'Отоларингологическое',
'rf_department_type' => 1 'rf_department_type' => 1,
'rf_mis_department_id' => 1061
]); ]);
Department::create([ Department::create([
'name_full' => 'Проктологическое отделение', 'name_full' => 'Проктологическое отделение',
'name_short' => 'Проктологическое', 'name_short' => 'Проктологическое',
'rf_department_type' => 1 'rf_department_type' => 1,
'rf_mis_department_id' => 1065
]); ]);
Department::create([ Department::create([
'name_full' => 'Отделение сосудистой хирургии', 'name_full' => 'Отделение сосудистой хирургии',
'name_short' => 'Сосудистой хирургии', 'name_short' => 'Сосудистой хирургии',
'rf_department_type' => 1 'rf_department_type' => 1,
'rf_mis_department_id' => 1050
]); ]);
Department::create([ Department::create([
'name_full' => 'Отделение торакальной хирургии', 'name_full' => 'Отделение торакальной хирургии',
'name_short' => 'Торакальной хирургии', 'name_short' => 'Торакальной хирургии',
'rf_department_type' => 1 'rf_department_type' => 1,
'rf_mis_department_id' => 1069
]); ]);
Department::create([ Department::create([
'name_full' => 'Травматологическое отделение', 'name_full' => 'Травматологическое отделение',
'name_short' => 'Травматологическое', 'name_short' => 'Травматологическое',
'rf_department_type' => 1 'rf_department_type' => 1,
'rf_mis_department_id' => 1070
]); ]);
Department::create([ Department::create([
'name_full' => 'Урологическое отделение', 'name_full' => 'Урологическое отделение',
'name_short' => 'Урологическое', 'name_short' => 'Урологическое',
'rf_department_type' => 1 'rf_department_type' => 1,
'rf_mis_department_id' => 1071
]); ]);
Department::create([ Department::create([
'name_full' => 'Хирургическое отделение', 'name_full' => 'Хирургическое отделение',
'name_short' => 'Хирургическое', 'name_short' => 'Хирургическое',
'rf_department_type' => 1 'rf_department_type' => 1,
'rf_mis_department_id' => 1072
]); ]);
Department::create([ Department::create([
'name_full' => 'Отделение ЧЛХ', 'name_full' => 'Отделение ЧЛХ',
'name_short' => 'ЧЛХ', 'name_short' => 'ЧЛХ',
'rf_department_type' => 1 'rf_department_type' => 1,
'rf_mis_department_id' => 1073
]); ]);
DepartmentMetrikaDefault::create([ DepartmentMetrikaDefault::create([

5
package-lock.json generated
View File

@@ -2017,7 +2017,6 @@
"integrity": "sha512-9nF4PdUle+5ta4W5SyZdLCCmFd37uVimSjg1evcTqKJCyvCEEj12WKzOSBNak6r4im4J4iYXKH1OWpUV5LBYFg==", "integrity": "sha512-9nF4PdUle+5ta4W5SyZdLCCmFd37uVimSjg1evcTqKJCyvCEEj12WKzOSBNak6r4im4J4iYXKH1OWpUV5LBYFg==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"@emotion/hash": "~0.8.0", "@emotion/hash": "~0.8.0",
"csstype": "~3.0.5" "csstype": "~3.0.5"
@@ -2093,7 +2092,6 @@
"resolved": "https://registry.npmjs.org/d3-selection/-/d3-selection-3.0.0.tgz", "resolved": "https://registry.npmjs.org/d3-selection/-/d3-selection-3.0.0.tgz",
"integrity": "sha512-fmTRWbNMmsmWq6xJV8D19U/gw/bwrHfNXxrIN+HfZgnzqTHp9jOmKMhsTUjXOJnZOdZY9Q28y4yebKzqDKlxlQ==", "integrity": "sha512-fmTRWbNMmsmWq6xJV8D19U/gw/bwrHfNXxrIN+HfZgnzqTHp9jOmKMhsTUjXOJnZOdZY9Q28y4yebKzqDKlxlQ==",
"license": "ISC", "license": "ISC",
"peer": true,
"engines": { "engines": {
"node": ">=12" "node": ">=12"
} }
@@ -2147,7 +2145,6 @@
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-4.1.0.tgz", "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-4.1.0.tgz",
"integrity": "sha512-Ukq0owbQXxa/U3EGtsdVBkR1w7KOQ5gIBqdH2hkvknzZPYvBxb/aa6E8L7tmjFtkwZBu3UXBbjIgPo/Ez4xaNg==", "integrity": "sha512-Ukq0owbQXxa/U3EGtsdVBkR1w7KOQ5gIBqdH2hkvknzZPYvBxb/aa6E8L7tmjFtkwZBu3UXBbjIgPo/Ez4xaNg==",
"license": "MIT", "license": "MIT",
"peer": true,
"funding": { "funding": {
"type": "github", "type": "github",
"url": "https://github.com/sponsors/kossnocorp" "url": "https://github.com/sponsors/kossnocorp"
@@ -3570,7 +3567,6 @@
"resolved": "https://registry.npmjs.org/vite/-/vite-7.3.0.tgz", "resolved": "https://registry.npmjs.org/vite/-/vite-7.3.0.tgz",
"integrity": "sha512-dZwN5L1VlUBewiP6H9s2+B3e3Jg96D0vzN+Ry73sOefebhYr9f94wwkMNN/9ouoU8pV1BqA1d1zGk8928cx0rg==", "integrity": "sha512-dZwN5L1VlUBewiP6H9s2+B3e3Jg96D0vzN+Ry73sOefebhYr9f94wwkMNN/9ouoU8pV1BqA1d1zGk8928cx0rg==",
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"esbuild": "^0.27.0", "esbuild": "^0.27.0",
"fdir": "^6.5.0", "fdir": "^6.5.0",
@@ -3928,7 +3924,6 @@
"resolved": "https://registry.npmjs.org/vue/-/vue-3.5.26.tgz", "resolved": "https://registry.npmjs.org/vue/-/vue-3.5.26.tgz",
"integrity": "sha512-SJ/NTccVyAoNUJmkM9KUqPcYlY+u8OVL1X5EW9RIs3ch5H2uERxyyIUI4MRxVCSOiEcupX9xNGde1tL9ZKpimA==", "integrity": "sha512-SJ/NTccVyAoNUJmkM9KUqPcYlY+u8OVL1X5EW9RIs3ch5H2uERxyyIUI4MRxVCSOiEcupX9xNGde1tL9ZKpimA==",
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"@vue/compiler-dom": "3.5.26", "@vue/compiler-dom": "3.5.26",
"@vue/compiler-sfc": "3.5.26", "@vue/compiler-sfc": "3.5.26",

View File

@@ -1,9 +1,10 @@
<script setup> <script setup>
import {NDataTable} from "naive-ui"; import {NIcon, NDataTable} from "naive-ui";
import {useReportStore} from "../../../Stores/report.js"; import {useReportStore} from "../../../Stores/report.js";
import {computed, h, onMounted, ref, watch} from "vue"; import {computed, h, onMounted, ref, watch} from "vue";
import { VueDraggableNext } from 'vue-draggable-next' import { VueDraggableNext } from 'vue-draggable-next'
import {storeToRefs} from "pinia"; import {storeToRefs} from "pinia";
import {TbGripVertical} from "vue-icons-plus/tb";
const props = defineProps({ const props = defineProps({
mode: { mode: {
@@ -12,7 +13,7 @@ const props = defineProps({
}, },
keys: { keys: {
type: Array, type: Array,
default: ['num', 'fullname', 'age', 'birth_date', 'ds'] default: ['num', 'fullname', 'age', 'birth_date', 'mkb.ds']
}, },
status: { status: {
type: String, type: String,
@@ -40,14 +41,22 @@ const columns = computed(() => {
title: '', title: '',
key: 'drag', key: 'drag',
width: 40, width: 40,
render: (row) => h('div', { render: (row) => h(
style: { 'div',
cursor: 'grab', {
color: '#666', style: {
textAlign: 'center', cursor: 'grab',
userSelect: 'none' textAlign: 'center',
} userSelect: 'none'
}, '⋮⋮') }
},
[
h(NIcon, {
depth: '2',
component: TbGripVertical
}, [])
]
)
} }
return [dragColumn, ...baseColumns] return [dragColumn, ...baseColumns]
@@ -143,7 +152,6 @@ onMounted(async () => {
@drop="handleDrop" @drop="handleDrop"
@dragover="handleDragOver" @dragover="handleDragOver"
:loading="isLoading" :loading="isLoading"
virtual-scroll
max-height="200" max-height="200"
min-height="200" min-height="200"
:row-props="rowProps" :row-props="rowProps"

View File

@@ -46,7 +46,7 @@ export const useReportStore = defineStore('reportStore', () => {
}, },
{ {
title: 'Диагноз', title: 'Диагноз',
key: 'ds' key: 'mkb.ds'
} }
] ]