Selaa lähdekoodia

长沙市病种统计

hsh 2 vuotta sitten
vanhempi
commit
8868bd502c

+ 48 - 0
src/main/java/thyyxxk/webserver/controller/ybkf/YbCssBzController.java

@@ -0,0 +1,48 @@
+package thyyxxk.webserver.controller.ybkf;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.entity.ybkf.YbkfShareDto;
+import thyyxxk.webserver.service.ybkf.YbCssBzService;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Description: 长沙市病种统计
+ * @Author: hsh
+ * @CreateTime: 2022-09-20  10:26
+ * @Version: 1.0
+ */
+@RestController
+@RequestMapping("/cssBzTj")
+public class YbCssBzController {
+
+    private final YbCssBzService service;
+
+    @Autowired
+    public YbCssBzController(YbCssBzService service) {
+        this.service = service;
+    }
+
+    @PostMapping("/selectCssYbBzTj")
+    public ResultVo<List<Map<String, Object>>> selectCssYbBzTj(@RequestBody @Validated YbkfShareDto dto){
+        return service.selectCssYbBzTj(dto);
+    }
+
+    @PostMapping("/selectBzDbTj")
+    public ResultVo<List<Map<String, Object>>> selectBzDbTj(@RequestBody @Validated YbkfShareDto dto){
+        return service.selectBzDbTj(dto);
+    }
+
+    @PostMapping("/selectBzDbBrTj")
+    public ResultVo<List<Map<String, Object>>> selectBzDbBrTj(@RequestBody @Validated YbkfShareDto dto){
+        return service.selectBzDbBrTj(dto);
+    }
+
+}

+ 127 - 0
src/main/java/thyyxxk/webserver/dao/his/ybkf/YbCssBzDao.java

@@ -0,0 +1,127 @@
+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;
+
+/**
+ * @description: 长沙市病种统计
+ * @author: hsh
+ * @date: 2022/9/20 10:41
+ **/
+@Mapper
+public interface YbCssBzDao {
+
+    @Select(" <script> " +
+            " select main_diagn_code as zdbm, main_diagn_name as zdmc, count(setl_id) rs, " +
+            " cast(sum(estimated_payment)/count(setl_id) as decimal(10, 2)) as cjyjzf, " +
+            " cast(sum(reimburse_amount)/count(setl_id) as decimal(10, 2)) as cjtczf, " +
+            " sum(reimburse_amount) as tczf, sum(estimated_payment) as yjzf, sum(bal) bal " +
+            " from yb_css_setl_info where flag = '0' " +
+            " and settl_time &gt;= #{beginTime} " +
+            " and settl_time &lt;= #{endTime} " +
+            " <if test=\"dept != null and dept != '' \">" +
+            " and dept_name = #{dept} " +
+            " </if> " +
+            " <if test=\"doctor != null and doctor != '' \">" +
+            " and doctor = #{doctor} " +
+            " </if> " +
+            " <if test=\"bzmc != null and bzmc != '' \">" +
+            " and main_diagn_name like '%' + #{bzmc} + '%' " +
+            " </if> " +
+            " <if test=\"insurName != null and insurName != '' \">" +
+            " and medins_type = #{insurName} " +
+            " </if> " +
+            " group by main_diagn_code, main_diagn_name " +
+            " order by sum(bal) desc" +
+            " </script> ")
+    List<Map<String, Object>> selectCssYbBzTj(@Param("beginTime") String beginTime, @Param("endTime") String endTime,
+        @Param("dept") String dept, @Param("insurName") String insurName, @Param("bzmc") String bzmc, @Param("doctor") String doctor);
+
+    @Select(" <script> " +
+            " select main_diagn_code as zdbm, main_diagn_name as zdmc, " +
+            " treatment as zlfs, declaration_type as sblx, real_score as fz, " +
+            " estimated_payment as yjzf, reimburse_amount as tczf, bal " +
+            " from yb_css_setl_info where flag = '0' " +
+            " and settl_time &gt;= #{beginTime} " +
+            " and settl_time &lt;= #{endTime} " +
+            " <if test=\"dept != null and dept != '' \">" +
+            " and dept_name = #{dept} " +
+            " </if> " +
+            " <if test=\"doctor != null and doctor != '' \">" +
+            " and doctor = #{doctor} " +
+            " </if> " +
+            " <if test=\"bzmc != null and bzmc != '' \">" +
+            " and main_diagn_name like '%' + #{bzmc} + '%' " +
+            " </if> " +
+            " <if test=\"insurName != null and insurName != '' \">" +
+            " and medins_type = #{insurName} " +
+            " </if> " +
+            " </script> ")
+    List<Map<String, Object>> selectCssYbBzTjMx(@Param("beginTime") String beginTime, @Param("endTime") String endTime,
+        @Param("dept") String dept, @Param("insurName") String insurName, @Param("bzmc") String bzmc, @Param("doctor") String doctor);
+
+    @Select(" <script> " +
+            " select main_diagn_code as zdbm, main_diagn_name as zdmc, " +
+            " dept_id as deptId, dept_name as dept, " +
+            " doctor_id as doctorId, doctor, medins_type as insurName, " +
+            " treatment as zlfs, declaration_type as sblx, " +
+            " sum(medical_total_fee) as zfy, sum(real_score) as fz, count(setl_id) rs, " +
+            " sum(estimated_payment) as yjzf, sum(reimburse_amount) as tczf, sum(bal) bal, " +
+            " cast(sum(medical_total_fee)/count(setl_id) as decimal(10, 2)) as cjzfy, " +
+            " cast(sum(estimated_payment)/count(setl_id) as decimal(10, 2)) as cjyjzf, " +
+            " cast(sum(reimburse_amount)/count(setl_id) as decimal(10, 2)) as cjtczf " +
+            " from yb_css_setl_info where flag = '0' " +
+            " and settl_time &gt;= #{beginTime} " +
+            " and settl_time &lt;= #{endTime} " +
+            " <if test=\"dept != null and dept != '' \">" +
+            " and dept_name = #{dept} " +
+            " </if> " +
+            " and treatment = #{zlfs} " +
+            " and declaration_type = #{sblx} " +
+            " and main_diagn_name = #{bzmc} " +
+            " <if test=\"doctor != null and doctor != '' \">" +
+            " and doctor = #{doctor} " +
+            " </if> " +
+            " <if test=\"insurName != null and insurName != '' \">" +
+            " and medins_type = #{insurName} " +
+            " </if> " +
+            " group by main_diagn_code, main_diagn_name, dept_id, dept_name, doctor_id, doctor, medins_type, treatment, declaration_type  " +
+            " </script> ")
+    List<Map<String, Object>> selectBzDbTj(@Param("beginTime") String beginTime, @Param("endTime") String endTime,
+        @Param("dept") String dept, @Param("insurName") String insurName, @Param("bzmc") String bzmc, @Param("doctor") String doctor,
+        @Param("zlfs") String zlfs, @Param("sblx") String sblx);
+
+    @Select(" <script> " +
+            " select main_diagn_code as zdbm, main_diagn_name as zdmc, " +
+            " dept_id as deptId, dept_name as dept, settl_time as jssj, " +
+            " doctor_id as doctorId, doctor, medins_type as yblx, " +
+            " treatment as zlfs, declaration_type as sblx, " +
+            " medical_total_fee as zfy, real_score as fz, " +
+            " estimated_payment as yjzf, reimburse_amount as tczf, bal, " +
+            " pat_no as zyh, psn_name as xm, main_operate_code as ssbm, main_operate_name as ssmc " +
+            " from yb_css_setl_info where flag = '0' " +
+            " and settl_time &gt;= #{beginTime} " +
+            " and settl_time &lt;= #{endTime} " +
+            " and dept_name = #{dept} " +
+            " and treatment = #{zlfs} " +
+            " and declaration_type = #{sblx} " +
+            " and main_diagn_name = #{bzmc} " +
+            " <if test=\"doctor != null and doctor != '' \">" +
+            " and doctor = #{doctor} " +
+            " </if> " +
+            " <if test=\"doctor == null and doctor == '' \">" +
+            " and (doctor = '' or doctor is null) " +
+            " </if> " +
+            " <if test=\"insurName != null and insurName != '' \">" +
+            " and medins_type = #{insurName} " +
+            " </if> " +
+            " </script> ")
+    List<Map<String, Object>> selectBzDbBrTj(@Param("beginTime") String beginTime, @Param("endTime") String endTime,
+        @Param("dept") String dept, @Param("insurName") String insurName, @Param("bzmc") String bzmc, @Param("doctor") String doctor,
+        @Param("zlfs") String zlfs, @Param("sblx") String sblx);
+
+}

+ 18 - 0
src/main/java/thyyxxk/webserver/entity/ybkf/YbkfShareDto.java

@@ -14,7 +14,9 @@ public class YbkfShareDto {
     private String startTime;
     private String endTime;
     private String deptId;
+    private String dept;
     private String doctorId;
+    private String doctor;
     private String insurId;
     private String insurName;
     private MultipartFile file;
@@ -22,4 +24,20 @@ public class YbkfShareDto {
      * 年份
      */
     private String nf;
+    /**
+     * 病种名称
+     */
+    private String bzmc;
+    /**
+     * 盈亏: y(盈余) k(亏损)
+     */
+    private String yk;
+    /**
+     * 治疗方案
+     */
+    private String zlfs;
+    /**
+     * 申报类型
+     */
+    private String sblx;
 }

+ 193 - 0
src/main/java/thyyxxk/webserver/service/ybkf/YbCssBzService.java

@@ -0,0 +1,193 @@
+package thyyxxk.webserver.service.ybkf;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import thyyxxk.webserver.dao.his.ybkf.YbCssBzDao;
+import thyyxxk.webserver.entity.ResultVo;
+import thyyxxk.webserver.entity.ybkf.YbkfShareDto;
+import thyyxxk.webserver.utils.DecimalUtil;
+import thyyxxk.webserver.utils.ResultVoUtil;
+import thyyxxk.webserver.utils.StringUtil;
+
+import java.text.MessageFormat;
+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-09-20 10:26
+ * @Version: 1.0
+ */
+@Service
+public class YbCssBzService {
+
+    private final YbCssBzDao dao;
+
+    @Autowired
+    public YbCssBzService(YbCssBzDao dao) {
+        this.dao = dao;
+    }
+
+    /**
+     * @description: 查询长沙市病种
+     * @author: hsh
+     * @date: 2022/9/20 10:38
+     * @param: [dto]
+     * @return: ResultVo<List<Map<String,Object>>>
+     **/
+    public ResultVo<List<Map<String, Object>>> selectCssYbBzTj(YbkfShareDto dto){
+        String beginTime = dto.getStartTime();
+        String endTime = dto.getEndTime();
+        String dept = dto.getDept();
+        String insurName = dto.getInsurName();
+        String bzmc = dto.getBzmc();
+        String doctor = dto.getDoctor();
+        String yk = dto.getYk();
+        List<Map<String, Object>> result = dao.selectCssYbBzTj(beginTime, endTime, dept, insurName, bzmc, doctor);
+        List<Map<String, Object>> bzTjmx = dao.selectCssYbBzTjMx(beginTime, endTime, dept, insurName, bzmc, doctor);
+
+        Map<String, List<Map<String, Object>>> bzMap = bzTjmx.stream().collect(Collectors.groupingBy(f -> String.valueOf(f.get("zdmc")), Collectors.toList()));
+
+        if(StringUtil.isBlank(yk)){
+
+            callBzMxInfo(result, bzMap);
+
+            return ResultVoUtil.success(result);
+        } else {
+            List<Map<String, Object>> ls = new ArrayList<>();
+            if("y".equals(yk)){
+                for(Map<String, Object> map : result){
+                    double bal = Double.parseDouble(map.get("bal") + "");
+                    if(bal >= 0d){
+                        ls.add(map);
+                    }
+                }
+            } else {
+                for(Map<String, Object> map : result){
+                    double bal = Double.parseDouble(map.get("bal") + "");
+                    if(bal < 0d){
+                        ls.add(map);
+                    }
+                }
+                ls = ls.stream().sorted((e1,e2) -> -Double.compare(Double.valueOf(e1.get("bal") + ""), Double.valueOf(e2.get("bal") + ""))).collect(Collectors.toList());
+            }
+
+            callBzMxInfo(ls, bzMap);
+
+            return ResultVoUtil.success(ls);
+
+        }
+
+    }
+
+    /**
+     * @description: 病种添加明细信息
+     * @author: hsh
+     * @date: 2022/9/21 8:44
+     * @param: [list, bzMap]
+     * @return: void
+     **/
+    private void callBzMxInfo(List<Map<String, Object>> list, Map<String, List<Map<String, Object>>> bzMap) {
+        if(null != bzMap || bzMap.size() != 0){
+            for(Map<String, Object> map : list){
+                String zdbm = map.get("zdbm") + "";
+                String zdmc = map.get("zdmc") + "";
+                List<Map<String, Object>> bzmx = bzMap.get(zdmc);
+                List<Map<String, Object>> childrenList = new ArrayList<>();
+                if(bzmx.size() > 0){
+                    Map<String, List<Map<String, Object>>> m2 = bzmx.stream().collect(Collectors.groupingBy(f -> formatString(f.get("zlfs"), f.get("sblx"))));
+                    for(Map.Entry<String, List<Map<String, Object>>> entry : m2.entrySet()){
+                        Map<String, Object> m1 = new HashMap<>();
+                        String key = entry.getKey();
+                        String[] gb = key.split("\\|");
+                        List<Map<String, Object>> l = entry.getValue();
+                        String yjzf = "0";
+                        String tczf = "0";
+                        int rs = 0;
+                        String fz = "0";
+                        String bal = "0";
+                        for(Map<String, Object> m3 : l){
+                            String o1 = m3.get("yjzf") + "";
+                            String o2 = m3.get("tczf") + "";
+                            String o4 = m3.get("fz") + "";
+                            String o5 = m3.get("bal") + "";
+                            yjzf = DecimalUtil.add(yjzf, o1);
+                            tczf = DecimalUtil.add(tczf, o2);
+                            fz = DecimalUtil.add(fz, o4);
+                            bal = DecimalUtil.add(bal, o5);
+                            rs ++;
+                        }
+                        m1.put("zdmc", zdmc);
+                        m1.put("zdbm", zdbm);
+                        m1.put("yjzf", yjzf);
+                        m1.put("tczf", tczf);
+                        m1.put("rs", rs);
+                        m1.put("cjyjzf", DecimalUtil.divide(yjzf, String.valueOf(rs), 2));
+                        m1.put("cjtczf", DecimalUtil.divide(tczf, String.valueOf(rs), 2));
+                        m1.put("zlfs", gb[0]);
+                        m1.put("sblx", gb[1]);
+                        m1.put("fz", fz);
+                        m1.put("bal", bal);
+                        childrenList.add(m1);
+                    }
+                }
+                if(childrenList.size() > 0){
+                    map.put("children", childrenList);
+                    map.put("childKey", zdmc);
+                    map.put("isChildren", true);
+                }
+            }
+        }
+    }
+
+    /**
+     * @description: 病种对比信息查询
+     * @author: hsh
+     * @date: 2022/9/21 11:20
+     * @param: [dto]
+     * @return: ResultVo<List<Map<String,Object>>>
+     **/
+    public ResultVo<List<Map<String, Object>>> selectBzDbTj(YbkfShareDto dto){
+        String beginTime = dto.getStartTime();
+        String endTime = dto.getEndTime();
+        String dept = dto.getDept();
+        String insurName = dto.getInsurName();
+        String bzmc = dto.getBzmc();
+        String doctor = dto.getDoctor();
+        String zlfs = dto.getZlfs();
+        String sblx = dto.getSblx();
+
+        List<Map<String, Object>> list = dao.selectBzDbTj(beginTime, endTime, dept, insurName, bzmc, doctor, zlfs, sblx);
+        return ResultVoUtil.success(list);
+    }
+
+    /**
+     * @description: 病种对比病人信息查询
+     * @author: hsh
+     * @date: 2022/9/21 15:30
+     * @param: [dto]
+     * @return: ResultVo<List<Map<String,Object>>>
+     **/
+    public ResultVo<List<Map<String, Object>>> selectBzDbBrTj(YbkfShareDto dto){
+        String beginTime = dto.getStartTime();
+        String endTime = dto.getEndTime();
+        String dept = dto.getDept();
+        String insurName = dto.getInsurName();
+        String bzmc = dto.getBzmc();
+        String doctor = dto.getDoctor();
+        String zlfs = dto.getZlfs();
+        String sblx = dto.getSblx();
+
+        List<Map<String, Object>> list = dao.selectBzDbBrTj(beginTime, endTime, dept, insurName, bzmc, doctor, zlfs, sblx);
+        return ResultVoUtil.success(list);
+    }
+
+    private String formatString(Object... paras) {
+        return MessageFormat.format("{0}|{1}", paras);
+    }
+
+}