You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
272 lines
11 KiB
272 lines
11 KiB
2 years ago
|
package com.ynxbd.common.dao.his;
|
||
|
|
||
|
import com.alibaba.fastjson.JSONArray;
|
||
|
import com.ynxbd.common.bean.HisRecipe;
|
||
|
import com.ynxbd.common.bean.enums.MerchantEnum;
|
||
|
import com.ynxbd.common.bean.pay.Recipe;
|
||
|
import com.ynxbd.common.bean.pay.Register;
|
||
|
import com.ynxbd.common.helper.common.CodeHelper;
|
||
|
import com.ynxbd.common.helper.common.DateHelper;
|
||
|
import com.ynxbd.common.helper.common.JsonHelper;
|
||
|
import com.ynxbd.common.helper.his.HisEnum;
|
||
|
import com.ynxbd.common.helper.his.HisHelper;
|
||
|
import com.ynxbd.common.result.JsonResult;
|
||
|
import com.ynxbd.common.result.Result;
|
||
|
import com.ynxbd.common.result.ResultEnum;
|
||
|
import com.ynxbd.wx.wxfactory.bean.MedicalInfo;
|
||
|
import org.apache.commons.lang3.ObjectUtils;
|
||
|
|
||
|
import java.math.BigDecimal;
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.List;
|
||
|
|
||
|
public class HisMedicalDao {
|
||
|
|
||
|
/**
|
||
|
* [医保处方]上传明细(请求地址不通)
|
||
|
*
|
||
|
* @param payAuthNo 授权码
|
||
|
* @param patientId 患者ID
|
||
|
* @param cardNo 卡号
|
||
|
* @param treatNum 治疗号
|
||
|
* @param recipeJson 处方json
|
||
|
* @param totalFee 总金额
|
||
|
*/
|
||
|
public static JsonResult recipeMdUploadFeeDetails(String payAuthNo, String cardNo, String openid, String patientId, String treatNum, String recipeJson, BigDecimal totalFee) {
|
||
|
List<Recipe> recipeList = JsonHelper.parseArray(recipeJson, Recipe.class);
|
||
|
if (recipeList == null || recipeList.size() == 0) {
|
||
|
return HisHelper.createErrorResult("处方数量为 0 或 数据转换失败");
|
||
|
}
|
||
|
|
||
|
StringBuilder recipeIdsXml = new StringBuilder();
|
||
|
for (Recipe item : recipeList) {
|
||
|
recipeIdsXml.append("<Id>").append(item.getRecipeId()).append("</Id>");
|
||
|
}
|
||
|
|
||
|
return HisHelper.getMdJsonResult(HisEnum.AP_Pay_Invoice, params -> {
|
||
|
params.put("PatientID", patientId);
|
||
|
params.put("MZNum", treatNum);
|
||
|
params.put("Recipe", recipeIdsXml.toString());
|
||
|
params.put("PayMoney", totalFee);
|
||
|
params.put("PayDate", DateHelper.getCurDate());
|
||
|
params.put("PayTime", DateHelper.getCurTime());
|
||
|
params.put("TransNo", CodeHelper.get32UUID());
|
||
|
params.put("PayWay", "4");
|
||
|
// 医保-----------------------------------
|
||
|
params.put("PayAuthNo", payAuthNo);
|
||
|
params.put("PersonID", cardNo);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* [医保挂号]分时段挂号
|
||
|
*/
|
||
|
public static JsonResult regTimeMdUploadFeeDetails(Register reg, String payAuthNo, String cardNo, MerchantEnum merchantEnum, Boolean isTime) {
|
||
|
|
||
|
if (isTime){
|
||
|
return HisHelper.getMdJsonResult(HisEnum.AP_Regist_New, params -> {
|
||
|
params.put("PatientID", reg.getPatientId());
|
||
|
params.put("PayMoney", reg.getPayMoney());
|
||
|
|
||
|
params.put("DeptCode", reg.getDeptCode());
|
||
|
params.put("DoctCode", reg.getDoctCode());
|
||
|
|
||
|
params.put("SourceId", reg.getSourceId());
|
||
|
params.put("TimeInterval", reg.getTid());
|
||
|
params.put("BegTime", reg.getBegTime());
|
||
|
params.put("EndTime", reg.getEndTime());
|
||
|
params.put("RegistCode", reg.getRegCode());
|
||
|
params.put("RegistDate", reg.getRegDate());
|
||
|
|
||
|
|
||
|
params.put("PayDate", DateHelper.getCurDate());
|
||
|
params.put("PayTime", DateHelper.getCurTime());
|
||
|
params.put("TransNo", CodeHelper.get32UUID());
|
||
|
params.put("PayWay", merchantEnum.HIS_PAY_WAY);
|
||
|
if (!ObjectUtils.isEmpty(reg.getSubDeptCode())) {
|
||
|
params.put("DeptCode_YZKCode", reg.getSubDeptCode()); // 亚专科code
|
||
|
}
|
||
|
|
||
|
// 医保-----------------------------------
|
||
|
params.put("PayAuthNo", payAuthNo);
|
||
|
params.put("PersonID", cardNo);
|
||
|
});
|
||
|
}
|
||
|
// 非分时段挂号 医保支付
|
||
|
return HisHelper.getMdJsonResult(HisEnum.AP_Regist,params-> {
|
||
|
params.put("PatientID", reg.getPatientId());
|
||
|
params.put("PayMoney", reg.getPayMoney());
|
||
|
params.put("DeptCode", reg.getDeptCode());
|
||
|
params.put("DoctCode", reg.getDoctCode());
|
||
|
params.put("ClinicCode",reg.getClinicCode());
|
||
|
params.put("TID",reg.getTid());
|
||
|
params.put("RegFee",reg.getRegFee());
|
||
|
params.put("ClinicFee",reg.getClinicFee());
|
||
|
params.put("PayMoney", reg.getPayMoney());
|
||
|
params.put("PayDate", DateHelper.getCurDate());
|
||
|
params.put("PayTime", DateHelper.getCurTime());
|
||
|
params.put("TransNo", CodeHelper.get32UUID());
|
||
|
params.put("PayDeviceID",reg.getPayDeviceId());
|
||
|
params.put("BankTransNo",reg.getBankTransNo());
|
||
|
params.put("PayWay", merchantEnum.HIS_PAY_WAY);
|
||
|
if (!ObjectUtils.isEmpty(reg.getSubDeptCode())) {
|
||
|
params.put("DeptCode_YZKCode", reg.getSubDeptCode()); // 亚专科code
|
||
|
}
|
||
|
|
||
|
// 医保-----------------------------------
|
||
|
params.put("PayAuthNo", payAuthNo);
|
||
|
params.put("PersonID", cardNo);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* HIS医保结算
|
||
|
*
|
||
|
* @param mdUserId 医保用户ID
|
||
|
* @param cashFee 现金
|
||
|
* @param payDate 支付日期
|
||
|
* @param payTime 支付实际
|
||
|
* @param transNo HIS交易流水号
|
||
|
* @param bankTransNo HIS流水号
|
||
|
*/
|
||
|
public static JsonResult regMdPay(String mdUserId, String payDate, String payTime, String transNo, String bankTransNo, BigDecimal cashFee) {
|
||
|
return HisHelper.getMdJsonResult(HisEnum.Medical_PAY, params -> {
|
||
|
params.put("UserID_YBZF", mdUserId);
|
||
|
params.put("PayMoney", cashFee);
|
||
|
params.put("PayDate", payDate);
|
||
|
params.put("PayTime", payTime);
|
||
|
params.put("TransNo", transNo);
|
||
|
params.put("BankTransNo", bankTransNo);
|
||
|
params.put("PayWay", "4");
|
||
|
params.put("PayDeviceID", "mobile");
|
||
|
});
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* [医保]HIS调用支付下单
|
||
|
*
|
||
|
* @param mdInfo 医保下单对象
|
||
|
*/
|
||
|
public static JsonResult mdPlaceOrder(MedicalInfo mdInfo) {
|
||
|
return HisHelper.getMdJsonResult(HisEnum.Medical_PayOrders, params -> {
|
||
|
// 授权码
|
||
|
params.put("PayAuthNo", mdInfo.getPayAuthNo());
|
||
|
// 授权token
|
||
|
params.put("PayToken", mdInfo.getPayToken());
|
||
|
// 订单id
|
||
|
params.put("PayOrdId", mdInfo.getPayOrdId());
|
||
|
params.put("MdtrtId", mdInfo.getMdTrtId());
|
||
|
params.put("ChrgBchno", mdInfo.getChrgBchno());
|
||
|
params.put("UserID_YBZF", mdInfo.getMdUserId());
|
||
|
});
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 医保退费(需先退医保,才能再退现金)
|
||
|
*
|
||
|
* @param payAuthNo 用户授权码
|
||
|
* @param fpNum 发票号(上传费用明细返回的 chrgBchno ,把第一位“M” 过滤后传入)
|
||
|
*/
|
||
|
// * @param refundType 退款类型(ALL:全部,CASH:只退现金 HI:只退医保)
|
||
|
public static JsonResult mdRefund(String payAuthNo, String fpNum, String bankTransNo, String refundTradeNo, BigDecimal cashFee) {
|
||
|
return HisHelper.getMdJsonResult(HisEnum.Medical_Refund, params -> {
|
||
|
params.put("PayAuthNo", payAuthNo); // AUTH530100202206291132200000008
|
||
|
params.put("FPNum", fpNum);
|
||
|
params.put("PayWay", "4");
|
||
|
params.put("BankTransNo", bankTransNo);
|
||
|
params.put("TransNo", refundTradeNo);
|
||
|
params.put("PayDeviceID", "mobile");
|
||
|
params.put("PayMoney", cashFee);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* HIS医保结算
|
||
|
*
|
||
|
* @param mdUserId 医保用户ID
|
||
|
* @param cashFee 现金
|
||
|
* @param payDate 支付日期
|
||
|
* @param payTime 支付实际
|
||
|
* @param transNo HIS交易流水号
|
||
|
* @param bankTransNo HIS流水号
|
||
|
*/
|
||
|
public static JsonResult mdPay(String mdUserId, String payDate, String payTime, String transNo, String bankTransNo, BigDecimal cashFee) {
|
||
|
return HisHelper.getMdJsonResult(HisEnum.Medical_PAY, params -> {
|
||
|
params.put("UserID_YBZF", mdUserId);
|
||
|
params.put("PayMoney", cashFee);
|
||
|
params.put("PayDate", payDate);
|
||
|
params.put("PayTime", payTime);
|
||
|
params.put("TransNo", transNo);
|
||
|
params.put("BankTransNo", bankTransNo);
|
||
|
params.put("PayWay", "4");
|
||
|
params.put("PayDeviceID", "mobile");
|
||
|
});
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* [医保]查询医保订单结算信息
|
||
|
*
|
||
|
* @param mdUserId 医保用户ID
|
||
|
* <p>
|
||
|
* StatusCode值域:
|
||
|
* 0 : 已保存
|
||
|
* 1 : 预结算完成
|
||
|
* 2 : 结算中
|
||
|
* 3 : 自费完成
|
||
|
* 4 : 医保支付完成
|
||
|
* 5 : 院内结算完成
|
||
|
* 6 : 结算完成
|
||
|
* 7 : 已退款
|
||
|
* 8 : 已医保全部退款
|
||
|
* 9 : 仅自费全部退款
|
||
|
* 10 : 仅自费部分退款
|
||
|
* 11 : 医保全部退自费部分退款
|
||
|
* 12 : 已撤销
|
||
|
* 13 : 医保已撤销
|
||
|
* 14 : 异常
|
||
|
* 15 : 结算失败
|
||
|
* -1 : 状态未知
|
||
|
*/
|
||
|
public static JsonResult getMedicalAccounts(String mdUserId) {
|
||
|
return HisHelper.getMdJsonResult(HisEnum.Medical_QueryOrderStatus, params -> {
|
||
|
params.put("UserID_YBZF", mdUserId);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* HIS医保结算信息查询
|
||
|
*
|
||
|
* @param queryNumType 类型
|
||
|
* @param queryNumber 查询号码
|
||
|
* @param begDate 开始日期
|
||
|
* @param endDate 结束日期
|
||
|
* @return 结果
|
||
|
*/
|
||
|
public static Result getBillInfo(String queryNumType, String queryNumber, String begDate, String endDate) {
|
||
|
if (ObjectUtils.isEmpty(queryNumType) || ObjectUtils.isEmpty(queryNumber) || ObjectUtils.isEmpty(begDate) || ObjectUtils.isEmpty(endDate)) {
|
||
|
return Result.error(ResultEnum.PARAM_IS_DEFECT);
|
||
|
}
|
||
|
|
||
|
JsonResult JsonResult = HisHelper.getMdJsonResult(HisEnum.Medical_Insurance_Bill, params -> {
|
||
|
params.put("QueryNumType", queryNumType);
|
||
|
params.put("QueryNumber", queryNumber);
|
||
|
params.put("BegDate", begDate);
|
||
|
params.put("EndDate", endDate);
|
||
|
});
|
||
|
if (JsonResult.success()) {
|
||
|
JSONArray resultList = JsonResult.getJsonArray("SettlementInfo", "Item");
|
||
|
return Result.success(resultList);
|
||
|
}
|
||
|
return Result.error(JsonResult.getMessage());
|
||
|
}
|
||
|
|
||
|
}
|