BasicData.cs 86 KB

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