PerDesigRecord.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. using Newtonsoft.Json;
  2. using Newtonsoft.Json.Linq;
  3. using PTMedicalInsurance.Helper;
  4. using PTMedicalInsurance.Variables;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Windows.Forms;
  8. using WinFrom1;
  9. using static PTMedicalInsurance.Helper.DropHelper;
  10. namespace PTMedicalInsurance
  11. {
  12. public partial class PerDesigRecord : Form
  13. {
  14. DropHelper drop = new DropHelper();
  15. IrisDataHelper irisData = new IrisDataHelper();
  16. InvokeHelper invoker = new InvokeHelper();
  17. Dictionary<string, string> cardTypeDic = new Dictionary<string, string>();
  18. Dictionary<string, string> mediDic = new Dictionary<string, string>();
  19. //string user = HaErBinMIMI.Forms.ToRecord.Helper.UserMessage.session;
  20. JObject userMsg = (JObject)JsonConvert.DeserializeObject("");
  21. //Dictionary<string, string> cardType = new Dictionary<string, string>();
  22. public PerDesigRecord()
  23. {
  24. InitializeComponent();
  25. }
  26. private void btn_GetMsg_Click(object sender, EventArgs e)
  27. {
  28. var cardType = (ComboBoxItem)cbx_CardType.Items[cbx_CardType.SelectedIndex == -1 ? 0 : cbx_CardType.SelectedIndex];
  29. JObject joData = new JObject();
  30. joData.Add("mdtrt_cert_type", cardType.Text.ToString());//就医凭证类型
  31. joData.Add("mdtrt_cert_no", cardType.Value.ToString()); //就医凭证编码
  32. //joData.Add("card_sn", Global.pat.cardSN); //为社保卡时必填
  33. //joData.Add("begntime", ""); //开始时间
  34. joData.Add("psn_cert_type", cardType.Value.ToString()); //证件类型 -02
  35. joData.Add("certno", this.tbx_IdCard.Text.Trim()); //身份证号
  36. joData.Add("psn_name", Global.pat.name); //人员姓名
  37. JObject joInput = new JObject();
  38. joInput.Add("data", joData);
  39. JObject joRtn = invoker.invokeInsuService(JsonHelper.setCenterInpar("1101", joInput), "获取人员信息");
  40. //MessageBox.Show(joRtn.ToString());
  41. if (!string.IsNullOrEmpty(joRtn.ToString()))
  42. {
  43. if (joRtn.ToString().IndexOf("errorCode") != -1) {
  44. if (joRtn["errorCode"].ToString() == "-1") {
  45. MessageBox.Show(joRtn["errorMessage"].ToString());
  46. return;
  47. }
  48. }
  49. if (joRtn["infcode"].ToString() == "-1") return;
  50. string code = joRtn["code"].ToString();
  51. string csbCode = joRtn["csbCode"].ToString();
  52. string message = joRtn["message"].ToString();
  53. string requestId = joRtn["requestId"].ToString();
  54. if (code == "200" && message == "SUCCESS")
  55. {
  56. JObject baseinfo = (JObject)JsonConvert.DeserializeObject(joRtn["body"]["output"]["baseinfo"].ToString());
  57. this.tbx_No.Text = baseinfo["psn_no"].ToString();
  58. //this.cbx_CardType.Text = baseinfo["certno"].ToString();
  59. //this.cbx_CardType.Text = baseinfo["psn_cert_type"].ToString();
  60. this.tbx_Name.Text = baseinfo["psn_name"].ToString();
  61. //JArray insuData = (JArray)JsonConvert.DeserializeObject(joRtn["body"]["output"]["insuinfo"].ToString());
  62. //JObject insuinfo = (JObject)insuData[0];
  63. //tbx_AddNo.Text = insuinfo["insuplc_admdvs"].ToString();
  64. //tbx_AddNo.Text = insuinfo["cvlserv_flag"].ToString();
  65. //tbx_InsuType.Text = insuinfo["insutype"].ToString();
  66. //tbx_MediGen.Text = insuinfo["insuplc_admdvs"].ToString();
  67. }
  68. }
  69. }
  70. private void PerDesigRecord_Load(object sender, EventArgs e)
  71. {
  72. //初始化身份选择
  73. cardTypeDic = drop.CredenecType();
  74. ComBoxChoose(cardTypeDic, cbx_CardType, false);
  75. ComBoxChoose(cardTypeDic, cbx_AgencyType, false);
  76. cbx_CardType.SelectedIndex = 0;
  77. cbx_AgencyType.SelectedIndex = 0;
  78. //初始化医药机构
  79. mediDic = drop.Medinsinfo();
  80. ComBoxChoose(mediDic, cbx_MedInst, false);
  81. cbx_MedInst.SelectedIndex = 0;
  82. }
  83. private void cbx_MedInst_TextUpdate(object sender, EventArgs e)
  84. {
  85. //Dictionary<string, string> data = drop.Medinsinfo();
  86. ComboBox cb = sender as ComboBox;
  87. ComBoxChoose(mediDic, cb, true);
  88. }
  89. private void cbx_AgencyType_TextChanged(object sender, EventArgs e)
  90. {
  91. //Dictionary<string, string> data = drop.CredenecType();
  92. ComboBox cb = sender as ComboBox;
  93. ComBoxChoose(cardTypeDic, cb, true);
  94. }
  95. private void cbx_CardType_TextUpdate(object sender, EventArgs e)
  96. {
  97. //Dictionary<string, string> data = drop.CredenecType();
  98. ComboBox cb = sender as ComboBox;
  99. ComBoxChoose(cardTypeDic, cb, true);
  100. }
  101. private void btn_OK_Click(object sender, EventArgs e)
  102. {
  103. //JObject joRtn = invoker.invokeInsuService(ToJson("data"), "定点备案");
  104. JObject joRtn = invoker.invokeInsuService(JsonHelper.setCenterInpar("2506", ToJson("data")),"人员定点备案");
  105. MessageBox.Show(joRtn.ToString());
  106. //JObject jo = (JObject)JsonConvert.DeserializeObject(rtnJson);
  107. if (joRtn.ToString().IndexOf("errorCode") != -1)
  108. {
  109. string errorCode = joRtn["errorCode"].ToString();
  110. if (errorCode == "-1")
  111. {
  112. MessageBox.Show(joRtn["errorMessage"].ToString());
  113. return;
  114. }
  115. }
  116. string code = joRtn["code"].ToString();
  117. string csbCode = joRtn["csbCode"].ToString();
  118. string message = joRtn["message"].ToString();
  119. if (code == "200" && message == "SUCCESS") //调用IRIS
  120. {
  121. string infcode = joRtn["infcode"].ToString();
  122. if (infcode == "-1") MessageBox.Show("备案失败,原因是:" + joRtn.ToString());
  123. if (infcode == "200")//成功时调用
  124. {
  125. string dcla = joRtn["trt_dcla_detl_sn"].ToString();
  126. //提交IRIS
  127. JObject toJson = ToJson("params", dcla);
  128. toJson.Add(new JProperty("code", "02030007"));
  129. toJson.Add(new JProperty("session", userMsg));
  130. JObject rtn = invoker.invokeIrisService(toJson.ToString().Replace("\r\n",""), "人员定点备案");
  131. string errorCode = rtn["errorCode"].ToString().Trim();
  132. if (errorCode == "0")
  133. {
  134. MessageBox.Show("备案操作已完成!");
  135. }
  136. else
  137. {
  138. MessageBox.Show("写入IRIS失败!");
  139. }
  140. }
  141. }
  142. }
  143. /// <summary>
  144. /// 组装json
  145. /// </summary>
  146. /// <param name="parmName">传入Key值</param>
  147. /// <param name="dclaRtn">流水号</param>
  148. /// <returns></returns>
  149. public JObject ToJson(string parmName, string dclaRtn = "")
  150. {
  151. System.Text.StringBuilder json = new System.Text.StringBuilder("{\"" + parmName + "\":[{", 1000);
  152. json.AppendFormat("\"psn_no\":\"{0}\",", tbx_No.Text.Trim());
  153. json.AppendFormat("\"biz_appy_type\":\"{0}\",", tbx_BizAppy.Text.Trim());
  154. json.AppendFormat("\"tel\":\"{0}\",", tbx_Phone.Text.Trim());
  155. json.AppendFormat("\"addr\":\"{0}\",", tbx_address.Text.Trim());
  156. json.AppendFormat("\"begndate\":\"{0}\",", dpk_StaDate.Text.Trim());
  157. json.AppendFormat("\"enddate\":\"{0}\",", dpk_EndDate.Text.Trim());
  158. json.AppendFormat("\"agnter_name\":\"{0}\",", tbx_AgnterName.Text.Trim());
  159. var agencyType = (ComboBoxItem)cbx_AgencyType.Items[cbx_AgencyType.SelectedIndex == -1 ? 0 : cbx_AgencyType.SelectedIndex];
  160. json.AppendFormat("\"agnter_cert_type\":\"{0}\",", agencyType.Value);
  161. json.AppendFormat("\"agnter_certno\":\"{0}\",", tbx_AgnterNo.Text.Trim());
  162. json.AppendFormat("\"agnter_tel\":\"{0}\",", tbx_AgnterTel.Text.Trim());
  163. json.AppendFormat("\"agnter_addr\":\"{0}\",", tbx_AgnterAddr.Text.Trim());
  164. json.AppendFormat("\"agnter_rlts\":\"{0}\",", tbx_AgnteRlts.Text.Trim());
  165. json.AppendFormat("\"fix_srt_no\":\"{0}\",", tbx_FixSrt.Text.Trim());
  166. var medInst = (ComboBoxItem)cbx_MedInst.Items[cbx_MedInst.SelectedIndex == -1 ? 0 : cbx_MedInst.SelectedIndex];
  167. json.AppendFormat("\"fixmedins_code\":\"{0}\",", medInst.Value);
  168. json.AppendFormat("\"fixmedins_name\":\"{0}\",", medInst.Text.Trim());
  169. var cardType = (ComboBoxItem)cbx_CardType.Items[cbx_CardType.SelectedIndex == -1 ? 0 : cbx_CardType.SelectedIndex];
  170. json.AppendFormat("\"psn_cert_type\":\"{0}\",", cardType.Value);
  171. //json.AppendFormat("\"dise_name\":\"{0}\",", cardType.Text.Trim());
  172. json.AppendFormat("\"certno\":\"{0}\",", tbx_IdCard.Text.Trim());
  173. json.AppendFormat("\"psn_name\":\"{0}\",", tbx_Name.Text.Trim());
  174. json.AppendFormat("\"med_trt_type\":\"{0}\",", tbx_MedType.Text.Trim());
  175. //若返回流水号非空,则表示成功,保存到IRIS
  176. if (dclaRtn != "")
  177. {
  178. json.AppendFormat("\"trt_dcla_detl_sn\":\"{0}\",", dclaRtn);//申报流水号
  179. }
  180. #region 拼上Iris所需
  181. json.AppendFormat("\"iresult\":\"\","); //操作结果 0已上传 9已撤销
  182. json.AppendFormat("\"InPut\":\"\","); //调用入参
  183. json.AppendFormat("\"OutPut\":\"\","); //调用反参
  184. #endregion
  185. json.AppendFormat("\"memo\":\"{0}\"", rtb_Remark.Text.Trim());
  186. json.Append("}]}");
  187. return JObject.Parse(json.ToString());
  188. }
  189. #region 下拉框自动选择
  190. /// <summary>
  191. /// 下拉框自动选择
  192. /// </summary>
  193. /// <param name="data">数据源(字典)</param>
  194. /// <param name="comBox">框体</param>
  195. public void ComBoxChoose(Dictionary<string, string> data, ComboBox comBox, bool drop)
  196. {
  197. comBox.Items.Clear();
  198. List<ComboBoxItem> temp = new List<ComboBoxItem>();
  199. foreach (var item in data)
  200. {
  201. //循环添加数据源
  202. if (item.Value.Contains(comBox.Text))
  203. {
  204. ComboBoxItem com = new ComboBoxItem();
  205. com.Text = item.Value;
  206. com.Value = item.Key;
  207. temp.Add(com);
  208. }
  209. }
  210. if (temp.Count < 1)
  211. {
  212. //输入参数未找到时添加空白选择
  213. ComboBoxItem zero = new ComboBoxItem();
  214. zero.Text = "";
  215. zero.Value = "";
  216. temp.Add(zero);
  217. }
  218. try
  219. {
  220. comBox.Items.AddRange(temp.ToArray());
  221. comBox.SelectionStart = comBox.Text.Length; //更新索引
  222. Cursor = Cursors.Default; //设置光标
  223. if (drop)
  224. {
  225. comBox.DroppedDown = true; //自动弹出下拉框
  226. }
  227. }
  228. catch (Exception ee)
  229. {
  230. comBox.SelectedIndex = -1;
  231. }
  232. }
  233. #endregion
  234. private void btn_Cancel_Click(object sender, EventArgs e)
  235. {
  236. }
  237. private void button1_Click(object sender, EventArgs e)
  238. {
  239. }
  240. }
  241. }