370【住院护士站站-》进入“三测单”模块报错
371 【业务配置】住院医生站-“呼吸内科病房”未在西药房取药规则中维护配置
This commit is contained in:
@@ -116,4 +116,12 @@ public interface IDoctorStationAdviceAppService {
|
||||
* @return 检查url相关参数
|
||||
*/
|
||||
R<?> getTestResult(Long encounterId);
|
||||
|
||||
/**
|
||||
* 获取当前科室已配置的药品类别列表
|
||||
*
|
||||
* @param organizationId 科室id
|
||||
* @return 已配置的药品类别编码列表
|
||||
*/
|
||||
R<?> getConfiguredCategories(Long organizationId);
|
||||
}
|
||||
|
||||
@@ -155,6 +155,7 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
String safePricingFlag = pricingFlag != null ? pricingFlag.toString() : "";
|
||||
String safePageNo = pageNo != null ? pageNo.toString() : "";
|
||||
String safePageSize = pageSize != null ? pageSize.toString() : "";
|
||||
String safeCategoryCode = categoryCode != null ? categoryCode : "";
|
||||
|
||||
// 设置默认科室:仅当前端/调用方未传 organizationId 时才回退到登录人科室
|
||||
// 否则会导致门诊划价等场景(按患者挂号科室查询)返回空
|
||||
@@ -169,7 +170,7 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
String cacheKey = null;
|
||||
if (useCache) {
|
||||
// 生成缓存 key:无搜索关键字时按科室缓存
|
||||
cacheKey = ADVICE_BASE_INFO_CACHE_PREFIX + organizationId + ":" + safeAdviceTypesStr + ":" + safePageNo + ":" + safePageSize;
|
||||
cacheKey = ADVICE_BASE_INFO_CACHE_PREFIX + organizationId + ":" + safeAdviceTypesStr + ":" + safeCategoryCode + ":" + safePageNo + ":" + safePageSize;
|
||||
|
||||
// 先清除可能存在的无效缓存(JSONObject类型)
|
||||
if (redisCache.hasKey(cacheKey)) {
|
||||
@@ -281,6 +282,8 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
}
|
||||
String unitCode = ""; // 包装单位
|
||||
Long chargeItemDefinitionId; // 费用定价主表ID
|
||||
// 检查是否有取药科室配置(用于药品类型)
|
||||
boolean hasPharmacyConfig = medLocationConfig != null && !medLocationConfig.isEmpty();
|
||||
for (AdviceBaseDto baseDto : adviceBaseDtoList) {
|
||||
String tableName = baseDto.getAdviceTableName();
|
||||
if (CommonConstants.TableName.MED_MEDICATION_DEFINITION.equals(tableName)) { // 药品
|
||||
@@ -289,6 +292,9 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
.setSkinTestFlag_enumText(EnumUtils.getInfoByValue(Whether.class, baseDto.getSkinTestFlag()));
|
||||
// 是否为注射药物
|
||||
baseDto.setInjectFlag_enumText(EnumUtils.getInfoByValue(Whether.class, baseDto.getInjectFlag()));
|
||||
|
||||
// 设置是否缺少取药科室配置标志
|
||||
baseDto.setPharmacyConfigMissing(!hasPharmacyConfig);
|
||||
|
||||
// fallthrough to 耗材处理逻辑(保持原有逻辑)
|
||||
// 每一条医嘱的库存集合信息 , 包装单位库存前端计算
|
||||
@@ -2148,4 +2154,23 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
return searchKey.matches("[a-zA-Z]+");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前科室已配置的药品类别列表
|
||||
*
|
||||
* @param organizationId 科室id
|
||||
* @return 已配置的药品类别编码列表
|
||||
*/
|
||||
@Override
|
||||
public R<?> getConfiguredCategories(Long organizationId) {
|
||||
// 查询取药科室配置
|
||||
List<AdviceInventoryDto> medLocationConfig = doctorStationAdviceAppMapper.getMedLocationConfig(organizationId);
|
||||
// 提取不重复的 categoryCode
|
||||
List<String> categoryCodes = medLocationConfig.stream()
|
||||
.map(AdviceInventoryDto::getCategoryCode)
|
||||
.filter(code -> code != null && !code.isEmpty())
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
return R.ok(categoryCodes);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -50,9 +50,10 @@ public class DoctorStationAdviceController {
|
||||
@RequestParam(value = "organizationId", required = false) Long organizationId,
|
||||
@RequestParam(value = "adviceTypes", defaultValue = "1,2,3") List<Integer> adviceTypes,
|
||||
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
@RequestParam(value = "categoryCode", required = false) String categoryCode) {
|
||||
return R.ok(iDoctorStationAdviceAppService.getAdviceBaseInfo(adviceBaseDto, searchKey, locationId,
|
||||
adviceDefinitionIdParamList, organizationId, pageNo, pageSize, Whether.NO.getValue(), adviceTypes, null, null));
|
||||
adviceDefinitionIdParamList, organizationId, pageNo, pageSize, Whether.NO.getValue(), adviceTypes, null, categoryCode));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -186,4 +187,15 @@ public class DoctorStationAdviceController {
|
||||
return iDoctorStationAdviceAppService.getTestResult(encounterId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前科室已配置的药品类别列表
|
||||
*
|
||||
* @param organizationId 科室id
|
||||
* @return 已配置的药品类别编码列表
|
||||
*/
|
||||
@GetMapping(value = "/configured-categories")
|
||||
public R<?> getConfiguredCategories(@RequestParam(value = "organizationId", required = false) Long organizationId) {
|
||||
return iDoctorStationAdviceAppService.getConfiguredCategories(organizationId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -242,4 +242,9 @@ public class AdviceBaseDto {
|
||||
@Dict(dictCode = "chrgitm_lv")
|
||||
private String chrgitmLv;
|
||||
private String chrgitmLv_dictText;
|
||||
|
||||
/**
|
||||
* 是否缺少取药科室配置(仅药品类型使用)
|
||||
*/
|
||||
private Boolean pharmacyConfigMissing;
|
||||
}
|
||||
|
||||
@@ -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