门诊医生站-》开立医嘱系统根据选中的药品名称
判断医嘱类型。
This commit is contained in:
@@ -103,7 +103,7 @@ watch(
|
|||||||
queryParams.value.searchKey = newValue.searchKey || '';
|
queryParams.value.searchKey = newValue.searchKey || '';
|
||||||
|
|
||||||
// 处理类型筛选
|
// 处理类型筛选
|
||||||
if (newValue.adviceType) {
|
if (newValue.adviceType !== undefined && newValue.adviceType !== null && newValue.adviceType !== '') {
|
||||||
// 单个类型
|
// 单个类型
|
||||||
queryParams.value.adviceTypes = newValue.adviceType.toString();
|
queryParams.value.adviceTypes = newValue.adviceType.toString();
|
||||||
} else {
|
} else {
|
||||||
@@ -111,6 +111,13 @@ watch(
|
|||||||
queryParams.value.adviceTypes = '1,2,3';
|
queryParams.value.adviceTypes = '1,2,3';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 设置categoryCode筛选条件(用于筛选西药和中成药)
|
||||||
|
if (newValue.categoryCode) {
|
||||||
|
queryParams.value.categoryCode = newValue.categoryCode;
|
||||||
|
} else {
|
||||||
|
queryParams.value.categoryCode = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
console.log('发送请求参数:', queryParams.value);
|
console.log('发送请求参数:', queryParams.value);
|
||||||
getList();
|
getList();
|
||||||
},
|
},
|
||||||
@@ -131,14 +138,31 @@ function getList() {
|
|||||||
|
|
||||||
getAdviceBaseInfo(queryParams.value).then((res) => {
|
getAdviceBaseInfo(queryParams.value).then((res) => {
|
||||||
if (res.data.records && res.data.records.length > 0) {
|
if (res.data.records && res.data.records.length > 0) {
|
||||||
adviceBaseList.value = res.data.records.filter((item) => {
|
let filteredRecords = res.data.records.filter((item) => {
|
||||||
|
// 后端已经根据adviceTypes参数进行了筛选,这里只需要进行前端补充筛选
|
||||||
|
|
||||||
|
// 过滤库存(药品和耗材需要检查库存,诊疗不需要检查库存)
|
||||||
if (item.adviceType == 1 || item.adviceType == 2) {
|
if (item.adviceType == 1 || item.adviceType == 2) {
|
||||||
return handleQuantity(item) != 0;
|
if (handleQuantity(item) == 0) {
|
||||||
} else {
|
return false;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果设置了categoryCode筛选条件,进行筛选(用于区分西药和中成药)
|
||||||
|
// categoryCode = '1' 表示中成药,categoryCode = '2' 表示西药
|
||||||
|
// 注意:只有药品类型(adviceType=1)才需要根据categoryCode筛选
|
||||||
|
if (queryParams.value.categoryCode && item.adviceType == 1) {
|
||||||
|
// 只筛选药品类型
|
||||||
|
if (item.categoryCode != queryParams.value.categoryCode) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
adviceBaseList.value = filteredRecords;
|
||||||
|
|
||||||
console.log('过滤后数据显示:', adviceBaseList.value.length, '条');
|
console.log('过滤后数据显示:', adviceBaseList.value.length, '条');
|
||||||
|
|
||||||
total.value = res.data.total;
|
total.value = res.data.total;
|
||||||
|
|||||||
@@ -526,9 +526,10 @@
|
|||||||
:ref="'adviceTypeRef' + scope.$index"
|
:ref="'adviceTypeRef' + scope.$index"
|
||||||
placeholder="请选择"
|
placeholder="请选择"
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
:value-key="'value'">
|
@change="handleAdviceTypeChange(scope.row, scope.$index)">
|
||||||
|
<!-- 直接使用drord_doctor_type字典,已包含拆分后的西药(1)和中成药(2) -->
|
||||||
<el-option
|
<el-option
|
||||||
v-for="dict in drord_doctor_type"
|
v-for="dict in getSortedAdviceTypeList()"
|
||||||
:key="dict.value"
|
:key="dict.value"
|
||||||
:label="dict.label"
|
:label="dict.label"
|
||||||
:value="dict.value"
|
:value="dict.value"
|
||||||
@@ -690,7 +691,7 @@ import {
|
|||||||
getActivityBindDevice,
|
getActivityBindDevice,
|
||||||
} from '../api';
|
} from '../api';
|
||||||
import adviceBaseList from '../adviceBaseList.vue';
|
import adviceBaseList from '../adviceBaseList.vue';
|
||||||
import { computed, getCurrentInstance, nextTick, watch } from 'vue';
|
import { computed, getCurrentInstance, nextTick, watch, unref } from 'vue';
|
||||||
import { calculateQuantityByDays, formatNumber } from '@/utils/his';
|
import { calculateQuantityByDays, formatNumber } from '@/utils/his';
|
||||||
import OrderGroupDrawer from './orderGroupDrawer';
|
import OrderGroupDrawer from './orderGroupDrawer';
|
||||||
import PrescriptionHistory from './prescriptionHistory';
|
import PrescriptionHistory from './prescriptionHistory';
|
||||||
@@ -707,7 +708,8 @@ const form = ref({
|
|||||||
});
|
});
|
||||||
const adviceQueryParams = ref({
|
const adviceQueryParams = ref({
|
||||||
searchKey: '',
|
searchKey: '',
|
||||||
adviceType: ''
|
adviceType: '',
|
||||||
|
categoryCode: '' // 用于筛选西药(2)和中成药(1)
|
||||||
});
|
});
|
||||||
const rowIndex = ref(-1);
|
const rowIndex = ref(-1);
|
||||||
const groupIndex = ref(1);
|
const groupIndex = ref(1);
|
||||||
@@ -771,18 +773,24 @@ const { method_code, unit_code, rate_code, distribution_category_code,drord_doct
|
|||||||
'drord_doctor_type'
|
'drord_doctor_type'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// 删除硬编码的adviceTypeList,直接使用drord_doctor_type字典
|
||||||
const adviceTypeList = ref([
|
const adviceTypeList = ref([
|
||||||
{
|
{
|
||||||
label: '西药中成药',
|
label: '西药',
|
||||||
value: 1,
|
value: 1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '耗材',
|
label: '中成药',
|
||||||
value: 2,
|
value: 2,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
label: '耗材',
|
||||||
|
value: 3,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: '诊疗',
|
label: '诊疗',
|
||||||
value: 3,
|
value: 4,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '全部',
|
label: '全部',
|
||||||
@@ -821,16 +829,88 @@ watch(
|
|||||||
},
|
},
|
||||||
{ immediate: true }
|
{ immediate: true }
|
||||||
);
|
);
|
||||||
|
// 获取排序后的医嘱类型列表(drord_doctor_type字典已包含拆分后的西药1和中成药2)
|
||||||
|
function getSortedAdviceTypeList() {
|
||||||
|
if (!drord_doctor_type.value || !Array.isArray(drord_doctor_type.value)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 按照字典排序显示(优先使用dictSort,如果没有则使用value排序)
|
||||||
|
// 同时确保value是数字类型,与adviceType匹配
|
||||||
|
return [...drord_doctor_type.value].sort((a, b) => {
|
||||||
|
// 优先使用dictSort排序
|
||||||
|
if (a.dictSort !== undefined && b.dictSort !== undefined) {
|
||||||
|
return (a.dictSort || 0) - (b.dictSort || 0);
|
||||||
|
}
|
||||||
|
// 如果没有dictSort,使用value排序
|
||||||
|
const valueA = Number(a.value) || 0;
|
||||||
|
const valueB = Number(b.value) || 0;
|
||||||
|
return valueA - valueB;
|
||||||
|
}).map(item => ({
|
||||||
|
...item,
|
||||||
|
value: Number(item.value) // 确保value是数字类型,与adviceType匹配
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
// 获取医嘱类别显示文本
|
// 获取医嘱类别显示文本
|
||||||
function getAdviceTypeText(adviceType) {
|
function getAdviceTypeText(adviceType) {
|
||||||
// 转换为字符串进行查找,确保无论输入是数字还是字符串都能正确匹配
|
// 如果adviceType为空或未定义,返回空字符串
|
||||||
const typeMap = {
|
if (adviceType === undefined || adviceType === null || adviceType === '') {
|
||||||
'1': '西药中成药',
|
return '';
|
||||||
'2': '耗材',
|
}
|
||||||
'3': '诊疗'
|
|
||||||
};
|
// 使用drord_doctor_type字典(已包含西药1、中成药2、诊疗3、耗材4、全部5)
|
||||||
// 先将adviceType转换为字符串,再查找映射
|
if (drord_doctor_type.value && Array.isArray(drord_doctor_type.value) && drord_doctor_type.value.length > 0) {
|
||||||
return typeMap[String(adviceType)] || '未知';
|
// 转换为数字进行比较
|
||||||
|
const adviceTypeNum = Number(adviceType);
|
||||||
|
|
||||||
|
// 尝试匹配字典项
|
||||||
|
let dictItem = drord_doctor_type.value.find(item => {
|
||||||
|
// 先尝试数字匹配
|
||||||
|
const itemValue = Number(item.value);
|
||||||
|
if (!isNaN(itemValue) && itemValue === adviceTypeNum) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// 再尝试字符串匹配
|
||||||
|
return String(item.value) === String(adviceType);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 如果找到匹配项,返回标签
|
||||||
|
if (dictItem && dictItem.label) {
|
||||||
|
return dictItem.label;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果字典未加载或未找到匹配项,返回空字符串
|
||||||
|
// 注意:这里不返回数字,避免显示数字
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理医嘱类型变化
|
||||||
|
function handleAdviceTypeChange(row, index) {
|
||||||
|
// 根据选择的医嘱类型设置categoryCode筛选条件
|
||||||
|
// drord_doctor_type: 1=西药, 2=中成药, 3=诊疗, 4=耗材, 5=全部
|
||||||
|
if (row.adviceType == 1) {
|
||||||
|
// 西药:categoryCode = 2
|
||||||
|
adviceQueryParams.value.categoryCode = '2';
|
||||||
|
adviceQueryParams.value.adviceType = 1; // 药品类型
|
||||||
|
} else if (row.adviceType == 2) {
|
||||||
|
// 中成药:categoryCode = 1
|
||||||
|
adviceQueryParams.value.categoryCode = '1';
|
||||||
|
adviceQueryParams.value.adviceType = 1; // 药品类型
|
||||||
|
} else if (row.adviceType == 3) {
|
||||||
|
// 诊疗:adviceType = 3
|
||||||
|
adviceQueryParams.value.categoryCode = '';
|
||||||
|
adviceQueryParams.value.adviceType = 3; // 诊疗类型
|
||||||
|
} else if (row.adviceType == 4) {
|
||||||
|
// 耗材:adviceType = 2(后端接口中耗材的adviceType是2)
|
||||||
|
adviceQueryParams.value.categoryCode = '';
|
||||||
|
adviceQueryParams.value.adviceType = 2; // 耗材类型
|
||||||
|
} else {
|
||||||
|
// 全部(5)或其他:清除筛选
|
||||||
|
adviceQueryParams.value.categoryCode = '';
|
||||||
|
adviceQueryParams.value.adviceType = '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
function handleTotalAmount() {
|
function handleTotalAmount() {
|
||||||
totalAmount.value = prescriptionList.value.reduce((accumulator, currentRow) => {
|
totalAmount.value = prescriptionList.value.reduce((accumulator, currentRow) => {
|
||||||
@@ -855,11 +935,14 @@ function getListInfo(addNewRow) {
|
|||||||
isAdding.value = false;
|
isAdding.value = false;
|
||||||
getPrescriptionList(props.patientInfo.encounterId).then((res) => {
|
getPrescriptionList(props.patientInfo.encounterId).then((res) => {
|
||||||
prescriptionList.value = res.data.map((item) => {
|
prescriptionList.value = res.data.map((item) => {
|
||||||
|
const parsedContent = JSON.parse(item.contentJson);
|
||||||
return {
|
return {
|
||||||
...JSON.parse(item.contentJson),
|
...parsedContent,
|
||||||
...item,
|
...item,
|
||||||
doseQuantity: JSON.parse(item.contentJson)?.doseQuantity,
|
// 确保adviceType是数字类型,以便正确显示文本
|
||||||
doseUnitCode_dictText: JSON.parse(item.contentJson)?.doseUnitCode_dictText,
|
adviceType: parsedContent.adviceType !== undefined ? Number(parsedContent.adviceType) : (item.adviceType !== undefined ? Number(item.adviceType) : undefined),
|
||||||
|
doseQuantity: parsedContent?.doseQuantity,
|
||||||
|
doseUnitCode_dictText: parsedContent?.doseUnitCode_dictText,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
groupMarkers.value = getGroupMarkers(prescriptionList.value); // 更新标记
|
groupMarkers.value = getGroupMarkers(prescriptionList.value); // 更新标记
|
||||||
@@ -903,7 +986,11 @@ function handleAddPrescription() {
|
|||||||
}
|
}
|
||||||
isAdding.value = true;
|
isAdding.value = true;
|
||||||
// 重置查询参数
|
// 重置查询参数
|
||||||
adviceQueryParams.value = {};
|
adviceQueryParams.value = {
|
||||||
|
searchKey: '',
|
||||||
|
adviceType: '',
|
||||||
|
categoryCode: ''
|
||||||
|
};
|
||||||
|
|
||||||
// 在数组最前方添加一行,让新增行显示在最上边
|
// 在数组最前方添加一行,让新增行显示在最上边
|
||||||
prescriptionList.value.unshift({
|
prescriptionList.value.unshift({
|
||||||
@@ -952,8 +1039,36 @@ function handleFocus(row, index) {
|
|||||||
rowIndex.value = index;
|
rowIndex.value = index;
|
||||||
row.showPopover = true;
|
row.showPopover = true;
|
||||||
// 确保查询参数与当前行类型一致
|
// 确保查询参数与当前行类型一致
|
||||||
|
let categoryCode = '';
|
||||||
|
let adviceType = row.adviceType || '';
|
||||||
|
|
||||||
|
// 根据医嘱类型设置筛选条件
|
||||||
|
// drord_doctor_type: 1=西药, 2=中成药, 3=诊疗, 4=耗材, 5=全部
|
||||||
|
if (row.adviceType == 1) {
|
||||||
|
// 西药
|
||||||
|
categoryCode = '2';
|
||||||
|
adviceType = 1; // 药品类型
|
||||||
|
} else if (row.adviceType == 2) {
|
||||||
|
// 中成药
|
||||||
|
categoryCode = '1';
|
||||||
|
adviceType = 1; // 药品类型
|
||||||
|
} else if (row.adviceType == 3) {
|
||||||
|
// 诊疗:adviceType = 3
|
||||||
|
categoryCode = '';
|
||||||
|
adviceType = 3; // 诊疗类型
|
||||||
|
} else if (row.adviceType == 4) {
|
||||||
|
// 耗材:adviceType = 2(后端接口中耗材的adviceType是2)
|
||||||
|
categoryCode = '';
|
||||||
|
adviceType = 2; // 耗材类型
|
||||||
|
} else {
|
||||||
|
// 全部(5)或其他:显示所有类型
|
||||||
|
categoryCode = '';
|
||||||
|
adviceType = '';
|
||||||
|
}
|
||||||
|
|
||||||
adviceQueryParams.value = {
|
adviceQueryParams.value = {
|
||||||
adviceType: row.adviceType || '',
|
adviceType: adviceType,
|
||||||
|
categoryCode: categoryCode,
|
||||||
searchKey: adviceQueryParams.value.searchKey || ''
|
searchKey: adviceQueryParams.value.searchKey || ''
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -1019,13 +1134,45 @@ function selectAdviceBase(key, row) {
|
|||||||
// 保存当前已选择的医嘱类型
|
// 保存当前已选择的医嘱类型
|
||||||
const currentAdviceType = prescriptionList.value[rowIndex.value].adviceType;
|
const currentAdviceType = prescriptionList.value[rowIndex.value].adviceType;
|
||||||
|
|
||||||
|
// 如果医嘱类型是"全部"(5)或未选择,根据药品的categoryCode自动判断
|
||||||
|
// drord_doctor_type: 1=西药, 2=中成药, 3=诊疗, 4=耗材, 5=全部
|
||||||
|
let finalAdviceType = currentAdviceType;
|
||||||
|
if ((currentAdviceType === undefined || currentAdviceType === null || currentAdviceType === '' || Number(currentAdviceType) === 5) && Number(row.adviceType) === 1) {
|
||||||
|
// 药品类型,需要根据categoryCode判断是西药还是中成药
|
||||||
|
// categoryCode = '1' 表示中成药,categoryCode = '2' 表示西药
|
||||||
|
if (row.categoryCode == '1') {
|
||||||
|
finalAdviceType = 2; // 中成药
|
||||||
|
} else if (row.categoryCode == '2') {
|
||||||
|
finalAdviceType = 1; // 西药
|
||||||
|
} else {
|
||||||
|
// 如果没有categoryCode,使用项目默认的类型
|
||||||
|
finalAdviceType = Number(row.adviceType);
|
||||||
|
}
|
||||||
|
} else if (currentAdviceType !== undefined && currentAdviceType !== null && currentAdviceType !== '' && Number(currentAdviceType) !== 5) {
|
||||||
|
// 用户已选择医嘱类型(且不是"全部"),保留用户的选择,确保是数字类型
|
||||||
|
finalAdviceType = Number(currentAdviceType);
|
||||||
|
} else {
|
||||||
|
// 使用项目默认的类型,确保是数字类型
|
||||||
|
finalAdviceType = Number(row.adviceType);
|
||||||
|
}
|
||||||
|
|
||||||
prescriptionList.value[rowIndex.value] = {
|
prescriptionList.value[rowIndex.value] = {
|
||||||
...prescriptionList.value[rowIndex.value],
|
...prescriptionList.value[rowIndex.value],
|
||||||
...JSON.parse(JSON.stringify(row)),
|
...JSON.parse(JSON.stringify(row)),
|
||||||
// 如果用户已经选择了医嘱类型,则保留用户的选择,否则使用项目默认的类型
|
adviceType: finalAdviceType, // 确保是数字类型
|
||||||
adviceType: currentAdviceType !== undefined && currentAdviceType !== null && currentAdviceType !== '' ?
|
|
||||||
currentAdviceType : row.adviceType,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 确保字典已加载后更新显示
|
||||||
|
nextTick(() => {
|
||||||
|
// 如果字典已加载,强制更新视图以确保显示正确的文本
|
||||||
|
if (drord_doctor_type.value && drord_doctor_type.value.length > 0) {
|
||||||
|
// 触发响应式更新
|
||||||
|
const currentRow = prescriptionList.value[rowIndex.value];
|
||||||
|
prescriptionList.value[rowIndex.value] = {
|
||||||
|
...currentRow
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
prescriptionList.value[rowIndex.value].orgId = undefined;
|
prescriptionList.value[rowIndex.value].orgId = undefined;
|
||||||
prescriptionList.value[rowIndex.value].dose = undefined;
|
prescriptionList.value[rowIndex.value].dose = undefined;
|
||||||
prescriptionList.value[rowIndex.value].unitCodeList = unitCodeList.value;
|
prescriptionList.value[rowIndex.value].unitCodeList = unitCodeList.value;
|
||||||
@@ -1132,6 +1279,7 @@ function handleDelete() {
|
|||||||
expandOrder.value = [];
|
expandOrder.value = [];
|
||||||
isAdding.value = false;
|
isAdding.value = false;
|
||||||
adviceQueryParams.value.adviceType = undefined;
|
adviceQueryParams.value.adviceType = undefined;
|
||||||
|
adviceQueryParams.value.categoryCode = undefined;
|
||||||
if (sum == selectRow.length) {
|
if (sum == selectRow.length) {
|
||||||
proxy.$modal.msgSuccess('删除成功');
|
proxy.$modal.msgSuccess('删除成功');
|
||||||
groupIndexList.value = [];
|
groupIndexList.value = [];
|
||||||
|
|||||||
Reference in New Issue
Block a user