当输入患者的姓名和身份号码两个字段的值已经存在时,提醒挂号工作人员该患者档案已经存在
This commit is contained in:
@@ -53,4 +53,13 @@ public interface IPatientInformationService {
|
||||
*/
|
||||
R<?> addPatient(PatientInformationDto patientInformationDto);
|
||||
|
||||
/**
|
||||
* 检查患者是否存在
|
||||
*
|
||||
* @param name 患者姓名
|
||||
* @param idCardNo 身份证号
|
||||
* @return 是否存在
|
||||
*/
|
||||
boolean checkPatientExists(String name, String idCardNo);
|
||||
|
||||
}
|
||||
|
||||
@@ -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<Patient> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("name", name)
|
||||
.eq("id_card", idCardNo)
|
||||
.eq("delete_flag", "0");
|
||||
return patientService.count(queryWrapper) > 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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' }],
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user