SettlementChecklist.cs 22 KB

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