| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553 | using Newtonsoft.Json.Linq;using PTMedicalInsurance.Common;using PTMedicalInsurance.FormSetter;using PTMedicalInsurance.Helper;using PTMedicalInsurance.Variables;using System;using System.Data;using System.Windows.Forms;namespace PTMedicalInsurance.Forms{    public partial class SettlementBillPrint : Form    {        private int hospitalDr;        private int interfaceDr;        private string hospitalNO;        private string interfaceNO;        private string hospitalName;        private string hospitalAreaCode;        private InvokeHelper invoker = new InvokeHelper();        public SettlementBillPrint()        {            InitializeComponent();            hospitalDr = Global.inf.hospitalDr;            hospitalNO = Global.inf.hospitalNO;            hospitalName = Global.inf.hospitalName;            hospitalAreaCode = Global.inf.areaCode;            interfaceDr = Global.inf.interfaceDr;        }        public SettlementBillPrint(JObject joParam)        {            InitializeComponent();            hospitalDr = Global.inf.hospitalDr;            hospitalNO = Global.inf.hospitalNO;            hospitalName = Global.inf.hospitalName;            hospitalAreaCode = Global.inf.areaCode;            if (joParam == null) return;            string setl_id = JsonHelper.getDestValue(joParam, "setl_id");            if (setl_id == "")            {                MessageBox.Show("根据传入的结算编号为查询到相关信息,请手动输入查询!");                return;            }            string sqlStr = "SELECT * FROM  BS_MedInsuSettlement WHERE Hospital_Dr=" + Global.inf.hospitalDr;            sqlStr = sqlStr + " and SettlementID='" + setl_id + "'";            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");            InvokeHelper invoker = new InvokeHelper();            JObject joRtn = invoker.invokeInsuService(joSettlQuery.ToString(), "查询结算信息");            DataTable dt = (DataTable)joRtn["result"]["data"].ToObject(typeof(DataTable));            dgvSettlRecord.DataSource = dt;        }        private void SettlementBillPrint_Load(object sender, EventArgs e)        {            dpST.Text = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");            dpED.Text = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");            ComboxSetter cbxSetter = new ComboxSetter();            cbxSetter.setCbxInterfaceDataSource(cbxInterface);            GridViewSetter grdSetter = new GridViewSetter();            grdSetter.SetHeaderTextOfSettlList(dgvSettlRecord);            rbgAdmType.SelectedIndex = 0;            rbgBillType.SelectedIndex = 1;            //cbxInterface.SelectedValueChanged += new EventHandler(cbxInterface_SelectedValueChanged);        }        private void cbxInterface_SelectedValueChanged(object sender, EventArgs e)        {            DataTable dt = (DataTable)cbxInterface.DataSource;            int i = cbxInterface.SelectedIndex;            if (i >= 0)            {                //赋值                hospitalNO = dt.Rows[i]["HospitalNO"].ToString();                //MessageBox.Show(dt.Rows[i]["HospitalDr"].ToString());                //MessageBox.Show(dt.Rows[i]["HospitalDr"].ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);                hospitalDr = int.Parse(dt.Rows[i]["HospitalDr"].ToString());                interfaceNO = dt.Rows[i]["InterfaceNO"].ToString();                interfaceDr = int.Parse(dt.Rows[i]["ID"].ToString());                hospitalAreaCode = dt.Rows[i]["AreaCode"].ToString();                //Global.inf.centerURL = dt.Rows[i]["CenterURL"].ToString();                //Global.inf.businessDllName = dt.Rows[i]["DLLName"].ToString();                //Global.inf.patientAreaCode = dt.Rows[i]["AreaCode"].ToString();                }        }        private void btnClose_Click(object sender, EventArgs e)        {            Close();        }        private void btnQuery_Click(object sender, EventArgs e)        {            string sqlStr = " SELECT * FROM  BS_MedInsuSettlement WHERE Hospital_Dr=" + hospitalDr;            sqlStr = sqlStr + " and OccurTime>'" + dpST.Text + "'";            sqlStr = sqlStr + " and OccurTime<'" + dpED.Text + "'";            if (tbName.Text != "")            {                sqlStr = sqlStr + " and PatientName='" + tbName.Text + "'";            }            if (tbPatSettlID.Text != "")            {                sqlStr = sqlStr + " and SettlementID='" + tbPatSettlID.Text + "'";            }            if (tbHisNO.Text != "")            {                sqlStr = sqlStr + " and Adm_Dr='" + tbHisNO.Text + "'";            }            if (cbxInterface.Text != "")            {                sqlStr = sqlStr + " and Interface_Dr=" + Global.inf.interfaceDr + "";            }            if (rbgAdmType.SelectedIndex == 1)            {                sqlStr = sqlStr + " and AdmType=2";            }            if (rbgAdmType.SelectedIndex == 2)            {                sqlStr = sqlStr + " and AdmType=1";            }            if (rbgBillType.SelectedIndex == 1)            {                sqlStr = sqlStr + " and BillType=1 and ValidFlag=1 ";            }            if (rbgBillType.SelectedIndex == 2)            {                sqlStr = sqlStr + " and BillType=-1 and ValidFlag=0 ";            }            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));            dgvSettlRecord.DataSource = dt;        }        public void btnPrint_Click(object sender, EventArgs e)        {            if (dgvSettlRecord.RowCount <= 0)            {                MessageBox.Show("请先查询结算数据!");                return;            }            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();                JObject joRtn = GetFastReportParams("", AdmID, MdtrtID, SettlementID, ValidFlag);                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;            }        }               public void btnDesign_Click(object sender, EventArgs e)        {            if (dgvSettlRecord.RowCount <= 0)            {                MessageBox.Show("请先查询结算数据!");                return;            }            try            {                string errMsg;                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 PsnNo = dt.Rows[i]["PersonnelNO"].ToString();                //更新医保费用明细表                //JObject joRtnFee = UpdateMedInsuUploadData(AdmID, PsnNo, MdtrtID, SettlementID);                //if (JsonHelper.parseIrisRtnValue(joRtnFee, out errMsg) != 0)                //{                //    MessageBox.Show("更新医保费用明细表失败:" + errMsg);                //    return;                //}                JObject joRtn = GetFastReportParams("Y", AdmID, MdtrtID, SettlementID, ValidFlag);                if (JsonHelper.parseIrisRtnValue(joRtn, out 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;            }        }        public int FastReportPrint(string InParams,out string OutMsg)        {            Global.writeLog("调用FastReport入参:" + InParams);            try            {                #region【调用正版FastReport打印】                                FastReportFrom.FastReportDll FrDll = new FastReportFrom.FastReportDll();                string sRtnFr = FrDll.FastReport(InParams);                JObject joRetObj = JObject.Parse(sRtnFr);                if (JsonHelper.parseIrisRtnValue(joRetObj, out string errMsg) != 0)                {                    OutMsg = "调用FastReport打印失败!" + errMsg;                    return -1;                }                else                {                    OutMsg = "";                    return 0;                }                #endregion            }            catch (Exception ex)            {                OutMsg = "调用FastReport打印失败!" + ex.Message;                return -1;            }                    }        public JObject GetFastReportParams(string designFlag, string admID, string MdtrtID, string settlementID, string validFlag)        {            try            {                if (designFlag == "") { designFlag = "N"; }                #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("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【组织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"));                                //转换金额大写                string Sumamt = FastReportFunction.MoneyToUpper(JsonHelper.getDestValue(joRtnSettle, "result.data.settlement[0].Sumamt").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("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);                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", Global.inf.interfaceDr.ToString());                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;            }        }        /// <summary>        /// 【5204】费用明细查询更新医保费用上传记录表        /// </summary>        /// <returns></returns>        public JObject UpdateMedInsuUploadData(string AdmID, string psnNo, string MdtrtID, string SettlementID)        {            string errorMsg, outParam;            if (AdmID == "")            {                return JObject.Parse(JsonHelper.setExceptionJson(-1, "", "AdmID不能为空!").ToString());            }            if (psnNo == "")            {                return JObject.Parse(JsonHelper.setExceptionJson(-1, "", "psnNo不能为空!").ToString());            }            if (MdtrtID == "")            {                return JObject.Parse(JsonHelper.setExceptionJson(-1, "", "MdtrtID不能为空!").ToString());            }            if (SettlementID == "")            {                return JObject.Parse(JsonHelper.setExceptionJson(-1, "", "settlementID不能为空!").ToString());            }            if (Global.inf.hospitalDr.ToString() == "")            {                                return JObject.Parse(JsonHelper.setExceptionJson(-1, "", "hospitalDr不能为空!").ToString());            }            try            {                #region【5204】费用明细查询                JObject joData = new JObject();                joData.Add("psn_no", psnNo);                joData.Add("setl_id", SettlementID);                joData.Add("mdtrt_id", MdtrtID);                JObject joInput = new JObject();                joInput.Add("data", joData);                JObject joRtn5204 = invoker.invokeCenterService("5204", JsonHelper.setCenterInpar("5204", joInput));                if (JsonHelper.parseCenterRtnValue(joRtn5204, out errorMsg) != 0)                {                                        outParam = JsonHelper.setExceptionJson(-1, "【5204】费用明细查询失败!", errorMsg).ToString();                    return JObject.Parse(outParam);                                    }                #endregion                JArray jaRtn5204 = JArray.Parse(JsonHelper.getDestValue(joRtn5204, "output"));                if (jaRtn5204.Count <= 0)                                                {                    return JObject.Parse(JsonHelper.setExceptionJson(-1, "", "【5204】医保费用明细查询返回结果为空!").ToString());                }                dynamic joTmp = new JObject();                joTmp.code = "09010090";                JArray jaParams = jaRtn5204;                joTmp.Add("params", jaParams);                joTmp.HospitalDr = Global.inf.hospitalDr;                joTmp.InterfaceDr = Global.inf.interfaceDr_TY; //如果是通用目录就更新通用目录                 joTmp.admID = AdmID;                joTmp.mdtrt_id = MdtrtID;                joTmp.psn_no = psnNo;                joTmp.updateUserID = Global.user.ID;                JObject joRtn = invoker.invokeInsuService(joTmp.ToString(), "更新医保费用上传明细表");                if (JsonHelper.parseIrisRtnValue(joRtn, out errorMsg) != 0)                {                    outParam = JsonHelper.setExceptionJson(-1, "更新医保费用上传明细表失败!", errorMsg).ToString();                    return JObject.Parse(outParam);                }                else                {                    return joRtn;                }            }            catch (Exception ex)            {                JObject joRtnEx = new JObject();                joRtnEx.Add("errorCode", -1);                joRtnEx.Add("errorMessage", ex.Message);                return joRtnEx;            }        }        private JObject getPatCheckList()        {            try            {                int i = dgvSettlRecord.CurrentRow.Index;                DataTable dt = (DataTable)dgvSettlRecord.DataSource;                JObject joSettel = new JObject();                joSettel.Add("HospitalDr", Global.inf.hospitalDr);                joSettel.Add("interfaceDr", Global.inf.interfaceDr);                joSettel.Add("admID", dt.Rows[i]["AdmID"].ToString());                joSettel.Add("SettlementID", dt.Rows[i]["SettlementID"].ToString());                joSettel.Add("ValidFlag", dt.Rows[i]["ValidFlag"].ToString());                JObject joRtn = invoker.invokeInsuService(JsonHelper.setIrisInpar("09010066", joSettel).ToString(), "获取结算单信息");                return joRtn;            }            catch (Exception ex)            {                JObject joRtn = new JObject();                joRtn.Add("errorCode", -1);                joRtn.Add("errorMessage", ex.Message);                return joRtn;            }        }        private void btn_UpdateMedInsuFee_Click(object sender, EventArgs e)        {            string errorMsg;            if (dgvSettlRecord.RowCount <= 0)            {                MessageBox.Show("请先查询结算数据!");                return;            }            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 MdtrtID = dt.Rows[i]["MdtrtID"].ToString();            string PsnNo = dt.Rows[i]["PersonnelNO"].ToString();            #region【5204】1.医保费用明细查询  2.更新医保平台费用上传明细表                                JObject joRtnFee = UpdateMedInsuUploadData(AdmID, PsnNo, MdtrtID, SettlementID);            if (JsonHelper.parseIrisRtnValue(joRtnFee, out errorMsg) != 0)            {                MessageBox.Show("更新医保费用明细表失败:" + errorMsg);                return;            }            else            {                MessageBox.Show("更新医保费用明细表成功");            }            #endregion        }    }}
 |