fix(ATDManage): 解决入院体征数据映射兼容性问题 BUG#179

- 添加心率字段兼容性处理,支持heartRate和hertRate历史数据
- 增强血压数据解析安全性,防止数组越界异常
- 实现DocStatisticsDefinition查找fallback机制
- 添加缺失定义的日志记录和错误处理
- 确保只设置非空血压数值到DTO对象
This commit is contained in:
2026-03-18 13:47:56 +08:00
parent a3650aa386
commit 0d1710f201

View File

@@ -780,19 +780,32 @@ public class ATDManageAppServiceImpl implements IATDManageAppService {
map.put(e.getStatisticDefinitionCode(), e.getValue()); map.put(e.getStatisticDefinitionCode(), e.getValue());
} }
}); });
// 入院体征赋值 // 入院体征赋值 - 带fallback处理兼容heartRate/hertRate等历史数据
dto.setHeight(map.get(TemperatureChartEnum.HEIGHT.getTypeCode())); dto.setHeight(map.get(TemperatureChartEnum.HEIGHT.getTypeCode()));
dto.setWeight(map.get(TemperatureChartEnum.WEIGHT.getTypeCode())); dto.setWeight(map.get(TemperatureChartEnum.WEIGHT.getTypeCode()));
dto.setTemperature(map.get(TemperatureChartEnum.TEMPERATURE.getTypeCode())); dto.setTemperature(map.get(TemperatureChartEnum.TEMPERATURE.getTypeCode()));
dto.setPulse(map.get(TemperatureChartEnum.PULSE.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()); String bloodPressure = map.get(TemperatureChartEnum.BLOOD_PRESSURE.getTypeCode());
if (!StringUtils.isEmpty(bloodPressure)) { if (!StringUtils.isEmpty(bloodPressure) && bloodPressure.contains("/")) {
String[] split = bloodPressure.split("/"); String[] split = bloodPressure.split("/");
String endBloodPressure = split[0].strip(); // 安全检查确保分割后有2个元素
String highBloodPressure = split[1].strip(); if (split.length >= 2) {
dto.setEndBloodPressure(endBloodPressure); String endBloodPressure = split[0].strip();
dto.setHighBloodPressure(highBloodPressure); 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)) { if (value != null && !value.isEmpty() && !" ".equals(value)) {
DocStatisticsDefinitionDto docStatisticsDefinitionDto = definitionDtoHashMap.get(key); 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(); DocStatisticsDto statistics = new DocStatisticsDto();
statistics.setStatisticDefinitionCode(key); statistics.setStatisticDefinitionCode(key);
statistics.setValue(value); statistics.setValue(value);