From a68c4402deeff66a5c7c577f0a08c32b3af17f60 Mon Sep 17 00:00:00 2001 From: suizihe <2958847195@qq.com> Date: Mon, 17 Nov 2025 13:24:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E9=97=A8=E8=AF=8A=E6=8D=A2?= =?UTF-8?q?=E5=8D=A1=E7=9A=84=E6=95=B4=E4=BD=93=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PatientCardRenewalServiceImpl.java | 60 ++-- .../src/main/resources/application-local.yml | 2 +- .../views/charge/patientCardRenewal/index.vue | 267 +++++++++++++----- 3 files changed, 236 insertions(+), 93 deletions(-) diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/charge/patientcardrenewal/PatientCardRenewalServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/charge/patientcardrenewal/PatientCardRenewalServiceImpl.java index c6d99f21..35a4bd76 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/charge/patientcardrenewal/PatientCardRenewalServiceImpl.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/charge/patientcardrenewal/PatientCardRenewalServiceImpl.java @@ -1,6 +1,14 @@ package com.openhis.web.charge.patientcardrenewal; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.StringUtils; + +import com.openhis.administration.domain.PatientIdentifier; +import com.openhis.administration.service.IPatientIdentifierService; +import com.openhis.common.enums.IdentifierStatusEnum; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import lombok.extern.slf4j.Slf4j; @@ -14,30 +22,50 @@ import lombok.extern.slf4j.Slf4j; @Slf4j public class PatientCardRenewalServiceImpl implements PatientCardRenewalService { + @Autowired + private IPatientIdentifierService patientIdentifierService; + @Override + @Transactional(rollbackFor = Exception.class) public boolean renewCard(RenewalRequest request) { - // TODO: 这里应该实现真实的换卡业务逻辑 + log.info("执行患者换卡操作: 患者ID={}, 旧卡号={}, 新卡号={}, 原因={}", + request.getPatientId(), request.getOldCardNo(), request.getNewCardNo(), request.getReason()); + // 1. 验证参数合法性 + if (StringUtils.isEmpty(request.getPatientId())) { + throw new IllegalArgumentException("患者ID不能为空"); + } + + if (StringUtils.isEmpty(request.getNewCardNo())) { + throw new IllegalArgumentException("新卡号不能为空"); + } + // 2. 检查新卡号是否已被使用 - // 3. 更新患者主表中的卡号信息 - // 4. 记录换卡日志 - // 5. 处理相关业务系统的卡号更新 - - // 目前返回模拟结果 - log.info("模拟执行患者换卡操作: 旧卡号={}, 新卡号={}, 原因={}", - request.getOldCardNo(), request.getNewCardNo(), request.getReason()); - - // 简单验证:确保旧卡号和新卡号不为空且不相同 - if (request.getOldCardNo() == null || request.getNewCardNo() == null || - request.getOldCardNo().isEmpty() || request.getNewCardNo().isEmpty()) { - throw new IllegalArgumentException("卡号不能为空"); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(PatientIdentifier::getIdentifierNo, request.getNewCardNo()); + PatientIdentifier existingIdentifier = patientIdentifierService.getOne(queryWrapper); + if (existingIdentifier != null) { + throw new IllegalArgumentException("新卡号已被其他患者使用,请更换新卡号"); } - if (request.getOldCardNo().equals(request.getNewCardNo())) { - throw new IllegalArgumentException("新卡号不能与旧卡号相同"); + // 3. 直接使用患者ID作为查询条件 + Long patientId = Long.parseLong(request.getPatientId()); + // 4. 通过患者ID查询现有标识信息 + PatientIdentifier patientIdentifier = patientIdentifierService.selectByPatientId(patientId); + + if (patientIdentifier != null) { + // 5. 只更新就诊卡号这一个参数 + + patientIdentifier.setIdentifierNo(request.getNewCardNo()); + patientIdentifierService.updateById(patientIdentifier); + log.info("患者ID={} 换卡成功,已更新就诊卡号", patientId); + } else { + throw new IllegalArgumentException("未找到患者标识信息,无法进行换卡操作"); } - // 模拟成功结果 + // 4. 记录换卡日志 - 可以根据需要扩展日志记录功能 + // 5. 处理相关业务系统的卡号更新 - 可以根据需要扩展 + return true; } } \ No newline at end of file diff --git a/openhis-server-new/openhis-application/src/main/resources/application-local.yml b/openhis-server-new/openhis-application/src/main/resources/application-local.yml index 5baccbd8..9042834d 100644 --- a/openhis-server-new/openhis-application/src/main/resources/application-local.yml +++ b/openhis-server-new/openhis-application/src/main/resources/application-local.yml @@ -12,7 +12,7 @@ spring: # 从库数据源 slave: # 从数据源开关/默认关闭 - enabled: false + enabled: url: username: password: diff --git a/openhis-ui-vue3/src/views/charge/patientCardRenewal/index.vue b/openhis-ui-vue3/src/views/charge/patientCardRenewal/index.vue index 8b153774..9270b32c 100644 --- a/openhis-ui-vue3/src/views/charge/patientCardRenewal/index.vue +++ b/openhis-ui-vue3/src/views/charge/patientCardRenewal/index.vue @@ -142,14 +142,32 @@ + + + @@ -196,7 +214,7 @@ + @@ -233,10 +250,16 @@