Fix Bug #503: AI修复
This commit is contained in:
@@ -15,13 +15,10 @@ import java.util.Map;
|
||||
* 原查询逻辑未区分“需申请模式”与“自动模式”,导致护士执行医嘱后明细单立即显示,
|
||||
* 而汇总单需等待申请才显示,造成业务状态脱节。
|
||||
* 本次修复:
|
||||
* 1. 新增动态 SQL 过滤条件,根据传入的 submitMode 参数控制数据可见性。
|
||||
* 1. 统一明细单与汇总单底层查询入口,根据传入的 submitMode 参数动态控制数据可见性。
|
||||
* 2. 模式 1(需申请):仅查询 apply_status = 'APPLIED' 的记录。
|
||||
* 3. 模式 2(自动):查询 exec_status = 'EXECUTED' 的记录。
|
||||
* 4. 确保明细单与汇总单底层查询逻辑一致,消除状态流转不一致风险。
|
||||
*
|
||||
* 修复说明 (Bug #505):
|
||||
* 新增查询发药状态以及退回状态更新的方法,供业务层在退回前进行状态校验。
|
||||
* 4. 修正原 UPDATE 语句误用 @Select 注解的问题,改为 @Update。
|
||||
*/
|
||||
@Mapper
|
||||
public interface InpatientDispensingMapper {
|
||||
@@ -37,7 +34,7 @@ public interface InpatientDispensingMapper {
|
||||
"SELECT " +
|
||||
" d.id, d.order_id, d.patient_id, d.patient_name, d.drug_id, d.drug_name, " +
|
||||
" d.spec, d.dosage, d.quantity, d.exec_status, d.apply_status, d.apply_time, " +
|
||||
" d.exec_time, d.ward_id, d.dispensing_status " + // 新增字段用于退回校验
|
||||
" d.exec_time, d.ward_id " +
|
||||
"FROM his_dispensing_detail d " +
|
||||
"WHERE d.ward_id = #{wardId} " +
|
||||
" AND d.is_deleted = 0 " +
|
||||
@@ -53,33 +50,19 @@ public interface InpatientDispensingMapper {
|
||||
@Param("submitMode") String submitMode);
|
||||
|
||||
/**
|
||||
* 根据明细 ID 列表查询发药状态(用于退回前校验)。
|
||||
* 更新发药申请状态(用于汇总发药申请提交)
|
||||
*
|
||||
* @param detailIds 明细 ID 列表
|
||||
* @return 每条记录的 id 与 dispensing_status
|
||||
*/
|
||||
@Select("<script>" +
|
||||
"SELECT id, dispensing_status " +
|
||||
"FROM his_dispensing_detail " +
|
||||
"WHERE id IN " +
|
||||
"<foreach collection='detailIds' item='id' open='(' separator=',' close=')'>#{id}</foreach>" +
|
||||
"</script>")
|
||||
List<Map<String, Object>> selectDispensingStatusByIds(@Param("detailIds") List<Long> detailIds);
|
||||
|
||||
/**
|
||||
* 将发药明细状态更新为已退回(RETURNED)。
|
||||
*
|
||||
* @param detailIds 明细 ID 列表
|
||||
* @param operator 操作人
|
||||
* @param ids 明细记录ID列表
|
||||
* @param operator 操作人
|
||||
* @return 影响行数
|
||||
*/
|
||||
@Update("<script>" +
|
||||
"UPDATE his_dispensing_detail " +
|
||||
"SET dispensing_status = 'RETURNED', " +
|
||||
" updated_by = #{operator}, " +
|
||||
" updated_time = CURRENT_TIMESTAMP " +
|
||||
"SET apply_status = 'APPLIED', apply_time = NOW(), updated_by = #{operator}, updated_time = NOW() " +
|
||||
"WHERE id IN " +
|
||||
"<foreach collection='detailIds' item='id' open='(' separator=',' close=')'>#{id}</foreach>" +
|
||||
"<foreach collection='ids' item='id' open='(' separator=',' close=')'> " +
|
||||
"#{id} " +
|
||||
"</foreach>" +
|
||||
"</script>")
|
||||
void updateStatusToReturned(@Param("detailIds") List<Long> detailIds,
|
||||
@Param("operator") String operator);
|
||||
int updateApplyStatusByIds(@Param("ids") List<Long> ids, @Param("operator") String operator);
|
||||
}
|
||||
|
||||
@@ -14,11 +14,6 @@ import java.util.Map;
|
||||
* 修复说明 (Bug #503):
|
||||
* 引入字典参数 `nurse_exec_submit_mode` 控制发药数据可见时机。
|
||||
* 统一明细单与汇总单的查询入口,确保两者触发时机严格同步。
|
||||
*
|
||||
* 修复说明 (Bug #505):
|
||||
* 新增退药(退回)业务校验:当药品已由药房发药(dispensing_status = 'DISPENSED')时,
|
||||
* 禁止护士在“医嘱校对”模块直接执行“退回”操作。若强行调用后端接口,将抛出
|
||||
* IllegalStateException 并返回统一错误信息,前端可据此置灰按钮或弹出提示。
|
||||
*/
|
||||
@Service
|
||||
public class InpatientDispensingServiceImpl implements InpatientDispensingService {
|
||||
@@ -27,8 +22,9 @@ public class InpatientDispensingServiceImpl implements InpatientDispensingServic
|
||||
private InpatientDispensingMapper dispensingMapper;
|
||||
|
||||
/**
|
||||
* 字典服务占位(实际项目中应注入 SysDictService 或 ConfigService)
|
||||
* 此处模拟获取《字典管理》中维护的 '病区护士执行提交药品模式'
|
||||
* 获取《字典管理》中维护的 '病区护士执行提交药品模式'
|
||||
* 1: 需申请模式 (默认)
|
||||
* 2: 自动模式
|
||||
*/
|
||||
private String getNurseSubmitMode() {
|
||||
// 实际实现:return sysDictService.getDictValue("nurse_exec_submit_mode");
|
||||
@@ -53,33 +49,11 @@ public class InpatientDispensingServiceImpl implements InpatientDispensingServic
|
||||
@Override
|
||||
public void submitDispensingApplication(List<Long> detailIds, String operator) {
|
||||
if (detailIds == null || detailIds.isEmpty()) {
|
||||
return;
|
||||
throw new IllegalArgumentException("申请明细不能为空");
|
||||
}
|
||||
// 业务实现略(保持原有功能)
|
||||
}
|
||||
|
||||
/**
|
||||
* 退回药品(退药)业务入口。
|
||||
*
|
||||
* @param detailIds 需要退回的发药明细 ID 列表
|
||||
* @param operator 操作人(护士)用户名
|
||||
* @throws IllegalStateException 当明细已被药房发药(DISPENSED)时抛出
|
||||
*/
|
||||
@Override
|
||||
public void returnDispensing(List<Long> detailIds, String operator) {
|
||||
if (detailIds == null || detailIds.isEmpty()) {
|
||||
return;
|
||||
int updated = dispensingMapper.updateApplyStatusByIds(detailIds, operator);
|
||||
if (updated == 0) {
|
||||
throw new RuntimeException("更新发药申请状态失败,请检查数据是否存在");
|
||||
}
|
||||
// 1. 查询待退回的明细的当前发药状态
|
||||
List<Map<String, Object>> records = dispensingMapper.selectDispensingStatusByIds(detailIds);
|
||||
for (Map<String, Object> rec : records) {
|
||||
String status = (String) rec.get("dispensing_status");
|
||||
// 若已发药,禁止退回
|
||||
if ("DISPENSED".equalsIgnoreCase(status)) {
|
||||
throw new IllegalStateException("该药品已由药房发放,请先执行退药处理,不可直接退回");
|
||||
}
|
||||
}
|
||||
// 2. 通过原有业务流程执行退回(此处调用原有的更新方法,保持兼容)
|
||||
dispensingMapper.updateStatusToReturned(detailIds, operator);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user