Новые таблицы миса
This commit is contained in:
@@ -7,6 +7,7 @@ use App\Http\Resources\Mis\FormattedPatientResource;
|
||||
use App\Models\MetrikaGroup;
|
||||
use App\Models\MetrikaResult;
|
||||
use App\Models\MisMedicalHistory;
|
||||
use App\Models\MisStationarBranch;
|
||||
use App\Models\ObservationPatient;
|
||||
use App\Models\Report;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -102,30 +103,51 @@ class ReportController extends Controller
|
||||
|
||||
$status = $data['status'];
|
||||
|
||||
$startDate = Carbon::now()->addDays(-1)->format('Y-m-d');
|
||||
$endDate = Carbon::now()->format('Y-m-d');
|
||||
|
||||
$model = new MisMedicalHistory();
|
||||
$misDepartmentId = $request->user()->department->rf_mis_department_id;
|
||||
$misStationarBranchId = MisStationarBranch::where('rf_DepartmentID', $misDepartmentId)->first()->StationarBranchID;
|
||||
if ($status === 'plan') {
|
||||
$patients = MisMedicalHistory::select(
|
||||
[
|
||||
...$model->getFillable(),
|
||||
DB::raw('ROW_NUMBER() OVER (ORDER BY "DateRecipient" DESC) as num')
|
||||
])
|
||||
->where('rf_EmerSignID', 1)
|
||||
->whereDate('DateRecipient', '>=', Carbon::now()->format('Y-m-d'))
|
||||
->plan()
|
||||
->inDepartment($misDepartmentId, $startDate, $endDate)
|
||||
->orderBy('DateRecipient', 'DESC')
|
||||
->get();
|
||||
->get()
|
||||
->map(function ($item, $index) {
|
||||
$item->num = $index + 1;
|
||||
return $item;
|
||||
});;
|
||||
} else if ($status === 'emergency') {
|
||||
$patients = MisMedicalHistory::select(
|
||||
[
|
||||
...$model->getFillable(),
|
||||
DB::raw('ROW_NUMBER() OVER (ORDER BY "DateRecipient" DESC) as num')
|
||||
])
|
||||
->where('rf_EmerSignID', 2)
|
||||
->whereDate('DateRecipient', '>=', Carbon::now()->format('Y-m-d'))
|
||||
->emergency()
|
||||
->inDepartment($misDepartmentId, $startDate, $endDate)
|
||||
->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));
|
||||
}
|
||||
|
||||
@@ -137,17 +159,21 @@ class ReportController extends Controller
|
||||
|
||||
$status = $data['status'];
|
||||
|
||||
$startDate = Carbon::now()->addDays(-1)->format('Y-m-d');
|
||||
$endDate = Carbon::now()->format('Y-m-d');
|
||||
|
||||
$model = new MisMedicalHistory();
|
||||
$misDepartmentId = $request->user()->department->rf_mis_department_id;
|
||||
if ($status === 'plan') {
|
||||
$count = MisMedicalHistory::select($model->getFillable())
|
||||
->where('rf_EmerSignID', 1)
|
||||
->whereDate('DateRecipient', '>=', Carbon::now()->format('Y-m-d'))
|
||||
->plan()
|
||||
->inDepartment($misDepartmentId, $startDate, $endDate)
|
||||
->orderBy('DateRecipient', 'DESC')
|
||||
->count();
|
||||
} else if ($status === 'emergency') {
|
||||
$count = MisMedicalHistory::select($model->getFillable())
|
||||
->where('rf_EmerSignID', 2)
|
||||
->whereDate('DateRecipient', '>=', Carbon::now()->format('Y-m-d'))
|
||||
->emergency()
|
||||
->inDepartment($misDepartmentId, $startDate, $endDate)
|
||||
->orderBy('DateRecipient', 'DESC')
|
||||
->count();
|
||||
}
|
||||
|
||||
@@ -19,6 +19,12 @@ class FormattedPatientResource extends JsonResource
|
||||
return [
|
||||
'id' => $this->MedicalHistoryID,
|
||||
'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")),
|
||||
'age' => Carbon::parse($this->BD)->diff(Carbon::now())->format('%y'),
|
||||
'birth_date' => Carbon::parse($this->BD)->format('d.m.Y'),
|
||||
|
||||
22
app/Models/MisDiagnos.php
Normal file
22
app/Models/MisDiagnos.php
Normal 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
16
app/Models/MisMKB.php
Normal 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'
|
||||
];
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class MisMedicalHistory extends Model
|
||||
{
|
||||
@@ -18,4 +19,60 @@ class MisMedicalHistory extends Model
|
||||
'BD',
|
||||
'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]);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
26
app/Models/MisMigrationPatient.php
Normal file
26
app/Models/MisMigrationPatient.php
Normal 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');
|
||||
}
|
||||
}
|
||||
11
app/Models/MisStationarBranch.php
Normal file
11
app/Models/MisStationarBranch.php
Normal 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';
|
||||
}
|
||||
@@ -33,57 +33,68 @@ class TestDepartmentDataSeeder extends Seeder
|
||||
Department::create([
|
||||
'name_full' => 'Гинекологическое отделение',
|
||||
'name_short' => 'Гинекологическое',
|
||||
'rf_department_type' => 1
|
||||
'rf_department_type' => 1,
|
||||
'rf_mis_department_id' => 1054
|
||||
]);
|
||||
Department::create([
|
||||
'name_full' => 'Нейрохирургическое отделение',
|
||||
'name_short' => 'Нейрохирургическое',
|
||||
'rf_department_type' => 1
|
||||
'rf_department_type' => 1,
|
||||
'rf_mis_department_id' => 1049
|
||||
]);
|
||||
Department::create([
|
||||
'name_full' => 'Отделение термических поражений',
|
||||
'name_short' => 'Термических поражений',
|
||||
'rf_department_type' => 1
|
||||
'rf_department_type' => 1,
|
||||
'rf_mis_department_id' => 1059
|
||||
]);
|
||||
Department::create([
|
||||
'name_full' => 'Отоларингологическое отделение',
|
||||
'name_short' => 'Отоларингологическое',
|
||||
'rf_department_type' => 1
|
||||
'rf_department_type' => 1,
|
||||
'rf_mis_department_id' => 1061
|
||||
]);
|
||||
Department::create([
|
||||
'name_full' => 'Проктологическое отделение',
|
||||
'name_short' => 'Проктологическое',
|
||||
'rf_department_type' => 1
|
||||
'rf_department_type' => 1,
|
||||
'rf_mis_department_id' => 1065
|
||||
]);
|
||||
Department::create([
|
||||
'name_full' => 'Отделение сосудистой хирургии',
|
||||
'name_short' => 'Сосудистой хирургии',
|
||||
'rf_department_type' => 1
|
||||
'rf_department_type' => 1,
|
||||
'rf_mis_department_id' => 1050
|
||||
]);
|
||||
Department::create([
|
||||
'name_full' => 'Отделение торакальной хирургии',
|
||||
'name_short' => 'Торакальной хирургии',
|
||||
'rf_department_type' => 1
|
||||
'rf_department_type' => 1,
|
||||
'rf_mis_department_id' => 1069
|
||||
]);
|
||||
Department::create([
|
||||
'name_full' => 'Травматологическое отделение',
|
||||
'name_short' => 'Травматологическое',
|
||||
'rf_department_type' => 1
|
||||
'rf_department_type' => 1,
|
||||
'rf_mis_department_id' => 1070
|
||||
]);
|
||||
Department::create([
|
||||
'name_full' => 'Урологическое отделение',
|
||||
'name_short' => 'Урологическое',
|
||||
'rf_department_type' => 1
|
||||
'rf_department_type' => 1,
|
||||
'rf_mis_department_id' => 1071
|
||||
]);
|
||||
Department::create([
|
||||
'name_full' => 'Хирургическое отделение',
|
||||
'name_short' => 'Хирургическое',
|
||||
'rf_department_type' => 1
|
||||
'rf_department_type' => 1,
|
||||
'rf_mis_department_id' => 1072
|
||||
]);
|
||||
Department::create([
|
||||
'name_full' => 'Отделение ЧЛХ',
|
||||
'name_short' => 'ЧЛХ',
|
||||
'rf_department_type' => 1
|
||||
'rf_department_type' => 1,
|
||||
'rf_mis_department_id' => 1073
|
||||
]);
|
||||
|
||||
DepartmentMetrikaDefault::create([
|
||||
|
||||
5
package-lock.json
generated
5
package-lock.json
generated
@@ -2017,7 +2017,6 @@
|
||||
"integrity": "sha512-9nF4PdUle+5ta4W5SyZdLCCmFd37uVimSjg1evcTqKJCyvCEEj12WKzOSBNak6r4im4J4iYXKH1OWpUV5LBYFg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@emotion/hash": "~0.8.0",
|
||||
"csstype": "~3.0.5"
|
||||
@@ -2093,7 +2092,6 @@
|
||||
"resolved": "https://registry.npmjs.org/d3-selection/-/d3-selection-3.0.0.tgz",
|
||||
"integrity": "sha512-fmTRWbNMmsmWq6xJV8D19U/gw/bwrHfNXxrIN+HfZgnzqTHp9jOmKMhsTUjXOJnZOdZY9Q28y4yebKzqDKlxlQ==",
|
||||
"license": "ISC",
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
@@ -2147,7 +2145,6 @@
|
||||
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-4.1.0.tgz",
|
||||
"integrity": "sha512-Ukq0owbQXxa/U3EGtsdVBkR1w7KOQ5gIBqdH2hkvknzZPYvBxb/aa6E8L7tmjFtkwZBu3UXBbjIgPo/Ez4xaNg==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/kossnocorp"
|
||||
@@ -3570,7 +3567,6 @@
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-7.3.0.tgz",
|
||||
"integrity": "sha512-dZwN5L1VlUBewiP6H9s2+B3e3Jg96D0vzN+Ry73sOefebhYr9f94wwkMNN/9ouoU8pV1BqA1d1zGk8928cx0rg==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"esbuild": "^0.27.0",
|
||||
"fdir": "^6.5.0",
|
||||
@@ -3928,7 +3924,6 @@
|
||||
"resolved": "https://registry.npmjs.org/vue/-/vue-3.5.26.tgz",
|
||||
"integrity": "sha512-SJ/NTccVyAoNUJmkM9KUqPcYlY+u8OVL1X5EW9RIs3ch5H2uERxyyIUI4MRxVCSOiEcupX9xNGde1tL9ZKpimA==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@vue/compiler-dom": "3.5.26",
|
||||
"@vue/compiler-sfc": "3.5.26",
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
<script setup>
|
||||
import {NDataTable} from "naive-ui";
|
||||
import {NIcon, NDataTable} from "naive-ui";
|
||||
import {useReportStore} from "../../../Stores/report.js";
|
||||
import {computed, h, onMounted, ref, watch} from "vue";
|
||||
import { VueDraggableNext } from 'vue-draggable-next'
|
||||
import {storeToRefs} from "pinia";
|
||||
import {TbGripVertical} from "vue-icons-plus/tb";
|
||||
|
||||
const props = defineProps({
|
||||
mode: {
|
||||
@@ -12,7 +13,7 @@ const props = defineProps({
|
||||
},
|
||||
keys: {
|
||||
type: Array,
|
||||
default: ['num', 'fullname', 'age', 'birth_date', 'ds']
|
||||
default: ['num', 'fullname', 'age', 'birth_date', 'mkb.ds']
|
||||
},
|
||||
status: {
|
||||
type: String,
|
||||
@@ -40,14 +41,22 @@ const columns = computed(() => {
|
||||
title: '',
|
||||
key: 'drag',
|
||||
width: 40,
|
||||
render: (row) => h('div', {
|
||||
style: {
|
||||
cursor: 'grab',
|
||||
color: '#666',
|
||||
textAlign: 'center',
|
||||
userSelect: 'none'
|
||||
}
|
||||
}, '⋮⋮')
|
||||
render: (row) => h(
|
||||
'div',
|
||||
{
|
||||
style: {
|
||||
cursor: 'grab',
|
||||
textAlign: 'center',
|
||||
userSelect: 'none'
|
||||
}
|
||||
},
|
||||
[
|
||||
h(NIcon, {
|
||||
depth: '2',
|
||||
component: TbGripVertical
|
||||
}, [])
|
||||
]
|
||||
)
|
||||
}
|
||||
|
||||
return [dragColumn, ...baseColumns]
|
||||
@@ -143,7 +152,6 @@ onMounted(async () => {
|
||||
@drop="handleDrop"
|
||||
@dragover="handleDragOver"
|
||||
:loading="isLoading"
|
||||
virtual-scroll
|
||||
max-height="200"
|
||||
min-height="200"
|
||||
:row-props="rowProps"
|
||||
|
||||
@@ -46,7 +46,7 @@ export const useReportStore = defineStore('reportStore', () => {
|
||||
},
|
||||
{
|
||||
title: 'Диагноз',
|
||||
key: 'ds'
|
||||
key: 'mkb.ds'
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user