|
@@ -168,10 +168,190 @@ namespace PTMedicalInsurance.Business
|
|
|
return Exception(-1, "保存结算信息失败",errMsg);
|
|
|
}
|
|
|
|
|
|
+ // 返回给HIS
|
|
|
+ if (returnToHis(joSettle, out errMsg) != 0)
|
|
|
+ {
|
|
|
+ outParam = errMsg;
|
|
|
+ return Exception(-1,"返回结算信息给HIS失败",errMsg);
|
|
|
+ }
|
|
|
+
|
|
|
MobilePayConfirmSettlement(joSettle,out outParam);
|
|
|
return IrisReturn("结算成功",null);
|
|
|
}
|
|
|
|
|
|
+ public CallResult Cancel(JObject input)
|
|
|
+ {
|
|
|
+ init(input);
|
|
|
+ int ret = MobilePayCancelSettlement(out outParam);
|
|
|
+ if(ret !=0)
|
|
|
+ {
|
|
|
+ return IrisReturn(-1,"退费失败", JObject.Parse(outParam));
|
|
|
+ }
|
|
|
+ return IrisReturn("退费成功", null);
|
|
|
+ }
|
|
|
+
|
|
|
+ public int MobilePayCancelSettlement(out string outPar)
|
|
|
+ {
|
|
|
+ string errMsg;
|
|
|
+ outPar = "";
|
|
|
+ try
|
|
|
+ {
|
|
|
+ if (MSettl.onlineYBFalg != "Y")
|
|
|
+ {
|
|
|
+ Global.businessType = "01301"; //结算
|
|
|
+ //读电子凭证
|
|
|
+ if (ReadEc(out errMsg) != 0)
|
|
|
+ {
|
|
|
+ outPar = errMsg;
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //获取6203入参
|
|
|
+ if (Get6203Inpar(out errMsg) != 0)
|
|
|
+ {
|
|
|
+ outPar = errMsg;
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ JObject joInput = JObject.Parse(errMsg);
|
|
|
+ // 调用his服务(移动支付院内退款服务)
|
|
|
+ JObject jo6203Rtn = invoker.invokeHISService(JsonHelper.setIrisInpar("05110036", joInput).ToString(), "移动支付退费");
|
|
|
+ if (JsonHelper.parseIrisRtnValue(jo6203Rtn, out errMsg) != 0)
|
|
|
+ {
|
|
|
+ outPar = errMsg;
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //处理撤销数据
|
|
|
+ if (cancleSettlement(Global.pat.settlID, out errMsg) != 0)
|
|
|
+ {
|
|
|
+ outPar = errMsg;
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ joParam.Add("middleSettleFlag", "");
|
|
|
+ //退HIS结算
|
|
|
+ if (hIS.cancleSettlementInfo(joParam, out errMsg) != 0)
|
|
|
+ {
|
|
|
+ outPar = errMsg;
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ outPar = JsonHelper.setIrisReturnValue(0, errMsg, null).ToString();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ Global.writeLog("MobilePayCancelSettlement:" + ex.Message);
|
|
|
+ outPar = ex.Message;
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 取消结算
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="outParam"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public int cancleSettlement(string newSettlID, out string outParam)
|
|
|
+ {
|
|
|
+ JObject joTmp = new JObject();
|
|
|
+ string errMsg = "";
|
|
|
+ try
|
|
|
+ {
|
|
|
+ joTmp.Add("HospitalDr", Global.inf.hospitalDr);
|
|
|
+ joTmp.Add("InterfaceDr", Global.inf.interfaceDr);
|
|
|
+ joTmp.Add("admID", MPat.adm_Dr);
|
|
|
+ joTmp.Add("mdtrt_id", MPat.mdtrtID);
|
|
|
+ joTmp.Add("setl_id", MPat.settlID);
|
|
|
+ joTmp.Add("new_setl_id", newSettlID);
|
|
|
+ joTmp.Add("updateUserID", Global.user.ID);
|
|
|
+ joTmp.Add("msgid", Global.curEvt.msgid);
|
|
|
+ joTmp.Add("OccurTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
|
+ JObject joRtn = invoker.invokeInsuService(JsonHelper.setIrisInpar("09010052", joTmp).ToString(), "取消结算信息");
|
|
|
+
|
|
|
+ if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
|
|
|
+ {
|
|
|
+ outParam = errMsg;
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ outParam = JsonHelper.setExceptionJson(0, "云医保平台", "取消结算成功").ToString();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ outParam = "取消结算信息:" + ex.Message;
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ #region 读卡
|
|
|
+ public int ReadEc(out string outPar)
|
|
|
+ {
|
|
|
+ outPar = "";
|
|
|
+ try
|
|
|
+ {
|
|
|
+ PatientService patientService = new PatientService();
|
|
|
+ int ret = patientService.trade1161(out outPar);
|
|
|
+ if (ret != 0)
|
|
|
+ {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ outPar = ex.Message;
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setPatientByEc(JObject jo)
|
|
|
+ {
|
|
|
+ MPat.name = JsonHelper.getDestValue(jo, "userName");
|
|
|
+ MPat.IDNO = JsonHelper.getDestValue(jo, "idNo");
|
|
|
+ MPat.certType = JsonHelper.getDestValue(jo, "idType");
|
|
|
+ MPat.token = JsonHelper.getDestValue(jo, "ecToken");
|
|
|
+ MPat.insuplc_admdvs = JsonHelper.getDestValue(jo, "insuOrg");
|
|
|
+ MPat.payAuthNo = JsonHelper.getDestValue(jo, "authNo");
|
|
|
+ MPat.gend = JsonHelper.getDestValue(jo, "gender");
|
|
|
+ MPat.brdy = JsonHelper.getDestValue(jo, "birthday");
|
|
|
+ MPat.naty = JsonHelper.getDestValue(jo, "nationality");
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ private int returnToHis(JObject joPreSettl,out string errMsg)
|
|
|
+ {
|
|
|
+ //返回给HIS后端
|
|
|
+ //JObject joTmp = JObject.Parse(JsonHelper.getDestValue(joM6201Rtn, "encData"));
|
|
|
+ JObject joTmp = new JObject();
|
|
|
+ joTmp.Add("insutype", MPat.insuType);
|
|
|
+ joTmp.Add("psn_no", MPat.psn_no);
|
|
|
+ joTmp.Add("insuplc_admdvs", MPat.insuplc_admdvs);
|
|
|
+ joTmp.Add("mdtrtId", MPat.mdtrtID);
|
|
|
+ joTmp.Add("mdtrt_id", MPat.mdtrtID);
|
|
|
+ joTmp.Add("mdtrt_cert_type", JsonHelper.getDestValue(joPreSettl, "mdtrt_cert_type"));
|
|
|
+ joTmp.Add("mdtrt_cert_no", JsonHelper.getDestValue(joPreSettl, "certno"));
|
|
|
+ joTmp.Add("med_type", JsonHelper.getDestValue(joPreSettl, "med_type"));
|
|
|
+
|
|
|
+ if (returnMPSettlementInfo(joTmp, joPreSettl, out errMsg) != 0)
|
|
|
+ {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
private int MobilePayConfirmSettlement(JObject joSettlInfo,out string outPar)
|
|
|
{
|
|
|
string errMsg;
|
|
@@ -496,6 +676,91 @@ namespace PTMedicalInsurance.Business
|
|
|
MPat.insuplc_admdvs = JsonHelper.getDestValue(jo, "data.InsuranceAreaCode");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ //组织M6203入参
|
|
|
+ public int Get6203Inpar(out string outparam)
|
|
|
+ {
|
|
|
+ string errMsg = "";
|
|
|
+ outparam = "";
|
|
|
+ try
|
|
|
+ {
|
|
|
+ JObject joInpar = new JObject();
|
|
|
+ //获取医保平台结算信息
|
|
|
+ if (QuerySettleInfo(out errMsg) != 0)
|
|
|
+ {
|
|
|
+ outparam = errMsg;
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ JObject joRtn = JObject.Parse(errMsg);
|
|
|
+ string settlInfo = JsonHelper.getDestValue(joRtn, "result.data[0]");
|
|
|
+ if (string.IsNullOrEmpty(settlInfo))
|
|
|
+ {
|
|
|
+ outparam = "没有查询到结算信息,请检查参数";
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 组织调用参数
|
|
|
+ Global.curEvt.msgid = Global.inf.hospitalNO + DateTime.Now.ToString("yyyyMMddHHmmssffff");
|
|
|
+ JObject joSettl = JObject.Parse(settlInfo);
|
|
|
+
|
|
|
+ MPat.settlID = JsonHelper.getDestValue(joSettl, "SettlementID");
|
|
|
+ //入参
|
|
|
+ joInpar.Add("outtradeno", JsonHelper.getDestValue(joSettl, "PayOrdID"));//支付订单号
|
|
|
+ joInpar.Add("appRefdSn", Global.curEvt.msgid);//应用退款流水号
|
|
|
+ string appRefdTime = JsonHelper.getDestValue(joInsuAdmObj, "appRefdTime");
|
|
|
+ if (string.IsNullOrEmpty(appRefdTime))
|
|
|
+ {
|
|
|
+ appRefdTime = Utils.GetDateTimeNow();
|
|
|
+ }
|
|
|
+ joInpar.Add("businessType", "DWREFUND");//应用退费时间
|
|
|
+ joInpar.Add("hospitalCode", Global.inf.hospitalNO);
|
|
|
+ joInpar.Add("ec_code", Global.pat.ecToken);
|
|
|
+ joInpar.Add("patName", Global.pat.name);
|
|
|
+ joInpar.Add("idType", "01");
|
|
|
+ joInpar.Add("idCardNo", Global.pat.IDNO);
|
|
|
+ outparam = joInpar.ToString();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+
|
|
|
+ outparam = "Get6203Inpar:" + ex.Message;
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ finally
|
|
|
+ {
|
|
|
+ Global.writeLog("Get6203Inpar", "", outparam);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询结算信息
|
|
|
+ public int QuerySettleInfo(out string errMsg)
|
|
|
+ {
|
|
|
+ errMsg = "";
|
|
|
+ try
|
|
|
+ {
|
|
|
+ string sqlStr = "SELECT * FROM BS_MedInsuSettlement WHERE Hospital_Dr= " + Global.inf.hospitalDr;
|
|
|
+ sqlStr = sqlStr + " and AdmType = 3 and Adm_Dr= " + MPat.adm_Dr + " and PayOrdID= '" + MPat.payOrdId + "'";
|
|
|
+ JObject joSqlstr = new JObject();
|
|
|
+ joSqlstr.Add("sqlStr", sqlStr);
|
|
|
+ JObject joRtn = mIS.DynamicQuerySettlInfo(joSqlstr);
|
|
|
+ if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
|
|
|
+ {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ errMsg = joRtn.ToString();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ errMsg = ex.Message;
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//获取入参,入参基本为类局部变量
|
|
|
public int Get6301Inpar(out string outparam)
|
|
|
{
|
|
@@ -536,6 +801,115 @@ namespace PTMedicalInsurance.Business
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 返回移动支付结算信息给HIS
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="joSetlInpar"></param>
|
|
|
+ /// <param name="joSetlinfo"></param>中心返回的信息
|
|
|
+ /// <param name="outParam"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public int returnMPSettlementInfo(JObject joReg, JObject joSettl, out string outParam)
|
|
|
+ {
|
|
|
+ string errMsg;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ JObject joSumFee = new JObject();
|
|
|
+ if (sumInsuRtnSettlInfo(joSettl, out joSumFee, out errMsg) != 0)
|
|
|
+ {
|
|
|
+ outParam = "返回结算结果给HIS失败,请联系管理员!" + errMsg;
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ dynamic joTmp = new JObject();
|
|
|
+ joTmp.settleInfo = joSettl;
|
|
|
+ joTmp.updateUserID = Global.user.ID;
|
|
|
+ joTmp.regInfo = joReg;
|
|
|
+ joTmp.middleSettleFlag = "";
|
|
|
+ joTmp.interfaceDr = Global.inf.interfaceDr;
|
|
|
+ dynamic joHisInfo = new JObject();
|
|
|
+ joHisInfo.admID = MPat.adm_Dr;
|
|
|
+ joHisInfo.billID = MPat.billID;
|
|
|
+ joHisInfo.recordID = MPat.recordID;
|
|
|
+ joTmp.hisInfo = joHisInfo;
|
|
|
+ joTmp.psn_type = MPat.psn_type;
|
|
|
+ joTmp.mobilePayFlag = "Y";
|
|
|
+ joTmp.sumFeeObj = joSumFee;
|
|
|
+ joTmp.mdtrtinfo = MPat.mdtrtID;
|
|
|
+ JObject joRtn = invoker.invokeHISService(JsonHelper.setIrisInpar("05110018", joTmp).ToString(), "返回移动支付结算结果给HIS");
|
|
|
+ if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
|
|
|
+ {
|
|
|
+ outParam = "返回移动支付结算结果给HIS失败,请联系管理员!" + errMsg;
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ joSumFee.Add("payAuthNo", MPat.payAuthNo);
|
|
|
+ joSumFee.Add("payOrdId", MPat.payOrdId);
|
|
|
+ joSumFee.Add("setlLatlnt", MPat.uldLatlnt);
|
|
|
+ joSumFee.Add("org_no", Global.inf.hospitalNO);
|
|
|
+ joSumFee.Add("medOrgOrd", MPat.recordID);
|
|
|
+ joSumFee.Add("mdtrtId", MPat.mdtrtID);
|
|
|
+ joSumFee.Add("gmt_out_create", MSettl.settlTime.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
|
+ joRtn["result"] = joSumFee;
|
|
|
+ outParam = joRtn.ToString();
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ outParam = "返回移动支付结算结果给HIS出现异常:!" + ex.Message;
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 汇总医保返回的结算金额(按照HIS的原则汇总,后期HIS按照这个来进行勾稽关系判断)
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="jo"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public int sumInsuRtnSettlInfo(JObject jo, out JObject joSumFee, out string errMsg)
|
|
|
+ {
|
|
|
+ // 医疗费总额是患者在医药机构花费的所有诊疗、药品、耗材、服务设施等项目费用的总和 = 基金支付总额 + 个人负担总金额 + 其他(如医院负担金额);
|
|
|
+ //3、基金支付总额 = 基本医保统筹基金支出(含职工基本医疗保险、居民基本医疗保险)+补充医疗保险基金支出 (含覆盖全体参保人的居民大病保险和大额医疗费用补助、覆盖部分参保人的企业职工大额医疗费用补助和公务员医疗补助等)+医疗救助基金支出 + 其他支出(如伤残人员医疗保障基金支出);
|
|
|
+ //5、个人账户支出中包含账户共济支付金额
|
|
|
+
|
|
|
+ joSumFee = new JObject();
|
|
|
+ errMsg = "";
|
|
|
+ decimal ybAmt, psnAcctAmt, hospAmt, psnCashAmt, medFee;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ ybAmt = 0; psnAcctAmt = 0; hospAmt = 0; psnCashAmt = 0; medFee = 0;
|
|
|
+ ybAmt = MSettl.fundPaySumamt;
|
|
|
+ psnAcctAmt = MSettl.accountPaySumamt;
|
|
|
+ psnCashAmt = MSettl.personCashPay;
|
|
|
+ hospAmt = MSettl.hospitalPartAmount;
|
|
|
+ medFee = MSettl.sumamt;
|
|
|
+
|
|
|
+ joSumFee.Add("sumamt", medFee);
|
|
|
+ joSumFee.Add("ybAmt", ybAmt);
|
|
|
+ joSumFee.Add("psnAcctAmt", psnAcctAmt);
|
|
|
+ joSumFee.Add("hospAmt", hospAmt);
|
|
|
+ joSumFee.Add("psnCashAmt", psnCashAmt);
|
|
|
+
|
|
|
+ if (medFee != (ybAmt + psnAcctAmt + psnCashAmt + hospAmt))
|
|
|
+ {
|
|
|
+ errMsg = "ybAmt(" + ybAmt.ToString() + ")+" + "psnAcctAmt(" + psnAcctAmt.ToString() + ")+" + "psnCashAmt(" + psnCashAmt.ToString() + ")+" + "hospAmt(" + hospAmt.ToString() + ")" + "!=medFee(" + medFee.ToString() + ")";
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ errMsg = ex.Message;
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
private int MobilePayQuery(out string outPar)
|
|
|
{
|
|
|
string errMsg, M6301Inpar;
|