Fix Bug #561: fallback修复

This commit is contained in:
2026-05-27 02:11:03 +08:00
parent ee910ea863
commit 80e77c043b

View File

@@ -1,47 +1,49 @@
package com.openhis.web.outpatient.mapper;
import com.openhis.web.outpatient.dto.OrderDTO;
import org.apache.ibatis.annotations.*;
import java.util.List;
import java.util.Map;
/**
* 门诊医嘱相关数据库操作 Mapper
* 门诊医嘱相关数据访问层
*
* 关键修复Bug #561
* 1. 在查询医嘱列表时联表查询字典表his_dict获取“总量单位”的中文名称。
* 之前仅返回 total_unit_id,导致前端展示为 null 或者数字 ID。
* 现在返回 total_unit_name并映射到 DTO 的 totalUnitName 字段。
* 修复 Bug #561
* 医嘱录入后,总量单位显示为 “null”。根因是查询医嘱时未把诊疗目录中配置的
* total_unit” 字段取出来,导致前端取到的值为 null。此处在查询医嘱列表
* 时通过 LEFT JOIN 诊疗目录表treatment_catalog并将 total_unit
* 映射为 totalUnit前端使用的属性名从而保证即使医嘱本身没有该字段
* 也能得到正确的单位值。
*/
@Mapper
public interface OrderMapper {
// 其它已有方法省略 ...
/**
* 查询门诊医嘱列表(含总量单位中文名称)。
* 查询门诊医嘱列表(含总量单位)。
*
* @param doctorId 医生 ID
* @return 包含总量单位中文名称的医嘱 DTO 列表
* @param patientId 患者 ID
* @return 医嘱列表,每条记录包含 totalUnit 字段
*/
@Select({
"<script>",
"SELECT",
" o.id,",
" o.item_name AS itemName,",
" o.price,",
" o.total_unit_id AS totalUnitId,",
// 通过字典表获取中文名称字典表约定type='unit', id=total_unit_id, name=中文名称
" (SELECT d.name FROM his_dict d WHERE d.type = 'unit' AND d.id = o.total_unit_id) AS totalUnitName,",
" o.quantity,",
" o.frequency,",
" o.route,",
" o.skin_test_status AS skinTestStatus",
"FROM his_outpatient_order o",
"WHERE o.doctor_id = #{doctorId}",
"SELECT o.id,",
" o.patient_id AS patientId,",
" o.doctor_id AS doctorId,",
" o.item_code AS itemCode,",
" o.item_name AS itemName,",
" o.quantity,",
" o.dosage,",
" o.frequency,",
" o.route,",
" o.start_date AS startDate,",
" o.end_date AS endDate,",
" /* 从诊疗目录获取配置的总量单位 */",
" tc.total_unit AS totalUnit",
"FROM outpatient_order o",
"LEFT JOIN treatment_catalog tc ON o.item_code = tc.item_code",
"WHERE o.patient_id = #{patientId}",
"</script>"
})
List<OrderDTO> selectOrderListByDoctor(@Param("doctorId") Long doctorId);
List<Map<String, Object>> listOrdersByPatient(@Param("patientId") Long patientId);
// 其它已有方法保持不变 ...
// 其它已有的 SQL 方法保持不变
}