Browse Source

优化病案统计,优化魔法数

lighter 2 years ago
parent
commit
01fa92782f

+ 1 - 0
src/main/java/thyyxxk/webserver/controller/inpatient/casefrontsheet/CaseFrontSheetController.java

@@ -5,6 +5,7 @@ import org.springframework.web.bind.annotation.*;
 import thyyxxk.webserver.config.auth.PassToken;
 import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.casefrontsheet.*;
+import thyyxxk.webserver.entity.casefrontsheet.request.SheetAnalyzeParams;
 import thyyxxk.webserver.entity.dictionary.CodeName;
 import thyyxxk.webserver.service.inpatient.casefrontsheet.CaseFrontSheetAnalyzeService;
 import thyyxxk.webserver.service.inpatient.casefrontsheet.CaseFrontSheetMainService;

+ 57 - 21
src/main/java/thyyxxk/webserver/dao/his/inpatient/casefrontsheet/CaseFrontSheetAnalyzeDao.java

@@ -17,32 +17,68 @@ public interface CaseFrontSheetAnalyzeDao {
     List<TempDismissCount> selectDismissCount(@Param("start") String start,
                                               @Param("end") String end);
 
-    @Select("<script>" +
+    @Select("select a.bah as patNo,a.admiss_times as times, " +
+            "a.name as name,gender=(case when a.sex='1' then N'男' else N'女' end), " +
+            "a.age,a.admiss_date,a.dismiss_date as disDate, " +
+            "inHospDays=admiss_days,a.total_cost as total_charge, " +
+            "a.trans_dept as disDept,a.clinic_diag_str as admDiag, " +
+            "disDiag=(select t.name from t_case_frontsheet_disdiag t where t.bah=a.bah " +
+            "and t.times=a.admiss_times and t.no=1), " +
+            "blfx=a.case_classification,admiss_dept,a.trans_dept as zkWard, " +
+            "a.dept_leader_name as kzy,a.main_doctor_name as zzys, " +
+            "a.admiss_doctor_name as zyys,fdcrb=a.statutory_epidemic " +
+            "from t_case_frontsheet_main a where a.trans_dept_code like #{dept} and " +
+            "a.dismiss_date>=#{begntime} and a.dismiss_date<=#{endtime} " +
+            "order by a.trans_dept_code ")
+    List<DismissCount> selectDismissDetailCount(@Param("begntime") String begntime,
+                                                @Param("endtime") String endtime,
+                                                @Param("dept") String dept);
+
+
+    @Select("select rtrim(a.inpatient_no) as patNo,a.admiss_times as times, " +
+            "rtrim(a.name) as name,gender=(case when a.sex='1' then N'男' else N'女' end),  " +
+            "age=datediff(year,b.birth_date,getdate()),a.admiss_date,d.start_time as dis_date, " +
+            "inHospDays=datediff(day, a.admiss_date, d.start_time),a.total_charge, " +
+            "rtrim(a.zk_ward) as disDept,rtrim(a.clinic_diag_str) as admDiag,  " +
+            "disDiag=(select dis_diag_comment from ba_first_page1 t where t.inpatient_no=a.inpatient_no  " +
+            "and t.admiss_times=a.admiss_times and t.dis_diag_no=1),  " +
+            "blfx=isnull(c.blfx,''),rtrim(a.small_dept) as admissDept,rtrim(a.zk_ward) as zkWard,  " +
+            "c.kzr,c.zzys,c.zyys,fdcrb=isnull(c.fdcrb,'') " +
+            "from zy_inactpatient a, a_patient_mi b, batj_ba2 c, " +
+            "(select inpatient_no,admiss_times,start_time from yz_act_order " +
+            "where start_time>=#{begntime} and start_time<=#{endtime} " +
+            "and order_code='05973' and exec_unit like #{dept} " +
+            "union " +
+            "select inpatient_no,admiss_times,start_time from yz_inact_order " +
+            "where start_time>=#{begntime} and start_time<=#{endtime} " +
+            "and order_code='05973' and exec_unit like #{dept}) d " +
+            "where a.inpatient_no=b.inpatient_no and a.inpatient_no=c.zyh and " +
+            "      a.inpatient_no=d.inpatient_no and a.admiss_times=c.zycs and " +
+            "      a.admiss_times=d.admiss_times " +
+            "union " +
             "select rtrim(a.inpatient_no) as patNo,a.admiss_times as times, " +
-            "rtrim(a.name) as name,gender=(case when a.sex='1' then '男' else '女' end), " +
-            "age=datediff(year,b.birth_date,getdate()),a.admiss_date,a.dis_date, " +
-            "inHospDays=datediff(day, a.admiss_date, a.dis_date),a.total_charge, " +
+            "rtrim(a.name) as name,gender=(case when a.sex='1' then N'男' else N'女' end), " +
+            "age=datediff(year,b.birth_date,getdate()),a.admiss_date,d.start_time as dis_date, " +
+            "inHospDays=datediff(day, a.admiss_date, d.start_time),a.total_charge, " +
             "rtrim(a.zk_ward) as disDept,rtrim(a.clinic_diag_str) as admDiag, " +
             "disDiag=(select dis_diag_comment from ba_first_page1 t where t.inpatient_no=a.inpatient_no " +
             "and t.admiss_times=a.admiss_times and t.dis_diag_no=1), " +
             "blfx=isnull(c.blfx,''),rtrim(a.small_dept) as admissDept,rtrim(a.zk_ward) as zkWard, " +
-            "c.kzr,c.zzys,c.zyys,fdcrb=isnull(c.fdcrb,'')," +
-            "deadOrder=(select count(1) from yz_inact_order t where t.inpatient_no=a.inpatient_no and " +
-            "t.admiss_times=a.admiss_times and t.order_code='05973') " +
-            "from zy_inactpatient a, a_patient_mi b, batj_ba2 c where " +
-            "a.inpatient_no not like 'S%' and " +
-            "a.inpatient_no not like 'JT%' and " +
-            "<if test=\" dept!=null and dept!='' \">" +
-            "a.zk_ward=#{dept} and " +
-            "</if>" +
-            "charindex('$',a.inpatient_no)=0 and " +
-            "a.dis_date&gt;=#{begntime} and a.dis_date&lt;=#{endtime} and " +
-            "a.inpatient_no=b.inpatient_no and a.inpatient_no=c.zyh and a.admiss_times=c.zycs " +
-            "order by a.zk_ward " +
-            "</script>")
-    List<DismissCount> selectDismissDetailCount(@Param("begntime") String begntime,
-                                                @Param("endtime") String endtime,
-                                                @Param("dept") String dept);
+            "c.kzr,c.zzys,c.zyys,fdcrb=isnull(c.fdcrb,'') " +
+            "from zy_actpatient a, a_patient_mi b, batj_ba2 c, " +
+            "(select inpatient_no,admiss_times,start_time from yz_act_order " +
+            "where start_time>=#{begntime} and start_time<=#{endtime} " +
+            "and order_code='05973' and exec_unit like #{dept} union " +
+            "select inpatient_no,admiss_times,start_time from yz_inact_order " +
+            "where start_time>=#{begntime} and start_time<=#{endtime} " +
+            "and order_code='05973' and exec_unit like #{dept}) d " +
+            "where a.inpatient_no=b.inpatient_no and a.inpatient_no=c.zyh and " +
+            "      a.inpatient_no=d.inpatient_no and a.admiss_times=c.zycs and " +
+            "      a.admiss_times=d.admiss_times ")
+    List<DismissCount> selectDeathCount(@Param("begntime") String begntime,
+                                        @Param("endtime") String endtime,
+                                        @Param("dept") String dept);
+
 
     @Select("select diag_conform2,diag_conform3,diag_conform4,rescue_times,rescue_success_times, " +
             "quality_control_level,admiss_days,${deptIdentity}_code as deptCode,${deptIdentity} as deptName " +

+ 18 - 0
src/main/java/thyyxxk/webserver/entity/casefrontsheet/request/CountType.java

@@ -0,0 +1,18 @@
+package thyyxxk.webserver.entity.casefrontsheet.request;
+
+public enum CountType {
+    /**
+     * 按科室计数
+     * */
+    BY_DEPARTMENT,
+
+    /**
+     * 按明细计数
+     * */
+    BY_DETAIL,
+
+    /**
+     * 死亡患者计数
+     * */
+    BY_DEATH
+}

+ 6 - 2
src/main/java/thyyxxk/webserver/entity/casefrontsheet/SheetAnalyzeParams.java → src/main/java/thyyxxk/webserver/entity/casefrontsheet/request/SheetAnalyzeParams.java

@@ -1,4 +1,4 @@
-package thyyxxk.webserver.entity.casefrontsheet;
+package thyyxxk.webserver.entity.casefrontsheet.request;
 
 import lombok.Data;
 
@@ -8,6 +8,10 @@ public class SheetAnalyzeParams {
     private String year;
     private String beginMonth;
     private String endMonth;
-    private Integer type;
+    private CountType countType;
     private String dept;
+
+    public String getDept() {
+        return null == dept ? "" : dept;
+    }
 }

+ 15 - 6
src/main/java/thyyxxk/webserver/service/inpatient/casefrontsheet/CaseFrontSheetAnalyzeService.java

@@ -6,6 +6,8 @@ import org.springframework.stereotype.Service;
 import thyyxxk.webserver.dao.his.inpatient.casefrontsheet.CaseFrontSheetAnalyzeDao;
 import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.casefrontsheet.*;
+import thyyxxk.webserver.entity.casefrontsheet.request.CountType;
+import thyyxxk.webserver.entity.casefrontsheet.request.SheetAnalyzeParams;
 import thyyxxk.webserver.service.redislike.RedisLikeService;
 import thyyxxk.webserver.utils.*;
 
@@ -26,9 +28,9 @@ public class CaseFrontSheetAnalyzeService {
 
     public ResultVo<List<DismissCount>> analyzeDismissCount(SheetAnalyzeParams param) {
         String[] dateRange = getDatetimeRangeByMonth(param.getMonth());
-        int type = param.getType();
+        param.setDept("%" + param.getDept().trim() + "%");
         List<DismissCount> list;
-        if (type == 1) {
+        if (param.getCountType() == CountType.BY_DEPARTMENT) {
             List<TempDismissCount> templist = dao.selectDismissCount(dateRange[0], dateRange[1]);
             Map<String, DismissCount> map = new HashMap<>();
             for (TempDismissCount item : templist) {
@@ -58,11 +60,17 @@ public class CaseFrontSheetAnalyzeService {
             for (Map.Entry<String, DismissCount> entry : map.entrySet()) {
                 list.add(entry.getValue());
             }
-        } else {
+        } else if (param.getCountType() == CountType.BY_DETAIL) {
             list = dao.selectDismissDetailCount(dateRange[0], dateRange[1], param.getDept());
-            if (type == 3) {
-                list.removeIf(item -> item.getDeadOrder() == 0);
+            for (DismissCount item : list) {
+                if (StringUtil.equalsIgnoreNull(item.getZkWard(), item.getAdmissDept())) {
+                    item.setZkWard(null);
+                }
+                item.setBlfx(FilterUtil.filterCaseClassification(item.getBlfx()));
+                item.setFdcrb(FilterUtil.filterNotifiableInfectiousDiseases(item.getFdcrb()));
             }
+        } else {
+            list = dao.selectDeathCount(dateRange[0], dateRange[1], param.getDept());
             for (DismissCount item : list) {
                 if (StringUtil.equalsIgnoreNull(item.getZkWard(), item.getAdmissDept())) {
                     item.setZkWard(null);
@@ -88,7 +96,8 @@ public class CaseFrontSheetAnalyzeService {
         } else {
             dateRange = getDatetimeRangeByYear(params.getYear());
         }
-        String deptIdentity = params.getType() == 1 ? "admiss_dept" : "dismiss_dept";
+        String deptIdentity = params.getCountType() == CountType.BY_DEPARTMENT ?
+                "admiss_dept" : "dismiss_dept";
         List<SheetQualitySources> qualitySources = dao.selectSheetQualitySource(dateRange[0], dateRange[1], deptIdentity);
         Map<String, List<SheetQualitySources>> deptQualitySources = new HashMap<>();
         for (SheetQualitySources sources : qualitySources) {

+ 6 - 0
src/main/java/thyyxxk/webserver/utils/FilterUtil.java

@@ -273,6 +273,9 @@ public class FilterUtil {
     }
 
     public static String filterCaseClassification(String val) {
+        if (StringUtil.isBlank(val)) {
+            return "";
+        }
         switch (val) {
             case "1":
                 return "A";
@@ -288,6 +291,9 @@ public class FilterUtil {
     }
 
     public static String filterNotifiableInfectiousDiseases(String val) {
+        if (StringUtil.isBlank(val)) {
+            return "";
+        }
         switch (val) {
             case "1":
                 return "甲类";