370【住院护士站站-》进入“三测单”模块报错
371 【业务配置】住院医生站-“呼吸内科病房”未在西药房取药规则中维护配置
This commit is contained in:
@@ -46,7 +46,7 @@
|
||||
abi.chrgitm_lv
|
||||
FROM (
|
||||
<!-- 确保至少有一个查询被执行以避免语法错误 -->
|
||||
<if test="adviceTypes != null and !adviceTypes.isEmpty() and (adviceTypes.contains(1) or adviceTypes.contains(2) or adviceTypes.contains(3))">
|
||||
<if test="adviceTypes != null and !adviceTypes.isEmpty() and (adviceTypes.contains(1) or adviceTypes.contains(2) or adviceTypes.contains(3) or adviceTypes.contains(6))">
|
||||
<!-- 如果有有效的adviceTypes,则执行对应的查询 -->
|
||||
<if test="adviceTypes.contains(1)">
|
||||
(SELECT
|
||||
@@ -95,14 +95,29 @@
|
||||
AND T2.delete_flag = '0' AND T2.status_enum = #{statusEnum}
|
||||
LEFT JOIN adm_supplier AS T3 ON T3.ID = t1.supply_id AND T3.delete_flag = '0'
|
||||
LEFT JOIN adm_charge_item_definition AS T5 ON T5.instance_id = t1.ID AND T5.delete_flag = '0' AND T5.status_enum = #{statusEnum}
|
||||
LEFT JOIN adm_organization_location AS T6 ON T6.distribution_category_code = t1.category_code AND T6.delete_flag = '0' AND T6.item_code = '1' AND T6.organization_id = #{organizationId} AND (CURRENT_TIME :: time (6) BETWEEN T6.start_time AND T6.end_time)
|
||||
INNER JOIN adm_organization_location AS T6 ON T6.distribution_category_code = t1.category_code AND T6.delete_flag = '0' AND T6.item_code = '1' AND T6.organization_id = #{organizationId} AND (CURRENT_TIME :: time (6) BETWEEN T6.start_time AND T6.end_time)
|
||||
WHERE t1.delete_flag = '0'
|
||||
AND T2.status_enum = #{statusEnum}
|
||||
<if test="pricingFlag == 1">
|
||||
AND 1 = 2
|
||||
</if>
|
||||
<if test="categoryCode != null and categoryCode != ''">
|
||||
AND t1.category_code = #{categoryCode}
|
||||
<!-- 🔧 BugFix: 支持两种匹配方式 -->
|
||||
<!-- 1. 直接匹配:distribution_category_code = category_code(都是数字代码) -->
|
||||
<!-- 2. 字典转换匹配:通过 sys_dict_data 表将 distribution_category_code(中文)转换为 category_code(数字代码) -->
|
||||
AND (
|
||||
-- 方式1:直接匹配
|
||||
t1.category_code = #{categoryCode}
|
||||
OR
|
||||
-- 方式2:通过字典转换匹配(当 distribution_category_code 存储的是中文时)
|
||||
EXISTS (
|
||||
SELECT 1 FROM sys_dict_data sdd
|
||||
WHERE sdd.dict_type = 'med_category_code'
|
||||
AND sdd.status = '0'
|
||||
AND sdd.dict_label = T6.distribution_category_code
|
||||
AND sdd.dict_value = #{categoryCode}
|
||||
)
|
||||
)
|
||||
</if>
|
||||
<if test="searchKey != null and searchKey != ''">
|
||||
AND (t1.name ILIKE '%' || #{searchKey} || '%' OR t1.py_str ILIKE '%' || #{searchKey} || '%')
|
||||
@@ -185,11 +200,15 @@
|
||||
<if test="adviceTypes.contains(3)">UNION ALL</if>
|
||||
</if>
|
||||
|
||||
<if test="adviceTypes.contains(3)">
|
||||
<if test="adviceTypes.contains(3) or adviceTypes.contains(6)">
|
||||
(SELECT
|
||||
DISTINCT ON (T1.ID)
|
||||
T1.tenant_id,
|
||||
3 AS advice_type,
|
||||
<choose>
|
||||
<when test="adviceTypes.contains(3) and adviceTypes.contains(6)">CASE T1.category_code WHEN '手术' THEN 6 WHEN '24' THEN 6 ELSE 3 END</when>
|
||||
<when test="adviceTypes.contains(6)">6</when>
|
||||
<otherwise>3</otherwise>
|
||||
</choose> AS advice_type,
|
||||
T1.bus_no AS bus_no,
|
||||
T1.category_code AS category_code,
|
||||
'' AS pharmacology_category_code,
|
||||
@@ -213,7 +232,7 @@
|
||||
WHEN '检验' THEN 1
|
||||
WHEN '检查' THEN 2
|
||||
WHEN '护理' THEN 3
|
||||
WHEN '手术' THEN 4
|
||||
WHEN '手术' THEN 4 WHEN '24' THEN 4
|
||||
WHEN '其他' THEN 5
|
||||
ELSE 0
|
||||
END AS activity_type,
|
||||
@@ -250,6 +269,14 @@
|
||||
<if test="pricingFlag != null">
|
||||
AND (t1.pricing_flag = #{pricingFlag} OR t1.pricing_flag IS NULL)
|
||||
</if>
|
||||
<!-- 如果只选择手术(adviceType=6),过滤 category_code = '手术' 或 '24' -->
|
||||
<if test="adviceTypes.contains(6) and !adviceTypes.contains(3)">
|
||||
AND (T1.category_code = '手术' OR T1.category_code = '24')
|
||||
</if>
|
||||
<!-- 如果只选择诊疗(adviceType=3),排除手术 -->
|
||||
<if test="adviceTypes.contains(3) and !adviceTypes.contains(6)">
|
||||
AND T1.category_code != '手术' AND T1.category_code != '24'
|
||||
</if>
|
||||
<if test="searchKey != null and searchKey != ''">
|
||||
AND (t1.name ILIKE '%' || #{searchKey} || '%' OR t1.py_str ILIKE '%' || #{searchKey} || '%')
|
||||
</if>
|
||||
@@ -263,7 +290,7 @@
|
||||
</if>
|
||||
</if>
|
||||
<!-- 如果没有有效的adviceTypes,提供一个空的默认查询以避免语法错误 -->
|
||||
<if test="adviceTypes == null or adviceTypes.isEmpty() or (!adviceTypes.contains(1) and !adviceTypes.contains(2) and !adviceTypes.contains(3))">
|
||||
<if test="adviceTypes == null or adviceTypes.isEmpty() or (!adviceTypes.contains(1) and !adviceTypes.contains(2) and !adviceTypes.contains(3) and !adviceTypes.contains(6))">
|
||||
SELECT
|
||||
mmd.tenant_id,
|
||||
CAST(0 AS INTEGER) AS advice_type,
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
T2.start_time AS admissionDate, --入院日期
|
||||
T3.ward_admission_date AS wardAdmissionDate, --入科日期
|
||||
T3.location_id AS ward_location_id, --病区
|
||||
T3.ward_admission_date AS wardAdmissionDate, --病区入院日期
|
||||
T4.location_id AS bed_location_id --床号
|
||||
FROM adm_patient AS T1
|
||||
INNER JOIN adm_encounter AS T2
|
||||
|
||||
Reference in New Issue
Block a user