InpatientRegistration.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. using Newtonsoft.Json;
  2. using Newtonsoft.Json.Linq;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Data;
  7. using System.Drawing;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12. using PTMedicalInsurance.Common;
  13. using PTMedicalInsurance.Helper;
  14. using PTMedicalInsurance.Variables;
  15. namespace PTMedicalInsurance.Forms
  16. {
  17. public partial class InpatientRegistration : Form
  18. {
  19. public InpatientRegistration()
  20. {
  21. InitializeComponent();
  22. this.StartPosition = FormStartPosition.CenterParent;
  23. Global.pat.medType = string.IsNullOrEmpty(Global.pat.medType) ? "21": Global.pat.medType; //默认医疗
  24. if (Global.pat.RYorCY == "2")
  25. {
  26. string sqlCondition = " and A.Interface_Dr = '" + Global.inf.interfaceDr.ToString() + "'";
  27. string sqlStr = " SELECT B.Code,B.Descripts AS Name FROM HB_Dictionary A JOIN HB_DictionaryDataDetail B ON A.ID = B.HBDictionary_Dr "
  28. + " WHERE B.Code='" + Global.pat.insuType + "' and A.InsuCode = 'insutype'" + sqlCondition;
  29. SetDBLKCombox(ref dblkcbxInsuranceType, sqlStr);
  30. sqlStr = "select A.Code, A.Name FROM HB_MedInsuDirectory A where A.ValidFlag='1' And A.HisType=7" + sqlCondition;
  31. //// 如果登记选择了,则直接用登记的病种
  32. //if(!string.IsNullOrEmpty(Global.pat.DiseasecCode))
  33. //{
  34. // sqlStr += " and A.Code='" + Global.pat.DiseasecCode + "' ";
  35. //}
  36. SetDBLKCombox(ref dblkcbxDisease, sqlStr);
  37. sqlStr = " SELECT B.Code,B.Descripts AS Name FROM HB_Dictionary A JOIN HB_DictionaryDataDetail B ON A.ID = B.HBDictionary_Dr"
  38. + " WHERE B.Code='" + Global.pat.medType + "' and A.InsuCode = 'med_type'" + sqlCondition;
  39. SetDBLKCombox(ref dblkcbxMedicalType, sqlStr);
  40. 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 = 'psn_setlway'" + sqlCondition;
  41. SetDBLKCombox(ref dblkcbxSettelmentWay, sqlStr);
  42. 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 = 'dscg_way'" + sqlCondition;
  43. SetDBLKCombox(ref dblkcbxExitway, sqlStr);
  44. }
  45. else
  46. {
  47. string sqlCondition = " and A.Interface_Dr = '" + Global.inf.interfaceDr.ToString() + "'";
  48. string 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 = 'insutype'" + sqlCondition;
  49. SetDBLKCombox(ref dblkcbxInsuranceType, sqlStr);
  50. sqlStr = "select A.Code, A.Name FROM HB_MedInsuDirectory A where A.ValidFlag='1' And A.HisType=7" + sqlCondition;
  51. SetDBLKCombox(ref dblkcbxDisease, sqlStr);
  52. 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 = 'psn_setlway'" + sqlCondition;
  53. SetDBLKCombox(ref dblkcbxSettelmentWay, sqlStr);
  54. 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;
  55. SetDBLKCombox(ref dblkcbxMedicalType, sqlStr);
  56. 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 = 'dscg_way'" + sqlCondition;
  57. SetDBLKCombox(ref dblkcbxExitway, sqlStr);
  58. }
  59. cbxAccountPay.Checked = false;
  60. }
  61. public Boolean b2001 = false;
  62. private DataTable dtDisease;
  63. //private DataTable dtDiseaseType;
  64. //private DataTable dtInsuranceType;
  65. //private DataTable dtMedicalType;
  66. //private DataTable dtOperation;
  67. //private DataTable dtSettelmentType;
  68. //private DataTable dtHospType;
  69. //险种
  70. public string insuType { get; set; }
  71. public string insuTypeName { get; set; }
  72. //医疗类别(人群类别)
  73. public string med_type { get; set; }
  74. public string med_type_name { get; set; }
  75. //诊断
  76. public string diseCodg { get; set; }
  77. public string diseName{ get; set; }
  78. //手术
  79. public string oprn_oprt_code { get; set; }
  80. public string oprn_oprt_name{ get; set; }
  81. //病种
  82. public string dise_type_code { get; set; }
  83. public string dise_type_name { get; set; }
  84. /// <summary>
  85. /// 本地病种编码
  86. /// </summary>
  87. public string local_dise_code { get; set; }
  88. //结算方式
  89. public string psn_setlway { get; set; }
  90. public string psn_setlway_name { get; set; }
  91. //治疗方式
  92. public string treatway_code = "A";
  93. public string treatway_name { get; set; }
  94. //外伤
  95. public string traumaFlag = "0";
  96. //涉及第三方标志
  97. public string relTtpFlag = "0";
  98. public string hospType = "0";
  99. //分级诊疗
  100. public string claTrtFlag = "0";
  101. public string otpErReflFlag = "0";
  102. public string mdtrtGrpType;
  103. public string unifPayStdType = "";
  104. //危重患者
  105. public string dangerFlag = "0";
  106. //住院类型(离院)
  107. public string iptTypeCode = "1";
  108. public string iptTypeName { get; set; }
  109. public DataTable DtDiagnose { get; set; }
  110. public string personAccountUsedFlag = "0";
  111. public void initBaseInfo(JObject jObject)
  112. {
  113. JObject jo = JObject.Parse(jObject["output"].Text());
  114. DataTable dtInsuInfo = (DataTable)jo["insuinfo"].ToObject(typeof(DataTable));
  115. JObject joBaseInfo = JObject.FromObject(jo["baseinfo"]);
  116. this.txtName.Text = joBaseInfo["psn_name"].Text();
  117. this.txtPsnNO.Text = joBaseInfo["psn_no"].Text();
  118. this.txtGend.Text = joBaseInfo["gend"].Text();
  119. this.txtBirthDay.Text = joBaseInfo["brdy"].Text();
  120. this.txtCertType.Text = joBaseInfo["psn_cert_type"].Text();
  121. this.txtCertNO.Text = joBaseInfo["certno"].Text();
  122. this.txtAge.Text = joBaseInfo["age"].Text();
  123. if (dtInsuInfo?.Rows.Count > 0)
  124. {
  125. this.txtCorp.Text = dtInsuInfo.Rows[0]["emp_name"].ToString();
  126. this.txtBalc.Text = dtInsuInfo.Rows[0]["balc"].ToString();
  127. this.txtAdmvs.Text = dtInsuInfo.Rows[0]["insuplc_admdvs"].ToString();
  128. this.txtPsnType.Text = dtInsuInfo.Rows[0]["psn_type"].ToString();
  129. this.txtInsuType.Text = dtInsuInfo.Rows[0]["insutype"].ToString();
  130. }
  131. }
  132. private DataTable GetDBLKComboxTable(string sqlStr)
  133. {
  134. InvokeHelper invoker = new InvokeHelper();
  135. dynamic joInparm = new JObject();
  136. dynamic joTmp = new JObject();
  137. joTmp.sqlStr = sqlStr;
  138. JArray jaParams = new JArray();
  139. jaParams.Add(joTmp);
  140. joInparm.Add("params", JArray.FromObject(jaParams));
  141. joInparm.code = "09010014";
  142. string inParam = joInparm.ToString();
  143. JObject joRtn = invoker.invokeInsuService(inParam,"获取下拉框消息");
  144. //dynamic jsonRtn = JsonConvert.DeserializeObject(strRtn);
  145. DataTable dt = (DataTable)joRtn["result"].ToObject(typeof(DataTable));
  146. //dt.Columns[0].ColumnName = "编码";
  147. //dt.Columns[1].ColumnName = "名称";
  148. //dt.Columns[2].ColumnName = "拼音查找码";
  149. return dt;
  150. }
  151. private void SetDBLKCombox(ref PTControl.DBLookupCombox dblcbx, string sqlStr)
  152. {
  153. dblcbx.sDisplayField = "Code,Name,SearchCode";
  154. dblcbx.sDisplayMember = "名称";
  155. dblcbx.sKeyWords = "Code,SearchCode";
  156. dblcbx.DataSource = GetDBLKComboxTable(sqlStr);
  157. dblcbx.RowFilterVisible = true;
  158. dblcbx.TextBox.Width = 400;
  159. dblcbx.DataGridView.Width = 400;
  160. dblcbx.DataGridView.Columns[0].Name = "编码";
  161. dblcbx.DataGridView.Columns[1].Name = "名称";
  162. dblcbx.DataGridView.Columns[2].Name = "查找码";
  163. dblcbx.DataGridView.Columns[0].Width = 100;
  164. dblcbx.DataGridView.Columns[1].Width = 200;
  165. }
  166. private void InpatientRegistration_Load(object sender, EventArgs e)
  167. {
  168. dgvDiagnose.AutoGenerateColumns = false;
  169. dgvDiagnose.DataSource = DtDiagnose;
  170. //DtDiagnose.AcceptChanges();
  171. dgvDiagnose.ReadOnly = true;
  172. }
  173. private void button1_Click(object sender, EventArgs e)
  174. {
  175. //外伤标志
  176. if (Chk_TraumaFlag.Checked)
  177. traumaFlag = "1";
  178. else
  179. traumaFlag = "0";
  180. //涉及第三方标志
  181. if (Chk_RelTtpFlag.Checked)
  182. relTtpFlag = "1";
  183. else
  184. relTtpFlag = "0";
  185. if (chkDanger.Checked)
  186. {
  187. dangerFlag = "1";
  188. }
  189. //单病种时必须选择病种
  190. if (string.IsNullOrEmpty(this.diseCodg) && "0201".Equals(psn_setlway))
  191. {
  192. MessageBox.Show("单病种时必须选择病种");
  193. return;
  194. }
  195. // 是否使用个人账户金额
  196. if (cbxAccountPay.Checked)
  197. {
  198. personAccountUsedFlag = "1";
  199. }
  200. this.local_dise_code = txtLocateCode.Text.Trim();
  201. this.DialogResult = DialogResult.OK;
  202. }
  203. private void dblkcbxInsuranceType_AfterSelector(object sender, PTControl.AfterSelectorEventArgs e)
  204. {
  205. DataGridViewRow row = e.Value as DataGridViewRow;
  206. DataRowView dataRow = row.DataBoundItem as DataRowView;
  207. insuType = dataRow["Code"].ToString().Trim();
  208. insuTypeName = dataRow["Name"].ToString().Trim();
  209. }
  210. private void dblkcbxMedicalType_AfterSelector(object sender, PTControl.AfterSelectorEventArgs e)
  211. {
  212. DataGridViewRow row = e.Value as DataGridViewRow;
  213. DataRowView dataRow = row.DataBoundItem as DataRowView;
  214. med_type = dataRow["Code"].ToString().Trim();
  215. med_type_name = dataRow["Name"].ToString().Trim();
  216. }
  217. private void dblkcbxDisease_AfterSelector(object sender, PTControl.AfterSelectorEventArgs e)
  218. {
  219. DataGridViewRow row = e.Value as DataGridViewRow;
  220. DataRowView dataRow = row.DataBoundItem as DataRowView;
  221. diseCodg = dataRow["Code"].ToString().Trim();
  222. diseName = dataRow["Name"].ToString().Trim();
  223. }
  224. private void dblkcbxOperation_AfterSelector(object sender, PTControl.AfterSelectorEventArgs e)
  225. {
  226. DataGridViewRow row = e.Value as DataGridViewRow;
  227. DataRowView dataRow = row.DataBoundItem as DataRowView;
  228. oprn_oprt_code = dataRow["Code"].ToString().Trim();
  229. oprn_oprt_name = dataRow["Name"].ToString().Trim();
  230. }
  231. private void dblkcbxSettelmentWay_AfterSelector(object sender, PTControl.AfterSelectorEventArgs e)
  232. {
  233. DataGridViewRow row = e.Value as DataGridViewRow;
  234. DataRowView dataRow = row.DataBoundItem as DataRowView;
  235. psn_setlway = dataRow["Code"].ToString().Trim();
  236. psn_setlway_name = dataRow["Name"].ToString().Trim();
  237. }
  238. private void dblkcbxDiseaseType_AfterSelector(object sender, PTControl.AfterSelectorEventArgs e)
  239. {
  240. DataGridViewRow row = e.Value as DataGridViewRow;
  241. DataRowView dataRow = row.DataBoundItem as DataRowView;
  242. dise_type_code = dataRow["Code"].ToString().Trim();
  243. dise_type_name = dataRow["Name"].ToString().Trim();
  244. }
  245. private void button2_Click(object sender, EventArgs e)
  246. {
  247. this.DialogResult = DialogResult.Cancel;
  248. }
  249. private void cbxAccountPay_ValueChanged(object sender, bool value)
  250. {
  251. if (cbxAccountPay.Checked)
  252. {
  253. personAccountUsedFlag = "1";
  254. }
  255. else
  256. {
  257. personAccountUsedFlag = "0";
  258. }
  259. }
  260. public int DealFor2001(string funNO)
  261. {
  262. //人员待遇享受检查
  263. string errMsg = "";
  264. JObject joData2001 = new JObject();
  265. joData2001.Add("psn_no", Global.pat.psn_no);
  266. joData2001.Add("insutype", insuType);
  267. joData2001.Add("fixmedins_code", Global.inf.hospitalNO);
  268. joData2001.Add("med_type", med_type);
  269. joData2001.Add("begntime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  270. joData2001.Add("endtime", "");
  271. joData2001.Add("dise_codg", diseCodg);
  272. joData2001.Add("dise_name", diseName);
  273. joData2001.Add("oprn_oprt_code", "");
  274. joData2001.Add("oprn_oprt_name", "");
  275. joData2001.Add("matn_type", "");
  276. joData2001.Add("birctrl_type", "");
  277. JObject joInput = new JObject();
  278. joInput.Add("data", joData2001);
  279. InvokeHelper invoker = new InvokeHelper();
  280. JObject joRtn2001 = invoker.invokeCenterService(TradeEnum.BenefitCheck, joInput);
  281. if (JsonHelper.parseCenterRtnValue(joRtn2001, out errMsg) != 0)
  282. {
  283. MessageBox.Show("人员待遇享受检查调用失败,中心返回错误信息:" + errMsg);
  284. return -1;
  285. }
  286. else
  287. {
  288. string treatInfo = JsonHelper.getDestValue(joRtn2001, "output.trtinfo");
  289. if (!string.IsNullOrEmpty(treatInfo))
  290. {
  291. JArray jarray = JArray.Parse(treatInfo);
  292. StringBuilder sb = new StringBuilder();
  293. foreach (JObject obj in jarray)
  294. {
  295. string flag = JsonHelper.getDestValue(obj, "trt_enjymnt_flag");
  296. if ("0".Equals(flag))
  297. {
  298. string fundType = JsonHelper.getDestValue(obj, "fund_pay_type");
  299. string msg = JsonHelper.getDestValue(obj, "trt_chk_rslt");
  300. sb.Append("基金类型:【" + fundType + "】" + msg);
  301. }
  302. }
  303. if (sb.Length > 0)
  304. {
  305. MessageBox.Show("人员待遇享受检查结果:" + sb.ToString());
  306. return -1;
  307. }
  308. }
  309. MessageBox.Show("人员待遇享受检查结果:【正常】!");
  310. }
  311. return 0;
  312. }
  313. private void uiButton1_Click(object sender, EventArgs e)
  314. {
  315. DealFor2001("");
  316. }
  317. private void dblkcbxHospType_AfterSelector(object sender, PTControl.AfterSelectorEventArgs e)
  318. {
  319. DataGridViewRow row = e.Value as DataGridViewRow;
  320. DataRowView dataRow = row.DataBoundItem as DataRowView;
  321. iptTypeCode = dataRow["Code"].ToString().Trim();
  322. iptTypeName = dataRow["Name"].ToString().Trim();
  323. }
  324. private void dblkcbxTreatway_AfterSelector(object sender, PTControl.AfterSelectorEventArgs e)
  325. {
  326. }
  327. }
  328. }