PatientInsuInfo.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  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 Newtonsoft.Json.Linq;
  11. using PTMedicalInsurance.Helper;
  12. using PTMedicalInsurance.Variables;
  13. using PTMedicalInsurance.Business;
  14. using PTMedicalInsurance.Common;
  15. using PTMedicalInsurance.Forms.Setters.PatientInsuInfos;
  16. namespace PTMedicalInsurance.Forms
  17. {
  18. public partial class PatientInsuInfo : Form
  19. {
  20. public DataTable dtInsuInfo;
  21. public DataTable dtIDInfo;
  22. public JObject joSelectedInsuInfo;
  23. public int insuInfoIndex = 0;
  24. public int idInfoIndex = 0;
  25. public string MedType = "";
  26. InvokeHelper invoker = new InvokeHelper();
  27. private MIIrisServices mIS = new MIIrisServices();
  28. private DataTable dtFundPayType;
  29. private Form mainForm;
  30. //1.声明自适应类实例
  31. AutoResizeForm asc = new AutoResizeForm();
  32. public PatientInsuInfo()
  33. {
  34. InitializeComponent();
  35. this.StartPosition = FormStartPosition.CenterParent;
  36. asc.controllInitializeSize(this);
  37. asc.controlAutoSize(this);
  38. //获取通用目录
  39. string sTYML = mIS.GetCommonInterface_Dr(Global.inf.interfaceDr.ToString(), "");
  40. if (sTYML == "")
  41. Global.inf.InsuCurrencyCataLogue = Global.inf.interfaceDr;
  42. else
  43. Global.inf.InsuCurrencyCataLogue = int.Parse(sTYML);
  44. }
  45. public PatientInsuInfo(JObject jo, Form frm)
  46. {
  47. InitializeComponent();
  48. InitForm(jo, frm);
  49. }
  50. private void InitForm(JObject jo)
  51. {
  52. dtInsuInfo = (DataTable)jo["insuinfo"].ToObject(typeof(DataTable));
  53. dtIDInfo = (DataTable)jo["idetinfo"].ToObject(typeof(DataTable));
  54. JObject joBaseInfo = JObject.FromObject(jo["baseinfo"]);
  55. this.tbName.Text = joBaseInfo["psn_name"].ToString();
  56. this.tbPsnNO.Text = joBaseInfo["psn_no"].ToString();
  57. this.tbGend.Text = joBaseInfo["gend"].ToString();
  58. this.tbBirthDay.Text = joBaseInfo["brdy"].ToString();
  59. this.tbNaty.Text = joBaseInfo["naty"].ToString();
  60. this.tbCertType.Text = joBaseInfo["psn_cert_type"].ToString();
  61. this.tbCertNO.Text = joBaseInfo["certno"].ToString();
  62. this.tbAge.Text = joBaseInfo["age"].ToString();
  63. string expContent = joBaseInfo["exp_content"].ToString(); //字段扩展 只有居民返回
  64. setDgvIDInfo();
  65. setDgvInsuInfo();
  66. setDgvChronicDiseaseRecordInfo();
  67. setDgvTreatement(dgvTreatment);
  68. dgvInsuInfo.DataSource = dtInsuInfo;
  69. dgvIDInfo.DataSource = dtIDInfo;
  70. }
  71. private void InitForm(JObject jo, Form frm)
  72. {
  73. InitForm(jo);
  74. mainForm = frm;
  75. CheckForIllegalCrossThreadCalls = false;
  76. // 禁用关闭按钮
  77. this.FormBorderStyle = FormBorderStyle.None;
  78. // 隐藏标题栏
  79. this.ControlBox = false;
  80. // 其他可能需要的配置
  81. if (mainForm != this)
  82. {
  83. this.TopLevel = false;
  84. this.Dock = DockStyle.Fill; // 根据需要设置 Dock 属性
  85. }
  86. else
  87. {
  88. this.WindowState = FormWindowState.Maximized;
  89. }
  90. }
  91. public PatientInsuInfo(JObject jo)
  92. {
  93. InitializeComponent();
  94. dtInsuInfo = (DataTable)jo["insuinfo"].ToObject(typeof(DataTable));
  95. dtIDInfo = (DataTable)jo["idetinfo"].ToObject(typeof(DataTable));
  96. JObject joBaseInfo = JObject.FromObject(jo["baseinfo"]);
  97. this.tbName.Text = joBaseInfo["psn_name"].ToString();
  98. this.tbPsnNO.Text = joBaseInfo["psn_no"].ToString();
  99. this.tbGend.Text = joBaseInfo["gend"].ToString();
  100. this.tbBirthDay.Text = joBaseInfo["brdy"].ToString();
  101. this.tbNaty.Text = joBaseInfo["naty"].ToString();
  102. this.tbCertType.Text = joBaseInfo["psn_cert_type"].ToString();
  103. this.tbCertNO.Text = joBaseInfo["certno"]+"";
  104. this.tbAge.Text = joBaseInfo["age"] + "";
  105. GridViewSetter grdSetter = new GridViewSetter();
  106. grdSetter.setDgvIDInfo(dgvIDInfo);
  107. grdSetter.setDgvInsuInfo(dgvInsuInfo);
  108. grdSetter.setDgvTreatement(dgvTreatment);
  109. grdSetter.setDgvChronicDiseaseRecordInfo(dgvChronicDiseaseRecordInfo);
  110. dgvInsuInfo.DataSource = dtInsuInfo;
  111. dgvIDInfo.DataSource = dtIDInfo;
  112. //提示参保地本地或异地
  113. if (!string.IsNullOrEmpty(Global.pat.insuplc_admdvs))
  114. {
  115. if (Global.pat.insuplc_admdvs.Substring(0, 4) != Global.pat.mdtrtarea_admvs.Substring(0, 4))
  116. {
  117. lb_Locate.Visible = true;
  118. lb_Locate.Text = "异地";
  119. lb_Locate.ForeColor = Color.Red;
  120. lb_Locate.Font = new Font(lb_Locate.Font.Name, 20, FontStyle.Bold); // 设置字体大小和样式
  121. lb_Locate.ForeColor = Color.Red; // 设置字体颜色为红色
  122. }
  123. else
  124. lb_Locate.Visible = false;
  125. }
  126. //【5301】人员慢特病备案查询
  127. if (trade5301(Global.pat.psn_no, out string Msg) == 0) //查询返回门诊慢特病信息
  128. {
  129. dgvChronicDiseaseRecordInfo.CellFormatting
  130. += new DataGridViewCellFormattingEventHandler(dgvChronicDiseaseRecordInfo_CellFormatting);
  131. JObject joRtn = JObject.Parse(Msg);
  132. DataTable dt = (DataTable)joRtn["output"]["feedetail"].ToObject(typeof(DataTable));
  133. dgvChronicDiseaseRecordInfo.DataSource = dt;
  134. }
  135. //获取通用目录
  136. string sTYML = mIS.GetCommonInterface_Dr(Global.inf.interfaceDr.ToString(), "");
  137. if (sTYML == "")
  138. Global.inf.InsuCurrencyCataLogue = Global.inf.interfaceDr;
  139. else
  140. Global.inf.InsuCurrencyCataLogue = int.Parse(sTYML);
  141. string sqlStr = "";
  142. string sqlCondition = " and A.Interface_Dr = '" + Global.inf.InsuCurrencyCataLogue.ToString() + "'";
  143. sqlStr = "SELECT B.Code,B.Descripts AS Name FROM HB_Dictionary A JOIN HB_DictionaryDataDetail B ON A.ID = B.HBDictionary_Dr WHERE A.InsuCode = 'fund_pay_type'" + sqlCondition;
  144. dtFundPayType = GetDBLKComboxTable(sqlStr);
  145. sqlStr = "SELECT B.Code,B.Descripts AS Name FROM HB_Dictionary A JOIN HB_DictionaryDataDetail B ON A.ID = B.HBDictionary_Dr WHERE A.InsuCode = 'med_type'" + sqlCondition;
  146. SetDBLKCombox(ref dblkcbxMedicalType, sqlStr);
  147. if (Global.inf.hospitalDr == 85)
  148. tabControl1.SelectedIndex = 0;
  149. else
  150. tabControl1.SelectedIndex = 3;
  151. }
  152. private void AddDGVColumn(DataGridView dgv, string headerText, string dataPropertyName, int width = 120)
  153. {
  154. DataGridViewColumn newColumn = new DataGridViewTextBoxColumn();
  155. newColumn.HeaderText = headerText;
  156. newColumn.Width = width;
  157. newColumn.DataPropertyName = dataPropertyName;
  158. newColumn.Name = dataPropertyName;
  159. dgv.Columns.Add(newColumn);
  160. }
  161. private DataTable GetDBLKComboxTable(string sqlStr)
  162. {
  163. InvokeHelper invoker = new InvokeHelper();
  164. dynamic joInparm = new JObject();
  165. dynamic joTmp = new JObject();
  166. joTmp.sqlStr = sqlStr;
  167. JArray jaParams = new JArray();
  168. jaParams.Add(joTmp);
  169. joInparm.Add("params", JArray.FromObject(jaParams));
  170. joInparm.code = "09010014";
  171. string inParam = joInparm.ToString();
  172. JObject joRtn = invoker.invokeInsuService(inParam, "获取下拉框消息");
  173. DataTable dt = (DataTable)joRtn["result"].ToObject(typeof(DataTable));
  174. return dt;
  175. }
  176. private void SetDBLKCombox(ref PTControl.DBLookupCombox dblcbx, string sqlStr)
  177. {
  178. dblcbx.sDisplayField = "Code,Name,SearchCode";
  179. dblcbx.sDisplayMember = "名称";
  180. dblcbx.sKeyWords = "Code,SearchCode";
  181. DataTable dt = GetDBLKComboxTable(sqlStr);
  182. dblcbx.DataSource = dt;
  183. if (dt?.Rows.Count > 0)
  184. {
  185. // default to select first one;
  186. }
  187. dblcbx.RowFilterVisible = true;
  188. dblcbx.TextBox.Width = 400;
  189. dblcbx.DataGridView.Width = 400;
  190. dblcbx.DataGridView.Columns[0].Name = "编码";
  191. dblcbx.DataGridView.Columns[1].Name = "名称";
  192. dblcbx.DataGridView.Columns[2].Name = "查找码";
  193. dblcbx.DataGridView.Columns[0].Width = 100;
  194. dblcbx.DataGridView.Columns[1].Width = 200;
  195. }
  196. public void setDgvTreatement(DataGridView dgv)
  197. {
  198. dgv.AutoGenerateColumns = false;
  199. dgv.Columns.Clear();
  200. AddDGVColumn(dgv, "人员编号", "psn_no", 350);
  201. AddDGVColumn(dgv, "待遇检查类型", "trt_chk_type", 130);
  202. AddDGVColumn(dgv, "基金支付类型", "fund_pay_type", 300);
  203. AddDGVColumn(dgv, "基金款项待遇享受标志", "trt_enjymnt_flag", 150);
  204. AddDGVColumn(dgv, "开始日期", "begndate", 220);
  205. AddDGVColumn(dgv, "结束日期", "enddate", 220);
  206. AddDGVColumn(dgv, "待遇检查结果", "trt_chk_rslt", 130);
  207. AddDGVColumn(dgv, "字段扩展", "exp_content", 120);
  208. dgv.ColumnHeadersDefaultCellStyle.Font = new Font("宋体", 9, FontStyle.Bold);
  209. dgv.ColumnHeadersHeight = 30;
  210. }
  211. private void setDgvInsuInfo()
  212. {
  213. AddDGVColumn(dgvInsuInfo, "余额", "balc", 70);
  214. AddDGVColumn(dgvInsuInfo, "险种类型", "insutype", 170);
  215. AddDGVColumn(dgvInsuInfo, "人员类别", "psn_type",100);
  216. AddDGVColumn(dgvInsuInfo, "人员参保状态", "psn_insu_stas",100);
  217. AddDGVColumn(dgvInsuInfo, "个人参保日期", "psn_insu_date", 150);
  218. AddDGVColumn(dgvInsuInfo, "暂停参保日期", "paus_insu_date", 150);
  219. AddDGVColumn(dgvInsuInfo, "公务员标志", "cvlserv_flag", 120);
  220. AddDGVColumn(dgvInsuInfo, "参保区划", "insuplc_admdvs", 85);
  221. AddDGVColumn(dgvInsuInfo, "单位名称", "emp_name", 280);
  222. AddDGVColumn(dgvInsuInfo, "险种类型编码", "insutypeNo",100);
  223. dgvInsuInfo.ColumnHeadersDefaultCellStyle.Font = new Font("宋体", 9, FontStyle.Bold);
  224. dgvInsuInfo.ColumnHeadersHeight = 40; //341124199210252617
  225. }
  226. private void setDgvIDInfo()
  227. {
  228. AddDGVColumn(dgvIDInfo, "人员身份类别", "psn_idet_type", 140);
  229. AddDGVColumn(dgvIDInfo, "人员类别等级", "psn_type_lv", 140);
  230. AddDGVColumn(dgvIDInfo, "备注", "memo", 150);
  231. AddDGVColumn(dgvIDInfo, "开始时间", "begntime", 200);
  232. AddDGVColumn(dgvIDInfo, "结束时间", "endtime", 200);
  233. dgvIDInfo.ColumnHeadersDefaultCellStyle.Font = new Font("宋体", 9, FontStyle.Bold);
  234. dgvIDInfo.ColumnHeadersHeight = 40;
  235. }
  236. private void setDgvChronicDiseaseRecordInfo()
  237. {
  238. AddDGVColumn(dgvChronicDiseaseRecordInfo, "门慢门特病种目录代码", "opsp_dise_code", 200);
  239. AddDGVColumn(dgvChronicDiseaseRecordInfo, "门慢门特病种名称", "opsp_dise_name", 200);
  240. AddDGVColumn(dgvChronicDiseaseRecordInfo, "开始时间", "begndate", 200);
  241. AddDGVColumn(dgvChronicDiseaseRecordInfo, "结束时间", "enddate", 200);
  242. dgvChronicDiseaseRecordInfo.ColumnHeadersDefaultCellStyle.Font = new Font("宋体", 9, FontStyle.Bold);
  243. dgvChronicDiseaseRecordInfo.ColumnHeadersHeight = 40;
  244. }
  245. private void uiButton1_Click(object sender, EventArgs e)
  246. {
  247. insuInfoIndex = dgvInsuInfo.CurrentRow.Index;
  248. if (dtIDInfo.Rows.Count != 0 )
  249. idInfoIndex = dgvIDInfo.CurrentRow.Index;
  250. joSelectedInsuInfo = new JObject();
  251. for (int i = 0; i < dtInsuInfo.Columns.Count; i++)
  252. {
  253. string key = dtInsuInfo.Columns[i].ColumnName;
  254. string value = dgvInsuInfo.CurrentRow.Cells[key].Value.ToString();
  255. joSelectedInsuInfo.Add(key, value);
  256. }
  257. DialogResult = DialogResult.OK;
  258. }
  259. private void uiButton2_Click(object sender, EventArgs e)
  260. {
  261. DialogResult = DialogResult.Cancel;
  262. }
  263. private JObject QueryPaymentDetail()
  264. {
  265. var joData = new { data = new { psn_no = this.tbPsnNO.Text } };
  266. return invoker.invokeCenterService(TradeEnum.QueryPaymentDetail,JObject.FromObject(joData));
  267. }
  268. private void btnRYDY2001_Click(object sender, EventArgs e)
  269. {
  270. string sInput = "", errorMsg = "";
  271. int iHis = dgvInsuInfo.CurrentRow.Index;
  272. if (dgvInsuInfo.CurrentRow == null)
  273. {
  274. MessageBox.Show("请选择参保信息再查询!");
  275. return;
  276. }
  277. string insutype = dgvInsuInfo.Rows[iHis].Cells["insutypeNo"].Value.ToString();
  278. string beginDate = DateTime.Now.AddYears(-1).ToString("yyyy-MM-dd HH:mm:ss");
  279. JObject joData = new JObject();
  280. joData.Add("psn_no", this.tbPsnNO.Text);
  281. joData.Add("insutype", insutype);
  282. joData.Add("fixmedins_code", Global.inf.hospitalNO);
  283. joData.Add("med_type", "11");
  284. joData.Add("begntime", beginDate);
  285. joData.Add("endtime", "");
  286. joData.Add("dise_codg", "");
  287. joData.Add("dise_name", "");
  288. joData.Add("oprn_oprt_code", "");
  289. joData.Add("oprn_oprt_name", "");
  290. joData.Add("matn_type", "");
  291. joData.Add("birctrl_type", "");
  292. JObject joInput = new JObject();
  293. joInput.Add("data", joData);
  294. JObject joRtn = invoker.invokeCenterService(TradeEnum.BenefitCheck, joInput);
  295. if (JsonHelper.parseCenterRtnValue(joRtn, out errorMsg) != 0)
  296. {
  297. MessageBox.Show("人员待遇享受检查失败:" + errorMsg);
  298. }
  299. else
  300. {
  301. string treatInfo = JsonHelper.getDestValue(joRtn, "output.trtinfo");
  302. if (!string.IsNullOrEmpty(treatInfo))
  303. {
  304. JArray jarray = JArray.Parse(treatInfo);
  305. StringBuilder sb = new StringBuilder();
  306. foreach (JObject obj in jarray)
  307. {
  308. string flag = JsonHelper.getDestValue(obj, "trt_enjymnt_flag");
  309. if ("0".Equals(flag))
  310. {
  311. string fundType = JsonHelper.getDestValue(obj, "fund_pay_type");
  312. string msg = JsonHelper.getDestValue(obj, "trt_chk_rslt");
  313. sb.Append("基金类型:【" + fundType + "】" + msg);
  314. }
  315. }
  316. if (sb.Length > 0)
  317. {
  318. MessageBox.Show("人员待遇享受检查结果:" + sb.ToString());
  319. return;
  320. }
  321. }
  322. MessageBox.Show("人员待遇享受检查结果:【正常】!");
  323. }
  324. }
  325. private void dgvInsuInfo_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  326. {
  327. uiButton1_Click(sender,e);
  328. }
  329. private JObject QueryTurnToOtherHospInfo()
  330. {
  331. var joData = new { data = new { psn_no = this.tbPsnNO.Text, refl_fil_type = tools.getDestPosStrBySpliter(cbTurnType.Text,1,".") , begntime = tbBeginDate.Text,endtime = tbEndDate.Text} };
  332. return invoker.invokeCenterService(TradeEnum.QueryTransferInfo, JObject.FromObject(joData));
  333. }
  334. private void btTurnToOtherHosp_Click(object sender, EventArgs e)
  335. {
  336. JObject joRtn = QueryTurnToOtherHospInfo();
  337. string err;
  338. if (JsonHelper.parseCenterRtnValue(joRtn, out err) != 0)
  339. {
  340. MessageBox.Show(err);
  341. return;
  342. }
  343. dgvTurnToOtherHospInfo.DataSource = (DataTable)joRtn["output"]["result"].ToObject(typeof(DataTable));
  344. }
  345. private JObject QueryTreamentInfo()
  346. {
  347. int i = dgvInsuInfo.SelectedIndex;
  348. string insutype = dgvInsuInfo.Rows[i].Cells["insutypeNo"].Value.ToString() ;
  349. //var joData = new { data = new { psn_no = this.tbPsnNO.Text, insutype =insutype, med_type = tools.getDestPosStrBySpliter(cbxMedicalType.Text, 1, "."), begntime = tbBeginDate_treatment.Text, endtime = tbEndDate_treatment.Text, fixmedins_code = Global.inf.hospitalNO} };
  350. var joData = new { data = new { psn_no = this.tbPsnNO.Text, insutype =insutype, med_type = MedType, begntime = tbBeginDate_treatment.Text, endtime = tbEndDate_treatment.Text, fixmedins_code = Global.inf.hospitalNO} };
  351. return invoker.invokeCenterService(TradeEnum.BenefitCheck, JObject.FromObject(joData));
  352. }
  353. private void btTreatment_Click(object sender, EventArgs e)
  354. {
  355. if (dblkcbxMedicalType.Text == "")
  356. {
  357. MessageBox.Show("请先选择医疗类别再查询");
  358. return;
  359. }
  360. JObject joRtn = QueryTreamentInfo();
  361. string err;
  362. if (JsonHelper.parseCenterRtnValue(joRtn, out err) != 0)
  363. {
  364. MessageBox.Show(err);
  365. return;
  366. }
  367. else
  368. {
  369. dgvTreatment.DataSource = (DataTable)joRtn["output"]["trtinfo"].ToObject(typeof(DataTable));
  370. DataTable dt = (DataTable)joRtn["output"]["trtinfo"].ToObject(typeof(DataTable));
  371. if (dt.Rows.Count == 0)
  372. MessageBox.Show("查询完成");
  373. }
  374. }
  375. private void dblkcbxMedicalType_AfterSelector(object sender, PTControl.AfterSelectorEventArgs e)
  376. {
  377. DataGridViewRow row = e.Value as DataGridViewRow;
  378. DataRowView dataRow = row.DataBoundItem as DataRowView;
  379. MedType = dataRow["Code"].ToString().Trim();
  380. }
  381. public int trade5301(string PsnNo, out string outParam)
  382. {
  383. outParam = "";
  384. string errorMsg = "";
  385. JObject joInput = new JObject();
  386. JObject joData = new JObject();
  387. joData.Add("psn_no", PsnNo);
  388. joInput.Add("data", joData);
  389. InvokeHelper invoker = new InvokeHelper();
  390. JObject joRtn = invoker.invokeCenterService(TradeEnum.QueryChronicDiseaseRecordInfo, joInput);
  391. if (JsonHelper.parseCenterRtnValue(joRtn, out errorMsg) != 0)
  392. {
  393. outParam = "人员慢特病备案信息查询失败:" + errorMsg;
  394. return -1;
  395. }
  396. else
  397. {
  398. if (JArray.Parse(JsonHelper.getDestValue(joRtn, "output.feedetail")).Count == 0)
  399. return -1;
  400. outParam = joRtn.ToString();
  401. return 0;
  402. }
  403. }
  404. private void dgvChronicDiseaseRecordInfo_CellClick(object sender, DataGridViewCellEventArgs e)
  405. {
  406. if ((DataTable)dgvChronicDiseaseRecordInfo.DataSource != null)
  407. {
  408. Global.pat.DiseasecCode =
  409. dgvChronicDiseaseRecordInfo.Rows[dgvChronicDiseaseRecordInfo.CurrentRow.Index].Cells["opsp_dise_code"].Value.ToString();
  410. Global.pat.DiseasecName =
  411. dgvChronicDiseaseRecordInfo.Rows[dgvChronicDiseaseRecordInfo.CurrentRow.Index].Cells["opsp_dise_name"].Value.ToString();
  412. Global.pat.iRes_Chronic = 0;
  413. uiButton1_Click(sender, e);
  414. }
  415. }
  416. private void dgvChronicDiseaseRecordInfo_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
  417. {
  418. if (e.RowIndex == dgvChronicDiseaseRecordInfo.CurrentRow.Index) // 如果是当前行
  419. e.CellStyle.BackColor = Color.Red; // 设置背景色
  420. }
  421. }
  422. }