From 48b2188cf93376615d2e058a53888d583c5b39b0 Mon Sep 17 00:00:00 2001 From: Auora <14587305+auoraasd@user.noreply.gitee.com> Date: Wed, 22 Oct 2025 15:15:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BD=93=E8=BE=93=E5=85=A5=E6=82=A3=E8=80=85?= =?UTF-8?q?=E7=9A=84=E5=A7=93=E5=90=8D=E5=92=8C=E8=BA=AB=E4=BB=BD=E5=8F=B7?= =?UTF-8?q?=E7=A0=81=E4=B8=A4=E4=B8=AA=E5=AD=97=E6=AE=B5=E7=9A=84=E5=80=BC?= =?UTF-8?q?=E5=B7=B2=E7=BB=8F=E5=AD=98=E5=9C=A8=E6=97=B6=EF=BC=8C=E6=8F=90?= =?UTF-8?q?=E9=86=92=E6=8C=82=E5=8F=B7=E5=B7=A5=E4=BD=9C=E4=BA=BA=E5=91=98?= =?UTF-8?q?=E8=AF=A5=E6=82=A3=E8=80=85=E6=A1=A3=E6=A1=88=E5=B7=B2=E7=BB=8F?= =?UTF-8?q?=E5=AD=98=E5=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IPatientInformationService.java | 9 +++++ .../impl/PatientInformationServiceImpl.java | 10 +++++ .../PatientInformationController.java | 12 ++++++ openhis-ui-vue3/src/main.js | 6 +++ .../components/patientAddDialog.vue | 37 ++++++++++++++++++- 5 files changed, 72 insertions(+), 2 deletions(-) diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/patientmanage/appservice/IPatientInformationService.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/patientmanage/appservice/IPatientInformationService.java index 9ae9e593..de99dc29 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/patientmanage/appservice/IPatientInformationService.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/patientmanage/appservice/IPatientInformationService.java @@ -53,4 +53,13 @@ public interface IPatientInformationService { */ R addPatient(PatientInformationDto patientInformationDto); + /** + * 检查患者是否存在 + * + * @param name 患者姓名 + * @param idCardNo 身份证号 + * @return 是否存在 + */ + boolean checkPatientExists(String name, String idCardNo); + } diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/patientmanage/appservice/impl/PatientInformationServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/patientmanage/appservice/impl/PatientInformationServiceImpl.java index 3bb6e966..c344b7a2 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/patientmanage/appservice/impl/PatientInformationServiceImpl.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/patientmanage/appservice/impl/PatientInformationServiceImpl.java @@ -257,4 +257,14 @@ public class PatientInformationServiceImpl implements IPatientInformationService : R.fail(MessageUtils.createMessage(PromptMsgConstant.Common.M00003, new Object[] {"病人信息"})); } + @Override + public boolean checkPatientExists(String name, String idCardNo) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("name", name) + .eq("id_card", idCardNo) + .eq("delete_flag", "0"); + return patientService.count(queryWrapper) > 0; + } + + } diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/patientmanage/controller/PatientInformationController.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/patientmanage/controller/PatientInformationController.java index aabf4458..24acbd23 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/patientmanage/controller/PatientInformationController.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/patientmanage/controller/PatientInformationController.java @@ -78,4 +78,16 @@ public class PatientInformationController { .ok(patientInformationService.getPatientInfo(patientInfoSearchParam, searchKey, pageNo, pageSize, request)); } + /** + * 检查患者是否存在 + * + * @param name 患者姓名 + * @param idCardNo 身份证号 + * @return 是否存在 + */ + @GetMapping("/check-exists") + public R checkPatientExists(@RequestParam String name, @RequestParam String idCardNo) { + return R.ok(patientInformationService.checkPatientExists(name, idCardNo)); + } + } diff --git a/openhis-ui-vue3/src/main.js b/openhis-ui-vue3/src/main.js index de28c8ac..ee4c1691 100644 --- a/openhis-ui-vue3/src/main.js +++ b/openhis-ui-vue3/src/main.js @@ -44,6 +44,9 @@ import TreeSelect from '@/components/TreeSelect' // 字典标签组件 import DictTag from '@/components/DictTag' +// 导入请求工具 +import request from './utils/request' + import { ElDialog, ElMessage } from 'element-plus'; import {registerComponents} from './template'; @@ -64,6 +67,9 @@ app.config.globalProperties.handleTree = handleTree app.config.globalProperties.addDateRange = addDateRange app.config.globalProperties.selectDictLabel = selectDictLabel app.config.globalProperties.selectDictLabels = selectDictLabels + +// 全局挂载请求实例 +app.config.globalProperties.$http = request // 全局组件挂载 app.component('DictTag', DictTag) app.component('Pagination', Pagination) diff --git a/openhis-ui-vue3/src/views/charge/outpatientregistration/components/patientAddDialog.vue b/openhis-ui-vue3/src/views/charge/outpatientregistration/components/patientAddDialog.vue index d1c0e1cc..0bc83397 100644 --- a/openhis-ui-vue3/src/views/charge/outpatientregistration/components/patientAddDialog.vue +++ b/openhis-ui-vue3/src/views/charge/outpatientregistration/components/patientAddDialog.vue @@ -300,6 +300,36 @@ const title = ref('新增患者'); const visible = ref(false); const emits = defineEmits(['submit']); // 声明自定义事件 +const validateUniquePatient = (rule, value, callback) => { + const { name, idCard } = form.value; + // 确保姓名和身份证都已填写且身份证为18位 + if (!name || !idCard || idCard.length !== 18) { + return callback(); // 不满足条件,不校验 + } + + // 使用 axios 直接请求,避免依赖 proxy.$http + import('@/utils/request').then(({ default: request }) => { + request({ + url: '/patient-manage/information/check-exists', + method: 'get', + params: { + name: name, + idCardNo: idCard + } + }).then(res => { + if (res.code === 200 && res.data === true) { + callback(new Error('该患者档案已存在!')); + } else { + callback(); + } + }).catch(error => { + console.error('校验患者是否存在失败:', error); + callback(); // 出错时不阻塞表单 + }); + }); +}; + + // 身份证号码校验函数 const validateIdCard = (rule, value, callback) => { @@ -338,14 +368,17 @@ const data = reactive({ age: undefined, }, rules: { - name: [{ required: true, message: '姓名不能为空', trigger: 'change' }], + name: [{ required: true, message: '姓名不能为空', trigger: 'change' }, + { validator: validateUniquePatient, trigger: 'blur' } + ], genderEnum: [{ required: true, message: '请选择性别', trigger: 'change' }], age: [{ required: true, message: '年龄不能为空', trigger: 'change' }], phone: [{ required: true, message: '联系方式不能为空', trigger: 'change' }], identifierNo: [{ required: true, message: '就诊卡号不能为空', trigger: 'change' }], idCard: [ { required: true, message: '证件号码不能为空', trigger: 'change' }, - { validator: validateIdCard, trigger: 'blur' } + { validator: validateIdCard, trigger: 'blur' }, + { validator: validateUniquePatient, trigger: 'blur' } ], birthDate: [{ required: false, message: '请选择出生日期', trigger: 'change' }], },