HisBusiness.cs 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. /******************************************************************************
  2. * 文件名称: HisBusiness.cs
  3. * 文件说明: HIS业务的封装
  4. * 当前版本: V1.0
  5. * 创建日期: 2022-04-14
  6. *
  7. * 2020-04-14: 增加 SingleDownload 方法
  8. * 2020-04-14: 增加 AutoDownload 方法
  9. ******************************************************************************/
  10. using Newtonsoft.Json.Linq;
  11. using System;
  12. using System.Collections.Generic;
  13. using System.Linq;
  14. using System.Text;
  15. using System.Threading.Tasks;
  16. using PTMedicalInsurance.Helper;
  17. using System.Windows.Forms;
  18. namespace PTMedicalInsurance.Business
  19. {
  20. class HisBusiness
  21. {
  22. /// <summary>
  23. /// 目录查询信息下载
  24. /// </summary>
  25. /// <param name="directoryType"></param>
  26. /// <param name="errorMessage"></param>
  27. /// <returns></returns>
  28. public int InsuMedQuery(JObject joData, string funNo, out string Outpar)
  29. {
  30. string errorMessage = "";
  31. Outpar = "";
  32. int iResult = -1;
  33. try
  34. {
  35. CenterBusiness centerBusiness = new CenterBusiness();
  36. JObject joRtn = centerBusiness.InvokeMedicalInsuranceInquiry(funNo, joData);
  37. if (JsonHelper.parseIrisRtnValue(joRtn, out errorMessage) == 0)
  38. {
  39. iResult = 0;
  40. Outpar = joRtn.ToString();
  41. return 0;
  42. }
  43. else
  44. {
  45. GlobalVariables.writeLog(joRtn.ToString());
  46. errorMessage = "调用交易"+ funNo + "出现错误,请查看日志!"; //joImportRtn["errorMessage"].ToString();
  47. return iResult;
  48. }
  49. }
  50. catch (Exception ex)
  51. {
  52. errorMessage = "InvokeMedicalInsuranceInquiry提示:" + ex.Message;
  53. return iResult;
  54. }
  55. }
  56. public int MedicalInstitutionSave(string sInput,string Code,out string errMsg)
  57. {
  58. string OutMsg = "";
  59. int iResult = -1;
  60. errMsg = "";
  61. try
  62. {
  63. DataImoport bus = new DataImoport();
  64. JObject joImportRtn = bus.importDataToIrisByJson(sInput, Code);
  65. if (JsonHelper.parseBusinessJson(joImportRtn, out OutMsg) == 0)
  66. {
  67. iResult = 0;
  68. }
  69. else
  70. {
  71. GlobalVariables.writeLog(joImportRtn.ToString());
  72. OutMsg = "导入医疗机构数据出现错误,请查看日志!";//joImportRtn["errorMessage"].ToString();
  73. errMsg = OutMsg;
  74. return iResult;
  75. }
  76. return iResult;
  77. }
  78. catch (Exception ex)
  79. {
  80. errMsg = ex.Message;
  81. return -1;
  82. }
  83. }
  84. /// <summary>
  85. /// 医保目录单个版本号的下载
  86. /// </summary>
  87. /// <param name="ver"></param>
  88. /// <param name="directoryType"></param>
  89. /// <param name="uiProcessBar"></param>
  90. /// <param name="errorMessage"></param>
  91. /// <returns></returns>
  92. public int SingleDownload(string ver, int directoryType,Sunny.UI.UIProcessBar uiProcessBar, out string errorMessage)
  93. {
  94. string txtPath = string.Empty;
  95. errorMessage = "";
  96. int iResult = -1;
  97. string funNo = "";
  98. switch (directoryType)
  99. {
  100. case 0://西药中成药目录下载
  101. {
  102. funNo = "1301";
  103. break;
  104. }
  105. case 1://医疗服务项目目录下载
  106. {
  107. funNo = "1305";
  108. break;
  109. }
  110. case 2://医用耗材目录下载
  111. {
  112. funNo = "1306";
  113. break;
  114. }
  115. case 3://疾病与诊断目录下载
  116. {
  117. funNo = "1307";
  118. break;
  119. }
  120. case 4://手术操作目录下载
  121. {
  122. funNo = "1308";
  123. break;
  124. }
  125. case 5://门诊慢特病种目录下载
  126. {
  127. funNo = "1309";
  128. break;
  129. }
  130. case 6://按病种付费病种目录下载
  131. {
  132. funNo = "1310";
  133. break; ;
  134. }
  135. case 7://日间手术治疗病种目录下载
  136. {
  137. funNo = "1311";
  138. break;
  139. }
  140. case 8://字典表 1901
  141. {
  142. break;
  143. }
  144. case 9://中药饮片目录下载
  145. {
  146. funNo = "1302";
  147. break;
  148. }
  149. case 10://医疗机构制剂
  150. {
  151. funNo = "1303";
  152. break;
  153. }
  154. case 11://肿瘤形态学
  155. {
  156. funNo = "1313";
  157. break;
  158. }
  159. case 12://中医疾病
  160. {
  161. funNo = "1314";
  162. break;
  163. }
  164. case 13://中医证候
  165. {
  166. funNo = "1315";
  167. break;
  168. }
  169. }
  170. try
  171. {
  172. CenterBusiness centerBusiness = new CenterBusiness();
  173. JObject joRtn = centerBusiness.DownDirecotry(funNo, ver);
  174. if (JsonHelper.parseBusinessJson(joRtn, out errorMessage) == 0)
  175. {
  176. txtPath = joRtn["filePath"].ToString();
  177. DataImoport bus = new DataImoport();
  178. JObject joImportRtn = bus.importDataToIrisByTxt(txtPath, 50, directoryType + 1, uiProcessBar);
  179. if (JsonHelper.parseBusinessJson(joImportRtn, out errorMessage) == 0)
  180. {
  181. iResult = 0;
  182. }
  183. else
  184. {
  185. GlobalVariables.writeLog(joImportRtn.ToString());
  186. errorMessage = "导入数据出现错误,请查看日志!";//joImportRtn["errorMessage"].ToString();
  187. }
  188. }
  189. return iResult;
  190. }
  191. catch (Exception ex)
  192. {
  193. errorMessage = "SingleDownload提示:" + ex.Message;
  194. return -1;
  195. }
  196. }
  197. /// <summary>
  198. /// 医保目录单个版本号的下载
  199. /// </summary>
  200. /// <param name="ver"></param>
  201. /// <param name="directoryType"></param>
  202. /// <param name="uiProcessBar"></param>
  203. /// <param name="errorMessage"></param>
  204. /// <returns></returns>
  205. public int downloadDicionary(JObject joData, Sunny.UI.UIProcessBar uiProcessBar, out string errorMessage)
  206. {
  207. errorMessage = "";
  208. int iResult = -1;
  209. try
  210. {
  211. CenterBusiness centerBusiness = new CenterBusiness();
  212. JObject joRtn = centerBusiness.DownDictionay(joData);
  213. if (JsonHelper.parseCenterJson(joRtn, out errorMessage) == 0)
  214. {
  215. DataImoport bus = new DataImoport();
  216. JArray jaList = JArray.Parse(JsonHelper.getJsonValue(joRtn,"output.list"));
  217. //MessageBox.Show(jaList.ToString());
  218. JObject joImportRtn = bus.importDictinary(uiProcessBar,jaList);
  219. if (JsonHelper.parseBusinessJson(joImportRtn, out errorMessage) == 0)
  220. {
  221. iResult = 0;
  222. }
  223. else
  224. {
  225. GlobalVariables.writeLog(joImportRtn.ToString());
  226. errorMessage = "导入数据出现错误,请查看日志!";
  227. }
  228. }
  229. return iResult;
  230. }
  231. catch (Exception ex)
  232. {
  233. errorMessage = "downloadDicionary提示:" + ex.Message;
  234. return -1;
  235. }
  236. }
  237. /// <summary>
  238. /// 自动下载医保目录,直到最新版本(返回报错)
  239. /// </summary>
  240. /// <param name="directoryType"></param>
  241. /// <param name="uiProcessBar"></param>
  242. /// <param name="errorMessage"></param>
  243. /// <returns></returns>
  244. public int AutoDownload(int directoryType, Sunny.UI.UIProcessBar uiProcessBar, out string errorMessage)
  245. {
  246. int iResult = 0;
  247. errorMessage = "";
  248. try
  249. {
  250. while (iResult == 0)
  251. {
  252. IrisInterfaceService irisBus = new IrisInterfaceService();
  253. JObject joMaxVerNO = irisBus.getDirectoryMaxVersionNO(directoryType);
  254. string ver = joMaxVerNO["result"]["MaxVersionNO"].ToString();
  255. iResult = JsonHelper.parseBusinessJson(joMaxVerNO, out errorMessage);
  256. iResult = SingleDownload(ver, directoryType,uiProcessBar, out errorMessage);
  257. }
  258. return iResult;
  259. }
  260. catch (Exception ex)
  261. {
  262. errorMessage = ex.Message;
  263. return -1;
  264. }
  265. }
  266. }
  267. }