LIJU vor 4 Monaten
Ursprung
Commit
296e5c4d56

+ 265 - 0
src/main/java/cn/hnthyy/thmz/controller/mz/MzPharmacyController.java

@@ -52,6 +52,11 @@ import cn.hnthyy.thmz.vo.MzRefundMedicineVo;
 import cn.hnthyy.thmz.vo.MzSendMedicineVo;
 import cn.hnthyy.thmz.vo.PharmacyCellVo;
 import cn.hnthyy.thmz.vo.YpMzFytjVo;
+import cn.hnthyy.thmz.controller.yb.YbController;
+import cn.hnthyy.thmz.entity.yb.SelinfoSold;
+import cn.hnthyy.thmz.entity.yb.SelinfoSoldTotal;
+import cn.hnthyy.thmz.entity.yb.DrugTracCodg;
+import cn.hnthyy.thmz.entity.jy.ResultVo;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.time.DateUtils;
@@ -123,6 +128,9 @@ public class MzPharmacyController {
     private MzZdInstructionCodeService mzZdInstructionCodeService;
     @Resource
     private YpZdGroupNameService ypZdGroupNameService;
+    
+    @Autowired
+    private YbController ybController;
     /**
      * 查询处方信息
      *
@@ -1980,4 +1988,261 @@ public class MzPharmacyController {
         
         return resultMap;
     }
+
+    /**
+     * 撤销退药时调用医保销售接口
+     * 内嵌获取退药明细、追溯码查询、医保接口调用
+     */
+    @RequestMapping(value = "/cancelRefundWithYb", method = {RequestMethod.POST})
+    @UserLoginToken
+    public Map<String, Object> cancelRefundWithYb(@RequestBody Map<String, Object> params) {
+        Map<String, Object> resultMap = new HashMap<>();
+        try {
+            log.info("撤销退药医保接口调用开始,参数:{}", params);
+            
+            // 1. 获取退药明细数据(包含所有医保接口需要的参数)
+            ChargeFeeParamsVo chargeFeeParamsVo = new ChargeFeeParamsVo();
+            chargeFeeParamsVo.setPatientId((String) params.get("patientId"));
+            chargeFeeParamsVo.setTimes((Integer) params.get("times"));
+            chargeFeeParamsVo.setReceiptNo(String.valueOf(params.get("receiptNo")));
+            chargeFeeParamsVo.setOrderNo(String.valueOf(params.get("orderNo")));
+            chargeFeeParamsVo.setGroupNoOut((String) params.get("groupNoOut"));
+            chargeFeeParamsVo.setConfirmFlag(3); // 已退药状态
+            
+            List<Map<String, Object>> refundDetailList = mzPharmacyService.getPrescriptionYpMxCxTy(chargeFeeParamsVo);
+            
+            if (refundDetailList == null || refundDetailList.isEmpty()) {
+                resultMap.put("code", -1);
+                resultMap.put("message", "未找到退药明细数据");
+                return resultMap;
+            }
+            
+            log.info("获取到退药明细数据,共{}条", refundDetailList.size());
+            
+            // 2. 遍历每个药品,获取追溯码并调用医保接口
+            int successCount = 0;
+            int failCount = 0;
+            StringBuilder errorMsg = new StringBuilder();
+            
+            for (Map<String, Object> item : refundDetailList) {
+                try {
+                    // 2.1 构建追溯码查询参数
+                    MzDrugTracCodg tracCodgQuery = new MzDrugTracCodg();
+                    tracCodgQuery.setPatientId((String) item.get("patientId"));
+                    tracCodgQuery.setTimes((Integer) item.get("times"));
+                    tracCodgQuery.setReceiptNo((Integer) item.get("receiptNo"));
+                    tracCodgQuery.setOrderNo((Integer) item.get("orderNo"));
+                    tracCodgQuery.setChargeItemCode((String) item.get("chargeItemCode"));
+                    tracCodgQuery.setSerial((String) item.get("serial"));
+                    tracCodgQuery.setItemNo((Integer) item.get("itemNo"));
+                    
+                    // 2.2 获取追溯码数据
+                    List<MzDrugTracCodg> tracCodgList = mzDrugTracCodgService.getMzDrugTracCodgData(tracCodgQuery);
+                    
+                    if (tracCodgList == null || tracCodgList.isEmpty()) {
+                        log.warn("药品{}未找到追溯码数据", item.get("chargeItemCode"));
+                        continue;
+                    }
+                    
+                    // 2.3 构建医保接口参数
+                    Map<String, Object> ybParams = buildYbParamsForCancelRefund(item, params);
+                    
+                    // 2.4 记录医保接口传参日志
+                    log.info("医保接口参数: {}", ybParams);
+                    
+                    // 2.5 构建 SelinfoSoldTotal 对象
+                    SelinfoSoldTotal selinfoSoldTotal = new SelinfoSoldTotal();
+                    
+                    // 构建 SelinfoSold 对象
+                    SelinfoSold selinfoSold = new SelinfoSold();
+                    selinfoSold.setPatientId((String) item.get("patientId"));
+                    selinfoSold.setTimes((Integer) item.get("times"));
+                    selinfoSold.setReceiptNo((Integer) item.get("receiptNo"));
+                    selinfoSold.setOrderNo((Integer) item.get("orderNo"));
+                    selinfoSold.setChargeItemCode((String) item.get("chargeItemCode"));
+                    selinfoSold.setRealNo((Integer) item.get("realNo"));
+                    selinfoSold.setMedListCodg((String) item.get("nationalCode"));
+                    selinfoSold.setPrscDrName(getCurrentDoctorName(params));
+                    selinfoSold.setPharName(getCurrentUserName(params));
+                    selinfoSold.setPharPracCertNo(getPharPracCertNo(params));
+                    selinfoSold.setSelRetnOpterName(getCurrentUserName(params));
+                    selinfoSold.setMdtrtSetlType(item.get("mdtrtSetlType") != null ? (String) item.get("mdtrtSetlType") : "2");
+                    selinfoSold.setRxFlag(item.get("rxFlag") != null ? (String) item.get("rxFlag") : "0");
+                    selinfoSold.setTrdnFlag(item.get("clFlag") != null ? (String) item.get("clFlag") : "0");
+                    selinfoSold.setPsnCertType(item.get("psnCertType") != null ? (String) item.get("psnCertType") : "01");
+                    selinfoSold.setCertno(item.get("certno") != null ? (String) item.get("certno") : "");
+                    selinfoSold.setPsnName(item.get("psnName") != null ? (String) item.get("psnName") : "");
+                    
+                    selinfoSoldTotal.setSelinfoSold(selinfoSold);
+                    
+                    // 构建追溯码列表
+                    List<DrugTracCodg> drugTracCodgList = new ArrayList<>();
+                    for (MzDrugTracCodg tracCodg : tracCodgList) {
+                        DrugTracCodg drugTracCodg = new DrugTracCodg();
+                        drugTracCodg.setDrugTracCodg(tracCodg.getDrugTracCodg());
+                        drugTracCodgList.add(drugTracCodg);
+                    }
+                    selinfoSoldTotal.setDrugtracinfo(drugTracCodgList);
+                    
+                    log.info("最终调用医保接口参数: {}", selinfoSoldTotal);
+                    
+                    // 2.6 调用医保销售接口
+                    ResultVo ybResult = ybController.saleGoodsItem(selinfoSoldTotal);
+                    
+                    if (ybResult != null && ybResult.getCode() == 0) {
+                        successCount++;
+                        log.info("药品{}医保接口调用成功", item.get("chargeItemCode"));
+                    } else {
+                        failCount++;
+                        String errorMessage = ybResult != null ? ybResult.getMessage() : "医保接口调用失败";
+                        errorMsg.append("药品").append(item.get("chargeItemCode"))
+                                .append("医保接口调用失败:").append(errorMessage).append("; ");
+                        log.error("药品{}医保接口调用失败:{}", item.get("chargeItemCode"), errorMessage);
+                    }
+                    
+                } catch (Exception e) {
+                    failCount++;
+                    errorMsg.append("药品").append(item.get("chargeItemCode"))
+                            .append("处理异常:").append(e.getMessage()).append("; ");
+                    log.error("药品{}处理异常", item.get("chargeItemCode"), e);
+                }
+            }
+            
+            // 3. 返回结果
+            if (failCount == 0) {
+                resultMap.put("code", 0);
+                resultMap.put("message", "撤销退药医保接口调用成功,共处理" + successCount + "个药品");
+                resultMap.put("data", null);
+            } else {
+                resultMap.put("code", -1);
+                resultMap.put("message", "撤销退药医保接口调用部分失败,成功" + successCount + "个,失败" + failCount + "个。错误信息:" + errorMsg.toString());
+                resultMap.put("data", null);
+            }
+            
+            return resultMap;
+            
+        } catch (Exception e) {
+            log.error("撤销退药医保接口调用异常", e);
+            resultMap.put("code", -1);
+            resultMap.put("message", "撤销退药医保接口调用异常:" + e.getMessage());
+            resultMap.put("data", null);
+            return resultMap;
+        }
+    }
+    
+    /**
+     * 构建撤销退药医保接口参数
+     */
+    private Map<String, Object> buildYbParamsForCancelRefund(Map<String, Object> item, Map<String, Object> params) {
+        Map<String, Object> ybParams = new HashMap<>();
+        
+        // 关联字段
+        ybParams.put("patientId", item.get("patientId"));
+        ybParams.put("times", item.get("times"));
+        ybParams.put("receiptNo", item.get("receiptNo"));
+        ybParams.put("orderNo", item.get("orderNo"));
+        ybParams.put("chargeItemCode", item.get("chargeItemCode"));
+        ybParams.put("realNo", item.get("realNo"));
+        
+        // 医疗目录编码(医保编码)
+        ybParams.put("medListCodg", item.get("nationalCode"));
+        
+        // 开方医师姓名(从处方明细中获取,如果没有则使用当前用户)
+        String doctorName = getCurrentDoctorName(params);
+        ybParams.put("prscDrName", doctorName);
+        
+        // 药师姓名(使用前端传递的药师姓名)
+        String pharName = getCurrentUserName(params);
+        ybParams.put("pharName", pharName);
+        
+        // 药师执业资格证号
+        String pharPracCertNo = getPharPracCertNo(params);
+        ybParams.put("pharPracCertNo", pharPracCertNo);
+        
+        // 销售/退货经办人姓名
+        ybParams.put("selRetnOpterName", pharName);
+        
+        // 就诊结算类型(1-医保结算 2-自费结算)
+        ybParams.put("mdtrtSetlType", item.get("mdtrtSetlType") != null ? item.get("mdtrtSetlType") : "2");
+        
+        // 处方药标志
+        ybParams.put("rxFlag", item.get("rxFlag") != null ? item.get("rxFlag") : "0");
+        
+        // 拆零标志(0-否;1-是)
+        ybParams.put("trdnFlag", item.get("clFlag") != null ? item.get("clFlag") : "0");
+        
+        // 患者相关参数
+        ybParams.put("psnCertType", item.get("psnCertType") != null ? item.get("psnCertType") : "01");
+        ybParams.put("certno", item.get("certno") != null ? item.get("certno") : "");
+        ybParams.put("psnName", item.get("psnName") != null ? item.get("psnName") : "");
+        
+        return ybParams;
+    }
+    
+    /**
+     * 获取当前医生姓名
+     */
+    private String getCurrentDoctorName(Map<String, Object> params) {
+        // 从前端参数中获取医生姓名
+        String doctorName = (String) params.get("doctorName");
+        if (doctorName != null && !doctorName.trim().isEmpty()) {
+            return doctorName;
+        }
+        
+        // 如果前端没有传递医生姓名,则报错
+        throw new RuntimeException("前端参数中未找到医生姓名(doctorName),请检查参数传递");
+    }
+    
+    /**
+     * 获取当前用户姓名
+     */
+    private String getCurrentUserName(Map<String, Object> params) {
+        // 从前端参数中获取药师姓名
+        String pharName = (String) params.get("pharName");
+        if (pharName != null && !pharName.trim().isEmpty()) {
+            return pharName;
+        }
+        
+        // 如果前端没有传递,则从当前用户信息获取
+        try {
+            User currentUser = TokenUtil.getUser();
+            if (currentUser != null) {
+                return currentUser.getUserName();
+            }
+        } catch (Exception e) {
+            log.warn("获取当前用户信息失败", e);
+        }
+        return "药师姓名"; // 默认值
+    }
+    
+    /**
+     * 获取药师执业资格证号
+     */
+    private String getPharPracCertNo(Map<String, Object> params) {
+        // 从前端参数中获取药师执业资格证号
+        String pharPracCertNo = (String) params.get("pharPracCertNo");
+        if (pharPracCertNo != null && !pharPracCertNo.trim().isEmpty()) {
+            return pharPracCertNo;
+        }
+        
+        // 如果前端没有传递,则从当前用户信息获取
+        try {
+            User currentUser = TokenUtil.getUser();
+            if (currentUser != null) {
+                // 根据当前用户编码查询员工信息
+                Employee employee = employeeService.queryByUserCode(currentUser.getUserCode());
+                if (employee != null) {
+                    // 获取药师执业资格证号:优先取执业证编码,如果为空则取医保赋码
+                    if (StringUtils.isNotBlank(employee.getPracticeCertificate())) {
+                        return employee.getPracticeCertificate();
+                    } else if (StringUtils.isNotBlank(employee.getYbCode())) {
+                        return employee.getYbCode();
+                    }
+                }
+            }
+        } catch (Exception e) {
+            log.warn("获取当前用户信息失败", e);
+        }
+        return "药师执业资格证号"; // 默认值
+    }
 }

+ 75 - 0
src/main/java/cn/hnthyy/thmz/mapper/his/mz/MzPharmacyMapper.java

@@ -313,6 +313,81 @@ public interface MzPharmacyMapper {
             "</script>"})
     List<Map<String, Object>> selectPrescriptionYpMx(ChargeFeeParamsVo chargeFeeParamsVo);
 
+
+    /**
+     * 查询处方药品明细 撤销退药使用
+     *
+     * @param chargeFeeParamsVo
+     * @return
+     */
+    @Select({"<script>" +
+            "SELECT DISTINCT yp_mz_fytj.serial_no,   " +
+            "         yp_mz_fytj.order_no,   " +
+            "         rtrim(yp_mz_fytj.patient_id)patient_id,   " +
+            "         yp_mz_fytj.times,   " +
+            "         yp_mz_fytj.receipt_no,   " +
+            "         drugname=c.name+'('+isnull(d.abbr_name,isnull(d.name,''))+')',   " +
+            "         specification=c.specification,   " +
+            "         quantity= case when isnull(cy_fy, 0) > 0 then yp_mz_fytj.quantity * cy_fy else yp_mz_fytj.quantity  end,   " +
+            "         yp_mz_fytj.unit_price,   " +
+            "         yp_mz_fytj.item_no,   " +
+            "         yp_mz_fytj.drug_flag,   " +
+            "         yp_mz_fytj.charge_item_code,   " +
+            "         yp_mz_fytj.serial,   " +
+            "         yp_mz_fytj.confirm_time,   " +
+            "         yp_mz_fytj.group_no,   " +
+            "         yp_mz_fytj.bill_item_code,   " +
+            "         yp_mz_fytj.pay_mark,   " +
+            "         yp_mz_fytj.charge_item_type,   " +
+            "         yp_mz_fytj.name,   " +
+            "         yp_mz_fytj.charge_date,   " +
+            "         yp_mz_fytj.cy_fy,   " +
+            "         yp_mz_fytj.specification,   " +
+            "         yp_mz_fytj.drugname,   " +
+            "         yp_mz_fytj.doctor_name,   " +
+            "         yp_mz_fytj.doctor_id,   " +
+            "         warn_dept=yp_mz_fytj.warn_dept,   " +
+            "         yp_mz_fytj.country_flag,   " +
+            "         yp_mz_fytj.confirm_flag,   " +
+            "         yp_mz_fytj.self_flag,   " +
+            "         yp_mz_fytj.response_type,   " +
+            "         yp_mz_fytj.warn_dept  ," +
+            "         yp_mz_fytj.refund_medicine_remark  ," +
+            "         real_no=yp_mz_fytj.real_no," +
+            "         win_no = yp_mz_fytj.win_no, " +
+            "         -- 医保接口需要的患者信息 " +
+            "         pm.certificate_type as psnCertType, " +
+            "         pm.social_no as certno, " +
+            "         pm.name as psnName, " +
+            "         -- 医保接口需要的药品信息 " +
+            "         c.national_code as nationalCode, " +
+            "         c.cl_flag as clFlag, " +
+            "         c.rx_flag as rxFlag, " +
+            "         -- 医保接口需要的收费明细信息 " +
+            "         mcd.real_no as realNo " +
+            "    FROM yp_mz_fytj WITH(NOLOCK) " +
+            "    JOIN yp_zd_dict c WITH(NOLOCK) ON yp_mz_fytj.charge_item_code = c.code AND yp_mz_fytj.serial = c.serial " +
+            "    LEFT JOIN yp_zd_manufactory d WITH(NOLOCK) ON c.manu_code = d.code " +
+            "    -- 关联患者信息表 " +
+            "    LEFT JOIN mz_patient_mi pm WITH(NOLOCK) ON yp_mz_fytj.patient_id = pm.patient_id " +
+            "    -- 关联收费明细表 " +
+            "    LEFT JOIN mz_charge_detail mcd WITH(NOLOCK) ON yp_mz_fytj.patient_id = mcd.patient_id " +
+            "        AND yp_mz_fytj.times = mcd.times " +
+            "        AND yp_mz_fytj.receipt_no = mcd.receipt_no " +
+            "        AND yp_mz_fytj.order_no = mcd.order_no " +
+            "        AND yp_mz_fytj.charge_item_code = mcd.charge_item_code " +
+            "        AND yp_mz_fytj.serial = mcd.serial " +
+            "        AND yp_mz_fytj.item_no = mcd.item_no " +
+            "   WHERE yp_mz_fytj.patient_id = #{patientId,jdbcType=CHAR}  AND  " +
+            "          yp_mz_fytj.times = #{times,jdbcType=INTEGER}  AND  " +
+            "          yp_mz_fytj.receipt_no = #{receiptNo,jdbcType=CHAR}  AND  " +
+            "          yp_mz_fytj.order_no = #{orderNo,jdbcType=CHAR}  AND  " +
+            "         yp_mz_fytj.group_no_out = #{groupNoOut,jdbcType=CHAR} AND  " +
+            "         yp_mz_fytj.confirm_flag = #{confirmFlag,jdbcType=CHAR}   and " +
+            "         yp_mz_fytj.serial_no <![CDATA[<]]> 0 " +
+            "ORDER BY yp_mz_fytj.item_no ASC ",
+            "</script>"})
+    List<Map<String, Object>> selectPrescriptionYpMxCxTy(ChargeFeeParamsVo chargeFeeParamsVo);
     /**
      * 更新发药统计状态
      *

+ 7 - 0
src/main/java/cn/hnthyy/thmz/service/his/mz/MzPharmacyService.java

@@ -56,6 +56,13 @@ public interface MzPharmacyService {
      */
     List<Map<String,Object>> getPrescriptionYpMx(ChargeFeeParamsVo chargeFeeParamsVo);
 
+    /**
+     * 查询处方药品明细 撤销退药
+     * @param chargeFeeParamsVo
+     * @return
+     */
+    List<Map<String,Object>> getPrescriptionYpMxCxTy(ChargeFeeParamsVo chargeFeeParamsVo);
+
     /**
      * 退药处理
      * @param mzRefundMedicineVos

+ 5 - 0
src/main/java/cn/hnthyy/thmz/service/impl/his/mz/MzPharmacyServiceImpl.java

@@ -115,6 +115,11 @@ public class MzPharmacyServiceImpl implements MzPharmacyService {
         return mzPharmacyMapper.selectPrescriptionYpMx(chargeFeeParamsVo);
     }
 
+    @Override
+    public List<Map<String, Object>> getPrescriptionYpMxCxTy(ChargeFeeParamsVo chargeFeeParamsVo) {
+        return mzPharmacyMapper.selectPrescriptionYpMxCxTy(chargeFeeParamsVo);
+    }
+
     @Override
     @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor = Exception.class)
     public Map<String, Object> refundMedicineProcessing(List<MzRefundMedicineVo> mzRefundMedicineVos, String userIdCode) {

+ 30 - 172
src/main/resources/static/js/mz/west_pharmacy_send.js

@@ -1937,6 +1937,7 @@ function saveRefundMedicine() {
  */
 function saveCancelRefundMedicine() {
     var row = $("#tb_table").bootstrapTable('getSelections');
+    console.log("row11111111111111111111111111111111",row)
     if (row.length != 1) {
         return errorMesageSimaple('请选择一条处方数据');
     }
@@ -1971,7 +1972,7 @@ function saveCancelRefundMedicine() {
         let orderNo = row[0].orderNo;
         let realNo = row[0].realNo;
         let name = row[0].name;
-        
+        let doctorName = row[0].doctorName; 
         console.log('撤销退药医保接口参数:', {
             patientId: patientId,
             times: times,
@@ -1982,7 +1983,7 @@ function saveCancelRefundMedicine() {
         });
         
         // 调用撤销退药医保接口
-        callYbSaleGoodsItemForCancelRefund(realNo, orderNo, receiptNo, times, patientId, name);
+        callYbSaleGoodsItemForCancelRefund(realNo, orderNo, receiptNo, times, patientId, name, doctorName);
         
         initTbTable();
     },err =>{
@@ -3688,195 +3689,52 @@ function validateTracCodgQuantity(realNo, orderNo, receiptNo, times, patientId,
  * @param patientId 病人ID
  * @param name 病人姓名
  */
-function callYbSaleGoodsItemForCancelRefund(realNo, orderNo, receiptNo, times, patientId, name) {
-    // 获取撤销退药后的处方明细数据 - 从已恢复的收费明细表获取
-    let tableData = $("#tb_table_right").bootstrapTable('getData');
-    
-    if (!tableData || tableData.length === 0) {
-        console.log('没有处方明细数据,跳过撤销退药医保接口调用');
-        return;
-    }
+function callYbSaleGoodsItemForCancelRefund(realNo, orderNo, receiptNo, times, patientId, name, doctorName) {
+    console.log('=== 开始调用撤销退药医保接口 ===');
     
     // 获取当前用户信息(药师信息)
     let currentUserName = localStorage.getItem('userName') || '';
-    let currentUserId = localStorage.getItem('userID') || '';
-    
-    // 获取当前时间
-    let currentTime = new Date();
-    let selRetnTime = currentTime.getFullYear() + '-' + 
-                     String(currentTime.getMonth() + 1).padStart(2, '0') + '-' + 
-                     String(currentTime.getDate()).padStart(2, '0') + ' ' +
-                     String(currentTime.getHours()).padStart(2, '0') + ':' + 
-                     String(currentTime.getMinutes()).padStart(2, '0') + ':' + 
-                     String(currentTime.getSeconds()).padStart(2, '0');
+    let pharPracCertNo = localStorage.getItem('pharPracCertNo') || '';
     
-    // 为每个药品调用一次医保接口
-    for (let i = 0; i < tableData.length; i++) {
-        let item = tableData[i];
-        
-        // 构建关联字段组合(用于关联撤销退药记录)
-        let currentPatientId = item.patientId || patientId;
-        let currentTimes = item.times || times;
-        let currentReceiptNo = item.receiptNo || receiptNo;
-        let currentOrderNo = item.orderNo || orderNo;
-        let chargeItemCode = item.chargeItemCode;
-        let currentRealNo = item.realNo || realNo;
-        
-        console.log('撤销退药关联键:', {patientId: currentPatientId, times: currentTimes, receiptNo: currentReceiptNo, orderNo: currentOrderNo, chargeItemCode, realNo: currentRealNo});
-        
-        // 参数验证
-        // 从处方明细数据中获取开方医师姓名
-        let doctorName = item.doctorName || item.employeeName || '';
-        if (!doctorName) {
-            console.warn('开方医师姓名为空,使用默认值');
-            doctorName = '未知医师';
-        }
-        
-        if (!currentUserName) {
-            console.warn('药师姓名为空,使用默认值');
-            currentUserName = '未知药师';
-        }
-        
-        // 构建医保接口参数 - 与发药时相同的参数结构
-        let ybData = {
-            // 关联字段 - 直接传递到医保接口
-            patientId: currentPatientId,
-            times: currentTimes,
-            receiptNo: currentReceiptNo,
-            orderNo: currentOrderNo,
-            chargeItemCode: chargeItemCode,
-            realNo: currentRealNo,
-            
-            // 医疗目录编码(医保编码)
-            medListCodg: item.nationalCode,
-            
-            // 开方医师姓名
-            prscDrName: doctorName,
-            
-            // 药师姓名
-            pharName: currentUserName,
-            
-            // 药师执业资格证号(取当前操作者的药师执业资格证号)
-            pharPracCertNo: localStorage.getItem('pharPracCertNo') || '',
-            
-            // 销售/退货经办人姓名
-            selRetnOpterName: currentUserName,
-            
-            // 就诊结算类型(1-医保结算 2-自费结算)
-            mdtrtSetlType: item.mdtrtSetlType || '2',
-            
-            // 处方药标志
-            rxFlag: item.rxFlag || '0',
-            
-            // 拆零标志(0-否;1-是)
-            trdnFlag: item.clFlag || '0',
-            
-            // 患者相关参数(医保接口需要)
-            // 人员证件类型
-            psnCertType: item.psnCertType || '01',
-            // 证件号码
-            certno: item.certno || '',
-            // 人员姓名
-            psnName: item.psnName || item.name || name || '',
-            
-        };
-        
-        // 追溯码信息 - 从已恢复的追溯码表获取
-        let drugtracinfo = [];
-        
-        // 主动获取追溯码信息(撤销退药后,追溯码已恢复到 mz_drug_trac_codg 表)
-        let tracCodgParams = {
-            patientId: currentPatientId,
-            times: currentTimes,
-            receiptNo: currentReceiptNo,
-            orderNo: currentOrderNo,
-            chargeItemCode: chargeItemCode,
-            serial: item.serial,
-            itemNo: item.itemNo,
-            groupNo: item.groupNo || groupNo
-        };
-        
-        // 调用追溯码查询接口(异步方式)
-        // 注意:撤销退药后,追溯码已恢复到 mz_drug_trac_codg 表
-        $.ajax({
-            type: "POST",
-            url: '/thmz/getMzDrugTracCodgData',
-            contentType: "application/json;charset=UTF-8",
-            dataType: "json",
-            headers: {
-                'Accept': 'application/json',
-                'Authorization': 'Bearer ' + localStorage.getItem("token")
-            },
-            data: JSON.stringify(tracCodgParams),
-            success: function (tracRes) {
-                console.log('撤销退药追溯码查询结果:', tracRes);
-                if (tracRes.code === 0 && tracRes.data && tracRes.data.length > 0) {
-                    // 将追溯码添加到医保接口参数中
-                    for (let k = 0; k < tracRes.data.length; k++) {
-                        let tracItem = tracRes.data[k];
-                        if (tracItem.drugTracCodg && tracItem.drugTracCodg !== '') {
-                            drugtracinfo.push({
-                                drugTracCodg: tracItem.drugTracCodg
-                            });
-                        }
-                    }
-                    console.log('撤销退药成功获取追溯码:', drugtracinfo);
-                } else {
-                    console.log('撤销退药未找到追溯码信息');
-                }
-                
-                // 追溯码查询完成后,调用医保接口
-                callYbSaleGoodsItemWithDataForCancelRefund(ybData, item, drugtracinfo);
-            },
-            error: function (xhr, status, error) {
-                console.error('撤销退药追溯码查询失败:', error);
-                // 即使追溯码查询失败,也要调用医保接口
-                callYbSaleGoodsItemWithDataForCancelRefund(ybData, item, drugtracinfo);
-            }
-        });
-    }
-}
-
-/**
- * 调用撤销退药医保接口(带追溯码数据)
- * @param ybData 医保接口参数
- * @param item 药品信息
- * @param drugtracinfo 追溯码信息
- */
-function callYbSaleGoodsItemWithDataForCancelRefund(ybData, item, drugtracinfo) {
-    // 如果没有追溯码,添加空数组(保持数据结构一致)
-    if (drugtracinfo.length === 0) {
-        drugtracinfo = [];
-    }
+    // 构建调用新接口的参数
+    let params = {
+        patientId: patientId,
+        times: times,
+        receiptNo: receiptNo,
+        orderNo: orderNo,
+        groupNoOut: groupNo,
+        // 添加医生姓名、药师姓名和药师执业资格证号
+        doctorName: doctorName, // 医生姓名,从处方明细中获取
+        pharName: currentUserName, // 药师姓名
+        pharPracCertNo: pharPracCertNo // 药师执业资格证号
+    };
     
-    console.log('调用撤销退药医保接口,药品:', item.drugname, '参数:', ybData);
+    console.log('撤销退药医保接口参数:', params);
     
-    let param = {
-        selinfoSold: ybData,
-        drugtracinfo: drugtracinfo
-    }
-    console.log("调用撤销退药医保接口param11111111111111111111111111111111111",param)
-    // 调用医保接口
+    // 调用新的撤销退药医保接口
     $.ajax({
         type: "POST",
-        url: '/thmz/Yb/saleGoodsItem',
+        url: '/thmz/cancelRefundWithYb',
         contentType: "application/json;charset=UTF-8",
         dataType: "json",
         headers: {
             'Accept': 'application/json',
             'Authorization': 'Bearer ' + localStorage.getItem("token")
         },
-        data: JSON.stringify(param),
+        data: JSON.stringify(params),
         success: function (res) {
-            console.log('撤销退药医保接口调用成功:', res);
-            if (res.code !== 0) {
+            console.log('撤销退药医保接口调用结果:', res);
+            if (res.code === 0) {
+                successMesage(res);
+                console.log('撤销退药医保接口调用成功');
+            } else {
+                errorMesage(res);
                 console.error('撤销退药医保接口调用失败:', res.message);
-                // 医保接口失败不影响撤销退药流程,只记录日志
             }
         },
         error: function (xhr, status, error) {
-            console.error('撤销退药医保接口调用失败:', error);
-            // 医保接口失败不影响撤销退药流程,只记录日志
+            console.error('撤销退药医保接口调用异常:', error);
+            errorMesage({message: '撤销退药医保接口调用异常:' + error});
         }
     });
 }