SettlementChecklist.cs 22 KB

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