* поправил поле выбора даты * добавил индикатор в контроле * окно выбора пользователя для сводной * привязка окна для ввода причины контроля * добавил привязку историй пациентов для просмотра статистики по дням * поправил фиксацию фио ответственного, убрал при диапазоне * отключение ролей адм и зав от реплики
196 lines
5.6 KiB
JavaScript
196 lines
5.6 KiB
JavaScript
import {defineStore} from "pinia";
|
|
import {useTimestamp} from "@vueuse/core";
|
|
import {computed, ref} from "vue";
|
|
import {router} from "@inertiajs/vue3";
|
|
|
|
export const useReportStore = defineStore('reportStore', () => {
|
|
const timestampNow = useTimestamp()
|
|
|
|
const _timestampCurrent = ref(null)
|
|
const timestampCurrent = computed({
|
|
get: () => {
|
|
if (_timestampCurrent.value === null)
|
|
return timestampNow.value
|
|
|
|
return _timestampCurrent.value
|
|
},
|
|
set: (value) => {
|
|
_timestampCurrent.value = value
|
|
}
|
|
})
|
|
|
|
const timestampCurrentRange = ref([null, null])
|
|
|
|
const dataOnReport = ref(null)
|
|
|
|
const reportInfo = ref({
|
|
userId: null
|
|
})
|
|
const isLoadReportInfo = ref(false)
|
|
|
|
const patientColumns = [
|
|
{
|
|
title: '№',
|
|
width: '80',
|
|
key: 'num'
|
|
},
|
|
{
|
|
title: 'ФИО',
|
|
width: '320',
|
|
key: 'fullname'
|
|
},
|
|
{
|
|
title: 'Возраст',
|
|
key: 'age'
|
|
},
|
|
{
|
|
title: 'Дата рождения',
|
|
key: 'birth_date'
|
|
},
|
|
{
|
|
title: 'Диагноз',
|
|
key: 'mkb.ds'
|
|
}
|
|
]
|
|
|
|
const patientsData = ref({
|
|
plan: [],
|
|
emergency: [],
|
|
observation: [],
|
|
outcome: []
|
|
})
|
|
|
|
const reportForm = ref({})
|
|
|
|
// Пользователи которые находятся в том же отделении что и авторизованный пользователь
|
|
const departmentUsers = ref([])
|
|
|
|
// Нежелательные события
|
|
const unwantedEvents = ref([])
|
|
|
|
const getColumnsByKey = (keys) => {
|
|
const result = []
|
|
for (const key of keys) {
|
|
const column = patientColumns.find(item => item.key === key)
|
|
result.push(column)
|
|
}
|
|
|
|
return result
|
|
}
|
|
|
|
const sendReportForm = (assignForm) => {
|
|
const form = {
|
|
metrics: reportForm.value,
|
|
observationPatients: patientsData.value['observation'],
|
|
unwantedEvents: unwantedEvents.value,
|
|
dates: timestampCurrentRange.value,
|
|
userId: reportInfo.value.userId,
|
|
...assignForm
|
|
}
|
|
|
|
axios.post('/api/report', form)
|
|
.then(r => {
|
|
window.$message.success('Отчет сохранен')
|
|
resetReportForm()
|
|
router.visit('/')
|
|
})
|
|
}
|
|
|
|
const resetReportForm = () => {
|
|
reportForm.value = {}
|
|
unwantedEvents.value = []
|
|
patientsData.value.observation = []
|
|
}
|
|
|
|
const $reset = () => {
|
|
|
|
}
|
|
|
|
const getReportInfo = async () => {
|
|
isLoadReportInfo.value = true
|
|
const queryParams = {
|
|
userId: reportInfo.value.userId
|
|
}
|
|
await axios.get(`/api/report`, {
|
|
params: queryParams
|
|
})
|
|
.then((res) => {
|
|
reportInfo.value = {
|
|
...reportInfo.value,
|
|
...res.data
|
|
}
|
|
|
|
reportForm.value.metrika_item_3 = reportInfo.value.department?.recipientCount
|
|
reportForm.value.metrika_item_7 = reportInfo.value.department?.extractCount
|
|
reportForm.value.metrika_item_8 = reportInfo.value.department?.currentCounts
|
|
|
|
reportForm.value.metrika_item_9 = reportInfo.value.department?.deadCount
|
|
reportForm.value.metrika_item_10 = reportInfo.value.department?.surgicalCount[1]
|
|
reportForm.value.metrika_item_11 = reportInfo.value.department?.surgicalCount[0]
|
|
|
|
unwantedEvents.value = reportInfo.value.report.unwantedEvents
|
|
|
|
timestampCurrentRange.value = [
|
|
reportInfo.value.dates.startAt,
|
|
reportInfo.value.dates.endAt,
|
|
]
|
|
})
|
|
.finally(() => {
|
|
isLoadReportInfo.value = false
|
|
})
|
|
}
|
|
|
|
const getDataOnReportDate = async (dateRange) => {
|
|
isLoadReportInfo.value = true
|
|
timestampCurrentRange.value = dateRange
|
|
const queryParams = {
|
|
userId: reportInfo.value.userId,
|
|
startAt: timestampCurrentRange.value[0],
|
|
endAt: timestampCurrentRange.value[1],
|
|
}
|
|
await axios.get(`/api/report`, {
|
|
params: queryParams
|
|
})
|
|
.then((res) => {
|
|
reportInfo.value = {
|
|
...reportInfo.value,
|
|
...res.data
|
|
}
|
|
|
|
reportForm.value.metrika_item_3 = reportInfo.value.department?.recipientCount
|
|
reportForm.value.metrika_item_7 = reportInfo.value.department?.extractCount
|
|
reportForm.value.metrika_item_8 = reportInfo.value.department?.currentCount
|
|
|
|
unwantedEvents.value = reportInfo.value.report.unwantedEvents
|
|
|
|
timestampCurrentRange.value = [
|
|
reportInfo.value.dates.startAt,
|
|
reportInfo.value.dates.endAt,
|
|
]
|
|
})
|
|
.finally(() => {
|
|
isLoadReportInfo.value = false
|
|
})
|
|
}
|
|
|
|
return {
|
|
timestampNow,
|
|
timestampCurrent,
|
|
timestampCurrentRange,
|
|
isLoadReportInfo,
|
|
dataOnReport,
|
|
patientColumns,
|
|
patientsData,
|
|
reportInfo,
|
|
reportForm,
|
|
departmentUsers,
|
|
unwantedEvents,
|
|
|
|
getColumnsByKey,
|
|
getDataOnReportDate,
|
|
getReportInfo,
|
|
sendReportForm,
|
|
resetReportForm,
|
|
}
|
|
})
|