SettlementChecklist.cs 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using PTMedicalInsurance.Helper;
  11. using PTMedicalInsurance.Common;
  12. using Newtonsoft.Json.Linq;
  13. using PTMedicalInsurance.FormSetter;
  14. using PTMedicalInsurance.Variables;
  15. using FastReport;
  16. using Newtonsoft.Json;
  17. using System.Threading;
  18. using PTMedicalInsurance.Business;
  19. using Spire.Pdf;
  20. using System.IO;
  21. using Spire.Pdf.Print;
  22. namespace PTMedicalInsurance.Forms
  23. {
  24. public partial class SettlementChecklist : Form
  25. {
  26. private int hospitalDr;
  27. private int interfaceDr;
  28. private string hospitalNO;
  29. private string interfaceNO;
  30. private string hospitalName;
  31. private string hospitalAreaCode;
  32. private bool disposed = false;
  33. private bool showDrgPrint = false;
  34. Thread thread_test;
  35. private InvokeHelper invoker = new InvokeHelper();
  36. public SettlementChecklist()
  37. {
  38. InitializeComponent();
  39. hospitalDr = Global.inf.hospitalDr;
  40. hospitalNO = Global.inf.hospitalNO;
  41. hospitalName = Global.inf.hospitalName;
  42. hospitalAreaCode = Global.inf.areaCode;
  43. interfaceDr = Global.inf.interfaceDr;
  44. }
  45. public SettlementChecklist(JObject joParam)
  46. {
  47. InitializeComponent();
  48. hospitalDr = Global.inf.hospitalDr;
  49. hospitalNO = Global.inf.hospitalNO;
  50. hospitalName = Global.inf.hospitalName;
  51. hospitalAreaCode = Global.inf.areaCode;
  52. if (joParam == null) return;
  53. Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joParam, "insuplc_admdvs");
  54. string setl_id = JsonHelper.getDestValue(joParam, "setl_id");
  55. if (setl_id == "")
  56. {
  57. MessageBox.Show("根据传入的结算编号为查询到相关信息,请手动输入查询!");
  58. return;
  59. }
  60. string sqlStr = "SELECT * FROM SQLUser.BS_MedInsuSettlement WHERE Hospital_Dr=" + Global.inf.hospitalDr;
  61. sqlStr = sqlStr + " and SettlementID='" + setl_id + "'";
  62. JObject joSqlStr = new JObject();
  63. joSqlStr.Add("sqlStr", sqlStr);
  64. MIIrisServices mIS = new MIIrisServices();
  65. JObject joRtn = mIS.QuerySettlementInfo(joSqlStr);
  66. DataTable dt = (DataTable)joRtn["result"]["data"].ToObject(typeof(DataTable));
  67. dgvSettlRecord.DataSource = dt;
  68. }
  69. private string getTemplatePath()
  70. {
  71. if (Utils.isOtherCity())
  72. {
  73. return Global.curEvt.path + "\\frx\\settlement_other.frx";
  74. }
  75. return Global.curEvt.path + "\\frx\\settlement.frx";
  76. }
  77. public void Dispose()
  78. {
  79. Dispose1(true);
  80. GC.SuppressFinalize(this);
  81. }
  82. protected virtual void Dispose1(bool disposing)
  83. {
  84. if (thread_test == null) return;
  85. if (disposed == false)
  86. {
  87. if (disposing == true)
  88. {
  89. Thread.Sleep(100);
  90. Global.writeLog("Main - aborting my thread.");
  91. thread_test.Abort();//终止线程myThread
  92. thread_test.Join();//等待线程myThread结束
  93. Global.writeLog("Main - ending.");
  94. }
  95. //释放托管资源的代码
  96. }
  97. disposed = true;
  98. }
  99. private void rbgDirecType_ValueChanged(object sender, int index, string text)
  100. {
  101. }
  102. private void btnQuery_Click(object sender, EventArgs e)
  103. {
  104. }
  105. private void btnQuery_Click_1(object sender, EventArgs e)
  106. {
  107. string sqlStr = " SELECT * FROM BS_MedInsuSettlement WHERE Hospital_Dr=" + hospitalDr;
  108. sqlStr = sqlStr + " and OccurTime>'" + dpST.Text + "'";
  109. sqlStr = sqlStr + " and OccurTime<'" + dpED.Text + "'";
  110. if (tbName.Text != "")
  111. {
  112. sqlStr = sqlStr + " and PatientName='" + tbName.Text + "'";
  113. }
  114. if (tbPatSettlID.Text != "")
  115. {
  116. sqlStr = sqlStr + " and SettlementID='" + tbPatSettlID.Text + "'";
  117. }
  118. if (tbHisNO.Text != "")
  119. {
  120. sqlStr = sqlStr + " and Adm_Dr='" + tbHisNO.Text + "'";
  121. }
  122. if (cbxInterface.Text != "")
  123. {
  124. sqlStr = sqlStr + " and Interface_Dr=" + Global.inf.interfaceDr + "";
  125. }
  126. if (rbgAdmType.SelectedIndex == 1)
  127. {
  128. sqlStr = sqlStr + " and AdmType=2";
  129. }
  130. if (rbgAdmType.SelectedIndex == 2)
  131. {
  132. sqlStr = sqlStr + " and AdmType=1";
  133. }
  134. if (rbgBillType.SelectedIndex == 1)
  135. {
  136. sqlStr = sqlStr + " and BillType=1 and ValidFlag=1 ";
  137. }
  138. if (rbgBillType.SelectedIndex == 2)
  139. {
  140. sqlStr = sqlStr + " and BillType=-1 and ValidFlag=0 ";
  141. }
  142. JObject joSqlStr = new JObject();
  143. joSqlStr.Add("sqlStr", sqlStr);
  144. MIIrisServices mIS = new MIIrisServices();
  145. JObject joRtn = mIS.QuerySettlementInfo(joSqlStr);
  146. DataTable dt = (DataTable)joRtn["result"]["data"].ToObject(typeof(DataTable));
  147. dgvSettlRecord.DataSource = dt;
  148. }
  149. public void ShowDrgPrint()
  150. {
  151. showDrgPrint = true;
  152. }
  153. private void SettlementChecklist_Load(object sender, EventArgs e)
  154. {
  155. dpST.Text = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  156. dpED.Text = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  157. ComboxSetter cbxSetter = new ComboxSetter();
  158. cbxSetter.setCbxInterfaceDataSource(cbxInterface);
  159. GridViewSetter grdSetter = new GridViewSetter();
  160. grdSetter.SetHeaderTextOfSettlList(dgvSettlRecord);
  161. rbgAdmType.SelectedIndex = 0;
  162. rbgBillType.SelectedIndex = 1;
  163. cbxInterface.SelectedValueChanged += new EventHandler(cbxInterface_SelectedValueChanged);
  164. btnDrgPrint.Visible = false;
  165. if(showDrgPrint)
  166. {
  167. btnPrint.Visible = false;
  168. btnDrgPrint.Visible = true;
  169. }
  170. }
  171. private void cbxInterface_SelectedValueChanged(object sender, EventArgs e)
  172. {
  173. DataTable dt = (DataTable)cbxInterface.DataSource;
  174. int i = cbxInterface.SelectedIndex;
  175. //赋值
  176. hospitalNO = dt.Rows[i]["HospitalNO"].ToString();
  177. //MessageBox.Show(dt.Rows[i]["HospitalDr"].ToString());
  178. //MessageBox.Show(dt.Rows[i]["HospitalDr"].ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
  179. hospitalDr = int.Parse(dt.Rows[i]["HospitalDr"].ToString());
  180. interfaceNO = dt.Rows[i]["InterfaceNO"].ToString();
  181. interfaceDr = int.Parse(dt.Rows[i]["ID"].ToString());
  182. hospitalAreaCode = dt.Rows[i]["AreaCode"].ToString();
  183. //Global.inf.centerURL = dt.Rows[i]["CenterURL"].ToString();
  184. //Global.inf.businessDllName = dt.Rows[i]["DLLName"].ToString();
  185. //Global.inf.patientAreaCode = dt.Rows[i]["AreaCode"].ToString();
  186. }
  187. private JObject getPatCheckList()
  188. {
  189. try
  190. {
  191. if (dgvSettlRecord.CurrentRow == null)
  192. {
  193. // mock data
  194. var root = new Root();
  195. root.result = new Result();
  196. root.result.data = new Data();
  197. root.result.data.classification = new List<Classification>() { new Classification() };
  198. root.result.data.settlement = new List<Settlement>() { new Settlement() };
  199. root.result.data.reginfo = new List<Reginfo>() { new Reginfo() };
  200. root.result.data.patinsuinfo = new List<Patinsuinfo>() { new Patinsuinfo() };
  201. return JObject.Parse(JsonHelper.toJsonString(root));
  202. }
  203. int i = dgvSettlRecord.CurrentRow.Index;
  204. DataTable dt = (DataTable)dgvSettlRecord.DataSource;
  205. JObject joSettel = new JObject();
  206. joSettel.Add("HospitalDr", Global.inf.hospitalDr);
  207. joSettel.Add("interfaceDr", Global.inf.interfaceDr);
  208. joSettel.Add("admID", dt.Rows[i]["AdmID"].ToString());
  209. joSettel.Add("SettlementID", dt.Rows[i]["SettlementID"].ToString());
  210. joSettel.Add("ValidFlag", dt.Rows[i]["ValidFlag"].ToString());
  211. JObject joRtn = invoker.invokeInsuService(JsonHelper.setIrisInpar("09010066", joSettel).ToString(), "获取结算单信息");
  212. return joRtn;
  213. }
  214. catch (Exception ex)
  215. {
  216. JObject joRtn = new JObject();
  217. joRtn.Add("errorCode", -1);
  218. joRtn.Add("errorMessage", ex.Message);
  219. return joRtn;
  220. }
  221. }
  222. private void uiPanel1_Click(object sender, EventArgs e)
  223. {
  224. }
  225. [STAThread]
  226. public void design()
  227. {
  228. try
  229. {
  230. FastReportFunction.Register();
  231. string chineseSimpleFrl = Global.curEvt.path + @"\Chinese (Simplified).frl";
  232. FastReport.Utils.Res.LoadLocale(chineseSimpleFrl);
  233. //string errMsg;
  234. //if (JsonHelper.parseIrisRtnValue(joSettleCheckList, out errMsg) != 0)
  235. //{
  236. // MessageBox.Show("查询结算信息异常:" + errMsg);
  237. // return;
  238. //}
  239. Report report = new Report();
  240. try
  241. {
  242. var json = JsonConvert.DeserializeObject<Root>(getPatCheckList().ToString());
  243. report.RegisterData(json.result.data.classification, "classification");
  244. report.RegisterData(json.result.data.settlement, "settlement");
  245. report.RegisterData(json.result.data.reginfo, "reginfo");
  246. report.RegisterData(json.result.data.patinsuinfo, "patinsuinfo");
  247. }
  248. catch (Exception ex)
  249. {
  250. MessageBox.Show(ex.Message);
  251. return;
  252. }
  253. report.Load(getTemplatePath());
  254. PrintDesign pf = new PrintDesign();
  255. pf.designerControl1.Report = report;
  256. report.Design();
  257. pf.WindowState = FormWindowState.Maximized;
  258. pf.ShowDialog();
  259. }
  260. catch (Exception ex)
  261. {
  262. MessageBox.Show(ex.Message);
  263. }
  264. }
  265. [STAThread]
  266. private void print()
  267. {
  268. try
  269. {
  270. FastReportFunction.Register();
  271. string chineseSimpleFrl = Global.curEvt.path + @"\Chinese (Simplified).frl";
  272. FastReport.Utils.Res.LoadLocale(chineseSimpleFrl);
  273. JObject joSettleCheckList = getPatCheckList();
  274. string errMsg;
  275. if (JsonHelper.parseIrisRtnValue(joSettleCheckList, out errMsg) != 0)
  276. {
  277. MessageBox.Show("查询结算信息异常:" + errMsg);
  278. return;
  279. }
  280. Report report = new Report();
  281. var json = JsonConvert.DeserializeObject<Root>(getPatCheckList().ToString());
  282. report.RegisterData(json.result.data.classification, "classification");
  283. report.RegisterData(json.result.data.settlement, "settlement");
  284. report.RegisterData(json.result.data.reginfo, "reginfo");
  285. report.RegisterData(json.result.data.patinsuinfo, "patinsuinfo");
  286. report.Load(getTemplatePath());
  287. this.ShowInTaskbar = true;
  288. PrintPreview pf = new PrintPreview();
  289. report.Preview = pf.previewControl1;
  290. report.Show();
  291. pf.WindowState = FormWindowState.Maximized;
  292. pf.ShowDialog();
  293. }
  294. catch (Exception ex)
  295. {
  296. MessageBox.Show(ex.Message);
  297. return;
  298. }
  299. }
  300. [STAThread]
  301. private void preview()
  302. {
  303. FastReportFunction.Register();
  304. Report report = new Report();
  305. try
  306. {
  307. var json = JsonConvert.DeserializeObject<Root>(getPatCheckList().ToString());
  308. report.RegisterData(json.result.data.classification, "classification");
  309. report.RegisterData(json.result.data.settlement, "settlement");
  310. report.RegisterData(json.result.data.reginfo, "reginfo");
  311. report.RegisterData(json.result.data.patinsuinfo, "patinsuinfo");
  312. }
  313. catch (Exception ex)
  314. {
  315. MessageBox.Show(ex.Message);
  316. return;
  317. }
  318. //report.Design();
  319. report.Load(getTemplatePath());
  320. //report.Show();
  321. PrintPreview preview1 = new PrintPreview();
  322. preview1.Show();
  323. report.Preview = preview1.previewControl1;
  324. report.Prepare(); //准备
  325. report.ShowPrepared(); //显示
  326. preview1.Show();
  327. }
  328. private void uiButton2_Click(object sender, EventArgs e)
  329. {
  330. Close();
  331. }
  332. /// <summary>
  333. /// 点击打印
  334. /// </summary>
  335. /// <param name="sender"></param>
  336. /// <param name="e"></param>
  337. public void btnPrint_Click(object sender, EventArgs e)
  338. {
  339. try
  340. {
  341. //Thread thread = new Thread(new ThreadStart(print));
  342. Thread thread = new Thread(new ThreadStart(printReportCloud));
  343. thread.SetApartmentState(ApartmentState.STA); //重点
  344. thread.Start();
  345. thread.Join();
  346. }
  347. catch (Exception ex)
  348. {
  349. Global.writeLog("结算单打印异常:" + ex.Message);
  350. MessageBox.Show("打印异常:" + ex.Message);
  351. }
  352. //printReport();
  353. }
  354. /// <summary>
  355. /// 调用正版FastReport打印
  356. /// </summary>
  357. private void printReportCloud()
  358. {
  359. if (dgvSettlRecord.RowCount <= 0)
  360. {
  361. MessageBox.Show("请先查询结算数据!");
  362. return;
  363. }
  364. try
  365. {
  366. int i = dgvSettlRecord.CurrentRow.Index;
  367. DataTable dt = (DataTable)dgvSettlRecord.DataSource;
  368. string AdmID = dt.Rows[i]["AdmID"].ToString();
  369. string SettlementID = dt.Rows[i]["SettlementID"].ToString();
  370. string ValidFlag = dt.Rows[i]["ValidFlag"].ToString();
  371. string MdtrtID = dt.Rows[i]["MdtrtID"].ToString();
  372. JObject joRtn = GetFastReportParams("", AdmID, MdtrtID, SettlementID, ValidFlag);
  373. if (JsonHelper.parseIrisRtnValue(joRtn, out string errMsg) != 0)
  374. {
  375. MessageBox.Show("获取FastReport入参失败:" + errMsg);
  376. return;
  377. }
  378. string sFastReportParam = JsonHelper.getDestValue(joRtn, "result");
  379. if (FastReportPrint(sFastReportParam, out errMsg) != 0)
  380. {
  381. MessageBox.Show("调用FastReport打印失败!" + errMsg);
  382. return;
  383. }
  384. }
  385. catch (Exception ex)
  386. {
  387. MessageBox.Show(ex.Message);
  388. return;
  389. }
  390. }
  391. /// <summary>
  392. /// 组织正版FastReport需要的参数
  393. /// </summary>
  394. /// <param name="designFlag"></param>
  395. /// <param name="admID"></param>
  396. /// <param name="MdtrtID"></param>
  397. /// <param name="settlementID"></param>
  398. /// <param name="validFlag"></param>
  399. /// <returns></returns>
  400. public JObject GetFastReportParams(string designFlag, string admID, string MdtrtID, string settlementID, string validFlag)
  401. {
  402. try
  403. {
  404. if (designFlag == "") { designFlag = "N"; }
  405. #region【获取HIS医保结算信息】
  406. JObject joSettel = new JObject();
  407. joSettel.Add("HospitalDr", Global.inf.hospitalDr);
  408. joSettel.Add("interfaceDr", Global.inf.interfaceDr);
  409. joSettel.Add("admID", admID);
  410. joSettel.Add("SettlementID", settlementID);
  411. joSettel.Add("ValidFlag", validFlag);
  412. joSettel.Add("MdtrtID", MdtrtID);
  413. JObject joRtnSettle = invoker.invokeInsuService(JsonHelper.setIrisInpar("09010066", joSettel).ToString(), "获取结算单信息");
  414. if (JsonHelper.parseIrisRtnValue(joRtnSettle, out string errMsg) != 0)
  415. {
  416. JObject joRtnSet = new JObject();
  417. joRtnSet.Add("errorCode", -1);
  418. joRtnSet.Add("errorMessage", errMsg);
  419. joRtnSet.Add("result", "");
  420. return joRtnSet;
  421. }
  422. #endregion
  423. #region【组织FastReport调用入参】
  424. JArray jachargeItemLvFee = JArray.Parse(JsonHelper.getDestValue(joRtnSettle, "result.data.chargeItemLvFee"));
  425. JArray jaClassification = JArray.Parse(JsonHelper.getDestValue(joRtnSettle, "result.data.classification"));
  426. JArray jaSettlement = JArray.Parse(JsonHelper.getDestValue(joRtnSettle, "result.data.settlement"));
  427. JArray jaReginfo = JArray.Parse(JsonHelper.getDestValue(joRtnSettle, "result.data.reginfo"));
  428. JArray japatinsuinfo = JArray.Parse(JsonHelper.getDestValue(joRtnSettle, "result.data.patinsuinfo"));
  429. JObject joDataResult = new JObject();
  430. joDataResult.Add("SettlementInfo", jaSettlement);
  431. joDataResult.Add("ChargeItemLvFee", jachargeItemLvFee);
  432. joDataResult.Add("ClassificationInfo", jaClassification);
  433. joDataResult.Add("RegInfo", jaReginfo);
  434. joDataResult.Add("Patinsuinfo", japatinsuinfo);
  435. JObject joParams = new JObject();
  436. joParams.Add("fastReportCode", "SP11"); //这个要从表取值
  437. joParams.Add("hospID", Global.inf.hisHospitalDr.ToString());
  438. joParams.Add("printCode", Global.inf.interfaceDr.ToString());
  439. joParams.Add("templateID", "");
  440. JArray jaParams = new JArray();
  441. jaParams.Add(joParams);
  442. JObject joReportParams = new JObject();
  443. joReportParams.Add("params", jaParams);
  444. joReportParams.Add("code", "01040306");
  445. JObject joParam = new JObject();
  446. joParam.Add("designFlag", designFlag);
  447. joParam.Add("logFlag", "N");
  448. joParam.Add("dataParams", "");
  449. joParam.Add("pdfName", "");
  450. joParam.Add("reportparams", joReportParams);
  451. joParam.Add("dataResult", joDataResult);
  452. JObject joDataURL = new JObject();
  453. joDataURL.Add("dataIP", Global.hisConfig.ip);
  454. joDataURL.Add("urlAddress", Global.hisConfig.url);
  455. joDataURL.Add("authorization", Global.hisConfig.authorization);
  456. joParam.Add("dataURL", joDataURL);
  457. JArray jaParam = new JArray();
  458. jaParam.Add(joParam);
  459. JObject joInparam = new JObject();
  460. joInparam.Add("params", JArray.FromObject(jaParam));
  461. joInparam.Add("session", Global.curEvt.jaSession);
  462. #endregion
  463. JObject joRtn = new JObject();
  464. joRtn.Add("errorCode", 0);
  465. joRtn.Add("errorMessage", "");
  466. joRtn.Add("result", joInparam.ToString());
  467. return joRtn;
  468. }
  469. catch (Exception ex)
  470. {
  471. JObject joRtnEx = new JObject();
  472. joRtnEx.Add("errorCode", -1);
  473. joRtnEx.Add("errorMessage", ex.Message);
  474. joRtnEx.Add("result", "");
  475. return joRtnEx;
  476. }
  477. }
  478. /// <summary>
  479. /// FastReport正版打印开始
  480. /// </summary>
  481. /// <param name="InParams"></param>
  482. /// <param name="OutMsg"></param>
  483. /// <returns></returns>
  484. public int FastReportPrint(string InParams, out string OutMsg)
  485. {
  486. Global.writeLog("调用FastReport入参:" + InParams);
  487. try
  488. {
  489. #region【调用正版FastReport打印】
  490. FastReportFrom.FastReportDll FrDll = new FastReportFrom.FastReportDll();
  491. string sRtnFr = FrDll.FastReport(InParams);
  492. JObject joRetObj = JObject.Parse(sRtnFr);
  493. if (JsonHelper.parseIrisRtnValue(joRetObj, out string errMsg) != 0)
  494. {
  495. OutMsg = "调用FastReport打印失败!" + errMsg;
  496. return -1;
  497. }
  498. else
  499. {
  500. OutMsg = "";
  501. return 0;
  502. }
  503. #endregion
  504. }
  505. catch (Exception ex)
  506. {
  507. OutMsg = "调用FastReport打印失败!" + ex.Message;
  508. return -1;
  509. }
  510. }
  511. /// <summary>
  512. /// 调用正版FastReport的设计模式
  513. /// </summary>
  514. private void designReport()
  515. {
  516. if (dgvSettlRecord.RowCount <= 0)
  517. {
  518. MessageBox.Show("请先查询结算数据!");
  519. return;
  520. }
  521. try
  522. {
  523. int i = dgvSettlRecord.CurrentRow.Index;
  524. DataTable dt = (DataTable)dgvSettlRecord.DataSource;
  525. string AdmID = dt.Rows[i]["AdmID"].ToString();
  526. string SettlementID = dt.Rows[i]["SettlementID"].ToString();
  527. string ValidFlag = dt.Rows[i]["ValidFlag"].ToString();
  528. string MdtrtID = dt.Rows[i]["MdtrtID"].ToString();
  529. JObject joRtn = GetFastReportParams("Y", AdmID, MdtrtID, SettlementID, ValidFlag);
  530. if (JsonHelper.parseIrisRtnValue(joRtn, out string errMsg) != 0)
  531. {
  532. MessageBox.Show("获取FastReport入参失败:" + errMsg);
  533. return;
  534. }
  535. string sFastReportParam = JsonHelper.getDestValue(joRtn, "result");
  536. if (FastReportPrint(sFastReportParam, out errMsg) != 0)
  537. {
  538. MessageBox.Show("调用FastReport设计失败!" + errMsg);
  539. return;
  540. }
  541. }
  542. catch (Exception ex)
  543. {
  544. MessageBox.Show(ex.Message);
  545. return;
  546. }
  547. }
  548. /// <summary>
  549. /// 点击设计
  550. /// </summary>
  551. /// <param name="sender"></param>
  552. /// <param name="e"></param>
  553. private void btnDesign_Click(object sender, EventArgs e)
  554. {
  555. thread_test = new Thread(new ThreadStart(design));
  556. thread_test.SetApartmentState(ApartmentState.STA); //重点
  557. thread_test.Start();
  558. }
  559. private void SettlementChecklist_FormClosed(object sender, FormClosedEventArgs e)
  560. {
  561. Dispose();
  562. }
  563. private void btnDrgPrint_Click(object sender, EventArgs e)
  564. {
  565. if (dgvSettlRecord.RowCount <= 0)
  566. {
  567. MessageBox.Show("请先查询结算数据!");
  568. return;
  569. }
  570. try
  571. {
  572. int i = dgvSettlRecord.CurrentRow.Index;
  573. DataTable dt = (DataTable)dgvSettlRecord.DataSource;
  574. string psnNo = dt.Rows[i]["PersonnelNO"].ToString();
  575. string SettlementID = dt.Rows[i]["SettlementID"].ToString();
  576. JObject joRtn = GetDRGReport(psnNo, SettlementID);
  577. if (JsonHelper.parseCenterRtnValue(joRtn, out string errMsg) != 0)
  578. {
  579. MessageBox.Show("获取报表内容失败:" + errMsg);
  580. return;
  581. }
  582. string reportData = JsonHelper.getDestValue(joRtn, "output.setl_print");
  583. if (!string.IsNullOrEmpty(reportData))
  584. {
  585. PrintBase64Pdf(reportData);
  586. }
  587. }
  588. catch (Exception ex)
  589. {
  590. MessageBox.Show(ex.Message);
  591. return;
  592. }
  593. }
  594. private JObject GetDRGReport(string psnNo,string setleId)
  595. {
  596. dynamic joInput = new JObject();
  597. dynamic joParams = new JObject();
  598. joParams.businesstype = "1";
  599. joParams.psnno = psnNo;
  600. joParams.setlid = setleId;
  601. joInput.data = joParams;
  602. return invoker.invokeCenterService(TradeEnum.PrintDrgReport, joInput);
  603. }
  604. public void PrintBase64Pdf(string base64Pdf)
  605. {
  606. string pdfFile = System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\bill.pdf";
  607. byte[] bytes = Convert.FromBase64String(base64Pdf);
  608. try
  609. {
  610. using (PdfDocument doc = new PdfDocument())
  611. {
  612. File.WriteAllBytes(pdfFile, bytes);
  613. doc.LoadFromFile(pdfFile);
  614. PrintersForm printers = new PrintersForm();
  615. if (printers.ShowDialog() == DialogResult.OK)
  616. {
  617. PdfPrintSettings settings = new PdfPrintSettings();
  618. settings.PrinterName = printers.PrinterName;
  619. settings.Landscape = printers.Landscape;
  620. doc.Print(settings);
  621. }
  622. }
  623. }
  624. finally
  625. {
  626. if (File.Exists(pdfFile))
  627. {
  628. File.Delete(pdfFile);
  629. }
  630. }
  631. }
  632. }
  633. // Root myDeserializedClass = JsonConvert.DeserializeObject<Root>(myJsonResponse);
  634. public class Classification
  635. {
  636. public string cwfSummat { get; set; }
  637. public string cwfInScope { get; set; }
  638. public string cwfPreSelfPay { get; set; }
  639. public string cwfOverLimit { get; set; }
  640. public string cwfFullOwnPay { get; set; }
  641. public string zcfSummat { get; set; }
  642. public string zcfInScope { get; set; }
  643. public string zcfPreSelfPay { get; set; }
  644. public string zcfOverLimit { get; set; }
  645. public string zcfFullOwnPay { get; set; }
  646. public string jcfSummat { get; set; }
  647. public string jcfInScope { get; set; }
  648. public string jcfPreSelfPay { get; set; }
  649. public string jcfOverLimit { get; set; }
  650. public string jcfFullOwnPay { get; set; }
  651. public string hyfSummat { get; set; }
  652. public string hyfInScope { get; set; }
  653. public string hyfPreSelfPay { get; set; }
  654. public string hyfOverLimit { get; set; }
  655. public string hyfFullOwnPay { get; set; }
  656. public string zlfSummat { get; set; }
  657. public string zlfInScope { get; set; }
  658. public string zlfPreSelfPay { get; set; }
  659. public string zlfOverLimit { get; set; }
  660. public string zlfFullOwnPay { get; set; }
  661. public string ssfSummat { get; set; }
  662. public string ssfInScope { get; set; }
  663. public string ssfPreSelfPay { get; set; }
  664. public string ssfOverLimit { get; set; }
  665. public string ssfFullOwnPay { get; set; }
  666. public string hlfSummat { get; set; }
  667. public string hlfInScope { get; set; }
  668. public string hlfPreSelfPay { get; set; }
  669. public string hlfOverLimit { get; set; }
  670. public string hlfFullOwnPay { get; set; }
  671. public string wsclfSummat { get; set; }
  672. public string wsclfInScope { get; set; }
  673. public string wsclfPreSelfPay { get; set; }
  674. public string wsclfOverLimit { get; set; }
  675. public string wsclfFullOwnPay { get; set; }
  676. public string xyfSummat { get; set; }
  677. public string xyfInScope { get; set; }
  678. public string xyfPreSelfPay { get; set; }
  679. public string xyfOverLimit { get; set; }
  680. public string xyfFullOwnPay { get; set; }
  681. public string zyypfSummat { get; set; }
  682. public string zyypfInScope { get; set; }
  683. public string zyypfPreSelfPay { get; set; }
  684. public string zyypfOverLimit { get; set; }
  685. public string zyypfFullOwnPay { get; set; }
  686. public string zcyfSummat { get; set; }
  687. public string zcyfInScope { get; set; }
  688. public string zcyfPreSelfPay { get; set; }
  689. public string zcyfOverLimit { get; set; }
  690. public string zcyfFullOwnPay { get; set; }
  691. public string ybzlfSummat { get; set; }
  692. public string ybzlfInScope { get; set; }
  693. public string ybzlfPreSelfPay { get; set; }
  694. public string ybzlfOverLimit { get; set; }
  695. public string ybzlfFullOwnPay { get; set; }
  696. public string ghfSummat { get; set; }
  697. public string ghfInScope { get; set; }
  698. public string ghfPreSelfPay { get; set; }
  699. public string ghfOverLimit { get; set; }
  700. public string ghfFullOwnPay { get; set; }
  701. public string qtSummat { get; set; }
  702. public string qtInScope { get; set; }
  703. public string qtPreSelfPay { get; set; }
  704. public string qtOverLimit { get; set; }
  705. public string qtFullOwnPay { get; set; }
  706. public string totalSummat { get; set; }
  707. public string totalInScope { get; set; }
  708. public string totalPreSelfPay { get; set; }
  709. public string totalOverLimit { get; set; }
  710. public string totalFullOwnPay { get; set; }
  711. }
  712. public class Data
  713. {
  714. public List<Classification> classification { get; set; }
  715. public List<Settlement> settlement { get; set; }
  716. public List<Reginfo> reginfo { get; set; }
  717. public List<Patinsuinfo> patinsuinfo { get; set; }
  718. }
  719. public class Patinsuinfo
  720. {
  721. public string PsnCertType { get; set; }
  722. public string PsnCertNO { get; set; }
  723. public string Gend { get; set; }
  724. public string Naty { get; set; }
  725. public string Brdy { get; set; }
  726. public string Age { get; set; }
  727. public string Balc { get; set; }
  728. public string PsnType { get; set; }
  729. public string Cvlservflag { get; set; }
  730. public string insuplcAdmdvs { get; set; }
  731. public string EmpName { get; set; }
  732. public string PsnIdettype { get; set; }
  733. public string PsnTypeLv { get; set; }
  734. }
  735. public class Reginfo
  736. {
  737. public string AttendDoctorNO { get; set; }
  738. public string ChiefPhyDocName { get; set; }
  739. public string AdmitDepartmentCode { get; set; }
  740. public string AdmitDepartmentName { get; set; }
  741. public string AdmBed { get; set; }
  742. public string AdmNo { get; set; }
  743. public string MainDiagCode { get; set; }
  744. public string MainDiagName { get; set; }
  745. public string RegDate { get; set; }
  746. public string ConerName { get; set; }
  747. public string Tel { get; set; }
  748. }
  749. public class Result
  750. {
  751. public Data data { get; set; }
  752. }
  753. public class Root
  754. {
  755. public Result result { get; set; }
  756. public int errorCode { get; set; }
  757. public string errorMessage { get; set; }
  758. }
  759. public class Settlement
  760. {
  761. public string AdmID { get; set; }
  762. public string MdtrtID { get; set; }
  763. public string SettlementID { get; set; }
  764. public string PersonnelNO { get; set; }
  765. public string PatientName { get; set; }
  766. public string birth { get; set; }
  767. public string CertificateNO { get; set; }
  768. public string Gender { get; set; }
  769. public string InsuranceType { get; set; }
  770. public string PersonType { get; set; }
  771. public string CivilserviceFlag { get; set; }
  772. public string SettlementTime { get; set; }
  773. public string MedicalType { get; set; }
  774. public string Sumamt { get; set; }
  775. public string OwnPayAmount { get; set; }
  776. public string OverLimitAmount { get; set; }
  777. public string PreSelfPayAmount { get; set; }
  778. public string InPolicyRangeAmount { get; set; }
  779. public double ActualPayDeductible { get; set; }
  780. public string HealthInsurancePay { get; set; }
  781. public string HealthInsuranceRatio { get; set; }
  782. public double CivilserviceAllowancePay { get; set; }
  783. public string EnterpriseSupplementPay { get; set; }
  784. public string SeriousIllnessPay { get; set; }
  785. public string LargeExpensesSupplementPay { get; set; }
  786. public string MedicalAssistPay { get; set; }
  787. public string HospitalPartAmount { get; set; }
  788. public string OtherPay { get; set; }
  789. public string FundPaySumamt { get; set; }
  790. public string PersonPaySumamt { get; set; }
  791. public string AccountPaySumamt { get; set; }
  792. public string PersonCashPay { get; set; }
  793. public string Balance { get; set; }
  794. public string AccountMutualAidAmount { get; set; }
  795. public string OrganSettlementID { get; set; }
  796. public string ClearingOrgan { get; set; }
  797. public string ClearingWay { get; set; }
  798. public string ClearingType { get; set; }
  799. public string ValidFlag { get; set; }
  800. public string msgid { get; set; }
  801. public string HospitalizationsTimes { get; set; }
  802. public string HospitalizationsDays { get; set; }
  803. public string HISAdmTime { get; set; }
  804. public string HISDischargeTime { get; set; }
  805. public int BillType { get; set; }
  806. public string BillID { get; set; }
  807. public string admType { get; set; }
  808. public string RecordID { get; set; }
  809. public string insuplc_admdvs { get; set; }
  810. }
  811. }