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();
|
||||
|
||||
Reference in New Issue
Block a user