Kaynağa Gözat

16岁以下或60岁以上的患者,联系人不能填写本人

lighter 3 yıl önce
ebeveyn
işleme
3aa118b1b6

+ 1 - 1
pom.xml

@@ -10,7 +10,7 @@
     </parent>
     <groupId>thyyxxk</groupId>
     <artifactId>web-server</artifactId>
-    <version>2</version>
+    <version>1</version>
     <name>web-server</name>
     <description>server for yibao-web</description>
     <properties>

+ 13 - 5
src/main/java/thyyxxk/webserver/service/yibao/DismissService.java

@@ -1,6 +1,5 @@
 package thyyxxk.webserver.service.yibao;
 
-import com.alibaba.fastjson.JSON;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -20,7 +19,6 @@ import thyyxxk.webserver.service.externalhttp.SiZySrvc;
 import thyyxxk.webserver.utils.*;
 
 import java.math.BigDecimal;
-import java.math.BigInteger;
 import java.util.*;
 
 /**
@@ -163,6 +161,16 @@ public class DismissService {
             exception.setMessage("没有找到入院时间,请重新获取病人信息。");
             throw new BizException(exception);
         }
+        if (!IdCardUtil.isValidatedIdCard(param.getSocialNo())) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "身份证不合法!");
+        }
+        int age = IdCardUtil.getAgeByIdCard(param.getSocialNo());
+        if (age < 16 || age > 60) {
+            if (param.getName().equals(param.getContactName()) ||
+                    param.getContactRelation().equals("0")) {
+                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "16岁以下或60岁以上的患者,联系人不能填写本人。");
+            }
+        }
         Date endtime = getEndtime(param.getMidSetl(), patNo, times, param.getZjdzDatetime());
         Date tmpendtime = param.getMidSetl() ? endtime : DateUtil.parse("2999-12-31 23:59:59");
         final int ledgerSn = dao.getLedgerSn(patNo, times);
@@ -183,7 +191,7 @@ public class DismissService {
         }
         List<String> unreceivedDrug = dao.hasUnreceivedDrugList(patNo, times);
         if (ListUtil.notBlank(unreceivedDrug)) {
-            throw new BizException(ExceptionEnum.LOGICAL_HTML_ERROR, dischargeErrorMessage("此患者有未接收的药单", unreceivedDrug));
+            throw new BizException(ExceptionEnum.LOGICAL_HTML_ERROR, dischargeErrorMessage(unreceivedDrug));
         }
         if (dao.hasUnreceivedFees(patNo, times, tmpendtime) > 0) {
             ExceptionEnum exception = ExceptionEnum.LOGICAL_ERROR;
@@ -283,8 +291,8 @@ public class DismissService {
     }
 
 
-    private String dischargeErrorMessage(String title, List<String> messages) {
-        StringBuilder str = new StringBuilder(title + "<br />");
+    private String dischargeErrorMessage(List<String> messages) {
+        StringBuilder str = new StringBuilder("此患者有未接收的药单" + "<br />");
         for (String message : messages) {
             str.append(message).append("<br>");
         }

+ 10 - 0
src/main/java/thyyxxk/webserver/service/yibao/PatientService.java

@@ -198,6 +198,16 @@ public class PatientService {
         if (StringUtil.isBlank(patient.getContactPhone())) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "联系人电话不能为空!");
         }
+        if (!IdCardUtil.isValidatedIdCard(patient.getSocialNo())) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "身份证不合法!");
+        }
+        int age = IdCardUtil.getAgeByIdCard(patient.getSocialNo());
+        if (age < 16 || age > 60) {
+            if (patient.getName().equals(patient.getContactName()) ||
+                    patient.getContactRelation().equals("0")) {
+                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "16岁以下或60岁以上的患者,联系人不能填写本人。");
+            }
+        }
 
         String zyh = patient.getInpatientNo();
         int times = patient.getAdmissTimes();

+ 31 - 2
src/main/java/thyyxxk/webserver/utils/IdCardUtil.java

@@ -37,8 +37,6 @@ public class IdCardUtil {
         return isValidate18IdCard(idCard);
     }
 
-
-
     private static boolean isValidate18IdCard(String idCard) {
         // 非18位为假
         if (idCard.length() != MAX_LENGTH) {
@@ -195,4 +193,35 @@ public class IdCardUtil {
         }
         return a;
     }
+
+    public static int getAgeByIdCard(String idCard) {
+        String birthDay = idCard.substring(6, 14);
+        String time = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
+        String yearStr = time.split("-")[0];
+        String monthStr = time.split("-")[1];
+        String dayStr = time.split("-")[2];
+        String yearBirthStr = birthDay.substring(0, 4);
+        String monthBirthStr = birthDay.substring(4, 6);
+        String dayBirthStr = birthDay.substring(6);
+        int year = Integer.parseInt(yearStr);
+        int yearBirth = Integer.parseInt(yearBirthStr);
+        if (year - yearBirth <= 0) {
+            return 0;
+        }
+        int age = year - yearBirth;
+        int month = Integer.parseInt(monthStr);
+        int monthBirth = Integer.parseInt(monthBirthStr);
+        if (month - monthBirth > 0) {
+            return age;
+        }
+        if (month - monthBirth < 0) {
+            return --age;
+        }
+        int day = Integer.parseInt(dayStr);
+        int dayBirth = Integer.parseInt(dayBirthStr);
+        if (day - dayBirth >= 0) {
+            return age;
+        }
+        return --age;
+    }
 }