|
@@ -11,6 +11,7 @@ import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.exception.CustomException;
|
|
|
import com.fs.common.utils.SecurityUtils;
|
|
|
import com.fs.his.vo.FsPatientVO;
|
|
|
+import com.hc.openapi.tool.util.StringUtils;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
@@ -132,48 +133,75 @@ public class FsPatientController extends BaseController
|
|
|
public AjaxResult add(@RequestBody FsPatient fsPatient)
|
|
|
{
|
|
|
String idCardNumber = fsPatient.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 (idCardNumber == null || idCardNumber.length() != 18) {
|
|
|
+// throw new CustomException("身份证号码不合法");
|
|
|
+// }
|
|
|
+// String regex = "\\d{17}[0-9Xx]";
|
|
|
+// if (!Pattern.matches(regex, idCardNumber)) {
|
|
|
+// throw new CustomException("身份证号码不合法");
|
|
|
+// }
|
|
|
+ if (StringUtils.isNotBlank(idCardNumber)){
|
|
|
+ if (idCardNumber.length() != 18) {
|
|
|
+ throw new CustomException("身份证号码不合法");
|
|
|
+ }
|
|
|
+ String regex = "\\d{17}[0-9Xx]";
|
|
|
+ if (!Pattern.matches(regex, idCardNumber)) {
|
|
|
+ throw new CustomException("身份证号码不合法");
|
|
|
+ }
|
|
|
+ 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) {
|
|
|
+ throw new CustomException("年龄必须大于18岁");
|
|
|
+ }
|
|
|
+ if (age > 200) {
|
|
|
+ throw new CustomException("年龄超过200岁");
|
|
|
+ }
|
|
|
}
|
|
|
if (fsPatient.getPatientName().length()<2||fsPatient.getPatientName().length()>30||!fsPatient.getPatientName().matches("^[\u4e00-\u9fa5]+$")) {
|
|
|
throw new CustomException("就诊人名称不合法");
|
|
|
}
|
|
|
- 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) {
|
|
|
- throw new CustomException("年龄必须大于18岁");
|
|
|
- }
|
|
|
- if (age > 200) {
|
|
|
- throw new CustomException("年龄超过200岁");
|
|
|
- }
|
|
|
+// 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) {
|
|
|
+// throw new CustomException("年龄必须大于18岁");
|
|
|
+// }
|
|
|
+// if (age > 200) {
|
|
|
+// throw new CustomException("年龄超过200岁");
|
|
|
+// }
|
|
|
Date birthday = fsPatient.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) {
|
|
|
- throw new CustomException("年龄必须大于18岁");
|
|
|
- }
|
|
|
- if (age2 > 200) {
|
|
|
- throw new CustomException("年龄超过200岁");
|
|
|
+ if (birthday!=null){
|
|
|
+ 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) {
|
|
|
+ throw new CustomException("年龄必须大于18岁");
|
|
|
+ }
|
|
|
+ if (age2 > 200) {
|
|
|
+ throw new CustomException("年龄超过200岁");
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
return toAjax(fsPatientService.insertFsPatient(fsPatient));
|
|
|
}
|
|
|
|
|
@@ -186,48 +214,78 @@ public class FsPatientController extends BaseController
|
|
|
public AjaxResult edit(@RequestBody FsPatient fsPatient)
|
|
|
{
|
|
|
String idCardNumber = fsPatient.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 (fsPatient.getPatientName().length()<2||fsPatient.getPatientName().length()>30||!fsPatient.getPatientName().matches("^[\u4e00-\u9fa5]+$")) {
|
|
|
- throw new CustomException("就诊人名称不合法");
|
|
|
- }
|
|
|
- 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) {
|
|
|
- throw new CustomException("年龄必须大于18岁");
|
|
|
- }
|
|
|
- if (age > 200) {
|
|
|
- throw new CustomException("年龄超过200岁");
|
|
|
+// if (idCardNumber == null || idCardNumber.length() != 18) {
|
|
|
+// throw new CustomException("身份证号码不合法");
|
|
|
+// }
|
|
|
+// String regex = "\\d{17}[0-9Xx]";
|
|
|
+// if (!Pattern.matches(regex, idCardNumber)) {
|
|
|
+// throw new CustomException("身份证号码不合法");
|
|
|
+// }
|
|
|
+// if (fsPatient.getPatientName().length()<2||fsPatient.getPatientName().length()>30||!fsPatient.getPatientName().matches("^[\u4e00-\u9fa5]+$")) {
|
|
|
+// throw new CustomException("就诊人名称不合法");
|
|
|
+// }
|
|
|
+// 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) {
|
|
|
+// throw new CustomException("年龄必须大于18岁");
|
|
|
+// }
|
|
|
+// if (age > 200) {
|
|
|
+// throw new CustomException("年龄超过200岁");
|
|
|
+// }
|
|
|
+ if (StringUtils.isNotBlank(idCardNumber)) {
|
|
|
+ if (idCardNumber.length() != 18) {
|
|
|
+ throw new CustomException("身份证号码不合法");
|
|
|
+ }
|
|
|
+ String regex = "\\d{17}[0-9Xx]";
|
|
|
+ if (!Pattern.matches(regex, idCardNumber)) {
|
|
|
+ throw new CustomException("身份证号码不合法");
|
|
|
+ }
|
|
|
+ if (fsPatient.getPatientName().length()<2||fsPatient.getPatientName().length()>30||!fsPatient.getPatientName().matches("^[\u4e00-\u9fa5]+$")) {
|
|
|
+ throw new CustomException("就诊人名称不合法");
|
|
|
+ }
|
|
|
+ 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) {
|
|
|
+ throw new CustomException("年龄必须大于18岁");
|
|
|
+ }
|
|
|
+ if (age > 200) {
|
|
|
+ throw new CustomException("年龄超过200岁");
|
|
|
+ }
|
|
|
}
|
|
|
Date birthday = fsPatient.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) {
|
|
|
- throw new CustomException("年龄必须大于18岁");
|
|
|
- }
|
|
|
- if (age2 > 200) {
|
|
|
- throw new CustomException("年龄超过200岁");
|
|
|
+ if (birthday!=null){
|
|
|
+ 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) {
|
|
|
+ throw new CustomException("年龄必须大于18岁");
|
|
|
+ }
|
|
|
+ if (age2 > 200) {
|
|
|
+ throw new CustomException("年龄超过200岁");
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
return toAjax(fsPatientService.updateFsPatient(fsPatient));
|
|
|
}
|
|
|
|