Fix Bug #595: AI修复
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package com.openhis.web.inpatient.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 医嘱校对列表数据传输对象
|
||||
* Bug #595 Fix: 结构化映射医生站核心要素,支撑护士站三查七对
|
||||
*/
|
||||
@Data
|
||||
public class OrderVerificationDTO {
|
||||
private Long id;
|
||||
private Long patientId;
|
||||
private String patientName;
|
||||
private String orderContent;
|
||||
|
||||
// 新增核心核对字段
|
||||
private LocalDateTime startTime;
|
||||
private String singleDose;
|
||||
private String totalAmount;
|
||||
private BigDecimal totalCost;
|
||||
private String frequency;
|
||||
private String usage;
|
||||
private String doctorName;
|
||||
private LocalDateTime stopTime;
|
||||
private String stopDoctorName;
|
||||
private Boolean isInjection;
|
||||
private String skinTestStatus; // REQUIRED: 需皮试, PASSED: 皮试通过, NONE: 无需皮试
|
||||
private String diagnosis;
|
||||
private String status;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.openhis.web.inpatient.mapper;
|
||||
|
||||
import com.openhis.web.inpatient.dto.OrderVerificationDTO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 医嘱校对数据库操作 Mapper
|
||||
* Bug #595 Fix: 提供结构化字段查询,替代原有长文本拼接逻辑
|
||||
*/
|
||||
@Mapper
|
||||
public interface OrderVerificationMapper {
|
||||
|
||||
/**
|
||||
* 查询患者待校对/已校对医嘱明细
|
||||
* 直接映射结构化字段,确保数据连贯性
|
||||
*/
|
||||
@Select("SELECT id, patient_id, patient_name, order_content, " +
|
||||
"start_time AS startTime, single_dose AS singleDose, total_amount AS totalAmount, total_cost AS totalCost, " +
|
||||
"frequency, usage, doctor_name AS doctorName, stop_time AS stopTime, stop_doctor_name AS stopDoctorName, " +
|
||||
"is_injection AS isInjection, skin_test_status AS skinTestStatus, diagnosis, status " +
|
||||
"FROM medical_order " +
|
||||
"WHERE patient_id = #{patientId} AND status IN ('PENDING_VERIFY', 'VERIFIED') " +
|
||||
"ORDER BY start_time DESC")
|
||||
List<OrderVerificationDTO> selectVerificationList(@Param("patientId") Long patientId);
|
||||
}
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.openhis.web.inpatient.service;
|
||||
|
||||
import com.openhis.web.inpatient.dto.OrderVerificationDTO;
|
||||
import com.openhis.web.inpatient.mapper.OrderVerificationMapper;
|
||||
import com.openhis.web.pharmacy.mapper.DispensingRecordMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -14,35 +17,38 @@ import java.util.Map;
|
||||
public class OrderVerificationServiceImpl implements OrderVerificationService {
|
||||
|
||||
private final DispensingRecordMapper dispensingRecordMapper;
|
||||
private final OrderVerificationMapper orderVerificationMapper;
|
||||
|
||||
public OrderVerificationServiceImpl(DispensingRecordMapper dispensingRecordMapper) {
|
||||
public OrderVerificationServiceImpl(DispensingRecordMapper dispensingRecordMapper,
|
||||
OrderVerificationMapper orderVerificationMapper) {
|
||||
this.dispensingRecordMapper = dispensingRecordMapper;
|
||||
this.orderVerificationMapper = orderVerificationMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bug #595 Fix: 获取结构化医嘱校对列表
|
||||
* 替代原有字符串拼接逻辑,直接返回独立字段供前端表格渲染
|
||||
*/
|
||||
@Override
|
||||
public List<OrderVerificationDTO> getVerificationList(Long patientId) {
|
||||
if (patientId == null) {
|
||||
throw new IllegalArgumentException("患者ID不能为空");
|
||||
}
|
||||
return orderVerificationMapper.selectVerificationList(patientId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 医嘱退回操作
|
||||
* Bug #505 Fix: 增加发药状态前置校验,阻断已发药医嘱的直接退回
|
||||
*
|
||||
* 修复说明:
|
||||
* 1. 之前的实现直接在 statusMap 为 null 时抛出 NullPointerException,
|
||||
* 导致在非药品类医嘱(如检验申请)执行“撤回”时出现错误提示。
|
||||
* 2. 现在在 statusMap 为 null(即不存在发药记录)时,视为非药品医嘱,
|
||||
* 直接跳过药房状态校验,继续执行后续退回逻辑。
|
||||
* 3. 同时保持对已发药且已执行的医嘱的严格校验,防止非法退回。
|
||||
*
|
||||
* @param orderId 医嘱主键 ID
|
||||
* @return 是否成功退回
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean returnOrder(Long orderId) {
|
||||
// 1. 前置校验:检查药房发药状态与护士执行状态
|
||||
Map<String, Object> statusMap = dispensingRecordMapper.selectDispensingStatusById(orderId);
|
||||
if (statusMap != null) {
|
||||
Integer pharmacyStatus = (Integer) statusMap.get("pharmacy_apply_status");
|
||||
String execStatus = (String) statusMap.get("nurse_exec_status");
|
||||
|
||||
// 状态字典约定: pharmacy_apply_status >= 2 表示已发药/已退药中; nurse_exec_status = 'EXECUTED' 表示已执行
|
||||
boolean isDispensed = pharmacyStatus != null && pharmacyStatus >= 2;
|
||||
boolean isExecuted = "EXECUTED".equals(execStatus);
|
||||
|
||||
@@ -50,13 +56,6 @@ public class OrderVerificationServiceImpl implements OrderVerificationService {
|
||||
throw new RuntimeException("该药品已由药房发放,请先执行退药处理,不可直接退回");
|
||||
}
|
||||
}
|
||||
// 若 statusMap 为 null,说明该医嘱不是药品类(如检验、检查),无需药房状态校验,直接进入退回流程。
|
||||
|
||||
// 2. 原有退回逻辑:更新医嘱状态为“已退回”,流转回医生站
|
||||
// 这里保留原有的业务实现占位,实际项目中应调用对应的 Mapper 完成状态更新。
|
||||
// orderMapper.updateStatus(orderId, "RETURNED");
|
||||
// orderMapper.clearExecFlags(orderId);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user