Explorar o código

初步完成超量收费检索

lighter %!s(int64=4) %!d(string=hai) anos
pai
achega
49a4d03966

+ 19 - 16
src/main/java/thyyxxk/webserver/dao/his/reports/IllegalChargesAnalysisDao.java

@@ -70,29 +70,32 @@ public interface IllegalChargesAnalysisDao {
                                                         @Param("end") String end,
                                                         @Param("code") String code);
 
-    @Select("select rtrim(inpatient_no) as inpatientNo,admiss_times, " +
-            "name=(select rtrim(name) from a_patient_mi where a_patient_mi.inpatient_no=a.inpatient_no), " +
-            "responceType=(select rtrim(responce_type) from yb_zy_review_record where yb_zy_review_record.inpatient_no=" +
-            "a.inpatient_no and yb_zy_review_record.admiss_times=a.admiss_times), " +
-            "deptName=(select rtrim(name) from zd_unit_code where code=a.ward_code), " +
-            "wardName=(select rtrim(name) from zd_unit_code where code=a.dept_code), " +
-            "diag=(select rtrim(dis_diag_comment) from zy_dis_diag_yb where zy_dis_diag_yb.inpatient_no=a.inpatient_no and " +
-            "zy_dis_diag_yb.admiss_times=a.admiss_times and dis_diag_no=1), " +
-            "rtrim(charge_code_mx) as chargeCode, " +
-            "chargeName=rtrim(isnull((select name from zd_charge_item where code=charge_code_mx)," +
-            "(select top 1 name from yp_zd_dict where code=charge_code_mx))), " +
-            "charge_fee,charge_amount from zy_detail_charge a " +
+    @Select("select *, " +
+            "name=(select rtrim(name) from a_patient_mi where inpatient_no=temp.inpatient_no), " +
+            "responceType=(select rtrim(responce_type) from yb_zy_review_record where inpatient_no= " +
+            "temp.inpatient_no and admiss_times=temp.admiss_times), " +
+            "wardName=(select rtrim(name) from zd_unit_code where code=temp.ward_code), " +
+            "diag=(select rtrim(dis_diag_comment) from zy_dis_diag_yb where zy_dis_diag_yb.inpatient_no=temp.inpatient_no and " +
+            "zy_dis_diag_yb.admiss_times=temp.admiss_times and dis_diag_no=1), " +
+            "chargeName=rtrim(isnull((select name from zd_charge_item where code=temp.chargeCode), " +
+            "(select top 1 name from yp_zd_dict where code=temp.chargeCode))) " +
+            "from (select inpatient_no,admiss_times,rtrim(charge_code_mx) as chargeCode,ward_code, " +
+            "convert(varchar(10), charge_date, 21) as chargeDay, sum(charge_amount) as chargeAmount, " +
+            "sum((charge_fee)) as chargeFee from zy_detail_charge " +
             "where charge_fee>0 and isnull(trans_flag_yb,0)!=2 and charge_date>=#{start} and " +
-            "charge_date<=#{end} and charge_code_mx=#{code}")
+            "charge_date<=#{end} and charge_code_mx=#{code} group by " +
+            "inpatient_no, admiss_times, charge_code_mx,ward_code, convert(varchar(10), charge_date, 21)) " +
+            "temp where chargeAmount>#{num} ")
     List<IllegalChargeData> selectChargeDataForOverLimit(@Param("start") String start,
                                                          @Param("end") String end,
-                                                         @Param("code") String code);
+                                                         @Param("code") String code,
+                                                         @Param("num") int num);
 
 
     @Select("<script>" +
             "select rtrim(a.inpatient_no) inpatient_no,rtrim(a.name) name,a.admiss_times,a.admiss_date,b.dis_date,DATEDIFF(day,b.dis_date,a.admiss_date) differ_date," +
-            "       (select name from zd_unit_code where code=isnull(a.small_dept,a.admiss_dept)) dept_name," +
-            "       a.responce_type " +
+            "(select name from zd_unit_code where code=isnull(a.small_dept,a.admiss_dept)) dept_name," +
+            "a.responce_type " +
             "from zy_inactpatient a ,zy_inactpatient b " +
             "where a.inpatient_no=b.inpatient_no" +
             "  and a.admiss_times=b.admiss_times+1" +

+ 5 - 1
src/main/java/thyyxxk/webserver/entity/reports/illegalchargesanalysis/IllegalChargeData.java

@@ -58,8 +58,12 @@ public class IllegalChargeData {
 
     private String disDiagComment;
 
+    public String getResponceType() {
+        return null == responceType ? "" : responceType;
+    }
+
     public String getResponceTypeName() {
-        switch (responceType) {
+        switch (getResponceType()) {
             case "02":
                 return "省医保";
             case "03":

+ 17 - 1
src/main/java/thyyxxk/webserver/entity/reports/illegalchargesanalysis/IllegalChargeTemplate.java

@@ -33,6 +33,16 @@ public class IllegalChargeTemplate implements Serializable {
      */
     private String value;
 
+    /**
+     * 超量收费上限
+     */
+    private Integer maxChargeNum;
+
+    /**
+     * 超量收费计算单位(day,week,month)
+     * */
+    private String maxChargeUnit;
+
     /**
      * 父模板id
      */
@@ -82,7 +92,13 @@ public class IllegalChargeTemplate implements Serializable {
             String[] allCharges = value.split("\\$");
             setMainCharges(genChargeListFromValue(allCharges[0]));
             if (allCharges.length > 1) {
-                setConflictCharges(genChargeListFromValue(allCharges[1]));
+                if (attribute == 1) {
+                    setConflictCharges(genChargeListFromValue(allCharges[1]));
+                } else {
+                    String[] maxVal = allCharges[1].split("\\|");
+                    maxChargeNum = Integer.valueOf(maxVal[0]);
+                    maxChargeUnit = maxVal[1];
+                }
             }
         }
     }

+ 13 - 22
src/main/java/thyyxxk/webserver/service/reports/IllegalChargesAnalysisService.java

@@ -135,12 +135,17 @@ public class IllegalChargesAnalysisService {
         if (null == template.getMainCharges() || template.getMainCharges().isEmpty()) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "收费主体不能为空!");
         }
-        StringBuilder value = genTemplateValue(template.getMainCharges());
+        StringBuilder value = genTemplateValue(template.getMainCharges()).append("$");
         if (template.getAttribute() == 1) {
             if (null == template.getConflictCharges() || template.getConflictCharges().isEmpty()) {
                 return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "冲突收费不能为空!");
             }
-            value.append("$").append(genTemplateValue(template.getConflictCharges()));
+            value.append(genTemplateValue(template.getConflictCharges()));
+        } else {
+            if (null == template.getMaxChargeNum()) {
+                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "超量收费上限不能为空!");
+            }
+            value.append(template.getMaxChargeNum()).append("|").append(template.getMaxChargeUnit());
         }
         template.setValue(value.toString());
         dao.updateTemplate(template);
@@ -215,26 +220,13 @@ public class IllegalChargesAnalysisService {
     }
 
     private ResultVo<List<IllegalChargeData>> overLimitCharge(IllegalChargeTemplate template) {
-        List<IllegalChargeData> mainList = new ArrayList<>();
-        for (PureCodeName mainCharge : template.getMainCharges()) {
-            List<IllegalChargeData> temp = dao.selectChargeDataForOverLimit(template.getStart(), template.getEnd(), mainCharge.getCode());
-            temp.removeIf(item -> !template.getResponces().contains(item.getResponceType()));
-            mainList.addAll(temp);
-        }
-        Map<String, IllegalChargeData> map = new HashMap<>(Capacity.DEFAULT);
-        for (IllegalChargeData item : mainList) {
-            String key = item.getInpatientNo() + "-" + item.getAdmissTimes();
-            if (map.containsKey(key)) {
-                IllegalChargeData temp = map.get(key);
-                temp.setChargeAmount(DecimalUtil.add(temp.getChargeAmount(), item.getChargeAmount()));
-                temp.setChargeFee(DecimalUtil.add(temp.getChargeFee(), item.getChargeFee()));
-            } else {
-                map.put(key, item);
-            }
-        }
         List<IllegalChargeData> resultList = new ArrayList<>();
-        for (Map.Entry<String, IllegalChargeData> entry : map.entrySet()) {
-            resultList.add(entry.getValue());
+        for (PureCodeName main : template.getMainCharges()) {
+            resultList.addAll(dao.selectChargeDataForOverLimit(template.getStart(), template.getEnd(),
+                    main.getCode(), template.getMaxChargeNum()));
+        }
+        if (resultList.isEmpty()) {
+            return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST);
         }
         return ResultVoUtil.success(resultList);
     }
@@ -256,7 +248,6 @@ public class IllegalChargesAnalysisService {
         return ResultVoUtil.success(tmp);
     }
 
-
     public ResultVo<List<IllegalChargeData>> queryHuanZheLiangCiRuYuanRiQi(IllegalChargeTemplate param) {
         List<IllegalChargeData> list = dao.queryHuanZheLiangCiRuYuanRiQi(param.getStart(), param.getEnd(), param.getResponces());
         if (list.isEmpty()) {