yeguodong 1 week ago
parent
commit
0cfa9047ec

+ 68 - 29
src/main/java/thyyxxk/webserver/dao/his/inpatient/ChargeListDao.java

@@ -63,8 +63,13 @@ public interface ChargeListDao {
             "(case when isnull(exec_unit,'')='' then ward_code else exec_unit end)), " +
             "billItemCode=case when isnull(nullif(serial,''),'00')='00' then " +
             "(select d.bill_item_zy from zd_charge_item d where d.code=charge_code_mx) else " +
-            "(select max(d.bill_item_zy) from yp_zd_dict d where d.code=charge_code_mx) end " +
-            "from zy_detail_charge a where inpatient_no=#{patNo} and admiss_times=#{times} " +
+            "(select max(d.bill_item_zy) from yp_zd_dict d where d.code=charge_code_mx) end, " +
+            "chrgitmLv=case when b.chrgitm_lv='01' then N'甲类' " +
+            "when b.chrgitm_lv='02' then N'乙类' " +
+            "when b.chrgitm_lv='03' then N'丙类' else '' end " +
+            "from zy_detail_charge a left join t_si_charge_temp b on a.inpatient_no=b.pat_no " +
+            "and a.admiss_times=b.times and a.ledger_sn=b.ledger_sn and a.detail_sn=b.feedetl_sn " +
+            "where inpatient_no=#{patNo} and admiss_times=#{times} " +
             "and trans_flag_yb!=2 and charge_amount!=0 ${statement} " +
             "<if test=\"ledgerSn != null \">" +
             "and ledger_sn=#{ledgerSn} " +
@@ -72,33 +77,67 @@ public interface ChargeListDao {
             "</script>")
     List<ChargeItem> getChargeListWithChargeDate(PatOverview overview);
     
-    @Select("select " +
-            "code,name,specification,unit,price,billItemCode,execDept, " +
-            "quantity=sum(quantity),cost=sum(cost) " +
-            "from (select * from ( " +
-            "select code=case when isnull(nullif(a.serial,''),'00')='00' then " +
-            "(select isnull(isnull(national_code_27,national_code),code) national_code from zd_charge_item d where d.code=charge_code_mx) else " +
-            "(select isnull(max(national_code),max(code)) from yp_zd_dict d where d.code=charge_code_mx) end, " +
-            "name=case when isnull(nullif(a.serial,''),'00')='00' then " +
-            "(select name as name from zd_charge_item d where d.code=charge_code_mx) else " +
-            "(select max(name) from yp_zd_dict d where d.code=charge_code_mx) end, " +
-            "specification=case when isnull(nullif(a.serial,''),'00')='00' then null else " +
-            "(select max(specification) from yp_zd_dict d where d.code=charge_code_mx) end, " +
-            "unit=case when isnull(nullif(a.serial,''),'00')='00' then " +
-            "(select d.charge_unit from zd_charge_item d where d.code=charge_code_mx) else " +
-            "(select name from yp_zd_unit e where e.code= " +
-            "(select d.pack_unit from yp_zd_dict d where d.code=charge_code_mx and d.serial=a.serial)) end, " +
-            "price=abs(round(charge_fee/case when charge_amount=0 then 1 else charge_amount end,2)), " +
-            "quantity=(a.charge_amount),cost=(charge_fee), " +
-            "execDept=(select d.name from zd_unit_code d where d.code= " +
-            "(case when isnull(exec_unit,'')='' then ward_code else exec_unit end)), " +
-            "billItemCode=case when isnull(nullif(a.serial,''),'00')='00' then " +
-            "(select d.bill_item_zy from zd_charge_item d where d.code=charge_code_mx) else " +
-            "(select max(d.bill_item_zy) from yp_zd_dict d where d.code=charge_code_mx) end " +
-            "from zy_detail_charge a where inpatient_no=#{patNo} and admiss_times=#{times} " +
-            "and trans_flag_yb!=2 and charge_amount!=0 and charge_date>=#{begndate} " +
-            "and charge_date<=#{enddate}) temp) res group by " +
-            "code, name, specification, unit, price, billItemCode, execDept ")
+    @Select("select code," +
+            "       name," +
+            "       specification," +
+            "       unit," +
+            "       price," +
+            "       billItemCode," +
+            "       billItemName," +
+            "       execDept," +
+            "       quantity=sum(quantity)," +
+            "       cost=sum(cost)," +
+            "       chrgitmLv" +
+            " from (select *,billItemName=(select name from zy_bill_item where code=billItemCode )" +
+            "      from (select code=case" +
+            "  when isnull(nullif(a.serial, ''), '00') = '00'" +
+            "   then (select isnull(isnull(national_code_27, national_code), code) national_code" +
+            "   from zd_charge_item d" +
+            "  where d.code = charge_code_mx)" +
+            "   else (select isnull(max(national_code), max(code)) from yp_zd_dict d where d.code = charge_code_mx) end, name=case" +
+            "                            when isnull(nullif(a.serial, ''), '00') = '00'" +
+            "                                then (select name as name from zd_charge_item d where d.code = charge_code_mx)" +
+            "                            else (select max(name) from yp_zd_dict d where d.code = charge_code_mx) end," +
+            "                   specification=case" +
+            "                                     when isnull(nullif(a.serial, ''), '00') = '00' then null" +
+            "                                     else (select max(specification)" +
+            "                                           from yp_zd_dict d" +
+            "                                           where d.code = charge_code_mx) end," +
+            "                   unit=case" +
+            "                            when isnull(nullif(a.serial, ''), '00') = '00' then (select d.charge_unit" +
+            "                                                                                 from zd_charge_item d" +
+            "                                                                                 where d.code = charge_code_mx)" +
+            "                            else (select name" +
+            "                                  from yp_zd_unit e" +
+            "                                  where e.code = (select d.pack_unit" +
+            "                                                  from yp_zd_dict d" +
+            "                                                  where d.code = charge_code_mx and d.serial = a.serial)) end," +
+            "                   price=abs(round(charge_fee / case when charge_amount = 0 then 1 else charge_amount end, 2))," +
+            "                   quantity=(a.charge_amount)," +
+            "                   cost=(charge_fee)," +
+            "                   execDept=(select d.name" +
+            "                             from zd_unit_code d" +
+            "                             where d.code = (case when isnull(exec_unit, '') = '' then ward_code else exec_unit end))," +
+            "                   billItemCode=case" +
+            "                                    when isnull(nullif(a.serial, ''), '00') = '00' then (select d.bill_item_zy" +
+            "                                                                                         from zd_charge_item d" +
+            "                                                                                         where d.code = charge_code_mx)" +
+            "                                    else (select max(d.bill_item_zy)" +
+            "                                          from yp_zd_dict d" +
+            "                                          where d.code = charge_code_mx) end," +
+            "                  chrgitmLv=case when chrgitm_lv='01' then N'甲类'" +
+            "                                 when chrgitm_lv='02' then N'乙类'" +
+            "                                 when chrgitm_lv='03' then N'丙类'" +
+            "                                 else '' end" +
+            "            from zy_detail_charge a left join t_si_charge_temp b on a.inpatient_no=b.pat_no" +
+            "                and a.admiss_times=b.times and a.ledger_sn=b.ledger_sn and a.detail_sn=b.feedetl_sn" +
+            "            where inpatient_no = #{patNo}" +
+            "              and admiss_times = #{times}" +
+            "              and trans_flag_yb != 2" +
+            "              and charge_amount != 0" +
+            "              and charge_date >= #{begndate}" +
+            "              and charge_date <= #{enddate}) temp) res" +
+            " group by code, name, specification, unit, price, billItemCode, billItemName, execDept, chrgitmLv")
     List<ChargeItem> getChargeListWithoutChargeDate(PatOverview overview);
 
     @Select("select count(1) from zy_actpatient where inpatient_no=#{patNo} and admiss_times=#{times}")

+ 3 - 0
src/main/java/thyyxxk/webserver/entity/inpatient/chargelist/ChargeItem.java

@@ -31,6 +31,9 @@ public class ChargeItem {
     // 收费时间
     private Date chargeDate;
 
+    //医保类别
+    private String chrgitmLv;
+
     private String priceString;
     private String quantityString;
     private String costString;