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

@@ -32,18 +32,11 @@ public class PatientServiceImpl extends ServiceImpl<PatientMapper, Patient> impl
*/
@Override
public boolean saveOrUpdatePatient(Patient patient) {
// 身份证ID患者ID确定唯一患者
LambdaQueryWrapper<Patient> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Patient::getId, patient.getId()).eq(Patient::getIdCard, patient.getIdCard());
Patient existingPatient = baseMapper.selectOne(queryWrapper);
if (existingPatient != null) {
// 如果记录存在,更新记录
patient.setId(existingPatient.getId());
if (patient.getId() != null) {
// 如果提供了ID则直接更新该ID的记录
return baseMapper.updateById(patient) > 0;
} else {
// 如果记录不存在,插入新记录
// 如果没有提供ID插入新记录
return baseMapper.insert(patient) > 0;
}
}