DownLoad.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. using Newtonsoft.Json.Linq;
  2. using PTMedicalInsurance.Common;
  3. using PTMedicalInsurance.Helper;
  4. using PTMedicalInsurance.Variables;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Data;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12. using System.Xml.Linq;
  13. namespace PTMedicalInsurance.Business.HIS
  14. {
  15. /// <summary>
  16. /// HIS下载业务
  17. /// </summary>
  18. class DownLoad
  19. {
  20. private PTMedicalInsurance.Business.Center.DownLoad cDL = new PTMedicalInsurance.Business.Center.DownLoad();
  21. private PTMedicalInsurance.Business.MI.DataImport mDI = new PTMedicalInsurance.Business.MI.DataImport();
  22. /// <summary>
  23. /// 根据指定版本号下载医保目录
  24. /// </summary>
  25. /// <param name="ver"></param>
  26. /// <param name="directoryType"></param>
  27. /// <param name="uiProcessBar"></param>
  28. /// <param name="errorMessage"></param>
  29. /// <returns></returns>
  30. public int DownloadMIDiretoryBySpecifyVerNO(string ver, int directoryType, Control uiProcessBar, out string errMsg, out string currentMaxVerNO )
  31. {
  32. string txtPath = string.Empty;
  33. currentMaxVerNO = "";
  34. errMsg = "";
  35. int iResult = -1;
  36. string funNo = "";
  37. XElement xe = new XElement("input","") ;
  38. string fileName = DateTime.Now.ToString("yyyyMMddHHmmssffff");
  39. switch (directoryType)
  40. {
  41. case 0://医保目录
  42. {
  43. funNo = "91A"; //"1301";
  44. xe = new XElement("input",
  45. new XElement("prm_aaalsh", ver),
  46. new XElement("prm_outputfile", Global.curEvt.path + "\\DownLoad\\" + fileName + "_" + funNo + ".txt"));
  47. break;
  48. }
  49. case 1://ICD10
  50. {
  51. funNo = "61";
  52. xe = new XElement("input",
  53. new XElement("prm_aaalsh", ver),
  54. new XElement("prm_outputfile", Global.curEvt.path + "\\DownLoad\\" + fileName + "_" + funNo + ".txt"));
  55. break;
  56. }
  57. case 2://字典
  58. {
  59. funNo = "57";
  60. break;
  61. }
  62. case 3://国家医生编码
  63. {
  64. funNo = "GB001";
  65. xe = new XElement("input",
  66. new XElement("prm_akb020", Global.inf.hospitalNO),
  67. new XElement("page_num",1),
  68. new XElement("page_size", 999),
  69. new XElement("prm_outputfile", Global.curEvt.path + "\\DownLoad\\" + fileName + "_" + funNo + ".txt"));
  70. break;
  71. }
  72. case 4://国家护士编码
  73. {
  74. funNo = "GB002";
  75. xe = new XElement("input",
  76. new XElement("prm_akb020", Global.inf.hospitalNO),
  77. new XElement("page_num", 1),
  78. new XElement("page_size", 999),
  79. new XElement("prm_outputfile", Global.curEvt.path + "\\DownLoad\\" + fileName + "_" + funNo + ".txt"));
  80. break;
  81. }
  82. case 5://国家医院机构信息
  83. {
  84. funNo = "GB003";
  85. xe = new XElement("input",
  86. new XElement("prm_akb020", Global.inf.hospitalNO),
  87. new XElement("prm_outputfile", Global.curEvt.path + "\\DownLoad\\" + fileName + "_" + funNo + ".txt"));
  88. break;
  89. }
  90. case 6://自付比例
  91. {
  92. funNo = "91C"; //"1301";
  93. xe = new XElement("input",
  94. new XElement("prm_aaalsh", ver),
  95. new XElement("prm_outputfile", Global.curEvt.path + "\\DownLoad\\" + fileName + "_" + funNo + ".txt"));
  96. break;
  97. }
  98. case 7://医保限价
  99. {
  100. funNo = "91B"; //"1301";
  101. xe = new XElement("input",
  102. new XElement("prm_aaalsh", ver),
  103. new XElement("prm_outputfile", Global.curEvt.path + "\\DownLoad\\" + fileName + "_" + funNo + ".txt"));
  104. break;
  105. }
  106. }
  107. try
  108. {
  109. JObject joRtn = new JObject();
  110. if (directoryType == 2)
  111. joRtn = cDL.DownloadDictionary(funNo, xe);
  112. else
  113. joRtn = cDL.DownloadDirectory(funNo,xe);
  114. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) == 0)
  115. {
  116. JObject joImportRtn = new JObject();
  117. switch (directoryType)
  118. {
  119. case 0://医保目录 导入目录表
  120. {
  121. txtPath = JsonHelper.getDestValue(joRtn, "result.input.prm_outputfile");
  122. joImportRtn = mDI.insertDirectoryToMIIrisByTxt(txtPath, 50, directoryType, (Sunny.UI.UIProcessBar)uiProcessBar,out currentMaxVerNO );
  123. break;
  124. }
  125. case 1://ICD10 导入目录表
  126. {
  127. txtPath = JsonHelper.getDestValue(joRtn, "result.input.prm_outputfile");
  128. joImportRtn = mDI.insertDirectoryToMIIrisByTxt(txtPath, 50, directoryType, (Sunny.UI.UIProcessBar)uiProcessBar, out currentMaxVerNO);
  129. break;
  130. }
  131. case 2://字典 导入字典表
  132. {
  133. JArray jaList = JArray.Parse(JsonHelper.getDestValue(joRtn, "result.output.sqldata.row"));
  134. joImportRtn = mDI.importDictionary((Sunny.UI.UIProcessBar)uiProcessBar, jaList);
  135. break;
  136. }
  137. case 3://国家医生编码 前台展示
  138. {
  139. try
  140. {
  141. txtPath = JsonHelper.getDestValue(joRtn, "result.input.prm_outputfile");
  142. DataTable dt = TxtHelper.ToDataTable(txtPath, 16);
  143. PTMedicalInsurance.Forms.BasicDatas.FormSetter fs = new Forms.BasicDatas.FormSetter();
  144. fs.SetHeaderTextOfDownloadDoctorInfo((DataGridView)uiProcessBar);
  145. ((DataGridView)uiProcessBar).DataSource = dt;
  146. joImportRtn = JsonHelper.setIrisReturnValue(0,"",null);
  147. }
  148. catch (Exception subEx)
  149. {
  150. joImportRtn = JsonHelper.setIrisReturnValue(0, subEx.Message, null);
  151. }
  152. break;
  153. }
  154. case 4://国家护士编码 前台展示
  155. {
  156. try
  157. {
  158. txtPath = JsonHelper.getDestValue(joRtn, "result.input.prm_outputfile");
  159. DataTable dt = TxtHelper.ToDataTable(txtPath, 14);
  160. PTMedicalInsurance.Forms.BasicDatas.FormSetter fs = new Forms.BasicDatas.FormSetter();
  161. fs.SetHeaderTextOfDownloadNurseInfo((DataGridView)uiProcessBar);
  162. ((DataGridView)uiProcessBar).DataSource = dt;
  163. joImportRtn = JsonHelper.setIrisReturnValue(0, "", null);
  164. }
  165. catch (Exception subEx)
  166. {
  167. joImportRtn = JsonHelper.setIrisReturnValue(0, subEx.Message, null);
  168. }
  169. break;
  170. }
  171. case 5://国家医院机构信息 前台展示
  172. {
  173. try
  174. {
  175. txtPath = JsonHelper.getDestValue(joRtn, "result.input.prm_outputfile");
  176. DataTable dt = TxtHelper.ToDataTable(txtPath, 32);
  177. PTMedicalInsurance.Forms.BasicDatas.FormSetter fs = new Forms.BasicDatas.FormSetter();
  178. fs.SetHeaderTextOfDownloadHospitalInfo((DataGridView)uiProcessBar);
  179. ((DataGridView)uiProcessBar).DataSource = dt;
  180. joImportRtn = JsonHelper.setIrisReturnValue(0, "", null);
  181. }
  182. catch (Exception subEx)
  183. {
  184. joImportRtn = JsonHelper.setIrisReturnValue(0, subEx.Message, null);
  185. }
  186. break;
  187. }
  188. case 6://医保目录自付比例 导入目录表
  189. {
  190. txtPath = JsonHelper.getDestValue(joRtn, "result.input.prm_outputfile");
  191. joImportRtn = mDI.insertDirectoryToMIIrisByTxt(txtPath, 50, directoryType, (Sunny.UI.UIProcessBar)uiProcessBar, out currentMaxVerNO);
  192. break;
  193. }
  194. case 7://医保限价 导入目录表
  195. {
  196. txtPath = JsonHelper.getDestValue(joRtn, "result.input.prm_outputfile");
  197. joImportRtn = mDI.insertDirectoryToMIIrisByTxt(txtPath, 50, directoryType, (Sunny.UI.UIProcessBar)uiProcessBar, out currentMaxVerNO);
  198. break;
  199. }
  200. }
  201. if (JsonHelper.parseIrisRtnValue(joImportRtn, out errMsg) == 0)
  202. {
  203. iResult = 0;
  204. }
  205. else
  206. {
  207. errMsg = "导入数据出现错误,请查看日志!" + errMsg;//joImportRtn["errorMessage"].ToString();
  208. }
  209. }
  210. return iResult;
  211. }
  212. catch (Exception ex)
  213. {
  214. errMsg = "PTMedicalInsurance.Business.HIS.DownLoad.DownloadMIDiretoryBySpecifyVerNO提示:" + ex.Message;
  215. return -1;
  216. }
  217. }
  218. }
  219. }