/// <summary>
        /// 住院预结算
        /// </summary>
        /// <param name="inPara">住院接口入参</param>
        /// <returns></returns>
        public void InNetworkPreSettle(InPayParameter para)
        {
            inReimPara = para;

            if (inReimPara.SettleInfo != null && inReimPara.SettleInfo.MedAmountTotal != 0)
            {
                PayAPIInterface.Model.Comm.PayType payType;
                inReimPara.PayTypeList = new List <PayType>();
                payType             = new PayAPIInterface.Model.Comm.PayType();
                payType.PayTypeId   = 4;
                payType.PayTypeName = "医保";
                payType.PayAmount   = inReimPara.SettleInfo.MedAmountTotal;
                inReimPara.PayTypeList.Add(payType);

                payType             = new PayAPIInterface.Model.Comm.PayType();
                payType.PayTypeId   = 5;
                payType.PayTypeName = "医保卡";
                payType.PayAmount   = inReimPara.SettleInfo.MedAmountZhzf;
                inReimPara.PayTypeList.Add(payType);

                return;
            }

            InterfaceInit();
            inReimPara.Details = PayAPIUtilities.Tools.CommonTools.GetGroupList(inReimPara.Details);
            string notMatchedCharge = "";

            foreach (var item in inReimPara.Details)
            {
                if (item.NetworkItemCode.ToString().Trim().Length == 0)
                {
                    notMatchedCharge += "编码:" + item.ChargeCode + "," + "名称:" + item.ChargeName + ";";
                }
            }
            if (notMatchedCharge.Trim().Length > 0)
            {
                if (MessageBox.Show("有以下项目未对应:\n" + notMatchedCharge + "\n是否继续?选择”是“将按自费项目进行收费报销。否则,取消本次收费报销!", "提示", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    throw new Exception("取消上传费用");
                }

                //MessageBox.Show("有以下项目未对应:\n" + notMatchedCharge + "\n不能收费报销!", "提示", MessageBoxButtons.OK);

                //throw new Exception("项目未对照");
            }

            handelModel.InitZY(inReimPara.PatInfo.PatInHosCode);
            string ishaceCed = "";

            if (MessageBox.Show("是否有医保卡?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                ishaceCed = "1";
            }
            else
            {
                ishaceCed = "0";
            }

            handelModel.DelAllInItems(inReimPara.PatInfo.PatInHosCode);
            if (inReimPara.Details.Count > 0)
            {
                handelModel.SaveInItems(inReimPara.Details,
                                        //"001", // 医师编码
                                        inReimPara.PatInfo.DoctorCode,

                                        inReimPara.PatInfo.OutDateTime.ToString("yyyy-MM-dd"),   //费用发生日期
                                        inReimPara.PatInfo.PatInHosCode
                                        );


                //  if (MessageBox.Show("是否有医保卡?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
                if (ishaceCed == "1")
                {
                    dicSettleInfo = handelModel.SettleZY("");

                    //SaveInSettleMain();
                    //保存住院结算数据
                    #region 保存中心返回值参数列表
                    //保存中心返回值参数列表
                    #region 保存SettleList值
                    try
                    {
                        InNetworkSettleList inNetworkSettleList = new InNetworkSettleList();
                        foreach (var item in dicSettleInfo)
                        {
                            inNetworkSettleList                   = new InNetworkSettleList();
                            inNetworkSettleList.PatInHosId        = inReimPara.PatInfo.PatInHosId;
                            inNetworkSettleList.InNetworkSettleId = -1;
                            inNetworkSettleList.ParaName          = item.Key;
                            inNetworkSettleList.ParaValue         = item.Value.ToString();
                            inNetworkSettleList.Memo              = "";
                            inReimPara.SettleParaList.Add(inNetworkSettleList);
                        }
                    }
                    catch (Exception ex)
                    {
                        LogManager.Error("保存农合中心返回值参数列表 插入值 失败" + ex.Message, ex);
                    }
                    #endregion
                    InNetworkSettleMain inSettleMain = new InNetworkSettleMain();
                    inSettleMain.PatInHosId           = inReimPara.PatInfo.PatInHosId;
                    inSettleMain.SettleNo             = dicSettleInfo["brjsh"] + "|" + DateTime.Now.ToString("yyyyMMddHHmmss");                                                               //医保中心交易流水号
                    inSettleMain.Amount               = Convert.ToDecimal(dicSettleInfo["brfdje"]) + Convert.ToDecimal(dicSettleInfo["ybfdje"]) + Convert.ToDecimal(dicSettleInfo["yljmje"]); //本次医疗费用
                    inSettleMain.GetAmount            = Convert.ToDecimal(dicSettleInfo["brfdje"]) - Convert.ToDecimal(dicSettleInfo["grzhzf"]);                                              //本次现金支出
                    inSettleMain.MedAmountZhzf        = Convert.ToDecimal(dicSettleInfo["grzhzf"]);                                                                                           //本次帐户支出
                    inSettleMain.MedAmountTc          = Convert.ToDecimal(dicSettleInfo["ybfdje"]);                                                                                           //本次统筹支出
                    inSettleMain.MedAmountDb          = 0;                                                                                                                                    //本次大病支出
                    inSettleMain.MedAmountBz          = Convert.ToDecimal(dicSettleInfo["ylbzje"]);                                                                                           //本次大病支出
                    inSettleMain.MedAmountJm          = Convert.ToDecimal(dicSettleInfo["yljmje"]);                                                                                           //减免金额
                    inSettleMain.MedAmountTotal       = Convert.ToDecimal(inSettleMain.Amount) - Convert.ToDecimal(inSettleMain.GetAmount);
                    inSettleMain.NetworkingPatClassId = Convert.ToInt32(inReimPara.CommPara.NetworkPatClassId);
                    inSettleMain.NetworkPatName       = inReimPara.PatInfo.InPatName;
                    inSettleMain.NetworkPatType       = "0";
                    inSettleMain.SettleBackNo         = inReimPara.PatInfo.PatInHosCode;
                    inSettleMain.SettleType           = "1";
                    inReimPara.SettleInfo             = inSettleMain;

                    //保存结算数据
                    IInClientBLL inBLl = PayAPIClassLib.Factory.ClientBLLFactory.GetInClientBLLInstance();
                    //获取联网结算ID 并重新组织数据
                    inBLl.GetInSettleIdAndReorganizeData(inReimPara);
                    inBLl.SaveInNetworkSettleMain(inSettleMain);
                    inBLl.SaveInNetworkSettleList(inReimPara.SettleParaList);//保存settleLis结算数据


                    PayAPIInterface.Model.Comm.PayType payType;
                    inReimPara.PayTypeList = new List <PayType>();
                    payType             = new PayAPIInterface.Model.Comm.PayType();
                    payType.PayTypeId   = 4;
                    payType.PayTypeName = "医保";
                    payType.PayAmount   = Convert.ToDecimal(inSettleMain.MedAmountTotal);
                    inReimPara.PayTypeList.Add(payType);

                    payType             = new PayAPIInterface.Model.Comm.PayType();
                    payType.PayTypeId   = 5;
                    payType.PayTypeName = "医保卡";
                    payType.PayAmount   = Convert.ToDecimal(inSettleMain.MedAmountZhzf);
                    inReimPara.PayTypeList.Add(payType);
                    #endregion
                }
                else
                {
                    dicSettleInfo = handelModel.SettleZY("wkzy");
                    //SaveInSettleMain();
                    //保存住院结算数据
                    #region 保存中心返回值参数列表
                    //保存中心返回值参数列表
                    #region 保存SettleList值
                    try
                    {
                        InNetworkSettleList inNetworkSettleList = new InNetworkSettleList();
                        foreach (var item in dicSettleInfo)
                        {
                            inNetworkSettleList                   = new InNetworkSettleList();
                            inNetworkSettleList.PatInHosId        = inReimPara.PatInfo.PatInHosId;
                            inNetworkSettleList.InNetworkSettleId = -1;
                            inNetworkSettleList.ParaName          = item.Key;
                            inNetworkSettleList.ParaValue         = item.Value.ToString();
                            inNetworkSettleList.Memo              = "";
                            inReimPara.SettleParaList.Add(inNetworkSettleList);
                        }
                    }
                    catch (Exception ex)
                    {
                        LogManager.Error("保存农合中心返回值参数列表 插入值 失败" + ex.Message, ex);
                    }
                    #endregion
                    InNetworkSettleMain inSettleMain = new InNetworkSettleMain();
                    inSettleMain.PatInHosId           = inReimPara.PatInfo.PatInHosId;
                    inSettleMain.SettleNo             = dicSettleInfo["brjsh"] + "|" + DateTime.Now.ToString("yyyyMMddHHmmss");                                                               //医保中心交易流水号
                    inSettleMain.Amount               = Convert.ToDecimal(dicSettleInfo["brfdje"]) + Convert.ToDecimal(dicSettleInfo["ybfdje"]) + Convert.ToDecimal(dicSettleInfo["yljmje"]); //本次医疗费用
                    inSettleMain.GetAmount            = Convert.ToDecimal(dicSettleInfo["brfdje"]) - Convert.ToDecimal(dicSettleInfo["grzhzf"]);                                              //本次现金支出
                    inSettleMain.MedAmountZhzf        = Convert.ToDecimal(dicSettleInfo["grzhzf"]);                                                                                           //本次帐户支出
                    inSettleMain.MedAmountTc          = Convert.ToDecimal(dicSettleInfo["ybfdje"]);                                                                                           //本次统筹支出
                    inSettleMain.MedAmountDb          = 0;                                                                                                                                    //本次大病支出
                    inSettleMain.MedAmountBz          = Convert.ToDecimal(dicSettleInfo["ylbzje"]);                                                                                           //本次大病支出
                    inSettleMain.MedAmountJm          = Convert.ToDecimal(dicSettleInfo["yljmje"]);                                                                                           //减免金额
                    inSettleMain.MedAmountTotal       = Convert.ToDecimal(inSettleMain.Amount) - Convert.ToDecimal(inSettleMain.GetAmount);
                    inSettleMain.NetworkingPatClassId = Convert.ToInt32(inReimPara.CommPara.NetworkPatClassId);
                    inSettleMain.NetworkPatName       = inReimPara.PatInfo.InPatName;
                    inSettleMain.NetworkPatType       = "0";
                    inSettleMain.SettleBackNo         = inReimPara.PatInfo.PatInHosCode;
                    inSettleMain.SettleType           = "1";
                    inReimPara.SettleInfo             = inSettleMain;

                    //保存结算数据
                    IInClientBLL inBLl = PayAPIClassLib.Factory.ClientBLLFactory.GetInClientBLLInstance();
                    //获取联网结算ID 并重新组织数据
                    inBLl.GetInSettleIdAndReorganizeData(inReimPara);
                    inBLl.SaveInNetworkSettleMain(inSettleMain);
                    inBLl.SaveInNetworkSettleList(inReimPara.SettleParaList);//保存settleLis结算数据


                    PayAPIInterface.Model.Comm.PayType payType;
                    inReimPara.PayTypeList = new List <PayType>();
                    payType             = new PayAPIInterface.Model.Comm.PayType();
                    payType.PayTypeId   = 4;
                    payType.PayTypeName = "医保";
                    payType.PayAmount   = Convert.ToDecimal(inSettleMain.MedAmountTotal);
                    inReimPara.PayTypeList.Add(payType);

                    payType             = new PayAPIInterface.Model.Comm.PayType();
                    payType.PayTypeId   = 5;
                    payType.PayTypeName = "医保卡";
                    payType.PayAmount   = Convert.ToDecimal(inSettleMain.MedAmountZhzf);
                    inReimPara.PayTypeList.Add(payType);
                    #endregion
                }
            }
        }