Browse Source

质控类型映射调整并根据日期来判断是否是日间病人

shiyue 3 years ago
parent
commit
2091a6b2eb

+ 56 - 23
src/main/java/com/diagbot/facade/data/ABehospitalInfoFacade.java

@@ -22,12 +22,15 @@ import com.diagbot.vo.data.ADeleteFlagVO;
 import com.diagbot.vo.data.AMedicalRecordVO;
 import com.diagbot.vo.data.APlaceFileVO;
 import com.google.common.collect.Lists;
+import io.swagger.models.auth.In;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 
+import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
 
@@ -158,19 +161,33 @@ public class ABehospitalInfoFacade extends BehospitalInfoServiceImpl {
      */
     private Long initQcTypeId(BehospitalInfo s) {
         Long qcTypeId = Long.valueOf("0");
+        //判断一下是否是日间病例
+        if (null != s.getLeaveHospitalDate()&& null !=s.getBehospitalDate()){
+                if (this.differentDays(s.getBehospitalDate(),s.getLeaveHospitalDate())<=1) {
+                    return qcTypeId;
+                }
+        }
         //判断文书表中是否有入院记录文书
-        MedicalRecord medicalRecord= aMedicalRecordFacade.getOne(new QueryWrapper<MedicalRecord>()
+        List<MedicalRecord> medicalRecordList= aMedicalRecordFacade.list(new QueryWrapper<MedicalRecord>()
         .eq("mode_id",1)
         .eq("behospital_code",s.getBehospitalCode())
         .eq("hospital_id",s.getHospitalId())
         .eq("is_deleted",IsDeleteEnum.N));
-        if (medicalRecord != null){
-            //根据科室
+        //根据疾病来判断是否有对映的质控类型
+        List<QcType> qcTypes =qcTypeFacade.list(new QueryWrapper<QcType>()
+                .eq("name", StringUtils.isNotEmpty(s.getDiagnose())?s.getDiagnose():"")
+                .eq("hospital_id",s.getHospitalId())
+                .eq("is_deleted",IsDeleteEnum.N));
+        if (qcTypes.size()>0){
+            qcTypeId=qcTypes.get(0).getId();
+        }else if (medicalRecordList.size()>=1){
+            //根据科室来判断是否有对映的质控类型
             List<QcType> qcTypeList =qcTypeFacade.list(new QueryWrapper<QcType>()
                     .eq("beh_dept_id",s.getBehDeptId())
                     .eq("hospital_id",s.getHospitalId())
                     .eq("is_deleted",IsDeleteEnum.N));
             if (qcTypeList.size()==0){
+                //没有对映的科室就根据病人的性别来判断
                 QcType qcType = qcTypeFacade.getOne(new QueryWrapper<QcType>()
                         .eq("default_module",1)
                         .eq("hospital_id",s.getHospitalId())
@@ -180,6 +197,7 @@ public class ABehospitalInfoFacade extends BehospitalInfoServiceImpl {
             }else if (qcTypeList.size()==1){
                 qcTypeId =qcTypeList.get(0).getId();
             }else {
+                //有多个科室信息就根据病人的男女来判断有对映的质控类型
                 QcType qcType =new QcType();
                 qcTypeList.forEach(qc->{
                     if (qc.getSex().equals(s.getSex()))
@@ -187,26 +205,6 @@ public class ABehospitalInfoFacade extends BehospitalInfoServiceImpl {
                 });
                 qcTypeId =qcType.getId();
             }
-//            //根据科室查找对应质控类型
-//            QcType qcTypeList = qcTypeFacade.getOne(new QueryWrapper<QcType>()
-//                    .eq("beh_dept_id", s.getBehDeptId())
-//                    .eq("hospital_id", s.getHospitalId())
-//                    .eq("default_module", 0)
-//                    .eq("sex",s.getSex())
-//                    .eq("is_deleted", IsDeleteEnum.N));
-//            if(qcTypeList == null){
-//                //无质控类型时,新增后初始化
-//                QcType qcType = qcTypeFacade.getOne(new QueryWrapper<QcType>()
-//                        .eq("default_module", 1)
-//                        .eq("hospital_id", s.getHospitalId())
-//                        .eq("sex",s.getSex())
-//                        .eq("is_deleted", IsDeleteEnum.N));
-//                if(qcType!=null){
-//                    qcTypeId = qcType.getId();
-//                }
-//            }else {
-//                qcTypeId = qcTypeList.getId();
-//            }
         }
         return qcTypeId;
     }
@@ -260,4 +258,39 @@ public class ABehospitalInfoFacade extends BehospitalInfoServiceImpl {
             return RespDTO.onError(e.getMessage());
         }
     }
+
+    public  int differentDays(Date date1,Date date2) {
+        Calendar cal1 = Calendar.getInstance();
+        cal1.setTime(date1);
+
+        Calendar cal2 = Calendar.getInstance();
+        cal2.setTime(date2);
+        int day1= cal1.get(Calendar.DAY_OF_YEAR);
+        int day2 = cal2.get(Calendar.DAY_OF_YEAR);
+
+        int year1 = cal1.get(Calendar.YEAR);
+        int year2 = cal2.get(Calendar.YEAR);
+        if(year1 != year2)   //不同一年
+        {
+            int timeDistance = 0 ;
+            for(int i = year1 ; i < year2 ; i ++)
+            {
+                if(i%4==0 && i%100!=0 || i%400==0)    //闰年
+                {
+                    timeDistance += 366;
+                }
+                else    //不是闰年
+                {
+                    timeDistance += 365;
+                }
+            }
+
+            return timeDistance + (day2-day1) ;
+        }
+        else    //同一年
+        {
+            System.out.println("判断day2 - day1 : " + (day2-day1));
+            return day2-day1;
+        }
+    }
 }

+ 70 - 19
src/main/java/com/diagbot/facade/data/AMedicalRecordFacade.java

@@ -21,6 +21,7 @@ import com.diagbot.vo.MedrecVo;
 import com.diagbot.vo.QueryVo;
 import com.diagbot.vo.data.*;
 import com.google.common.collect.Lists;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.beans.factory.annotation.Value;
@@ -438,27 +439,42 @@ public class AMedicalRecordFacade extends MedicalRecordServiceImpl {
      */
     private Long initQcTypeId(BehospitalInfo s) {
         Long qcTypeId = Long.valueOf("0");
-        //根据科室查找对应质控类型
-        List<QcType> qcTypeList =qcTypeFacade.list(new QueryWrapper<QcType>()
-                .eq("beh_dept_id",s.getBehDeptId())
+        if (null != s.getLeaveHospitalDate ()&& null !=s.getBehospitalDate()){
+                if (this.differentDays(s.getBehospitalDate(),s.getLeaveHospitalDate())<=1) {
+                    return qcTypeId;
+                }
+        }
+        //先按照疾病查找对映的质控类型没有再按照科室
+        List<QcType> qcTypes =qcTypeFacade.list(new QueryWrapper<QcType>()
+                .eq("name", StringUtils.isNotEmpty(s.getDiagnose())?s.getDiagnose():"")
                 .eq("hospital_id",s.getHospitalId())
                 .eq("is_deleted",IsDeleteEnum.N));
-        if (qcTypeList.size()==0){
-            QcType qcType = qcTypeFacade.getOne(new QueryWrapper<QcType>()
-                    .eq("default_module",1)
-                    .eq("hospital_id",s.getHospitalId())
-                    .eq("sex",s.getSex())
-                    .eq("is_deleted",IsDeleteEnum.N));
-            qcTypeId =qcType.getId();
-        }else if (qcTypeList.size()==1){
-            qcTypeId =qcTypeList.get(0).getId();
+        if (qcTypes.size()>0){
+            qcTypeId=qcTypes.get(0).getId();
         }else {
-            QcType qcType =new QcType();
-            qcTypeList.forEach(qc->{
-                if (qc.getSex().equals(s.getSex()))
-                    qcType.setId(qc.getId());
-            });
-            qcTypeId =qcType.getId();
+            //根据科室查找对应质控类型
+            List<QcType> qcTypeList = qcTypeFacade.list(new QueryWrapper<QcType>()
+                    .eq("beh_dept_id", s.getBehDeptId())
+                    .eq("hospital_id", s.getHospitalId())
+                    .eq("is_deleted", IsDeleteEnum.N));
+            if (qcTypeList.size() == 0) {
+                //科室找不到对映的质控类型就按照性别来找通用版本
+                QcType qcType = qcTypeFacade.getOne(new QueryWrapper<QcType>()
+                        .eq("default_module", 1)
+                        .eq("hospital_id", s.getHospitalId())
+                        .eq("sex", s.getSex())
+                        .eq("is_deleted", IsDeleteEnum.N));
+                qcTypeId = qcType.getId();
+            } else if (qcTypeList.size() == 1) {
+                qcTypeId = qcTypeList.get(0).getId();
+            } else {
+                QcType qcType = new QcType();
+                qcTypeList.forEach(qc -> {
+                    if (qc.getSex().equals(s.getSex()))
+                        qcType.setId(qc.getId());
+                });
+                qcTypeId = qcType.getId();
+            }
         }
         return qcTypeId;
     }
@@ -482,7 +498,7 @@ public class AMedicalRecordFacade extends MedicalRecordServiceImpl {
             modeId = Long.valueOf("0");
         }
         if (modeId==1){
-            if (medicalRecord.getRecTitle().contains("24")){
+            if (medicalRecord.getRecTitle().contains("24小时")){
                 modeId=Long.valueOf("0");
             }
         }else if (modeId==5){
@@ -569,5 +585,40 @@ public class AMedicalRecordFacade extends MedicalRecordServiceImpl {
         }
     }
 
+    public  int differentDays(Date date1,Date date2)
+    {
+        Calendar cal1 = Calendar.getInstance();
+        cal1.setTime(date1);
+
+        Calendar cal2 = Calendar.getInstance();
+        cal2.setTime(date2);
+        int day1= cal1.get(Calendar.DAY_OF_YEAR);
+        int day2 = cal2.get(Calendar.DAY_OF_YEAR);
+
+        int year1 = cal1.get(Calendar.YEAR);
+        int year2 = cal2.get(Calendar.YEAR);
+        if(year1 != year2)   //不同一年
+        {
+            int timeDistance = 0 ;
+            for(int i = year1 ; i < year2 ; i ++)
+            {
+                if(i%4==0 && i%100!=0 || i%400==0)    //闰年
+                {
+                    timeDistance += 366;
+                }
+                else    //不是闰年
+                {
+                    timeDistance += 365;
+                }
+            }
+
+            return timeDistance + (day2-day1) ;
+        }
+        else    //同一年
+        {
+            System.out.println("判断day2 - day1 : " + (day2-day1));
+            return day2-day1;
+        }
+    }
 
 }

+ 1 - 1
src/main/resources/bootstrap.yml

@@ -2,7 +2,7 @@ spring:
   application:
     name: mrqc-sys
   profiles:
-    active: test
+    active: local
   main:
     allow-bean-definition-overriding: true