diff --git a/openhis-ui-vue3/src/views/inpatientDoctor/home/components/adviceBaseList.vue b/openhis-ui-vue3/src/views/inpatientDoctor/home/components/adviceBaseList.vue index a3fe5c714..129d2b8a3 100755 --- a/openhis-ui-vue3/src/views/inpatientDoctor/home/components/adviceBaseList.vue +++ b/openhis-ui-vue3/src/views/inpatientDoctor/home/components/adviceBaseList.vue @@ -81,7 +81,7 @@ const tableColumns = computed(() => [ /** * 父组件主动调用此方法刷新列表 - * @param adviceType 医嘱类型(1=药品, 3=诊疗, 6=手术, ''=全部) + * @param adviceType 医嘱类型(1=药品, 3=诊疗, 6=手术, 7=出院带药, ''=全部) * @param categoryCode 药品分类编码('1'=中成药, '2'=西药, '4'=中草药, ''=不限) * @param searchKey 搜索关键词 */ @@ -89,6 +89,9 @@ function refresh(adviceType: any, categoryCode: string, searchKey: string) { // 有搜索词时跨类型搜索,避免用户输入"级护理"但因当前adviceType为药品而搜不到诊疗类护理项目 if (searchKey) { queryParams.value.adviceTypes = [1, 2, 3, 6]; + } else if (adviceType == 7) { + // Bug #589: 出院带药仅检索西药和中成药 + queryParams.value.adviceTypes = [1]; } else { queryParams.value.adviceTypes = adviceType !== undefined && adviceType !== '' ? [parseInt(adviceType)] : [1, 2, 3, 6]; @@ -117,6 +120,13 @@ function getList() { // 药品/耗材需要有库存才显示,诊疗/手术直接显示 adviceBaseList.value = records.filter((item: any) => { + // Bug #589: 出院带药仅显示西药(categoryCode='2')和中成药(categoryCode='1') + if (queryParams.value.adviceTypes.length === 1 && queryParams.value.adviceTypes[0] === 1 && !queryParams.value.categoryCode) { + if (item.adviceType == 1 && (item.categoryCode == '1' || item.categoryCode == '2')) { + return handleQuantity(item) !== '0'; + } + return false; + } if (item.adviceType == 1 || item.adviceType == 2) { return handleQuantity(item) !== '0'; } diff --git a/openhis-ui-vue3/src/views/inpatientDoctor/home/components/order/OrderForm.vue b/openhis-ui-vue3/src/views/inpatientDoctor/home/components/order/OrderForm.vue index 0c127f7bf..3495081a1 100755 --- a/openhis-ui-vue3/src/views/inpatientDoctor/home/components/order/OrderForm.vue +++ b/openhis-ui-vue3/src/views/inpatientDoctor/home/components/order/OrderForm.vue @@ -304,6 +304,119 @@ + @@ -165,6 +165,13 @@ // 更新行的 adviceType(数字)和 categoryCode filterPrescriptionList[scope.$index].adviceType = newAdviceType; filterPrescriptionList[scope.$index].categoryCode = newCategoryCode; + // Bug #589: 出院带药强制为临时医嘱 + if (newAdviceType == 7) { + filterPrescriptionList[scope.$index].therapyEnum = '2'; + filterPrescriptionList[scope.$index].dischargeFlag = true; + } else { + filterPrescriptionList[scope.$index].dischargeFlag = false; + } // 更新 adviceQueryParams(备用) adviceQueryParams.value = { adviceType: newAdviceType, @@ -495,10 +502,11 @@ const adviceTypeList = computed(() => { hasShownPharmacyConfigWarning.value = true; } - // 只返回不需要取药科室配置的类别(诊疗、手术) + // 只返回不需要取药科室配置的类别(诊疗、手术、出院带药) return [ { label: '诊疗', value: 3, adviceType: 3, categoryCode: '' }, { label: '手术', value: 6, adviceType: 6, categoryCode: '' }, + { label: '出院带药', value: 7, adviceType: 7, categoryCode: '' }, { label: '全部', value: '', adviceType: '', categoryCode: '' }, ]; } @@ -526,6 +534,9 @@ const adviceTypeList = computed(() => { typeList.push({ label: '诊疗', value: 3, adviceType: 3, categoryCode: '' }); typeList.push({ label: '手术', value: 6, adviceType: 6, categoryCode: '' }); + // 始终添加"出院带药"选项(不需要取药科室配置) + typeList.push({ label: '出院带药', value: 7, adviceType: 7, categoryCode: '' }); + // 添加全部选项 typeList.push({ label: '全部', value: '', adviceType: '', categoryCode: '' }); @@ -656,6 +667,12 @@ function getListInfo(addNewRow) { // 🔧 修复:同时保存 orgName,当 orgId 在科室树中匹配不到时作为兜底显示 // 优先从科室树查找名称,其次用 positionName(后端已保存的科室名),最后用 contentJson 中的 orgName orgName: findOrgName(item.positionId || parsedContent?.orgId || item.orgId) || item.positionName || parsedContent?.orgName || undefined, + // Bug #589: 从contentJson检测出院带药标记,恢复类型显示 + // 后端存储时adviceType转为1(药品),通过prescriptionCategory=3标识出院带药 + ...(parsedContent?.prescriptionCategory == 3 ? { + adviceType: 7, + dischargeFlag: true, + } : {}), }; }) .sort((a, b) => { @@ -783,6 +800,9 @@ function getRowSelectValue(row) { if (row.adviceType == 1 && row.categoryCode) { return '1-' + row.categoryCode; } + if (row.adviceType == 7) { + return 7; + } return row.adviceType; } @@ -1002,13 +1022,21 @@ function selectAdviceBase(key, row) { // 每次选择药品时,将当前行数据初始化为最初状态 const currentUniqueKey = prescriptionList.value[rowIndex.value]?.uniqueKey || key; + const prevRow = prescriptionList.value[rowIndex.value] || {}; prescriptionList.value[rowIndex.value] = { uniqueKey: currentUniqueKey, isEdit: true, statusEnum: 1, - therapyEnum: prescriptionList.value[rowIndex.value]?.therapyEnum, + therapyEnum: prevRow.therapyEnum, + // Bug #589: 出院带药需要保留类型和标志,setValue中可能被API数据覆盖 + adviceType: prevRow.adviceType || undefined, + dischargeFlag: prevRow.dischargeFlag || undefined, }; setValue(row); + // Bug #589: 出院带药选择药品后恢复类型标志 + if (prescriptionList.value[rowIndex.value]?.dischargeFlag) { + prescriptionList.value[rowIndex.value].adviceType = 7; + } // 确保 uniqueKey 不被覆盖 prescriptionList.value[rowIndex.value].uniqueKey = currentUniqueKey; // 先清空展开状态,然后在 nextTick 中设置,确保数据更新后再展开 @@ -1251,6 +1279,14 @@ function handleSave() { item.encounterId = patientInfo.value.encounterId; item.accountId = patientInfo.value.accountId; item.dbOpType = '1'; + // Bug #589: 出院带药保存时转为药品类型 + if (item.adviceType == 7) { + item.adviceType = 1; + const parsed = item.contentJson ? JSON.parse(item.contentJson) : {}; + parsed.adviceType = 1; + parsed.prescriptionCategory = 3; // 出院带药标记 + item.contentJson = JSON.stringify(parsed); + } }); // 此处签发处方和单行保存处方传参相同,后台已经将传参存为JSON字符串,此处直接转换为JSON即可 loading.value = true; @@ -1387,8 +1423,9 @@ function handleSaveSign(row, index) { if (!validateStartTime(row.startTime)) { return; } + // Bug #589: 出院带药按药品逻辑处理绑设备检查 if (row.adviceType != 2) { - let itemNo = row.adviceType == 1 ? row.methodCode : row.adviceDefinitionId; + let itemNo = row.adviceType == 1 || row.adviceType == 7 ? row.methodCode : row.adviceDefinitionId; if (!itemNo) { console.warn('绑定设备检查跳过:itemNo为空(adviceType=' + row.adviceType + ', adviceName=' + row.adviceName + ')'); } else { @@ -1421,7 +1458,8 @@ function handleSaveSign(row, index) { row.patientId = patientInfo.value.patientId; row.encounterId = patientInfo.value.encounterId; row.accountId = accountId.value; - if (row.adviceType == 1) { + // Bug #589: 出院带药(adviceType=7)按药品(adviceType=1)逻辑保存 + if (row.adviceType == 1 || row.adviceType == 7) { row.minUnitQuantity = row.minUnitCode == row.unitCode ? row.quantity : row.quantity * row.partPercent; row.quantity = row.therapyEnum === '1' ? row.doseQuantity || row.quantity : row.quantity; @@ -1429,8 +1467,14 @@ function handleSaveSign(row, index) { } else { row.minUnitQuantity = row.quantity; } + // Bug #589: 保存时将出院带药adviceType转为1(药品),兼容后端 + const originalAdviceType = row.adviceType; + if (row.adviceType == 7) { + row.adviceType = 1; + } row.conditionId = conditionId.value; // 处理总量为小单位情况,需要把单价也保存成小单位的 + // Bug #589: 出院带药按药品逻辑处理单价 if (row.unitCodeList.find((item) => item.value == row.unitCode).type == 'unit') { if (row.adviceType != 3) { row.unitPrice = row.unitTempPrice; @@ -1447,6 +1491,10 @@ function handleSaveSign(row, index) { if (row.injectFlag == 1) { row.sortNumber = row.sortNumber ? row.sortNumber : prescriptionList.value.length; } + // Bug #589: 出院带药标记到contentJson + if (originalAdviceType == 7) { + row.prescriptionCategory = 3; + } row.contentJson = JSON.stringify(row); if (row.requestId) { row.dbOpType = '2'; @@ -1494,11 +1542,20 @@ function handleSaveBatch() { .map((item) => { // 确保 therapyEnum 被正确传递,默认为长期医嘱('1') const therapyEnum = item.therapyEnum || '1'; - return { + const result = { ...item, therapyEnum: therapyEnum, dbOpType: item.requestId ? '2' : '1', }; + // Bug #589: 出院带药批量保存时转为药品类型 + if (result.adviceType == 7) { + result.adviceType = 1; + const parsed = result.contentJson ? JSON.parse(result.contentJson) : {}; + parsed.adviceType = 1; + parsed.prescriptionCategory = 3; + result.contentJson = JSON.stringify(parsed); + } + return result; }); if (saveList.length == 0) { proxy.$modal.msgWarning('当前没有可保存医嘱');