Forráskód Böngészése

药品退费提药单。

DESKTOP-0GD05B0\Administrator 2 éve
szülő
commit
9c617c0825

+ 25 - 8
src/main/java/thyyxxk/webserver/controller/inpatient/XiangMuLuRuController.java

@@ -163,20 +163,37 @@ public class XiangMuLuRuController {
         return service.xiuGaiZiFeiBiaoZhi(param);
     }
 
-    @GetMapping("/drugRefundForm")
-    public ResultVo<Map<String, List<DrugReturnForm>>> drugRefundForm(@RequestParam("groupNo") String groupNo,
-                                                                      @RequestParam("patNo") String patNo,
-                                                                      @RequestParam("times") Integer times,
-                                                                      @RequestParam("refundTime") String refundTime) {
-        return service.drugRefundForm(groupNo, patNo, times, refundTime);
-    }
-
     @GetMapping("/rejectNotGeneratedMedicationList")
     public ResultVo<String> rejectNotGeneratedMedicationList(@RequestParam("patNo") String patNo,
                                                              @RequestParam("times") Integer times) {
         return service.rejectNotGeneratedMedicationList(patNo, times);
     }
 
+    @GetMapping("/getNoMedicineReturnOrderGenerated")
+    public ResultVo<List<DrugReturnForm>> getNoMedicineReturnOrderGenerated(@RequestParam("startDate") String startDate,
+                                                                            @RequestParam("endDate") String endDate,
+                                                                            @RequestParam("groupNo") String groupNo) {
+        return service.getNoMedicineReturnOrderGenerated(startDate, endDate, groupNo);
+    }
+
+    @GetMapping("/generateMedicationList")
+    public ResultVo<Integer> generateMedicationList(@RequestParam("startDate") String startDate,
+                                                   @RequestParam("endDate") String endDate,
+                                                   @RequestParam("groupNo") String groupNo) {
+        return service.generateMedicationList(startDate, endDate, groupNo);
+    }
+
+    @GetMapping("/getPrescription")
+    public ResultVo<List<DrugReturnForm>> getPrescription(@RequestParam("startDate") String startDate,
+                                                          @RequestParam("endDate") String endDate) {
+        return service.getPrescription(startDate, endDate);
+    }
+
+
+    @GetMapping("/getAPrescriptionByPageNo")
+    public ResultVo<List<DrugReturnForm>> getAPrescriptionByPageNo(@RequestParam("pageNo") Integer pageNo) {
+        return service.getAPrescriptionByPageNo(pageNo);
+    }
 
 }
 

+ 64 - 23
src/main/java/thyyxxk/webserver/dao/his/inpatient/XiangMuLuRuDao.java

@@ -15,6 +15,7 @@ import thyyxxk.webserver.entity.projectEntry.DrugReturnForm;
 
 import java.math.BigDecimal;
 import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -308,7 +309,8 @@ public interface XiangMuLuRuDao extends BaseMapper<ZyDetailCharge> {
             "       suppress_flag, " +
             "       ward_code, " +
             "       dept_code, " +
-            "       order_no, " +
+            "       order_no," +
+            "       order_no as new_order_no, " +
             "       ope_flag, " +
             "       exec_unit, " +
             "       gen_time, " +
@@ -410,7 +412,7 @@ public interface XiangMuLuRuDao extends BaseMapper<ZyDetailCharge> {
             "<foreach collection='list' item='item' separator=','>" +
             "(#{item.inpatientNo},#{item.admissTimes},#{item.ledgerSn},#{item.detailSn},getdate(),#{item.opIdCode},#{item.chargeCode},#{item.infantFlag}," +
             "#{item.chargeStatus},#{item.retprice},cast(#{item.chargeAmount,jdbcType=DECIMAL} as decimal(14,5)),cast(#{item.chargeFee,jdbcType=DECIMAL} as decimal(14,5))," +
-            "#{item.selfFlag},#{item.separateFlag},#{item.suppressFlag},#{item.wardCode},#{item.deptCode},0," +
+            "#{item.selfFlag},#{item.separateFlag},#{item.suppressFlag},#{item.wardCode},#{item.deptCode},#{item.newOrderNo}," +
             "#{item.opeFlag},#{item.execUnit},#{item.oldGenTime}," +
             "#{item.payPercent},#{item.zjFlag},#{item.zfl},#{item.chargeCodeMx},#{item.serial},#{item.zySerialNo},#{item.doctorCode}," +
             "#{item.ybSelfFlag},cast(#{item.origChargeFee,jdbcType=DECIMAL} as decimal(14,5)),#{item.confirmId},0,#{item.ssCode},#{item.gsFlag}," +
@@ -1138,8 +1140,15 @@ public interface XiangMuLuRuDao extends BaseMapper<ZyDetailCharge> {
     void xiuGaiZiFeiZhiYiBaoBiaoZhi(@Param(Constants.WRAPPER) Wrapper<?> wq);
 
 
-    @Select("<script>" +
-            "select a.charge_code, " +
+
+    @Update("update yz_yp_zy_order set status_flag = '2' " +
+            "where inpatient_no = #{patNo} " +
+            "and admiss_times = #{times} " +
+            "and page_no = 0")
+    void rejectNotGeneratedMedicationList(String patNo, Integer times);
+
+
+    @Select("select a.charge_code, " +
             "       b.name         as drug_name, " +
             "       b.specification, " +
             "       a.amount, " +
@@ -1149,28 +1158,60 @@ public interface XiangMuLuRuDao extends BaseMapper<ZyDetailCharge> {
             "       a.name, " +
             "       page_class, " +
             "       page_no_ty " +
-            "from yz_yp_zy_order a, " +
-            "     yp_zd_dict b " +
-            "where a.inpatient_no = #{patNo} " +
-            "  and a.admiss_times = #{times}" +
+            "from yz_yp_zy_order a," +
+            "yp_zd_dict b " +
+            "where page_no_ty = 0 " +
+            "  and dept_code = #{dept}" +
             "  and group_no = #{groupNo} " +
-            "  and a.status_flag = 1 " +
             "  and page_class = 'HT' " +
-            "<if test=\"refundTime != null and refundTime != '' \">" +
-            " and CONVERT(varchar(100), occ_time, 23)  = #{refundTime} " +
-            "</if>" +
+            "  AND charge_date >= #{start} AND charge_date <= #{end}" +
             "  and a.charge_code = b.code " +
-            "  and a.serial = b.serial " +
-            "</script>")
-    List<DrugReturnForm> queryTheDrugReturnForm(@Param("groupNo") String groupNo,
-                                                @Param("patNo") String patNo,
-                                                @Param("times") Integer times,
-                                                @Param("refundTime") String refundTime);
+            "  and a.serial = b.serial ")
+    List<DrugReturnForm> selectNoMedicineReturnOrderGenerated(String start,
+                                                              String end,
+                                                              String dept,
+                                                              String groupNo);
+
+
+    @Update("update yz_yp_zy_order set page_no_ty = #{pageNo} " +
+            "where page_no_ty = 0 " +
+            "  and dept_code = #{dept}" +
+            "  and group_no = #{groupNo} " +
+            "  and page_class = 'HT' " +
+            "  AND charge_date >= #{start} AND charge_date <= #{end}")
+    void generateMedicationList(String start,
+                                String end,
+                                String dept,
+                                String groupNo,
+                                int pageNo);
+
+
+    @Select("select page_no, " +
+            "       group_no, " +
+            "       group_name = (select rtrim(group_name) from yp_zd_group_name b where b.group_no = yz_yp_page_no.group_no) " +
+            "from yz_yp_page_no " +
+            "where dept_code = #{dept} " +
+            "  and page_class = 'HT' " +
+            "  AND submit_time >= #{start} AND submit_time <= #{end}")
+    List<DrugReturnForm> getPrescription(String start, String end, String dept);
+
+
+    @Select("select a.charge_code, " +
+            "       b.name         as drug_name, " +
+            "       b.specification, " +
+            "       a.amount, " +
+            "       a.retprice, " +
+            "       b.pack_retprice, " +
+            "       a.inpatient_no as pat_no, " +
+            "       a.name, " +
+            "       page_class, " +
+            "       page_no_ty " +
+            "from yz_yp_zy_order a," +
+            "yp_zd_dict b " +
+            " where a.page_no_ty = #{pageNo} " +
+            "  and a.charge_code = b.code " +
+            "  and a.serial = b.serial")
+    List<DrugReturnForm> getAPrescriptionByPageNo(Integer pageNo);
 
 
-    @Update("update yz_yp_zy_order set status_flag = '2' " +
-            "where inpatient_no = #{patNo} " +
-            "and admiss_times = #{times} " +
-            "and page_no = 0")
-    void rejectNotGeneratedMedicationList(String patNo, Integer times);
 }

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

@@ -96,6 +96,7 @@ public class ZyDetailCharge implements Serializable {
     private String deptCode;
 
     private BigDecimal orderNo;
+    private BigDecimal newOrderNo;
     private BigDecimal actOrderNo;
 
     private String opeFlag;

+ 8 - 0
src/main/java/thyyxxk/webserver/entity/projectEntry/DrugReturnForm.java

@@ -10,6 +10,8 @@ public class DrugReturnForm {
      * 项目编码
      */
     private String chargeCode;
+
+    private Integer pageNo;
     /**
      * 名称
      */
@@ -45,4 +47,10 @@ public class DrugReturnForm {
      * 退药单
      */
     private String pageNoTy;
+
+    /**
+     * 药房
+     */
+    private String groupNo;
+    private String groupName;
 }

+ 65 - 19
src/main/java/thyyxxk/webserver/service/inpatient/XiangMuLuRuService.java

@@ -1,5 +1,6 @@
 package thyyxxk.webserver.service.inpatient;
 
+import cn.hutool.extra.spring.SpringUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.dynamic.datasource.annotation.DS;
@@ -59,6 +60,10 @@ public class XiangMuLuRuService {
         this.siSettleApplyDao = siSettleApplyDao;
     }
 
+    private XiangMuLuRuService getThis() {
+        return SpringUtil.getBean(this.getClass());
+    }
+
     /**
      * 获取患者费用
      * 费用 类型  1 - 医嘱  2 - 项目费用  3 - 医技 4 - 全部  5 -药品费用
@@ -189,9 +194,9 @@ public class XiangMuLuRuService {
                 return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, String.format("流水号:【%s】,中药无法退费。", item.getDetailSn()));
             }
             // 数据库有个 触发器 如果带了医嘱号且有篆刻那么这里就需要改成 0
-//            if (BigUtils.bigDaYu(item.getOrderNo(), 10)) {
-//                item.setOrderNo(new BigDecimal(0));
-//            }
+            if (BigUtils.bigDaYu(item.getOrderNo(), 10)) {
+                item.setNewOrderNo(new BigDecimal(0));
+            }
             // 00 是项目
             if ("00".equals(item.getSerial())) {
                 maxDetailSn = setRefund(project, tuiFeiList, updateRefundFlag, maxDetailSn, item);
@@ -234,14 +239,14 @@ public class XiangMuLuRuService {
             }
 
             ZyActpatient patientInfo = publicServer.huoQuHuanZheXinXi(param.getInpatientNo());
-            // 药品单号
-            Integer pageNo = publicServer.getTheDrugListNo();
-            // 退药单汇总
-            dao.drugReturnForm(pageNo, userInfo.getDeptCode(), TokenUtil.getTokenUserId(), param.getGroupNo());
+//            // 药品单号
+//            Integer pageNo = publicServer.getTheDrugListNo();
+//            // 退药单汇总
+//            dao.drugReturnForm(pageNo, userInfo.getDeptCode(), TokenUtil.getTokenUserId(), param.getGroupNo());
             // 退药明细
             dao.detailsOfDrugReturnForm(drug, patientInfo.getInpatientNo(), patientInfo.getAdmissTimes(),
                     patientInfo.getName(), patientInfo.getBedNo(), userInfo.getDeptCode(), infantFlag,
-                    param.getGroupNo(), TokenUtil.getTokenUserId(), pageNo, ledgerSn);
+                    param.getGroupNo(), TokenUtil.getTokenUserId(), 0, ledgerSn);
             // 药品的退药 标准 为 -2 申请退药
             dao.genXinZhenShuTuiFeiLiuShui(param.getInpatientNo(), param.getAdmissTimes(), ledgerSn, updateDrugLabel, -2);
             log.info("项目录入==》药品退费,操作人:{},数据:{}", TokenUtil.getTokenUserId(), JSON.toJSONStringWithDateFormat(drug, DateUtil.DEFAULT_PATTERN));
@@ -863,17 +868,6 @@ public class XiangMuLuRuService {
         return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION);
     }
 
-
-    public ResultVo<Map<String, List<DrugReturnForm>>> drugRefundForm(String groupNo, String patNo, Integer times, String refundTime) {
-        Map<String, List<DrugReturnForm>> drugPageNoGy = dao.queryTheDrugReturnForm(groupNo, patNo, times, refundTime).stream()
-                .collect(Collectors.groupingBy(DrugReturnForm::getPageNoTy));
-        if (drugPageNoGy.isEmpty()) {
-            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有护士退药单。");
-        }
-        return ResultVoUtil.success(drugPageNoGy);
-    }
-
-
     public ResultVo<String> rejectNotGeneratedMedicationList(String patNo, Integer times) {
         log.info("拒绝生成的药单 ==> 住院号:{},住院次数:{},操作人:{}", patNo, times, TokenUtil.getTokenUserId());
         Date disdate;
@@ -888,5 +882,57 @@ public class XiangMuLuRuService {
         return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION);
     }
 
+    public ResultVo<List<DrugReturnForm>> getNoMedicineReturnOrderGenerated(String startDate, String endDate, String groupNo) {
+        UserInfo us = redisLikeService.getUserInfoByToken();
+        return ResultVoUtil.success(groupingValues(dao.selectNoMedicineReturnOrderGenerated(startDate, endDate, us.getDeptCode(), groupNo)));
+    }
+
+    public List<DrugReturnForm> groupingValues(List<DrugReturnForm> list) {
+        if (ListUtil.isBlank(list)) {
+            return list;
+        }
+        Map<String, DrugReturnForm> map = new HashMap<>(list.size());
+        list.forEach(item -> {
+            if (map.containsKey(item.getChargeCode())) {
+                DrugReturnForm temp = map.get(item.getChargeCode());
+                temp.setAmount(temp.getAmount().add(item.getAmount()));
+                temp.setRetprice(temp.getRetprice().add(item.getRetprice()));
+            } else {
+                map.put(item.getChargeCode(), item);
+            }
+        });
+        return new ArrayList<>(map.values());
+    }
+
+    /**
+     * 生成药单
+     *
+     * @param startDate 开始时间
+     * @param endDate   结束时间
+     * @param groupNo   药房
+     * @return 返回提示
+     */
+    public ResultVo<Integer> generateMedicationList(String startDate, String endDate, String groupNo) {
+        UserInfo us = redisLikeService.getUserInfoByToken();
+        Integer pageNo = publicServer.getTheDrugListNo();
+        getThis().generateMedicationListFunc(startDate, endDate, groupNo, pageNo, us.getDeptCode());
+        return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, "药单生成成功。", pageNo);
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    public void generateMedicationListFunc(String startDate, String endDate, String groupNo, Integer pageNo, String dept) {
+        dao.drugReturnForm(pageNo, dept, TokenUtil.getTokenUserId(), groupNo);
+        dao.generateMedicationList(startDate, endDate, dept, groupNo, pageNo);
+    }
+
+    public ResultVo<List<DrugReturnForm>> getPrescription(String startDate, String endDate) {
+        UserInfo us = redisLikeService.getUserInfoByToken();
+        return ResultVoUtil.success(dao.getPrescription(startDate, endDate, us.getDeptCode()));
+    }
+
+    public ResultVo<List<DrugReturnForm>> getAPrescriptionByPageNo(Integer pageNo) {
+        return ResultVoUtil.success(groupingValues(dao.getAPrescriptionByPageNo(pageNo)));
+    }
+
 }