BasicData.cs 69 KB

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