ToRecordFrom.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. using Newtonsoft.Json;
  2. using Newtonsoft.Json.Linq;
  3. using PTMedicalInsurance;
  4. using PTMedicalInsurance.Helper;
  5. using PTMedicalInsurance.Variables;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.ComponentModel;
  9. using System.Data;
  10. using System.Drawing;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Threading.Tasks;
  14. using System.Windows.Forms;
  15. using PTMedicalInsurance.Business;
  16. using System.IO;
  17. using PTMedicalInsurance.FormSetter;
  18. using PTMedicalInsurance.Common;
  19. using static PTMedicalInsurance.Helper.DropHelper;
  20. namespace PTMedicalInsurance.Forms
  21. {
  22. public partial class ToRecordFrom : Form
  23. {
  24. public ToRecordFrom()
  25. {
  26. InitializeComponent();
  27. }
  28. JObject userMsg = (JObject)JsonConvert.DeserializeObject("");
  29. DropHelper drop = new DropHelper();
  30. IrisDataHelper irisData = new IrisDataHelper();
  31. InvokeHelper invoker = new InvokeHelper();
  32. #region 下拉框自动选择
  33. /// <summary>
  34. /// 下拉框自动选择
  35. /// </summary>
  36. /// <param name="data">数据源(字典)</param>
  37. /// <param name="comBox">框体</param>
  38. public void ComBoxChoose(Dictionary<string, string> data, ComboBox comBox,bool drop=false)
  39. {
  40. comBox.Items.Clear();
  41. List<ComboBoxItem> temp = new List<ComboBoxItem>();
  42. foreach (var item in data)
  43. {
  44. //循环添加数据源
  45. if (item.Value.Contains(comBox.Text))
  46. {
  47. ComboBoxItem com = new ComboBoxItem();
  48. com.Text = item.Value;
  49. com.Value = item.Key;
  50. temp.Add(com);
  51. }
  52. }
  53. if (temp.Count < 1)
  54. {
  55. //输入参数未找到时添加空白选择
  56. ComboBoxItem zero = new ComboBoxItem();
  57. zero.Text = "";
  58. zero.Value = "";
  59. temp.Add(zero);
  60. }
  61. try
  62. {
  63. comBox.Items.AddRange(temp.ToArray());
  64. comBox.SelectionStart = comBox.Text.Length; //更新索引
  65. Cursor = Cursors.Default; //设置光标
  66. if (drop)
  67. {
  68. comBox.DroppedDown = true; //自动弹出下拉框
  69. }
  70. }
  71. catch (Exception ee)
  72. {
  73. comBox.SelectedIndex = -1;
  74. }
  75. }
  76. #endregion
  77. private void btn_GetMsg_Click(object sender, EventArgs e)
  78. {
  79. //InsuBusiness insu = new InsuBusiness();
  80. //MessageBox.Show("调用读卡:" + insu.GetPatientInfo(""));
  81. #region 调用1101
  82. ////调用1101
  83. //JObject joData = new JObject();
  84. //joData.Add("mdtrt_cert_type", "居民身份证");//就医凭证类型
  85. //joData.Add("mdtrt_cert_no", "02"); //就医凭证编码
  86. //joData.Add("card_sn", Global.pat.cardSN); //为社保卡时必填
  87. ////joData.Add("begntime", ""); //开始时间
  88. //joData.Add("psn_cert_type", "居民身份证"); //证件类型
  89. //joData.Add("certno", "511923187001..."); //身份证号
  90. //joData.Add("psn_name", Global.pat.name); //人员姓名
  91. //JObject joInput = new JObject();
  92. //joInput.Add("data", joData);
  93. //InvokeHelper invoker = new InvokeHelper();
  94. //JObject joRtn = invoker.invokeCenterService("1101", JsonHelper.setCenterInpar("1101", joInput));
  95. // MessageBox.Show(joRtn.ToString());
  96. #endregion
  97. string rtnJson = "{\"body\":{\"output\":{\"idetinfo\":[],\"baseinfo\":{\"certno\":\"342822196511171215\",\"psn_no\":\"13465308\",\"gend\":\"1\",\"brdy\":-130147200000,\"psn_cert_type\":\"01\",\"psn_name\":\"高国正\",\"age\":56},\"insuinfo\":[{\"insuplc_admdvs\":\"340800\",\"cvlserv_flag\":\"0\",\"balc\":0,\"psn_type\":\"1501\",\"emp_name\":\"云水村\",\"psn_insu_stas\":\"1\",\"insutype\":\"390\"}]},\"infcode\":0,\"inf_refmsgid\":\"349900202208221634300039305403\"},\"code\":200,\"csbCode\":200,\"message\":\"SUCCESS\",\"requestId\":\"0a429bab16611572691156719d0116\",\"state\":{}}";
  98. #region 解析返回值,填充
  99. JObject joRtn = (JObject)JsonConvert.DeserializeObject(rtnJson);
  100. string code = joRtn["code"].ToString();
  101. string csbCode = joRtn["csbCode"].ToString();
  102. string message = joRtn["message"].ToString();
  103. string requestId = joRtn["requestId"].ToString();
  104. if (code == "200" && message == "SUCCESS")
  105. {
  106. string infcode = joRtn["body"]["infcode"].ToString();
  107. if (infcode == "-1") return;
  108. JObject baseinfo = (JObject)JsonConvert.DeserializeObject(joRtn["body"]["output"]["baseinfo"].ToString());
  109. this.tbx_No.Text = baseinfo["psn_no"].ToString();
  110. //this.cbx_CardType.Text = baseinfo["certno"].ToString();
  111. //this.cbx_CardType.Text = baseinfo["psn_cert_type"].ToString();
  112. this.tbx_Name.Text = baseinfo["psn_name"].ToString();
  113. this.tbx_TranType.Text = baseinfo["age"].ToString();
  114. JArray insuData = (JArray)JsonConvert.DeserializeObject(joRtn["body"]["output"]["insuinfo"].ToString());
  115. JObject insuinfo = (JObject)insuData[0];
  116. tbx_AddNo.Text = insuinfo["insuplc_admdvs"].ToString();
  117. //tbx_AddNo.Text = insuinfo["cvlserv_flag"].ToString();
  118. tbx_InsuType.Text = insuinfo["insutype"].ToString();
  119. //tbx_MediGen.Text = insuinfo["insuplc_admdvs"].ToString();
  120. }
  121. #endregion
  122. int fdee = 1;
  123. }
  124. private void ToRecordFrom_Load(object sender, EventArgs e)
  125. {
  126. //初始化身份选择
  127. Dictionary<string, string> data = drop.CredenecType();
  128. ComBoxChoose(data, cbx_CardType, false);
  129. cbx_CardType.SelectedIndex = 0;
  130. //初始化病种选择
  131. Dictionary<string, string> dise = drop.DiseName();
  132. ComBoxChoose(dise, cbx_DiseName, false);
  133. cbx_DiseName.SelectedIndex = 0;
  134. }
  135. private void cbx_CardType_TextUpdate(object sender, EventArgs e)
  136. {
  137. Dictionary<string, string> data = drop.CredenecType();
  138. ComboBox cb = sender as ComboBox;
  139. ComBoxChoose(data, cb, true);
  140. }
  141. private void cbx_DiseName_TextUpdate(object sender, EventArgs e)
  142. {
  143. Dictionary<string, string> data = drop.DiseName();
  144. ComboBox cb = sender as ComboBox;
  145. ComBoxChoose(data, cb, true);
  146. }
  147. /// <summary>
  148. /// 提交备案
  149. /// </summary>
  150. /// <param name="sender"></param>
  151. /// <param name="e"></param>
  152. private void btn_OK_Click(object sender, EventArgs e)
  153. {
  154. JObject joRtn = invoker.invokeCenterService("2501", JsonHelper.setCenterInpar("2501", ToJson()));
  155. //JObject jo = (JObject)JsonConvert.DeserializeObject(rtnJson);
  156. if (string.IsNullOrWhiteSpace(joRtn.ToString())) MessageBox.Show("备案失败,原因是:" + joRtn.ToString()) ;
  157. string code = joRtn["infcode"].ToString();
  158. if(code=="-1") MessageBox.Show("备案失败,原因是:" + joRtn.ToString());
  159. //string code = joRtn["code"].ToString();
  160. //string csbCode = joRtn["csbCode"].ToString();
  161. //string message = joRtn["message"].ToString();
  162. //string requestId = joRtn["requestId"].ToString(); oString();
  163. if (code == "200")//成功时调用
  164. {
  165. string dcla = joRtn["trt_dcla_detl_sn"].ToString();
  166. //提交备案
  167. JObject rtn = invoker.invokeInsuService(ToJson(dcla), "ToRecord");
  168. }
  169. }
  170. public string ToJson(string dclaRtn="")
  171. {
  172. #region 下拉框取值
  173. var diseName = (ComboBoxItem)cbx_DiseName.Items[cbx_DiseName.SelectedIndex == -1 ? 0 : cbx_DiseName.SelectedIndex];
  174. //var diagName = (ComboBoxItem)cbx_DiagName.Items[cbx_DiagName.SelectedIndex == -1 ? 0 : cbx_DiagName.SelectedIndex];
  175. //json.AppendFormat("\"diag_code\":\"{0}\",", diagName.Value);
  176. //json.AppendFormat("\"diag_name\":\"{0}\",", diagName.Text.Trim());
  177. //var MedInst = (ComboBoxItem)cbx_MedInst.Items[cbx_MedInst.SelectedIndex == -1 ? 0 : cbx_MedInst.SelectedIndex];
  178. //json.AppendFormat("\"fixmedins_code\":\"{0}\",", MedInst.Value);
  179. //json.AppendFormat("\"fixmedins_name\":\"{0}\",", MedInst.Text.Trim());
  180. var ToMedInst = (ComboBoxItem)cbx_ToMedInst.Items[cbx_ToMedInst.SelectedIndex == -1 ? 0 : cbx_ToMedInst.SelectedIndex];
  181. //json.AppendFormat("\"reflin_medins_no\":\"{0}\",", ToMedInst.Value);
  182. //json.AppendFormat("\"reflin_medins_name\":\"{0}\",", ToMedInst.Text.Trim());
  183. #endregion
  184. JObject joData = new JObject();
  185. joData.Add("psn_no", tbx_No.Text.Trim());
  186. joData.Add("insutype", tbx_InsuType.Text.Trim());
  187. joData.Add("tel", tbx_Phone.Text.Trim());
  188. joData.Add("addr", tbx_address.Text.Trim());
  189. joData.Add("insu_optins", tbx_AddNo.Text.Trim());
  190. joData.Add("diag_code", diseName.Value.ToString());
  191. joData.Add("diag_name", diseName.Text.Trim());
  192. joData.Add("dise_cond_dscr", rtb_DiagDesc.Text.Trim());
  193. joData.Add("reflin_medins_no", ToMedInst.Value.ToString());
  194. joData.Add("reflin_medins_name", ToMedInst.Text.Trim());
  195. joData.Add("mdtrtarea_admdvs", tbx_ToAddNo.Text.Trim());
  196. joData.Add("hosp_agre_refl_flag", "1");
  197. joData.Add("refl_type", tbx_TranType.Text.Trim());
  198. joData.Add("refl_date", dpk_TranDate.Text.Trim());
  199. joData.Add("refl_rea", tbx_TranRea.Text.Trim());
  200. joData.Add("refl_opnn", tbx_TranOpin.Text.Trim());
  201. joData.Add("begndate", dpk_StaDate.Text.Trim());
  202. joData.Add("enddate", dpk_EndDate.Text.Trim());
  203. joData.Add("refl_used_flag", "");
  204. JObject joInput = new JObject();
  205. joInput.Add("refmedin", joData);
  206. return joInput.ToString();
  207. /*
  208. System.Text.StringBuilder json = new System.Text.StringBuilder("{\"refmedin\":[{", 1000);
  209. json.AppendFormat("\"psn_no\":\"{0}\",", tbx_No.Text.Trim());
  210. json.AppendFormat("\"insutype\":\"{0}\",", tbx_InsuType.Text.Trim());
  211. json.AppendFormat("\"tel\":\"{0}\",", tbx_Phone.Text.Trim());
  212. json.AppendFormat("\"addr\":\"{0}\",", tbx_address.Text.Trim());
  213. json.AppendFormat("\"insu_optins\":\"{0}\",", tbx_AddNo.Text.Trim());
  214. json.AppendFormat("\"med_type\":\"{0}\",", tbx_MediGen.Text.Trim());
  215. #region 下拉框取值
  216. var diseName = (ComboBoxItem)cbx_DiseName.Items[cbx_DiseName.SelectedIndex == -1 ? 0 : cbx_DiseName.SelectedIndex];
  217. json.AppendFormat("\"dise_codg\":\"{0}\",", diseName.Value);
  218. json.AppendFormat("\"dise_name\":\"{0}\",", diseName.Text.Trim());
  219. //var diagName = (ComboBoxItem)cbx_DiagName.Items[cbx_DiagName.SelectedIndex == -1 ? 0 : cbx_DiagName.SelectedIndex];
  220. //json.AppendFormat("\"diag_code\":\"{0}\",", diagName.Value);
  221. //json.AppendFormat("\"diag_name\":\"{0}\",", diagName.Text.Trim());
  222. //var MedInst = (ComboBoxItem)cbx_MedInst.Items[cbx_MedInst.SelectedIndex == -1 ? 0 : cbx_MedInst.SelectedIndex];
  223. //json.AppendFormat("\"fixmedins_code\":\"{0}\",", MedInst.Value);
  224. //json.AppendFormat("\"fixmedins_name\":\"{0}\",", MedInst.Text.Trim());
  225. //var ToMedInst = (ComboBoxItem)cbx_ToMedInst.Items[cbx_ToMedInst.SelectedIndex == -1 ? 0 : cbx_ToMedInst.SelectedIndex];
  226. //json.AppendFormat("\"reflin_medins_no\":\"{0}\",", ToMedInst.Value);
  227. //json.AppendFormat("\"reflin_medins_name\":\"{0}\",", ToMedInst.Text.Trim());
  228. #endregion
  229. //若返回流水号非空,则表示成功,保存到IRIS
  230. if (dclaRtn != "") {
  231. json.AppendFormat("\"trt_dcla_detl_sn\":\"{0}\",", dclaRtn);
  232. }
  233. json.AppendFormat("\"dise_cond_dscr\":\"{0}\",", rtb_DiagDesc.Text.Trim());
  234. json.AppendFormat("\"refl_type\":\"{0}\",", tbx_TranType.Text.Trim());
  235. json.AppendFormat("\"mdtrtarea_admdvs\":\"{0}\",", tbx_ToAddNo.Text.Trim());
  236. json.AppendFormat("\"refl_date\":\"{0}\",", dpk_TranDate.Text.Trim());
  237. json.AppendFormat("\"refl_rea\":\"{0}\",", tbx_TranRea.Text.Trim());
  238. json.AppendFormat("\"refl_opnn\":\"{0}\",", tbx_TranOpin.Text.Trim());
  239. json.AppendFormat("\"begndate\":\"{0}\",", dpk_StaDate.Text.Trim());
  240. json.AppendFormat("\"enddate\":\"{0}\",", dpk_EndDate.Text.Trim());
  241. #region 拼上Iris所需
  242. json.AppendFormat("\"iresult\":\"\","); //操作结果 0已上传 9已撤销
  243. json.AppendFormat("\"InPut\":\"\","); //调用入参
  244. json.AppendFormat("\"OutPut\":\"\","); //调用反参
  245. //json.AppendFormat("\"trtDclaDetlSn\":\"\","); //申报流水号
  246. #endregion
  247. json.AppendFormat("\"hosp_agre_refl_flag\":\"{0}\"", "1");
  248. json.Append("}]}");
  249. return json.ToString();
  250. */
  251. }
  252. private void btn_Cancel_Click(object sender, EventArgs e)
  253. {
  254. ////获取拼装的接口调用json
  255. //string getJson = irisData.GetToFileData();
  256. JObject toIris = new JObject();
  257. string code = "";
  258. toIris.Add(new JProperty("params", SetJsonObject("SetToFile", out code)));
  259. toIris.Add(new JProperty("code", code));
  260. //toIris.Add(new JProperty("session", irisData.AddUserJson()));
  261. toIris.Add(new JProperty("session", userMsg));
  262. string rtnStr = toIris.ToString();
  263. //去除json数据里的换行符转义
  264. rtnStr = rtnStr.Replace("\r\n","");
  265. //调用iris推送
  266. JObject rtn = invoker.invokeIrisService(rtnStr, "applyDataToIris");
  267. //this.Close();
  268. }
  269. #region 拼装Json
  270. private JArray SetJsonObject(string types, out string code)
  271. {
  272. code = "";
  273. JArray jaData = new JArray();
  274. switch (types)
  275. {
  276. case "SetToFile"://民族药品目
  277. {
  278. code = "02030001";
  279. JObject jo = (JObject)JsonConvert.DeserializeObject(ToJson());
  280. jaData = (JArray)JsonConvert.DeserializeObject(jo["refmedin"].ToString());
  281. break;
  282. }
  283. }
  284. return jaData;
  285. }
  286. #endregion
  287. }
  288. }