BasicData.cs 68 KB

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