BasicData.cs 87 KB

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