BasicData.cs 65 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653
  1. using Newtonsoft.Json;
  2. using Newtonsoft.Json.Linq;
  3. using PTMedicalInsurance.Business;
  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.IO;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Threading.Tasks;
  15. using System.Windows.Forms;
  16. using PTMedicalInsurance.FormSetter;
  17. using PTMedicalInsurance.Common;
  18. namespace PTMedicalInsurance.Forms
  19. {
  20. public partial class BasicData : Form
  21. {
  22. //设置实例
  23. CenterBusiness cBus = new CenterBusiness();
  24. HisMainBusiness hBus = new HisMainBusiness();
  25. HisIrisServices hIS = new HisIrisServices();
  26. MIIrisServices mIS = new MIIrisServices();
  27. InvokeHelper invoker = new InvokeHelper();
  28. InsuServices Iis = new InsuServices();
  29. //1.声明自适应类实例
  30. AutoResizeForm asc = new AutoResizeForm();
  31. public JObject joSelectedInsuInfo;
  32. public int insuInfoIndex = 0;
  33. public int idInfoIndex = 0;
  34. DataTable dtExport;
  35. int iCount = 50;
  36. private string err = "";
  37. #region 初始化
  38. private void Form1_Load(object sender, EventArgs e)
  39. {
  40. this.WindowState = FormWindowState.Maximized;
  41. rbgDirecType.ValueChanged += new Sunny.UI.UIRadioButtonGroup.OnValueChanged(rbgDirecType_ValueChanged);
  42. LabExplain.Visible = false;
  43. }
  44. public BasicData()
  45. {
  46. InitializeComponent();
  47. rbgDirecType.SelectedIndex = 0;
  48. rbgDirecType_C.SelectedIndex = 0;
  49. rbgInsuDirecType_C.SelectedIndex = 0;
  50. rbSingleDown.Checked = true;
  51. rbOnlyName.Checked = true;
  52. rbSelf.Checked = true;
  53. this.rbgDirecType.ValueChanged += new Sunny.UI.UIRadioButtonGroup.OnValueChanged(this.rbgDirecType_ValueChanged);
  54. this.pgDownload.PageChanged += new Sunny.UI.UIPagination.OnPageChangeEventHandler(this.pgDownload_PageChanged);
  55. this.pgCenterDirect.PageChanged += new Sunny.UI.UIPagination.OnPageChangeEventHandler(this.pgCenterDirect_PageChanged);
  56. this.pgHISDirect.PageChanged += new Sunny.UI.UIPagination.OnPageChangeEventHandler(this.pgHISDirect_PageChanged);
  57. Font rowFont = new Font("UTF-8", 8);
  58. Font columnFont = new Font("UTF-8", 9);
  59. rbgDirecType.SelectedIndex = 8;
  60. rbAll.Checked = true;
  61. this.rbAll.ValueChanged += new Sunny.UI.UIRadioButton.OnValueChanged(this.rbAll_ValueChanged);
  62. this.rbSelf.ValueChanged += new Sunny.UI.UIRadioButton.OnValueChanged(this.GetMainInterfaceDr);
  63. this.rbSpecial.ValueChanged += new Sunny.UI.UIRadioButton.OnValueChanged(this.GetMainInterfaceDr);
  64. this.rbMain.ValueChanged += new Sunny.UI.UIRadioButton.OnValueChanged(this.GetMainInterfaceDr);
  65. //tabControl1.SelectedIndex = 1;
  66. //this.StartPosition = FormStartPosition.CenterParent;
  67. asc.controllInitializeSize(this);
  68. asc.controlAutoSize(this);
  69. GridViewSetter gvs = new GridViewSetter();
  70. gvs.SetHeaderTextOfMapping_HisDirectory(dgvHISDirectory);
  71. GetMainInterfaceDr(null,true);
  72. }
  73. #endregion
  74. #region 函数封装
  75. private void queryInsuDirectory(int currentPage, int pageSize, int directoryType, int interfaceDr, string code)
  76. {
  77. try
  78. {
  79. string dirCode = "";
  80. string dirName = "";
  81. string approvalNO = "";
  82. string DosageForm = "";
  83. string Specifications = "";
  84. string manufacturers = "";
  85. Sunny.UI.UIDataGridView dgv;
  86. Sunny.UI.UIPagination pg;
  87. if (tabControl1.SelectedIndex == 0)
  88. {
  89. dirCode = tbDirectoryCode.Text;
  90. dirName = tbDircetoryName.Text;
  91. approvalNO = "";
  92. dgv = dgvDirectoy;
  93. pg = pgDownload;
  94. }
  95. else
  96. {
  97. dirName = tbCenterDirectoryFilter.Text;
  98. dirCode = tbInsuCode.Text;
  99. dgv = dgvCenterDirectory;
  100. approvalNO = tbApprovalNO.Text;
  101. pg = pgCenterDirect;
  102. //manufacturers = tbManufacturer.Text;
  103. //DosageForm = tbDosageForm.Text;
  104. //Specifications = tbSpecifications.Text;
  105. }
  106. JObject joInput = new JObject {
  107. { "currentPage" , currentPage },
  108. { "pageSize" , pageSize },
  109. { "serviceCode" , code },
  110. { "directoryType" , directoryType },
  111. { "directoryCode" , dirCode },
  112. { "directoryName" , dirName },
  113. { "approvalNO" , approvalNO },
  114. { "dosageForm" , DosageForm },
  115. { "specifications" , Specifications },
  116. { "manufacturers" , manufacturers },
  117. { "directoryDr" , interfaceDr }
  118. };
  119. JObject joRtn = mIS.getMIDirectoryByPagination(joInput);
  120. if (joRtn["errorCode"].ToString() != "0")
  121. {
  122. MessageBox.Show("IRIS数据返回错误:" + joRtn["errorMessage"].ToString());
  123. return;
  124. }
  125. if (joRtn["result"]["rows"] == null)
  126. {
  127. MessageBox.Show("该节点不存在");
  128. return;
  129. }
  130. if (joRtn["result"]["total"].ToString() == "0")
  131. {
  132. MessageBox.Show("未查询到数据");
  133. dgv.DataSource = null;
  134. return;
  135. }
  136. DataTable dt = (DataTable)joRtn["result"]["rows"].ToObject(typeof(DataTable));
  137. int totalCount = int.Parse(joRtn["result"]["total"].ToString());
  138. pg.TotalCount = totalCount;
  139. pg.PageSize = pageSize;
  140. dgv.DataSource = dt;
  141. dgv.Columns[0].ReadOnly = true;
  142. }
  143. catch (Exception ex)
  144. {
  145. MessageBox.Show("查询异常:" + ex.Message);
  146. }
  147. }
  148. private void setHeaderTxt(int directoryType, Sunny.UI.UIDataGridView dgv)
  149. {
  150. GridViewSetter gvdSetter = new GridViewSetter();
  151. switch (directoryType)
  152. {
  153. case 0://药品
  154. {
  155. gvdSetter.SetHeaderTextOfDrug(dgv);
  156. break;
  157. }
  158. case 1://诊疗
  159. {
  160. gvdSetter.SetHeaderTextOfMedicalService(dgv);
  161. break;
  162. }
  163. case 2://材料
  164. {
  165. gvdSetter.SetHeaderTextOfMaterials(dgv);
  166. break;
  167. }
  168. case 3://疾病诊断
  169. {
  170. gvdSetter.SetHeaderTextOfDiagnose(dgv);
  171. break;
  172. }
  173. case 4://手术
  174. {
  175. gvdSetter.SetHeaderTextOfDiagnose(dgv);
  176. break;
  177. }
  178. case 5://慢性病
  179. {
  180. gvdSetter.SetHeaderTextOfDiagnose(dgv);
  181. break;
  182. }
  183. case 6://DRGs
  184. {
  185. gvdSetter.SetHeaderTextOfDiagnose(dgv);
  186. break; ;
  187. }
  188. case 7://日间手术
  189. {
  190. gvdSetter.SetHeaderTextOfDiagnose(dgv);
  191. break; ;
  192. }
  193. case 8://字典表
  194. {
  195. gvdSetter.SetHeaderTextOfDictionary(dgv);
  196. break;
  197. }
  198. case 9://中药饮片下载
  199. {
  200. gvdSetter.SetHeaderTextOfChineseMedicine(dgv);
  201. break;
  202. }
  203. case 10://医药机构制剂目录下载
  204. {
  205. gvdSetter.SetHeaderTextOfPreparation(dgv);
  206. break;
  207. }
  208. case 11://肿瘤形态学下载
  209. {
  210. gvdSetter.SetHeaderTextOfTumorMorphology(dgv);
  211. break;
  212. }
  213. case 12://中医疾病下载
  214. {
  215. gvdSetter.GetChineseDiagnoseJsonByTxt(dgv);
  216. break;
  217. }
  218. case 13://中医证候下载
  219. {
  220. gvdSetter.GetTCMSyndromeJsonByTxt(dgv);
  221. break;
  222. }
  223. case 14://民族药品
  224. {
  225. gvdSetter.GetEthnicMedicineJsonByTxt(dgv);
  226. break;
  227. }
  228. case 15://目录信息查询
  229. {
  230. gvdSetter.GetMedInsuCatalogJsonByTxt(dgv);
  231. break;
  232. }
  233. case 16://医疗与医保目录匹配关系查询
  234. {
  235. gvdSetter.GetMedInsuCorrespondencJsonByTxt(dgv);
  236. break;
  237. }
  238. case 17://医药机构目录匹配查询
  239. {
  240. gvdSetter.GetMedInstCorrespondencJsonByTxt(dgv);
  241. break;
  242. }
  243. case 18://医保目录限价查询
  244. {
  245. gvdSetter.GetMedInsuFixedPriceJsonByTxt(dgv);
  246. break;
  247. }
  248. case 19://医保目录先自付比例下载
  249. {
  250. gvdSetter.GetMedInsuFirstPayProportionJsonByTxt(dgv);
  251. break;
  252. }
  253. case 20://医药机构信息
  254. {
  255. gvdSetter.GetMedicalInstitutionJsonByTxt(dgv);
  256. break;
  257. }
  258. }
  259. gvdSetter.DatagridviewColumnWidthAdaptation(dgv);
  260. }
  261. private void queryHISInsuDirectory(int directoryType, int pageIndex, int count, Sunny.UI.UIDataGridView dgv, int interfaceDr)
  262. {
  263. string code = "09010042";
  264. if (tabControl1.SelectedIndex == 0)
  265. {
  266. if (rbgDirecType.SelectedIndex == 20)
  267. {
  268. code = "090100XX";
  269. }
  270. else if (rbgDirecType.SelectedIndex == 8)
  271. {
  272. code = "09010043";
  273. }
  274. else
  275. {
  276. code = "09010042";
  277. }
  278. if (rbgDirecType.SelectedIndex <= 13)
  279. {
  280. queryInsuDirectory(pageIndex, count, directoryType + 1, interfaceDr, code);
  281. setHeaderTxt(directoryType, dgv);
  282. }
  283. else //几个医保查询该部分数据不存数据库只是临时查询(除医疗机构信息查询外)
  284. {
  285. //生成DataView列
  286. //setHeaderTxt(directoryType, dgv);
  287. string pages, recordCounts, errorMessage;
  288. dynamic joData = GetInput(rbgDirecType.SelectedIndex, out string funNo);
  289. JObject joRtn = cBus.InvokeMedicalInsuranceInquiry(funNo, joData);
  290. if (joRtn["infcode"].ToString() == "0")
  291. {
  292. try
  293. {
  294. Sunny.UI.UIPagination pg;
  295. dgv = dgvDirectoy;
  296. pg = pgDownload;
  297. DataTable dt;
  298. if (rbgDirecType.SelectedIndex == 20)
  299. {
  300. dt = (DataTable)joRtn["output"]["medinsinfo"].ToObject(typeof(DataTable));
  301. if (joRtn["output"]["medinsinfo"].ToString() == "")
  302. {
  303. MessageBox.Show("查询成功,但返回结果集为空!");
  304. //return;
  305. }
  306. pg.TotalCount = 50;
  307. pg.PageSize = 50;
  308. }
  309. else
  310. {
  311. pages = joRtn["output"]["pages"].ToString(); //页数
  312. recordCounts = joRtn["output"]["recordCounts"].ToString(); //总记录条数
  313. dt = (DataTable)joRtn["output"]["data"].ToObject(typeof(DataTable));
  314. if (recordCounts == "0")
  315. {
  316. MessageBox.Show("查询成功,但返回结果集为空!");
  317. //return;
  318. }
  319. pg.TotalCount = int.Parse(recordCounts);
  320. pg.PageSize = int.Parse(TexBYSJL.Text); //int.Parse(pages);
  321. }
  322. dgv.DataSource = dt;
  323. dgv.Columns[0].ReadOnly = true;
  324. }
  325. catch (Exception ex)
  326. {
  327. MessageBox.Show("查询异常:" + ex.Message);
  328. }
  329. }
  330. else
  331. {
  332. errorMessage = "调用交易" + funNo + "出现错误,请查看日志!"; //joImportRtn["errorMessage"].ToString();
  333. MessageBox.Show(errorMessage);
  334. return;
  335. }
  336. }
  337. }
  338. else
  339. {
  340. queryInsuDirectory(pageIndex, count, directoryType + 1, interfaceDr, code);
  341. setHeaderTxt(directoryType, dgv);
  342. }
  343. GridViewSetter gridSetter = new GridViewSetter();
  344. gridSetter.DatagridviewColumnWidthAdaptation(dgvCenterDirectory);
  345. }
  346. private int queryHISDirectory(int currentPage, int pageSize, out string errMsg)
  347. {
  348. errMsg = "";
  349. string directoryType = string.Empty;
  350. switch (rbgDirecType_C.SelectedIndex)
  351. {
  352. case 0:
  353. {
  354. directoryType = "drugs";
  355. break;
  356. }
  357. case 1:
  358. {
  359. directoryType = "diagnosi";
  360. break;
  361. }
  362. case 2:
  363. {
  364. directoryType = "consumables";
  365. break;
  366. }
  367. }
  368. JObject joHISRtn = new JObject();
  369. JObject joRtn = new JObject();
  370. InvokeHelper invoker = new InvokeHelper();
  371. string flag = "";
  372. //全部是先调HIS,然后再匹配医保平台的对照关系
  373. if (rbAll.Checked)
  374. {
  375. JArray jaPagination = new JArray();
  376. JArray jaParams = new JArray();
  377. flag = "All";
  378. dynamic joParam = new JObject();
  379. joParam.code = "";
  380. joParam.descripts = "";
  381. joParam.FindType = new JArray();
  382. joParam.TypeID = "";
  383. joParam.alias = tbHISDirectoryFilter.Text;
  384. joParam.include = "Hosp";
  385. joParam.groupID = "324";
  386. joParam.hospID = Global.inf.hisHospitalDr;
  387. joParam.interfaceDr = Global.inf.mainInterfaceDr;
  388. joParam.type = directoryType;
  389. joParam.flag = flag;
  390. joParam.specInput = "";
  391. jaParams.Add(joParam);
  392. dynamic joPagination = new JObject();
  393. joPagination.pageSize = pageSize;
  394. //joPagination.pageSize = 2;
  395. joPagination.currentPage = currentPage;
  396. joPagination.sortColumn = "Code";
  397. joPagination.sortOrder = "asc";
  398. jaPagination.Add(joPagination);
  399. //该服务需要改写,需要跟(CloudMedicalInsurancePlatform.Tables.MapRelation)进行关联
  400. //joInParams.code = "09010038";
  401. if (hIS.getHISDir(jaPagination, jaParams, out joHISRtn, out errMsg) != 0)
  402. {
  403. return -1;
  404. }
  405. joRtn = mIS.ConvertHISDir(joHISRtn);
  406. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  407. {
  408. return -1;
  409. }
  410. }
  411. //已对照是先调云医保,然后再匹配HIS
  412. if (rbMaped.Checked)
  413. {
  414. JArray jaPagination = new JArray();
  415. JArray jaParams = new JArray();
  416. flag = "Maped";
  417. dynamic joParam = new JObject();
  418. joParam.alias = tbHISDirectoryFilter.Text;
  419. joParam.InsuAlias = tbMappedInfo.Text;
  420. joParam.HospitalDr = Global.inf.hospitalDr;
  421. joParam.InterfaceDr = Global.inf.mainInterfaceDr;
  422. joParam.hisType = directoryType;
  423. jaParams.Add(joParam);
  424. dynamic joPagination = new JObject();
  425. joPagination.pageSize = pageSize;
  426. joPagination.currentPage = currentPage;
  427. joPagination.sortColumn = "HisCode";
  428. joPagination.sortOrder = "asc";
  429. jaPagination.Add(joPagination);
  430. JObject joMIRtn = mIS.GetMappedHISDir(jaPagination, jaParams);
  431. if (JsonHelper.parseIrisRtnValue(joMIRtn, out errMsg) != 0)
  432. {
  433. return -1;
  434. }
  435. JArray jaMaped = JArray.FromObject(joMIRtn["result"]["Data"]);
  436. if (jaMaped.Count < 1)
  437. {
  438. errMsg = "未查询到对照数据!";
  439. dgvHISDirectory.DataSource = null;
  440. return -1;
  441. }
  442. //传给HIS,进行匹配
  443. joParam = new JObject();
  444. joParam.TotalCount = joMIRtn["result"]["TotalCount"];
  445. joParam.type = directoryType;
  446. joParam.flag = flag;
  447. joParam.hospID = Global.inf.hisHospitalDr;
  448. joParam.mainInterfaceDr = Global.inf.mainInterfaceDr;
  449. joParam.alias = tbHISDirectoryFilter.Text;
  450. joParam.include = "Hosp";
  451. joParam.groupID = "324";
  452. joParam.compareArr = joMIRtn["result"]["Data"];
  453. jaParams = new JArray();
  454. jaParams.Add(joParam);
  455. if (hIS.getHISDir(jaPagination, jaParams, out joRtn, out errMsg) != 0)
  456. {
  457. return -1;
  458. }
  459. else
  460. {
  461. JArray jaData = JArray.Parse(JsonHelper.getDestValue(joRtn, "result.Data"));
  462. for (int i = 0; i < jaData.Count; i++)
  463. {
  464. jaData[i]["flag"] = new JObject();
  465. jaData[i]["flag"] = "已对照";
  466. }
  467. joRtn["result"]["Data"] = jaData;
  468. }
  469. }
  470. //未对照
  471. if (rbNoMaped.Checked)
  472. {
  473. JArray jaPagination = new JArray();
  474. JArray jaParams = new JArray();
  475. flag = "All";
  476. dynamic joParam = new JObject();
  477. joParam.code = "";
  478. joParam.descripts = "";
  479. joParam.FindType = new JArray();
  480. joParam.TypeID = "";
  481. joParam.alias = tbHISDirectoryFilter.Text;
  482. joParam.include = "Hosp";
  483. joParam.groupID = "324";
  484. joParam.hospID = Global.inf.hisHospitalDr;
  485. joParam.interfaceDr = Global.inf.mainInterfaceDr;
  486. joParam.type = directoryType;
  487. joParam.flag = flag;
  488. joParam.specInput = "";
  489. jaParams.Add(joParam);
  490. dynamic joPagination = new JObject();
  491. joPagination.pageSize = pageSize; //pageSize;
  492. //joPagination.pageSize = 2;
  493. joPagination.currentPage = currentPage;
  494. joPagination.sortColumn = "Code";
  495. joPagination.sortOrder = "asc";
  496. jaPagination.Add(joPagination);
  497. //1.获取全部HIS目录
  498. if (hIS.getHISDir(jaPagination, jaParams, out joHISRtn, out errMsg) != 0)
  499. {
  500. return -1;
  501. }
  502. joRtn = mIS.GetNoMappHISDir(joHISRtn);
  503. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  504. {
  505. return -1;
  506. }
  507. }
  508. DataTable dt = (DataTable)joRtn["result"]["Data"].ToObject(typeof(DataTable));
  509. dtExport = dt;
  510. int totalCount = int.Parse(joRtn["result"]["TotalCount"].ToString());
  511. pgHISDirect.TotalCount = totalCount;
  512. pgHISDirect.PageSize = 50;
  513. dgvHISDirectory.DataSource = null;
  514. dgvHISDirectory.DataSource = dt;
  515. dgvHISDirectory.Columns[0].ReadOnly = true;
  516. return 0;
  517. }
  518. private void Mapping()
  519. {
  520. int iHis = dgvHISDirectory.CurrentRow.Index;
  521. if (dgvCenterDirectory.CurrentRow == null)
  522. {
  523. MessageBox.Show("请查询中心目录");
  524. return;
  525. }
  526. int iCenter = dgvCenterDirectory.CurrentRow.Index;
  527. DataTable dtHis = (DataTable)dgvHISDirectory.DataSource;
  528. DataTable dtCenter = (DataTable)dgvCenterDirectory.DataSource;
  529. dgvHISDirectory.Rows[iHis].Cells["insuCode"].Value = dgvCenterDirectory.Rows[iCenter].Cells["Code"].Value.ToString();
  530. dgvHISDirectory.Rows[iHis].Cells["insuName"].Value = dgvCenterDirectory.Rows[iCenter].Cells["Name"].Value.ToString();
  531. int hisType = rbgDirecType_C.SelectedIndex + 1;
  532. string hisTypeName = rbgDirecType_C.Items[hisType - 1].ToString(); ;
  533. JArray jaParams = new JArray();
  534. dynamic jsonTemp = new JObject();
  535. jsonTemp.ID = dtHis.Rows[iHis]["MapID"];
  536. jsonTemp.HospitalDr = Global.inf.hospitalDr;
  537. jsonTemp.updateUserID = Global.user.ID;
  538. jsonTemp.InterfaceDr = Global.inf.mainInterfaceDr;
  539. jsonTemp.HISCode = dgvHISDirectory.Rows[iHis].Cells["itemCode"].Value;
  540. jsonTemp.HISName = dgvHISDirectory.Rows[iHis].Cells["itemDesc"].Value;
  541. jsonTemp.ChargeItemDr = dtHis.Rows[iHis]["ID"];
  542. jsonTemp.DiretoryDr = dtCenter.Rows[iCenter]["medInsuDirectoryID"];
  543. //1.已对照 2.已对照但未上传 3 已对照且已上传
  544. jsonTemp.State = 1;
  545. jsonTemp.HisType = hisType;
  546. jsonTemp.HisTypeName = hisTypeName;
  547. jsonTemp.InsuCode = dgvCenterDirectory.Rows[dgvCenterDirectory.CurrentRow.Index].Cells["Code"].Value;
  548. jsonTemp.InsuName = dgvCenterDirectory.Rows[dgvCenterDirectory.CurrentRow.Index].Cells["Name"].Value;
  549. jsonTemp.UpdateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  550. jaParams.Add(jsonTemp);
  551. JObject joIn = new JObject();
  552. joIn.Add(new JProperty("params", jaParams));
  553. joIn.Add("code", "09010040");
  554. InvokeHelper invoker = new InvokeHelper();
  555. JObject joRtn = invoker.invokeInsuService(joIn.ToString(), "插入对照信息");
  556. //JObject joRtn = JObject.Parse(irisRtn);
  557. if ((int)joRtn["errorCode"] == 0)
  558. {
  559. dgvHISDirectory.Rows[iHis].Cells["flag"].Value = "已对照";
  560. }
  561. else
  562. {
  563. dgvHISDirectory.Rows[iHis].Cells["flag"].Value = "对照失败";
  564. }
  565. }
  566. private void CancleMapping()
  567. {
  568. int iHis = dgvHISDirectory.CurrentRow.Index;
  569. DataTable dtHis = (DataTable)dgvHISDirectory.DataSource;
  570. JArray jaParams = new JArray();
  571. dynamic jsonTemp = new JObject();
  572. jsonTemp.ID = dtHis.Rows[iHis]["MapID"];
  573. jsonTemp.HospitalDr = Global.inf.hospitalDr;
  574. jsonTemp.updateUserID = Global.user.ID;
  575. jsonTemp.InterfaceDr = Global.inf.mainInterfaceDr;
  576. jsonTemp.HISCode = dgvHISDirectory.Rows[iHis].Cells["itemCode"].Value;
  577. jsonTemp.UpdateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  578. jaParams.Add(jsonTemp);
  579. JObject joIn = new JObject();
  580. joIn.Add(new JProperty("params", jaParams));
  581. joIn.Add("code", "09010041");
  582. InvokeHelper invoker = new InvokeHelper();
  583. JObject joRtn = invoker.invokeInsuService(joIn.ToString(), "取消对照");
  584. if ((int)joRtn["errorCode"] == 0)
  585. {
  586. dgvHISDirectory.Rows[iHis].Cells["insuCode"].Value = "";
  587. dgvHISDirectory.Rows[iHis].Cells["insuName"].Value = "";
  588. dgvHISDirectory.Rows[iHis].Cells["flag"].Value = "";
  589. }
  590. else
  591. {
  592. dgvHISDirectory.Rows[iHis].Cells["flag"].Value = "取消失败";
  593. }
  594. }
  595. /// <summary>
  596. /// 几个医保查询的交易组织入参
  597. /// </summary>
  598. /// <param name="Index"></param>
  599. /// <param name="funNo"></param>
  600. /// <returns></returns>
  601. private JObject GetInput(int Index, out string funNo)
  602. {
  603. funNo = "";
  604. dynamic joData = new JObject();
  605. switch (Index)
  606. {
  607. case 14://民族药品目
  608. {
  609. funNo = "1304";
  610. joData.med_list_codg = tbDirectoryCode.Text; //医疗目录编码
  611. joData.genname_codg = ""; //通用名编号
  612. joData.drug_genname = ""; //药品通用名
  613. joData.drug_prodname = tbDircetoryName.Text; //药品商品名
  614. joData.reg_name = ""; //注册名称
  615. joData.tcmherb_name = ""; //中草药名称
  616. joData.mlms_name = ""; //药材名称
  617. joData.vali_flag = ""; //有效标志
  618. joData.rid = ""; //唯一记录号
  619. joData.ver = ""; //版本号
  620. joData.ver_name = ""; //版本名称
  621. joData.opt_begn_time = ""; //经办开始时间
  622. joData.opt_end_time = ""; //经办结束时间
  623. joData.updt_time = TexDate.Text; //更新时间
  624. joData.page_num = TexDQYS.Text; //当前页数
  625. joData.page_size = TexBYSJL.Text; //本页数据量
  626. break;
  627. }
  628. case 15://目录信息查询
  629. {
  630. funNo = "1312";
  631. joData.query_date = ""; //查询时间点
  632. joData.hilist_code = tbDirectoryCode.Text; //医保目录编码
  633. joData.insu_admdvs = ""; //参保机构医保区划
  634. joData.begndate = ""; //开始日期
  635. joData.hilist_name = tbDircetoryName.Text; //医保目录名称
  636. joData.wubi = ""; //五笔助记码
  637. joData.pinyin = ""; //拼音助记码
  638. joData.med_chrgitm_type = ""; //医疗收费项目类别
  639. joData.chrgitm_lv = ""; //收费项目等级
  640. joData.lmt_used_flag = ""; //限制使用标志
  641. joData.list_type = ""; //目录类别
  642. joData.med_use_flag = ""; //医疗使用标志
  643. joData.matn_used_flag = ""; //生育使用标志
  644. joData.hilist_use_type = ""; //医保目录使用类别
  645. joData.lmt_cpnd_type = ""; //限复方使用类型
  646. joData.vali_flag = ""; //有效标志
  647. joData.updt_time = TexDate.Text; //更新时间
  648. joData.page_num = TexDQYS.Text; //当前页数
  649. joData.page_size = TexBYSJL.Text; //本页数据量
  650. break;
  651. }
  652. case 16://医疗与医保目录匹配
  653. {
  654. funNo = "1316";
  655. joData.query_date = ""; //查询时间点
  656. joData.medins_list_codg = ""; //定点医药机构目录编号
  657. joData.hilist_code = tbDirectoryCode.Text; //医保目录编码
  658. joData.list_type = ""; //目录类别
  659. joData.insu_admdvs = ""; //参保机构医保区划
  660. joData.begndate = ""; //开始日期
  661. joData.vali_flag = ""; //有效标志
  662. joData.updt_time = TexDate.Text; //更新时间
  663. joData.page_num = TexDQYS.Text; //当前页数
  664. joData.page_size = TexBYSJL.Text; //本页数据量
  665. break;
  666. }
  667. case 17://医药机构目录匹配
  668. {
  669. funNo = "1317";
  670. joData.query_date = ""; //查询时间点
  671. joData.fixmedins_code = ""; //定点医药机构编号
  672. joData.medins_list_codg = ""; //定点医药机构目录编号
  673. joData.medins_list_name = ""; //定点医药机构目录名称
  674. joData.insu_admdvs = ""; //参保机构医保区划
  675. joData.list_type = ""; //目录类别
  676. joData.med_list_codg = tbDirectoryCode.Text; //医疗目录编码
  677. joData.begndate = ""; //开始日期
  678. joData.vali_flag = ""; //有效标志
  679. joData.updt_time = TexDate.Text; //更新时间
  680. joData.page_num = TexDQYS.Text; //当前页数
  681. joData.page_size = TexBYSJL.Text; //本页数据量
  682. break;
  683. }
  684. case 18://医保目录限价
  685. {
  686. funNo = "1318";
  687. joData.query_date = ""; //查询时间点
  688. joData.hilist_code = tbDirectoryCode.Text; //医保目录编码
  689. joData.hilist_lmtpric_type = ""; //医保目录限价类型
  690. joData.overlmt_dspo_way = ""; //医保目录超限处理方式
  691. joData.insu_admdvs = ""; //参保机构医保区划
  692. joData.begndate = ""; //开始日期
  693. joData.enddate = ""; //结束日期
  694. joData.vali_flag = ""; //有效标志
  695. joData.rid = ""; //唯一记录号
  696. joData.tabname = ""; //表名
  697. joData.poolarea_no = ""; //统筹区
  698. joData.updt_time = TexDate.Text; //更新时间
  699. joData.page_num = TexDQYS.Text; //当前页数
  700. joData.page_size = TexBYSJL.Text; //本页数据量
  701. break;
  702. }
  703. case 19://医保目录先自付比例
  704. {
  705. funNo = "1319";
  706. joData.query_date = ""; //查询时间点
  707. joData.hilist_code = tbDirectoryCode.Text; //医保目录编码
  708. joData.selfpay_prop_psn_type = "";//医保目录自付比例人员类别
  709. joData.selfpay_prop_type = ""; //目录自付比例类别
  710. joData.insu_admdvs = ""; //参保机构医保区划
  711. joData.begndate = ""; //开始日期
  712. joData.enddate = ""; //结束日期
  713. joData.vali_flag = ""; //有效标志
  714. joData.rid = ""; //唯一记录号
  715. joData.tabname = ""; //表名
  716. joData.poolarea_no = ""; //统筹区
  717. joData.updt_time = TexDate.Text; //更新时间
  718. joData.page_num = TexDQYS.Text; //当前页数
  719. joData.page_size = TexBYSJL.Text; //本页数据量
  720. break;
  721. }
  722. case 20://医药机构信息
  723. {
  724. funNo = "1201";
  725. joData.fixmedins_type = "1"; //定点医疗服务机构类型 1定点医疗机构,2定点零售药店,3工伤定点康复机构,4辅助器具配置机构,5计划生育服务机构
  726. joData.fixmedins_name = TexYYMC.Text; //定点医药机构名称
  727. joData.fixmedins_code = ""; //定点医药机构编号
  728. break;
  729. }
  730. }
  731. return joData;
  732. }
  733. private string GetListType(int hisType,string source)
  734. {
  735. if (string.IsNullOrEmpty(source))
  736. {
  737. if (hisType == 1)
  738. {
  739. return "101"; //101西药中成药 102中药饮片 103自制剂 104民族药 201医疗服务项目 301医用耗材 501长护服务项目 105其他
  740. }
  741. else if (hisType == 2)
  742. {
  743. return "201";
  744. }
  745. else
  746. {
  747. return "301";
  748. }
  749. }
  750. else
  751. {
  752. return source;
  753. }
  754. }
  755. private int UpdateUploadStatus(string ids, int state,out string errMsg)
  756. {
  757. if (string.IsNullOrEmpty(ids))
  758. {
  759. errMsg = "更新状态失败!mapID为空!";
  760. return -1;
  761. }
  762. dynamic joInput = new JObject();
  763. joInput.HospitalDr = Global.inf.hospitalDr;
  764. joInput.InterfaceDr = Global.inf.interfaceDr;
  765. joInput.ID = ids;
  766. joInput.state = state;
  767. JObject joRtn = invoker.invokeInsuService(JsonHelper.setIrisInpar("09010103", joInput).ToString(), "更新上传状态");
  768. if (joRtn["errorCode"].Text() != "0")
  769. {
  770. errMsg = "更新状态失败!" + joRtn["errorMessage"].ToString();
  771. return -1;
  772. }
  773. else
  774. {
  775. errMsg = "";
  776. return 0;
  777. }
  778. }
  779. private int SingleUpload(out string errMsg)
  780. {
  781. string sMLLX = "";
  782. if ((dgvHISDirectory.CurrentRow == null))
  783. {
  784. errMsg = "请查询HIS目录对照关系";
  785. return -1;
  786. }
  787. //单条目录对照关系上传
  788. int iHis = dgvHISDirectory.CurrentRow.Index;
  789. DataTable dtHis = (DataTable)dgvHISDirectory.DataSource;
  790. //调用3301目录对照上传
  791. JObject joData = new JObject();
  792. joData.Add("fixmedins_hilist_id", dtHis.Rows[iHis]["itemCode"].ToString());
  793. joData.Add("fixmedins_hilist_name", dtHis.Rows[iHis]["itemDesc"].ToString());
  794. joData.Add("list_type", GetListType(rbgDirecType_C.SelectedIndex + 1, dtHis.Rows[iHis]["listType"].ToString())); //目录类别
  795. joData.Add("med_list_codg", dtHis.Rows[iHis]["InsuCode"].ToString()); //医疗目录编码
  796. joData.Add("begndate", "2023-12-01"); //开始日期
  797. joData.Add("enddate", ""); //结束日期
  798. joData.Add("aprvno", "");
  799. joData.Add("dosform", "");
  800. joData.Add("exct_cont", "");
  801. joData.Add("item_cont", "");
  802. joData.Add("prcunt", "");
  803. joData.Add("spec", "");
  804. joData.Add("pacspec", "");
  805. joData.Add("memo", "");
  806. JObject joInput = new JObject();
  807. JArray jaData = new JArray();
  808. jaData.Add(joData);
  809. joInput.Add("data", jaData);
  810. JObject joRtn = invoker.invokeCenterService("3301", JsonHelper.setCenterInpar("3301", joInput));
  811. if (JsonHelper.parseCenterRtnValue(joRtn, out errMsg) != 0)
  812. {
  813. return -1;
  814. }
  815. else
  816. {
  817. return UpdateUploadStatus(dtHis.Rows[iHis]["MapID"].ToString(), 3, out errMsg);
  818. }
  819. }
  820. /// <summary>
  821. /// 单条撤销目录对照关系上传
  822. /// </summary>
  823. private int SingleCancelUpload(out string errMsg)
  824. {
  825. if ((dgvHISDirectory.CurrentRow == null))
  826. {
  827. errMsg = "请查询HIS目录对照关系";
  828. return -1;
  829. }
  830. //撤销目录对照关系
  831. DataTable dtHis = (DataTable)dgvHISDirectory.DataSource;
  832. int iHis = dgvHISDirectory.CurrentRow.Index;
  833. //调用3302目录对照撤销
  834. JObject joData = new JObject();
  835. joData.Add("fixmedins_code", Global.inf.hospitalNO);
  836. joData.Add("fixmedins_hilist_id", dtHis.Rows[iHis]["HisCode"].ToString());
  837. joData.Add("list_type", GetListType(rbgDirecType_C.SelectedIndex + 1, dtHis.Rows[iHis]["listType"].ToString())); //目录类别
  838. joData.Add("med_list_codg", dtHis.Rows[iHis]["InsuCode"].ToString()); //医疗目录编码
  839. JObject joInput = new JObject();
  840. joInput.Add("data", joData);
  841. JObject joRtn = invoker.invokeCenterService("3302", JsonHelper.setCenterInpar("3302", joInput));
  842. if (JsonHelper.parseCenterRtnValue(joRtn, out errMsg) != 0)
  843. {
  844. return -1;
  845. }
  846. else
  847. {
  848. return UpdateUploadStatus(dtHis.Rows[iHis]["MapID"].ToString(), 2, out errMsg);
  849. }
  850. }
  851. /// <summary>
  852. /// 全部上传目录对照关系
  853. /// </summary>
  854. private void AllUpLoad()
  855. {
  856. if ((dgvHISDirectory.CurrentRow == null) || (rbMaped.Checked != true))
  857. {
  858. MessageBox.Show("请查询HIS目录对照关系");
  859. return;
  860. }
  861. string Msg = "";
  862. bool bOk = true;
  863. DataTable dtHis = (DataTable)dgvHISDirectory.DataSource;
  864. for (int i = 0; i < dtHis.Rows.Count; i++)
  865. {
  866. dgvHISDirectory.CurrentCell = dgvHISDirectory.Rows[i].Cells[0];
  867. if (SingleUpload(out err) != 0)
  868. {
  869. bOk = false;
  870. Msg = Msg + $"<{err}>";
  871. }
  872. }
  873. if (bOk == false)
  874. {
  875. MessageBox.Show("全部目录对照关系上传成功,部分上传异常:" + Msg);
  876. }
  877. else
  878. {
  879. MessageBox.Show("全部目录对照关系上传成功!");
  880. }
  881. }
  882. /// <summary>
  883. /// 全部撤销目录对照关系上传
  884. /// </summary>
  885. private void AllCancelUpload()
  886. {
  887. if ((dgvHISDirectory.CurrentRow == null) || (rbMaped.Checked != true))
  888. {
  889. MessageBox.Show("请查询HIS目录对照关系");
  890. return;
  891. }
  892. string Msg = "";
  893. bool bOk = true;
  894. DataTable dtHis = (DataTable)dgvHISDirectory.DataSource;
  895. for (int i = 0; i < dtHis.Rows.Count; i++)
  896. {
  897. dgvHISDirectory.CurrentCell = dgvHISDirectory.Rows[i].Cells[0];
  898. if (SingleCancelUpload(out err) != 0)
  899. {
  900. bOk = false;
  901. Msg = Msg + $"<{err}>";
  902. }
  903. }
  904. if (bOk == false)
  905. {
  906. MessageBox.Show("全部撤销目录对照关系上传成功,部分撤销异常:" + Msg);
  907. }
  908. else
  909. {
  910. MessageBox.Show("全部撤销目录对照关系上传成功!");
  911. }
  912. }
  913. /// <summary>
  914. /// 医保目录单个版本号的下载
  915. /// </summary>
  916. /// <param name="ver"></param>
  917. /// <param name="directoryType"></param>
  918. /// <param name="uiProcessBar"></param>
  919. /// <param name="errorMessage"></param>
  920. /// <returns></returns>
  921. public int SingleDownload(string ver, int directoryType, Sunny.UI.UIProcessBar uiProcessBar, out string errorMessage)
  922. {
  923. string txtPath = string.Empty;
  924. errorMessage = "";
  925. int iResult = -1;
  926. string funNo = "";
  927. switch (directoryType)
  928. {
  929. case 0://药品
  930. {
  931. funNo = "1301"; //"1301";
  932. break;
  933. }
  934. case 1://诊疗
  935. {
  936. funNo = "1305";
  937. break;
  938. }
  939. case 2://材料
  940. {
  941. funNo = "1306";
  942. break;
  943. }
  944. case 3://疾病诊断
  945. {
  946. funNo = "1307";
  947. break;
  948. }
  949. case 4://手术
  950. {
  951. funNo = "1308";
  952. break;
  953. }
  954. case 5://慢性病
  955. {
  956. funNo = "1309";
  957. break;
  958. }
  959. case 6://DRGs
  960. {
  961. funNo = "1310";
  962. break; ;
  963. }
  964. case 7://日间手术
  965. {
  966. funNo = "1311";
  967. break;
  968. }
  969. case 8://字典表
  970. {
  971. break;
  972. }
  973. case 9://中药饮片
  974. {
  975. funNo = "1302";
  976. break;
  977. }
  978. case 10://医药机构制剂
  979. {
  980. funNo = "1303";
  981. break;
  982. }
  983. }
  984. try
  985. {
  986. JObject joRtn = hBus.DownloadDirectory(funNo, ver);
  987. if (JsonHelper.parseIrisRtnValue(joRtn, out errorMessage) == 0)
  988. {
  989. txtPath = joRtn["filePath"].ToString();
  990. //MessageBox.Show("获取txt数据往IRIS插入文件路径:"+ txtPath);
  991. DataImoport bus = new DataImoport();
  992. JObject joImportRtn = bus.importDataToIrisByTxt(txtPath, 50, directoryType + 1, uiProcessBar);
  993. //MessageBox.Show("往IRIS插入数据:" + joImportRtn.ToString());
  994. //if (JsonHelper.parseCenterRtnValue(joImportRtn, out errorMessage) == 0)
  995. if (JsonHelper.parseIrisRtnValue(joImportRtn, out errorMessage) == 0)
  996. {
  997. iResult = 0;
  998. }
  999. else
  1000. {
  1001. Global.writeLog(joImportRtn.ToString());
  1002. errorMessage = "导入数据出现错误,请查看日志!";//joImportRtn["errorMessage"].ToString();
  1003. }
  1004. }
  1005. return iResult;
  1006. }
  1007. catch (Exception ex)
  1008. {
  1009. errorMessage = "SingleDownload提示:" + ex.Message;
  1010. return -1;
  1011. }
  1012. }
  1013. private void GetMainInterfaceDr(object sender, bool value)
  1014. {
  1015. string errMsg = "";
  1016. if (rbSelf.Checked)
  1017. {
  1018. Global.inf.mainInterfaceDr = Global.inf.interfaceDr;
  1019. }
  1020. if (rbSpecial.Checked)
  1021. {
  1022. JObject joRtn = mIS.getInterface(Global.inf.interfaceDr.ToString());
  1023. string specialInterfaceDr = JsonHelper.getDestValue(joRtn, "InsuCurrencyCataLogue");
  1024. if (!string.IsNullOrEmpty(specialInterfaceDr))
  1025. {
  1026. Global.inf.mainInterfaceDr = int.Parse(specialInterfaceDr);
  1027. }
  1028. else
  1029. {
  1030. MessageBox.Show("该接口不存在指定目录");
  1031. return;
  1032. }
  1033. }
  1034. if (rbMain.Checked)
  1035. {
  1036. JObject joRtn = mIS.getMainInterface(Global.inf.interfaceDr.ToString());
  1037. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  1038. {
  1039. MessageBox.Show(errMsg);
  1040. return;
  1041. }
  1042. string mainInterfaceDr = JsonHelper.getDestValue(joRtn, "result.data[0].MainInterfaceDr");
  1043. if (!string.IsNullOrEmpty(mainInterfaceDr))
  1044. {
  1045. Global.inf.mainInterfaceDr = int.Parse(mainInterfaceDr);
  1046. return;
  1047. }
  1048. else
  1049. {
  1050. MessageBox.Show("该接口不存在主目录");
  1051. return;
  1052. }
  1053. }
  1054. }
  1055. /// <summary>
  1056. /// 医保目录单个版本号的下载
  1057. /// </summary>
  1058. /// <param name="ver"></param>
  1059. /// <param name="directoryType"></param>
  1060. /// <param name="uiProcessBar"></param>
  1061. /// <param name="errorMessage"></param>
  1062. /// <returns></returns>
  1063. public int downloadDicionary(JObject joData, Sunny.UI.UIProcessBar uiProcessBar, string dictCode, out string errorMessage)
  1064. {
  1065. errorMessage = "";
  1066. int iResult = -1;
  1067. try
  1068. {
  1069. JObject joRtn = cBus.DownDictionay(joData);
  1070. if (JsonHelper.parseCenterRtnValue(joRtn, out errorMessage) == 0)
  1071. {
  1072. DataImoport DI = new DataImoport();
  1073. JArray jaList = JArray.Parse(JsonHelper.getDestValue(joRtn, "output.list"));
  1074. JObject joImportRtn = DI.importDictionary(uiProcessBar, jaList, dictCode);
  1075. if (JsonHelper.parseIrisRtnValue(joImportRtn, out errorMessage) == 0)
  1076. {
  1077. iResult = 0;
  1078. }
  1079. else
  1080. {
  1081. errorMessage = "导入数据出现错误,请查看日志!" + errorMessage;
  1082. }
  1083. }
  1084. return iResult;
  1085. }
  1086. catch (Exception ex)
  1087. {
  1088. errorMessage = "downloadDicionary提示:" + ex.Message;
  1089. return -1;
  1090. }
  1091. }
  1092. /// <summary>
  1093. /// 自动下载医保目录,直到最新版本(返回报错)
  1094. /// </summary>
  1095. /// <param name="directoryType"></param>
  1096. /// <param name="uiProcessBar"></param>
  1097. /// <param name="errorMessage"></param>
  1098. /// <returns></returns>
  1099. public int AutoDownload(int directoryType, Sunny.UI.UIProcessBar uiProcessBar, out string errorMessage)
  1100. {
  1101. int iResult = 0;
  1102. errorMessage = "";
  1103. try
  1104. {
  1105. while (iResult == 0)
  1106. {
  1107. JObject joMaxVerNO = mIS.getDirectoryMaxVersionNO(directoryType);
  1108. string ver = joMaxVerNO["result"]["MaxVersionNO"].ToString();
  1109. tbVer.Text = ver;
  1110. iResult = JsonHelper.parseIrisRtnValue(joMaxVerNO, out errorMessage);
  1111. iResult = SingleDownload(ver, directoryType, uiProcessBar, out errorMessage);
  1112. }
  1113. return iResult;
  1114. }
  1115. catch (Exception ex)
  1116. {
  1117. errorMessage = ex.Message;
  1118. return -1;
  1119. }
  1120. }
  1121. #endregion
  1122. #region 下载
  1123. private void btSignIn_Click(object sender, EventArgs e)
  1124. {
  1125. string errMsg;
  1126. if (mIS.isSigned(ref Global.curEvt.signno) != true)
  1127. {
  1128. JObject joRtn = new JObject();
  1129. //签到
  1130. if (cBus.signIn(out joRtn) != 0)
  1131. {
  1132. MessageBox.Show((string)joRtn["err_msg"]).ToString();
  1133. }
  1134. else
  1135. {
  1136. Global.curEvt.signno = JsonHelper.getDestValue(joRtn, "output.signinoutb.sign_no");
  1137. //插入签到表
  1138. if (mIS.saveSignRecord(Global.curEvt.signno, out errMsg) != 0)
  1139. {
  1140. MessageBox.Show("中心签到成功但插入签到表失败:" + errMsg);
  1141. }
  1142. else
  1143. {
  1144. MessageBox.Show("签到成功");
  1145. }
  1146. }
  1147. }
  1148. }
  1149. private void dgvDirectoy_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
  1150. {
  1151. //自动编号,与数据无关
  1152. Rectangle rectangle = new Rectangle(e.RowBounds.Location.X,
  1153. e.RowBounds.Location.Y,
  1154. dgvDirectoy.RowHeadersWidth - 4,
  1155. e.RowBounds.Height);
  1156. TextRenderer.DrawText(e.Graphics,
  1157. (e.RowIndex + 1).ToString(),
  1158. dgvDirectoy.RowHeadersDefaultCellStyle.Font,
  1159. rectangle,
  1160. dgvDirectoy.RowHeadersDefaultCellStyle.ForeColor,
  1161. TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
  1162. }
  1163. private void btnDownload_Click(object sender, EventArgs e)
  1164. {
  1165. string errorMessage = string.Empty;
  1166. //医保字典数据下载
  1167. if (rbgDirecType.SelectedIndex == 8)
  1168. {
  1169. if (tbDicDate.Text == "")
  1170. {
  1171. MessageBox.Show("请输入查询日期!");
  1172. return;
  1173. }
  1174. // 支持批量
  1175. string[] dictText = tbDicType.Text.Trim().Split(",".ToCharArray());
  1176. dictText.ToList().ForEach((dict) =>
  1177. {
  1178. this.downloadDict(dict);
  1179. });
  1180. }
  1181. else if (rbgDirecType.SelectedIndex <= 10)
  1182. {
  1183. if (rbSingleDown.Checked)
  1184. {
  1185. string ver = tbVer.Text;
  1186. if (tbVer.Text != "")
  1187. {
  1188. ver = tbVer.Text;
  1189. }
  1190. if (SingleDownload(ver, rbgDirecType.SelectedIndex, uiProcessBar1, out errorMessage) != 0)
  1191. {
  1192. MessageBox.Show("医保目录下载失败:" + errorMessage);
  1193. return;
  1194. }
  1195. }
  1196. if (rbAutoDown.Checked)
  1197. {
  1198. if (AutoDownload(rbgDirecType.SelectedIndex, uiProcessBar1, out errorMessage) != 0)
  1199. {
  1200. MessageBox.Show("医保目录下载失败:" + errorMessage);
  1201. return;
  1202. }
  1203. }
  1204. }
  1205. btnQuery_Click(sender, e);
  1206. }
  1207. private void downloadDict(string dictCode)
  1208. {
  1209. try
  1210. {
  1211. string errorMessage = "";
  1212. dynamic joData = new JObject();
  1213. joData.type = dictCode; //字典类型
  1214. joData.parentValue = ""; //父字典键值
  1215. joData.admdvs = Global.inf.areaCode; //行政区划 就医地
  1216. joData.date = tbDicDate.Text; //查询日期
  1217. joData.vali_flag = "1"; //有效标志
  1218. if (downloadDicionary(joData, uiProcessBar1, dictCode, out errorMessage) != 0)
  1219. {
  1220. MessageBox.Show("医保字典下载失败:" + errorMessage);
  1221. }
  1222. }
  1223. catch (Exception)
  1224. {
  1225. }
  1226. }
  1227. private void btnQuery_Click(object sender, EventArgs e)
  1228. {
  1229. #region 校验查询条件
  1230. if ((rbgDirecType.SelectedIndex < 0) || (rbgDirecType.SelectedIndex > 20))
  1231. {
  1232. MessageBox.Show("请先选择查询类型!");
  1233. return;
  1234. }
  1235. if (rbgDirecType.SelectedIndex > 13)
  1236. {
  1237. if (rbgDirecType.SelectedIndex != 20)
  1238. {
  1239. if ((TexDate.Text == "") || (TexDate.Text == "输入日期 2021-01-01"))
  1240. {
  1241. MessageBox.Show("查询条件-请输入查询日期!");
  1242. return;
  1243. }
  1244. if ((TexDQYS.Text == "") || (TexDQYS.Text == "当前页数"))
  1245. {
  1246. MessageBox.Show("查询条件-请输入当前页数!");
  1247. return;
  1248. }
  1249. if ((TexBYSJL.Text == "") || (TexBYSJL.Text == "本页数据量"))
  1250. {
  1251. MessageBox.Show("查询条件-请输入本页数据量!");
  1252. return;
  1253. }
  1254. }
  1255. else
  1256. {
  1257. if ((TexYYMC.Text == "") || (TexYYMC.Text == "输入医院名称模糊查找"))
  1258. {
  1259. MessageBox.Show("查询条件-请输入医院名称模糊查找!");
  1260. return;
  1261. }
  1262. }
  1263. }
  1264. #endregion
  1265. queryHISInsuDirectory(rbgDirecType.SelectedIndex, 1, 20, dgvDirectoy, Global.inf.interfaceDr);
  1266. }
  1267. private void pgDownload_PageChanged(object sender, object pagingSource, int pageIndex, int count)
  1268. {
  1269. queryHISInsuDirectory(rbgDirecType.SelectedIndex, pageIndex, count, dgvDirectoy, Global.inf.interfaceDr);
  1270. }
  1271. private void rbgDirecType_ValueChanged(object sender, int index, string text)
  1272. {
  1273. //选定项不同调用的接口也不相同,Index值大于
  1274. if (rbgDirecType.SelectedIndex > 13)
  1275. {
  1276. uiGroupBox1.Visible = false;
  1277. uiGroupBox5.Visible = false;
  1278. uiGroupBox2.Visible = true;
  1279. //uiGroupBox3.Visible = true;
  1280. uiProcessBar1.Visible = false;
  1281. uiGroupBox2.Left = rbgDirecType.Width + rbgDirecType.Left + 5;
  1282. uiGroupBox3.Left = uiGroupBox2.Width + rbgDirecType.Width + rbgDirecType.Left + 10;
  1283. dgvDirectoy.DataSource = null;
  1284. }
  1285. else
  1286. {
  1287. uiGroupBox1.Visible = true;
  1288. uiGroupBox5.Visible = true;
  1289. uiGroupBox2.Visible = true;
  1290. //uiGroupBox3.Visible = false;
  1291. uiProcessBar1.Visible = true;
  1292. uiGroupBox1.Left = rbgDirecType.Width + rbgDirecType.Left + 5;
  1293. uiGroupBox5.Left = uiGroupBox1.Width + rbgDirecType.Width + rbgDirecType.Left + 10;
  1294. uiGroupBox2.Left = uiGroupBox5.Width + uiGroupBox1.Width + rbgDirecType.Width + rbgDirecType.Left + 15;
  1295. uiGroupBox3.Left = uiGroupBox2.Width + uiGroupBox5.Width + uiGroupBox1.Width + rbgDirecType.Width + rbgDirecType.Left + 20;
  1296. uiProcessBar1.Left = rbgDirecType.Width + rbgDirecType.Left + 5;
  1297. uiProcessBar1.Width = uiGroupBox1.Width + uiGroupBox5.Width + uiGroupBox2.Width + 10;
  1298. }
  1299. setHeaderTxt(rbgDirecType.SelectedIndex, dgvDirectoy);
  1300. }
  1301. private void btAddDir_Click(object sender, EventArgs e)
  1302. {
  1303. AddSingleDirectory addDirectory = new AddSingleDirectory(rbgDirecType.SelectedIndex);
  1304. if (addDirectory.ShowDialog() == DialogResult.OK)
  1305. {
  1306. JObject joRtn = mIS.UpdateDirectoryBySelf(addDirectory.joPamam);
  1307. string error = "";
  1308. if (JsonHelper.parseIrisRtnValue(joRtn, out error) != 0)
  1309. {
  1310. MessageBox.Show("新增失败:" + error);
  1311. }
  1312. else
  1313. {
  1314. MessageBox.Show("新增成功");
  1315. }
  1316. }
  1317. }
  1318. private void btEditDir_Click(object sender, EventArgs e)
  1319. {
  1320. DataTable dt = (DataTable)dgvDirectoy.DataSource;
  1321. if ((dt == null) || (dt.Rows.Count < 1))
  1322. {
  1323. MessageBox.Show("表中无数据,请检查!");
  1324. return;
  1325. }
  1326. DataRow dr = dt.Rows[dgvDirectoy.CurrentRow.Index];
  1327. AddSingleDirectory addDirectory = new AddSingleDirectory(rbgDirecType.SelectedIndex, dr);
  1328. if (addDirectory.ShowDialog() == DialogResult.OK)
  1329. {
  1330. JObject joRtn = mIS.UpdateDirectoryBySelf(addDirectory.joPamam);
  1331. string error = "";
  1332. if (JsonHelper.parseIrisRtnValue(joRtn, out error) != 0)
  1333. {
  1334. MessageBox.Show("修改失败:" + error);
  1335. }
  1336. else
  1337. {
  1338. MessageBox.Show("修改成功");
  1339. }
  1340. }
  1341. }
  1342. private void btnExit_Click(object sender, EventArgs e)
  1343. {
  1344. Close();
  1345. }
  1346. #endregion
  1347. #region 对照
  1348. private void btnQueryHISDirectory_Click(object sender, EventArgs e)
  1349. {
  1350. this.dgvHISDirectory.SelectionChanged -= this.dgvHISDirectory_SelectionChanged;
  1351. string errMsg;
  1352. if (!string.IsNullOrEmpty(tbCountPerPage.Text))
  1353. {
  1354. iCount = int.Parse(tbCountPerPage.Text);
  1355. }
  1356. if (rbNoMaped.Checked) iCount = 5000;
  1357. if (queryHISDirectory(1, iCount, out errMsg) != 0)
  1358. {
  1359. MessageBox.Show(errMsg);
  1360. return;
  1361. }
  1362. this.dgvHISDirectory.SelectionChanged += this.dgvHISDirectory_SelectionChanged;
  1363. }
  1364. private void btnQueryCenterDirectory_Click(object sender, EventArgs e)
  1365. {
  1366. queryHISInsuDirectory(rbgInsuDirecType_C.SelectedIndex, 1, 50, dgvCenterDirectory, Global.inf.interfaceDr);
  1367. }
  1368. private void pgHISDirect_PageChanged(object sender, object pagingSource, int pageIndex, int count)
  1369. {
  1370. string errMsg;
  1371. if (queryHISDirectory(pageIndex, iCount, out errMsg) != 0)
  1372. {
  1373. MessageBox.Show(errMsg);
  1374. return;
  1375. }
  1376. }
  1377. private void pgCenterDirect_PageChanged(object sender, object pagingSource, int pageIndex, int count)
  1378. {
  1379. queryHISInsuDirectory(rbgDirecType_C.SelectedIndex, pageIndex, count, dgvCenterDirectory, Global.inf.interfaceDr);
  1380. }
  1381. private void toolStripMenuItem2_Click(object sender, EventArgs e)
  1382. {
  1383. CancleMapping();
  1384. }
  1385. private void tsmiMapping_Click(object sender, EventArgs e)
  1386. {
  1387. Mapping();
  1388. }
  1389. private void rbAll_ValueChanged(object sender, bool value)
  1390. {
  1391. if (rbAll.Checked)
  1392. {
  1393. btnQueryHISDirectory_Click(null, new EventArgs());
  1394. }
  1395. }
  1396. private void rbMaped_CheckedChanged(object sender, EventArgs e)
  1397. {
  1398. if (rbMaped.Checked)
  1399. {
  1400. string errMsg;
  1401. if (queryHISDirectory(iCount, 50, out errMsg) != 0)
  1402. {
  1403. MessageBox.Show(errMsg);
  1404. return;
  1405. }
  1406. }
  1407. }
  1408. private void btnExport_Click(object sender, EventArgs e)
  1409. {
  1410. //if (rbAll.Checked) return;
  1411. if (queryHISDirectory(1, iCount, out string errMsg) != 0)
  1412. {
  1413. MessageBox.Show(errMsg);
  1414. return;
  1415. }
  1416. if (dtExport.Rows.Count > 0)
  1417. {
  1418. string Maped = "";
  1419. if (rbAll.Checked) Maped = "全部";
  1420. if (rbMaped.Checked) Maped = "已对照";
  1421. if (rbNoMaped.Checked) Maped = "未对照";
  1422. string directoryType = string.Empty;
  1423. switch (rbgDirecType_C.SelectedIndex)
  1424. {
  1425. case 0:
  1426. {
  1427. directoryType = "药品";
  1428. break;
  1429. }
  1430. case 1:
  1431. {
  1432. directoryType = "诊疗";
  1433. break;
  1434. }
  1435. case 2:
  1436. {
  1437. directoryType = "材料";
  1438. break;
  1439. }
  1440. }
  1441. string LSH = DateTime.Now.ToString("yyyyMMddHHMMss"); //DateTime.Now.ToString("MMddHHmmssffff");
  1442. string sFliePathName = @"D:\" + LSH + "【" + directoryType + "】医保目录【" + Maped + "】信息.xls";
  1443. string ReturnFileName = ExportToExcel.DataTabletoExcel(dtExport, sFliePathName);
  1444. if (ReturnFileName != "")
  1445. {
  1446. MessageBox.Show("导出成功,文件保存路径:【" + ReturnFileName + "】");
  1447. System.Diagnostics.Process.Start(ReturnFileName); //打开excel文件
  1448. }
  1449. else
  1450. {
  1451. MessageBox.Show("导出失败!");
  1452. }
  1453. }
  1454. }
  1455. private void dgvHISDirectory_RowEnter(object sender, DataGridViewCellEventArgs e)
  1456. {
  1457. tbCenterDirectoryFilter.Text = "%" + dgvHISDirectory.SelectedRows[0].Cells["itemDesc"].Value.ToString() + "%";
  1458. tbApprovalNO.Text = dgvHISDirectory.SelectedRows[0].Cells["pprovalNo"].Value.ToString();
  1459. }
  1460. private void dgvHISDirectory_SelectionChanged(object sender, EventArgs e)
  1461. {
  1462. int i = dgvHISDirectory.CurrentRow.Index;
  1463. if (dgvHISDirectory.Rows[i].Cells["insuCode"].Value.ToString() != "")
  1464. {
  1465. tbInsuCode.Text = dgvHISDirectory.Rows[i].Cells["insuCode"].Value.ToString();
  1466. tbCenterDirectoryFilter.Text = "";
  1467. tbApprovalNO.Text = "";
  1468. }
  1469. else
  1470. {
  1471. tbInsuCode.Text = "";
  1472. if (rbOnlyName.Checked)
  1473. {
  1474. tbInsuCode.Text = "";
  1475. tbApprovalNO.Text = "";
  1476. tbCenterDirectoryFilter.Text = "%" + dgvHISDirectory.Rows[i].Cells["itemDesc"].Value.ToString() + "%";
  1477. }
  1478. if (rbOnlyApprNO.Checked)
  1479. {
  1480. tbCenterDirectoryFilter.Text = "";
  1481. tbInsuCode.Text = "";
  1482. tbApprovalNO.Text = "%" + dgvHISDirectory.Rows[i].Cells["pprovalNo"].Value.ToString() + "%";
  1483. }
  1484. if (rbBoth.Checked)
  1485. {
  1486. tbInsuCode.Text = "";
  1487. tbCenterDirectoryFilter.Text = "%" + dgvHISDirectory.Rows[i].Cells["itemDesc"].Value.ToString() + "%";
  1488. tbApprovalNO.Text = "%" + dgvHISDirectory.Rows[i].Cells["pprovalNo"].Value.ToString() + "%";
  1489. }
  1490. }
  1491. }
  1492. private void ToolStripMenuItem_Upload_Click(object sender, EventArgs e)
  1493. {
  1494. if (SingleUpload(out err) != 0)
  1495. {
  1496. MessageBox.Show(err);
  1497. }
  1498. else
  1499. {
  1500. MessageBox.Show("上传成功");
  1501. }
  1502. }
  1503. private void ToolStripMenuItem_CancelUpload_Click(object sender, EventArgs e)
  1504. {
  1505. if (SingleCancelUpload(out err) != 0)
  1506. {
  1507. MessageBox.Show(err);
  1508. }
  1509. else
  1510. {
  1511. MessageBox.Show("上传撤销成功");
  1512. }
  1513. }
  1514. private void btnUploadRelation_Click(object sender, EventArgs e)
  1515. {
  1516. AllUpLoad();
  1517. }
  1518. private void btnCancelRelation_Click(object sender, EventArgs e)
  1519. {
  1520. AllCancelUpload();
  1521. }
  1522. #endregion
  1523. }
  1524. }