SettlementChecklist.cs 19 KB

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