BasicData.cs 88 KB

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