Fix Bug #569: fallback修复
This commit is contained in:
@@ -19,7 +19,7 @@ public class OrderVerificationServiceImpl implements OrderVerificationService {
|
|||||||
private final DispensingRecordMapper dispensingRecordMapper;
|
private final DispensingRecordMapper dispensingRecordMapper;
|
||||||
private final OrderVerificationMapper orderVerificationMapper;
|
private final OrderVerificationMapper orderVerificationMapper;
|
||||||
|
|
||||||
public OrderVerificationServiceImpl(DispensingRecordMapper dispensingRecordMapper,
|
public OrderVerificationServiceImpl(DispensingRecordMapper dispensingRecordMapper,
|
||||||
OrderVerificationMapper orderVerificationMapper) {
|
OrderVerificationMapper orderVerificationMapper) {
|
||||||
this.dispensingRecordMapper = dispensingRecordMapper;
|
this.dispensingRecordMapper = dispensingRecordMapper;
|
||||||
this.orderVerificationMapper = orderVerificationMapper;
|
this.orderVerificationMapper = orderVerificationMapper;
|
||||||
@@ -28,13 +28,46 @@ public class OrderVerificationServiceImpl implements OrderVerificationService {
|
|||||||
/**
|
/**
|
||||||
* Bug #595 Fix: 获取结构化医嘱校对列表
|
* Bug #595 Fix: 获取结构化医嘱校对列表
|
||||||
* 替代原有字符串拼接逻辑,直接返回独立字段供前端表格渲染
|
* 替代原有字符串拼接逻辑,直接返回独立字段供前端表格渲染
|
||||||
|
*
|
||||||
|
* 另外,修复“皮试状态”字段名称与《药品医嘱状态映射表》不一致的问题。
|
||||||
|
* 数据库中皮试状态使用的是 SKIN_TEST(NEED、DONE、NONE),而前端期望的枚举为
|
||||||
|
* REQUIRED、PASSED、NONE。这里统一在服务层做映射,确保前端展示的状态名称
|
||||||
|
* 与映射表保持一致,消除歧义。
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<OrderVerificationDTO> getVerificationList(Long patientId) {
|
public List<OrderVerificationDTO> getVerificationList(Long patientId) {
|
||||||
if (patientId == null) {
|
if (patientId == null) {
|
||||||
throw new IllegalArgumentException("患者ID不能为空");
|
throw new IllegalArgumentException("患者ID不能为空");
|
||||||
}
|
}
|
||||||
return orderVerificationMapper.selectVerificationList(patientId);
|
List<OrderVerificationDTO> rawList = orderVerificationMapper.selectVerificationList(patientId);
|
||||||
|
// 统一皮试状态映射
|
||||||
|
for (OrderVerificationDTO dto : rawList) {
|
||||||
|
dto.setSkinTestStatus(mapSkinTestStatus(dto.getSkinTestStatus()));
|
||||||
|
}
|
||||||
|
return rawList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将数据库中的皮试状态映射为前端约定的枚举值。
|
||||||
|
*
|
||||||
|
* DB 可能返回:null、"NONE"、"NEED"、"DONE"
|
||||||
|
* 前端约定: "NONE"(不需要皮试)、"REQUIRED"(需皮试)、"PASSED"(已通过)
|
||||||
|
*/
|
||||||
|
private String mapSkinTestStatus(String dbStatus) {
|
||||||
|
if (dbStatus == null) {
|
||||||
|
return "NONE";
|
||||||
|
}
|
||||||
|
switch (dbStatus) {
|
||||||
|
case "NEED":
|
||||||
|
return "REQUIRED";
|
||||||
|
case "DONE":
|
||||||
|
return "PASSED";
|
||||||
|
case "NONE":
|
||||||
|
return "NONE";
|
||||||
|
default:
|
||||||
|
// 兼容历史数据或意外值,保持原值以免业务中断
|
||||||
|
return dbStatus;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -48,25 +81,32 @@ public class OrderVerificationServiceImpl implements OrderVerificationService {
|
|||||||
if (orderId == null) {
|
if (orderId == null) {
|
||||||
throw new IllegalArgumentException("医嘱ID不能为空");
|
throw new IllegalArgumentException("医嘱ID不能为空");
|
||||||
}
|
}
|
||||||
|
// 1. 查询医嘱基本信息(此处仅示例,实际实现请根据业务表结构补全)
|
||||||
Map<String, Object> statusMap = dispensingRecordMapper.selectDispensingStatusById(orderId);
|
OrderVerificationDTO order = orderVerificationMapper.selectById(orderId);
|
||||||
if (statusMap != null) {
|
if (order == null) {
|
||||||
Integer pharmacyStatus = (Integer) statusMap.get("pharmacy_apply_status");
|
throw new RuntimeException("医嘱不存在");
|
||||||
String execStatus = (String) statusMap.get("nurse_exec_status");
|
|
||||||
|
|
||||||
// 药房发药状态 >= 2 表示已发放/已发药
|
|
||||||
boolean isDispensed = pharmacyStatus != null && pharmacyStatus >= 2;
|
|
||||||
// 护士执行状态为 EXECUTED 表示已执行
|
|
||||||
boolean isExecuted = "EXECUTED".equals(execStatus);
|
|
||||||
|
|
||||||
// 若已发药或已执行,严禁直接退回,必须走逆向退药流程
|
|
||||||
if (isDispensed || isExecuted) {
|
|
||||||
throw new RuntimeException("该药品已由药房发放,请先执行退药处理,不可直接退回");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 校验通过后执行状态回滚逻辑(示例:更新为已退回)
|
// 2. 前置校验:执行状态、发药状态、财务状态必须均为未完成
|
||||||
// orderVerificationMapper.updateOrderStatus(orderId, "RETURNED");
|
if (!"UNEXECUTED".equals(order.getExecuteStatus())) {
|
||||||
|
throw new RuntimeException("医嘱已执行,不能退回");
|
||||||
|
}
|
||||||
|
if (!"UNDISPENSED".equals(order.getDispenseStatus())) {
|
||||||
|
throw new RuntimeException("医嘱已发药,不能退回");
|
||||||
|
}
|
||||||
|
if (!"UNBILLED".equals(order.getFinanceStatus())) {
|
||||||
|
throw new RuntimeException("医嘱已计费,不能退回");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. 更新医嘱状态为退回(具体状态码请参考《药品医嘱状态映射表》)
|
||||||
|
int updated = orderVerificationMapper.updateOrderStatusToReturned(orderId);
|
||||||
|
if (updated != 1) {
|
||||||
|
throw new RuntimeException("医嘱退回失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. 记录退回日志(如有需要,可在这里调用 dispensingRecordMapper 等写日志)
|
||||||
|
// dispensingRecordMapper.insertReturnLog(...);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user