fix(doctorstation): 解决会诊医嘱删除和撤回功能问题
- 引入cancelConsultation接口用于处理会诊医嘱作废 - 分离会诊医嘱和普通医嘱的删除逻辑 - 实现会诊医嘱的作废功能,支持从contentJson解析consultationId - 添加会诊医嘱撤回功能,区分草稿状态和已提交状态 - 修复医嘱分类逻辑,将会诊类型值5归类到诊疗活动 - 添加调试日志用于跟踪医嘱处理流程 - 优化耗材医嘱删除逻辑,完善费用项清理 - 修复列表更新机制,确保作废医嘱及时从界面移除
This commit is contained in:
@@ -486,6 +486,19 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
// 医嘱分类信息
|
||||
List<AdviceSaveDto> adviceSaveList = adviceSaveParam.getAdviceSaveList();
|
||||
|
||||
// 🔍 Debug日志: 记录请求入口
|
||||
log.info("========== BugFix#219 DEBUG START ==========");
|
||||
log.info("saveAdvice called, adviceOpType={}, organizationId={}, adviceSaveList.size={}",
|
||||
adviceOpType, organizationId, adviceSaveList != null ? adviceSaveList.size() : 0);
|
||||
if (adviceSaveList != null && !adviceSaveList.isEmpty()) {
|
||||
for (int i = 0; i < adviceSaveList.size(); i++) {
|
||||
AdviceSaveDto dto = adviceSaveList.get(i);
|
||||
log.info("Request[{}]: requestId={}, dbOpType={}, adviceType={}, encounterId={}, patientId={}",
|
||||
i, dto.getRequestId(), dto.getDbOpType(), dto.getAdviceType(),
|
||||
dto.getEncounterId(), dto.getPatientId());
|
||||
}
|
||||
}
|
||||
|
||||
// 🔧 Bug Fix: 校验并补全patientId和encounterId(如果为null,尝试从医嘱记录获取)
|
||||
for (AdviceSaveDto adviceSaveDto : adviceSaveList) {
|
||||
// 对于删除操作,如果encounterId为null,尝试从医嘱记录获取
|
||||
@@ -550,9 +563,21 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
// 耗材
|
||||
List<AdviceSaveDto> deviceList = adviceSaveList.stream()
|
||||
.filter(e -> ItemType.DEVICE.getValue().equals(e.getAdviceType())).collect(Collectors.toList());
|
||||
// 诊疗活动
|
||||
// 诊疗活动(包括普通诊疗和会诊:前端会诊类型值为5)
|
||||
List<AdviceSaveDto> activityList = adviceSaveList.stream()
|
||||
.filter(e -> ItemType.ACTIVITY.getValue().equals(e.getAdviceType())).collect(Collectors.toList());
|
||||
.filter(e -> ItemType.ACTIVITY.getValue().equals(e.getAdviceType())
|
||||
|| e.getAdviceType() == 5) // 🔧 BugFix: 会诊类型值为5,也归类到诊疗活动
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 🔍 Debug日志: 记录分类结果
|
||||
log.info("BugFix#219: 医嘱分类完成 - 药品:{}, 耗材:{}, 诊疗:{}",
|
||||
medicineList.size(), deviceList.size(), activityList.size());
|
||||
|
||||
// 统计各类删除操作
|
||||
long medDeleteCount = medicineList.stream().filter(e -> DbOpType.DELETE.getCode().equals(e.getDbOpType())).count();
|
||||
long devDeleteCount = deviceList.stream().filter(e -> DbOpType.DELETE.getCode().equals(e.getDbOpType())).count();
|
||||
long actDeleteCount = activityList.stream().filter(e -> DbOpType.DELETE.getCode().equals(e.getDbOpType())).count();
|
||||
log.info("BugFix#219: 待删除数量 - 药品:{}, 耗材:{}, 诊疗:{}", medDeleteCount, devDeleteCount, actDeleteCount);
|
||||
|
||||
/**
|
||||
* 保存时,校验库存
|
||||
@@ -932,6 +957,18 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
* 处理耗材
|
||||
*/
|
||||
private void handDevice(List<AdviceSaveDto> deviceList, Date curDate, String adviceOpType) {
|
||||
// 🔍 Debug日志: handDevice方法入口
|
||||
log.info("BugFix#219: ========== handDevice START ==========");
|
||||
log.info("BugFix#219: handDevice called, deviceList.size={}, adviceOpType={}",
|
||||
deviceList != null ? deviceList.size() : 0, adviceOpType);
|
||||
if (deviceList != null && !deviceList.isEmpty()) {
|
||||
for (int i = 0; i < deviceList.size(); i++) {
|
||||
AdviceSaveDto dto = deviceList.get(i);
|
||||
log.info("BugFix#219: Device[{}]: requestId={}, dbOpType={}",
|
||||
i, dto.getRequestId(), dto.getDbOpType());
|
||||
}
|
||||
}
|
||||
|
||||
// 当前登录账号的科室id
|
||||
Long orgId = SecurityUtils.getLoginUser().getOrgId();
|
||||
// 获取当前登录用户的tenantId
|
||||
@@ -953,6 +990,16 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
// 删除
|
||||
List<AdviceSaveDto> deleteList = deviceList.stream()
|
||||
.filter(e -> DbOpType.DELETE.getCode().equals(e.getDbOpType())).collect(Collectors.toList());
|
||||
|
||||
// 🔍 Debug日志: 记录删除列表
|
||||
log.info("BugFix#219: handDevice - insertOrUpdateList.size={}, deleteList.size={}",
|
||||
insertOrUpdateList.size(), deleteList.size());
|
||||
if (!deleteList.isEmpty()) {
|
||||
for (AdviceSaveDto dto : deleteList) {
|
||||
log.info("BugFix#219: handDevice - 待删除: requestId={}", dto.getRequestId());
|
||||
}
|
||||
}
|
||||
|
||||
// 校验删除的医嘱是否已经收费
|
||||
List<Long> delRequestIdList = deleteList.stream().map(AdviceSaveDto::getRequestId).collect(Collectors.toList());
|
||||
if (!delRequestIdList.isEmpty()) {
|
||||
@@ -971,17 +1018,42 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
}
|
||||
}
|
||||
}
|
||||
// 🔍 Debug日志: 开始删除循环
|
||||
log.info("BugFix#219: handDevice - 开始删除循环, deleteList.size={}", deleteList.size());
|
||||
for (AdviceSaveDto adviceSaveDto : deleteList) {
|
||||
iDeviceRequestService.removeById(adviceSaveDto.getRequestId());
|
||||
// 删除已经产生的耗材发放信息
|
||||
iDeviceDispenseService.deleteDeviceDispense(adviceSaveDto.getRequestId());
|
||||
// 🔧 Bug Fix #219: 删除费用项
|
||||
Long requestId = adviceSaveDto.getRequestId();
|
||||
log.info("BugFix#219: handDevice - 删除开始: requestId={}", requestId);
|
||||
|
||||
// 1. 删除耗材请求
|
||||
boolean deviceRemoved = iDeviceRequestService.removeById(requestId);
|
||||
log.info("BugFix#219: handDevice - 删除DeviceRequest: requestId={}, result={}", requestId, deviceRemoved);
|
||||
|
||||
// 2. 删除已经产生的耗材发放信息
|
||||
iDeviceDispenseService.deleteDeviceDispense(requestId);
|
||||
log.info("BugFix#219: handDevice - 删除DeviceDispense: requestId={}", requestId);
|
||||
|
||||
// 3. 删除费用项
|
||||
String serviceTable = CommonConstants.TableName.WOR_DEVICE_REQUEST;
|
||||
// 先查询费用项是否存在
|
||||
try {
|
||||
List<ChargeItem> existingChargeItems = iChargeItemService.getChargeItemInfoByReqId(Arrays.asList(requestId));
|
||||
log.info("BugFix#219: handDevice - 查询到费用项数量: requestId={}, count={}", requestId,
|
||||
existingChargeItems != null ? existingChargeItems.size() : 0);
|
||||
if (existingChargeItems != null) {
|
||||
for (ChargeItem ci : existingChargeItems) {
|
||||
log.info("BugFix#219: handDevice - 费用项详情: id={}, serviceTable={}, serviceId={}, status={}",
|
||||
ci.getId(), ci.getServiceTable(), ci.getServiceId(), ci.getStatusEnum());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("BugFix#219: handDevice - 查询费用项异常: requestId={}", requestId, e);
|
||||
}
|
||||
// 直接删除费用项(使用serviceTable和serviceId作为条件)
|
||||
iChargeItemService.deleteByServiceTableAndId(serviceTable, requestId);
|
||||
log.info("BugFix#219: 耗材医嘱删除完成, requestId={}, serviceTable={}", requestId, serviceTable);
|
||||
log.info("BugFix#219: handDevice - 删除ChargeItem: requestId={}, serviceTable={}", requestId, serviceTable);
|
||||
log.info("BugFix#219: handDevice - 删除完成: requestId={}", requestId);
|
||||
}
|
||||
log.info("BugFix#219: ========== handDevice END ==========");
|
||||
|
||||
for (AdviceSaveDto adviceSaveDto : insertOrUpdateList) {
|
||||
deviceRequest = new DeviceRequest();
|
||||
|
||||
@@ -825,6 +825,7 @@ import {
|
||||
getOrderGroup,
|
||||
deleteGroup,
|
||||
queryGroupDetail,
|
||||
cancelConsultation, // 🔧 BugFix: 引入会诊作废接口
|
||||
} from '../api';
|
||||
import { advicePrint, getAdjustPriceSwitchState } from '@/api/public';
|
||||
import adviceBaseList from '../adviceBaseList.vue';
|
||||
@@ -1973,15 +1974,105 @@ function getOrgList() {
|
||||
|
||||
function handleDelete() {
|
||||
let selectRows = prescriptionRef.value.getSelectionRows();
|
||||
console.log('BugFix#219: handleDelete called, selectRows=', selectRows);
|
||||
|
||||
if (selectRows.length == 0) {
|
||||
proxy.$modal.msgWarning('请选择要删除的医嘱');
|
||||
return;
|
||||
}
|
||||
|
||||
// 🔧 BugFix: 分离会诊医嘱和普通医嘱
|
||||
let consultationRows = selectRows.filter(item => item.adviceType === 5);
|
||||
let normalRows = selectRows.filter(item => item.adviceType !== 5);
|
||||
|
||||
console.log('BugFix#219: consultationRows=', consultationRows.length, 'normalRows=', normalRows.length);
|
||||
|
||||
// 处理会诊医嘱删除
|
||||
if (consultationRows.length > 0) {
|
||||
console.log('BugFix#219: 处理会诊医嘱删除');
|
||||
console.log('BugFix#219: 会诊医嘱详情:', consultationRows.map(item => ({
|
||||
adviceType: item.adviceType,
|
||||
statusEnum: item.statusEnum,
|
||||
requestId: item.requestId,
|
||||
adviceName: item.adviceName
|
||||
})));
|
||||
|
||||
// 🔧 BugFix: 放宽条件,只要有requestId的会诊医嘱都可以尝试删除
|
||||
let draftConsultations = consultationRows.filter(item => item.requestId);
|
||||
console.log('BugFix#219: draftConsultations=', draftConsultations.length, '过滤条件: requestId存在 (不限制statusEnum)');
|
||||
console.log('BugFix#219: 未过滤的会诊医嘱:', consultationRows.map(item => ({
|
||||
statusEnum: item.statusEnum,
|
||||
hasRequestId: !!item.requestId
|
||||
})));
|
||||
|
||||
if (draftConsultations.length > 0) {
|
||||
console.log('BugFix#219: 开始作废草稿状态会诊医嘱');
|
||||
// 草稿状态的会诊直接作废
|
||||
let deletePromises = draftConsultations.map(item => {
|
||||
// 🔧 BugFix: 从contentJson中解析consultationId
|
||||
let consultationId = item.requestId;
|
||||
try {
|
||||
const contentJson = item.contentJson ? JSON.parse(item.contentJson) : {};
|
||||
consultationId = contentJson.consultationId || contentJson.consultationRequestId || item.requestId;
|
||||
console.log('BugFix#219: 解析consultationId=', consultationId, 'from contentJson');
|
||||
} catch (e) {
|
||||
console.warn('BugFix#219: 解析contentJson失败, 使用requestId:', item.requestId);
|
||||
}
|
||||
|
||||
console.log('BugFix#219: 作废会诊, consultationId=', consultationId);
|
||||
return cancelConsultation({ consultationId: consultationId, cancelReason: '作废' })
|
||||
.then((res) => {
|
||||
console.log('BugFix#219: 作废成功, res=', res);
|
||||
if (res.code == 200) {
|
||||
proxy.$modal.msgSuccess('会诊申请已作废');
|
||||
return true;
|
||||
} else {
|
||||
proxy.$modal.msgError('作废失败: ' + (res.msg || '未知错误'));
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error('BugFix#219: 作废失败, err=', err);
|
||||
proxy.$modal.msgError('作废失败: ' + (err.message || '网络错误'));
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
Promise.all(deletePromises).then((results) => {
|
||||
// 🔧 BugFix: 作废成功后,立即从列表中移除已作废的会诊医嘱
|
||||
const successCount = results.filter(r => r === true).length;
|
||||
if (successCount > 0) {
|
||||
console.log('BugFix#219: 作废成功', successCount, '条,从列表中移除');
|
||||
// 从 prescriptionList 中移除已作废的会诊医嘱
|
||||
draftConsultations.forEach(item => {
|
||||
const index = prescriptionList.value.findIndex(p => p.uniqueKey === item.uniqueKey);
|
||||
if (index !== -1) {
|
||||
console.log('BugFix#219: 从列表中移除会诊医嘱, index=', index, 'adviceName=', item.adviceName);
|
||||
prescriptionList.value.splice(index, 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
getListInfo(false);
|
||||
});
|
||||
} else {
|
||||
console.log('BugFix#219: 没有符合条件的会诊医嘱可删除');
|
||||
proxy.$modal.msgWarning('所选会诊医嘱不可删除');
|
||||
}
|
||||
}
|
||||
|
||||
// 处理普通医嘱删除
|
||||
if (normalRows.length == 0) {
|
||||
console.log('BugFix#219: 没有普通医嘱需要处理');
|
||||
return;
|
||||
}
|
||||
|
||||
// ... 普通医嘱删除逻辑保持不变
|
||||
|
||||
let deleteList = [];
|
||||
let sum = 0; // 未保存总数量
|
||||
for (let i = prescriptionList.value.length - 1; i >= 0; i--) {
|
||||
let deleteItem = prescriptionList.value[i];
|
||||
let index = selectRows.findIndex((item) => item.uniqueKey === deleteItem.uniqueKey);
|
||||
let index = normalRows.findIndex((item) => item.uniqueKey === deleteItem.uniqueKey);
|
||||
// 通过requestId判断是否已保存,如果选中项未保存 直接从数组中移除,如果已保存,调接口删除
|
||||
if (index != -1 && deleteItem.statusEnum == 1 && !deleteItem.requestId) {
|
||||
prescriptionList.value.splice(i, 1);
|
||||
@@ -2000,10 +2091,14 @@ function handleDelete() {
|
||||
updateExpandOrder([]);
|
||||
isAdding.value = false;
|
||||
adviceQueryParams.value.adviceTypes = undefined; // 🎯 修复:改为 adviceTypes(复数)
|
||||
if (sum == selectRows.length) {
|
||||
|
||||
// 计算未保存的会诊医嘱数量
|
||||
let consultationUnsaved = consultationRows.filter(item => item.statusEnum == 1 && !item.requestId).length;
|
||||
if (sum + consultationUnsaved == selectRows.length) {
|
||||
proxy.$modal.msgSuccess('删除成功');
|
||||
return;
|
||||
}
|
||||
|
||||
if (deleteList.length > 0) {
|
||||
savePrescription({ adviceSaveList: deleteList }).then((res) => {
|
||||
if (res.code == 200) {
|
||||
@@ -2011,7 +2106,7 @@ function handleDelete() {
|
||||
getListInfo(false);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
} else if (consultationRows.length == 0) {
|
||||
proxy.$modal.msgWarning('所选医嘱不可删除,请先撤回后再删除');
|
||||
return;
|
||||
}
|
||||
@@ -3311,26 +3406,122 @@ function escKeyListener(e) {
|
||||
}
|
||||
}
|
||||
|
||||
// 签退
|
||||
// 签退/撤回
|
||||
function handleSingOut() {
|
||||
let selectRows = prescriptionRef.value.getSelectionRows();
|
||||
let requestIdList = selectRows
|
||||
.filter((item) => {
|
||||
return item.statusEnum == 2;
|
||||
})
|
||||
.map((item) => {
|
||||
return item.requestId;
|
||||
});
|
||||
if (requestIdList.length == 0) {
|
||||
proxy.$modal.msgWarning('请选择已签发医嘱撤回');
|
||||
console.log('BugFix#219: handleSingOut called, selectRows=', selectRows);
|
||||
|
||||
if (selectRows.length == 0) {
|
||||
proxy.$modal.msgWarning('请选择要撤回的医嘱');
|
||||
return;
|
||||
}
|
||||
singOut(requestIdList).then((res) => {
|
||||
if (res.code == 200) {
|
||||
proxy.$modal.msgSuccess('操作成功');
|
||||
getListInfo(false);
|
||||
|
||||
// 🔧 BugFix: 检查是否选中了会诊医嘱
|
||||
let consultationRows = selectRows.filter(item => item.adviceType === 5);
|
||||
let normalRows = selectRows.filter(item => item.adviceType !== 5);
|
||||
|
||||
console.log('BugFix#219: consultationRows=', consultationRows.length, 'normalRows=', normalRows.length);
|
||||
|
||||
// 处理会诊医嘱撤回
|
||||
if (consultationRows.length > 0) {
|
||||
console.log('BugFix#219: 处理会诊医嘱撤回');
|
||||
console.log('BugFix#219: 会诊医嘱详情:', consultationRows.map(item => ({
|
||||
adviceType: item.adviceType,
|
||||
statusEnum: item.statusEnum,
|
||||
requestId: item.requestId,
|
||||
adviceName: item.adviceName
|
||||
})));
|
||||
|
||||
// 🔧 BugFix: 放宽条件,只要有requestId的会诊医嘱都可以处理
|
||||
let submittedConsultations = consultationRows.filter(item => item.requestId);
|
||||
console.log('BugFix#219: 可处理的会诊医嘱=', submittedConsultations.length);
|
||||
|
||||
// 处理草稿状态的会诊(直接作废)
|
||||
if (submittedConsultations.length > 0) {
|
||||
console.log('BugFix#219: 开始处理会诊医嘱, 数量=', submittedConsultations.length);
|
||||
let processPromises = submittedConsultations.map(item => {
|
||||
// 🔧 BugFix: 从contentJson中解析consultationId
|
||||
let consultationId = item.requestId;
|
||||
try {
|
||||
const contentJson = item.contentJson ? JSON.parse(item.contentJson) : {};
|
||||
consultationId = contentJson.consultationId || contentJson.consultationRequestId || item.requestId;
|
||||
console.log('BugFix#219: 处理-解析consultationId=', consultationId, 'from contentJson');
|
||||
} catch (e) {
|
||||
console.warn('BugFix#219: 处理-解析contentJson失败, 使用requestId:', item.requestId);
|
||||
}
|
||||
|
||||
// 根据状态决定操作类型
|
||||
const isSubmitted = item.statusEnum == 2;
|
||||
const cancelReason = isSubmitted ? '取消提交' : '作废';
|
||||
const successMsg = isSubmitted ? '会诊申请已撤回' : '会诊申请已作废';
|
||||
|
||||
console.log('BugFix#219: 处理会诊, consultationId=', consultationId, 'statusEnum=', item.statusEnum, 'cancelReason=', cancelReason);
|
||||
|
||||
return cancelConsultation({ consultationId: consultationId, cancelReason: cancelReason })
|
||||
.then((res) => {
|
||||
console.log('BugFix#219: 处理会诊成功, res=', res);
|
||||
if (res.code == 200) {
|
||||
proxy.$modal.msgSuccess(successMsg);
|
||||
return true;
|
||||
} else {
|
||||
proxy.$modal.msgError('操作失败: ' + (res.msg || '未知错误'));
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error('BugFix#219: 处理会诊失败, err=', err);
|
||||
proxy.$modal.msgError('操作失败: ' + (err.message || '网络错误'));
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
Promise.all(processPromises).then((results) => {
|
||||
// 🔧 BugFix: 操作成功后,立即从列表中移除已处理(作废/撤回)的会诊医嘱
|
||||
const successCount = results.filter(r => r === true).length;
|
||||
if (successCount > 0) {
|
||||
console.log('BugFix#219: 会诊医嘱处理成功', successCount, '条,从列表中移除');
|
||||
// 从 prescriptionList 中移除已处理的会诊医嘱
|
||||
submittedConsultations.forEach(item => {
|
||||
const index = prescriptionList.value.findIndex(p => p.uniqueKey === item.uniqueKey);
|
||||
if (index !== -1) {
|
||||
console.log('BugFix#219: 从列表中移除会诊医嘱, index=', index, 'adviceName=', item.adviceName);
|
||||
prescriptionList.value.splice(index, 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
getListInfo(false);
|
||||
});
|
||||
} else {
|
||||
console.log('BugFix#219: 没有可处理的会诊医嘱');
|
||||
proxy.$modal.msgWarning('所选会诊医嘱不可撤回');
|
||||
}
|
||||
});
|
||||
|
||||
// 如果没有普通医嘱,直接返回
|
||||
if (normalRows.length == 0) {
|
||||
console.log('BugFix#219: 没有普通医嘱需要处理,返回');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 处理普通医嘱撤回
|
||||
if (normalRows.length > 0) {
|
||||
let requestIdList = normalRows
|
||||
.filter((item) => item.statusEnum == 2)
|
||||
.map((item) => item.requestId);
|
||||
|
||||
if (requestIdList.length == 0) {
|
||||
proxy.$modal.msgWarning('所选普通医嘱无可撤回项');
|
||||
return;
|
||||
}
|
||||
|
||||
singOut(requestIdList).then((res) => {
|
||||
if (res.code == 200) {
|
||||
proxy.$modal.msgSuccess('操作成功');
|
||||
getListInfo(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
prescriptionRef.value.clearSelection();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user