fix(patient): 修复患者信息新增和更新逻辑

- 修改handlePatientInfo方法中的患者对象初始化逻辑
- 添加患者ID存在时的查询验证机制
- 区分新增和更新操作分别调用不同的服务方法
- 移除重复的身份证号查询条件优化性能
- 统一患者信息保存和更新的操作流程
This commit is contained in:
2026-01-19 21:41:05 +08:00
parent ae96bbd0bb
commit aa3beb848b
2 changed files with 23 additions and 15 deletions

View File

@@ -308,12 +308,20 @@ public class PatientInformationServiceImpl implements IPatientInformationService
* @return 患者信息
*/
private Patient handlePatientInfo(PatientBaseInfoDto patientInfoDto) {
Patient patient = new Patient();
patient.setId(patientInfoDto.getId());
if (patientInfoDto.getId() == null) {
Patient patient;
if (patientInfoDto.getId() != null) {
// 更新现有患者信息
patient = patientService.getById(patientInfoDto.getId());
if (patient == null) {
throw new ServiceException("患者信息不存在,无法更新");
}
} else {
// 新增患者信息
patient = new Patient();
patient.setBusNo(assignSeqUtil.getSeq(AssignSeqEnum.PATIENT_NUM.getPrefix(), 10));
patientInfoDto.setActiveFlag(PublicationStatus.ACTIVE.getValue()); // 默认启用
patient.setActiveFlag(PublicationStatus.ACTIVE.getValue()); // 默认启用
}
patient.setName(patientInfoDto.getName()); // 患者姓名
patient.setPyStr(ChineseConvertUtils.toPinyinFirstLetter(patientInfoDto.getName())); // 拼音首拼
patient.setWbStr(ChineseConvertUtils.toWBFirstLetter(patientInfoDto.getName())); // 五笔首拼
@@ -337,7 +345,14 @@ public class PatientInformationServiceImpl implements IPatientInformationService
patient.setDeceasedDate(patientInfoDto.getDeceasedDate()); // 死亡时间
patient.setNationalityCode(patientInfoDto.getNationalityCode());// 民族
patient.setActiveFlag(patientInfoDto.getActiveFlag());// 活动标识
patientService.saveOrUpdate(patient);
if (patientInfoDto.getId() != null) {
// 更新操作
patientService.updateById(patient);
} else {
// 新增操作
patientService.save(patient);
}
return patient;
}