Добавил выбор ст. мед. сестер из отделений
This commit is contained in:
@@ -4,7 +4,9 @@ namespace App\Http\Controllers\Api;
|
|||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\Department;
|
use App\Models\Department;
|
||||||
|
use App\Models\MisLpuDoctor;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
class DepartmentController extends Controller
|
class DepartmentController extends Controller
|
||||||
{
|
{
|
||||||
@@ -17,4 +19,35 @@ class DepartmentController extends Controller
|
|||||||
|
|
||||||
return response()->json($departments);
|
return response()->json($departments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getDepartmentUsers(Department $department, Request $request)
|
||||||
|
{
|
||||||
|
$onlyUserDepartment = filter_var($request->query('onlyUserDepartment', false), FILTER_VALIDATE_BOOLEAN);
|
||||||
|
$type = $request->query('type', 'duty');
|
||||||
|
|
||||||
|
if ($onlyUserDepartment) {
|
||||||
|
$departmentId = $department->rf_mis_department_id;
|
||||||
|
} else {
|
||||||
|
$user = Auth::user();
|
||||||
|
$departmentId = $user->department->rf_mis_department_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$users = MisLpuDoctor::select(['LPUDoctorID', 'FAM_V', 'IM_V', 'OT_V'])
|
||||||
|
->whereHas('prvds', function ($query) use ($departmentId, $type) {
|
||||||
|
$query->when($type === 'nurse', function ($query) {
|
||||||
|
$query->whereIn('rf_PRVDID', [1567, 1629]);
|
||||||
|
})
|
||||||
|
->where('rf_DepartmentID', $departmentId)
|
||||||
|
->whereDate('D_END', '2222-01-01 00:00:00.000000');
|
||||||
|
})
|
||||||
|
->active()
|
||||||
|
->whereNotIn('LPUDoctorID', [0, 1])
|
||||||
|
->orderBy('FAM_V')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
...$users,
|
||||||
|
])->setStatusCode(200);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -482,27 +482,6 @@ class ReportController extends Controller
|
|||||||
return response()->json()->setStatusCode(200);
|
return response()->json()->setStatusCode(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDepartmentUsers(Request $request)
|
|
||||||
{
|
|
||||||
$user = Auth::user();
|
|
||||||
|
|
||||||
$departmentId = $user->department->rf_mis_department_id;
|
|
||||||
|
|
||||||
$users = MisLpuDoctor::select(['LPUDoctorID', 'FAM_V', 'IM_V', 'OT_V'])
|
|
||||||
->whereHas('prvds', function ($query) use ($departmentId) {
|
|
||||||
$query->where('rf_DepartmentID', $departmentId)
|
|
||||||
->whereDate('D_END', '2222-01-01 00:00:00.000000');
|
|
||||||
})
|
|
||||||
->active()
|
|
||||||
->whereNotIn('LPUDoctorID', [0, 1])
|
|
||||||
->orderBy('FAM_V')
|
|
||||||
->get();
|
|
||||||
|
|
||||||
return response()->json([
|
|
||||||
...$users,
|
|
||||||
])->setStatusCode(200);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Получить все отчеты в промежутке дат (для агрегации данных)
|
* Получить все отчеты в промежутке дат (для агрегации данных)
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -70,11 +70,12 @@ const openReport = (path) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const openNurseReport = () => {
|
const openNurseReport = () => {
|
||||||
if (authStore.isSeniorStaff) {
|
// if (authStore.isSeniorStaff) {
|
||||||
showSelectNurseUserModal.value = true
|
// showSelectNurseUserModal.value = true
|
||||||
} else {
|
// } else {
|
||||||
router.visit('/nurse/report')
|
// router.visit('/nurse/report')
|
||||||
}
|
// }
|
||||||
|
showSelectNurseUserModal.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
const cardColor = computed(() => themeVars.value.cardColor)
|
const cardColor = computed(() => themeVars.value.cardColor)
|
||||||
@@ -174,7 +175,7 @@ const dividerColor = computed(() => themeVars.value.dividerColor)
|
|||||||
</NFlex>
|
</NFlex>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<SelectUserModal v-model:show="showSelectUserModal" />
|
<SelectUserModal v-model:show="showSelectUserModal" :only-user-department="false" />
|
||||||
<SelectUserModal
|
<SelectUserModal
|
||||||
v-model:show="showSelectNurseUserModal"
|
v-model:show="showSelectNurseUserModal"
|
||||||
target-path="/nurse/report"
|
target-path="/nurse/report"
|
||||||
|
|||||||
@@ -18,6 +18,10 @@ const props = defineProps({
|
|||||||
withExistsCheck: {
|
withExistsCheck: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true
|
default: true
|
||||||
|
},
|
||||||
|
onlyUserDepartment: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -30,6 +34,8 @@ const usersLoaded = ref(false)
|
|||||||
const departmentsLoaded = ref(false)
|
const departmentsLoaded = ref(false)
|
||||||
const reportExists = ref(false)
|
const reportExists = ref(false)
|
||||||
const existingReportId = ref(null)
|
const existingReportId = ref(null)
|
||||||
|
const loadingDepartmentFetch = ref(false)
|
||||||
|
const loadingUserFetch = ref(false)
|
||||||
|
|
||||||
const users = computed(() => rawUsers.value.map(itm => ({
|
const users = computed(() => rawUsers.value.map(itm => ({
|
||||||
label: `${itm.FAM_V} ${itm.IM_V} ${itm.OT_V}`,
|
label: `${itm.FAM_V} ${itm.IM_V} ${itm.OT_V}`,
|
||||||
@@ -41,22 +47,29 @@ const departments = computed(() => rawDepartments.value.map(itm => ({
|
|||||||
value: itm.department_id
|
value: itm.department_id
|
||||||
})))
|
})))
|
||||||
|
|
||||||
const fetchUsers = () => {
|
const fetchUsers = (departmentId) => {
|
||||||
if (usersLoaded.value) return
|
usersLoaded.value = []
|
||||||
axios.get('/api/mis/department-users')
|
loadingUserFetch.value = true
|
||||||
|
const type = props.onlyUserDepartment ? 'nurse' : 'duty'
|
||||||
|
axios.get(`/api/app/departments/${departmentId}/users?onlyUserDepartment=${props.onlyUserDepartment}&type=${type}`)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
rawUsers.value = res.data
|
rawUsers.value = res.data
|
||||||
usersLoaded.value = true
|
usersLoaded.value = true
|
||||||
})
|
}).finally((e) => {
|
||||||
|
loadingUserFetch.value = false
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const fetchDepartments = () => {
|
const fetchDepartments = () => {
|
||||||
if (departmentsLoaded.value) return
|
if (departmentsLoaded.value) return
|
||||||
|
loadingDepartmentFetch.value = true
|
||||||
axios.get('/api/app/departments')
|
axios.get('/api/app/departments')
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
rawDepartments.value = res.data
|
rawDepartments.value = res.data
|
||||||
departmentsLoaded.value = true
|
departmentsLoaded.value = true
|
||||||
})
|
}).finally((e) => {
|
||||||
|
loadingDepartmentFetch.value = false
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const checkReportExists = async (userId, departmentId) => {
|
const checkReportExists = async (userId, departmentId) => {
|
||||||
@@ -130,7 +143,7 @@ watch(() => show.value, (opened) => {
|
|||||||
|
|
||||||
reportStore.reportInfo.userId = null
|
reportStore.reportInfo.userId = null
|
||||||
reportStore.reportInfo.departmentId = null
|
reportStore.reportInfo.departmentId = null
|
||||||
fetchUsers()
|
// fetchUsers()
|
||||||
fetchDepartments()
|
fetchDepartments()
|
||||||
}, {immediate: false})
|
}, {immediate: false})
|
||||||
|
|
||||||
@@ -158,6 +171,11 @@ const onAfterLeave = () => {
|
|||||||
reportExists.value = false
|
reportExists.value = false
|
||||||
existingReportId.value = null
|
existingReportId.value = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const onChangeDepartment = (departmentId) => {
|
||||||
|
usersLoaded.value = false
|
||||||
|
fetchUsers(departmentId)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -168,15 +186,19 @@ const onAfterLeave = () => {
|
|||||||
@before-leave="onAfterLeave"
|
@before-leave="onAfterLeave"
|
||||||
>
|
>
|
||||||
<NForm id="select-user-form" ref="formRef" :model="reportStore.reportInfo" :rules="rules">
|
<NForm id="select-user-form" ref="formRef" :model="reportStore.reportInfo" :rules="rules">
|
||||||
<NFormItem label="Выберите ответственного" path="userId">
|
<NFormItem label="Выберите отделение" path="departmentId">
|
||||||
<NSelect :options="users"
|
<NSelect :options="departments"
|
||||||
v-model:value="reportStore.reportInfo.userId"
|
:loading="loadingDepartmentFetch"
|
||||||
|
@change="onChangeDepartment"
|
||||||
|
v-model:value="reportStore.reportInfo.departmentId"
|
||||||
filterable
|
filterable
|
||||||
/>
|
/>
|
||||||
</NFormItem>
|
</NFormItem>
|
||||||
<NFormItem label="Выберите отделение" path="departmentId">
|
<NFormItem label="Выберите ответственного" path="userId">
|
||||||
<NSelect :options="departments"
|
<NSelect :options="users"
|
||||||
v-model:value="reportStore.reportInfo.departmentId"
|
:loading="loadingUserFetch"
|
||||||
|
:disabled="!usersLoaded"
|
||||||
|
v-model:value="reportStore.reportInfo.userId"
|
||||||
filterable
|
filterable
|
||||||
/>
|
/>
|
||||||
</NFormItem>
|
</NFormItem>
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ Route::middleware(['auth:sanctum'])->group(function () {
|
|||||||
Route::get('/patients/search', [ReportController::class, 'searchMisPatients']);
|
Route::get('/patients/search', [ReportController::class, 'searchMisPatients']);
|
||||||
Route::get('/mkb/search', [ReportController::class, 'searchMkb']);
|
Route::get('/mkb/search', [ReportController::class, 'searchMkb']);
|
||||||
Route::get('/services/search', [ReportController::class, 'searchMedicalServices']);
|
Route::get('/services/search', [ReportController::class, 'searchMedicalServices']);
|
||||||
Route::get('/department-users', [ReportController::class, 'getDepartmentUsers']);
|
|
||||||
|
|
||||||
Route::prefix('operations')->group(function () {
|
Route::prefix('operations')->group(function () {
|
||||||
Route::get('/', [\App\Http\Controllers\Api\OperationController::class, 'operations']);
|
Route::get('/', [\App\Http\Controllers\Api\OperationController::class, 'operations']);
|
||||||
@@ -91,6 +90,9 @@ Route::middleware(['auth:sanctum'])->group(function () {
|
|||||||
});
|
});
|
||||||
Route::prefix('departments')->group(function () {
|
Route::prefix('departments')->group(function () {
|
||||||
Route::get('/', [DepartmentController::class, 'index']);
|
Route::get('/', [DepartmentController::class, 'index']);
|
||||||
|
Route::prefix('{department}')->group(function () {
|
||||||
|
Route::get('/users', [DepartmentController::class, 'getDepartmentUsers']);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user