From 0d1710f2018c08bfa939bef8f6a1fa2975fa3c69 Mon Sep 17 00:00:00 2001 From: chenqi Date: Wed, 18 Mar 2026 13:47:56 +0800 Subject: [PATCH] =?UTF-8?q?fix(ATDManage):=20=E8=A7=A3=E5=86=B3=E5=85=A5?= =?UTF-8?q?=E9=99=A2=E4=BD=93=E5=BE=81=E6=95=B0=E6=8D=AE=E6=98=A0=E5=B0=84?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=E6=80=A7=E9=97=AE=E9=A2=98=20BUG#179?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加心率字段兼容性处理,支持heartRate和hertRate历史数据 - 增强血压数据解析安全性,防止数组越界异常 - 实现DocStatisticsDefinition查找fallback机制 - 添加缺失定义的日志记录和错误处理 - 确保只设置非空血压数值到DTO对象 --- .../impl/ATDManageAppServiceImpl.java | 40 +++++++++++++++---- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/inhospitalnursestation/appservice/impl/ATDManageAppServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/inhospitalnursestation/appservice/impl/ATDManageAppServiceImpl.java index 0e78b07f..41c5b3fe 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/inhospitalnursestation/appservice/impl/ATDManageAppServiceImpl.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/inhospitalnursestation/appservice/impl/ATDManageAppServiceImpl.java @@ -780,19 +780,32 @@ public class ATDManageAppServiceImpl implements IATDManageAppService { map.put(e.getStatisticDefinitionCode(), e.getValue()); } }); - // 入院体征赋值 + // 入院体征赋值 - 带fallback处理,兼容heartRate/hertRate等历史数据 dto.setHeight(map.get(TemperatureChartEnum.HEIGHT.getTypeCode())); dto.setWeight(map.get(TemperatureChartEnum.WEIGHT.getTypeCode())); dto.setTemperature(map.get(TemperatureChartEnum.TEMPERATURE.getTypeCode())); dto.setPulse(map.get(TemperatureChartEnum.PULSE.getTypeCode())); - dto.setHertRate(map.get(TemperatureChartEnum.HEART_RATE.getTypeCode())); + // 心率字段兼容性处理:尝试heartRate,如果不存在尝试hertRate + String heartRateValue = map.get(TemperatureChartEnum.HEART_RATE.getTypeCode()); + if (heartRateValue == null) { + heartRateValue = map.get("hertRate"); // 兼容历史数据中的拼写错误 + } + dto.setHertRate(heartRateValue); String bloodPressure = map.get(TemperatureChartEnum.BLOOD_PRESSURE.getTypeCode()); - if (!StringUtils.isEmpty(bloodPressure)) { + if (!StringUtils.isEmpty(bloodPressure) && bloodPressure.contains("/")) { String[] split = bloodPressure.split("/"); - String endBloodPressure = split[0].strip(); - String highBloodPressure = split[1].strip(); - dto.setEndBloodPressure(endBloodPressure); - dto.setHighBloodPressure(highBloodPressure); + // 安全检查:确保分割后有2个元素 + if (split.length >= 2) { + String endBloodPressure = split[0].strip(); + String highBloodPressure = split[1].strip(); + // 进一步检查值不为空 + if (!endBloodPressure.isEmpty()) { + dto.setEndBloodPressure(endBloodPressure); + } + if (!highBloodPressure.isEmpty()) { + dto.setHighBloodPressure(highBloodPressure); + } + } } } @@ -847,6 +860,19 @@ public class ATDManageAppServiceImpl implements IATDManageAppService { // 只保存非空值 if (value != null && !value.isEmpty() && !" ".equals(value)) { DocStatisticsDefinitionDto docStatisticsDefinitionDto = definitionDtoHashMap.get(key); + // 如果找不到定义,尝试使用code作为fallback(兼容历史数据) + if (docStatisticsDefinitionDto == null) { + log.warn("DocStatisticsDefinition not found for key: {}, trying fallback lookup", key); + // 尝试查找任意匹配的定义(兼容heartRate/hertRate等差异) + docStatisticsDefinitionDto = definitionList.stream() + .filter(d -> key.equalsIgnoreCase(d.getCode()) || key.equalsIgnoreCase(d.getTypeCode())) + .findFirst() + .orElse(null); + } + if (docStatisticsDefinitionDto == null) { + log.error("无法找到DocStatisticsDefinition,跳过保存 - key: {}, value: {}", key, value); + return; // 跳过这个字段 + } DocStatisticsDto statistics = new DocStatisticsDto(); statistics.setStatisticDefinitionCode(key); statistics.setValue(value);