Browse Source

增加市医保结算单打印

zzz 6 months ago
parent
commit
2fbd765717

+ 777 - 29
HuBeiMI/Forms/SettlementChecklist.cs

@@ -593,7 +593,7 @@ namespace PTMedicalInsurance.Forms
                     joParams.Add("fastReportCode", "SP11"); //湖北普瑞门诊结算单撤销结算单从SP14打印
                 }
                 joParams.Add("hospID", Global.inf.hisHospitalDr.ToString());
-                joParams.Add("printCode", Global.inf.interfaceDr.ToString());
+                joParams.Add("printCode", "14");
                 joParams.Add("templateID", "");
 
 
@@ -643,6 +643,326 @@ namespace PTMedicalInsurance.Forms
                 return joRtnEx;
             }
         }
+        //湖北市医保单独fastReport打印方法
+        [STAThread]
+        private void cityPrint()
+        {
+            try
+            {
+                int i = dgvSettlRecord.CurrentRow.Index;
+                DataTable dt = (DataTable)dgvSettlRecord.DataSource;
+                string AdmID = dt.Rows[i]["AdmID"].ToString();
+                string SettlementID = dt.Rows[i]["SettlementID"].ToString();
+                string ValidFlag = dt.Rows[i]["ValidFlag"].ToString();
+                string MdtrtID = dt.Rows[i]["MdtrtID"].ToString();
+                string BillType = dt.Rows[i]["BillType"].ToString();
+                JObject pJoInparm = new JObject();
+                pJoInparm.Add("MdtrtCertType", dt.Rows[i]["MdtrtCertType"].ToString());
+                JObject joRtn = cityGetFastReportParams("", AdmID, MdtrtID, SettlementID, ValidFlag, BillType, pJoInparm);
+                if (JsonHelper.parseIrisRtnValue(joRtn, out string errMsg) != 0)
+                {
+                    MessageBox.Show("获取FastReport入参失败:" + errMsg);
+                    return;
+                }
+
+                string sFastReportParam = JsonHelper.getDestValue(joRtn, "result");
+                if (FastReportPrint(sFastReportParam, out errMsg) != 0)
+                {
+                    MessageBox.Show("调用FastReport打印失败!" + errMsg);
+                    return;
+                }
+            }
+            catch (Exception ex)
+            {
+                MessageBox.Show(ex.Message);
+                return;
+            }
+
+        }
+        //湖北市医保单独获取fastReport打印入参
+        public JObject cityGetFastReportParams(string designFlag, string admID, string MdtrtID, string settlementID, string validFlag, string BillType, JObject pJoInparm)
+        {
+            try
+            {
+                if (designFlag == "") { designFlag = "N"; }
+                //string sqlStr = " SELECT * FROM  BS_MedInsuSettlement WHERE SettlementID='" + settlementID + "'"; 
+                //sqlStr = sqlStr + " and Adm_Dr='" + admID + "'";
+                //sqlStr = sqlStr + " and ValidFlag='" + validFlag + "'";
+                //sqlStr = sqlStr + " and BillType='" + BillType + "'";
+
+                //JObject joSqlstr = new JObject();
+                //joSqlstr.Add("sqlStr", sqlStr);
+                //JArray jaParam = new JArray();
+                //jaParam.Add(joSqlstr);
+                //JObject joSettlQuery = new JObject();
+                //joSettlQuery.Add("params", jaParam);
+                //joSettlQuery.Add("code", "09010059");
+                //JObject joRtn = invoker.invokeInsuService(joSettlQuery.ToString(), "查询结算信息");
+
+                //DataTable dt = (DataTable)joRtn["result"]["data"].ToObject(typeof(DataTable));
+
+                 #region【获取HIS医保结算信息】
+                JObject joSettel = new JObject();
+                joSettel.Add("HospitalDr", Global.inf.hospitalDr);
+                joSettel.Add("interfaceDr", Global.inf.interfaceDr);
+                joSettel.Add("admID", admID);
+                joSettel.Add("SettlementID", settlementID);
+                joSettel.Add("ValidFlag", validFlag);
+                joSettel.Add("BillType", BillType);
+                joSettel.Add("MdtrtID", MdtrtID);
+
+                JObject joRtnSettle = invoker.invokeInsuService(JsonHelper.setIrisInpar("09010066", joSettel).ToString(), "获取结算单信息");
+
+
+                if (JsonHelper.parseIrisRtnValue(joRtnSettle, out string errMsg) != 0)
+                {
+                    JObject joRtnSet = new JObject();
+                    joRtnSet.Add("errorCode", -1);
+                    joRtnSet.Add("errorMessage", errMsg);
+                    joRtnSet.Add("result", "");
+
+                    return joRtnSet;
+                }
+                #endregion
+                #region【获取住院号】
+                JObject joTmp = new JObject();
+                joTmp.Add("admID", joRtnSettle["result"]["data"]["settlement"][0]["AdmID"]);
+                joTmp.Add("psn_no", joRtnSettle["result"]["data"]["settlement"][0]["PersonnelNO"]);
+
+                //JObject joRtn = invoker.invokeHISService(JsonHelper.setIrisInpar("05110001", joTmp).ToString(), "获取诊断信息");
+                JObject joRtnDiag = invoker.invokeHISService(JsonHelper.setIrisInpar("05110014", joTmp).ToString(), "获取诊断信息");
+                string medrcdno = "";
+                string mdtrtCertType = "";//医保使用凭证 电子凭证 身份证 社保卡
+                string adtime = JsonHelper.getDestValue(joRtnSettle, "result.data.settlement[0].SettlementTime").ToString();
+                string distime = "";
+                int billtype = int.Parse(BillType);
+                //取就诊日期日期部分
+                DateTime addateTime;
+                if (DateTime.TryParse(JsonHelper.getDestValue(joRtnSettle, "result.data.settlement[0].SettlementTime").ToString(), out addateTime))
+                {
+                    distime = addateTime.Date.ToString("yyyy-MM-dd"); // 格式化输出日期部分
+                    adtime = addateTime.Date.ToString("yyyy-MM-dd"); // 格式化输出日期部分
+                }
+
+                if (JsonHelper.parseIrisRtnValue(joRtnSettle, out errMsg) == 0)
+                {
+                    medrcdno = joRtnDiag["mdtrtinfo"]["medrcdno"].ToString();
+                }
+                #endregion 
+                #region【数据转换】
+                if (joRtnSettle["result"]["data"]["settlement"][0]["Gender"].ToString() == "1")
+                {
+                    joRtnSettle["result"]["data"]["settlement"][0]["Gender"] = "男";
+                }
+                else
+                {
+                    joRtnSettle["result"]["data"]["settlement"][0]["Gender"] = "女";
+                }
+                if (pJoInparm["MdtrtCertType"].ToString() == "01")
+                {
+                    mdtrtCertType = "医保电子凭证";
+                }
+                else if (pJoInparm["MdtrtCertType"].ToString() == "02")
+                {
+                    mdtrtCertType = "居民身份证";
+                }
+                else if (pJoInparm["MdtrtCertType"].ToString() == "03")
+                {
+                    mdtrtCertType = "社保卡";             
+                }
+
+                DateTime startDate = (DateTime)joRtnSettle["result"]["data"]["reginfo"][0]["RegDate"];
+                DateTime endDate = (DateTime)joRtnSettle["result"]["data"]["settlement"][0]["SettlementTime"];
+                int diffInDays = (int)(endDate - startDate).TotalDays;
+                if (diffInDays == 0)
+                {
+                    diffInDays = 1;
+                }
+
+                joRtnSettle["result"]["data"]["settlement"][0]["HospitalizationsDays"] = diffInDays;
+
+                string str = joRtnSettle["result"]["data"]["patinsuinfo"][0]["Age"].ToString();
+                if (str.Contains("."))
+                {
+                    joRtnSettle["result"]["data"]["patinsuinfo"][0]["Age"] = str.Split('.')[0] + "岁";
+                }
+                else
+                {
+                    joRtnSettle["result"]["data"]["patinsuinfo"][0]["Age"] = str + "岁";
+                }
+
+                string ISCX = "";
+                if (BillType == "-1")
+                {
+                    ISCX = "撤销";
+                }
+                
+
+                #endregion 
+
+
+                #region【组织FastReport调用入参】               
+                JArray jachargeItemLvFee = JArray.Parse(JsonHelper.getDestValue(joRtnSettle, "result.data.chargeItemLvFee"));
+                JArray jaClassification = JArray.Parse(JsonHelper.getDestValue(joRtnSettle, "result.data.classification"));
+                JArray jaSettlement = JArray.Parse(JsonHelper.getDestValue(joRtnSettle, "result.data.settlement"));
+                JArray jaReginfo = JArray.Parse(JsonHelper.getDestValue(joRtnSettle, "result.data.reginfo"));
+                JArray japatinsuinfo = JArray.Parse(JsonHelper.getDestValue(joRtnSettle, "result.data.patinsuinfo"));
+
+             //退费前卡余额
+                decimal BalanceBefore = Convert.ToDecimal(JsonHelper.getDestValue(joRtnSettle, "result.data.settlement[0].Balance")) - Convert.ToDecimal(JsonHelper.getDestValue(joRtnSettle, "result.data.settlement[0].AccountPaySumamt")) + Convert.ToDecimal(JsonHelper.getDestValue(joRtnSettle, "result.data.settlement[0].AccountMutualAidAmount"));
+                //退费撤销结算单负数显示
+                decimal LSumamt = Convert.ToDecimal(JsonHelper.getDestValue(joRtnSettle, "result.data.settlement[0].Sumamt")) * billtype;                
+                decimal LFundPaySumamt = Convert.ToDecimal(JsonHelper.getDestValue(joRtnSettle, "result.data.settlement[0].FundPaySumamt")) * billtype;
+                decimal LHealthInsurancePay = Convert.ToDecimal(JsonHelper.getDestValue(joRtnSettle, "result.data.settlement[0].HealthInsurancePay")) * billtype;
+                decimal LLargeExpensesSupplementPay = Convert.ToDecimal(JsonHelper.getDestValue(joRtnSettle, "result.data.settlement[0].LargeExpensesSupplementPay")) * billtype;
+                decimal LSeriousIllnessPay = Convert.ToDecimal(JsonHelper.getDestValue(joRtnSettle, "result.data.settlement[0].SeriousIllnessPay")) * billtype;
+                decimal LMedicalAssistPay = Convert.ToDecimal(JsonHelper.getDestValue(joRtnSettle, "result.data.settlement[0].MedicalAssistPay")) * billtype;
+                decimal LEnterpriseSupplementPay = Convert.ToDecimal(JsonHelper.getDestValue(joRtnSettle, "result.data.settlement[0].EnterpriseSupplementPay")) * billtype;
+                decimal LOtherPay = Convert.ToDecimal(JsonHelper.getDestValue(joRtnSettle, "result.data.settlement[0].OtherPay")) * billtype;
+                decimal LCivilserviceAllowancePay = Convert.ToDecimal(JsonHelper.getDestValue(joRtnSettle, "result.data.settlement[0].CivilserviceAllowancePay")) * billtype;
+                decimal LDEZF = LLargeExpensesSupplementPay + LSeriousIllnessPay;
+                decimal LHospitalPartAmount = Convert.ToDecimal(JsonHelper.getDestValue(joRtnSettle, "result.data.settlement[0].HospitalPartAmount")) * billtype;
+                decimal LPersonPaySumamt = Convert.ToDecimal(JsonHelper.getDestValue(joRtnSettle, "result.data.settlement[0].PersonPaySumamt")) * billtype;
+                decimal LAccountPaySumamt = Convert.ToDecimal(JsonHelper.getDestValue(joRtnSettle, "result.data.settlement[0].AccountPaySumamt")) * billtype;
+                decimal LPersonCashPay = Convert.ToDecimal(JsonHelper.getDestValue(joRtnSettle, "result.data.settlement[0].PersonCashPay")) * billtype;
+                decimal LAccountMutualAidAmount = Convert.ToDecimal(JsonHelper.getDestValue(joRtnSettle, "result.data.settlement[0].AccountMutualAidAmount")) * billtype;
+
+
+                decimal LBlZf = Convert.ToDecimal(JsonHelper.getDestValue(joRtnSettle, "result.data.settlement[0].PersonPaySumamt")) - Convert.ToDecimal(JsonHelper.getDestValue(joRtnSettle, "result.data.settlement[0].OwnPayAmount")) - Convert.ToDecimal(JsonHelper.getDestValue(joRtnSettle, "result.data.settlement[0].PreSelfPayAmount")) - Convert.ToDecimal(JsonHelper.getDestValue(joRtnSettle, "result.data.settlement[0].OverLimitAmount")) - Convert.ToDecimal(JsonHelper.getDestValue(joRtnSettle, "result.data.settlement[0].ActualPayDeductible"));
+
+                //转换金额大写
+                string Sumamt = FastReportFunction.MoneyToUpper(LSumamt.ToString());
+
+                string HealthInsurancePay = FastReportFunction.MoneyToUpper(JsonHelper.getDestValue(joRtnSettle, "result.data.settlement[0].HealthInsurancePay").ToString());
+                string ActualPayDeductible = FastReportFunction.MoneyToUpper(JsonHelper.getDestValue(joRtnSettle, "result.data.settlement[0].ActualPayDeductible").ToString());
+                string PersonCashPay = FastReportFunction.MoneyToUpper(JsonHelper.getDestValue(joRtnSettle, "result.data.settlement[0].PersonCashPay").ToString());
+                string AccountPaySumamt = FastReportFunction.MoneyToUpper(JsonHelper.getDestValue(joRtnSettle, "result.data.settlement[0].AccountPaySumamt").ToString());
+                string FundPaySumamt = FastReportFunction.MoneyToUpper(JsonHelper.getDestValue(joRtnSettle, "result.data.settlement[0].FundPaySumamt").ToString());
+                string LargeExpensesSupplementPay = FastReportFunction.MoneyToUpper(JsonHelper.getDestValue(joRtnSettle, "result.data.settlement[0].LargeExpensesSupplementPay").ToString());
+                string SeriousIllnessPay = FastReportFunction.MoneyToUpper(JsonHelper.getDestValue(joRtnSettle, "result.data.settlement[0].SeriousIllnessPay").ToString());
+                string CivilserviceAllowancePay = FastReportFunction.MoneyToUpper(JsonHelper.getDestValue(joRtnSettle, "result.data.settlement[0].CivilserviceAllowancePay").ToString());
+                string MedicalAssistPay = FastReportFunction.MoneyToUpper(JsonHelper.getDestValue(joRtnSettle, "result.data.settlement[0].MedicalAssistPay").ToString());
+                string OtherPay = FastReportFunction.MoneyToUpper(JsonHelper.getDestValue(joRtnSettle, "result.data.settlement[0].OtherPay").ToString());
+                string HospitalPartAmount = FastReportFunction.MoneyToUpper(JsonHelper.getDestValue(joRtnSettle, "result.data.settlement[0].HospitalPartAmount").ToString());
+                string AccountMutualAidAmount = FastReportFunction.MoneyToUpper(JsonHelper.getDestValue(joRtnSettle, "result.data.settlement[0].AccountMutualAidAmount").ToString());
+                string InPolicyRangeAmount = FastReportFunction.MoneyToUpper(JsonHelper.getDestValue(joRtnSettle, "result.data.settlement[0].InPolicyRangeAmount").ToString());
+
+
+                //string BeginDate = JsonHelper.getDestValue(joRtnSettle, "result.data.reginfo[0].RegDate").ToString();
+                //string EndDate = JsonHelper.getDestValue(joRtnSettle, "result.data.settlement[0].HISDischargeTime").ToString();
+                //string InHosDays = FastReportFunction.DateDiff(Convert.ToDateTime(BeginDate), Convert.ToDateTime(EndDate));  
+
+                JObject jaAmountChiness = new JObject();
+                jaAmountChiness.Add("Sumamt", Sumamt);
+                jaAmountChiness.Add("HealthInsurancePay", HealthInsurancePay);
+                jaAmountChiness.Add("ActualPayDeductible", ActualPayDeductible);
+                jaAmountChiness.Add("PersonCashPay", PersonCashPay);
+                jaAmountChiness.Add("AccountPaySumamt", AccountPaySumamt);
+                jaAmountChiness.Add("FundPaySumamt", FundPaySumamt);
+                jaAmountChiness.Add("LargeExpensesSupplementPay", LargeExpensesSupplementPay);
+                jaAmountChiness.Add("SeriousIllnessPay", SeriousIllnessPay);
+                jaAmountChiness.Add("CivilserviceAllowancePay", CivilserviceAllowancePay);
+                jaAmountChiness.Add("MedicalAssistPay", MedicalAssistPay);
+                jaAmountChiness.Add("OtherPay", OtherPay);
+                jaAmountChiness.Add("HospitalPartAmount", HospitalPartAmount);
+                jaAmountChiness.Add("AccountMutualAidAmount", AccountMutualAidAmount);
+                jaAmountChiness.Add("InPolicyRangeAmount", InPolicyRangeAmount); //合规费用
+
+                jaAmountChiness.Add("SettlOpter", Global.user.name);
+                jaAmountChiness.Add("medrcdno", medrcdno);
+                jaAmountChiness.Add("mdtrtCertType", mdtrtCertType);
+                jaAmountChiness.Add("hospitalNO",Global.inf.hospitalNO);
+                jaAmountChiness.Add("hospitalName", Global.inf.hospitalName);
+
+                //其他自定义处理字段
+                jaAmountChiness.Add("BalanceBefore", BalanceBefore);//结算前卡余额
+                jaAmountChiness.Add("LSumamt", LSumamt);
+                jaAmountChiness.Add("LFundPaySumamt", LFundPaySumamt);
+                jaAmountChiness.Add("LHealthInsurancePay", LHealthInsurancePay);
+                jaAmountChiness.Add("LMedicalAssistPay", LMedicalAssistPay);
+                jaAmountChiness.Add("LCivilserviceAllowancePay", LCivilserviceAllowancePay);
+                jaAmountChiness.Add("LLargeExpensesSupplementPay", LLargeExpensesSupplementPay);
+                jaAmountChiness.Add("LSeriousIllnessPay", LSeriousIllnessPay);
+                jaAmountChiness.Add("LEnterpriseSupplementPay", LEnterpriseSupplementPay);
+                jaAmountChiness.Add("LOtherPay", LOtherPay);
+                jaAmountChiness.Add("LDEZF", LDEZF);
+                jaAmountChiness.Add("LHospitalPartAmount", LHospitalPartAmount);
+                jaAmountChiness.Add("LPersonPaySumamt", LPersonPaySumamt);
+                jaAmountChiness.Add("LAccountPaySumamt", LAccountPaySumamt);
+                jaAmountChiness.Add("LPersonCashPay", LPersonCashPay);
+                jaAmountChiness.Add("LAccountMutualAidAmount", LAccountMutualAidAmount);           
+                jaAmountChiness.Add("LBlZf", LBlZf);
+                jaAmountChiness.Add("adtime", adtime);
+                jaAmountChiness.Add("distime", distime);
+                jaAmountChiness.Add("iscx", ISCX);
+                
+
+                JArray jachinessParams = new JArray();
+                jachinessParams.Add(jaAmountChiness);
+
+                JObject joDataResult = new JObject();
+                joDataResult.Add("SettlementInfo", jaSettlement);
+                joDataResult.Add("ChargeItemLvFee", jachargeItemLvFee);
+                joDataResult.Add("ClassificationInfo", jaClassification);
+                joDataResult.Add("RegInfo", jaReginfo);
+                joDataResult.Add("Patinsuinfo", japatinsuinfo);
+                joDataResult.Add("ChinessSummat", jachinessParams);
+          
+
+                JObject joParams = new JObject();
+                joParams.Add("fastReportCode", "printSettlementList"); //这个要从表取值  
+                joParams.Add("hospID", Global.inf.hisHospitalDr.ToString());
+                joParams.Add("printCode", "City");
+                joParams.Add("templateID", "");
+
+
+                JArray jaParams = new JArray();
+                jaParams.Add(joParams);
+
+                JObject joReportParams = new JObject();
+                joReportParams.Add("params", jaParams);
+                joReportParams.Add("code", "01040306");
+
+                JObject joParam = new JObject();
+                joParam.Add("designFlag", designFlag);
+                joParam.Add("logFlag", "N");
+                joParam.Add("dataParams", "");
+                joParam.Add("pdfName", "");
+                joParam.Add("reportparams", joReportParams);
+                joParam.Add("dataResult", joDataResult);
+
+                JObject joDataURL = new JObject();
+                joDataURL.Add("dataIP", Global.hisConfig.ip);
+                joDataURL.Add("urlAddress", Global.hisConfig.url);
+                joDataURL.Add("authorization", Global.hisConfig.authorization);
+
+                joParam.Add("dataURL", joDataURL);
+
+                JArray jaParam = new JArray();
+                jaParam.Add(joParam);
+
+                JObject joInparam = new JObject();
+                joInparam.Add("params", JArray.FromObject(jaParam));
+                joInparam.Add("session", Global.curEvt.jaSession);
+                #endregion
+
+                JObject joRtn = new JObject();
+                joRtn.Add("errorCode", 0);
+                joRtn.Add("errorMessage", "");
+                joRtn.Add("result", joInparam.ToString());
+
+                return joRtn;
+            }
+            catch (Exception ex)
+            {
+                JObject joRtnEx = new JObject();
+                joRtnEx.Add("errorCode", -1);
+                joRtnEx.Add("errorMessage", ex.Message);
+                joRtnEx.Add("result", "");
+                return joRtnEx;
+            }
+        }
+
 
         [STAThread]
         private void preview()
@@ -725,11 +1045,6 @@ namespace PTMedicalInsurance.Forms
                 
                 #endregion
             }
-
-
-
-
-
         }
 
         public void btnDesign_Click(object sender, EventArgs e)
@@ -886,7 +1201,326 @@ namespace PTMedicalInsurance.Forms
                 setlinfo.hosp_part_amt = Outlog["hosp_part_amt"];//医院负担金额
                 setlinfo.hifdm_pay = 0;//伤残人员医疗保障基金支出
 
-               
+
+
+                //string outParam = "";
+                ////获取IS费用
+                //if (hIS.getHisFee(Global.pat, out outParam) != 0)
+                //{
+                //    MessageBox.Show("获取HIS费用失败");
+                //}
+                ////调用医保平台转换HIS费用(转换医保编码等)
+                //JObject joHisFee = JObject.Parse(outParam);
+
+                //if (mIS.convertHisFeeWithInsuCode(joHisFee, out outParam) != 0)
+                //{
+                //    MessageBox.Show("获取HIS费用医保对照关系失败");
+                //}
+                //JArray jaFeeDetail = JArray.Parse(JsonHelper.getDestValue(JObject.Parse(outParam), "data"));
+
+                // JObject jaFeeOne=new  JObject();
+                //for (int i = 0; i < jaFeeDetail.Count; i++)
+                //{
+                //    jaFeeOne.Add("feedetl_sn", jaFeeDetail[i]["feedetl_sn"]);//费用明细流水号
+                //    jaFeeOne.Add("rxno", "");//处方号
+                //    if (string.IsNullOrEmpty(jaFeeDetail[i]["rx_circ_flag"].ToString()))
+                //    {
+                //        jaFeeOne.Add("rx_circ_flag", "");//外购处方标志
+                //    }
+                //    else
+                //    {
+                //        jaFeeOne.Add("rx_circ_flag", jaFeeDetail[i]["rx_circ_flag"]);//外购处方标志
+                //    }
+                //    jaFeeOne.Add("fee_ocur_time", jaFeeDetail[i]["fee_ocur_time"]);
+                //    jaFeeOne.Add("med_list_codg", jaFeeDetail[i]["med_list_codg"]);
+
+                //    jaFeeOne.Add("medins_list_codg", jaFeeDetail[i]["medins_list_codg"]);
+                //    jaFeeOne.Add("medins_list_name", jaFeeDetail[i]["medins_list_desc"]);
+
+                //    jaFeeOne.Add("prodname", jaFeeDetail[i]["medins_list_desc"]);
+
+                //    if (string.IsNullOrEmpty(jaFeeDetail[i]["spec"].ToString()))
+                //    {
+                //        jaFeeOne.Add("spec", "");
+                //    }
+                //    else
+                //    {
+                //        jaFeeOne.Add("spec", jaFeeDetail[i]["spec"]);
+                //    }
+
+
+                //    if (string.IsNullOrEmpty(jaFeeDetail[i]["doseForm"].ToString()))
+                //    {
+                //        jaFeeOne.Add("dosform_name", "");
+                //    }
+
+                //    else
+                //    {
+                //        jaFeeOne.Add("dosform_name", jaFeeDetail[i]["doseForm"]);
+                //    }
+
+
+                //    jaFeeOne.Add(" det_item_fee_sumamt", jaFeeDetail[i]["det_item_fee_sumamt"]);
+                //    jaFeeOne.Add("cnt", jaFeeDetail[i]["cnt"]);
+                //    jaFeeOne.Add("pric", jaFeeDetail[i]["pric"]);
+
+                //    if (string.IsNullOrEmpty(jaFeeDetail[i]["sin_dos_dscr"].ToString()))
+                //    {
+                //        jaFeeOne.Add("sin_dos_dscr", "");
+                //    }
+                //    else
+                //    {
+                //        jaFeeOne.Add("sin_dos_dscr", jaFeeDetail[i]["sin_dos_dscr"]);
+                //    }
+
+
+                //    if (string.IsNullOrEmpty(jaFeeDetail[i]["used_frqu_dscr"].ToString()))
+                //    {
+                //        jaFeeOne.Add("used_frqu_dscr", "");
+                //    }
+                //    else
+                //    {
+                //        jaFeeOne.Add("used_frqu_dscr", jaFeeDetail[i]["used_frqu_dscr"]);
+                //    }
+
+                //    if (string.IsNullOrEmpty(jaFeeDetail[i]["prd_days"].ToString()))
+                //    {
+                //        jaFeeOne.Add("prd_days", "");
+                //    }
+                //    else
+                //    {
+                //        jaFeeOne.Add("prd_days", jaFeeDetail[i]["prd_days"]);
+                //    }
+                //    MessageBox.Show("555");
+                //    if (string.IsNullOrEmpty(jaFeeDetail[i]["medc_way_dscr"].ToString()))
+                //    {
+                //        jaFeeOne.Add("medc_way_dscr", "");
+                //    }
+                //    else
+                //    {
+                //        jaFeeOne.Add("medc_way_dscr", jaFeeDetail[i]["medc_way_dscr"]);
+                //    }
+
+                //    if (string.IsNullOrEmpty(jaFeeDetail[i]["bilg_dr_codg"].ToString()))
+                //    {
+                //        jaFeeOne.Add("bilg_dr_codg", "");
+                //    }
+                //    else
+                //    {
+                //        jaFeeOne.Add("bilg_dr_codg", jaFeeDetail[i]["bilg_dr_codg"]);
+                //    }
+                //    if (string.IsNullOrEmpty(jaFeeDetail[i]["bilg_dr_name"].ToString()))
+                //    {
+                //        jaFeeOne.Add("bilg_dr_name", "");
+                //    }
+                //    else
+                //    {
+                //        jaFeeOne.Add("bilg_dr_name", jaFeeDetail[i]["bilg_dr_name"]);
+                //    }
+                //    MessageBox.Show("666");
+                //    jaFeeOne.Add("phar_name", "");
+
+                //    jaFeeOne.Add("phar_prac_cert_no", "");
+                //    jaFeeOne.Add("tcmdrug_used_way", ""); //中药使用方式 1复方 2单方 必填
+                //    jaFeeOne.Add("trdn_flag", "1");//拆零标志 必填 0否  1是
+                //    jaFeeDetail.Add(jaFeeOne);
+
+                //    jaFeeOne = new JObject();
+                //    MessageBox.Show("777");
+                //}
+                JObject Jo992001 = new JObject();
+                //Jo992001.Add("setlinfo",JObject.Parse(setlinfo));//结算信息节点
+                
+                Jo992001.Add("setlinfo", setlinfo);//结算信息节点
+     
+                //Jo992001.Add("drugdetail", jaFeeDetail);//购药明细节点 
+    
+                JObject OutJo = invoker.invokeCenterServiceJXC("992001", JObject.Parse(JsonHelper.setCenterInpar("992001", Jo992001)));
+                MessageBox.Show("上传成功!!!,上传返回:" + OutJo.ToString());
+            }
+            catch (Exception ex)
+            {
+                MessageBox.Show(ex.Message);
+                return;
+            }
+        }
+
+        private void SYBJXCTFToolStripMenuItem_Click(object sender, EventArgs e)
+        {
+            
+
+            if (dgvSettlRecord.RowCount <= 0)
+            {
+                MessageBox.Show("请先查询结算数据!");
+                return;
+            }
+            string sqlStr;
+            try
+            {
+                int m = dgvSettlRecord.CurrentRow.Index;
+                DataTable dt = (DataTable)dgvSettlRecord.DataSource;
+                string msgid = dt.Rows[m]["msgid"].ToString();
+                string SettlementID = dt.Rows[m]["SettlementID"].ToString();
+                string ValidFlag = dt.Rows[m]["ValidFlag"].ToString();
+                string MdtrtID = dt.Rows[m]["MdtrtID"].ToString();
+                string BillType = dt.Rows[m]["BillType"].ToString();
+                string AdmID = dt.Rows[m]["AdmID"].ToString();
+                string billID = dt.Rows[m]["billID"].ToString();
+                string recordID = dt.Rows[m]["recordID"].ToString();
+                Global.pat.adm_Dr = int.Parse(AdmID);
+                Global.pat.billID = billID;
+                Global.pat.recordID = recordID;
+
+
+                if (BillType == "1")
+                {
+                    MessageBox.Show("请选择退费负记录!该记录为正交易记录");
+                }
+           
+                sqlStr = "SELECT * FROM  BS_MedInsuTransactionLog WHERE MSGID='" + msgid + "'";
+                JObject joSqlstr = new JObject();
+                joSqlstr.Add("sqlStr", sqlStr);
+                JObject joRtn = mIS.QueryTransactionLog(joSqlstr);
+         
+                if (joRtn["result"]["data"].ToString() == "[]")
+                {
+                    MessageBox.Show("查询结果为空!");
+                    return;
+                }
+        
+                //DataTable dtlog = (DataTable)joRtn["result"]["data"][0].ToObject(typeof(DataTable));
+                JObject Outlog = JObject.Parse(joRtn["result"]["data"][0]["OutparamPlain"].ToString()); 
+                dynamic setlinfo = new JObject();//结算信息节点
+                setlinfo.setl_id = Outlog["output"]["setlinfo"]["setl_id"];//结算ID
+                setlinfo.init_setl_id = "";//原结算ID
+                setlinfo.setl_time = Outlog["output"]["setlinfo"]["setl_time"];//结算退费时间
+                setlinfo.mdtrt_id = Outlog["output"]["setlinfo"]["mdtrt_id"];//就诊ID
+                setlinfo.psn_no = Outlog["output"]["setlinfo"]["psn_no"];//人员编号
+                setlinfo.exp_content = "";
+
+
+                string mdtrt_id = Outlog["output"]["setlinfo"]["mdtrt_id"].ToString();
+                sqlStr = "SELECT * FROM  BS_MedInsuSettlement WHERE billType = 1 ";
+                sqlStr = sqlStr + " AND Hospital_Dr=" + Global.inf.hospitalDr + " AND Interface_Dr=" + Global.inf.interfaceDr;
+                sqlStr = sqlStr + " AND MdtrtID ='" + mdtrt_id + "'";
+          
+                JObject joSql = new JObject();
+                joSql.Add("sqlStr", sqlStr);
+                JObject joSettlInfo = mIS.QuerySettlementInfo(joSql);
+                //查询结算信息
+                JObject Outpam = JObject.Parse(joSettlInfo["result"]["data"][0].ToString());
+                setlinfo.init_setl_id = Outpam["SettlementID"];//ADMID
+                setlinfo.psn_no = Outpam["PersonnelNO"];
+              
+                JObject joParam992002 = new JObject();
+                joParam992002.Add("data", setlinfo);//结算信息节点
+                JObject OutJo = invoker.invokeCenterServiceJXC("992002", JObject.Parse(JsonHelper.setCenterInpar("992002", joParam992002)));
+                MessageBox.Show("上传成功+"+ OutJo.ToString());
+            }
+            catch (Exception ex)
+            {
+                MessageBox.Show(ex.Message);
+                return;
+            }
+        }
+
+        private void FYMXToolStripMenuItem_Click(object sender, EventArgs e)
+        {
+            if (dgvSettlRecord.RowCount <= 0)
+            {
+                MessageBox.Show("请先查询结算数据!");
+                return;
+            }
+            string sqlStr;
+            try
+            {
+                int m = dgvSettlRecord.CurrentRow.Index;
+                DataTable dt = (DataTable)dgvSettlRecord.DataSource;
+                string msgid = dt.Rows[m]["msgid"].ToString();
+                string SettlementID = dt.Rows[m]["SettlementID"].ToString();
+                string ValidFlag = dt.Rows[m]["ValidFlag"].ToString();
+                string MdtrtID = dt.Rows[m]["MdtrtID"].ToString();
+                string BillType = dt.Rows[m]["BillType"].ToString();
+                string AdmID = dt.Rows[m]["AdmID"].ToString();
+                string billID = dt.Rows[m]["billID"].ToString();
+                string recordID = dt.Rows[m]["recordID"].ToString();
+                Global.pat.adm_Dr = int.Parse(AdmID);
+                Global.pat.billID = billID;
+                Global.pat.recordID = recordID;
+
+
+                //if (BillType == "-1")
+                //{
+                //    MessageBox.Show("请选择结算正记录!该记录为退费记录");
+                //}
+
+                sqlStr = "SELECT * FROM  BS_MedInsuTransactionLog WHERE MSGID='" + msgid + "'";
+                JObject joSqlstr = new JObject();
+                joSqlstr.Add("sqlStr", sqlStr);
+                JObject joRtn = mIS.QueryTransactionLog(joSqlstr);
+                if (joRtn["result"]["data"].ToString() == "[]")
+                {
+                    MessageBox.Show("查询结果为空!");
+                    return;
+                }
+
+                //DataTable dtlog = (DataTable)joRtn["result"]["data"][0].ToObject(typeof(DataTable));
+                JObject Outlog = JObject.Parse(joRtn["result"]["data"][0]["OutparamPlain"].ToString());
+                dynamic setlinfo = new JObject();//结算信息节点
+                setlinfo.setl_id = Outlog["output"]["setlinfo"]["setl_id"];//结算ID
+                //setlinfo.mdtrt_id = Outlog["output"]["setlinfo"]["mdtrt_id"];//就诊ID
+                //setlinfo.psn_no = Outlog["output"]["setlinfo"]["psn_no"];//人员编号
+                //setlinfo.psn_name = Outlog["output"]["setlinfo"]["psn_name"];//人员姓名
+                //setlinfo.psn_cert_type = Outlog["output"]["setlinfo"]["psn_cert_type"];//凭证类型
+
+                //setlinfo.certno = Outlog["output"]["setlinfo"]["certno"];//证件号码
+                //setlinfo.gend = Outlog["output"]["setlinfo"]["gend"];//性别
+                //setlinfo.naty = Outlog["output"]["setlinfo"]["naty"];//民族
+                //setlinfo.brdy = Outlog["output"]["setlinfo"]["brdy"];//出生日期
+                //setlinfo.age = Outlog["output"]["setlinfo"]["age"];//年龄
+
+                //setlinfo.insutype = Outlog["output"]["setlinfo"]["insutype"];//险种类型
+                //setlinfo.psn_type = Outlog["output"]["setlinfo"]["psn_type"];//人员类别
+                //setlinfo.cvlserv_flag = Outlog["output"]["setlinfo"]["cvlserv_flag"];//公务员标志
+                setlinfo.setl_time = Outlog["output"]["setlinfo"]["setl_time"];//结算时间
+                //setlinfo.mdtrt_cert_type = Outlog["output"]["setlinfo"]["mdtrt_cert_type"];//就诊凭证类型
+
+                //setlinfo.med_type = Outlog["output"]["setlinfo"]["med_type"];//医疗类别
+                //setlinfo.medfee_sumamt = Outlog["output"]["setlinfo"]["medfee_sumamt"];//医疗费总额
+                //setlinfo.fulamt_ownpay_amt = Outlog["output"]["setlinfo"]["fulamt_ownpay_amt"];//全自费金额
+                //setlinfo.overlmt_selfpay = Outlog["output"]["setlinfo"]["overlmt_selfpay"];//超限价自费费用
+                //setlinfo.preselfpay_amt = Outlog["output"]["setlinfo"]["preselfpay_amt"];//先行自付金额
+
+                //setlinfo.inscp_scp_amt = Outlog["output"]["setlinfo"]["inscp_scp_amt"];//符合政策范围金额
+                //setlinfo.act_pay_dedc = Outlog["output"]["setlinfo"]["act_pay_dedc"];//实际支付起付线
+                //setlinfo.hifp_pay = Outlog["output"]["setlinfo"]["hifp_pay"];//基本医疗保险统筹基金支出
+                //setlinfo.pool_prop_selfpay = Outlog["output"]["setlinfo"]["pool_prop_selfpay"];//基本医疗保险统筹基金支付比例
+                //setlinfo.cvlserv_pay = Outlog["output"]["setlinfo"]["cvlserv_pay"];//公务员医疗补助资金支出
+
+                //setlinfo.hifes_pay = Outlog["output"]["setlinfo"]["hifes_pay"];//企业补充医疗保险基金支出
+                //setlinfo.hifmi_pay = Outlog["output"]["setlinfo"]["hifmi_pay"];//居民大病保险资金支出
+                //setlinfo.hifob_pay = Outlog["output"]["setlinfo"]["hifob_pay"];//职工大额医疗费用补助基金支出
+                //setlinfo.maf_pay = Outlog["output"]["setlinfo"]["maf_pay"];//医疗救助基金支出
+                //setlinfo.oth_pay = Outlog["output"]["setlinfo"]["oth_pay"];//结算ID
+
+                //setlinfo.fund_pay_sumamt = Outlog["output"]["setlinfo"]["fund_pay_sumamt"];//基金支付总额
+                //setlinfo.psn_part_amt = Outlog["output"]["setlinfo"]["psn_part_amt"];//个人负担总金额
+                //setlinfo.acct_pay = Outlog["output"]["setlinfo"]["acct_pay"];//个人账户支出
+                //setlinfo.psn_cash_pay = Outlog["output"]["setlinfo"]["psn_cash_pay"];//个人现金支出
+                //setlinfo.balc = Outlog["output"]["setlinfo"]["balc"];//余额
+
+                //setlinfo.acct_mulaid_pay = Outlog["output"]["setlinfo"]["acct_mulaid_pay"];//个人账户共济支付金额
+                //setlinfo.medins_setl_id = Outlog["output"]["setlinfo"]["medins_setl_id"];//医药机构结算结算ID
+                //setlinfo.clr_optins = Outlog["output"]["setlinfo"]["clr_optins"];//clr_optins
+                //setlinfo.clr_way = Outlog["output"]["setlinfo"]["clr_way"];//clr_way
+                //setlinfo.clr_type = Outlog["output"]["setlinfo"]["clr_type"];//clr_type
+
+                //// setlinfo.exp_content = Outlog["output"]["setlinfo"]["exp_content"];//exp_content
+                //setlinfo.exp_content = "";//exp_content
+                //setlinfo.hosp_part_amt = Outlog["output"]["setlinfo"]["hosp_part_amt"];//医院负担金额
+                //setlinfo.hifdm_pay = 0;//伤残人员医疗保障基金支出
+
+
 
                 string outParam = "";
                 //获取IS费用
@@ -902,22 +1536,34 @@ namespace PTMedicalInsurance.Forms
                     MessageBox.Show("获取HIS费用医保对照关系失败");
                 }
                 JArray jaFeeDetail = JArray.Parse(JsonHelper.getDestValue(JObject.Parse(outParam), "data"));
-                
-                 JObject jaFeeOne=new  JObject();
-                for (int i = 0; i < jaFeeDetail.Count; i++)
-                {
-                    jaFeeOne.Add("feedetl_sn", jaFeeDetail[i]["feedetl_sn"]);//费用明细流水号
+                JArray jaFeeDetail1 = new JArray();
+;                JObject jaFeeOne = new JObject();
+     
+                for (int k = 0; k < jaFeeDetail.Count; k++)
+                {   if (!(jaFeeDetail[k]["med_list_codg"].ToString().Substring(0, 1) == "X" || jaFeeDetail[k]["med_list_codg"].ToString().Substring(0, 1) == "Z")) continue;
+                    jaFeeOne.Add("feedetl_sn", jaFeeDetail[k]["feedetl_sn"]);//费用明细流水号
                     jaFeeOne.Add("rxno", "");//处方号
                     if (string.IsNullOrEmpty(jaFeeDetail[i]["rx_circ_flag"].ToString()))
                     {
-                        jaFeeOne.Add("rx_circ_flag", "");//外购处方标志
+                        jaFeeOne.Add("rx_circ_flag", "0");//外购处方标志
                     }
                     else
                     {
-                        jaFeeOne.Add("rx_circ_flag", jaFeeDetail[i]["rx_circ_flag"]);//外购处方标志
+                        jaFeeOne.Add("rx_circ_flag", jaFeeDetail[k]["rx_circ_flag"].ToString());//外购处方标志
+                    }
+                   
+                   
+        
+                    if (BillType == "-1")
+                    {
+                        jaFeeOne.Add("fee_ocur_time", setlinfo.setl_time);
                     }
-                    jaFeeOne.Add("fee_ocur_time", jaFeeDetail[i]["fee_ocur_time"]);
-                    jaFeeOne.Add("med_list_codg", jaFeeDetail[i]["med_list_codg"]);
+                    else{
+                        jaFeeOne.Add("fee_ocur_time", jaFeeDetail[k]["fee_ocur_time"]);
+
+                    }
+
+                    jaFeeOne.Add("med_list_codg", jaFeeDetail[k]["med_list_codg"]);
 
                     jaFeeOne.Add("medins_list_codg", jaFeeDetail[i]["medins_list_codg"]);
                     jaFeeOne.Add("medins_list_name", jaFeeDetail[i]["medins_list_desc"]);
@@ -945,9 +1591,9 @@ namespace PTMedicalInsurance.Forms
                     }
 
 
-                    jaFeeOne.Add(" det_item_fee_sumamt", jaFeeDetail[i]["det_item_fee_sumamt"]);
-                    jaFeeOne.Add("cnt", jaFeeDetail[i]["cnt"]);
-                    jaFeeOne.Add("pric", jaFeeDetail[i]["pric"]);
+                    jaFeeOne.Add("det_item_fee_sumamt", decimal.Parse(jaFeeDetail[k]["det_item_fee_sumamt"].ToString()));
+                    jaFeeOne.Add("cnt", decimal.Parse(jaFeeDetail[k]["cnt"].ToString()));
+                    jaFeeOne.Add("pric", decimal.Parse(jaFeeDetail[k]["pric"].ToString()));
 
                     if (string.IsNullOrEmpty(jaFeeDetail[i]["sin_dos_dscr"].ToString()))
                     {
@@ -970,11 +1616,11 @@ namespace PTMedicalInsurance.Forms
 
                     if (string.IsNullOrEmpty(jaFeeDetail[i]["prd_days"].ToString()))
                     {
-                        jaFeeOne.Add("prd_days", "");
+                        jaFeeOne.Add("prd_days", 1);
                     }
                     else
                     {
-                        jaFeeOne.Add("prd_days", jaFeeDetail[i]["prd_days"]);
+                        jaFeeOne.Add("prd_days", decimal.Parse(jaFeeDetail[k]["prd_days"].ToString()));
                     }
                     MessageBox.Show("555");
                     if (string.IsNullOrEmpty(jaFeeDetail[i]["medc_way_dscr"].ToString()))
@@ -1006,18 +1652,30 @@ namespace PTMedicalInsurance.Forms
                     jaFeeOne.Add("phar_name", "");
 
                     jaFeeOne.Add("phar_prac_cert_no", "");
-                    jaFeeOne.Add("tcmdrug_used_way", ""); //中药使用方式 1复方 2单方 必填
-                    jaFeeOne.Add("trdn_flag", "1");//拆零标志 必填 0否  1是
-                    jaFeeDetail.Add(jaFeeOne);
+                    jaFeeOne.Add("tcmdrug_used_way", "1"); //中药使用方式 1复方 2单方 必填
+
+
+                  jaFeeOne.Add("trdn_flag", joHisFee["result"][k]["outApartFlag"].ToString());//拆零标志 必填 0否  1是
+                  
+                    
+                    jaFeeDetail1.Add(jaFeeOne);
 
                     jaFeeOne = new JObject();
                     MessageBox.Show("777");
                 }
-                JObject Jo992001 = new JObject();
-                Jo992001.Add("setlinfo",JObject.Parse(setlinfo));//结算信息节点
-                Jo992001.Add("drugdetail", jaFeeDetail);//购药明细节点 
-                MessageBox.Show("上传开始:" + Jo992001.ToString());
-                JObject OutJo = invoker.invokeCenterServiceJXC("992001", JObject.Parse(JsonHelper.setCenterInpar("992001", Jo992001)));
+          
+                JObject Jo992004 = new JObject();
+               // JObject Jo992001 = new JObject();
+         
+       
+                //Jo992001.Add("setlinfo",JObject.Parse(setlinfo));//结算信息节点
+
+                Jo992004.Add("setlinfo", setlinfo);
+                Jo992004.Add("drugdetail", jaFeeDetail1);//结算信息节点
+   
+                //Jo992001.Add("drugdetail", jaFeeDetail);//购药明细节点 
+                MessageBox.Show("上传开始:" + Jo992004.ToString());
+                JObject OutJo = invoker.invokeCenterServiceJXC("9920004", JObject.Parse(JsonHelper.setCenterInpar("992004", Jo992004)));
                 MessageBox.Show("上传返回:" + OutJo.ToString());
             }
             catch (Exception ex)
@@ -1026,6 +1684,96 @@ namespace PTMedicalInsurance.Forms
                 return;
             }
         }
+
+
+        private void cityDesignToolStripMenuItem_Click(object sender, EventArgs e)
+        {
+            //try
+            //{
+            //    Thread thread = new Thread(new ThreadStart(design));
+            //    thread.SetApartmentState(ApartmentState.STA); //重点
+            //    thread.Start();
+            //    thread.Join();
+            //}
+            //catch (Exception ex)
+            //{
+            //    Global.writeLog("结算单设计预览异常:" + ex.Message);
+            //    MessageBox.Show("设计预览异常:" + ex.Message);
+            //}
+            if (dgvSettlRecord.RowCount <= 0)
+            {
+                MessageBox.Show("请先查询结算数据!");
+                return;
+            }
+
+            try
+            {
+                int i = dgvSettlRecord.CurrentRow.Index;
+                DataTable dt = (DataTable)dgvSettlRecord.DataSource;
+                Global.pat.admType = int.Parse(dgvSettlRecord.Rows[i].Cells["admType"].Value.ToString());
+                string AdmID = dt.Rows[i]["AdmID"].ToString();
+                string SettlementID = dt.Rows[i]["SettlementID"].ToString();
+                string ValidFlag = dt.Rows[i]["ValidFlag"].ToString();
+                string MdtrtID = dt.Rows[i]["MdtrtID"].ToString();
+                string BillType = dt.Rows[i]["BillType"].ToString();
+                JObject pJoInparm= new JObject();
+                pJoInparm.Add("MdtrtCertType", dt.Rows[i]["MdtrtCertType"].ToString());
+                JObject joRtn = cityGetFastReportParams("Y", AdmID, MdtrtID, SettlementID, ValidFlag, BillType, pJoInparm);
+
+                if (JsonHelper.parseIrisRtnValue(joRtn, out string errMsg) != 0)
+                {
+                    MessageBox.Show("获取FastReport入参失败:" + errMsg);
+                    return;
+                }
+
+                string sFastReportParam = JsonHelper.getDestValue(joRtn, "result");
+                if (FastReportPrint(sFastReportParam, out errMsg) != 0)
+                {
+                    MessageBox.Show("调用FastReport设计失败!" + errMsg);
+                    return;
+                }
+            }
+            catch (Exception ex)
+            {
+                MessageBox.Show(ex.Message);
+                return;
+            }
+        }
+
+        private void cityToolStripMenuItem_Click(object sender, EventArgs e)
+        {
+            string errorMsg;
+            int iHis = dgvSettlRecord.CurrentRow.Index;
+            String BType = dgvSettlRecord.Rows[iHis].Cells["BillType"].Value.ToString();
+            Global.pat.admType = int.Parse(dgvSettlRecord.Rows[iHis].Cells["admType"].Value.ToString());
+
+
+            JObject joData = new JObject();
+            joData.Add("mdtrt_id", dgvSettlRecord.Rows[iHis].Cells["MdtrtID"].Value.ToString());
+            joData.Add("setl_id", dgvSettlRecord.Rows[iHis].Cells["SettlementID"].Value.ToString());
+            joData.Add("psn_no", dgvSettlRecord.Rows[iHis].Cells["PersonnelNO"].Value.ToString());
+            joData.Add("med_type", dgvSettlRecord.Rows[iHis].Cells["MedicalType"].Value.ToString());
+            JObject joInput = new JObject();
+            joInput.Add("data", joData);
+            Global.pat.insuplc_admdvs = dgvSettlRecord.Rows[iHis].Cells["insuplc_admdvs"].Value.ToString();//更新参保地
+                #region【调用FastRepor打印】
+                try
+                {
+                    //Thread thread = new Thread(new ThreadStart(print));
+                    //thread.SetApartmentState(ApartmentState.STA); //重点
+                    //thread.Start();
+                    //thread.Join();
+                    cityPrint();
+                }
+                catch (Exception ex)
+                {
+                    Global.writeLog("结算单打印异常:" + ex.Message);
+                    MessageBox.Show("打印异常:" + ex.Message);
+                }
+
+                #endregion
+            
+        }
  }
 
     // Root myDeserializedClass = JsonConvert.DeserializeObject<Root>(myJsonResponse);

+ 59 - 26
HuBeiMI/Forms/SettlementChecklist.designer.cs

@@ -36,6 +36,12 @@
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SettlementChecklist));
             this.panel1 = new System.Windows.Forms.Panel();
             this.dgvSettlRecord = new Sunny.UI.UIDataGridView();
+            this.JXCMenuStrip = new Sunny.UI.UIContextMenuStrip();
+            this.市医保进销存992001结算信息上传ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+            this.SYBJXCTFToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+            this.FYMXToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+            this.cityToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+            this.cityDesignToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.pgSettlRecod = new Sunny.UI.UIPagination();
             this.uiPanel1 = new Sunny.UI.UIPanel();
             this.btnClose = new Sunny.UI.UIButton();
@@ -53,9 +59,6 @@
             this.gbDateTime = new Sunny.UI.UIGroupBox();
             this.dpED = new Sunny.UI.UIDatetimePicker();
             this.dpST = new Sunny.UI.UIDatetimePicker();
-            this.report1 = new FastReport.Report();
-            this.JXCMenuStrip = new Sunny.UI.UIContextMenuStrip();
-            this.市医保进销存992001结算信息上传ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.panel1.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.dgvSettlRecord)).BeginInit();
             this.uiPanel1.SuspendLayout();
@@ -127,6 +130,55 @@
             this.dgvSettlRecord.TabIndex = 3;
             this.dgvSettlRecord.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
             // 
+            // JXCMenuStrip
+            // 
+            this.JXCMenuStrip.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(243)))), ((int)(((byte)(249)))), ((int)(((byte)(255)))));
+            this.JXCMenuStrip.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.JXCMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+            this.市医保进销存992001结算信息上传ToolStripMenuItem,
+            this.SYBJXCTFToolStripMenuItem,
+            this.FYMXToolStripMenuItem,
+            this.cityToolStripMenuItem,
+            this.cityDesignToolStripMenuItem});
+            this.JXCMenuStrip.Name = "JXCMenuStrip";
+            this.JXCMenuStrip.Size = new System.Drawing.Size(359, 156);
+            this.JXCMenuStrip.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
+            // 
+            // 市医保进销存992001结算信息上传ToolStripMenuItem
+            // 
+            this.市医保进销存992001结算信息上传ToolStripMenuItem.Name = "市医保进销存992001结算信息上传ToolStripMenuItem";
+            this.市医保进销存992001结算信息上传ToolStripMenuItem.Size = new System.Drawing.Size(358, 26);
+            this.市医保进销存992001结算信息上传ToolStripMenuItem.Text = "市医保进销存992001结算信息上传";
+            this.市医保进销存992001结算信息上传ToolStripMenuItem.Click += new System.EventHandler(this.JXCJSToolStripMenuItem_Click);
+            // 
+            // SYBJXCTFToolStripMenuItem
+            // 
+            this.SYBJXCTFToolStripMenuItem.Name = "SYBJXCTFToolStripMenuItem";
+            this.SYBJXCTFToolStripMenuItem.Size = new System.Drawing.Size(358, 26);
+            this.SYBJXCTFToolStripMenuItem.Text = "市医保进销存992002结算退费信息上传";
+            this.SYBJXCTFToolStripMenuItem.Click += new System.EventHandler(this.SYBJXCTFToolStripMenuItem_Click);
+            // 
+            // FYMXToolStripMenuItem
+            // 
+            this.FYMXToolStripMenuItem.Name = "FYMXToolStripMenuItem";
+            this.FYMXToolStripMenuItem.Size = new System.Drawing.Size(358, 26);
+            this.FYMXToolStripMenuItem.Text = "市医保进销存992004费用明细上传";
+            this.FYMXToolStripMenuItem.Click += new System.EventHandler(this.FYMXToolStripMenuItem_Click);
+            // 
+            // cityToolStripMenuItem
+            // 
+            this.cityToolStripMenuItem.Name = "cityToolStripMenuItem";
+            this.cityToolStripMenuItem.Size = new System.Drawing.Size(358, 26);
+            this.cityToolStripMenuItem.Text = "市医保结算单打印";
+            this.cityToolStripMenuItem.Click += new System.EventHandler(this.cityToolStripMenuItem_Click);
+            // 
+            // cityDesignToolStripMenuItem
+            // 
+            this.cityDesignToolStripMenuItem.Name = "cityDesignToolStripMenuItem";
+            this.cityDesignToolStripMenuItem.Size = new System.Drawing.Size(358, 26);
+            this.cityDesignToolStripMenuItem.Text = "市医保结算单报表设计";
+            this.cityDesignToolStripMenuItem.Click += new System.EventHandler(this.cityDesignToolStripMenuItem_Click);
+            // 
             // pgSettlRecod
             // 
             this.pgSettlRecod.Dock = System.Windows.Forms.DockStyle.Bottom;
@@ -417,29 +469,6 @@
             this.dpST.Value = new System.DateTime(2022, 5, 22, 14, 3, 13, 266);
             this.dpST.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
             // 
-            // report1
-            // 
-            this.report1.NeedRefresh = false;
-            this.report1.ReportResourceString = resources.GetString("report1.ReportResourceString");
-            this.report1.Tag = null;
-            // 
-            // JXCMenuStrip
-            // 
-            this.JXCMenuStrip.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(243)))), ((int)(((byte)(249)))), ((int)(((byte)(255)))));
-            this.JXCMenuStrip.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.JXCMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
-            this.市医保进销存992001结算信息上传ToolStripMenuItem});
-            this.JXCMenuStrip.Name = "JXCMenuStrip";
-            this.JXCMenuStrip.Size = new System.Drawing.Size(327, 30);
-            this.JXCMenuStrip.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
-            // 
-            // 市医保进销存992001结算信息上传ToolStripMenuItem
-            // 
-            this.市医保进销存992001结算信息上传ToolStripMenuItem.Name = "市医保进销存992001结算信息上传ToolStripMenuItem";
-            this.市医保进销存992001结算信息上传ToolStripMenuItem.Size = new System.Drawing.Size(326, 26);
-            this.市医保进销存992001结算信息上传ToolStripMenuItem.Text = "市医保进销存992001结算信息上传";
-            this.市医保进销存992001结算信息上传ToolStripMenuItem.Click += new System.EventHandler(this.JXCJSToolStripMenuItem_Click);
-            // 
             // SettlementChecklist
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
@@ -486,5 +515,9 @@
         private Sunny.UI.UIButton btnDesign;
         private Sunny.UI.UIContextMenuStrip JXCMenuStrip;
         private System.Windows.Forms.ToolStripMenuItem 市医保进销存992001结算信息上传ToolStripMenuItem;
+        private System.Windows.Forms.ToolStripMenuItem SYBJXCTFToolStripMenuItem;
+        private System.Windows.Forms.ToolStripMenuItem FYMXToolStripMenuItem;
+        private System.Windows.Forms.ToolStripMenuItem cityToolStripMenuItem;
+        private System.Windows.Forms.ToolStripMenuItem cityDesignToolStripMenuItem;
     }
 }

+ 54 - 3
HuBeiMI/InsuBusiness.cs

@@ -18,6 +18,9 @@ using System.Collections;
 using System.Data.SqlTypes;
 using Sunny.UI.Win32;
 using Sunny.UI;
+using PTMedicalInsurance.Forms.ElectronicSettlementCertificates;
+using System.Threading;
+using FastReport.Editor;
 
 using PTMedicalInsurance.Business.Core.SelfServiceMachine.ProcessScheduler;
 using PTMedicalInsurance.Business.Core.Forms.DischargeAudit;
@@ -1816,9 +1819,33 @@ namespace PTMedicalInsurance
                     //}
                     joRtn = invoker.invokeCenterServiceJXC(funNO, JObject.Parse(JsonHelper.setCenterInpar(funNO, joParam)));
 
-                    string funNOA = funNO + 'A';
-                   
-                    joRtn = invoker.invokeCenterService(funNOA, JsonHelper.setCenterInpar(funNOA, joParamA));
+                    //joRtn = invoker.invokeCenterServiceJXC2(funNO, JObject.Parse(JsonHelper.setCenterInpar(funNO, joParam)));】】
+
+
+                    if (funNO == "3505" || funNO == "3506")
+                    {
+                        if (!string.IsNullOrEmpty(joParam["selinfo"]["setl_id"].ToString()))
+                        {
+                            if (joParam["selinfo"]["setl_id"].ToString().Substring(0, 4) == "4299" || joParam["selinfo"]["setl_id"].ToString().Substring(0, 4) == "4201")
+                            {
+                                joParam["selinfo"]["hi_feesetl_type"] = "1";
+                                joRtn = invoker.invokeCenterService(funNO + 'A', JsonHelper.setCenterInpar(funNO + 'A', joParamA));
+                            }
+
+                        }
+                        else
+                        {
+                            joRtn = invoker.invokeCenterService(funNO + 'A', JsonHelper.setCenterInpar(funNO + 'A', joParamA));
+                        }
+
+                    }
+                    else
+                    {
+                        joRtn = invoker.invokeCenterService(funNO + 'A', JsonHelper.setCenterInpar(funNO + 'A', joParamA));
+                    }
+
+
+
 
                 }
                 else //非进销存交易
@@ -1877,6 +1904,12 @@ namespace PTMedicalInsurance
                     {
                         joParam["selinfo"]["hi_feesetl_type"] = "0";
                     }
+                    if(funno == "3506")
+                    {
+                        joParam["selinfo"]["fixmedins_bchno"] = joParam["selinfo"]["fixmedins_bchno"].ToString()+"-1".ToString();
+                        joParam["selinfo"]["rtal_docno"] = joParam["selinfo"]["init_rtal_docno"].ToString();
+                    }
+
                     JObject joRtn = JObject.Parse(joParam["selinfo"].ToString());
                     //if (!string.IsNullOrEmpty(joParam["selinfo"]["drugtracinfo"].ToString()))
                     //{
@@ -1961,6 +1994,24 @@ namespace PTMedicalInsurance
 
                     return 0;
                 }
+                else if (funno == "3507")
+                {
+                    JObject joRtn = JObject.Parse(joParam["data"].ToString());
+                    //if (!string.IsNullOrEmpty(joParam["purcinfo"]["drugtracinfo"].ToString()))
+                    //{
+                    //    joRtn.Add("drug_trac_info", joParam["purcinfo"]["drugtracinfo"]);
+                    //    joParam["purcinfo"] = joRtn;
+                    //}
+
+
+                    JArray selDtl = new JArray();
+                    selDtl.Add(JObject.Parse(joParam["data"].ToString()));
+                    //MessageBox.Show(selDtl.ToString());
+                    joParamA = new JObject();
+                    joParamA.Add("goodDetail", selDtl);
+
+                    return 0;
+                }
                 else { return -1; }
                 
             }