fix(ATDManage): 解决入院体征数据映射兼容性问题 BUG#179
- 添加心率字段兼容性处理,支持heartRate和hertRate历史数据 - 增强血压数据解析安全性,防止数组越界异常 - 实现DocStatisticsDefinition查找fallback机制 - 添加缺失定义的日志记录和错误处理 - 确保只设置非空血压数值到DTO对象
This commit is contained in:
@@ -780,20 +780,33 @@ 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("/");
|
||||||
|
// 安全检查:确保分割后有2个元素
|
||||||
|
if (split.length >= 2) {
|
||||||
String endBloodPressure = split[0].strip();
|
String endBloodPressure = split[0].strip();
|
||||||
String highBloodPressure = split[1].strip();
|
String highBloodPressure = split[1].strip();
|
||||||
|
// 进一步检查值不为空
|
||||||
|
if (!endBloodPressure.isEmpty()) {
|
||||||
dto.setEndBloodPressure(endBloodPressure);
|
dto.setEndBloodPressure(endBloodPressure);
|
||||||
|
}
|
||||||
|
if (!highBloodPressure.isEmpty()) {
|
||||||
dto.setHighBloodPressure(highBloodPressure);
|
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);
|
||||||
|
|||||||
Reference in New Issue
Block a user