SettlementChecklist.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  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. namespace PTMedicalInsurance.Forms
  20. {
  21. public partial class SettlementChecklist : Form
  22. {
  23. private int hospitalDr;
  24. private int interfaceDr;
  25. private string hospitalNO;
  26. private string interfaceNO;
  27. private string hospitalName;
  28. private string hospitalAreaCode;
  29. private bool disposed = false;
  30. Thread thread_test;
  31. private InvokeHelper invoker = new InvokeHelper();
  32. public SettlementChecklist()
  33. {
  34. InitializeComponent();
  35. hospitalDr = Global.inf.hospitalDr;
  36. hospitalNO = Global.inf.hospitalNO;
  37. hospitalName = Global.inf.hospitalName;
  38. hospitalAreaCode = Global.inf.areaCode;
  39. interfaceDr = Global.inf.interfaceDr;
  40. }
  41. public SettlementChecklist(JObject joParam)
  42. {
  43. InitializeComponent();
  44. hospitalDr = Global.inf.hospitalDr;
  45. hospitalNO = Global.inf.hospitalNO;
  46. hospitalName = Global.inf.hospitalName;
  47. hospitalAreaCode = Global.inf.areaCode;
  48. if (joParam == null) return;
  49. string setl_id = JsonHelper.getDestValue(joParam, "setl_id");
  50. if (setl_id == "")
  51. {
  52. MessageBox.Show("根据传入的结算编号为查询到相关信息,请手动输入查询!");
  53. return;
  54. }
  55. string sqlStr = "SELECT * FROM BS_MedInsuSettlement WHERE Hospital_Dr=" + Global.inf.hospitalDr;
  56. sqlStr = sqlStr + " and SettlementID='" + setl_id + "'";
  57. //JObject joSqlStr = new JObject("sqlStr", sqlStr);
  58. //MIIrisServices mIS = new MIIrisServices();
  59. //JObject joRtn = mIS.QuerySettlementInfo(joSqlStr);
  60. //DataTable dt = (DataTable)joRtn["result"]["data"].ToObject(typeof(DataTable));
  61. //dgvSettlRecord.DataSource = dt;
  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. public void Dispose()
  70. {
  71. Dispose1(true);
  72. GC.SuppressFinalize(this);
  73. }
  74. protected virtual void Dispose1(bool disposing)
  75. {
  76. if (thread_test == null) return;
  77. if (disposed == false)
  78. {
  79. if (disposing == true)
  80. {
  81. Thread.Sleep(100);
  82. Global.writeLog("Main - aborting my thread.");
  83. thread_test.Abort();//终止线程myThread
  84. thread_test.Join();//等待线程myThread结束
  85. Global.writeLog("Main - ending.");
  86. }
  87. //释放托管资源的代码
  88. }
  89. disposed = true;
  90. }
  91. private void rbgDirecType_ValueChanged(object sender, int index, string text)
  92. {
  93. }
  94. private void btnQuery_Click(object sender, EventArgs e)
  95. {
  96. }
  97. private void btnQuery_Click_1(object sender, EventArgs e)
  98. {
  99. string sqlStr = " SELECT * FROM BS_MedInsuSettlement WHERE Hospital_Dr=" + hospitalDr ;
  100. sqlStr = sqlStr + " and OccurTime>'" + dpST.Text + "'";
  101. sqlStr = sqlStr + " and OccurTime<'" + dpED.Text + "'";
  102. if (tbName.Text != "")
  103. {
  104. sqlStr = sqlStr + " and PatientName='" + tbName.Text + "'";
  105. }
  106. if (tbPatSettlID.Text != "")
  107. {
  108. sqlStr = sqlStr + " and SettlementID='" + tbPatSettlID.Text + "'";
  109. }
  110. if (tbHisNO.Text != "")
  111. {
  112. sqlStr = sqlStr + " and Adm_Dr='" + tbHisNO.Text + "'";
  113. }
  114. if (cbxInterface.Text != "")
  115. {
  116. sqlStr = sqlStr + " and Interface_Dr=" + Global.inf.interfaceDr + "";
  117. }
  118. if (rbgAdmType.SelectedIndex == 1)
  119. {
  120. sqlStr = sqlStr + " and AdmType=2";
  121. }
  122. if (rbgAdmType.SelectedIndex == 2)
  123. {
  124. sqlStr = sqlStr + " and AdmType=1";
  125. }
  126. if (rbgBillType.SelectedIndex == 1)
  127. {
  128. sqlStr = sqlStr + " and BillType=1 and ValidFlag=1 ";
  129. }
  130. if (rbgBillType.SelectedIndex == 2)
  131. {
  132. sqlStr = sqlStr + " and BillType=-1 and ValidFlag=0 ";
  133. }
  134. JObject joSqlStr = new JObject();
  135. joSqlStr.Add("sqlStr", sqlStr);
  136. MIIrisServices mIS = new MIIrisServices();
  137. JObject joRtn = mIS.QuerySettlementInfo(joSqlStr);
  138. DataTable dt = (DataTable)joRtn["result"]["data"].ToObject(typeof(DataTable));
  139. dgvSettlRecord.DataSource = dt;
  140. }
  141. private void SettlementChecklist_Load(object sender, EventArgs e)
  142. {
  143. dpST.Text = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  144. dpED.Text = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  145. ComboxSetter cbxSetter = new ComboxSetter();
  146. cbxSetter.setCbxInterfaceDataSource(cbxInterface);
  147. GridViewSetter grdSetter = new GridViewSetter();
  148. grdSetter.SetHeaderTextOfSettlList(dgvSettlRecord);
  149. rbgAdmType.SelectedIndex = 0;
  150. rbgBillType.SelectedIndex = 1;
  151. cbxInterface.SelectedValueChanged += new EventHandler(cbxInterface_SelectedValueChanged);
  152. }
  153. private void cbxInterface_SelectedValueChanged(object sender, EventArgs e)
  154. {
  155. DataTable dt = (DataTable)cbxInterface.DataSource;
  156. int i = cbxInterface.SelectedIndex;
  157. //赋值
  158. hospitalNO = dt.Rows[i]["HospitalNO"].ToString();
  159. //MessageBox.Show(dt.Rows[i]["HospitalDr"].ToString());
  160. //MessageBox.Show(dt.Rows[i]["HospitalDr"].ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
  161. hospitalDr = int.Parse(dt.Rows[i]["HospitalDr"].ToString());
  162. interfaceNO = dt.Rows[i]["InterfaceNO"].ToString();
  163. interfaceDr = int.Parse(dt.Rows[i]["ID"].ToString());
  164. hospitalAreaCode = dt.Rows[i]["AreaCode"].ToString();
  165. //Global.inf.centerURL = dt.Rows[i]["CenterURL"].ToString();
  166. //Global.inf.businessDllName = dt.Rows[i]["DLLName"].ToString();
  167. //Global.inf.patientAreaCode = dt.Rows[i]["AreaCode"].ToString();
  168. }
  169. private JObject getPatCheckList()
  170. {
  171. try
  172. {
  173. int i = dgvSettlRecord.CurrentRow.Index;
  174. DataTable dt = (DataTable)dgvSettlRecord.DataSource;
  175. JObject joSettel = new JObject();
  176. joSettel.Add("HospitalDr", Global.inf.hospitalDr);
  177. joSettel.Add("interfaceDr", Global.inf.interfaceDr);
  178. joSettel.Add("admID", dt.Rows[i]["AdmID"].ToString());
  179. joSettel.Add("SettlementID", dt.Rows[i]["SettlementID"].ToString());
  180. joSettel.Add("ValidFlag", dt.Rows[i]["ValidFlag"].ToString());
  181. JObject joRtn = invoker.invokeInsuService(JsonHelper.setIrisInpar("09010066", joSettel).ToString(), "获取结算单信息");
  182. return joRtn;
  183. }
  184. catch (Exception ex)
  185. {
  186. JObject joRtn = new JObject();
  187. joRtn.Add("errorCode", -1);
  188. joRtn.Add("errorMessage", ex.Message);
  189. return joRtn;
  190. }
  191. }
  192. private void uiPanel1_Click(object sender, EventArgs e)
  193. {
  194. }
  195. [STAThread]
  196. public void design()
  197. {
  198. try
  199. {
  200. string chineseSimpleFrl = Global.curEvt.path + @"\Chinese (Simplified).frl";
  201. FastReport.Utils.Res.LoadLocale(chineseSimpleFrl);
  202. JObject joSettleCheckList = getPatCheckList();
  203. string errMsg;
  204. if (JsonHelper.parseIrisRtnValue(joSettleCheckList, out errMsg) != 0)
  205. {
  206. MessageBox.Show("查询结算信息异常:" + errMsg);
  207. return;
  208. }
  209. Report report = new Report();
  210. try
  211. {
  212. var json = JsonConvert.DeserializeObject<Root>(getPatCheckList().ToString());
  213. report.RegisterData(json.result.data.classification, "classification");
  214. report.RegisterData(json.result.data.settlement, "settlement");
  215. report.RegisterData(json.result.data.reginfo, "reginfo");
  216. report.RegisterData(json.result.data.patinsuinfo, "patinsuinfo");
  217. }
  218. catch (Exception ex)
  219. {
  220. MessageBox.Show(ex.Message);
  221. return;
  222. }
  223. report.Load(Global.curEvt.path + "\\frx\\河南郑州结算单.frx");
  224. PrintDesign pf = new PrintDesign();
  225. pf.designerControl1.Report = report;
  226. report.Design();
  227. pf.WindowState = FormWindowState.Maximized;
  228. pf.ShowDialog();
  229. }
  230. catch (Exception ex)
  231. {
  232. MessageBox.Show(ex.Message);
  233. }
  234. }
  235. [STAThread]
  236. private void print()
  237. {
  238. string chineseSimpleFrl = Global.curEvt.path + @"\Chinese (Simplified).frl";
  239. FastReport.Utils.Res.LoadLocale(chineseSimpleFrl);
  240. JObject joSettleCheckList = getPatCheckList();
  241. string errMsg;
  242. if (JsonHelper.parseIrisRtnValue(joSettleCheckList, out errMsg) != 0)
  243. {
  244. MessageBox.Show("查询结算信息异常:" + errMsg);
  245. return;
  246. }
  247. Report report = new Report();
  248. try
  249. {
  250. var json = JsonConvert.DeserializeObject<Root>(getPatCheckList().ToString());
  251. report.RegisterData(json.result.data.classification, "classification");
  252. report.RegisterData(json.result.data.settlement, "settlement");
  253. report.RegisterData(json.result.data.reginfo, "reginfo");
  254. report.RegisterData(json.result.data.patinsuinfo, "patinsuinfo");
  255. }
  256. catch (Exception ex)
  257. {
  258. MessageBox.Show(ex.Message);
  259. return;
  260. }
  261. //report.Design();
  262. report.Load(Global.curEvt.path + "\\frx\\河南郑州结算单.frx");
  263. this.ShowInTaskbar = true;
  264. PrintPreview pf = new PrintPreview();
  265. report.Preview = pf.previewControl1;
  266. report.Show();
  267. pf.WindowState = FormWindowState.Maximized;
  268. pf.ShowDialog();
  269. }
  270. [STAThread]
  271. private void preview()
  272. {
  273. //JObject joCheckList = getPatCheckList();
  274. Report report = new Report();
  275. try
  276. {
  277. var json = JsonConvert.DeserializeObject<Root>(getPatCheckList().ToString());
  278. report.RegisterData(json.result.data.classification, "classification");
  279. report.RegisterData(json.result.data.settlement, "settlement");
  280. report.RegisterData(json.result.data.reginfo, "reginfo");
  281. report.RegisterData(json.result.data.patinsuinfo, "patinsuinfo");
  282. }
  283. catch (Exception ex)
  284. {
  285. MessageBox.Show(ex.Message);
  286. return;
  287. }
  288. //report.Design();
  289. report.Load(Global.curEvt.path + "\\frx\\河南郑州结算单.frx");
  290. //report.Show();
  291. PrintPreview preview1 = new PrintPreview();
  292. preview1.Show();
  293. report.Preview = preview1.previewControl1;
  294. report.Prepare(); //准备
  295. report.ShowPrepared(); //显示
  296. preview1.Show();
  297. }
  298. private void uiButton2_Click(object sender, EventArgs e)
  299. {
  300. Close();
  301. }
  302. public void btnPrint_Click(object sender, EventArgs e)
  303. {
  304. try
  305. {
  306. Thread thread = new Thread(new ThreadStart(print));
  307. thread.SetApartmentState(ApartmentState.STA); //重点
  308. thread.Start();
  309. thread.Join();
  310. }
  311. catch (Exception ex)
  312. {
  313. Global.writeLog("结算单打印异常:" + ex.Message);
  314. MessageBox.Show("打印异常:" + ex.Message);
  315. }
  316. }
  317. public void btnDesign_Click(object sender, EventArgs e)
  318. {
  319. try
  320. {
  321. Thread thread = new Thread(new ThreadStart(design));
  322. thread.SetApartmentState(ApartmentState.STA); //重点
  323. thread.Start();
  324. thread.Join();
  325. }
  326. catch (Exception ex)
  327. {
  328. Global.writeLog("结算单设计预览异常:" + ex.Message);
  329. MessageBox.Show("设计预览异常:" + ex.Message);
  330. }
  331. }
  332. private void SettlementChecklist_FormClosed(object sender, FormClosedEventArgs e)
  333. {
  334. Dispose();
  335. }
  336. }
  337. // Root myDeserializedClass = JsonConvert.DeserializeObject<Root>(myJsonResponse);
  338. public class Classification
  339. {
  340. public string cwfSummat { get; set; }
  341. public string cwfInScope { get; set; }
  342. public string cwfPreSelfPay { get; set; }
  343. public string cwfOverLimit { get; set; }
  344. public string cwfFullOwnPay { get; set; }
  345. public string zcfSummat { get; set; }
  346. public string zcfInScope { get; set; }
  347. public string zcfPreSelfPay { get; set; }
  348. public string zcfOverLimit { get; set; }
  349. public string zcfFullOwnPay { get; set; }
  350. public string jcfSummat { get; set; }
  351. public string jcfInScope { get; set; }
  352. public string jcfPreSelfPay { get; set; }
  353. public string jcfOverLimit { get; set; }
  354. public string jcfFullOwnPay { get; set; }
  355. public string hyfSummat { get; set; }
  356. public string hyfInScope { get; set; }
  357. public string hyfPreSelfPay { get; set; }
  358. public string hyfOverLimit { get; set; }
  359. public string hyfFullOwnPay { get; set; }
  360. public string zlfSummat { get; set; }
  361. public string zlfInScope { get; set; }
  362. public string zlfPreSelfPay { get; set; }
  363. public string zlfOverLimit { get; set; }
  364. public string zlfFullOwnPay { get; set; }
  365. public string ssfSummat { get; set; }
  366. public string ssfInScope { get; set; }
  367. public string ssfPreSelfPay { get; set; }
  368. public string ssfOverLimit { get; set; }
  369. public string ssfFullOwnPay { get; set; }
  370. public string hlfSummat { get; set; }
  371. public string hlfInScope { get; set; }
  372. public string hlfPreSelfPay { get; set; }
  373. public string hlfOverLimit { get; set; }
  374. public string hlfFullOwnPay { get; set; }
  375. public string wsclfSummat { get; set; }
  376. public string wsclfInScope { get; set; }
  377. public string wsclfPreSelfPay { get; set; }
  378. public string wsclfOverLimit { get; set; }
  379. public string wsclfFullOwnPay { get; set; }
  380. public string xyfSummat { get; set; }
  381. public string xyfInScope { get; set; }
  382. public string xyfPreSelfPay { get; set; }
  383. public string xyfOverLimit { get; set; }
  384. public string xyfFullOwnPay { get; set; }
  385. public string zyypfSummat { get; set; }
  386. public string zyypfInScope { get; set; }
  387. public string zyypfPreSelfPay { get; set; }
  388. public string zyypfOverLimit { get; set; }
  389. public string zyypfFullOwnPay { get; set; }
  390. public string zcyfSummat { get; set; }
  391. public string zcyfInScope { get; set; }
  392. public string zcyfPreSelfPay { get; set; }
  393. public string zcyfOverLimit { get; set; }
  394. public string zcyfFullOwnPay { get; set; }
  395. public string ybzlfSummat { get; set; }
  396. public string ybzlfInScope { get; set; }
  397. public string ybzlfPreSelfPay { get; set; }
  398. public string ybzlfOverLimit { get; set; }
  399. public string ybzlfFullOwnPay { get; set; }
  400. public string ghfSummat { get; set; }
  401. public string ghfInScope { get; set; }
  402. public string ghfPreSelfPay { get; set; }
  403. public string ghfOverLimit { get; set; }
  404. public string ghfFullOwnPay { get; set; }
  405. public string qtSummat { get; set; }
  406. public string qtInScope { get; set; }
  407. public string qtPreSelfPay { get; set; }
  408. public string qtOverLimit { get; set; }
  409. public string qtFullOwnPay { get; set; }
  410. public string totalSummat { get; set; }
  411. public string totalInScope { get; set; }
  412. public string totalPreSelfPay { get; set; }
  413. public string totalOverLimit { get; set; }
  414. public string totalFullOwnPay { get; set; }
  415. }
  416. public class Data
  417. {
  418. public List<Classification> classification { get; set; }
  419. public List<Settlement> settlement { get; set; }
  420. public List<Reginfo> reginfo { get; set; }
  421. public List<Patinsuinfo> patinsuinfo { get; set; }
  422. }
  423. public class Patinsuinfo
  424. {
  425. public string PsnCertType { get; set; }
  426. public string PsnCertNO { get; set; }
  427. public string Gend { get; set; }
  428. public string Naty { get; set; }
  429. public string Brdy { get; set; }
  430. public string Age { get; set; }
  431. public string Balc { get; set; }
  432. public string PsnType { get; set; }
  433. public string Cvlservflag { get; set; }
  434. public string insuplcAdmdvs { get; set; }
  435. public string EmpName { get; set; }
  436. public string PsnIdettype { get; set; }
  437. public string PsnTypeLv { get; set; }
  438. }
  439. public class Reginfo
  440. {
  441. public string AttendDoctorNO { get; set; }
  442. public string ChiefPhyDocName { get; set; }
  443. public string AdmitDepartmentCode { get; set; }
  444. public string AdmitDepartmentName { get; set; }
  445. public string AdmBed { get; set; }
  446. public string MainDiagCode { get; set; }
  447. public string MainDiagName { get; set; }
  448. public string RegDate { get; set; }
  449. public string ConerName { get; set; }
  450. public string Tel { get; set; }
  451. }
  452. public class Result
  453. {
  454. public Data data { get; set; }
  455. }
  456. public class Root
  457. {
  458. public Result result { get; set; }
  459. public int errorCode { get; set; }
  460. public string errorMessage { get; set; }
  461. }
  462. public class Settlement
  463. {
  464. public string AdmID { get; set; }
  465. public string MdtrtID { get; set; }
  466. public string SettlementID { get; set; }
  467. public string PersonnelNO { get; set; }
  468. public string PatientName { get; set; }
  469. public string birth { get; set; }
  470. public string CertificateNO { get; set; }
  471. public string Gender { get; set; }
  472. public string InsuranceType { get; set; }
  473. public string PersonType { get; set; }
  474. public string CivilserviceFlag { get; set; }
  475. public string SettlementTime { get; set; }
  476. public string MedicalType { get; set; }
  477. public string Sumamt { get; set; }
  478. public string OwnPayAmount { get; set; }
  479. public string OverLimitAmount { get; set; }
  480. public string PreSelfPayAmount { get; set; }
  481. public string InPolicyRangeAmount { get; set; }
  482. public double ActualPayDeductible { get; set; }
  483. public string HealthInsurancePay { get; set; }
  484. public string HealthInsuranceRatio { get; set; }
  485. public double CivilserviceAllowancePay { get; set; }
  486. public string EnterpriseSupplementPay { get; set; }
  487. public string SeriousIllnessPay { get; set; }
  488. public string LargeExpensesSupplementPay { get; set; }
  489. public string MedicalAssistPay { get; set; }
  490. public string HospitalPartAmount { get; set; }
  491. public string OtherPay { get; set; }
  492. public string FundPaySumamt { get; set; }
  493. public string PersonPaySumamt { get; set; }
  494. public string AccountPaySumamt { get; set; }
  495. public string PersonCashPay { get; set; }
  496. public string Balance { get; set; }
  497. public string AccountMutualAidAmount { get; set; }
  498. public string OrganSettlementID { get; set; }
  499. public string ClearingOrgan { get; set; }
  500. public string ClearingWay { get; set; }
  501. public string ClearingType { get; set; }
  502. public string ValidFlag { get; set; }
  503. public string msgid { get; set; }
  504. public string HospitalizationsTimes { get; set; }
  505. public string HospitalizationsDays { get; set; }
  506. public string HISAdmTime { get; set; }
  507. public string HISDischargeTime { get; set; }
  508. public int BillType { get; set; }
  509. public string BillID { get; set; }
  510. public string admType { get; set; }
  511. public string RecordID { get; set; }
  512. public string insuplc_admdvs { get; set; }
  513. }
  514. }