|
@@ -7,6 +7,7 @@ import com.fs.app.param.FsPatientAddEditParam;
|
|
import com.fs.common.annotation.RepeatSubmit;
|
|
import com.fs.common.annotation.RepeatSubmit;
|
|
import com.fs.common.core.domain.R;
|
|
import com.fs.common.core.domain.R;
|
|
import com.fs.common.exception.CustomException;
|
|
import com.fs.common.exception.CustomException;
|
|
|
|
+import com.fs.common.utils.StringUtils;
|
|
import com.fs.his.domain.FsPatient;
|
|
import com.fs.his.domain.FsPatient;
|
|
import com.fs.his.enums.FsUserIntegralLogTypeEnum;
|
|
import com.fs.his.enums.FsUserIntegralLogTypeEnum;
|
|
import com.fs.his.param.FsUserAddIntegralTemplateParam;
|
|
import com.fs.his.param.FsUserAddIntegralTemplateParam;
|
|
@@ -77,51 +78,56 @@ public class PatientController extends AppBaseController {
|
|
@ApiOperation("添加病人")
|
|
@ApiOperation("添加病人")
|
|
@PostMapping("/addPatient")
|
|
@PostMapping("/addPatient")
|
|
public R addPatient(@Valid @RequestBody FsPatientAddEditParam param, HttpServletRequest request){
|
|
public R addPatient(@Valid @RequestBody FsPatientAddEditParam param, HttpServletRequest request){
|
|
-
|
|
|
|
- String idCardNumber = param.getIdCard(); // 替换为要验证的身份证号码
|
|
|
|
- if (idCardNumber == null || idCardNumber.length() != 18) {
|
|
|
|
- return R.error("身份证号码不合法");
|
|
|
|
- }
|
|
|
|
- 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("就诊人名称不合法");
|
|
|
|
- }
|
|
|
|
- try {
|
|
|
|
- String birthDateString = idCardNumber.substring(6, 14);
|
|
|
|
- LocalDate birthDate = LocalDate.parse(birthDateString, DateTimeFormatter.ofPattern("yyyyMMdd"));
|
|
|
|
- LocalDate currentDate = LocalDate.now();
|
|
|
|
- int age = currentDate.getYear() - birthDate.getYear();
|
|
|
|
- if (currentDate.getMonthValue() < birthDate.getMonthValue()
|
|
|
|
- || (currentDate.getMonthValue() == birthDate.getMonthValue()
|
|
|
|
- && currentDate.getDayOfMonth() < birthDate.getDayOfMonth())) {
|
|
|
|
- age--;
|
|
|
|
|
|
+ String idCardNumber = null;
|
|
|
|
+ if(StringUtils.isNotEmpty(param.getIdCard()) ) {
|
|
|
|
+ idCardNumber = param.getIdCard(); // 替换为要验证的身份证号码
|
|
|
|
+ if (idCardNumber == null || idCardNumber.length() != 18) {
|
|
|
|
+ return R.error("身份证号码不合法");
|
|
}
|
|
}
|
|
- if (age < 18) {
|
|
|
|
- return R.error("年龄必须大于18岁");
|
|
|
|
|
|
+ String regex = "\\d{17}[0-9Xx]";
|
|
|
|
+ if (!Pattern.matches(regex, idCardNumber)) {
|
|
|
|
+ return R.error("身份证号码不合法");
|
|
}
|
|
}
|
|
- if (age > 200) {
|
|
|
|
- return R.error("年龄超过200岁");
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- Date birthday = param.getBirthday();
|
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
|
|
|
- String formattedBirthday = sdf.format(birthday);
|
|
|
|
- LocalDate da = LocalDate.parse(formattedBirthday, DateTimeFormatter.ofPattern("yyyyMMdd"));
|
|
|
|
- LocalDate currentDate2 = LocalDate.now();
|
|
|
|
- int age2 = currentDate2.getYear() - da.getYear();
|
|
|
|
- if (currentDate2.getMonthValue() < da.getMonthValue()
|
|
|
|
- || (currentDate2.getMonthValue() == da.getMonthValue()
|
|
|
|
- && currentDate2.getDayOfMonth() < da.getDayOfMonth())) {
|
|
|
|
- age2--;
|
|
|
|
- }
|
|
|
|
- if (age2 < 18) {
|
|
|
|
- return R.error("年龄必须大于18岁");
|
|
|
|
|
|
+ if (param.getPatientName().length()<2||param.getPatientName().length()>30||!param.getPatientName().matches("^[\u4e00-\u9fa5]+$")) {
|
|
|
|
+ return R.error("就诊人名称不合法");
|
|
}
|
|
}
|
|
- if (age2 > 200) {
|
|
|
|
- return R.error("年龄超过200岁");
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ if (idCardNumber != null) {
|
|
|
|
+ String birthDateString = idCardNumber.substring(6, 14);
|
|
|
|
+ LocalDate birthDate = LocalDate.parse(birthDateString, DateTimeFormatter.ofPattern("yyyyMMdd"));
|
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
|
+ int age = currentDate.getYear() - birthDate.getYear();
|
|
|
|
+ if (currentDate.getMonthValue() < birthDate.getMonthValue()
|
|
|
|
+ || (currentDate.getMonthValue() == birthDate.getMonthValue()
|
|
|
|
+ && currentDate.getDayOfMonth() < birthDate.getDayOfMonth())) {
|
|
|
|
+ age--;
|
|
|
|
+ }
|
|
|
|
+ if (age < 18) {
|
|
|
|
+ return R.error("年龄必须大于18岁");
|
|
|
|
+ }
|
|
|
|
+ if (age > 200) {
|
|
|
|
+ return R.error("年龄超过200岁");
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ Date birthday = param.getBirthday();
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
|
|
|
+ String formattedBirthday = sdf.format(birthday);
|
|
|
|
+ LocalDate da = LocalDate.parse(formattedBirthday, DateTimeFormatter.ofPattern("yyyyMMdd"));
|
|
|
|
+ LocalDate currentDate2 = LocalDate.now();
|
|
|
|
+ int age2 = currentDate2.getYear() - da.getYear();
|
|
|
|
+ if (currentDate2.getMonthValue() < da.getMonthValue()
|
|
|
|
+ || (currentDate2.getMonthValue() == da.getMonthValue()
|
|
|
|
+ && currentDate2.getDayOfMonth() < da.getDayOfMonth())) {
|
|
|
|
+ age2--;
|
|
|
|
+ }
|
|
|
|
+ if (age2 < 18) {
|
|
|
|
+ return R.error("年龄必须大于18岁");
|
|
|
|
+ }
|
|
|
|
+ if (age2 > 200) {
|
|
|
|
+ return R.error("年龄超过200岁");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
return R.error("身份证校验错误");
|
|
return R.error("身份证校验错误");
|
|
@@ -148,14 +154,18 @@ public class PatientController extends AppBaseController {
|
|
@ApiOperation("编辑病人")
|
|
@ApiOperation("编辑病人")
|
|
@PostMapping("/editPatient")
|
|
@PostMapping("/editPatient")
|
|
public R editPatient(@Valid @RequestBody FsPatientAddEditParam param, HttpServletRequest request){
|
|
public R editPatient(@Valid @RequestBody FsPatientAddEditParam param, HttpServletRequest request){
|
|
- String idCardNumber = param.getIdCard(); // 替换为要验证的身份证号码
|
|
|
|
- if (idCardNumber == null || idCardNumber.length() != 18) {
|
|
|
|
- throw new CustomException("身份证号码不合法");
|
|
|
|
- }
|
|
|
|
- String regex = "\\d{17}[0-9Xx]";
|
|
|
|
- if (!Pattern.matches(regex, idCardNumber)) {
|
|
|
|
- throw new CustomException("身份证号码不合法");
|
|
|
|
|
|
+
|
|
|
|
+ if (StringUtils.isNotEmpty(param.getIdCard())) {
|
|
|
|
+ String idCardNumber = param.getIdCard(); // 替换为要验证的身份证号码
|
|
|
|
+ if (idCardNumber == null || idCardNumber.length() != 18) {
|
|
|
|
+ throw new CustomException("身份证号码不合法");
|
|
|
|
+ }
|
|
|
|
+ String regex = "\\d{17}[0-9Xx]";
|
|
|
|
+ if (!Pattern.matches(regex, idCardNumber)) {
|
|
|
|
+ throw new CustomException("身份证号码不合法");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+
|
|
if (param.getPatientName().length()<2||param.getPatientName().length()>30||!param.getPatientName().matches("^[\u4e00-\u9fa5]+$")) {
|
|
if (param.getPatientName().length()<2||param.getPatientName().length()>30||!param.getPatientName().matches("^[\u4e00-\u9fa5]+$")) {
|
|
return R.error("就诊人名称不合法");
|
|
return R.error("就诊人名称不合法");
|
|
}
|
|
}
|