BasicData.cs 69 KB

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