|
@@ -2,16 +2,21 @@ package com.fs.app.controller;
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.fs.app.annotation.Login;
|
|
|
import com.fs.app.param.FsPatientAddEditParam;
|
|
|
import com.fs.common.annotation.RepeatSubmit;
|
|
|
import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.exception.CustomException;
|
|
|
+import com.fs.common.utils.StringUtils;
|
|
|
+import com.fs.his.config.StoreConfig;
|
|
|
import com.fs.his.domain.FsPatient;
|
|
|
import com.fs.his.enums.FsUserIntegralLogTypeEnum;
|
|
|
import com.fs.his.param.FsUserAddIntegralTemplateParam;
|
|
|
import com.fs.his.service.IFsPatientService;
|
|
|
import com.fs.his.service.IFsUserIntegralLogsService;
|
|
|
+import com.fs.his.utils.IdCardUtil;
|
|
|
+import com.fs.system.service.ISysConfigService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -38,6 +43,8 @@ public class PatientController extends AppBaseController {
|
|
|
private IFsPatientService patientService;
|
|
|
@Autowired
|
|
|
private IFsUserIntegralLogsService userIntegralLogsService;
|
|
|
+ @Autowired
|
|
|
+ private ISysConfigService configService;
|
|
|
|
|
|
@Login
|
|
|
@ApiOperation("获取病人列表")
|
|
@@ -77,15 +84,32 @@ public class PatientController extends AppBaseController {
|
|
|
@ApiOperation("添加病人")
|
|
|
@PostMapping("/addPatient")
|
|
|
public R addPatient(@Valid @RequestBody FsPatientAddEditParam param, HttpServletRequest request){
|
|
|
+ String json = configService.selectConfigByKey("his.store");
|
|
|
+ StoreConfig storeConfig = JSONUtil.toBean(json, StoreConfig.class);
|
|
|
+ Integer isIdVerification = storeConfig.getIsIdVerification();
|
|
|
|
|
|
String idCardNumber = param.getIdCard(); // 替换为要验证的身份证号码
|
|
|
- if (idCardNumber == null || idCardNumber.length() != 18) {
|
|
|
+ String mobile = param.getMobile();
|
|
|
+ if (idCardNumber == null || idCardNumber.trim().isEmpty()) {
|
|
|
return R.error("身份证号码不合法");
|
|
|
}
|
|
|
- String regex = "\\d{17}[0-9Xx]";
|
|
|
- if (!Pattern.matches(regex, idCardNumber)) {
|
|
|
- return R.error("身份证号码不合法");
|
|
|
+ if (idCardNumber.length() != 18) {
|
|
|
+ //大陆身份证是18位
|
|
|
+ if (isIdVerification != 1) {
|
|
|
+ return R.error("身份证号码不合法");
|
|
|
+ } else {
|
|
|
+ //非大陆身份校验需要手机号 手机号只支持大陆的办理的手机号
|
|
|
+ if (StringUtils.isBlank(mobile)){
|
|
|
+ R.error("手机号不能为空");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ String regex = "\\d{17}[0-9Xx]";
|
|
|
+ if (!Pattern.matches(regex, idCardNumber)) {
|
|
|
+ return R.error("身份证号码不合法");
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
if (param.getPatientName().length()<2||param.getPatientName().length()>30||!param.getPatientName().matches("^[\u4e00-\u9fa5]+$")) {
|
|
|
return R.error("就诊人名称不合法");
|
|
|
}
|
|
@@ -127,6 +151,19 @@ public class PatientController extends AppBaseController {
|
|
|
return R.error("身份证校验错误");
|
|
|
}
|
|
|
|
|
|
+ //三方校验
|
|
|
+ if (isIdVerification == 1){
|
|
|
+ boolean match = true;
|
|
|
+ if (idCardNumber.length() != 18) {
|
|
|
+ match = IdCardUtil.isMatchByMobile(storeConfig,param.getPatientName(), mobile);
|
|
|
+ } else {
|
|
|
+ match = IdCardUtil.isMatchById(storeConfig,param.getPatientName(), param.getIdCard());
|
|
|
+ }
|
|
|
+ if (!match){
|
|
|
+ return R.error("身份证校验错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
FsPatient patient=new FsPatient();
|
|
|
BeanUtil.copyProperties(param, patient);
|
|
|
patient.setUserId(Long.parseLong(getUserId()));
|
|
@@ -148,14 +185,32 @@ public class PatientController extends AppBaseController {
|
|
|
@ApiOperation("编辑病人")
|
|
|
@PostMapping("/editPatient")
|
|
|
public R editPatient(@Valid @RequestBody FsPatientAddEditParam param, HttpServletRequest request){
|
|
|
+ String json = configService.selectConfigByKey("his.store");
|
|
|
+ StoreConfig storeConfig = JSONUtil.toBean(json, StoreConfig.class);
|
|
|
+ Integer isIdVerification = storeConfig.getIsIdVerification();
|
|
|
+ String mobile = param.getMobile();
|
|
|
+
|
|
|
String idCardNumber = param.getIdCard(); // 替换为要验证的身份证号码
|
|
|
- if (idCardNumber == null || idCardNumber.length() != 18) {
|
|
|
- throw new CustomException("身份证号码不合法");
|
|
|
+ if (idCardNumber == null || idCardNumber.trim().isEmpty()) {
|
|
|
+ return R.error("身份证号码不合法");
|
|
|
}
|
|
|
- String regex = "\\d{17}[0-9Xx]";
|
|
|
- if (!Pattern.matches(regex, idCardNumber)) {
|
|
|
- throw new CustomException("身份证号码不合法");
|
|
|
+ if (idCardNumber.length() != 18) {
|
|
|
+ //大陆身份证是18位
|
|
|
+ if (isIdVerification != 1) {
|
|
|
+ return R.error("身份证号码不合法");
|
|
|
+ } else {
|
|
|
+ //非大陆身份校验需要手机号 手机号只支持大陆的办理的手机号
|
|
|
+ if (StringUtils.isBlank(mobile)){
|
|
|
+ R.error("手机号不能为空");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ String regex = "\\d{17}[0-9Xx]";
|
|
|
+ if (!Pattern.matches(regex, idCardNumber)) {
|
|
|
+ return R.error("身份证号码不合法");
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
if (param.getPatientName().length()<2||param.getPatientName().length()>30||!param.getPatientName().matches("^[\u4e00-\u9fa5]+$")) {
|
|
|
return R.error("就诊人名称不合法");
|
|
|
}
|
|
@@ -191,6 +246,20 @@ public class PatientController extends AppBaseController {
|
|
|
// if (age2 > 200) {
|
|
|
// throw new CustomException("年龄超过200岁");
|
|
|
// }
|
|
|
+
|
|
|
+ //三方校验
|
|
|
+ if (isIdVerification == 1){
|
|
|
+ boolean match = true;
|
|
|
+ if (idCardNumber.length() != 18) {
|
|
|
+ match = IdCardUtil.isMatchByMobile(storeConfig,param.getPatientName(), mobile);
|
|
|
+ } else {
|
|
|
+ match = IdCardUtil.isMatchById(storeConfig,param.getPatientName(), param.getIdCard());
|
|
|
+ }
|
|
|
+ if (!match){
|
|
|
+ return R.error("身份证校验错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
FsPatient patient=new FsPatient();
|
|
|
BeanUtil.copyProperties(param, patient);
|
|
|
patientService.updateFsPatient(patient);
|