Browse Source

Merge branch 'master' into 'master'

科室核算汇总增加门诊以及全院医保收入分析增加工伤

See merge request lighter/web-server!95
huangshuhua 1 năm trước cách đây
mục cha
commit
1bd1df98d3

+ 124 - 0
src/main/java/thyyxxk/webserver/dao/his/highreport/AllStatisticsDao.java

@@ -63,5 +63,129 @@ public interface AllStatisticsDao {
     List<Map<String, Object>> selectInpatientDeptAccountingReport(
             @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("suffer") String suffer);
 
+    @Select("select " +
+            "   z.name as ksmc, " +
+            "   z.code as ksid, " +
+            "   sum ( a.charge_fee ) as totalCharge, " +
+            "   max ( d.parent_code ) as flm, " +
+            "   max ( e.name ) as flmc, " +
+            "   max ( d.name ) as hsmc, " +
+            "   c.audit_code as hsm " +
+            "from " +
+            " zy_detail_charge a ( nolock ), " +
+            " zd_charge_item c, " +
+            " zy_zd_audit_item d, " +
+            " zy_zd_audit_report e, " +
+            " zd_unit_code z, " +
+            " zy_patient f  " +
+            "where " +
+            "   a.charge_code = c.code  " +
+            " and c.audit_code *= d.code " +
+            " and d.parent_code = e.code " +
+            " and ( case when isnull( a.exec_unit, '' ) = '' then ( " +
+            "   case when isnull( f.zk_ward, '' ) = '' then a.ward_code else f.zk_ward end ) else a.exec_unit end ) *= z.code  " +
+            " and a.charge_date >= #{startTime}  " +
+            " and a.charge_date <= #{endTime}  " +
+            " and a.charge_status >= 2 " +
+            " and a.inpatient_no = f.inpatient_no  " +
+            " and a.admiss_times = f.admiss_times  " +
+            " group by " +
+            "   z.name, " +
+            "   z.code, " +
+            "   c.audit_code")
+    List<Map<String, Object>> selectInpatientDeptAccountingReportZyExecDept(
+            @Param("startTime") String startTime, @Param("endTime") String endTime);
+
+    @Select("select  " +
+            "   z.name as ksmc,  " +
+            "   z.code as ksid,  " +
+            "   sum ( a.charge_fee ) as totalCharge,  " +
+            "   max ( d.parent_code ) as flm,  " +
+            "   max ( e.name ) as flmc,  " +
+            "   max ( d.name ) as hsmc,  " +
+            "   c.audit_code as hsm  " +
+            "from  " +
+            " zy_detail_charge a ( nolock ),  " +
+            " zd_charge_item c,  " +
+            " zy_zd_audit_item d,  " +
+            " zy_zd_audit_report e,  " +
+            " zd_unit_code z,  " +
+            " zy_patient f   " +
+            "where  " +
+            "   a.charge_code = c.code   " +
+            " and c.audit_code *= d.code   " +
+            " and a.ward_code *= z.code   " +
+            " and d.parent_code = e.code  " +
+            " and a.charge_date >= #{startTime}   " +
+            " and a.charge_date <= #{endTime}   " +
+            " and a.charge_status >= 2 )   " +
+            " and a.inpatient_no= f.inpatient_no   " +
+            " and a.admiss_times= f.admiss_times   " +
+            " group by  " +
+            "   z.name,  " +
+            "   z.code,  " +
+            "   c.audit_code")
+    List<Map<String, Object>> selectInpatientDeptAccountingReportZyWardCode(
+            @Param("startTime") String startTime, @Param("endTime") String endTime);
+
+    @Select(" select z.name as ksmc, " +
+            "        z.code as ksid, " +
+            "        max(d.parent_code) as flm, " +
+            "        max(e.name) as flmc, " +
+            "        isnull(sum(round(convert(decimal(18,3),((convert(decimal(18,3),unit_price)) * (quantity * isnull(drug_win,1)))),2)),0) as totalCharge, " +
+            "        max(d.name) as hsmc, " +
+            "        c.audit_code as hsm " +
+            "   from mz_charge_detail a(nolock),    " +
+            "        (select distinct patient_id,times,receipt_no, serial_no,receipt_sn from mz_receipt_serial " +
+            "         where charge_date >= #{startTime}   " +
+            "           and charge_date <= #{endTime}) as b, " +
+            "        zd_charge_item c, " +
+            "        zy_zd_audit_item d, " +
+            "        zy_zd_audit_report e, " +
+            "        zd_unit_code z  " +
+            "  where a.patient_id = b.patient_id  " +
+            "    and a.times = b.times  " +
+            "    and a.receipt_no = b.receipt_no    " +
+            "    and a.real_no = b.receipt_sn   " +
+            "    and d.parent_code = e.code " +
+            "    and case a.charge_bill_code when 'BILL10' then 'BILL01' when 'BILL11' then 'BILL28' when 'BILL12' then 'BILL02' else a.charge_bill_code end *= c.code " +
+            "    and isnull(c.audit_code, d.code) = d.code  " +
+            "    and a.serial_no = b.serial_no   " +
+            "    and a.bill_item_code <> 'TC' " +
+            "    and (case when isnull(a.exec_dept,'') = '' or a.exec_dept = 'null' then a.warn_dept else a.exec_dept end) *= z.code  " +
+            "    and a.exec_dept <> '0000000' " +
+            "  group by z.name, z.code, c.audit_code")
+    List<Map<String, Object>> selectInpatientDeptAccountingReportMzExecDept(
+            @Param("startTime") String startTime, @Param("endTime") String endTime);
+
+    @Select(" select z.name as ksmc, " +
+            "        z.code as ksid, " +
+            "        max(d.parent_code) as flm, " +
+            "        max(e.name) as flmc, " +
+            "        isnull(sum(round(convert(decimal(18,3),((convert(decimal(18,3),unit_price)) * (quantity * isnull(drug_win,1)))),2)),0) as totalCharge, " +
+            "        max(d.name) as hsmc, " +
+            "        c.audit_code as hsm " +
+            "   from mz_charge_detail a(nolock),    " +
+            "        (select distinct patient_id,times,receipt_no, serial_no,receipt_sn from mz_receipt_serial " +
+            "         where charge_date >= #{startTime}   " +
+            "           and charge_date <= #{endTime}) as b, " +
+            "        zd_charge_item c, " +
+            "        zy_zd_audit_item d, " +
+            "        zy_zd_audit_report e, " +
+            "        zd_unit_code z  " +
+            "  where a.patient_id = b.patient_id  " +
+            "    and a.times = b.times  " +
+            "    and a.receipt_no = b.receipt_no    " +
+            "    and a.real_no = b.receipt_sn   " +
+            "    and d.parent_code = e.code " +
+            "    and case a.charge_bill_code when 'BILL10' then 'BILL01' when 'BILL11' then 'BILL28' when 'BILL12' then 'BILL02' else a.charge_bill_code end *= c.code " +
+            "    and isnull(c.audit_code, d.code) = d.code  " +
+            "    and a.serial_no = b.serial_no   " +
+            "    and a.bill_item_code <> 'TC' " +
+            "    and (case when isnull(a.warn_dept,'') = '' or a.warn_dept = 'null' then a.exec_dept else a.warn_dept end) *= z.code  " +
+            "    and a.exec_dept <> '0000000' " +
+            "  group by z.name, z.code, c.audit_code")
+    List<Map<String, Object>> selectInpatientDeptAccountingReportMzWardDept(
+            @Param("startTime") String startTime, @Param("endTime") String endTime);
 
 }

+ 50 - 4
src/main/java/thyyxxk/webserver/dao/his/ybkf/YbStatDao.java

@@ -164,7 +164,7 @@ public interface YbStatDao {
     YbStatResult selectYbStatRatioTotal(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("setlType") String setlType);
 
     @Select("<script>" +
-            "select a.*, rtrim(zy.small_dept) as deptId, rtrim(z.name) as psnCertType," +
+            "select a.*, rtrim(zy.small_dept) as deptId, rtrim(z.name) as dept," +
             "rtrim(isnull(zd2.dis_diag_comment, zd1.dis_diag_comment)) as mainDiagnosis, rtrim(isnull(ss2.ssmc, ss1.ssmc)) as mainOperation " +
             "from t_si_setlinfo a " +
             "left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no and zy.admiss_times = a.times) " +
@@ -198,7 +198,7 @@ public interface YbStatDao {
                                           @Param("med_type") List<String> med_type);
 
     @Select("<script>" +
-            "select a.*, rtrim(zy.small_dept) as deptId, rtrim(z.name) as psnCertType, " +
+            "select a.*, rtrim(zy.small_dept) as deptId, rtrim(z.name) as dept, " +
             "rtrim(isnull(zd2.dis_diag_comment, zd1.dis_diag_comment)) as mainDiagnosis, rtrim(isnull(ss2.ssmc, ss1.ssmc)) as mainOperation " +
             "from t_si_setlinfo a " +
             "left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no and zy.admiss_times = a.times) " +
@@ -214,7 +214,7 @@ public interface YbStatDao {
 
 
     @Select("<script>" +
-            "select a.*, rtrim(zy.small_dept) as deptId, rtrim(z.name) as psnCertType, " +
+            "select a.*, rtrim(zy.small_dept) as deptId, rtrim(z.name) as dept, " +
             "rtrim(isnull(zd2.dis_diag_comment, zd1.dis_diag_comment)) as mainDiagnosis, rtrim(isnull(ss2.ssmc, ss1.ssmc)) as mainOperation " +
             "from t_si_setlinfo a " +
             "left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no and zy.admiss_times = a.times) " +
@@ -230,7 +230,7 @@ public interface YbStatDao {
 
 
     @Select("<script>" +
-            "select a.*, rtrim(zy.small_dept) as deptId, rtrim(z.name) as psnCertType, " +
+            "select a.*, rtrim(zy.small_dept) as deptId, rtrim(z.name) as dept, " +
             "rtrim(isnull(zd2.dis_diag_comment, zd1.dis_diag_comment)) as mainDiagnosis, rtrim(isnull(ss2.ssmc, ss1.ssmc)) as mainOperation " +
             "from t_si_setlinfo a " +
             "left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no and zy.admiss_times = a.times) " +
@@ -336,4 +336,50 @@ public interface YbStatDao {
     List<Map<String, Object>> selectTreeAllData(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("setlType") String setlType,
                                               @Param("dept") String dept, @Param("doctor") String doctor, @Param("insurType") String insurType);
 
+    @Select("<script>" +
+            "select psnCount=count(distinct a.kaz001), " +
+            "inDays=sum(datediff(day, zy.admiss_date, zy.dis_date)), " +
+            "avgInDays=cast(round(sum(datediff(day, zy.admiss_date, zy.dis_date))/cast(count(distinct a.kaz001) as decimal(12,2)),2) as decimal(12,2)), " +
+            "totalFee=cast(round(sum(a.aae019),2) as decimal(12,2)), " +
+            "fundPooling=cast(round(sum(isnull(b.aae019, 0)),2) as decimal(12,2)), " +
+            "allFunds=cast(round(sum(a.akc264),2) as decimal(12,2)) " +
+            "from t_injury_setlinfo a " +
+            "left join t_injury_setldetail b on a.kaz001 = b.kaz001 and b.bka023 = 'C000' " +
+            "left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no and zy.admiss_times = a.times) " +
+            "where a.revoked=0 and a.setl_type=#{setlType} and a.ake010 &gt;= #{beginTime} and a.ake010 &lt;= #{endTime} " +
+            "</script>")
+    YbStatResult selectYbStatInfoIninjury(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("setlType") String setlType);
+
+    @Select("<script>" +
+            "select a.aac003 as psnName, a.pat_no as patNo, a.times, a.kaz001 as setlId, a.aaz217 as mdtrtId, " +
+            "a.aac004 as gend, convert(date, substring(a.aac002, 7, 8)) as brdy, a.aac002 as certno, " +
+            "a.baa027 as insuplcAdmdvs, a.aae140 as insutype, a.bka035 as psnType, a.aka130 as medType, rtrim(z.name) as dept, " +
+            "<if test=\"setlType == '21'.toString \"> " +
+            "zy.admiss_date as begntime, zy.dis_date as endtime, rtrim(zy.small_dept) as deptId, " +
+            "</if> " +
+            "<if test=\"setlType == '11'.toString \"> " +
+            "zy.visit_dept_code as deptId, " +
+            "</if> " +
+            "cast(substring(a.ake010, 1, 4) + '-' + substring(a.ake010, 5, 2) + '-' + substring(a.ake010, 7, 2) + ' ' + " +
+            "    substring(a.ake010, 9, 2) + ':' + substring(a.ake010, 11, 2) + ':' + substring(a.ake010, 13, 2) as datetime) as setlTime, " +
+            "a.aae019 as medfeeSumamt, a.akc264 as fundPaySumamt, a.akc268 as psnCashPay, cast(isnull(b.aae019, 0) as numeric(10, 2)) as mealsFee, " +
+            "rtrim(isnull(zd2.dis_diag_comment, zd1.dis_diag_comment)) as mainDiagnosis, rtrim(isnull(ss2.ssmc, ss1.ssmc)) as mainOperation " +
+            "from t_injury_setlinfo a " +
+            "left join t_injury_setldetail b on (a.kaz001 = b.kaz001 and b.bka023 = 'C004') " +
+            "<if test=\"setlType == '21' \"> " +
+            "left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no and zy.admiss_times = a.times) " +
+            "left join zd_unit_code z on zy.small_dept = z.code " +
+            "</if> " +
+            "<if test=\"setlType == '11' \"> " +
+            "left join mz_visit_table zy on (zy.patient_id = a.pat_no and zy.times = a.times) " +
+            "left join zd_unit_code z on zy.visit_dept_code = z.code " +
+            "</if> " +
+            "left join zy_dis_diag_yb zd1 on (zd1.inpatient_no = a.pat_no and zd1.admiss_times = a.times and zd1.dis_diag_no = '1') " +
+            "left join zy_dis_diag_yb_modify zd2 on (zd2.inpatient_no = a.pat_no and zd2.admiss_times = a.times and zd2.dis_diag_no = '1') " +
+            "left join batj_ba4 ss1 on (ss1.zyh = a.pat_no and ss1.zycs = a.times and ss1.ssxh = '1') " +
+            "left join batj_ba4_modify ss2 on (ss2.zyh = a.pat_no and ss2.zycs = a.times and ss2.ssxh = '1') " +
+            "where a.revoked=0 and a.setl_type=#{setlType} and a.ake010 &gt;= #{beginTime} and a.ake010 &lt;= #{endTime} " +
+            "</script>")
+    List<SiSetlinfo> selectInjurySetlInfoList(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("setlType") String setlType);
+
 }

+ 5 - 0
src/main/java/thyyxxk/webserver/entity/medicalinsurance/setlinfo/SiSetlinfo.java

@@ -387,5 +387,10 @@ public class SiSetlinfo implements Serializable {
 	private String dept;
 	@TableField(exist = false)
 	private String doctor;
+	/**
+	 * 伙食费
+	 * */
+	@TableField(exist = false)
+	private String mealsFee;
 
 }

+ 17 - 5
src/main/java/thyyxxk/webserver/service/highreport/AllStatisticsService.java

@@ -409,14 +409,26 @@ public class AllStatisticsService {
      */
     public ResultVo<Map<String, Object>> selectInpatientDeptAccountingReport(HighReportDto dto){
         Map<String, Object> results = new HashMap<>();
-        // 执行科室
-        String suffer;
+        List<Map<String, Object>> list;
+        /*
+         * 老系统查询方式(时间条件口径):
+         * 住院
+         * 1.是否勾选按录入日期:勾选取zy_detail_charge表charge_date值(收费时间)查询;未勾选取zy_detail_charge表gen_time值(系统时间?)查询
+         * 2.结账和应收二选一:选结账,上述时间查询取zy_ledger_file表cash_date值;选应收,按1的方式选择
+         * 3.结账和应收二选一:zy_detail_charge表charge_status值选结账取3(结算),选应收取2(上账)
+         * 门诊
+         * 4.收费基准时间选择mz_receipt_serial表的charge_date字段值;结账基准时间选择mz_receipt_serial表的dcount_date字段值
+         * 5.结算基准要求mz_receipt_serial的 isnull(dcount_no, 0) = 1 条件成立,收费基准不做要求
+         */
         if("1".equals(dto.getType())){
-            suffer = "exec_unit";
+            list = dao.selectInpatientDeptAccountingReportZyExecDept(dto.getStartTime(), dto.getEndTime());
+        } else if("2".equals(dto.getType())){
+            list = dao.selectInpatientDeptAccountingReportZyWardCode(dto.getStartTime(), dto.getEndTime());
+        } else if("3".equals(dto.getType())){
+            list = dao.selectInpatientDeptAccountingReportMzExecDept(dto.getStartTime(), dto.getEndTime());
         } else {
-            suffer = "ward_code";
+            list = dao.selectInpatientDeptAccountingReportMzWardDept(dto.getStartTime(), dto.getEndTime());
         }
-        List<Map<String, Object>> list = dao.selectInpatientDeptAccountingReport(dto.getStartTime(), dto.getEndTime(), suffer);
         List<Map<String, Object>> dataList = new ArrayList<>();
         List<HeadInfo> headList = new ArrayList<>();
         Map<String, Map<String, List<Map<String, Object>>>> map =

+ 55 - 3
src/main/java/thyyxxk/webserver/service/ybkf/YbStatService.java

@@ -52,6 +52,8 @@ public class YbStatService {
         String endTime = DateUtil.getMonthEndtime(dto.getEndTime());
         String insurType = dto.getInsurType();
         String setlType = dto.getSetlType();
+        String d1 = beginTime.replace(" ", "").replace("-", "").replace(":","");
+        String d2 = endTime.replace(" ", "").replace("-", "").replace(":","");
 
         // 统筹区域
         List<String> insuplcAdmdvs = new ArrayList<>();
@@ -456,6 +458,20 @@ public class YbStatService {
                 }
             }
 
+            insuplcAdmdvs.clear();
+            insurtype.clear();
+            med_type.clear();
+
+            if("431321410".equals(insurType) || "99".equals(insurType)){
+                // 住院所有工伤病人
+                YbStatResult result = dao.selectYbStatInfoIninjury(d1, d2, setlType);
+                if(!ObjectUtils.isEmpty(result) && result.getPsnCount() > 0){
+                    result.setInsurName("住院工伤");
+                    result.setInsurType("99".equals(insurType) ? "431321410" : insurType);
+                    ybStatResult.add(result);
+                }
+            }
+
         } else {
             // 门诊
             if("11".equals(insurType) || "99".equals(insurType)){
@@ -498,6 +514,19 @@ public class YbStatService {
                 }
             }
 
+            insuplcAdmdvs.clear();
+            insurtype.clear();
+            med_type.clear();
+            if("98".equals(insurType) || "99".equals(insurType)){
+                // 工伤门诊
+                YbStatResult result = dao.selectYbStatInfoIninjury(d1, d2, setlType);
+                if(!ObjectUtils.isEmpty(result) && result.getPsnCount() > 0){
+                    result.setInsurName("门诊工伤");
+                    result.setInsurType("99".equals(insurType) ? "98" : insurType);
+                    ybStatResult.add(result);
+                }
+            }
+
         }
 
         if (ybStatResult.isEmpty()) {
@@ -1125,7 +1154,8 @@ public class YbStatService {
         List<String> med_type = new ArrayList<>();
         // 返回结果
         List<SiSetlinfo> siSetlInfoList = new ArrayList<>();
-
+        String d1 = beginTime.replace(" ", "").replace("-", "").replace(":","");
+        String d2 = endTime.replace(" ", "").replace("-", "").replace(":","");
         if("21".equals(setlType)){
             // 住院
             if("43010031001".equals(insurType)){
@@ -1240,6 +1270,20 @@ public class YbStatService {
                 med_type.add("2106");
                 med_type.add("2107");
                 siSetlInfoList = dao.selectSiSetlInfoList(beginTime, endTime, setlType, insuplcAdmdvs, insurtype, med_type);
+            } else if("43018231001".equals(insurType)){
+                // 宁乡市城职普通住院(包含外伤住院)
+                insuplcAdmdvs.add("430182");
+                insurtype.add("310");
+                med_type.add("2101");
+                med_type.add("22");
+                siSetlInfoList = dao.selectSiSetlInfoList(beginTime, endTime, setlType, insuplcAdmdvs, insurtype, med_type);
+            } else if("43018239001".equals(insurType)){
+                // 宁乡市城居普通住院(包含外伤住院)
+                insuplcAdmdvs.add("430182");
+                insurtype.add("390");
+                med_type.add("2101");
+                med_type.add("22");
+                siSetlInfoList = dao.selectSiSetlInfoList(beginTime, endTime, setlType, insuplcAdmdvs, insurtype, med_type);
             } else if("43990031001".equals(insurType)){
                 // 湖南省城职普通住院(包含外伤住院)
                 insuplcAdmdvs.add("439900");
@@ -1289,6 +1333,9 @@ public class YbStatService {
             } else if("4399012102".equals(insurType)){
                 // 省内异地单病种
                 siSetlInfoList = dao.selectSiSetlInfoListInProvinceOtherCitiesSingleDisease(beginTime, endTime, setlType);
+            } else if("431321410".equals(insurType)){
+                // 住院工伤
+                siSetlInfoList = dao.selectInjurySetlInfoList(d1, d2, setlType);
             }
 
         } else {
@@ -1306,6 +1353,8 @@ public class YbStatService {
                 // 生育门诊
                 med_type.add("51");
                 siSetlInfoList = dao.selectSiSetlInfoList(beginTime, endTime, setlType, insuplcAdmdvs, insurtype, med_type);
+            } else if("98".equals(insurType)){
+                siSetlInfoList = dao.selectInjurySetlInfoList(d1, d2, setlType);
             }
 
         }
@@ -1315,8 +1364,11 @@ public class YbStatService {
         }
 
         siSetlInfoList.forEach(item -> {
-            String othpay = DecimalUtil.minusLink(String.valueOf(item.getFundPaySumamt()), String.valueOf(item.getHifpPay()), String.valueOf(item.getHifmiPay()), String.valueOf(item.getCvlservPay()));
-            item.setOthPay("".equals(othpay) ? 0d : Double.parseDouble(othpay));
+            // 工伤不计算其他支出
+            if(!("431321410".equals(insurType) || "98".equals(insurType))){
+                String othpay = DecimalUtil.minusLink(String.valueOf(item.getFundPaySumamt()), String.valueOf(item.getHifpPay()), String.valueOf(item.getHifmiPay()), String.valueOf(item.getCvlservPay()));
+                item.setOthPay("".equals(othpay) ? 0d : Double.parseDouble(othpay));
+            }
             item.setInsuplcAdmdvsName(redis.getRegionName(item.getInsuplcAdmdvs()));
             FilterUtil.filterCodeToName(item);
         });