fix(prescription): 解决处方列表患者信息不完整导致保存失败的问题 BUG#220

- 在前端处方组件中添加患者信息完整性校验
- 当患者信息缺失时显示错误提示并阻止保存操作
- 确保处方项目正确携带patientId和encounterId信息
- 在后端服务中验证并自动补全缺失的patientId信息
- 当encounterId为空时返回相应错误提示
- 添加详细的日志记录以便问题追踪
This commit is contained in:
2026-03-24 11:53:04 +08:00
parent cc51d0b345
commit e1dc5c895f
2 changed files with 47 additions and 1 deletions

View File

@@ -16,9 +16,11 @@ import com.core.common.utils.SecurityUtils;
import com.core.common.utils.StringUtils;
import com.core.web.util.TenantOptionUtil;
import com.openhis.administration.domain.Account;
import com.openhis.administration.service.IAccountService;
import com.openhis.administration.domain.ChargeItem;
import com.openhis.administration.domain.Encounter;
import com.openhis.administration.service.IAccountService;
import com.openhis.administration.service.IChargeItemService;
import com.openhis.administration.service.IEncounterService;
import com.openhis.common.constant.CommonConstants;
import com.openhis.common.constant.PromptMsgConstant;
import com.openhis.common.enums.*;
@@ -106,6 +108,9 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
@Resource
RedisCache redisCache;
@Resource
IEncounterService iEncounterService;
// 缓存 key 前缀
private static final String ADVICE_BASE_INFO_CACHE_PREFIX = "advice:base:info:";
// 缓存过期时间(小时)
@@ -480,6 +485,30 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
Long organizationId = adviceSaveParam.getOrganizationId();
// 医嘱分类信息
List<AdviceSaveDto> adviceSaveList = adviceSaveParam.getAdviceSaveList();
// 🔧 Bug Fix: 校验并补全patientId如果为null从encounter查询获取
for (AdviceSaveDto adviceSaveDto : adviceSaveList) {
// 首先检查encounterId是否为null
if (adviceSaveDto.getEncounterId() == null) {
log.error("encounterId为null无法保存医嘱");
return R.fail(null, "就诊信息不完整,请重新选择患者后再试");
}
// 如果patientId为null尝试从encounter获取
if (adviceSaveDto.getPatientId() == null) {
// 从就诊记录中获取patientId
Encounter encounter = iEncounterService.getById(adviceSaveDto.getEncounterId());
if (encounter != null && encounter.getPatientId() != null) {
adviceSaveDto.setPatientId(encounter.getPatientId());
log.info("自动补全patientId: encounterId={}, patientId={}",
adviceSaveDto.getEncounterId(), encounter.getPatientId());
} else {
log.error("无法获取patientId: encounterId={}", adviceSaveDto.getEncounterId());
return R.fail(null, "无法获取患者信息,请重新选择患者");
}
}
}
// 药品
List<AdviceSaveDto> medicineList = adviceSaveList.stream()
.filter(e -> ItemType.MEDICINE.getValue().equals(e.getAdviceType())).collect(Collectors.toList());