Ver código fonte

项目录入添加筛选条件。

xiaochan 4 anos atrás
pai
commit
3e1426800a

+ 1 - 1
pom.xml

@@ -10,7 +10,7 @@
     </parent>
     <groupId>thyyxxk</groupId>
     <artifactId>web-server</artifactId>
-    <version>9.9.6</version>
+    <version>9.9.7</version>
     <name>web-server</name>
     <description>server for yibao-web</description>
     <properties>

+ 47 - 8
src/main/java/thyyxxk/webserver/dao/his/yibao/XiangMuLuRuDao.java

@@ -5,6 +5,7 @@ import thyyxxk.webserver.entity.datamodify.FeiYongLeiXin;
 import thyyxxk.webserver.entity.datamodify.GetDropdownBox;
 import thyyxxk.webserver.entity.datamodify.ZyDetailCharge;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 /**
@@ -31,7 +32,7 @@ public interface XiangMuLuRuDao {
             "SELECT a.admiss_times, " +
             "       a.inpatient_no, " +
             "       a.ledger_sn, " +
-            "       a.detail_sn, " +
+            "       a.detail_sn," +
             "       a.charge_date, " +
             "       a.op_id_code, " +
             "       d.name op_name," +
@@ -62,10 +63,26 @@ public interface XiangMuLuRuDao {
             " a.charge_code_mx = #{chargeCode} and" +
             "</if>" +
             "        a.charge_code=b.code and " +
-            // "        a.order_no  =0    and " +
+            "<if test=\"startTime != null and startTime!= '' \">" +
+            " a.charge_date = #{startTime} and " +
+            "</if>" +
+            "<if test=\"orderNo !=null\">" +
+            "<choose>" +
+            "<when test=\"orderNo == 1\">" +
+            " len(a.order_no) &gt; 2 and " +
+            "</when>" +
+            "<when test=\"orderNo == 4\">" +
+            " a.order_no != 6 and " +
+            "</when>" +
+            "<otherwise>" +
+            " a.order_no = #{orderNo} and " +
+            "</otherwise>" +
+            "</choose>" +
+            "</if>" +
+
             "        a.serial=c.serial and " +
             "        c.code= a.charge_code_mx and a.charge_code like 'BILL%' and " +
-            "        a.infant_flag = '0' and d.code = a.op_id_code " +
+            "        a.infant_flag = #{infantFlag} and d.code = a.op_id_code " +
             "union " +
             "SELECT a.admiss_times, " +
             "       a.inpatient_no, " +
@@ -101,13 +118,31 @@ public interface XiangMuLuRuDao {
             " a.charge_code_mx = #{chargeCode} and" +
             "</if>" +
             "        a.charge_code=b.code and " +
-            //"      a.order_no = 0     and " +
+            "<if test=\"startTime != null and startTime!= '' \">" +
+            " a.charge_date = #{startTime} and " +
+            "</if>" +
+            "<if test=\"orderNo !=null\">" +
+            "<choose>" +
+            "<when test=\"orderNo == 1\">" +
+            " len(a.order_no) &gt; 2 and " +
+            "</when>" +
+            "<when test=\"orderNo == 4\">" +
+            " a.order_no != 6 and " +
+            "</when>" +
+            "<otherwise>" +
+            " a.order_no = #{orderNo} and " +
+            "</otherwise>" +
+            "</choose>" +
+            "</if>" +
             "        a.charge_code not like 'BILL%' and " +
-            "        a.infant_flag = '0' and c.code = a.op_id_code ) temp" +
+            "        a.infant_flag = #{infantFlag} and c.code = a.op_id_code ) temp" +
             "</script>")
     List<ZyDetailCharge> getHuanZheFeiYong(@Param("inpatientNo") String inpatientNo,
                                            @Param("admissTimes") Integer admissTimes,
-                                           @Param("chargeCode") String chargeCode);
+                                           @Param("chargeCode") String chargeCode,
+                                           @Param("infantFlag") int infantFlag,
+                                           @Param("startTime") String startTime,
+                                           @Param("orderNo") BigDecimal orderNo);
 
     /**
      * @param pyCode 拼音编码
@@ -415,14 +450,15 @@ public interface XiangMuLuRuDao {
             "VALUES " +
             "<foreach collection='list' item='item' separator=','>" +
             "(#{zyDetailCharge.inpatientNo}, #{zyDetailCharge.admissTimes}, #{zyDetailCharge.ledgerSn}, #{item.detailSn}, getdate()  " +
-            "  , #{zyDetailCharge.opIdCode}, #{item.chargeCode}, '0', '2', cast(#{item.chargeAmount,jdbcType=DECIMAL} as decimal(14,5))  " +
+            "  , #{zyDetailCharge.opIdCode}, #{item.chargeCode}, #{infantFlag}, '2', cast(#{item.chargeAmount,jdbcType=DECIMAL} as decimal(14,5))  " +
             "  , '0', '0', NULL, #{zyDetailCharge.ward}, #{zyDetailCharge.dept}  " +
             "  , 0, '0', #{item.deptCode}, cast(#{item.amount,jdbcType=DECIMAL} as decimal(14,5)), getdate()  " +
             "  , #{zyDetailCharge.zySerialNo}, #{item.chargeCode}, '00')" +
             "</foreach>" +
             "</script>")
     void chaRuFeiYong(@Param("zyDetailCharge") ZyDetailCharge zyDetailCharge,
-                      @Param("list") List<ZyDetailCharge> list);
+                      @Param("list") List<ZyDetailCharge> list,
+                      @Param("infantFlag") int infantFlag);
 
     /**
      * 需要更新患者的总费用
@@ -629,4 +665,7 @@ public interface XiangMuLuRuDao {
     List<String> chaXunZhiZXinKeShi(@Param("dept") String dept);
 
 
+    @Select("select role_id from dj_user_role where  user_code = #{code}")
+    List<Integer> huoQuJueSe(@Param("code") String code);
+
 }

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

@@ -32,6 +32,8 @@ public class ZyDetailCharge implements Serializable {
 
     private Integer admissTimes;
 
+    private String startTime;
+
     private String chargeCodeName;
 
     private Integer ledgerSn;

+ 61 - 18
src/main/java/thyyxxk/webserver/service/yibao/XiangMuLuRuService.java

@@ -50,9 +50,16 @@ public class XiangMuLuRuService {
      * @return 返回患者费用
      */
     public ResultVo<List<ZyDetailCharge>> getHuanZheFeiYong(ZyDetailCharge param) {
-        log.info("查询患者费用==》住院号{},住院次数:{},项目名称:{}", param.getInpatientNo(), param.getAdmissTimes(),
-                param.getChargeCode());
-        List<ZyDetailCharge> list = dao.getHuanZheFeiYong(param.getInpatientNo(), param.getAdmissTimes(), param.getChargeCode());
+        log.info("查询患者费用==》住院号{},住院次数:{},项目名称:{},录入日期:{},费用类型:{}", param.getInpatientNo(), param.getAdmissTimes(),
+                param.getChargeCode(), param.getStartTime(), param.getOrderNo());
+        int infantFlag = 0;
+        if (param.getInpatientNo().contains("$")) {
+            String[] yingEr = param.getInpatientNo().split("\\$");
+            param.setInpatientNo(yingEr[0]);
+            infantFlag = 1;
+        }
+        List<ZyDetailCharge> list = dao.getHuanZheFeiYong(param.getInpatientNo(), param.getAdmissTimes(), param.getChargeCode(), infantFlag,
+                param.getStartTime(), param.getOrderNo());
         Map<Integer, Integer> map = new HashMap<>();
         for (int i = 0; i < list.size(); i++) {
             // 判断一下这一条数据 是否为 退费数据 再把原数据和 本身添加一个退费的 flag
@@ -94,25 +101,39 @@ public class XiangMuLuRuService {
         for (ZyDetailCharge charge : chaKanSFtuiFei) {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("流水号为:【%s】已退费,请勿重复退费", charge.getOriDetailSn()));
         }
+        // 判断是否为婴儿
+        if (param.getInpatientNo().contains("$")) {
+            String[] yingEr = param.getInpatientNo().split("\\$");
+            param.setInpatientNo(yingEr[0]);
+        }
+        // 获取到用户角色
+        List<Integer> yongHuJueSe = dao.huoQuJueSe(TokenUtil.getTokenUserId());
 
-        /**
-         * 获取到科室费用
-         */
+        //获取到这个人是否属于这个科室
         List<String> zhiXinKeShi = dao.chaXunZhiZXinKeShi(param.getDeptCode());
-        // 获取最大值
-        Integer maxDetailSn = transferInOfExpensesDao.getMaxDetailSn(param.getInpatientNo(), param.getAdmissTimes());
+
         // 获取原来的数据
         List<ZyDetailCharge> yuanTuiFeiList = dao.huoQuJuTiFeiYong(param.getInpatientNo(), param.getAdmissTimes(), param.getLedgerSn(), param.getList());
         // 获取患者的总费用
         BigDecimal sum = new BigDecimal(0);
+        // 退费的list
+        // 获取最大值
+        Integer maxDetailSn = transferInOfExpensesDao.getMaxDetailSn(param.getInpatientNo(), param.getAdmissTimes());
         List<ZyDetailCharge> tuiFeiList = new ArrayList<>();
         for (ZyDetailCharge pojo : yuanTuiFeiList) {
             // 判断患者的费用是否存在负数
             if (pojo.getChargeFee().signum() == -1 || pojo.getChargeAmount().signum() == -1) {
-                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "患者费用存在负数,流水号:{" + pojo.getDetailSn() + "},该数据为退费数据");
+                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("患者费用存在负数,流水号:【%s】,该数据为退费数据", pojo.getDetailSn()));
+            }
+            // 管理员角色可以无视
+            if (!yongHuJueSe.contains(1)) {
+                if (!zhiXinKeShi.contains(pojo.getExecUnit())) {
+                    return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("流水号为【%s】,请对应的执行科室进行退费。", pojo.getDetailSn()));
+                }
             }
-            if (!zhiXinKeShi.contains(pojo.getExecUnit())) {
-                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("流水号为【%s】,请对应的执行科室进行退费。", pojo.getDetailSn()));
+            // 判断如果这个药品的医嘱号 大于0 那么就不能退
+            if (pojo.getChargeCode().equals("BILL01") || pojo.getChargeCode().equals("BILL02")) {
+                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("流水号为【%s】,中草药费或西药费,无法退费。", pojo.getDetailSn()));
             }
             sum = sum.add(pojo.getChargeFee().multiply(pojo.getChargeAmount()));
             pojo.setChargeFee(pojo.getChargeFee().negate());
@@ -121,16 +142,23 @@ public class XiangMuLuRuService {
             pojo.setOriDetailSn(pojo.getDetailSn());
             pojo.setDetailSn(maxDetailSn += 1);
             pojo.setOldGenTime(DateUtil.formatDatetime(pojo.getGenTime(), DateUtil.DEFAULT_PATTERN));
+            // 向退费 list 里面添加
             tuiFeiList.add(pojo);
         }
+        // 总费用计算
         FeiYongLeiXin fy = JiSuanFeiYong.jiSuan(yuanTuiFeiList, false);
+        // 计算出这一次 总退的费用
         fy.setTotalCharge(sum.negate());
         // 执行退费的操作 20 条的退费
-        List<List<ZyDetailCharge>> fenGe = ListUtils.partition(tuiFeiList, 20);
-        fenGe.forEach(dao::xiangMuTuiFei);
-        dao.huanZheZongFeiYong(fy, param.getInpatientNo(), param.getAdmissTimes(), "zy_actpatient");
-        log.info("操作项目退费 ==》 操作人:{},数据:{}", TokenUtil.getTokenUserId(), JSON.toJSONString(tuiFeiList));
-        return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "项目退费操作成功。");
+        if (tuiFeiList.isEmpty()) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "查询不到患者原数据,请联系管理员。");
+        } else {
+            List<List<ZyDetailCharge>> fenGe = ListUtils.partition(tuiFeiList, 20);
+            fenGe.forEach(dao::xiangMuTuiFei);
+            dao.huanZheZongFeiYong(fy, param.getInpatientNo(), param.getAdmissTimes(), "zy_actpatient");
+            log.info("操作项目退费 ==》 操作人:{},数据:{}", TokenUtil.getTokenUserId(), JSON.toJSONString(tuiFeiList));
+            return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "项目退费操作成功。");
+        }
     }
 
     /**
@@ -164,6 +192,12 @@ public class XiangMuLuRuService {
         return ResultVoUtil.success(dao.queryXiangMu(pyCode.toUpperCase() + "%"));
     }
 
+    /**
+     * 这个项目录入
+     *
+     * @param param 参数
+     * @return 返回提示语句
+     */
     @Transactional(rollbackFor = Exception.class)
     public ResultVo<String> xiangMuFeiYongShangChuan(ZyDetailCharge param) {
         if (param.getList().size() > 50) {
@@ -173,6 +207,15 @@ public class XiangMuLuRuService {
                 || StringUtil.isBlank(param.getWard()) || StringUtil.isBlank(param.getDept()) || StringUtil.isBlank(param.getZySerialNo())) {
             return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "患者信息不全。");
         }
+        // 婴儿 要特殊处理
+        int infantFlag = 0;
+        // 如果带有这个 $ 说明是婴儿
+        if (param.getInpatientNo().contains("$")) {
+            infantFlag = 1;
+            String[] yingEr = param.getInpatientNo().split("\\$");
+            param.setInpatientNo(yingEr[0]);
+        }
+
         // 获取最大流水号
         Integer maxDetailSn = transferInOfExpensesDao.getMaxDetailSn(param.getInpatientNo(), param.getAdmissTimes());
         // 获取项目的 总费用
@@ -199,7 +242,7 @@ public class XiangMuLuRuService {
         FeiYongLeiXin fy = JiSuanFeiYong.jiSuan(param.getList(), true);
         fy.setTotalCharge(sum);
         // 在此处 插入费用
-        dao.chaRuFeiYong(param, param.getList());
+        dao.chaRuFeiYong(param, param.getList(), infantFlag);
         dao.huanZheZongFeiYong(fy, param.getInpatientNo(), param.getAdmissTimes(), "zy_actpatient");
         log.info("项目录入费用上传 ==》 操作人:{},数据:{}", param.getOpIdCode(), JSON.toJSONString(param));
         return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "费用上传成功。");
@@ -237,7 +280,7 @@ public class XiangMuLuRuService {
         List<ZyDetailCharge> getYiZhuFeiYongFuShu = dao.getYiZhuFeiYong(inpatientNo, admissTimes, "<");
         // 需要保存需要匹配的一些流水数据
         List<ZyDetailCharge> piPei = new ArrayList<>();
-        // 保存正数的 map 来匹配
+        // 保存正数的数据用 map 来匹配
         Map<String, ZyDetailCharge> zhenShuMap = new HashMap<>();
         for (ZyDetailCharge zhenShu : getYiZhuFeiYongZhenShu) {
             String key = zhenShu.getOrderNo() + DateUtil.formatDatetime(zhenShu.getChargeDate()) + zhenShu.getChargeCodeMx() + zhenShu.getChargeAmount();