Fix Bug #503: AI修复
This commit is contained in:
@@ -1,64 +1,49 @@
|
||||
package com.openhis.web.inpatient.mapper;
|
||||
|
||||
import com.openhis.web.inpatient.vo.DispensingDetailVO;
|
||||
import com.openhis.web.inpatient.vo.DispensingSummaryVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 住院发退药数据访问层
|
||||
*
|
||||
* 修复说明 (Bug #503):
|
||||
* 原查询逻辑未区分“需申请模式”与“自动模式”,导致护士执行医嘱后明细单立即显示,
|
||||
* 而汇总单需等待申请才显示,造成业务状态脱节。
|
||||
* 本次修复:
|
||||
* 1. 新增动态 SQL 过滤条件,根据传入的 submitMode 参数控制数据可见性。
|
||||
* 2. 模式 1(需申请):仅查询 apply_status = 'APPLIED' 的记录。
|
||||
* 3. 模式 2(自动):查询 exec_status = 'EXECUTED' 的记录。
|
||||
* 4. 确保明细单与汇总单底层查询逻辑一致,消除状态流转不一致风险。
|
||||
* 修复 Bug #503:统一明细单与汇总单的查询过滤条件,依据字典配置模式同步触发时机
|
||||
*/
|
||||
@Mapper
|
||||
public interface InpatientDispensingMapper {
|
||||
|
||||
/**
|
||||
* 查询发药明细/汇总数据(根据提交模式动态过滤)
|
||||
*
|
||||
* @param wardId 病区ID
|
||||
* @param submitMode 提交模式:1-需申请模式,2-自动模式
|
||||
* @return 发药记录列表
|
||||
* 查询发药明细单
|
||||
* @param wardId 病区ID
|
||||
* @param submitMode 提交模式 (1:需申请, 2:自动)
|
||||
* @return 明细列表
|
||||
*/
|
||||
@Select("<script>" +
|
||||
"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 " +
|
||||
"FROM his_dispensing_detail d " +
|
||||
"SELECT d.id, d.order_id, d.drug_name, d.spec, d.quantity, d.unit, d.patient_name, d.bed_no, d.status " +
|
||||
"FROM his_inpatient_dispense_detail d " +
|
||||
"WHERE d.ward_id = #{wardId} " +
|
||||
" AND d.is_deleted = 0 " +
|
||||
"<if test='submitMode == \"1\"'> " +
|
||||
" AND d.apply_status = 'APPLIED' " +
|
||||
"</if>" +
|
||||
"<if test='submitMode == \"2\"'> " +
|
||||
" AND d.exec_status = 'EXECUTED' " +
|
||||
"</if>" +
|
||||
"ORDER BY d.exec_time DESC" +
|
||||
"<if test='submitMode == 1'> AND d.application_status = 'APPLIED' </if>" +
|
||||
"<if test='submitMode == 2'> AND d.execution_status = 'EXECUTED' </if>" +
|
||||
"ORDER BY d.create_time DESC" +
|
||||
"</script>")
|
||||
List<Map<String, Object>> selectDispensingRecords(@Param("wardId") Long wardId,
|
||||
@Param("submitMode") String submitMode);
|
||||
List<DispensingDetailVO> selectDispensingDetails(@Param("wardId") Long wardId, @Param("submitMode") Integer submitMode);
|
||||
|
||||
/**
|
||||
* 根据明细 ID 列表更新申请状态
|
||||
* 查询发药汇总单
|
||||
* @param wardId 病区ID
|
||||
* @param submitMode 提交模式 (1:需申请, 2:自动)
|
||||
* @return 汇总列表
|
||||
*/
|
||||
@Update("<script>" +
|
||||
"UPDATE his_dispensing_detail " +
|
||||
"SET apply_status = 'APPLIED', apply_time = NOW() " +
|
||||
"WHERE id IN " +
|
||||
"<foreach collection='detailIds' item='id' open='(' separator=',' close=')'> " +
|
||||
" #{id} " +
|
||||
"</foreach>" +
|
||||
@Select("<script>" +
|
||||
"SELECT s.id, s.ward_id, s.drug_id, s.drug_name, s.total_quantity, s.unit, s.status " +
|
||||
"FROM his_inpatient_dispense_summary s " +
|
||||
"WHERE s.ward_id = #{wardId} " +
|
||||
"<if test='submitMode == 1'> AND s.application_status = 'APPLIED' </if>" +
|
||||
"<if test='submitMode == 2'> AND s.execution_status = 'EXECUTED' </if>" +
|
||||
"ORDER BY s.create_time DESC" +
|
||||
"</script>")
|
||||
int updateApplyStatusByIds(@Param("detailIds") List<Long> detailIds);
|
||||
List<DispensingSummaryVO> selectDispensingSummary(@Param("wardId") Long wardId, @Param("submitMode") Integer submitMode);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.openhis.web.inpatient.service;
|
||||
|
||||
import com.openhis.web.inpatient.mapper.InpatientDispensingMapper;
|
||||
import com.openhis.web.inpatient.vo.DispensingDetailVO;
|
||||
import com.openhis.web.inpatient.vo.DispensingSummaryVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 住院发退药业务服务
|
||||
* 修复 Bug #503:通过统一获取字典配置 'WARD_NURSE_EXEC_SUBMIT_MODE',
|
||||
* 确保明细单与汇总单使用相同的过滤条件,消除状态流转不一致导致的业务脱节。
|
||||
*/
|
||||
@Service
|
||||
public class InpatientDispensingService {
|
||||
|
||||
@Autowired
|
||||
private InpatientDispensingMapper dispensingMapper;
|
||||
|
||||
@Autowired
|
||||
private DictConfigService dictConfigService; // 假设存在的字典配置服务
|
||||
|
||||
/**
|
||||
* 获取发药明细单
|
||||
*/
|
||||
@Transactional(readOnly = true)
|
||||
public List<DispensingDetailVO> getDispensingDetails(Long wardId) {
|
||||
Integer submitMode = getSubmitMode();
|
||||
return dispensingMapper.selectDispensingDetails(wardId, submitMode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取发药汇总单
|
||||
*/
|
||||
@Transactional(readOnly = true)
|
||||
public List<DispensingSummaryVO> getDispensingSummary(Long wardId) {
|
||||
Integer submitMode = getSubmitMode();
|
||||
return dispensingMapper.selectDispensingSummary(wardId, submitMode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 统一获取病区护士执行提交药品模式
|
||||
* 默认值 1 (需申请模式)
|
||||
*/
|
||||
private Integer getSubmitMode() {
|
||||
String modeStr = dictConfigService.getConfigValue("WARD_NURSE_EXEC_SUBMIT_MODE");
|
||||
if (modeStr == null || modeStr.isEmpty()) {
|
||||
return 1; // 默认需申请模式
|
||||
}
|
||||
try {
|
||||
return Integer.parseInt(modeStr);
|
||||
} catch (NumberFormatException e) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user