소스 검색

新增门诊统筹人数统计

hsh 2 년 전
부모
커밋
c7e6081ce4

+ 26 - 0
src/main/java/thyyxxk/webserver/constants/YbTjConstant.java

@@ -17,4 +17,30 @@ public class YbTjConstant {
      **/
     public static final String ICU_DEPT = "1160000";
 
+    /**
+     * @description: 财务部
+     * @author: hsh
+     * @date: 2022/10/20 8:35
+     * @param:
+     * @return: null
+     **/
+    public static final String REGISTER_DEPT_NAME = "财务部";
+
+    /**
+     * @description: 信息中心
+     * @author: hsh
+     * @date: 2022/10/20 8:37
+     * @param:
+     * @return: null
+     **/
+    public static final String INFO_CENTER_DEPT_NAME = "信息中心";
+
+    /**
+     * @description: 医保办
+     * @author: hsh
+     * @date: 2022/10/20 8:38
+     * @param:
+     * @return: null
+     **/
+    public static final String MEDICAL_INSURANCE_DEPT_NAME = "医保办";
 }

+ 38 - 0
src/main/java/thyyxxk/webserver/controller/ybkf/OutpatientCoordinationController.java

@@ -0,0 +1,38 @@
+package thyyxxk.webserver.controller.ybkf;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import thyyxxk.webserver.config.auth.PassToken;
+import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.service.ybkf.OutpatientCoordinationService;
+
+import java.util.Map;
+
+/**
+ * @Description: 门诊统筹人数统计
+ * @Author: hsh
+ * @CreateTime: 2022-10-19  10:25
+ * @Version: 1.0
+ */
+@RestController
+@RequestMapping("/outpatientCoordination")
+public class OutpatientCoordinationController {
+
+    private final OutpatientCoordinationService service;
+
+    @Autowired
+    public OutpatientCoordinationController(OutpatientCoordinationService service) {
+        this.service = service;
+    }
+
+    @PassToken
+    @GetMapping("/selectOutpatientCoordination")
+    public ResultVo<Map<String, Object>> selectOutpatientCoordination(@RequestParam("month") String month){
+        return service.selectOutpatientCoordination(month);
+    }
+
+
+}

+ 62 - 0
src/main/java/thyyxxk/webserver/dao/his/ybkf/OutpatientCoordinationDao.java

@@ -0,0 +1,62 @@
+package thyyxxk.webserver.dao.his.ybkf;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.List;
+import java.util.Map;
+
+@Mapper
+public interface OutpatientCoordinationDao {
+
+    @Select(" select convert(varchar(100), request_day, 112) rq, cast(count(1) as varchar) rs " +
+            " from mzy_reqrec with(nolock) where cancel_mark=0 " +
+            " and convert(varchar(6), request_day, 112) = #{month} " +
+            " and unit_code != '1500010' " +
+            " group by convert(varchar(100), request_day, 112) ")
+    List<Map<String, String>> selectRegisterPeople(@Param("month") String month);
+
+    @Select(" select cast(count(distinct t.pat_no) as varchar) as rs, convert(varchar(100), t.create_datetime, 112) rq " +
+            " from t_si_pat_info t, mzy_reqrec m " +
+            " where t.pat_no = m.patient_id " +
+            " and t.med_type='11' " +
+            " and t.insutype='310' " +
+            " and m.cancel_mark=0 " +
+            " and convert(varchar(100), t.create_datetime, 112) = convert(varchar(100), m.request_day, 112) " +
+            " and convert(varchar(6), t.create_datetime, 112) = #{month} " +
+            " group by CONVERT(varchar(100), t.create_datetime, 112) ")
+    List<Map<String, String>> selectRegisterOutpatientCoordinationPeople(@Param("month") String month);
+
+    @Select(" select cast(count(1) as varchar) rs, t1.rq from " +
+            " (select pat_no, convert(varchar(100), setl_time, 112) rq " +
+            " from t_si_setlinfo where med_type='11' and insutype='310' and revoked=0 " +
+            " and convert(varchar(6), setl_time, 112) = #{month} ) t1, " +
+            " (select distinct patient_id, convert(varchar(100), request_day, 112) rq " +
+            " from mzy_reqrec with(nolock) " +
+            " where cancel_mark=0 " +
+            " and convert(varchar(6), request_day, 112) = #{month} ) t2 " +
+            " where t1.pat_no = t2.patient_id " +
+            " and t1.rq = t2.rq " +
+            " group by t1.rq ")
+    List<Map<String, String>> selectUsedOutpatientCoordinationPeople(@Param("month") String month);
+
+    @Select(" select cast(sum(tt.rs) as varchar) rs, tt.rq, tt.code, tt.dept from ( " +
+            " select count(1) rs, t1.rq, " +
+            " code = (select d.code from a_employee_mi a, zd_unit_code d WHERE a.code = t1.staff_id and d.code = a.dept_code ), " +
+            " dept = (select d.name from a_employee_mi a, zd_unit_code d WHERE a.code = t1.staff_id and d.code = a.dept_code ) " +
+            " from " +
+            " (select pat_no, convert(varchar(100), setl_time, 112) rq, staff_id " +
+            " from t_si_setlinfo where med_type='11' and insutype='310' and revoked=0 " +
+            " and convert(varchar(6), setl_time, 112) = #{month} ) t1, " +
+            " (select distinct patient_id, CONVERT(varchar(100), request_day, 112) rq " +
+            " from mzy_reqrec with(nolock) " +
+            " where cancel_mark=0 " +
+            " and convert(varchar(6), request_day, 112) = #{month} ) t2 " +
+            " where t1.pat_no = t2.patient_id " +
+            " and t1.rq = t2.rq " +
+            " group by t1.rq,t1.staff_id) tt" +
+            " group by tt.rq, tt.code, tt.dept ")
+    List<Map<String, String>> selectUsedOutpatientCoordinationDeptPeople(@Param("month") String month);
+
+}

+ 4 - 2
src/main/java/thyyxxk/webserver/dao/his/ybkf/YbCssTjDao.java

@@ -274,13 +274,15 @@ public interface YbCssTjDao {
 
     @Select("<script> " +
             " <foreach collection='list' item='item' separator='union all'> " +
-            " select sum(a.charge_fee) as charge_fee, a.ward_code, a.refer_physician, rtrim(a.inpatient_no) as inpatient_no, a.admiss_times, a.ledger_sn, " +
+            " select t.* from " +
+            " (select sum(a.charge_fee) as charge_fee, a.ward_code, a.refer_physician, rtrim(a.inpatient_no) as inpatient_no, a.admiss_times, a.ledger_sn, " +
             " rtrim(z.name) as execUnitName, rtrim(e.name) as consultPhysician " +
             " from zy_detail_charge a " +
             " left join zy_dept_code z on a.ward_code = z.code " +
             " left join a_employee_mi e on a.refer_physician = e.code " +
             " where a.inpatient_no = #{item.patNo} and a.admiss_times = #{item.times} " +
-            " group by a.ward_code, a.refer_physician, z.name, e.name, a.inpatient_no, a.admiss_times, a.ledger_sn " +
+            " group by a.ward_code, a.refer_physician, z.name, e.name, a.inpatient_no, a.admiss_times, a.ledger_sn) t " +
+            " where t.charge_fee &lt;&gt; 0 " +
             " </foreach> " +
             " </script> ")
     List<ZyDetailCharge> selectDeptShareFee(@Param("list") List<YbSetlInfo> list);

+ 145 - 0
src/main/java/thyyxxk/webserver/service/ybkf/OutpatientCoordinationService.java

@@ -0,0 +1,145 @@
+package thyyxxk.webserver.service.ybkf;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import thyyxxk.webserver.constants.YbTjConstant;
+import thyyxxk.webserver.dao.his.ybkf.OutpatientCoordinationDao;
+import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.utils.DateUtil;
+import thyyxxk.webserver.utils.ResultVoUtil;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * @Description: 门诊统筹人数统计
+ * @Author: hsh
+ * @CreateTime: 2022-10-19  10:29
+ * @Version: 1.0
+ */
+@Service
+public class OutpatientCoordinationService {
+
+    private final OutpatientCoordinationDao dao;
+
+    @Autowired
+    public OutpatientCoordinationService(OutpatientCoordinationDao dao) {
+        this.dao = dao;
+    }
+
+    public ResultVo<Map<String, Object>> selectOutpatientCoordination(String month) {
+        Map<String, Object> resultMap = new HashMap<>();
+        List<Map<String, Object>> headTitle = new ArrayList<>();
+        List<Map<String, Object>> resultList = new ArrayList<>();
+        // 挂号人数(不包含驾驶员体检人员)
+        List<Map<String, String>> register = dao.selectRegisterPeople(month);
+        // 挂号可以使用门诊统筹的
+        List<Map<String, String>> oc = dao.selectRegisterOutpatientCoordinationPeople(month);
+        // 挂号已经使用门诊统筹的
+        List<Map<String, String>> usedOc = dao.selectUsedOutpatientCoordinationPeople(month);
+        // 挂号科室已经使用门诊统筹的
+        List<Map<String, String>> deptList = dao.selectUsedOutpatientCoordinationDeptPeople(month);
+        Map<String, List<Map<String, String>>> deptMap = deptList.stream().collect(Collectors.groupingBy(map -> map.get("dept")));
+
+        List<String> list = DateUtil.getDayListOfMonth(month);
+        assert list != null;
+        Map<String, Object> head = new HashMap<>(list.size() + 2);
+        head.put("prop", "item");
+        head.put("label", "科室");
+        headTitle.add(head);
+        head = new HashMap<>();
+        head.put("prop", "total");
+        head.put("label", "合计");
+        headTitle.add(head);
+        for(String yf : list){
+            head = new HashMap<>();
+            head.put("prop", yf);
+            head.put("label", yf);
+            headTitle.add(head);
+        }
+
+        Map<String, Object> regMap = new HashMap<>(list.size() + 2);
+        Map<String, Object> ocMap = new HashMap<>(list.size() + 2);
+        Map<String, Object> uocMap = new HashMap<>(list.size() + 2);
+        int regRs = 0;
+        int ocRs = 0;
+        int uocRs = 0;
+        regMap.put("item", "门诊挂号人数");
+        for(Map<String, String> m : register){
+            regMap.put(m.get("rq"), m.get("rs"));
+            regRs = regRs + Integer.parseInt(m.get("rs"));
+        }
+        regMap.put("total", regRs);
+        resultList.add(regMap);
+        ocMap.put("item", "可以使用门诊统筹人数");
+        for(Map<String, String> m : oc){
+            ocMap.put(m.get("rq"), m.get("rs"));
+            ocRs = ocRs + Integer.parseInt(m.get("rs"));
+        }
+        ocMap.put("total", ocRs);
+        resultList.add(ocMap);
+        uocMap.put("item", "已经使用门诊统筹人数");
+        for(Map<String, String> m : usedOc){
+            uocMap.put(m.get("rq"), m.get("rs"));
+            uocRs = uocRs + Integer.parseInt(m.get("rs"));
+        }
+        uocMap.put("total", uocRs);
+        resultList.add(uocMap);
+
+        Map<String, List<Map<String, String>>> yfMap = deptList.stream().collect(Collectors.groupingBy(map -> map.get("rq")));
+        Map<String, Object> ksMap = new HashMap<>(list.size() + 2);
+        ksMap.put("item", "门诊科室");
+        int ksRs = 0;
+        for(Map.Entry<String, List<Map<String, String>>> entry : yfMap.entrySet()){
+            String rq = entry.getKey();
+            int rs = 0;
+            for(Map<String, String> m : entry.getValue()){
+                if(!(YbTjConstant.REGISTER_DEPT_NAME.equals((m.get("dept").trim()))
+                        || YbTjConstant.INFO_CENTER_DEPT_NAME.equals((m.get("dept").trim()))
+                        || YbTjConstant.MEDICAL_INSURANCE_DEPT_NAME.equals((m.get("dept").trim())))){
+                    rs = rs + Integer.parseInt(m.get("rs"));
+                }
+            }
+            ksMap.put(rq, rs);
+            ksRs = ksRs + rs;
+        }
+        ksMap.put("total", ksRs);
+
+
+        List<Map<String, Object>> ksList = new ArrayList<>();
+        for(Map.Entry<String, List<Map<String, String>>> entry : deptMap.entrySet()){
+            Map<String, Object> deptR = new HashMap<>(list.size() + 2);
+            String dept = entry.getKey().trim();
+            deptR.put("item", dept);
+            int rs = 0;
+            for(Map<String, String> m : entry.getValue()){
+                deptR.put(m.get("rq"), m.get("rs"));
+                rs = rs + Integer.parseInt(m.get("rs"));
+            }
+            deptR.put("total", rs);
+            if(YbTjConstant.REGISTER_DEPT_NAME.equals(dept)
+                    || YbTjConstant.INFO_CENTER_DEPT_NAME.equals(dept)
+                    || YbTjConstant.MEDICAL_INSURANCE_DEPT_NAME.equals(dept)){
+                resultList.add(deptR);
+            } else {
+                ksList.add(deptR);
+            }
+        }
+
+        if(ksList.size() > 0){
+            ksMap.put("children", ksList);
+            ksMap.put("childKey", "门诊科室");
+            ksMap.put("isChildren", true);
+        }
+        resultList.add(ksMap);
+
+        resultMap.put("headTitle", headTitle);
+        resultMap.put("resultData", resultList);
+        resultMap.put("deptData", ksList);
+        return ResultVoUtil.success(resultMap);
+    }
+
+}

+ 44 - 0
src/main/java/thyyxxk/webserver/utils/DateUtil.java

@@ -10,8 +10,10 @@ import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
+import java.util.List;
 
 /**
  * @author dj
@@ -390,5 +392,47 @@ public class DateUtil {
         }
         return s + "秒";
     }
+
+    /**
+     * @description: 获取某月的每一天
+     * @author: hsh
+     * @date: 2022/10/19 14:59
+     * @param: [yyyymm]
+     * @return: List<String>
+     **/
+    public static List<String> getDayListOfMonth(String yyyymm) {
+
+        if (yyyymm.length() != 6) {
+            return null;
+        }
+
+        List<String> list = new ArrayList<>();
+        String ystr = yyyymm.substring(0, 4);
+        String mstr = yyyymm.substring(4,6);
+
+        Calendar a = Calendar.getInstance();
+        //年份
+        a.set(Calendar.YEAR, Integer.parseInt(ystr));
+        //月份
+        a.set(Calendar.MONTH,Integer.parseInt(mstr) - 1);
+        a.set(Calendar.DATE, 1);
+        a.roll(Calendar.DATE, -1);
+
+        int maxDate = a.get(Calendar.DATE);
+
+        for (int i = 0; i < maxDate; i++) {
+            int d = i+1;
+            String dStr = "";
+            if (d < 10) {
+                dStr = "0" + d;
+            }else {
+                dStr = String.valueOf(d);
+            }
+            String day = ystr + mstr + dStr;
+            list.add(day);
+        }
+        return list;
+    }
+
 }