BasicData.cs 84 KB

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