lihong 9 months ago
parent
commit
26e8e88f44

+ 48 - 10
src/main/java/cn/hnthyy/thmz/controller/mz/MzChargeDetailController.java

@@ -19,6 +19,7 @@ import cn.hnthyy.thmz.entity.his.zd.ZdChequeType;
 import cn.hnthyy.thmz.entity.his.zd.ZdUnitCode;
 import cn.hnthyy.thmz.entity.his.zy.ZyZdAuditItem;
 import cn.hnthyy.thmz.entity.thmz.Clinic;
+import cn.hnthyy.thmz.entity.thmz.Discount;
 import cn.hnthyy.thmz.entity.thmz.HybirdTest;
 import cn.hnthyy.thmz.entity.thmz.PayInfo;
 import cn.hnthyy.thmz.entity.thmz.TurnToConsultation;
@@ -39,15 +40,7 @@ import cn.hnthyy.thmz.service.his.zd.ZdChargeItemService;
 import cn.hnthyy.thmz.service.his.zd.ZdChequeTypeService;
 import cn.hnthyy.thmz.service.his.zd.ZdUnitCodeService;
 import cn.hnthyy.thmz.service.his.zy.ZyZdAuditItemService;
-import cn.hnthyy.thmz.service.thmz.ClinicService;
-import cn.hnthyy.thmz.service.thmz.HaiCiAdapterService;
-import cn.hnthyy.thmz.service.thmz.HybirdTestService;
-import cn.hnthyy.thmz.service.thmz.RationalUseService;
-import cn.hnthyy.thmz.service.thmz.TransactionService;
-import cn.hnthyy.thmz.service.thmz.TsmzService;
-import cn.hnthyy.thmz.service.thmz.TurnToConsultationService;
-import cn.hnthyy.thmz.service.thmz.UserDeptRelationService;
-import cn.hnthyy.thmz.service.thmz.WindowsService;
+import cn.hnthyy.thmz.service.thmz.*;
 import cn.hnthyy.thmz.vo.ChargeFeeParamsVo;
 import cn.hnthyy.thmz.vo.MzDepositFileVo;
 import cn.hnthyy.thmz.vo.MzPrescriptionVo;
@@ -137,6 +130,8 @@ public class MzChargeDetailController {
     private MzOrderLockMapper mzOrderLockMapper;
     @Resource
     private MzYjReqService mzYjReqService;
+    @Resource
+    DiscountService discountService;
 
     @Value("${healthEducationUrl}")
     private String healthEducationUrl;
@@ -434,6 +429,11 @@ public class MzChargeDetailController {
                 resultMap.put("receiptNo", receiptNo);
             }
              else  if(CollUtil.isNotEmpty(mzDepositFiles)){
+                 if(mzDepositFiles.stream().anyMatch(item->Constants.ZZWX.equals(item.getChequeType()))){
+                     resultMap.put("code", -1);
+                     resultMap.put("message", "缴费失败,已经缴费,缴费方式为微信缴费,请不要重复缴费!");
+                     return resultMap;
+                 }
                 //    修改收费人
                 mzChargeDetailService.updateOpId(HttpUtil.getIPAddress(httpServletRequest),TokenUtil.getUser().getUserIdCode(),mzDepositFileVo);
                 resultMap.put("receiptNo", 1);
@@ -1957,8 +1957,42 @@ public class MzChargeDetailController {
                 mzPrescriptionVo.setDoctorCode(Constants.BRZZJF_CODE);
             }
             Tools.setReqNo(mzPrescriptionVo.getMzYjReqList());
+            Map<String, Object> tempPrescription = mzChargeDetailService.getAmountForTempPrescription(mzPrescriptionVo);
+            List<String> chargeItemCodes = new ArrayList<>();
+            discountService.getChargeItemCodes(chargeItemCodes,mzPrescriptionVo);
+            List<Discount> discounts = discountService.containsTcItem(chargeItemCodes);
+            BigDecimal discountAmount = Convert.toBigDecimal(tempPrescription.get("discountAmount"), BigDecimal.ZERO);
+            if(CollUtil.isNotEmpty(discounts) && discountAmount.compareTo(new BigDecimal("1")) <= 0){
+                //优惠警告信息
+                List<String> discountWarningMessageList = new ArrayList<>();
+                for(Discount discount: discounts){
+                    if(StrUtil.isNotBlank(discount.getDeptNo())){
+                        List<String> deptList = CollUtil.newArrayList(discount.getDeptNo().split(","));
+                        List<String> deptNameList = new ArrayList<>();
+                        for (String dept :deptList){
+                            ZdUnitCode zdUnitCode = zdUnitCodeService.queryByCode(dept);
+                            if(zdUnitCode != null){
+                                deptNameList.add(zdUnitCode.getName());
+                            }
+                        }
+                        String msg = "";
+                        if(!deptList.contains(mzPrescriptionVo.getVisitDeptCode())){
+                            msg += "该处方包含优惠套餐("+discount.getName()+"),但是申请科室不符(该优惠套餐只有科室["+CollUtil.join(deptNameList,",")+"]享受折扣优惠,请检查是否申请科室是否正确),如果不要套餐优惠折扣请忽略;";
+                        }
+                        if(Convert.toInt(mzPrescriptionVo.getZgmztczf(),0) == 1){
+                            msg += "该处方包含优惠套餐("+discount.getName()+"),已选择门诊统筹处方不享受折扣优惠,如要优惠折扣,门诊统筹请选否,如果不要套餐优惠折扣请忽略";
+                        }
+                        if(StrUtil.isNotBlank(msg)){
+                            discountWarningMessageList.add(msg);
+                        }
+                    }
+                }
+                if(CollUtil.isNotEmpty(discountWarningMessageList)){
+                    resultMap.put("discountWarningMessage",CollUtil.join(discountWarningMessageList,";"));
+                }
+            }
             resultMap.put("code", 0);
-            resultMap.put("data", mzChargeDetailService.getAmountForTempPrescription(mzPrescriptionVo));
+            resultMap.put("data",tempPrescription);
             resultMap.put("message", "计算临时处方的中药,西药,诊疗以及总金额成功");
             return resultMap;
         } catch (MzException e) {
@@ -3009,6 +3043,10 @@ public class MzChargeDetailController {
         if(mzOrderLock != null && Convert.toInt(mzOrderLock.getLockFlag(),0) == 1){
             return R.error("处方在缴费中,不能修改处方");
         }
+        Integer countYbJs = mzPatientMiService.countYbJs(patientId, times);
+        if(Convert.toInt(countYbJs,0) > 0) {
+            return R.error("处方已经结算,不能修改处方,如要修改请找医保科取消医保结算再修改");
+        }
         return R.ok();
     }
     @UserLoginToken

+ 8 - 0
src/main/java/cn/hnthyy/thmz/mapper/his/mz/MzPatientMiMapper.java

@@ -247,6 +247,14 @@ public interface MzPatientMiMapper {
             " union " +
             "  select fund_pay,psn_acct_pay from powersi_mip_setlinfo where med_org_ord ='${patientId}_${times}_1' and ord_state ='SETTLED' ")
     Map<String,BigDecimal>  selectYbAmount(@Param("patientId") String patientId,@Param("times") Integer times);
+    /**
+     * 根据门诊ID和就诊次数查询门诊统筹报销金额 包含统筹支付和个人账户支付金额
+     * @param patientId
+     * @param times
+     * @return  fund_pay_sumamt 基金支付总额  acct_pay 个人账户支出
+     */
+    @Select("select fund_pay_sumamt,acct_pay from t_si_setlinfo where pat_no=#{patientId} and times=#{times} and revoked=0 ")
+    Map<String,BigDecimal>  selectYbSiAmount(@Param("patientId") String patientId,@Param("times") Integer times);
 
 
     /**

+ 9 - 0
src/main/java/cn/hnthyy/thmz/service/his/mz/MzPatientMiService.java

@@ -126,4 +126,13 @@ public interface MzPatientMiService {
      * @return: java.lang.String
      **/
     String getCrmTypeName(String patientId);
+    /**
+     * @description: 是否结算
+     * @author: lihong
+     * @date: 2024/11/27 11:02
+     * @param: patientId
+     * @param: times
+     * @return: java.lang.Integer
+     **/
+    Integer countYbJs(String patientId, Integer times);
 }

+ 5 - 2
src/main/java/cn/hnthyy/thmz/service/impl/his/mz/MzChargeDetailServiceImpl.java

@@ -281,7 +281,7 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
                 if (mzChargeDetail.getCountYbZf() <= 0) {
                     continue;
                 }
-                Map<String, BigDecimal> ybAmountMap = mzPatientMiMapper.selectYbAmount(mzChargeDetail.getPatientId(), mzChargeDetail.getTimes());
+                Map<String, BigDecimal> ybAmountMap = mzPatientMiMapper.selectYbSiAmount(mzChargeDetail.getPatientId(), mzChargeDetail.getTimes());
                 if (ybAmountMap == null || ybAmountMap.size() == 0) {
                     continue;
                 }
@@ -1272,6 +1272,9 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
             if(Convert.toInt(mzOrderLock.getLockFlag(),0) == 1){
                 throw new MzException("当前病人正在缴费中,不能修改处方!");
             }
+            if(Convert.toInt(mzPatientMiService.countYbJs(dbClinic.getPatientId(),dbClinic.getTimes()),0) > 0){
+                throw new MzException("处方已经结算,不能修改处方,如要修改请找医保科取消医保结算再修改!");
+            }
             List<MzChargeDetail> dbMzChargeDetailList = mzChargeDetailMapper.selectNotPayMzChargeDetailByPatientId(mzPrescriptionVo.getPatientId(), dbClinic.getTimes());
             if (dbMzChargeDetailList != null && dbMzChargeDetailList.size() > 0) {
                 for (MzChargeDetail mzChargeDetail : dbMzChargeDetailList) {
@@ -2874,7 +2877,7 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService {
         if (totalAmount == null) {
             throw new MzException("该患者本次门诊处方没有产生任何费用!");
         }
-        Map<String, BigDecimal> map = mzPatientMiMapper.selectYbAmount(patientId, times);
+        Map<String, BigDecimal> map = mzPatientMiMapper.selectYbSiAmount(patientId, times);
         if (map == null) {
             throw new MzException("该患者本次门诊处方没有门诊统筹费用补录信息!");
         }

+ 13 - 0
src/main/java/cn/hnthyy/thmz/service/impl/his/mz/MzPatientMiServiceImpl.java

@@ -287,4 +287,17 @@ public class MzPatientMiServiceImpl implements MzPatientMiService {
         }
         return null;
     }
+
+    /**
+     * @description: 是否结算
+     * @author: lihong
+     * @date: 2024/11/27 11:02
+     * @param: patientId
+     * @param: times
+     * @return: java.lang.Integer
+     */
+    @Override
+    public Integer countYbJs(String patientId, Integer times) {
+        return mzPatientMiMapper.countYbJs(patientId,times);
+    }
 }

+ 52 - 18
src/main/java/cn/hnthyy/thmz/service/impl/thmz/DiscountServiceImpl.java

@@ -239,6 +239,31 @@ public class DiscountServiceImpl implements DiscountService {
         return map;
     }
 
+    /**
+     * @param chargeItemCodes
+     * @description: 是否匹配套餐项目 并返回匹配的套餐名称  不考虑考试匹配
+     * @author: lihong
+     * @date: 2024/12/2 9:59
+     * @param: chargeItemCodes
+     * @return: java.lang.String
+     */
+    @Override
+    public List<Discount> containsTcItem(List<String> chargeItemCodes) {
+        if(CollUtil.isEmpty(chargeItemCodes)) return null;
+        List<Discount> discounts = discountMapper.selectTcDiscountForToday();
+        if(CollUtil.isEmpty(discounts)) return null;
+        List<Discount> deptDiscount = discounts.stream().filter(obj -> obj.getTemplateId() != null && obj.getDeptType() !=null && obj.getDeptType() != 2 && StrUtil.isNotBlank(obj.getDeptNo())).collect(Collectors.toList());
+        if(CollUtil.isEmpty(deptDiscount)) return null;
+        List<Discount> result = new ArrayList<>();
+            for(Discount discount : discounts){
+                List<String> itemCodes = getItemCodes(discount.getTemplateId());
+                if(CollUtil.isNotEmpty(itemCodes) && CollUtil.containsAll(CollUtil.newHashSet(chargeItemCodes), CollUtil.newHashSet(itemCodes))){
+                    result.add(discount);
+                }
+            }
+        return result;
+    }
+
     private void setValue(List<String> chargeItemCodes, Map<String, BigDecimal> map, Discount discount) {
         Long templateId = discount.getTemplateId();
         List<String> itemCodes = getItemCodes(templateId);
@@ -261,26 +286,12 @@ public class DiscountServiceImpl implements DiscountService {
         Template template = templateService.queryById(templateId);
         if (template != null && StrUtil.isNotBlank(template.getTemplateData())) {
             MzPrescriptionVo mzPrescriptionVo = (MzPrescriptionVo) JsonUtil.jsontoObject(template.getTemplateData(), MzPrescriptionVo.class);
-            List<MzYjReq> mzYjReqList = mzPrescriptionVo.getMzYjReqList();
-            if(CollUtil.isNotEmpty(mzYjReqList)){
-                mzYjReqList.forEach(item -> {
-                            List<String> yjItemCodes = getItemCodes(item.getOrderCode(), item.getReqType());
-                            if (CollUtil.isNotEmpty(yjItemCodes)) {
-                                result.addAll(yjItemCodes);
-                            }
-                        }
-                );
-            }
-            List<MzChargeDetail> mzChargeDetailList = mzPrescriptionVo.getMzChargeDetailList();
-            if (CollUtil.isNotEmpty(mzChargeDetailList)) {
-                List<String> chargeItemCodes = mzChargeDetailList.stream().filter(item -> StrUtil.isNotBlank(item.getChargeItemCode())).map(MzChargeDetail::getChargeItemCode).collect(Collectors.toList());
-                if (CollUtil.isNotEmpty(chargeItemCodes)) {
-                    result.addAll(chargeItemCodes);
-                }
-            }
+            getChargeItemCodes(result, mzPrescriptionVo);
         }
         return result;
     }
+
+
     /**
      * @description:获取医技处方对应的项目编码集合
      * @author: lihong
@@ -458,7 +469,8 @@ public class DiscountServiceImpl implements DiscountService {
                 Map<String, Object> amountForTempPrescription = mzChargeDetailService.getAmountForTempPrescription(mzPrescriptionVo);
                 totalFee = (BigDecimal) amountForTempPrescription.get("amount");
             }catch (Exception e){
-                throw new BizException(e.getMessage());
+                log.error("查询套餐费用报错:{}",e.getMessage());
+                return BigDecimal.ZERO;
             }
 
         }
@@ -650,4 +662,26 @@ public class DiscountServiceImpl implements DiscountService {
             throw new BizException("项目有单项优惠折扣",-2);
         }
     }
+
+    @Override
+    public void getChargeItemCodes(List<String> result,MzPrescriptionVo mzPrescriptionVo) {
+        if(mzPrescriptionVo == null) return;
+        List<MzYjReq> mzYjReqList = mzPrescriptionVo.getMzYjReqList();
+        if(CollUtil.isNotEmpty(mzYjReqList)){
+            mzYjReqList.forEach(item -> {
+                        List<String> yjItemCodes = getItemCodes(item.getOrderCode(), item.getReqType());
+                        if (CollUtil.isNotEmpty(yjItemCodes)) {
+                            result.addAll(yjItemCodes);
+                        }
+                    }
+            );
+        }
+        List<MzChargeDetail> mzChargeDetailList = mzPrescriptionVo.getMzChargeDetailList();
+        if (CollUtil.isNotEmpty(mzChargeDetailList)) {
+            List<String> chargeItemCodes = mzChargeDetailList.stream().filter(item -> StrUtil.isNotBlank(item.getChargeItemCode())).map(MzChargeDetail::getChargeItemCode).collect(Collectors.toList());
+            if (CollUtil.isNotEmpty(chargeItemCodes)) {
+                result.addAll(chargeItemCodes);
+            }
+        }
+    }
 }

+ 11 - 0
src/main/java/cn/hnthyy/thmz/service/thmz/DiscountService.java

@@ -2,6 +2,7 @@ package cn.hnthyy.thmz.service.thmz;
 
 import cn.hnthyy.thmz.entity.MzException;
 import cn.hnthyy.thmz.entity.thmz.Discount;
+import cn.hnthyy.thmz.vo.MzPrescriptionVo;
 
 import java.math.BigDecimal;
 import java.util.List;
@@ -83,6 +84,14 @@ public interface DiscountService {
      * @return: cn.hnthyy.thmz.entity.thmz.Discount
      **/
     Map<String, BigDecimal> getTcDiscountRate(Integer deptType, String deptNo, List<String> chargeItemCodes);
+    /**
+     * @description: 是否匹配套餐项目 并返回匹配的套餐
+     * @author: lihong
+     * @date: 2024/12/2 9:59
+     * @param: chargeItemCodes
+     * @return: java.lang.String
+     **/
+    List<Discount> containsTcItem(List<String> chargeItemCodes);
 
     /**
      * 初始化缓存
@@ -165,4 +174,6 @@ public interface DiscountService {
      * @param: chargeCodes
      **/
     void checkDiscount(String patientId,Integer times, List<String> chargeCodes);
+
+    void getChargeItemCodes(List<String> result,MzPrescriptionVo mzPrescriptionVo);
 }

+ 3 - 0
src/main/resources/static/js/mz/clinic.js

@@ -6248,6 +6248,9 @@ function calculateTotalAmount(needRemoveLastObject) {
                 return;
             }
             if (res.code == 0) {
+                if(!stringIsBlank(res.discountWarningMessage)){
+                    warningMesageSimaple(res.discountWarningMessage)
+                }
                 $("#totalAmount").html(res.data.amount.toFixed(2));
                 var arrs = $("span.cf_amount");
                 for (var i = 0; i < arrs.length; i++) {