ソースを参照

Merge branch 'master' into 'master'

新增市医保测算统计

See merge request lighter/web-server!13
huangshuhua 2 年 前
コミット
0ce7dab038

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

@@ -0,0 +1,20 @@
+package thyyxxk.webserver.constants;
+
+/**
+ * @Description: 医保常量
+ * @Author: hsh
+ * @CreateTime: 2022-09-28  16:05
+ * @Version: 1.0
+ */
+public class YbTjConstant {
+
+    /**
+     * @description: 重症医学科科室编码
+     * @author: hsh
+     * @date: 2022/9/28 16:07
+     * @param:
+     * @return: null
+     **/
+    public static final String ICU_DEPT = "1160000";
+
+}

+ 60 - 0
src/main/java/thyyxxk/webserver/constants/sidicts/TreatmentMethods.java

@@ -0,0 +1,60 @@
+package thyyxxk.webserver.constants.sidicts;
+
+import thyyxxk.webserver.utils.StringUtil;
+
+/**
+ * @description: 治疗方式枚举
+ * @author: hsh
+ * @date: 2022/9/27 10:33
+ * @param: code
+ * @return: TreatmentMethods
+ **/
+public enum TreatmentMethods {
+
+    NonOperative("0", "非手术"),
+
+    TraditionalSurgery("1", "传统手术"),
+
+    InterventionalSurgery("2", "介入手术"),
+
+    MinuteSurgery("3", "微创手术"),
+
+    TumorRadioTherapy("4", "恶性肿瘤放射治疗"),
+
+    TumorChemotherapy("5", "恶性肿瘤化学治疗"),
+
+    TumorRAC("6", "恶性肿瘤放疗加化疗"),
+
+    TumorPalliativeTreatment("7", "恶性肿瘤姑息治疗"),
+
+    ELSE("8", "其它");
+
+    private final String code;
+
+    private final String name;
+
+    TreatmentMethods(String code, String name) {
+        this.code = code;
+        this.name = name;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public static TreatmentMethods get(String code) {
+        if (StringUtil.isBlank(code)) {
+            return ELSE;
+        }
+        for (TreatmentMethods treatment : TreatmentMethods.values()) {
+            if (code.trim().equals(treatment.getCode())) {
+                return treatment;
+            }
+        }
+        return ELSE;
+    }
+}

+ 5 - 0
src/main/java/thyyxxk/webserver/controller/ybkf/YbCssTjController.java

@@ -108,4 +108,9 @@ public class YbCssTjController {
         service.exportBrYbSetlExcel(response, dto);
     }
 
+    @PostMapping("/selectCssYbCsTj")
+    public ResultVo<List<Map<String, Object>>> selectCssYbCsTj(@RequestBody @Validated YbkfShareDto dto){
+        return service.selectCssYbCsTj(dto);
+    }
+
 }

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

@@ -2,6 +2,7 @@ package thyyxxk.webserver.dao.his.ybkf;
 
 import org.apache.ibatis.annotations.*;
 import thyyxxk.webserver.entity.datamodify.ZyDetailCharge;
+import thyyxxk.webserver.entity.medicalinsurance.inpatient.BatjBa4;
 import thyyxxk.webserver.entity.medicalinsurance.inpatient.YbZyDisDiag;
 import thyyxxk.webserver.entity.ybkf.*;
 
@@ -296,6 +297,15 @@ public interface YbCssTjDao {
     @Select(" select top 1 * from yb_param_info where param_type = 'setl_cc' and medins_type = #{insurName} and valid_year = #{year} ")
     YbParamInfo selectSetlYbParamInfo(@Param("insurName") String insurName, @Param("year") String year);
 
+    @Select(" <script> " +
+            " select * from yb_param_info " +
+            " where valid_year = #{year} " +
+            " <if test=\"type != null and type != '' \"> " +
+            " and param_type = #{type} " +
+            " </if> " +
+            " </script> ")
+    List<YbParamInfo> selectYbParamInfoByYear(@Param("year") String year, @Param("type") String type);
+
     @Select("<script> " +
             " select " +
             " rtrim(inpatient_no) inpatient_no, admiss_times, dis_diag_no, dis_diag_type, " +
@@ -308,13 +318,36 @@ public interface YbCssTjDao {
             " </script> ")
     List<YbZyDisDiag> selectYbDiganInfo(@Param("patNo") String patNo, @Param("times") Integer times, @Param("tableName") String tableName);
 
+    @Select("select ssys_name = (select top(1) rtrim(name) from a_employee_mi where code = ssys), " +
+            "       sszsName1 = (select top(1) rtrim(name) from a_employee_mi where code = sszs1), " +
+            "       sszsName2 = (select top(1) rtrim(name) from a_employee_mi where code = sszs2), " +
+            "       mzys_name = (select top(1) rtrim(name) from a_employee_mi where code = mzys)," +
+            "       bah, zyh, zycs, ssxh, ssrq, sstj, " +
+            "       ssys , sszs1, sszs2, mzys ,op_start_date, op_end_date, anst_start_date, anst_end_date," +
+            "       op_start_date as oprn_oprt_begntime," +
+            "       op_end_date as  oprn_oprt_endtime," +
+            "       anst_start_date as anst_begntime," +
+            "       anst_end_date as anst_endtime, " +
+            " case when yb_code is null then rtrim(ssbm) else rtrim(yb_code) end  ssbm ," +
+            " case when yb_name is null then rtrim(ssmc) else rtrim(yb_name) end  ssmc," +
+            " rtrim(mzff) mzff, rtrim(qkjb) qkjb," +
+            "rtrim(yhqk) yhqk, ssbfz, fhqk, ssjb, cut_heal," +
+            "(select top(1) yb_code from a_employee_mi where code = ssys) as oper_dr_code, " +
+            "(select top(1) yb_code from a_employee_mi where code = mzys) as anst_dr_code " +
+//            "dept_code," +
+//            "(select name from zd_unit_code where code = dept_code) as dept_code_name " +
+            "from ${tableName} left join zd_icd9_cm3 on (ssbm = zd_icd9_cm3.code)  " +
+            "where zyh = #{patNo} and zycs = #{times} " +
+            "order by ssxh")
+    List<BatjBa4> selectYbOprtInfo(@Param("patNo") String patNo, @Param("times") Integer times, @Param("tableName") String tableName);
+
     @Select("<script> " +
             " select t.*, " +
-            " rtrim(a.small_dept) as deptId, rtrim(z.name) as deptName, " +
+            " rtrim(a.zk_ward) as deptId, rtrim(z.name) as deptName, " +
             " rtrim(a.refer_physician) as doctorId, rtrim(e.name) as doctor " +
             " from t_si_setlinfo t " +
             " left join zy_inactpatient a on t.pat_no = a.inpatient_no and t.times = a.admiss_times " +
-            " left join zy_dept_code z on a.small_dept = z.code " +
+            " left join zy_dept_code z on a.zk_ward = z.code " +
             " left join a_employee_mi e on a.refer_physician = e.code " +
             " where t.revoked = '0' and t.setl_id in " +
             " <foreach collection='list' item='item' open='(' close=')' separator=','> " +
@@ -374,4 +407,34 @@ public interface YbCssTjDao {
             " </script> ")
     void insertYbCssSetlDeptInfo(@Param("list") List<YbCssSetlDeptInfo> list);
 
+    @Select("<script> " +
+            " select rtrim(b.code) as deptId, rtrim(b.name) as cyks, rtrim(a.name) as ryks, " +
+            " rtrim(e.name) as doctor, rtrim(zy.refer_physician) as doctorId, " +
+            " t.pat_no as zyh, t.times as zycs, t.psn_name as xm, t.medins_type as yblx, " +
+            " t.medfee_sumamt as zfy, t.fund_pay_sumamt as tczf, t.setl_time as jssj, " +
+            " round(t.fund_pay_sumamt/t.medfee_sumamt * 100, 2) bxbl, " +
+            " zy.operation as zlfs, zy.dec_type as sblx " +
+            " from t_si_setlinfo t, zy_inactpatient zy " +
+            " left join zy_dept_code a on zy.small_dept = a.code " +
+            " left join zy_dept_code b on zy.zk_ward = b.code " +
+            " left join a_employee_mi e on e.code = zy.refer_physician " +
+            " where t.revoked = '0' and t.setl_type = '21' " +
+            " and t.pat_no = zy.inpatient_no " +
+            " and t.times = zy.admiss_times " +
+            " and t.medins_type in ('长沙市城职普通住院','长沙市城居普通住院') " +
+            " and t.setl_time &gt;= #{beginTime} " +
+            " and t.setl_time &lt;= #{endTime} " +
+            " <if test=\"dept != null and dept != '' \">" +
+            " and rtrim(b.name) = #{dept} " +
+            " </if> " +
+            " <if test=\"zyh != null and zyh != '' \">" +
+            " and rtrim(t.pat_no) = #{zyh} " +
+            " </if> " +
+            " <if test=\"insurName != null and insurName != '' \">" +
+            " and t.medins_type = #{insurName} " +
+            " </if> " +
+            " </script> ")
+    List<Map<String, Object>> selectCssYbCsTj(@Param("beginTime") String beginTime, @Param("endTime") String endTime,
+        @Param("dept") String dept, @Param("insurName") String insurName, @Param("zyh") String zyh);
+
 }

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

@@ -19,6 +19,7 @@ public class YbkfShareDto {
     private String doctor;
     private String insurId;
     private String insurName;
+    private String zyh;
     private MultipartFile file;
     /**
      * 年份

+ 148 - 0
src/main/java/thyyxxk/webserver/service/ybkf/YbCssTjService.java

@@ -11,6 +11,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 import thyyxxk.webserver.config.exception.ExceptionEnum;
+import thyyxxk.webserver.constants.YbTjConstant;
+import thyyxxk.webserver.constants.sidicts.TreatmentMethods;
 import thyyxxk.webserver.dao.his.casefrontsheet.CaseFrontSheetDao;
 import thyyxxk.webserver.dao.his.ybkf.YbCssTjDao;
 import thyyxxk.webserver.entity.HeadInfo;
@@ -18,6 +20,7 @@ import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.casefrontsheet.DisefamilyGrade;
 import thyyxxk.webserver.entity.casefrontsheet.OprnDisefamilyGrade;
 import thyyxxk.webserver.entity.datamodify.ZyDetailCharge;
+import thyyxxk.webserver.entity.medicalinsurance.inpatient.BatjBa4;
 import thyyxxk.webserver.entity.medicalinsurance.inpatient.YbZyDisDiag;
 import thyyxxk.webserver.entity.ybkf.DeptChargeGroup;
 import thyyxxk.webserver.entity.ybkf.YbCssImp;
@@ -41,6 +44,7 @@ import java.math.BigDecimal;
 import java.text.MessageFormat;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.Comparator;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
@@ -431,6 +435,8 @@ public class YbCssTjService {
         BigDecimal sumScore = BigDecimal.ZERO;
         // 实际总分值
         BigDecimal realScore = DecimalUtil.minus(imp.getScore(), imp.getDeductScore() == null ? BigDecimal.ZERO : imp.getDeductScore());
+        // 没有匹配到出院科室
+        boolean notify_flag = true;
 
         for(int i = deptChargeList.size() - 1; i >= 0; i-- ){
             YbCssSetlDeptInfo deptInfo = new YbCssSetlDeptInfo();
@@ -469,13 +475,30 @@ public class YbCssTjService {
             deptInfo.setDeptName(ks.getDeptName());
             deptInfo.setDoctorId(ks.getDoctorId());
             deptInfo.setDoctor(ks.getDoctor());
+
             if(ybSetlInfo.getDeptId().equals(ks.getDeptId())){
                 deptInfo.setShortNo("1");
+                notify_flag = false;
             } else {
                 deptInfo.setShortNo("0");
             }
             list.add(deptInfo);
         }
+
+        // 科室不匹配
+        if(notify_flag){
+            // 取科室费用最多的科室为算人数科室
+            // 重症医学科不能作为算人数科室, 顺延至下一个科室
+            list.sort(Comparator.comparing(YbCssSetlDeptInfo::getMedicalTotalFee).reversed());
+
+            if(YbTjConstant.ICU_DEPT.equals(list.get(0).getDeptId())){
+                list.get(1).setShortNo("1");
+            } else {
+                list.get(0).setShortNo("1");
+            }
+
+        }
+
         return list;
     }
 
@@ -1291,4 +1314,129 @@ public class YbCssTjService {
         return headList;
     }
 
+    /**
+     * @description: 长沙市医保出院测算查询
+     * @author: hsh
+     * @date: 2022/9/22 17:13
+     * @param: [dto]
+     * @return: ResultVo<List<Map<String,Object>>>
+     **/
+    public ResultVo<List<Map<String, Object>>> selectCssYbCsTj(YbkfShareDto dto){
+        String beginTime = dto.getStartTime();
+        String endTime = dto.getEndTime();
+        String dept = dto.getDept();
+        String insurName = dto.getInsurName();
+        String zyh = dto.getZyh();
+        long start_times1 = System.currentTimeMillis();
+        List<Map<String, Object>> result = dao.selectCssYbCsTj(beginTime, endTime, dept, insurName, zyh);
+        long end_times1 = System.currentTimeMillis();
+        System.out.println((end_times1-start_times1)/3600);
+
+        // 获取当年长沙市分值测算标准(setl_cc: 决算; test_cc: 测算)
+        String year = endTime.substring(0,4);
+        List<YbParamInfo> testParams = dao.selectYbParamInfoByYear(year, "test_cc");
+        List<YbParamInfo> setlParams = dao.selectYbParamInfoByYear(year, "setl_cc");
+
+        long start_times = System.currentTimeMillis();
+        // 补充主诊断、主手术、分值、预计支付,计算预计的盈亏额
+        for(Map<String, Object> map : result){
+            AddDaginAndBal(testParams, setlParams, map);
+        }
+        long end_times = System.currentTimeMillis();
+        System.out.println((end_times-start_times)/3600);
+        return ResultVoUtil.success(result);
+    }
+
+    /**
+     * @description: 补充主诊断、主手术、分值、预计支付,计算预计的盈亏额
+     * @author: hsh
+     * @date: 2022/9/26 15:44
+     * @param: [paramInfoList, map]
+     * @return: void
+     **/
+    private void AddDaginAndBal(List<YbParamInfo> testParams, List<YbParamInfo> setlParams, Map<String, Object> map) {
+        // 获取标准分值
+        String medinsType = String.valueOf(map.get("yblx"));
+        if(StringUtil.isBlank(medinsType)){
+            return;
+        }
+        BigDecimal csbz = BigDecimal.ONE;
+        for(YbParamInfo param : testParams){
+            if(medinsType.equals(param.getMedinsType())){
+                csbz = new BigDecimal(param.getParamValue());
+                break;
+            }
+        }
+        BigDecimal jsbz = BigDecimal.ONE;
+        for(YbParamInfo param : setlParams){
+            if(medinsType.equals(param.getMedinsType())){
+                jsbz = new BigDecimal(param.getParamValue());
+                break;
+            }
+        }
+
+        // 治疗方式与申报类型
+        String zlfs = map.get("zlfs") + "";
+        map.put("zlfs", TreatmentMethods.get(zlfs).getName());
+
+        String zyh = map.get("zyh") + "";
+        Integer times = Integer.parseInt(map.get("zycs") + "");
+
+        List<YbZyDisDiag> zdList = dao.selectYbDiganInfo(zyh, times, "zy_dis_diag_yb_modify");
+        if(zdList.size() == 0){
+            zdList = dao.selectYbDiganInfo(zyh, times, "zy_dis_diag_yb");
+        }
+
+        List<BatjBa4> ba4List = dao.selectYbOprtInfo(zyh, times, "batj_ba4_modify");
+        if(ba4List.size() == 0){
+            ba4List = dao.selectYbOprtInfo(zyh, times, "batj_ba4");
+        }
+
+        BigDecimal tczf = new BigDecimal(map.get("tczf") + "");
+        // 添加主要诊断
+        for (YbZyDisDiag zd : zdList) {
+            // 选择第一诊断作为主诊断
+            if(zd.getDisDiagNo() == 1){
+                String code = zd.getDisDiag();
+                map.put("zdmc", zd.getDisDiagComment());
+                map.put("zdbm", code);
+                BigDecimal fz = selectDiagScore(code, zyh, times);
+
+                if(fz.compareTo(BigDecimal.ZERO) == 0){
+                    // 无对照分值计算:统筹支付/分值标准
+                    fz = DecimalUtil.divide(tczf, csbz, 1);
+                    map.put("sblx", "无对照");
+                } else {
+                    map.put("sblx", "有对照");
+                }
+                // 计算预计支付
+                BigDecimal yjzf = DecimalUtil.multiply(fz, jsbz);
+                map.put("yjzf", yjzf);
+                map.put("score", fz);
+                map.put("bal", DecimalUtil.minus(yjzf, tczf));
+
+                if(tczf.compareTo(BigDecimal.ZERO) == 0){
+                    map.put("yjzf", 0);
+                    map.put("score", 0);
+                    map.put("bal", 0);
+                    map.put("sblx", "非正常数据");
+                }
+
+                break;
+            }
+        }
+
+        // 添加主要操作手术
+        if(ba4List.size() > 0){
+            for (BatjBa4 ss : ba4List) {
+                if(ss.getSsxh() == 1){
+                    map.put("ssbm", ss.getSsbm());
+                    map.put("ssmc", ss.getSsmc());
+                    break;
+                }
+            }
+        }
+
+    }
+
 }