xiaochan hace 3 años
padre
commit
ad88b79a70

+ 2 - 1
src/main/java/thyyxxk/webserver/dao/his/PublicDao.java

@@ -99,7 +99,8 @@ public interface PublicDao {
 
 
     @Select("select rtrim(inpatient_no) inpatient_no,admiss_times,admiss_date,dis_date,name, " +
-            "responce_name = (select rtrim(name) name from zy_zd_responce_type where code = responce_type), " +
+            "responce_name = (select rtrim(name) name from zy_zd_responce_type where code = responce_type)," +
+            "responce_type,  " +
             "ward,ward_name = (select rtrim(name) name from zd_unit_code where code = ward), " +
             "ledger_sn = (select max(ledger_sn) from zy_ledger_file where a.inpatient_no = zy_ledger_file.inpatient_no and a.admiss_times = zy_ledger_file.admiss_times), " +
             "chu_yuan_yi_zhu = (case when (select count(1) from yz_act_order where inpatient_no= a.inpatient_no and admiss_times= a.admiss_times " +

+ 49 - 11
src/main/java/thyyxxk/webserver/dao/his/yibao/XiangMuLuRuDao.java

@@ -942,7 +942,7 @@ public interface XiangMuLuRuDao extends BaseMapper<ZyDetailCharge> {
                                      @Param("ledger") Integer ledger,
                                      @Param("detailSn") Integer detailSn);
 
- 
+
     @Select("select act_order_no as order_no,exec_unit from yz_erase_order where act_order_no in  " +
             "(select order_no from zy_detail_charge where  inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledger}   " +
             "and exec_unit is null AND charge_fee < 0 and ori_detail_sn is null)")
@@ -953,7 +953,7 @@ public interface XiangMuLuRuDao extends BaseMapper<ZyDetailCharge> {
     @Update("<script>" +
             " <foreach collection='list' item='item' separator=';' >" +
             "update zy_detail_charge set exec_unit = #{item.execUnit}  where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledger} " +
-            "and act_order_no = #{item.orderNo} and exec_unit is null  and charge_fee &lt; 0" +
+            "and order_no = #{item.orderNo} and exec_unit is null  and charge_fee &lt; 0" +
             "</foreach> " +
             "</script> ")
     void yiZhuTuiFeiGenXingZhiXingKeShi(@Param("inpatientNo") String inpatientNo,
@@ -981,6 +981,19 @@ public interface XiangMuLuRuDao extends BaseMapper<ZyDetailCharge> {
             "</script>")
     void genXinYaoPingPiPeiXinXi(@Param("list") List<String> list);
 
+
+    @Select("select a.charge_code_mx,case when (select top(1) rtrim(name) from zd_charge_item where code = a.charge_code_mx) != '' then " +
+            "(select top(1) rtrim(name) from zd_charge_item where code = a.charge_code_mx) else " +
+            "(select top(1) rtrim(name) from yp_zd_dict where code = a.charge_code_mx) end as name " +
+            "from zy_detail_charge a left join zd_charge_item_hnsgs b " +
+            "on (a.charge_code_mx = b.hosp_code) where " +
+            "inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledger} and infant_flag = #{infantFlag} and isnull(b.hnsyb_item_code,'') = '' " +
+            "group by a.charge_code_mx ")
+    List<WeiGuiFeiYongFenXi> gongShangWeiPiPei(@Param("inpatientNo") String inpatientNo,
+                                               @Param("admissTimes") Integer admissTimes,
+                                               @Param("ledger") Integer ledger,
+                                               @Param("infantFlag") Integer infantFlag);
+
     /**
      * 违规药品 信息 没有匹配的
      *
@@ -989,24 +1002,24 @@ public interface XiangMuLuRuDao extends BaseMapper<ZyDetailCharge> {
      * @param ledger      账页号
      * @return 返回违规药品 没有匹配的
      */
-    @Select("select charge_code_mx,b.name,national_code from zy_detail_charge a, yp_zd_dict b " +
-            "where order_no <> 6 and trans_flag_yb not in (1,2)  and charge_code like 'BILL%' " +
+    @Select("select charge_code_mx,b.name from zy_detail_charge a, yp_zd_dict b " +
+            "where  trans_flag_yb not in (1,2)  and charge_code like 'BILL%' " +
             "  and  isnull(b.national_code,'') = '' and inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledger} " +
             "and a.infant_flag = #{infantFlag} " +
             "  and a.charge_code_mx = b.code " +
-            "group by  charge_code_mx, b.name, national_code")
+            "group by  charge_code_mx, b.name")
     List<WeiGuiFeiYongFenXi> weiGuiYaoPin(@Param("inpatientNo") String inpatientNo,
                                           @Param("admissTimes") Integer admissTimes,
                                           @Param("ledger") Integer ledger,
                                           @Param("infantFlag") Integer infantFlag);
 
 
-    @Select("select charge_code_mx,b.name,national_code from zy_detail_charge a, zd_charge_item b  " +
-            "where order_no <> 6 and trans_flag_yb not in (1,2)  and charge_code not like 'BILL%'  " +
+    @Select("select charge_code_mx,b.name from zy_detail_charge a, zd_charge_item b  " +
+            "where  trans_flag_yb not in (1,2)  and charge_code not like 'BILL%'  " +
             "  and  isnull(b.national_code,'') = '' and inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledger}  " +
             " and a.infant_flag = #{infantFlag} " +
             "  and a.charge_code_mx = b.code  " +
-            "group by  charge_code_mx, b.name, national_code")
+            "group by  charge_code_mx, b.name")
     List<WeiGuiFeiYongFenXi> weiGuiXiangMu(@Param("inpatientNo") String inpatientNo,
                                            @Param("admissTimes") Integer admissTimes,
                                            @Param("ledger") Integer ledger,
@@ -1090,23 +1103,48 @@ public interface XiangMuLuRuDao extends BaseMapper<ZyDetailCharge> {
             "from zy_detail_charge where " +
             "inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} and charge_code_mx = #{chargeCodeMx} " +
             "and exec_unit = #{execUnit} and trans_flag_yb <> 2 and order_no <> 6 and" +
-            "    detail_sn in(select ori_detail_sn from zy_detail_charge where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} and charge_code_mx = #{chargeCodeMx}" +
+            "    detail_sn in(select ori_detail_sn from zy_detail_charge where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and " +
+            "ledger_sn = #{ledgerSn} and charge_code_mx = #{chargeCodeMx}" +
             " and charge_fee <0 and ori_detail_sn is not null)  " +
             "union all  " +
             "select inpatient_no,admiss_times,ledger_sn,ori_detail_sn,charge_code_mx,charge_fee  " +
             "from zy_detail_charge where " +
             "inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} and charge_code_mx = #{chargeCodeMx} " +
             "and exec_unit = #{execUnit} and trans_flag_yb <> 2 and order_no <> 6 and " +
-            "ori_detail_sn in(select ori_detail_sn from zy_detail_charge where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} and charge_code_mx = #{chargeCodeMx} and charge_fee <0 and ori_detail_sn is not null)  " +
+            "ori_detail_sn in(select ori_detail_sn from zy_detail_charge where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} " +
+            "and ledger_sn = #{ledgerSn} and charge_code_mx = #{chargeCodeMx} and charge_fee <0 and ori_detail_sn is not null)  " +
             ") temp  " +
             "group by inpatient_no, admiss_times, ledger_sn, detail_sn, charge_code_mx")
     List<ZyDetailCharge> tuiFeiYuEr1(@Param("inpatientNo") String inpatientNo,
                                      @Param("admissTimes") Integer admissTimes,
                                      @Param("ledgerSn") Integer ledgerSn,
-                                     @Param("infantFlag") Integer infantFlag,
                                      @Param("chargeCodeMx") String chargeCodeMx,
                                      @Param("execUnit") String execUnit);
 
+
+    @Select("<script>" +
+            "select detail_sn,ori_detail_sn,order_no,charge_fee,charge_amount,charge_code_mx,charge_date, " +
+            "       exec_unit_name = (select rtrim(name) from zd_unit_code where code =exec_unit), " +
+            "       ward_code = (select rtrim(name) from zd_unit_code where code = ward_code) " +
+            "       from zy_detail_charge where " +
+            "       inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn}  " +
+            "and infant_flag = #{infantFlag} " +
+            "and charge_code_mx = #{chargeCodeMx} and trans_flag_yb &lt;&gt; 2 and order_no &lt;&gt; 6 " +
+            "and charge_amount &gt; 0 " +
+            "<if test=\"startTime != null and startTime != '' \">" +
+            "and charge_date &gt;= #{startTime} and charge_date &lt;= #{endTime} " +
+            "</if>" +
+            "order by charge_date ${riQiPaiXu}" +
+            "</script>")
+    List<ZyDetailCharge> genJuBianMaChaZhaoZhenShuFeiYong(@Param("inpatientNo") String inpatientNo,
+                                                          @Param("admissTimes") Integer admissTimes,
+                                                          @Param("ledgerSn") Integer ledgerSn,
+                                                          @Param("infantFlag") Integer infantFlag,
+                                                          @Param("chargeCodeMx") String chargeCodeMx,
+                                                          @Param("startTime") String startTime,
+                                                          @Param("endTime") String endTime,
+                                                          @Param("riQiPaiXu") String riQiPaiXu);
+
     @Select("<script>" +
             "select * from zy_detail_charge " +
             "where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} and infant_flag = #{infantFlag} and detail_sn in " +

+ 3 - 0
src/main/java/thyyxxk/webserver/entity/datamodify/ZyDetailCharge.java

@@ -241,6 +241,9 @@ public class ZyDetailCharge implements Serializable {
     private String execUnitB;
     private Integer itemNo;
 
+    /**
+     * 执行科室
+     */
     private String execUnitName;
     /**
      * 拼音码

+ 1 - 1
src/main/java/thyyxxk/webserver/entity/yibao/ZyActpatient.java

@@ -161,7 +161,7 @@ public class ZyActpatient implements Serializable {
     private String contractCode;
 
     /**
-     * responceType
+     * 医保类型
      */
     private String responceType;
 

+ 4 - 4
src/main/java/thyyxxk/webserver/service/PublicServer.java

@@ -186,15 +186,15 @@ public class PublicServer {
                 dao.genXingFuShuDuiYingZhenLiuShui(inpatientNo, admissTimes, ledger, integers);
             }
         }
-        Map<Integer, ZyDetailCharge> chongFuLiuShuiMap = dao.chongFuTuiFeiLiuShui(inpatientNo, admissTimes, ledger).stream().collect(
+        Map<Integer, ZyDetailCharge> chongFuYuanLiuShuiMap = dao.chongFuTuiFeiLiuShui(inpatientNo, admissTimes, ledger).stream().collect(
                 Collectors.toMap(ZyDetailCharge::getOriDetailSn, a -> a, (k1, k2) -> k1)
         );
-        if (!chongFuLiuShuiMap.isEmpty()) {
-            List<ZyDetailCharge> chongFuTuiFeiZhenShu = dao.getZhenShuLiuShui(inpatientNo, admissTimes, ledger, chongFuLiuShuiMap.keySet());
+        if (!chongFuYuanLiuShuiMap.isEmpty()) {
+            List<ZyDetailCharge> chongFuTuiFeiZhenShu = dao.getZhenShuLiuShui(inpatientNo, admissTimes, ledger, chongFuYuanLiuShuiMap.keySet());
             List<Integer> xuYaoChongZhiLiuShui = new ArrayList<>();
             if (ListUtil.notBlank(chongFuTuiFeiZhenShu)) {
                 for (ZyDetailCharge zyDetailCharge : chongFuTuiFeiZhenShu) {
-                    ZyDetailCharge zy = chongFuLiuShuiMap.get(zyDetailCharge.getDetailSn());
+                    ZyDetailCharge zy = chongFuYuanLiuShuiMap.get(zyDetailCharge.getDetailSn());
                     if (BigUtils.bigXiaoYu(zyDetailCharge.getChargeFee(), zy.getChargeFee().negate())) {
                         xuYaoChongZhiLiuShui.add(zyDetailCharge.getDetailSn());
                     }

+ 13 - 5
src/main/java/thyyxxk/webserver/service/yibao/XiangMuLuRuService.java

@@ -620,10 +620,15 @@ public class XiangMuLuRuService {
         }
         patient.setWeiPiPei(new ArrayList<>());
         patient.setWeiXieDaiYuanLiuShui(new ArrayList<>());
-        patient.getWeiPiPei().addAll(dao.weiGuiYaoPin(patient.getInpatientNo(), patient.getAdmissTimes(), patient.getLedgerSn(), patient.getInfantFlag()));
-        patient.getWeiPiPei().addAll(dao.weiGuiXiangMu(patient.getInpatientNo(), patient.getAdmissTimes(), patient.getLedgerSn(), patient.getInfantFlag()));
+        if (patient.getResponceType().equals("al")) {
+            patient.getWeiPiPei().addAll(dao.gongShangWeiPiPei(patient.getInpatientNo(), patient.getAdmissTimes(), patient.getLedgerSn(), patient.getInfantFlag()));
+        } else {
+            patient.getWeiPiPei().addAll(dao.weiGuiYaoPin(patient.getInpatientNo(), patient.getAdmissTimes(), patient.getLedgerSn(), patient.getInfantFlag()));
+            patient.getWeiPiPei().addAll(dao.weiGuiXiangMu(patient.getInpatientNo(), patient.getAdmissTimes(), patient.getLedgerSn(), patient.getInfantFlag()));
+        }
         patient.getWeiXieDaiYuanLiuShui().addAll(dao.weiXieDaiYuanLiuShuiXiangMu(patient.getInpatientNo(), patient.getAdmissTimes(), patient.getLedgerSn(), patient.getInfantFlag(), keShi, patient.getChuYuanYiZhu()));
         patient.getWeiXieDaiYuanLiuShui().addAll(dao.weiXieDaiYuanLiuShuiYaoPing(patient.getInpatientNo(), patient.getAdmissTimes(), patient.getLedgerSn(), patient.getInfantFlag(), keShi, patient.getChuYuanYiZhu()));
+
         return ResultVoUtil.success(patient);
     }
 
@@ -631,8 +636,7 @@ public class XiangMuLuRuService {
     public ResultVo<List<ZyDetailCharge>> huoQuZhenShuKePiPei(String inpatientNo, Integer admissTimes, Integer ledgerSn, String chargeCodeMx, String execUnit, String startTime, String endTime, String riQiPaiXu) {
         List<ZyDetailCharge> zhenShuFeiYong = dao.weiGuiZhenShuPiPei(publicServer.getInpatientNo(inpatientNo), admissTimes, ledgerSn, publicServer.getInfantFlag(inpatientNo),
                 chargeCodeMx, execUnit, startTime, endTime, riQiPaiXu);
-        List<ZyDetailCharge> yuEr = dao.tuiFeiYuEr1(publicServer.getInpatientNo(inpatientNo), admissTimes, ledgerSn, publicServer.getInfantFlag(inpatientNo),
-                chargeCodeMx, execUnit);
+        List<ZyDetailCharge> yuEr = dao.tuiFeiYuEr1(publicServer.getInpatientNo(inpatientNo), admissTimes, ledgerSn, chargeCodeMx, execUnit);
         Map<String, ZyDetailCharge> yuErPiPei = new HashMap<>();
         for (ZyDetailCharge item : yuEr) {
             String key = item.getInpatientNo() + item.getAdmissTimes() + item.getDetailSn() + item.getChargeCodeMx();
@@ -647,11 +651,15 @@ public class XiangMuLuRuService {
                     len--;
                     i--;
                 } else {
-                    log.info("原本的费用:{},减去的费用:{}", zy.getChargeFee(), yuErPiPei.get(key).getYiTuiFei());
+                    // 这里是 set 退费的余额
                     zy.setYiTuiFei(yuErPiPei.get(key).getYiTuiFei());
                 }
             }
         }
+        if (ListUtil.isBlank(zhenShuFeiYong)) {
+            return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST, "没有查询到该负数费用的对应正数。", dao.genJuBianMaChaZhaoZhenShuFeiYong(publicServer.getInpatientNo(inpatientNo), admissTimes, ledgerSn,
+                    publicServer.getInfantFlag(inpatientNo), chargeCodeMx, startTime, endTime, riQiPaiXu));
+        }
         return ResultVoUtil.success(zhenShuFeiYong);
     }