BasicData.cs 85 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213
  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. int currentPageIndex = 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. string DosageForm = "";
  63. string Specifications = "";
  64. string manufacturers = "";
  65. Sunny.UI.UIDataGridView dgv;
  66. Sunny.UI.UIPagination pg;
  67. if (tabControl1.SelectedIndex == 0)
  68. {
  69. dirCode = tbDirectoryCode.Text;
  70. dirName = tbDircetoryName.Text;
  71. approvalNO = "";
  72. dgv = dgvDirectoy;
  73. pg = pgDownload;
  74. }
  75. else
  76. {
  77. dirName = tbCenterDirectoryFilter.Text;
  78. dirCode = tbInsuCode.Text;
  79. dgv = dgvCenterDirectory;
  80. approvalNO = tbApprovalNO.Text;
  81. pg = pgCenterDirect;
  82. manufacturers = tbManufacturer.Text;
  83. DosageForm = tbDosageForm.Text;
  84. Specifications = tbSpecifications.Text;
  85. }
  86. JObject joInput = new JObject {
  87. { "currentPage" , currentPage },
  88. { "pageSize" , pageSize },
  89. { "serviceCode" , code },
  90. { "directoryType" , directoryType },
  91. { "directoryCode" , dirCode },
  92. { "directoryName" , dirName },
  93. { "approvalNO" , approvalNO },
  94. { "dosageForm" , DosageForm },
  95. { "specifications" , Specifications },
  96. { "manufacturers" , manufacturers },
  97. { "directoryDr" , interfaceDr }
  98. };
  99. JObject joRtn = mIS.getMIDirectoryByPagination(joInput);
  100. if (joRtn["errorCode"].ToString() != "0")
  101. {
  102. MessageBox.Show("IRIS数据返回错误:" + joRtn["errorMessage"].ToString());
  103. return;
  104. }
  105. if (joRtn["result"]["rows"] == null)
  106. {
  107. MessageBox.Show("该节点不存在");
  108. return;
  109. }
  110. if (joRtn["result"]["total"].ToString() == "0")
  111. {
  112. MessageBox.Show("未查询到数据");
  113. dgv.DataSource = null;
  114. return;
  115. }
  116. DataTable dt = (DataTable)joRtn["result"]["rows"].ToObject(typeof(DataTable));
  117. int totalCount = int.Parse(joRtn["result"]["total"].ToString());
  118. pg.TotalCount = totalCount;
  119. pg.PageSize = pageSize;
  120. dgv.DataSource = dt;
  121. dgv.Columns[0].ReadOnly = true;
  122. }
  123. catch (Exception ex)
  124. {
  125. MessageBox.Show("查询异常:" + ex.Message);
  126. }
  127. }
  128. private void setHeaderTxt(int directoryType, Sunny.UI.UIDataGridView dgv)
  129. {
  130. GridViewSetter gvdSetter = new GridViewSetter();
  131. switch (directoryType)
  132. {
  133. case 0://药品
  134. {
  135. gvdSetter.SetHeaderTextOfDrug(dgv);
  136. break;
  137. }
  138. case 1://诊疗
  139. {
  140. gvdSetter.SetHeaderTextOfMedicalService(dgv);
  141. break;
  142. }
  143. case 2://材料
  144. {
  145. gvdSetter.SetHeaderTextOfMaterials(dgv);
  146. break;
  147. }
  148. case 3://疾病诊断
  149. {
  150. gvdSetter.SetHeaderTextOfDiagnose(dgv);
  151. break;
  152. }
  153. case 4://手术
  154. {
  155. gvdSetter.SetHeaderTextOfDiagnose(dgv);
  156. break;
  157. }
  158. case 5://慢性病
  159. {
  160. gvdSetter.SetHeaderTextOfDiagnose(dgv);
  161. break;
  162. }
  163. case 6://DRGs
  164. {
  165. gvdSetter.SetHeaderTextOfDiagnose(dgv);
  166. break; ;
  167. }
  168. case 7://日间手术
  169. {
  170. gvdSetter.SetHeaderTextOfDiagnose(dgv);
  171. break; ;
  172. }
  173. case 8://字典表
  174. {
  175. gvdSetter.SetHeaderTextOfDictionary(dgv);
  176. break;
  177. }
  178. case 9://中药饮片下载
  179. {
  180. gvdSetter.SetHeaderTextOfChineseMedicine(dgv);
  181. break;
  182. }
  183. case 10://医药机构制剂目录下载
  184. {
  185. gvdSetter.SetHeaderTextOfPreparation(dgv);
  186. break;
  187. }
  188. case 11://肿瘤形态学下载
  189. {
  190. gvdSetter.SetHeaderTextOfTumorMorphology(dgv);
  191. break;
  192. }
  193. case 12://中医疾病下载
  194. {
  195. gvdSetter.GetChineseDiagnoseJsonByTxt(dgv);
  196. break;
  197. }
  198. case 13://中医证候下载
  199. {
  200. gvdSetter.GetTCMSyndromeJsonByTxt(dgv);
  201. break;
  202. }
  203. case 14://民族药品
  204. {
  205. gvdSetter.GetEthnicMedicineJsonByTxt(dgv);
  206. break;
  207. }
  208. case 15://目录信息查询
  209. {
  210. gvdSetter.GetMedInsuCatalogJsonByTxt(dgv);
  211. break;
  212. }
  213. case 16://医疗与医保目录匹配关系查询
  214. {
  215. gvdSetter.GetMedInsuCorrespondencJsonByTxt(dgv);
  216. break;
  217. }
  218. case 17://医药机构目录匹配查询
  219. {
  220. gvdSetter.GetMedInstCorrespondencJsonByTxt(dgv);
  221. break;
  222. }
  223. case 18://医保目录限价查询
  224. {
  225. gvdSetter.GetMedInsuFixedPriceJsonByTxt(dgv);
  226. break;
  227. }
  228. case 19://医保目录先自付比例下载
  229. {
  230. gvdSetter.GetMedInsuFirstPayProportionJsonByTxt(dgv);
  231. break;
  232. }
  233. case 20://医药机构信息
  234. {
  235. gvdSetter.GetMedicalInstitutionJsonByTxt(dgv);
  236. break;
  237. }
  238. }
  239. gvdSetter.DatagridviewColumnWidthAdaptation(dgv);
  240. }
  241. private void queryHISInsuDirectory(int directoryType, int pageIndex, int count, Sunny.UI.UIDataGridView dgv, int interfaceDr)
  242. {
  243. string code = "09010042";
  244. if (tabControl1.SelectedIndex == 0)
  245. {
  246. if (rbgDirecType.SelectedIndex == 20)
  247. {
  248. code = "090100XX";
  249. }
  250. else if (rbgDirecType.SelectedIndex == 8)
  251. {
  252. code = "09010043";
  253. }
  254. else
  255. {
  256. code = "09010042";
  257. }
  258. if (rbgDirecType.SelectedIndex <= 13)
  259. {
  260. queryInsuDirectory(pageIndex, count, directoryType + 1, interfaceDr, code);
  261. setHeaderTxt(directoryType, dgv);
  262. }
  263. else //几个医保查询该部分数据不存数据库只是临时查询(除医疗机构信息查询外)
  264. {
  265. //生成DataView列
  266. //setHeaderTxt(directoryType, dgv);
  267. string pages, recordCounts, errorMessage, sOutpar;
  268. dynamic joData = GetInput(rbgDirecType.SelectedIndex, out string funNo);
  269. JObject joRtn = cBus.InvokeMedicalInsuranceInquiry(funNo, joData);
  270. if (joRtn["infcode"].ToString() == "0")
  271. {
  272. try
  273. {
  274. Sunny.UI.UIPagination pg;
  275. dgv = dgvDirectoy;
  276. pg = pgDownload;
  277. DataTable dt;
  278. if (rbgDirecType.SelectedIndex == 20)
  279. {
  280. dt = (DataTable)joRtn["output"]["medinsinfo"].ToObject(typeof(DataTable));
  281. if (joRtn["output"]["medinsinfo"].ToString() == "")
  282. {
  283. MessageBox.Show("查询成功,但返回结果集为空!");
  284. //return;
  285. }
  286. pg.TotalCount = 50;
  287. pg.PageSize = 50;
  288. }
  289. else
  290. {
  291. pages = joRtn["output"]["pages"].ToString(); //页数
  292. recordCounts = joRtn["output"]["recordCounts"].ToString(); //总记录条数
  293. dt = (DataTable)joRtn["output"]["data"].ToObject(typeof(DataTable));
  294. if (recordCounts == "0")
  295. {
  296. MessageBox.Show("查询成功,但返回结果集为空!");
  297. //return;
  298. }
  299. pg.TotalCount = int.Parse(recordCounts);
  300. pg.PageSize = int.Parse(TexBYSJL.Text); //int.Parse(pages);
  301. }
  302. dgv.DataSource = dt;
  303. dgv.Columns[0].ReadOnly = true;
  304. }
  305. catch (Exception ex)
  306. {
  307. MessageBox.Show("查询异常:" + ex.Message);
  308. }
  309. }
  310. else
  311. {
  312. errorMessage = "调用交易" + funNo + "出现错误,请查看日志!"; //joImportRtn["errorMessage"].ToString();
  313. MessageBox.Show(errorMessage);
  314. return;
  315. }
  316. }
  317. }
  318. else
  319. {
  320. queryInsuDirectory(pageIndex, count, directoryType + 1, interfaceDr, code);
  321. setHeaderTxt(directoryType, dgv);
  322. }
  323. GridViewSetter gridSetter = new GridViewSetter();
  324. gridSetter.DatagridviewColumnWidthAdaptation(dgvCenterDirectory);
  325. }
  326. private int queryHISDirectory(int currentPage, int pageSize, out string errMsg)
  327. {
  328. errMsg = "";
  329. string directoryType = string.Empty;
  330. switch (rbgDirecType_C.SelectedIndex)
  331. {
  332. case 0:
  333. {
  334. directoryType = "drugs";
  335. break;
  336. }
  337. case 1:
  338. {
  339. directoryType = "diagnosi";
  340. break;
  341. }
  342. case 2:
  343. {
  344. directoryType = "consumables";
  345. break;
  346. }
  347. }
  348. JObject joHISRtn = new JObject();
  349. JObject joRtn = new JObject();
  350. InvokeHelper invoker = new InvokeHelper();
  351. string flag = "";
  352. //全部是先调HIS,然后再匹配医保平台的对照关系
  353. if (rbAll.Checked)
  354. {
  355. JArray jaPagination = new JArray();
  356. JArray jaParams = new JArray();
  357. flag = "All";
  358. dynamic joParam = new JObject();
  359. joParam.code = "";
  360. joParam.descripts = "";
  361. joParam.FindType = new JArray();
  362. joParam.TypeID = "";
  363. joParam.alias = tbHISDirectoryFilter.Text;
  364. joParam.include = "Hosp";
  365. joParam.groupID = "324";
  366. joParam.hospID = Global.inf.hisHospitalDr;
  367. joParam.interfaceDr = Global.inf.interfaceDr;
  368. joParam.type = directoryType;
  369. joParam.flag = flag;
  370. joParam.specInput = "";
  371. jaParams.Add(joParam);
  372. dynamic joPagination = new JObject();
  373. joPagination.pageSize = pageSize;
  374. //joPagination.pageSize = 2;
  375. joPagination.currentPage = currentPage;
  376. joPagination.sortColumn = "Code";
  377. joPagination.sortOrder = "asc";
  378. jaPagination.Add(joPagination);
  379. //该服务需要改写,需要跟(CloudMedicalInsurancePlatform.Tables.MapRelation)进行关联
  380. //joInParams.code = "09010038";
  381. if (hIS.getHISDir(jaPagination, jaParams, out joHISRtn, out errMsg) != 0)
  382. {
  383. return -1;
  384. }
  385. joRtn = mIS.ConvertHISDir(joHISRtn);
  386. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  387. {
  388. return -1;
  389. }
  390. }
  391. //已对照是先调云医保,然后再匹配HIS
  392. if (rbMaped.Checked)
  393. {
  394. JArray jaPagination = new JArray();
  395. JArray jaParams = new JArray();
  396. flag = "Maped";
  397. dynamic joParam = new JObject();
  398. joParam.alias = tbHISDirectoryFilter.Text;
  399. joParam.HospitalDr = Global.inf.hospitalDr;
  400. joParam.InterfaceDr = Global.inf.interfaceDr;
  401. joParam.hisType = directoryType;
  402. jaParams.Add(joParam);
  403. dynamic joPagination = new JObject();
  404. joPagination.pageSize = pageSize;
  405. joPagination.currentPage = currentPage;
  406. joPagination.sortColumn = "HisCode";
  407. joPagination.sortOrder = "asc";
  408. jaPagination.Add(joPagination);
  409. JObject joMIRtn = mIS.GetMappedHISDir(jaPagination, jaParams);
  410. if (JsonHelper.parseIrisRtnValue(joMIRtn, out errMsg) != 0)
  411. {
  412. return -1;
  413. }
  414. //传给HIS,进行匹配
  415. joParam = new JObject();
  416. joParam.TotalCount = joMIRtn["result"]["TotalCount"];
  417. joParam.type = directoryType;
  418. joParam.flag = flag;
  419. joParam.hospID = Global.inf.hisHospitalDr;
  420. joParam.interfaceDr = Global.inf.interfaceDr;
  421. joParam.alias = tbHISDirectoryFilter.Text;
  422. joParam.include = "Hosp";
  423. joParam.groupID = "324";
  424. joParam.compareArr = joMIRtn["result"]["Data"];
  425. jaParams = new JArray();
  426. jaParams.Add(joParam);
  427. if (hIS.getHISDir(jaPagination, jaParams, out joRtn, out errMsg) != 0)
  428. {
  429. return -1;
  430. }
  431. }
  432. //if (rbNoMaped.Checked) { flag = "NoMaped"; }
  433. if (rbNoMaped.Checked)
  434. {
  435. JArray jaPagination = new JArray();
  436. JArray jaParams = new JArray();
  437. flag = "All";
  438. dynamic joParam = new JObject();
  439. joParam.code = "";
  440. joParam.descripts = "";
  441. joParam.FindType = new JArray();
  442. joParam.TypeID = "";
  443. joParam.alias = tbHISDirectoryFilter.Text;
  444. joParam.include = "Hosp";
  445. joParam.groupID = "324";
  446. joParam.hospID = Global.inf.hisHospitalDr;
  447. joParam.interfaceDr = Global.inf.interfaceDr;
  448. joParam.type = directoryType;
  449. joParam.flag = flag;
  450. joParam.specInput = "";
  451. jaParams.Add(joParam);
  452. dynamic joPagination = new JObject();
  453. joPagination.pageSize = pageSize;
  454. //joPagination.pageSize = 2;
  455. joPagination.currentPage = currentPage;
  456. joPagination.sortColumn = "Code";
  457. joPagination.sortOrder = "asc";
  458. jaPagination.Add(joPagination);
  459. //1.获取全部HIS目录
  460. if (hIS.getHISDir(jaPagination, jaParams, out joHISRtn, out errMsg) != 0)
  461. {
  462. return -1;
  463. }
  464. joRtn = mIS.GetNoMappHISDir(joHISRtn);
  465. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  466. {
  467. return -1;
  468. }
  469. }
  470. DataTable dt = (DataTable)joRtn["result"]["Data"].ToObject(typeof(DataTable));
  471. dtExport = dt;
  472. int totalCount = int.Parse(joRtn["result"]["TotalCount"].ToString());
  473. pgHISDirect.TotalCount = totalCount;
  474. //if (rbNoMaped.Checked)
  475. // pgHISDirect.PageSize = pageSize;
  476. //else
  477. // pgHISDirect.PageSize = 50;
  478. pgHISDirect.PageSize = pageSize;
  479. dgvHISDirectory.DataSource = null;
  480. dgvHISDirectory.DataSource = dt;
  481. dgvHISDirectory.Columns[0].ReadOnly = true;
  482. GridViewSetter gridSetter = new GridViewSetter();
  483. gridSetter.SetHeaderTextOfMapping_HisDirectory(dgvHISDirectory);
  484. gridSetter.DatagridviewColumnWidthAdaptation(dgvHISDirectory);
  485. return 0;
  486. }
  487. private void queryCenterDirectory_09010012(int currentPage, int pageSize)
  488. {
  489. string directoryType = string.Empty;
  490. switch (rbgDirecType_C.SelectedIndex)
  491. {
  492. case 0:
  493. {
  494. directoryType = "drugs";
  495. break;
  496. }
  497. case 1:
  498. {
  499. directoryType = "diagnosi";
  500. break;
  501. }
  502. case 2:
  503. {
  504. directoryType = "consumables";
  505. break;
  506. }
  507. }
  508. dynamic joInParams = new JObject();
  509. joInParams.pagination = new JArray() as dynamic;
  510. joInParams.session = new JArray() as dynamic;
  511. JArray jaParams = new JArray();
  512. dynamic joParams = new JObject();
  513. joParams.code = "";
  514. joParams.descripts = "";
  515. joParams.FindType = new JArray();
  516. joParams.TypeID = "";
  517. joParams.alias = "";
  518. joParams.include = "Hosp";
  519. joParams.groupID = "324";
  520. joParams.hospID = "25";
  521. joParams.type = directoryType;
  522. joParams.specInput = "";
  523. jaParams.Add(joParams);
  524. joInParams.Add("params", JArray.FromObject(jaParams));
  525. dynamic joSession = new JObject();
  526. joSession.userID = "";
  527. joSession.locID = "";
  528. joSession.groupID = "";
  529. joSession.hospID = "";
  530. joSession.sessionID = "";
  531. joSession.hospCode = "";
  532. joSession.language = "";
  533. joSession.hostName = "";
  534. joSession.ipv4 = "";
  535. joSession.ipv6 = "";
  536. joSession.mac = "";
  537. joInParams.session.Add(joSession);
  538. dynamic joPagination = new JObject();
  539. joPagination.pageSize = pageSize;
  540. joPagination.currentPage = currentPage;
  541. joPagination.sortColumn = "Code";
  542. joPagination.sortOrder = "asc";
  543. joInParams.pagination.Add(joPagination);
  544. joInParams.code = "09010012";
  545. string sInput = joInParams.ToString();
  546. string sRtn = invoker.invokeInsuService(joInParams, "");
  547. JObject jsonRtn = JObject.Parse(sRtn);
  548. if (jsonRtn["result"]["Data"] == null)
  549. {
  550. MessageBox.Show("该节点不存在");
  551. return;
  552. }
  553. JObject joRtn = JObject.Parse(sRtn);
  554. DataTable dt = (DataTable)joRtn["result"]["Data"].ToObject(typeof(DataTable));
  555. int totalCount = int.Parse(joRtn["result"]["TotalCount"].ToString());
  556. pgCenterDirect.TotalCount = totalCount;
  557. pgCenterDirect.PageSize = 50;
  558. dgvCenterDirectory.DataSource = dt;
  559. }
  560. private void Mapping()
  561. {
  562. int iHis = dgvHISDirectory.CurrentRow.Index;
  563. if (dgvCenterDirectory.CurrentRow == null)
  564. {
  565. MessageBox.Show("请查询中心目录");
  566. return;
  567. }
  568. int iCenter = dgvCenterDirectory.CurrentRow.Index;
  569. DataTable dtHis = (DataTable)dgvHISDirectory.DataSource;
  570. DataTable dtCenter = (DataTable)dgvCenterDirectory.DataSource;
  571. dgvHISDirectory.Rows[iHis].Cells["insuCode"].Value = dgvCenterDirectory.Rows[iCenter].Cells["Code"].Value.ToString();
  572. dgvHISDirectory.Rows[iHis].Cells["insuName"].Value = dgvCenterDirectory.Rows[iCenter].Cells["Name"].Value.ToString();
  573. int hisType = rbgDirecType_C.SelectedIndex + 1;
  574. string hisTypeName = rbgDirecType_C.Items[hisType - 1].ToString(); ;
  575. JArray jaParams = new JArray();
  576. dynamic jsonTemp = new JObject();
  577. jsonTemp.ID = dtHis.Rows[iHis]["MapID"];
  578. jsonTemp.HospitalDr = Global.inf.hospitalDr;
  579. jsonTemp.updateUserID = Global.user.ID;
  580. jsonTemp.InterfaceDr = Global.inf.interfaceDr;
  581. jsonTemp.HISCode = dgvHISDirectory.Rows[iHis].Cells["itemCode"].Value;
  582. jsonTemp.HISName = dgvHISDirectory.Rows[iHis].Cells["itemDesc"].Value;
  583. jsonTemp.ChargeItemDr = dtHis.Rows[iHis]["ID"];
  584. jsonTemp.DiretoryDr = dtCenter.Rows[iCenter]["medInsuDirectoryID"];
  585. //1.已对照 2.已对照但未上传 3 已对照且已上传
  586. jsonTemp.State = 1;
  587. jsonTemp.HisType = hisType;
  588. jsonTemp.HisTypeName = hisTypeName;
  589. jsonTemp.InsuCode = dgvCenterDirectory.Rows[dgvCenterDirectory.CurrentRow.Index].Cells["Code"].Value;
  590. jsonTemp.InsuName = dgvCenterDirectory.Rows[dgvCenterDirectory.CurrentRow.Index].Cells["Name"].Value;
  591. jsonTemp.UpdateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  592. jaParams.Add(jsonTemp);
  593. JObject joIn = new JObject();
  594. joIn.Add(new JProperty("params", jaParams));
  595. joIn.Add("code", "09010040");
  596. InvokeHelper invoker = new InvokeHelper();
  597. JObject joRtn = invoker.invokeInsuService(joIn.ToString(), "插入对照信息");
  598. //JObject joRtn = JObject.Parse(irisRtn);
  599. if ((int)joRtn["errorCode"] == 0)
  600. {
  601. dgvHISDirectory.Rows[iHis].Cells["flag"].Value = "已对照";
  602. }
  603. else
  604. {
  605. dgvHISDirectory.Rows[iHis].Cells["flag"].Value = "对照失败";
  606. }
  607. }
  608. private void CancleMapping()
  609. {
  610. int iHis = dgvHISDirectory.CurrentRow.Index;
  611. DataTable dtHis = (DataTable)dgvHISDirectory.DataSource;
  612. JArray jaParams = new JArray();
  613. dynamic jsonTemp = new JObject();
  614. jsonTemp.ID = dtHis.Rows[iHis]["MapID"];
  615. jsonTemp.HospitalDr = Global.inf.hospitalDr;
  616. jsonTemp.updateUserID = Global.user.ID;
  617. jsonTemp.InterfaceDr = Global.inf.interfaceDr;
  618. jsonTemp.HISCode = dgvHISDirectory.Rows[iHis].Cells["itemCode"].Value;
  619. jsonTemp.UpdateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  620. jaParams.Add(jsonTemp);
  621. JObject joIn = new JObject();
  622. joIn.Add(new JProperty("params", jaParams));
  623. joIn.Add("code", "09010041");
  624. InvokeHelper invoker = new InvokeHelper();
  625. JObject joRtn = invoker.invokeInsuService(joIn.ToString(), "取消对照");
  626. if ((int)joRtn["errorCode"] == 0)
  627. {
  628. dgvHISDirectory.Rows[iHis].Cells["insuCode"].Value = "";
  629. dgvHISDirectory.Rows[iHis].Cells["insuName"].Value = "";
  630. dgvHISDirectory.Rows[iHis].Cells["flag"].Value = "";
  631. }
  632. else
  633. {
  634. dgvHISDirectory.Rows[iHis].Cells["flag"].Value = "取消失败";
  635. }
  636. }
  637. /// <summary>
  638. /// 医保目录单个版本号的下载
  639. /// </summary>
  640. /// <param name="ver"></param>
  641. /// <param name="directoryType"></param>
  642. /// <param name="uiProcessBar"></param>
  643. /// <param name="errorMessage"></param>
  644. /// <returns></returns>
  645. public int SingleDownload(string ver, int directoryType, Sunny.UI.UIProcessBar uiProcessBar, out string errorMessage)
  646. {
  647. string txtPath = string.Empty;
  648. errorMessage = "";
  649. int iResult = -1;
  650. string funNo = "";
  651. switch (directoryType)
  652. {
  653. case 0://药品
  654. {
  655. funNo = "1301"; //"1301";
  656. break;
  657. }
  658. case 1://诊疗
  659. {
  660. funNo = "1305";
  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. public void loadTextDebug()
  740. {
  741. DataImoport bus = new DataImoport();
  742. string txtPath = @"E:\insu\Demo\bin\Debug\20230101535395327567680436.txt";
  743. JObject joImportRtn = bus.importDataToIrisByTxt(txtPath, 50, 2, uiProcessBar1);
  744. }
  745. /// <summary>
  746. /// 医保目录单个版本号的下载
  747. /// </summary>
  748. /// <param name="ver"></param>
  749. /// <param name="directoryType"></param>
  750. /// <param name="uiProcessBar"></param>
  751. /// <param name="errorMessage"></param>
  752. /// <returns></returns>
  753. public int downloadDicionary(JObject joData, Sunny.UI.UIProcessBar uiProcessBar, string dictCode,out string errorMessage)
  754. {
  755. errorMessage = "";
  756. int iResult = -1;
  757. try
  758. {
  759. JObject joRtn = cBus.DownDictionay(joData);
  760. if (JsonHelper.parseCenterRtnValue(joRtn, out errorMessage) == 0)
  761. {
  762. DataImoport DI = new DataImoport();
  763. JArray jaList = JArray.Parse(JsonHelper.getDestValue(joRtn, "output.list"));
  764. JObject joImportRtn = DI.importDictionary(uiProcessBar, jaList, dictCode);
  765. if (JsonHelper.parseIrisRtnValue(joImportRtn, out errorMessage) == 0)
  766. {
  767. iResult = 0;
  768. }
  769. else
  770. {
  771. errorMessage = "导入数据出现错误,请查看日志!" + errorMessage;
  772. }
  773. }
  774. return iResult;
  775. }
  776. catch (Exception ex)
  777. {
  778. errorMessage = "downloadDicionary提示:" + ex.Message;
  779. return -1;
  780. }
  781. }
  782. /// <summary>
  783. /// 自动下载医保目录,直到最新版本(返回报错)
  784. /// </summary>
  785. /// <param name="directoryType"></param>
  786. /// <param name="uiProcessBar"></param>
  787. /// <param name="errorMessage"></param>
  788. /// <returns></returns>
  789. public int AutoDownload(int directoryType, Sunny.UI.UIProcessBar uiProcessBar, out string errorMessage)
  790. {
  791. int iResult = 0;
  792. errorMessage = "";
  793. try
  794. {
  795. while (iResult == 0)
  796. {
  797. JObject joMaxVerNO = mIS.getDirectoryMaxVersionNO(directoryType);
  798. string ver = joMaxVerNO["result"]["MaxVersionNO"].ToString();
  799. tbVer.Text = ver;
  800. iResult = JsonHelper.parseIrisRtnValue(joMaxVerNO, out errorMessage);
  801. iResult = SingleDownload(ver, directoryType, uiProcessBar, out errorMessage);
  802. }
  803. return iResult;
  804. }
  805. catch (Exception ex)
  806. {
  807. errorMessage = ex.Message;
  808. return -1;
  809. }
  810. }
  811. #endregion
  812. private void Form1_Load(object sender, EventArgs e)
  813. {
  814. this.WindowState = FormWindowState.Maximized;
  815. rbgDirecType.ValueChanged += new Sunny.UI.UIRadioButtonGroup.OnValueChanged(rbgDirecType_ValueChanged);
  816. LabExplain.Visible = false;
  817. }
  818. private void btnDownload_Click(object sender, EventArgs e)
  819. {
  820. string errorMessage = string.Empty;
  821. //医保字典数据下载
  822. if (rbgDirecType.SelectedIndex == 8)
  823. {
  824. if (tbDicDate.Text == "")
  825. {
  826. MessageBox.Show("请输入查询日期!");
  827. return;
  828. }
  829. // 支持批量
  830. string[] dictText = tbDicType.Text.Trim().Split(",".ToCharArray());
  831. dictText.ToList().ForEach((dict) =>
  832. {
  833. this.downloadDict(dict);
  834. });
  835. }
  836. else if (rbgDirecType.SelectedIndex <=10)
  837. {
  838. if (rbSingleDown.Checked)
  839. {
  840. string ver = tbVer.Text;
  841. if (tbVer.Text != "")
  842. {
  843. ver = tbVer.Text;
  844. }
  845. if (SingleDownload(ver, rbgDirecType.SelectedIndex, uiProcessBar1, out errorMessage) != 0)
  846. {
  847. MessageBox.Show("医保目录下载失败:" + errorMessage);
  848. return;
  849. }
  850. }
  851. if (rbAutoDown.Checked)
  852. {
  853. if (AutoDownload(rbgDirecType.SelectedIndex, uiProcessBar1, out errorMessage) != 0)
  854. {
  855. MessageBox.Show("医保目录下载失败:" + errorMessage);
  856. return;
  857. }
  858. }
  859. }
  860. btnQuery_Click(sender, e);
  861. }
  862. private void downloadDict(string dictCode)
  863. {
  864. try
  865. {
  866. string errorMessage = "";
  867. dynamic joData = new JObject();
  868. joData.type = dictCode; //字典类型
  869. joData.parentValue = ""; //父字典键值
  870. joData.admdvs = Global.inf.areaCode; //行政区划 就医地
  871. joData.date = tbDicDate.Text; //查询日期
  872. joData.vali_flag = "1"; //有效标志
  873. if (downloadDicionary(joData, uiProcessBar1,dictCode, out errorMessage) != 0)
  874. {
  875. MessageBox.Show("医保字典下载失败:" + errorMessage);
  876. }
  877. }
  878. catch (Exception e)
  879. {
  880. }
  881. }
  882. private void btnQuery_Click(object sender, EventArgs e)
  883. {
  884. #region 校验查询条件
  885. if ((rbgDirecType.SelectedIndex < 0) || (rbgDirecType.SelectedIndex > 20))
  886. {
  887. MessageBox.Show("请先选择查询类型!");
  888. return;
  889. }
  890. if (rbgDirecType.SelectedIndex > 13)
  891. {
  892. if (rbgDirecType.SelectedIndex != 20)
  893. {
  894. if ((TexDate.Text == "") || (TexDate.Text == "输入日期 2021-01-01"))
  895. {
  896. MessageBox.Show("查询条件-请输入查询日期!");
  897. return;
  898. }
  899. if ((TexDQYS.Text == "") || (TexDQYS.Text == "当前页数"))
  900. {
  901. MessageBox.Show("查询条件-请输入当前页数!");
  902. return;
  903. }
  904. if ((TexBYSJL.Text == "") || (TexBYSJL.Text == "本页数据量"))
  905. {
  906. MessageBox.Show("查询条件-请输入本页数据量!");
  907. return;
  908. }
  909. }
  910. else
  911. {
  912. if ((TexYYMC.Text == "") || (TexYYMC.Text == "输入医院名称模糊查找"))
  913. {
  914. MessageBox.Show("查询条件-请输入医院名称模糊查找!");
  915. return;
  916. }
  917. }
  918. }
  919. #endregion
  920. queryHISInsuDirectory(rbgDirecType.SelectedIndex, 1, 20, dgvDirectoy, Global.inf.interfaceDr);
  921. }
  922. private void btnQueryHISDirectory_Click(object sender, EventArgs e)
  923. {
  924. int iCount = 50;
  925. if (rbNoMaped.Checked)
  926. {
  927. try
  928. {
  929. if (Int32.Parse(numPage.Text) > currentPageIndex && pgHISDirect.TotalCount > 0)
  930. {
  931. currentPageIndex = Int32.Parse(numPage.Text);
  932. }
  933. }
  934. catch (Exception ex)
  935. {
  936. MessageBox.Show(ex.Message);
  937. return;
  938. }
  939. iCount = 300;
  940. }
  941. string errMsg;
  942. if (queryHISDirectory(currentPageIndex, iCount, out errMsg) != 0)
  943. {
  944. MessageBox.Show(errMsg);
  945. return;
  946. }
  947. }
  948. private void btnQueryCenterDirectory_Click(object sender, EventArgs e)
  949. {
  950. if ((tbCenterDirectoryFilter.Text == "") && (tbInsuCode.Text == "") && (tbApprovalNO.Text == "") &&
  951. (tbManufacturer.Text == "") && (tbSpecifications.Text == "") && (tbDosageForm.Text == ""))
  952. {
  953. return;
  954. }
  955. //查询区域通用目录
  956. JObject joRtn = mIS.getInterface_TY(Global.inf.interfaceDr.ToString(),"");
  957. string InsuCurrencyCataLogue = JsonHelper.getDestValue(joRtn, "InsuCurrencyCataLogue"); //通用目录编码 6
  958. string InterfaceName_TY = JsonHelper.getDestValue(joRtn, "InterfaceName_TY"); //通用目录名称
  959. string HospName_TY = JsonHelper.getDestValue(joRtn, "HospitalName"); //目录名称
  960. string HospitalDr_TY = JsonHelper.getDestValue(joRtn, "HospitalDr_TY"); //区域通用目录医院ID
  961. if (InsuCurrencyCataLogue != "")
  962. {
  963. queryHISInsuDirectory(rbgDirecType_C.SelectedIndex, 1, 50, dgvCenterDirectory, int.Parse(InsuCurrencyCataLogue));
  964. LabExplain.Visible = true;
  965. LabExplain.Text = "当前接口已设置区域通用目录,数据源:" + HospName_TY + " ,如果确认没有所查目录请联系数据源医院新增维护!";
  966. }
  967. else
  968. {
  969. queryHISInsuDirectory(rbgDirecType_C.SelectedIndex, 1, 50, dgvCenterDirectory, Global.inf.interfaceDr);
  970. LabExplain.Visible = true;
  971. LabExplain.Text = "当前接口未设置区域通用目录,数据源:" + HospName_TY;
  972. }
  973. }
  974. private void pgDownload_PageChanged(object sender, object pagingSource, int pageIndex, int count)
  975. {
  976. queryHISInsuDirectory(rbgDirecType.SelectedIndex, pageIndex, count, dgvDirectoy, Global.inf.interfaceDr);
  977. }
  978. private void pgHISDirect_PageChanged(object sender, object pagingSource, int pageIndex, int count)
  979. {
  980. string errMsg;
  981. int iCount = 50;
  982. if (rbNoMaped.Checked) iCount = 300;
  983. if (queryHISDirectory(pageIndex, iCount, out errMsg) != 0)
  984. {
  985. MessageBox.Show(errMsg);
  986. return;
  987. }
  988. }
  989. private void pgCenterDirect_PageChanged(object sender, object pagingSource, int pageIndex, int count)
  990. {
  991. queryHISInsuDirectory(rbgDirecType_C.SelectedIndex, pageIndex, count, dgvCenterDirectory, Global.inf.interfaceDr);
  992. }
  993. private void rbgDirecType_ValueChanged(object sender, int index, string text)
  994. {
  995. //选定项不同调用的接口也不相同,Index值大于
  996. if (rbgDirecType.SelectedIndex > 13)
  997. {
  998. uiGroupBox1.Visible = false;
  999. uiGroupBox5.Visible = false;
  1000. uiGroupBox2.Visible = true;
  1001. //uiGroupBox3.Visible = true;
  1002. uiProcessBar1.Visible = false;
  1003. uiGroupBox2.Left = rbgDirecType.Width + rbgDirecType.Left + 5;
  1004. uiGroupBox3.Left = uiGroupBox2.Width+rbgDirecType.Width + rbgDirecType.Left + 10;
  1005. dgvDirectoy.DataSource = null;
  1006. }
  1007. else
  1008. {
  1009. uiGroupBox1.Visible = true;
  1010. uiGroupBox5.Visible = true;
  1011. uiGroupBox2.Visible = true;
  1012. //uiGroupBox3.Visible = false;
  1013. uiProcessBar1.Visible = true;
  1014. uiGroupBox1.Left = rbgDirecType.Width + rbgDirecType.Left + 5;
  1015. uiGroupBox5.Left = uiGroupBox1.Width + rbgDirecType.Width + rbgDirecType.Left + 10;
  1016. uiGroupBox2.Left = uiGroupBox5.Width + uiGroupBox1.Width + rbgDirecType.Width + rbgDirecType.Left + 15;
  1017. uiGroupBox3.Left = uiGroupBox2.Width + uiGroupBox5.Width + uiGroupBox1.Width + rbgDirecType.Width + rbgDirecType.Left + 20;
  1018. uiProcessBar1.Left = rbgDirecType.Width + rbgDirecType.Left + 5;
  1019. uiProcessBar1.Width = uiGroupBox1.Width + uiGroupBox5.Width + uiGroupBox2.Width + 10;
  1020. }
  1021. setHeaderTxt(rbgDirecType.SelectedIndex, dgvDirectoy);
  1022. }
  1023. private void toolStripMenuItem2_Click(object sender, EventArgs e)
  1024. {
  1025. CancleMapping();
  1026. }
  1027. private void tsmiMapping_Click(object sender, EventArgs e)
  1028. {
  1029. Mapping();
  1030. }
  1031. private void dgvHISDirectory_DoubleClick(object sender, EventArgs e)
  1032. {
  1033. int currentPage = pgHISDirect.ActivePage;
  1034. string flag = dgvHISDirectory.Rows[dgvHISDirectory.CurrentRow.Index].Cells["flag"].Value.ToString();
  1035. if (flag == "未对照")
  1036. {
  1037. Mapping();
  1038. }
  1039. else
  1040. if (flag == "已对照")
  1041. {
  1042. CancleMapping();
  1043. }
  1044. if (rbAll.Checked)
  1045. {
  1046. string errMsg;
  1047. if (queryHISDirectory(1, 50, out errMsg) != 0)
  1048. {
  1049. MessageBox.Show(errMsg);
  1050. return;
  1051. }
  1052. }
  1053. }
  1054. private void dgvDirectoy_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  1055. {
  1056. }
  1057. private void dgvDirectoy_CellContentClick(object sender, DataGridViewCellEventArgs e)
  1058. {
  1059. }
  1060. private void uiRadioButton1_CheckedChanged(object sender, EventArgs e)
  1061. {
  1062. }
  1063. private void dgvDirectoy_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
  1064. {
  1065. //自动编号,与数据无关
  1066. Rectangle rectangle = new Rectangle(e.RowBounds.Location.X,
  1067. e.RowBounds.Location.Y,
  1068. dgvDirectoy.RowHeadersWidth - 4,
  1069. e.RowBounds.Height);
  1070. TextRenderer.DrawText(e.Graphics,
  1071. (e.RowIndex + 1).ToString(),
  1072. dgvDirectoy.RowHeadersDefaultCellStyle.Font,
  1073. rectangle,
  1074. dgvDirectoy.RowHeadersDefaultCellStyle.ForeColor,
  1075. TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
  1076. }
  1077. private void rbAll_ValueChanged(object sender, bool value)
  1078. {
  1079. //if (rbAll.Checked)
  1080. //{
  1081. // btnQueryHISDirectory_Click(null, new EventArgs());
  1082. //}
  1083. }
  1084. private void rbMaped_CheckedChanged(object sender, EventArgs e)
  1085. {
  1086. //if (rbMaped.Checked)
  1087. //{
  1088. // string errMsg;
  1089. // if (queryHISDirectory(1, 50, out errMsg) != 0)
  1090. // {
  1091. // MessageBox.Show(errMsg);
  1092. // return;
  1093. // }
  1094. //}
  1095. }
  1096. private void btAddDir_Click(object sender, EventArgs e)
  1097. {
  1098. AddSingleDirectory addDirectory = new AddSingleDirectory(rbgDirecType.SelectedIndex);
  1099. if (addDirectory.ShowDialog() == DialogResult.OK)
  1100. {
  1101. JObject joRtn = mIS.UpdateDirectoryBySelf(addDirectory.joPamam);
  1102. string error = "";
  1103. if (JsonHelper.parseIrisRtnValue(joRtn, out error) != 0)
  1104. {
  1105. MessageBox.Show("新增失败:" + error);
  1106. }
  1107. else
  1108. {
  1109. MessageBox.Show("新增成功");
  1110. }
  1111. }
  1112. }
  1113. private void btEditDir_Click(object sender, EventArgs e)
  1114. {
  1115. DataTable dt = (DataTable)dgvDirectoy.DataSource;
  1116. if ((dt == null) || (dt.Rows.Count < 1))
  1117. {
  1118. MessageBox.Show("表中无数据,请检查!");
  1119. return;
  1120. }
  1121. DataRow dr = dt.Rows[dgvDirectoy.CurrentRow.Index];
  1122. AddSingleDirectory addDirectory = new AddSingleDirectory(rbgDirecType.SelectedIndex, dr);
  1123. if (addDirectory.ShowDialog() == DialogResult.OK)
  1124. {
  1125. JObject joRtn = mIS.UpdateDirectoryBySelf(addDirectory.joPamam);
  1126. string error = "";
  1127. if (JsonHelper.parseIrisRtnValue(joRtn, out error) != 0)
  1128. {
  1129. MessageBox.Show("修改失败:" + error);
  1130. }
  1131. else
  1132. {
  1133. MessageBox.Show("修改成功");
  1134. }
  1135. }
  1136. }
  1137. private void btnExit_Click(object sender, EventArgs e)
  1138. {
  1139. Close();
  1140. }
  1141. /// <summary>
  1142. /// 几个医保查询的交易组织入参
  1143. /// </summary>
  1144. /// <param name="Index"></param>
  1145. /// <param name="funNo"></param>
  1146. /// <returns></returns>
  1147. private JObject GetInput(int Index, out string funNo)
  1148. {
  1149. funNo = "";
  1150. dynamic joData = new JObject();
  1151. switch (Index)
  1152. {
  1153. case 14://民族药品目
  1154. {
  1155. funNo = "1304";
  1156. joData.med_list_codg = tbDirectoryCode.Text; //医疗目录编码
  1157. joData.genname_codg = ""; //通用名编号
  1158. joData.drug_genname = ""; //药品通用名
  1159. joData.drug_prodname = tbDircetoryName.Text; //药品商品名
  1160. joData.reg_name = ""; //注册名称
  1161. joData.tcmherb_name = ""; //中草药名称
  1162. joData.mlms_name = ""; //药材名称
  1163. joData.vali_flag = ""; //有效标志
  1164. joData.rid = ""; //唯一记录号
  1165. joData.ver = ""; //版本号
  1166. joData.ver_name = ""; //版本名称
  1167. joData.opt_begn_time = ""; //经办开始时间
  1168. joData.opt_end_time = ""; //经办结束时间
  1169. joData.updt_time = TexDate.Text; //更新时间
  1170. joData.page_num = TexDQYS.Text; //当前页数
  1171. joData.page_size = TexBYSJL.Text; //本页数据量
  1172. break;
  1173. }
  1174. case 15://目录信息查询
  1175. {
  1176. funNo = "1312";
  1177. joData.query_date = ""; //查询时间点
  1178. joData.hilist_code = tbDirectoryCode.Text; //医保目录编码
  1179. joData.insu_admdvs = Global.inf.areaCode; //参保机构医保区划
  1180. joData.begndate = ""; //开始日期
  1181. joData.hilist_name = tbDircetoryName.Text; //医保目录名称
  1182. joData.wubi = ""; //五笔助记码
  1183. joData.pinyin = ""; //拼音助记码
  1184. joData.med_chrgitm_type = ""; //医疗收费项目类别
  1185. joData.chrgitm_lv = ""; //收费项目等级
  1186. joData.lmt_used_flag = ""; //限制使用标志
  1187. joData.list_type = ""; //目录类别
  1188. joData.med_use_flag = ""; //医疗使用标志
  1189. joData.matn_used_flag = ""; //生育使用标志
  1190. joData.hilist_use_type = ""; //医保目录使用类别
  1191. joData.lmt_cpnd_type = ""; //限复方使用类型
  1192. joData.vali_flag = ""; //有效标志
  1193. joData.updt_time = TexDate.Text; //更新时间
  1194. joData.page_num = TexDQYS.Text; //当前页数
  1195. joData.page_size = TexBYSJL.Text; //本页数据量
  1196. break;
  1197. }
  1198. case 16://医疗与医保目录匹配
  1199. {
  1200. funNo = "1316";
  1201. joData.query_date = ""; //查询时间点
  1202. joData.medins_list_codg = ""; //定点医药机构目录编号
  1203. joData.hilist_code = tbDirectoryCode.Text; //医保目录编码
  1204. joData.list_type = ""; //目录类别
  1205. joData.insu_admdvs = ""; //参保机构医保区划
  1206. joData.begndate = ""; //开始日期
  1207. joData.vali_flag = ""; //有效标志
  1208. joData.updt_time = TexDate.Text; //更新时间
  1209. joData.page_num = TexDQYS.Text; //当前页数
  1210. joData.page_size = TexBYSJL.Text; //本页数据量
  1211. break;
  1212. }
  1213. case 17://医药机构目录匹配
  1214. {
  1215. funNo = "1317";
  1216. joData.query_date = ""; //查询时间点
  1217. joData.fixmedins_code = ""; //定点医药机构编号
  1218. joData.medins_list_codg = ""; //定点医药机构目录编号
  1219. joData.medins_list_name = ""; //定点医药机构目录名称
  1220. joData.insu_admdvs = ""; //参保机构医保区划
  1221. joData.list_type = ""; //目录类别
  1222. joData.med_list_codg = tbDirectoryCode.Text; //医疗目录编码
  1223. joData.begndate = ""; //开始日期
  1224. joData.vali_flag = ""; //有效标志
  1225. joData.updt_time = TexDate.Text; //更新时间
  1226. joData.page_num = TexDQYS.Text; //当前页数
  1227. joData.page_size = TexBYSJL.Text; //本页数据量
  1228. break;
  1229. }
  1230. case 18://医保目录限价
  1231. {
  1232. funNo = "1318";
  1233. joData.query_date = ""; //查询时间点
  1234. joData.hilist_code = tbDirectoryCode.Text; //医保目录编码
  1235. joData.hilist_lmtpric_type = ""; //医保目录限价类型
  1236. joData.overlmt_dspo_way = ""; //医保目录超限处理方式
  1237. joData.insu_admdvs = Global.inf.areaCode; //参保机构医保区划
  1238. joData.begndate = ""; //开始日期
  1239. joData.enddate = ""; //结束日期
  1240. joData.vali_flag = ""; //有效标志
  1241. joData.rid = ""; //唯一记录号
  1242. joData.tabname = ""; //表名
  1243. joData.poolarea_no = ""; //统筹区
  1244. joData.updt_time = TexDate.Text; //更新时间
  1245. joData.page_num = TexDQYS.Text; //当前页数
  1246. joData.page_size = TexBYSJL.Text; //本页数据量
  1247. break;
  1248. }
  1249. case 19://医保目录先自付比例
  1250. {
  1251. funNo = "1319";
  1252. joData.query_date = ""; //查询时间点
  1253. joData.hilist_code = tbDirectoryCode.Text; //医保目录编码
  1254. joData.selfpay_prop_psn_type = "";//医保目录自付比例人员类别
  1255. joData.selfpay_prop_type = ""; //目录自付比例类别
  1256. joData.insu_admdvs = ""; //参保机构医保区划
  1257. joData.begndate = ""; //开始日期
  1258. joData.enddate = ""; //结束日期
  1259. joData.vali_flag = ""; //有效标志
  1260. joData.rid = ""; //唯一记录号
  1261. joData.tabname = ""; //表名
  1262. joData.poolarea_no = ""; //统筹区
  1263. joData.updt_time = TexDate.Text; //更新时间
  1264. joData.page_num = TexDQYS.Text; //当前页数
  1265. joData.page_size = TexBYSJL.Text; //本页数据量
  1266. break;
  1267. }
  1268. case 20://医药机构信息
  1269. {
  1270. funNo = "1201";
  1271. joData.fixmedins_type = "1"; //定点医疗服务机构类型 1定点医疗机构,2定点零售药店,3工伤定点康复机构,4辅助器具配置机构,5计划生育服务机构
  1272. joData.fixmedins_name = TexYYMC.Text; //定点医药机构名称
  1273. joData.fixmedins_code = ""; //定点医药机构编号
  1274. break;
  1275. }
  1276. }
  1277. return joData;
  1278. }
  1279. private void chek_UporCancel_CheckedChanged(object sender, EventArgs e)
  1280. {
  1281. }
  1282. private void uiButton1_Click(object sender, EventArgs e)
  1283. {
  1284. Close();
  1285. }
  1286. private void btnUpShip_Click(object sender, EventArgs e)
  1287. {
  1288. AllUpLoad();
  1289. }
  1290. private void btnCancelUpShip_Click(object sender, EventArgs e)
  1291. {
  1292. AllCancelUpload();
  1293. }
  1294. /// <summary>
  1295. /// 单条上传目录对照关系
  1296. /// </summary>
  1297. private void SingleUpload()
  1298. {
  1299. if ((dgvHISDirectory.CurrentRow == null) || (rbMaped.Checked != true))
  1300. {
  1301. MessageBox.Show("请查询HIS目录对照关系");
  1302. return;
  1303. }
  1304. string errorMsg = "", sMLLX = "";
  1305. //单条目录对照关系上传
  1306. int iHis = dgvHISDirectory.CurrentRow.Index;
  1307. DataTable dtHis = (DataTable)dgvHISDirectory.DataSource;
  1308. int hisType = rbgDirecType_C.SelectedIndex + 1; //1药品 2诊疗 3材料
  1309. //string hisTypeName = rbgDirecType_C.Items[hisType - 1].ToString();
  1310. if (hisType == 1)
  1311. {
  1312. sMLLX = "101"; //101西药中成药 102中药饮片 103自制剂 104民族药 201医疗服务项目 301医用耗材 501长护服务项目 105其他
  1313. }
  1314. else if (hisType == 2)
  1315. {
  1316. sMLLX = "201";
  1317. }
  1318. else if (hisType == 3)
  1319. {
  1320. sMLLX = "301";
  1321. }
  1322. string InsuCode = dtHis.Rows[iHis]["InsuCode"].ToString();
  1323. string InsuName = dtHis.Rows[iHis]["InsuName"].ToString();
  1324. string HisCode = dtHis.Rows[iHis]["itemCode"].ToString();
  1325. string HisName = dtHis.Rows[iHis]["itemDesc"].ToString();
  1326. string UpdateDate = DateTime.Now.ToString("yyyy-MM-dd");
  1327. //调用3301目录对照上传
  1328. JObject joData = new JObject();
  1329. joData.Add("fixmedins_hilist_id", HisCode);
  1330. joData.Add("fixmedins_hilist_name", HisName);
  1331. joData.Add("list_type", sMLLX); //目录类别
  1332. joData.Add("med_list_codg", InsuCode); //医疗目录编码
  1333. joData.Add("begndate", "2022-10-01"); //开始日期
  1334. joData.Add("enddate", UpdateDate); //结束日期
  1335. joData.Add("aprvno", "");
  1336. joData.Add("dosform", "");
  1337. joData.Add("exct_cont", "");
  1338. joData.Add("item_cont", "");
  1339. joData.Add("prcunt", "");
  1340. joData.Add("spec", "");
  1341. joData.Add("pacspec", "");
  1342. joData.Add("memo", "");
  1343. JObject joInput = new JObject();
  1344. joInput.Add("data", joData);
  1345. InvokeHelper invoker = new InvokeHelper();
  1346. JObject joRtn = invoker.invokeCenterService("3301", JsonHelper.setCenterInpar("3301", joInput));
  1347. if (JsonHelper.parseCenterRtnValue(joRtn, out errorMsg) != 0)
  1348. {
  1349. MessageBox.Show("目录对照关系上传失败:" + errorMsg);
  1350. }
  1351. else
  1352. {
  1353. MessageBox.Show("目录对照关系上传成功!");
  1354. }
  1355. }
  1356. /// <summary>
  1357. /// 单条撤销目录对照关系上传
  1358. /// </summary>
  1359. private void SingleCancelUpload()
  1360. {
  1361. if ((dgvHISDirectory.CurrentRow == null) || (rbMaped.Checked != true))
  1362. {
  1363. MessageBox.Show("请查询HIS目录对照关系");
  1364. return;
  1365. }
  1366. string errorMsg = "", sMLLX = "";
  1367. //撤销目录对照关系
  1368. DataTable dtHis = (DataTable)dgvHISDirectory.DataSource;
  1369. int iHis = dgvHISDirectory.CurrentRow.Index;
  1370. string InsuCode = dtHis.Rows[iHis]["InsuCode"].ToString();
  1371. string HisCode = dtHis.Rows[iHis]["HisCode"].ToString();
  1372. int hisType = rbgDirecType_C.SelectedIndex + 1; //1药品 2诊疗 3材料
  1373. //string hisTypeName = rbgDirecType_C.Items[hisType - 1].ToString();
  1374. if (hisType == 1)
  1375. {
  1376. sMLLX = "101"; //101西药中成药 102中药饮片 103自制剂 104民族药 201医疗服务项目 301医用耗材 501长护服务项目 105其他
  1377. }
  1378. else if (hisType == 2)
  1379. {
  1380. sMLLX = "201";
  1381. }
  1382. else if (hisType == 3)
  1383. {
  1384. sMLLX = "301";
  1385. }
  1386. //调用3302目录对照撤销
  1387. JObject joData = new JObject();
  1388. joData.Add("fixmedins_code", Global.inf.hospitalNO);
  1389. joData.Add("fixmedins_hilist_id", HisCode);
  1390. joData.Add("list_type", sMLLX); //目录类别
  1391. joData.Add("med_list_codg", InsuCode); //医疗目录编码
  1392. JObject joInput = new JObject();
  1393. joInput.Add("data", joData);
  1394. InvokeHelper invoker = new InvokeHelper();
  1395. JObject joRtn = invoker.invokeCenterService("3302", JsonHelper.setCenterInpar("3302", joInput));
  1396. if (JsonHelper.parseCenterRtnValue(joRtn, out errorMsg) != 0)
  1397. {
  1398. MessageBox.Show("目录对照撤销失败:" + errorMsg);
  1399. }
  1400. else
  1401. {
  1402. MessageBox.Show("目录对照撤销成功!");
  1403. }
  1404. }
  1405. /// <summary>
  1406. /// 全部上传目录对照关系
  1407. /// </summary>
  1408. private void AllUpLoad()
  1409. {
  1410. if ((dgvHISDirectory.CurrentRow == null) || (rbMaped.Checked != true))
  1411. {
  1412. MessageBox.Show("请查询HIS目录对照关系");
  1413. return;
  1414. }
  1415. string sInputStr = "", sMLLX = "", errorMsg = "", Msg = "";
  1416. Boolean bOk = true;
  1417. JObject InputjoRtn = new JObject();
  1418. string UpdateDate = DateTime.Now.ToString("yyyy-MM-dd");
  1419. int hisType = rbgDirecType_C.SelectedIndex + 1; //1药品 2诊疗 3材料
  1420. if (hisType == 1)
  1421. {
  1422. sMLLX = "101"; //101西药中成药 102中药饮片 103自制剂 104民族药 201医疗服务项目 301医用耗材 501长护服务项目 105其他
  1423. }
  1424. else if (hisType == 2)
  1425. {
  1426. sMLLX = "201";
  1427. }
  1428. else if (hisType == 3)
  1429. {
  1430. sMLLX = "301";
  1431. }
  1432. DataTable dtHis = (DataTable)dgvHISDirectory.DataSource;
  1433. for (int i = 0; i < dtHis.Rows.Count; i++)
  1434. {
  1435. string InsuCode = dtHis.Rows[i]["InsuCode"].ToString(); //医保目录编码
  1436. string InsuName = dtHis.Rows[i]["InsuName"].ToString(); //医保目录名称
  1437. string HisCode = dtHis.Rows[i]["itemCode"].ToString(); //HIS目录编码
  1438. string HisName = dtHis.Rows[i]["itemDesc"].ToString(); //HIS目录名称
  1439. //调用3301目录对照上传
  1440. JObject joData = new JObject();
  1441. joData.Add("fixmedins_hilist_id", HisCode);
  1442. joData.Add("fixmedins_hilist_name", HisName);
  1443. joData.Add("list_type", sMLLX); //目录类别
  1444. joData.Add("med_list_codg", InsuCode); //医疗目录编码
  1445. joData.Add("begndate", "2022-10-01"); //开始日期
  1446. joData.Add("enddate", UpdateDate); //结束日期
  1447. joData.Add("aprvno", "");
  1448. joData.Add("dosform", "");
  1449. joData.Add("exct_cont", "");
  1450. joData.Add("item_cont", "");
  1451. joData.Add("prcunt", "");
  1452. joData.Add("spec", "");
  1453. joData.Add("pacspec", "");
  1454. joData.Add("memo", "");
  1455. JObject joInput = new JObject();
  1456. joInput.Add("data", joData);
  1457. InvokeHelper invoker = new InvokeHelper();
  1458. JObject joRtn = invoker.invokeCenterService("3301", JsonHelper.setCenterInpar("3301", joInput));
  1459. if (JsonHelper.parseCenterRtnValue(joRtn, out errorMsg) != 0)
  1460. {
  1461. bOk = false;
  1462. Msg = Msg + "<" + joInput.ToString() + ":" + errorMsg + ">";
  1463. }
  1464. }
  1465. if (bOk == false)
  1466. {
  1467. MessageBox.Show("全部目录对照关系上传成功,部分上传异常:" + Msg);
  1468. }
  1469. else
  1470. {
  1471. MessageBox.Show("全部目录对照关系上传成功!");
  1472. }
  1473. }
  1474. /// <summary>
  1475. /// 全部撤销目录对照关系上传
  1476. /// </summary>
  1477. private void AllCancelUpload()
  1478. {
  1479. if ((dgvHISDirectory.CurrentRow == null) || (rbMaped.Checked != true))
  1480. {
  1481. MessageBox.Show("请查询HIS目录对照关系");
  1482. return;
  1483. }
  1484. string sMLLX = "", errorMsg = "", Msg = "";
  1485. Boolean bOk = true;
  1486. string UpdateDate = DateTime.Now.ToString("yyyy-MM-dd");
  1487. int hisType = rbgDirecType_C.SelectedIndex + 1; //1药品 2诊疗 3材料
  1488. if (hisType == 1)
  1489. {
  1490. sMLLX = "101"; //101西药中成药 102中药饮片 103自制剂 104民族药 201医疗服务项目 301医用耗材 501长护服务项目 105其他
  1491. }
  1492. else if (hisType == 2)
  1493. {
  1494. sMLLX = "201";
  1495. }
  1496. else if (hisType == 3)
  1497. {
  1498. sMLLX = "301";
  1499. }
  1500. DataTable dtHis = (DataTable)dgvHISDirectory.DataSource;
  1501. for (int i = 0; i < dtHis.Rows.Count; i++)
  1502. {
  1503. string InsuCode = dtHis.Rows[i]["InsuCode"].ToString();
  1504. string HisCode = dtHis.Rows[i]["HisCode"].ToString();
  1505. //调用3302目录对照撤销
  1506. JObject joData = new JObject();
  1507. joData.Add("fixmedins_code", Global.inf.hospitalNO);
  1508. joData.Add("fixmedins_hilist_id", HisCode);
  1509. joData.Add("list_type", sMLLX); //目录类别
  1510. joData.Add("med_list_codg", InsuCode); //医疗目录编码
  1511. JObject joInput = new JObject();
  1512. joInput.Add("data", joData);
  1513. InvokeHelper invoker = new InvokeHelper();
  1514. JObject joRtn = invoker.invokeCenterService("3302", JsonHelper.setCenterInpar("3302", joInput));
  1515. if (JsonHelper.parseCenterRtnValue(joRtn, out errorMsg) != 0)
  1516. {
  1517. bOk = false;
  1518. Msg = Msg + "<" + joInput.ToString()+":" + errorMsg + ">";
  1519. }
  1520. }
  1521. if (bOk == false)
  1522. {
  1523. MessageBox.Show("全部撤销目录对照关系上传成功,部分撤销异常:" + Msg);
  1524. }
  1525. else
  1526. {
  1527. MessageBox.Show("全部撤销目录对照关系上传成功!");
  1528. }
  1529. }
  1530. private void ToolStripMenuItem_Upload_Click(object sender, EventArgs e)
  1531. {
  1532. SingleUpload();
  1533. }
  1534. private void ToolStripMenuItem_CancelUpload_Click(object sender, EventArgs e)
  1535. {
  1536. SingleCancelUpload();
  1537. }
  1538. private void rbgDirecType_C_ValueChanged(object sender, int index, string text)
  1539. {
  1540. tbHISDirectoryFilter.Text = "";
  1541. uiTextBox1.Text = "";
  1542. rbAll.Checked = true;
  1543. rbMaped.Checked = false;
  1544. rbNoMaped.Checked = false;
  1545. tbCenterDirectoryFilter.Text = "";
  1546. tbInsuCode.Text = "";
  1547. tbApprovalNO.Text = "";
  1548. dgvCenterDirectory.DataSource = null;
  1549. btnQueryHISDirectory_Click(null, new EventArgs());
  1550. }
  1551. private void rbNoMaped_CheckedChanged(object sender, EventArgs e)
  1552. {
  1553. //if (rbNoMaped.Checked)
  1554. //{
  1555. // string errMsg;
  1556. // if (queryHISDirectory(1, 300, out errMsg) != 0)
  1557. // {
  1558. // MessageBox.Show(errMsg);
  1559. // return;
  1560. // }
  1561. //}
  1562. }
  1563. private void dgvHISDirectory_RowStateChanged(object sender, DataGridViewRowStateChangedEventArgs e)
  1564. {
  1565. e.Row.HeaderCell.Value = string.Format("{0}", e.Row.Index + 1);
  1566. }
  1567. private void dgvCenterDirectory_RowStateChanged(object sender, DataGridViewRowStateChangedEventArgs e)
  1568. {
  1569. e.Row.HeaderCell.Value = string.Format("{0}", e.Row.Index + 1);
  1570. }
  1571. private void btnExport_Click(object sender, EventArgs e)
  1572. {
  1573. if (queryHISDirectory(1, 1000, out string errMsg) != 0)
  1574. {
  1575. MessageBox.Show(errMsg);
  1576. return;
  1577. }
  1578. if (dtExport.Rows.Count > 0)
  1579. {
  1580. string directoryType = string.Empty;
  1581. string sBZ = "";
  1582. switch (rbgDirecType_C.SelectedIndex)
  1583. {
  1584. case 0:
  1585. {
  1586. directoryType = "药品";
  1587. break;
  1588. }
  1589. case 1:
  1590. {
  1591. directoryType = "诊疗";
  1592. break;
  1593. }
  1594. case 2:
  1595. {
  1596. directoryType = "材料";
  1597. break;
  1598. }
  1599. }
  1600. if (rbAll.Checked) sBZ = "全部";
  1601. else
  1602. if (rbMaped.Checked) sBZ = "已对照";
  1603. else
  1604. if (rbNoMaped.Checked) sBZ = "未对照";
  1605. string LSH = DateTime.Now.ToString("yyyy-MM-dd"); //DateTime.Now.ToString("MMddHHmmssffff");
  1606. string sFliePathName = @"D:\" + LSH + "(" + directoryType + ")医保目录"+ sBZ + "信息.xls";
  1607. string ReturnFileName = ExportToExcel.DataTabletoExcel(dtExport, sFliePathName);
  1608. if (ReturnFileName != "")
  1609. {
  1610. MessageBox.Show("导出成功,文件保存路径:【" + ReturnFileName + "】");
  1611. System.Diagnostics.Process.Start(ReturnFileName); //打开excel文件
  1612. }
  1613. else
  1614. {
  1615. MessageBox.Show("导出失败!");
  1616. }
  1617. }
  1618. }
  1619. private void tsmExportAllMappedData_Click(object sender, EventArgs e)
  1620. {
  1621. if (queryHISDirectory(1, 1000, out string errMsg) != 0)
  1622. {
  1623. MessageBox.Show(errMsg);
  1624. return;
  1625. }
  1626. if (dtExport.Rows.Count > 0)
  1627. {
  1628. string directoryType = string.Empty;
  1629. string sBZ = "";
  1630. switch (rbgDirecType_C.SelectedIndex)
  1631. {
  1632. case 0:
  1633. {
  1634. directoryType = "药品";
  1635. break;
  1636. }
  1637. case 1:
  1638. {
  1639. directoryType = "诊疗";
  1640. break;
  1641. }
  1642. case 2:
  1643. {
  1644. directoryType = "材料";
  1645. break;
  1646. }
  1647. }
  1648. if (rbAll.Checked) sBZ = "全部";
  1649. else
  1650. if (rbMaped.Checked) sBZ = "已对照";
  1651. else
  1652. if (rbNoMaped.Checked) sBZ = "未对照";
  1653. string LSH = DateTime.Now.ToString("yyyy-MM-dd"); //DateTime.Now.ToString("MMddHHmmssffff");
  1654. string sFliePathName = @"D:\" + LSH + "(" + directoryType + ")医保目录" + sBZ + "信息.xls";
  1655. string ReturnFileName = ExportToExcel.DataTabletoExcel(dtExport, sFliePathName);
  1656. if (ReturnFileName != "")
  1657. {
  1658. MessageBox.Show("导出成功,文件保存路径:【" + ReturnFileName + "】");
  1659. System.Diagnostics.Process.Start(ReturnFileName); //打开excel文件
  1660. }
  1661. else
  1662. {
  1663. MessageBox.Show("导出失败!");
  1664. }
  1665. }
  1666. }
  1667. private void tsmUploadAllMappedData_Click(object sender, EventArgs e)
  1668. {
  1669. AllUpLoad();
  1670. }
  1671. private void tsmCancelAllUploadedData_Click(object sender, EventArgs e)
  1672. {
  1673. AllCancelUpload();
  1674. }
  1675. private void tsmUpdateCellPriceOfAllMapped_Click(object sender, EventArgs e)
  1676. {
  1677. updateMappedInsuInfo(updateCellPriceWrapper);
  1678. }
  1679. private void tsmUpdateAllMapped_Click(object sender, EventArgs e)
  1680. {
  1681. updateMappedInsuInfo(updateAuxAndCellPriceWrapper);
  1682. }
  1683. private void updateMappedInsuInfo(Func<JObject, OutParamWrapper, int> action)
  1684. {
  1685. string sqlStr = $"select * from HB_MedInsuMapRelation where Interface_Dr='{Global.inf.interfaceDr}' and Hospital_Dr ='{Global.inf.hospitalDr}'";
  1686. JObject joSqlstr = new JObject();
  1687. joSqlstr.Add("sqlStr", sqlStr);
  1688. JObject joRtn = mIS.QueryMappedData(joSqlstr, "查询所有已对照数据");
  1689. DataTable dt = (DataTable)joRtn["result"]["data"].ToObject(typeof(DataTable));
  1690. int iFalse = 0;
  1691. int iCount = 0;
  1692. foreach (DataRow dr in dt.Rows)
  1693. {
  1694. JObject jo = new JObject();
  1695. jo.Add("code", dr["InsuCode"].ToString());
  1696. jo.Add("HisType", dr["HisType"].ToString());
  1697. OutParamWrapper outParWarp = new OutParamWrapper();
  1698. if (action(jo, outParWarp) != 0)
  1699. {
  1700. iFalse++;
  1701. Global.writeLog(outParWarp.Value);
  1702. }
  1703. }
  1704. if (iFalse != 0)
  1705. {
  1706. MessageBox.Show($"总共{iCount}条数据更新完成,但有{iFalse}条更新发生错误!");
  1707. }
  1708. else
  1709. {
  1710. MessageBox.Show("全部数据更新完成");
  1711. }
  1712. }
  1713. private int updateAuxAndCellPriceWrapper(JObject jo, OutParamWrapper outParamWrapper)
  1714. {
  1715. string err;
  1716. int iresult = updateAuxAndCellPrice(jo, out err);
  1717. outParamWrapper.Value = err;
  1718. return iresult;
  1719. }
  1720. private int updateCellPriceWrapper(JObject jo, OutParamWrapper outParamWrapper)
  1721. {
  1722. string err;
  1723. int iresult = updateCellingPrice(jo, out err);
  1724. outParamWrapper.Value = err;
  1725. return iresult;
  1726. }
  1727. private int updateAuxInfoWrapper(JObject jo, OutParamWrapper outParamWrapper)
  1728. {
  1729. string err;
  1730. int iresult = updateAuxInfo(jo, out err);
  1731. outParamWrapper.Value = err;
  1732. return iresult;
  1733. }
  1734. private int updateAuxAndCellPrice(JObject jo, out string error)
  1735. {
  1736. string err = "";
  1737. int iResult = 0;
  1738. error = "";
  1739. if (updateAuxInfo(jo, out err) != 0)
  1740. {
  1741. error = $"更新目录信息失败{err}";
  1742. iResult--;
  1743. }
  1744. err = "";
  1745. if (updateCellingPrice(jo, out err) != 0)
  1746. {
  1747. error = $"{error};更新限价信息失败{err}";
  1748. iResult--;
  1749. }
  1750. return iResult;
  1751. }
  1752. private void tsmUpdateLevelTypeOfAllMappedData_Click(object sender, EventArgs e)
  1753. {
  1754. updateMappedInsuInfo(updateAuxInfoWrapper);
  1755. }
  1756. private void tsmSingleUpdateInsuInfo_Click(object sender, EventArgs e)
  1757. {
  1758. if ((dgvHISDirectory.CurrentRow == null) || (rbMaped.Checked != true))
  1759. {
  1760. MessageBox.Show("请查询HIS目录对照关系,注意选择已对照!");
  1761. return;
  1762. }
  1763. int iMapped = dgvHISDirectory.CurrentRow.Index;
  1764. string insuCode = dgvHISDirectory.Rows[iMapped].Cells["insuCode"].Value.ToString();
  1765. if (string.IsNullOrEmpty(insuCode))
  1766. {
  1767. MessageBox.Show("未检测到对应的医保目录,请检查该目录是否已对照!");
  1768. return;
  1769. }
  1770. JObject jo = new JObject();
  1771. jo.Add("code", dgvHISDirectory.Rows[iMapped].Cells["insuCode"].Value.ToString());
  1772. jo.Add("HisType", rbgDirecType_C.SelectedIndex + 1);
  1773. string error;
  1774. if (updateAuxAndCellPrice(jo, out error) != 0)
  1775. {
  1776. MessageBox.Show($"更新失败{error}");
  1777. }
  1778. else
  1779. {
  1780. MessageBox.Show("更新成功!");
  1781. }
  1782. }
  1783. public string getDataRowValue(DataRow dr,string columnName)
  1784. {
  1785. if (!dr.Table.Columns.Contains(columnName))
  1786. {
  1787. return "";
  1788. }
  1789. else
  1790. {
  1791. return dr[columnName].ToString();
  1792. }
  1793. }
  1794. //更新目录信息(附属信息)
  1795. private int updateAuxInfo(JObject jo, out string err)
  1796. {
  1797. err = "";
  1798. tbDirectoryCode.Text = JsonHelper.getDestValue(jo, "code");
  1799. string funNo; 
  1800. dynamic joData = GetInput(15, out funNo);
  1801. JObject joRtn = cBus.InvokeMedicalInsuranceInquiry(funNo, joData);
  1802. if (joRtn["infcode"].ToString() == "0")
  1803. {
  1804. DataTable dtAuxInfo = (DataTable)joRtn["output"]["data"].ToObject(typeof(DataTable));
  1805. DateTime dtToday = DateTime.Today;
  1806. string chrgitm_lv = "";
  1807. string begndate = "";
  1808. string enddate = "";
  1809. string list_type = "";
  1810. string med_chrgitm_type = "";
  1811. int iAdpater = 0;
  1812. foreach (DataRow dr in dtAuxInfo.Rows)
  1813. {
  1814. DateTime dtBegin = getDataRowValue(dr,"begndate") == "" ? Convert.ToDateTime("2000-01-01 00:00:00") : Convert.ToDateTime(getDataRowValue(dr,"begndate"));
  1815. DateTime dtEnd = getDataRowValue(dr,"enddate") == "" ? Convert.ToDateTime("2099-01-01 00:00:00") : Convert.ToDateTime(getDataRowValue(dr,"enddate"));
  1816. if ((dtBegin < dtToday) && (dtToday < dtEnd))
  1817. {
  1818. iAdpater++;
  1819. chrgitm_lv = dr["chrgitm_lv"].ToString();
  1820. begndate = dtBegin.ToString("yyyy-MM-dd HH:mm:ss");
  1821. enddate = dtEnd.ToString("yyyy-MM-dd HH:mm:ss");
  1822. list_type = dr["list_type"].ToString();
  1823. med_chrgitm_type = dr["med_chrgitm_type"].ToString();
  1824. }
  1825. }
  1826. //有且只能有一条数据符合
  1827. if (iAdpater == 1)
  1828. {
  1829. JObject joPamam = new JObject();
  1830. joPamam.Add("Code", JsonHelper.getDestValue(jo, "code"));
  1831. joPamam.Add("HisType", JsonHelper.getDestValue(jo, "HisType"));
  1832. joPamam.Add("StartDate", begndate);
  1833. joPamam.Add("EndDate", enddate);
  1834. joPamam.Add("ChargeItemLevel", chrgitm_lv);
  1835. joPamam.Add("ListType", list_type);
  1836. joPamam.Add("ChargeItemType", med_chrgitm_type);
  1837. JObject joUpdateRtn = mIS.UpdateDirectoryBySelf(joPamam);
  1838. string error = "";
  1839. if (JsonHelper.parseIrisRtnValue(joUpdateRtn, out error) != 0)
  1840. {
  1841. err = "修改失败:" + error;
  1842. return -1;
  1843. }
  1844. else
  1845. {
  1846. err = "修改成功";
  1847. return 0;
  1848. }
  1849. }
  1850. else
  1851. {
  1852. err = "中心返回符合条数的记录不唯一或者为空,请检查!";
  1853. return -1;
  1854. }
  1855. }
  1856. else
  1857. {
  1858. err = "查询中心数据出错,请检查!";
  1859. return -1;
  1860. }
  1861. }
  1862. //更新目录信息(附属信息)
  1863. private int updateCellingPrice(JObject jo, out string err)
  1864. {
  1865. err = "";
  1866. tbDirectoryCode.Text = JsonHelper.getDestValue(jo, "code");
  1867. string funNO;
  1868. dynamic joData = GetInput(18, out funNO);
  1869. JObject joRtn = cBus.InvokeMedicalInsuranceInquiry(funNO, joData);
  1870. if (joRtn["infcode"].ToString() == "0")
  1871. {
  1872. DataTable dtAuxInfo = (DataTable)joRtn["output"]["data"].ToObject(typeof(DataTable));
  1873. DateTime dtToday = DateTime.Today;
  1874. string cellingPrice = "";
  1875. string begndate = "";
  1876. string enddate = "";
  1877. int iAdpater = 0;
  1878. foreach (DataRow dr in dtAuxInfo.Rows)
  1879. {
  1880. DateTime dtBegin = getDataRowValue(dr, "begndate") == "" ? Convert.ToDateTime("2000-01-01 00:00:00") : Convert.ToDateTime(getDataRowValue(dr, "begndate"));
  1881. DateTime dtEnd = getDataRowValue(dr, "enddate") == "" ? Convert.ToDateTime("2099-01-01 00:00:00") : Convert.ToDateTime(getDataRowValue(dr, "enddate"));
  1882. if ((dtBegin < dtToday) && (dtToday < dtEnd))
  1883. {
  1884. iAdpater++;
  1885. cellingPrice = dr["hilist_pric_uplmt_amt"].ToString();
  1886. begndate = dtBegin.ToString("yyyy-MM-dd HH:mm:ss");
  1887. enddate = dtEnd.ToString("yyyy-MM-dd HH:mm:ss");
  1888. }
  1889. }
  1890. //有且只能有一条数据符合
  1891. if (iAdpater == 1)
  1892. {
  1893. JObject joPamam = new JObject();
  1894. joPamam.Add("Code", JsonHelper.getDestValue(jo, "code"));
  1895. joPamam.Add("HisType", JsonHelper.getDestValue(jo, "HisType"));
  1896. joPamam.Add("StartDate", begndate);
  1897. joPamam.Add("EndDate", enddate);
  1898. joPamam.Add("CeilingPrice", cellingPrice);
  1899. JObject joUpdateRtn = mIS.UpdateDirectoryBySelf(joPamam);
  1900. string error = "";
  1901. if (JsonHelper.parseIrisRtnValue(joUpdateRtn, out error) != 0)
  1902. {
  1903. err = "修改失败:" + error;
  1904. return -1;
  1905. }
  1906. else
  1907. {
  1908. err = "修改成功";
  1909. return 0;
  1910. }
  1911. }
  1912. else
  1913. {
  1914. err = "中心返回符合条数的记录不唯一或者为空,请检查!";
  1915. return -1;
  1916. }
  1917. }
  1918. else
  1919. {
  1920. err = "查询中心数据出错,请检查!";
  1921. return -1;
  1922. }
  1923. }
  1924. private void btTripMenu_Click(object sender, EventArgs e)
  1925. {
  1926. uiContextMenuStrip1.Show(((Sunny.UI.UIButton)sender), new Point(0, btTripMenu.Height));
  1927. }
  1928. private void tsmiUpdateCellingPrice_Click(object sender, EventArgs e)
  1929. {
  1930. string error;
  1931. int iDir = dgvDirectoy.CurrentRow.Index;
  1932. if (dgvDirectoy.CurrentRow == null)
  1933. {
  1934. MessageBox.Show("请查询中心目录");
  1935. return;
  1936. }
  1937. JObject jo = new JObject();
  1938. jo.Add("code", dgvDirectoy.Rows[iDir].Cells["code"].Value.ToString());
  1939. jo.Add("HisType", rbgDirecType.SelectedIndex + 1);
  1940. if (updateCellingPrice(jo, out error) != 0)
  1941. {
  1942. MessageBox.Show(error);
  1943. }
  1944. else
  1945. {
  1946. MessageBox.Show(error);
  1947. }
  1948. }
  1949. private void tsmiSingleUpdateAuxInfo_Click(object sender, EventArgs e)
  1950. {
  1951. string error;
  1952. int iDir = dgvDirectoy.CurrentRow.Index;
  1953. if (dgvDirectoy.CurrentRow == null)
  1954. {
  1955. MessageBox.Show("请查询中心目录");
  1956. return;
  1957. }
  1958. JObject jo = new JObject();
  1959. jo.Add("code", dgvDirectoy.Rows[iDir].Cells["code"].Value.ToString());
  1960. jo.Add("HisType", rbgDirecType.SelectedIndex + 1);
  1961. if (updateAuxInfo(jo, out error) != 0)
  1962. {
  1963. MessageBox.Show(error);
  1964. }
  1965. else
  1966. {
  1967. MessageBox.Show(error);
  1968. }
  1969. }
  1970. }
  1971. public class OutParamWrapper
  1972. {
  1973. public string Value { get; set; }
  1974. }
  1975. }