SettlementChecklist.cs 20 KB

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