BasicData.cs 118 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017
  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. using OfficeOpenXml;
  19. namespace PTMedicalInsurance.Forms
  20. {
  21. public partial class BasicData : Form
  22. {
  23. //设置实例
  24. CenterBusiness cBus = new CenterBusiness();
  25. HisMainBusiness hBus = new HisMainBusiness();
  26. HisIrisServices hIS = new HisIrisServices();
  27. MIIrisServices mIS = new MIIrisServices();
  28. InvokeHelper invoker = new InvokeHelper();
  29. InsuServices Iis = new InsuServices();
  30. //1.声明自适应类实例
  31. AutoResizeForm asc = new AutoResizeForm();
  32. public JObject joSelectedInsuInfo;
  33. public int insuInfoIndex = 0;
  34. public int idInfoIndex = 0;
  35. int iTotalCount = 0;
  36. int currentPageIndex = 0;
  37. private Func<JObject, OutParamWrapper, int> action;
  38. private DataTable dtAllMapped;
  39. DataTable dtExport;
  40. public BasicData()
  41. {
  42. InitializeComponent();
  43. rbgDirecType.SelectedIndex = 0;
  44. rbgDirecType_C.SelectedIndex = 0;
  45. rbSingleDown.Checked = true;
  46. rbOnlyName.Checked = true;
  47. this.rbgDirecType.ValueChanged += new Sunny.UI.UIRadioButtonGroup.OnValueChanged(this.rbgDirecType_ValueChanged);
  48. this.pgDownload.PageChanged += new Sunny.UI.UIPagination.OnPageChangeEventHandler(this.pgDownload_PageChanged);
  49. this.pgCenterDirect.PageChanged += new Sunny.UI.UIPagination.OnPageChangeEventHandler(this.pgCenterDirect_PageChanged);
  50. Font rowFont = new Font("UTF-8", 8);
  51. Font columnFont = new Font("UTF-8", 9);
  52. rbgDirecType.SelectedIndex = 8;
  53. rbAll.Checked = true;
  54. //tabControl1.SelectedIndex = 1;
  55. //this.StartPosition = FormStartPosition.CenterParent;
  56. asc.controllInitializeSize(this);
  57. asc.controlAutoSize(this);
  58. TextCbd.Text = Global.inf.areaCode;
  59. //查询区域通用目录
  60. MIIrisServices mIS = new MIIrisServices();
  61. JObject joRtnTY = mIS.getInterface_TY(Global.inf.interfaceDr.ToString(), "");
  62. Global.inf.InsuCurrencyCataLogue = JsonHelper.getDestValue(joRtnTY, "InsuCurrencyCataLogue"); //通用目录编码 6
  63. Global.inf.hospitalDr_TY = JsonHelper.getDestValue(joRtnTY, "HospitalDr_TY"); //通用目录所属医院ID
  64. }
  65. #region 函数封装
  66. private void queryInsuDirectory(int currentPage, int pageSize, int directoryType, int interfaceDr, string code)
  67. {
  68. try
  69. {
  70. string dirCode = "";
  71. string dirName = "";
  72. string approvalNO = "";
  73. string DosageForm = "";
  74. string Specifications = "";
  75. string manufacturers = "";
  76. Sunny.UI.UIDataGridView dgv;
  77. Sunny.UI.UIPagination pg;
  78. if (tabControl1.SelectedIndex == 0)
  79. {
  80. dirCode = tbDirectoryCode.Text;
  81. dirName = tbDircetoryName.Text;
  82. approvalNO = "";
  83. dgv = dgvDirectoy;
  84. pg = pgDownload;
  85. }
  86. else
  87. {
  88. dirName = tbCenterDirectoryFilter.Text;
  89. dirCode = tbInsuCode.Text;
  90. dgv = dgvCenterDirectory;
  91. approvalNO = tbApprovalNO.Text;
  92. pg = pgCenterDirect;
  93. manufacturers = tbManufacturer.Text;
  94. DosageForm = tbDosageForm.Text;
  95. Specifications = tbSpecifications.Text;
  96. }
  97. JObject joInput = new JObject {
  98. { "currentPage" , currentPage },
  99. { "pageSize" , pageSize },
  100. { "serviceCode" , code },
  101. { "directoryType" , directoryType },
  102. { "directoryCode" , dirCode },
  103. { "directoryName" , dirName },
  104. { "approvalNO" , approvalNO },
  105. { "dosageForm" , DosageForm },
  106. { "specifications" , Specifications },
  107. { "manufacturers" , manufacturers },
  108. { "directoryDr" , interfaceDr }
  109. };
  110. JObject joRtn = mIS.getMIDirectoryByPagination(joInput);
  111. if (joRtn["errorCode"].ToString() != "0")
  112. {
  113. MessageBox.Show("IRIS数据返回错误:" + joRtn["errorMessage"].ToString());
  114. return;
  115. }
  116. if (joRtn["result"]["rows"] == null)
  117. {
  118. MessageBox.Show("该节点不存在");
  119. return;
  120. }
  121. if (joRtn["result"]["total"].ToString() == "0")
  122. {
  123. MessageBox.Show("未查询到数据");
  124. dgv.DataSource = null;
  125. return;
  126. }
  127. DataTable dt = (DataTable)joRtn["result"]["rows"].ToObject(typeof(DataTable));
  128. int totalCount = int.Parse(joRtn["result"]["total"].ToString());
  129. pg.TotalCount = totalCount;
  130. pg.PageSize = pageSize;
  131. dgv.DataSource = dt;
  132. dgv.Columns[0].ReadOnly = true;
  133. }
  134. catch (Exception ex)
  135. {
  136. MessageBox.Show("查询异常:" + ex.Message);
  137. }
  138. }
  139. private void setHeaderTxt(int directoryType, Sunny.UI.UIDataGridView dgv)
  140. {
  141. GridViewSetter gvdSetter = new GridViewSetter();
  142. switch (directoryType)
  143. {
  144. case 0://药品
  145. {
  146. gvdSetter.SetHeaderTextOfDrug(dgv);
  147. break;
  148. }
  149. case 1://诊疗
  150. {
  151. gvdSetter.SetHeaderTextOfMedicalService(dgv);
  152. break;
  153. }
  154. case 2://材料
  155. {
  156. gvdSetter.SetHeaderTextOfMaterials(dgv);
  157. break;
  158. }
  159. case 3://疾病诊断
  160. {
  161. gvdSetter.SetHeaderTextOfDiagnose(dgv);
  162. break;
  163. }
  164. case 4://手术
  165. {
  166. gvdSetter.SetHeaderTextOfDiagnose(dgv);
  167. break;
  168. }
  169. case 5://慢性病
  170. {
  171. gvdSetter.SetHeaderTextOfDiagnose(dgv);
  172. break;
  173. }
  174. case 6://DRGs
  175. {
  176. gvdSetter.SetHeaderTextOfDiagnose(dgv);
  177. break; ;
  178. }
  179. case 7://日间手术
  180. {
  181. gvdSetter.SetHeaderTextOfDiagnose(dgv);
  182. break; ;
  183. }
  184. case 8://字典表
  185. {
  186. gvdSetter.SetHeaderTextOfDictionary(dgv);
  187. break;
  188. }
  189. case 9://中药饮片下载
  190. {
  191. gvdSetter.SetHeaderTextOfChineseMedicine(dgv);
  192. break;
  193. }
  194. case 10://医药机构制剂目录下载
  195. {
  196. gvdSetter.SetHeaderTextOfPreparation(dgv);
  197. break;
  198. }
  199. case 11://肿瘤形态学下载
  200. {
  201. gvdSetter.SetHeaderTextOfTumorMorphology(dgv);
  202. break;
  203. }
  204. case 12:
  205. {
  206. //中医疾病下载
  207. gvdSetter.GetChineseDiagnoseJsonByTxt(dgv);
  208. // ICPC3
  209. //gvdSetter.SetICPCAdmReasonHeader(dgv);
  210. break;
  211. }
  212. case 13:
  213. {
  214. //中医证候下载
  215. gvdSetter.GetTCMSyndromeJsonByTxt(dgv);
  216. // ICPC3
  217. //gvdSetter.SetICPCTreatmentHeader(dgv);
  218. break;
  219. }
  220. case 14://民族药品
  221. {
  222. gvdSetter.GetEthnicMedicineJsonByTxt(dgv);
  223. break;
  224. }
  225. case 15://目录信息查询
  226. {
  227. gvdSetter.GetMedInsuCatalogJsonByTxt(dgv);
  228. break;
  229. }
  230. case 16://医疗与医保目录匹配关系查询
  231. {
  232. gvdSetter.GetMedInsuCorrespondencJsonByTxt(dgv);
  233. break;
  234. }
  235. case 17://医药机构目录匹配查询
  236. {
  237. gvdSetter.GetMedInstCorrespondencJsonByTxt(dgv);
  238. break;
  239. }
  240. case 18://医保目录限价查询
  241. {
  242. gvdSetter.GetMedInsuFixedPriceJsonByTxt(dgv);
  243. break;
  244. }
  245. case 19://医保目录先自付比例下载
  246. {
  247. gvdSetter.GetMedInsuFirstPayProportionJsonByTxt(dgv);
  248. break;
  249. }
  250. case 20://医药机构信息
  251. {
  252. gvdSetter.GetMedicalInstitutionJsonByTxt(dgv);
  253. break;
  254. }
  255. }
  256. gvdSetter.DatagridviewColumnWidthAdaptation(dgv);
  257. }
  258. private void queryHISInsuDirectory(int directoryType, int pageIndex, int count, Sunny.UI.UIDataGridView dgv, int interfaceDr)
  259. {
  260. string code = "09010042";
  261. if (tabControl1.SelectedIndex == 0)
  262. {
  263. if (rbgDirecType.SelectedIndex == 20)
  264. {
  265. code = "090100XX";
  266. }
  267. else if (rbgDirecType.SelectedIndex == 8)
  268. {
  269. code = "09010043";
  270. }
  271. else
  272. {
  273. code = "09010042";
  274. }
  275. if (rbgDirecType.SelectedIndex <= 13)
  276. {
  277. queryInsuDirectory(pageIndex, count, directoryType + 1, interfaceDr, code);
  278. setHeaderTxt(directoryType, dgv);
  279. }
  280. else //几个医保查询该部分数据不存数据库只是临时查询(除医疗机构信息查询外)
  281. {
  282. //生成DataView列
  283. //setHeaderTxt(directoryType, dgv);
  284. string pages, recordCounts, errorMessage, sOutpar;
  285. dynamic joData = GetInput(rbgDirecType.SelectedIndex, out TradeEnum trade);
  286. JObject joRtn = cBus.InvokeMedicalInsuranceInquiry(trade, joData);
  287. if (joRtn["infcode"].ToString() == "0")
  288. {
  289. try
  290. {
  291. Sunny.UI.UIPagination pg;
  292. dgv = dgvDirectoy;
  293. pg = pgDownload;
  294. DataTable dt;
  295. if (rbgDirecType.SelectedIndex == 20)
  296. {
  297. dt = (DataTable)joRtn["output"]["medinsinfo"].ToObject(typeof(DataTable));
  298. if (joRtn["output"]["medinsinfo"].ToString() == "")
  299. {
  300. MessageBox.Show("查询成功,但返回结果集为空!");
  301. //return;
  302. }
  303. pg.TotalCount = 50;
  304. pg.PageSize = 50;
  305. }
  306. else
  307. {
  308. pages = joRtn["output"]["pages"].ToString(); //页数
  309. recordCounts = joRtn["output"]["recordCounts"].ToString(); //总记录条数
  310. dt = (DataTable)joRtn["output"]["data"].ToObject(typeof(DataTable));
  311. if (recordCounts == "0")
  312. {
  313. MessageBox.Show("查询成功,但返回结果集为空!");
  314. //return;
  315. }
  316. pg.TotalCount = int.Parse(recordCounts);
  317. pg.PageSize = int.Parse(TexBYSJL.Text); //int.Parse(pages);
  318. }
  319. dgv.DataSource = dt;
  320. dgv.Columns[0].ReadOnly = true;
  321. }
  322. catch (Exception ex)
  323. {
  324. MessageBox.Show("查询异常:" + ex.Message);
  325. }
  326. }
  327. else
  328. {
  329. errorMessage = "调用交易" + trade.GetCode() + "出现错误,请查看日志!"; //joImportRtn["errorMessage"].ToString();
  330. MessageBox.Show(errorMessage);
  331. return;
  332. }
  333. }
  334. }
  335. else
  336. {
  337. queryInsuDirectory(pageIndex, count, directoryType + 1, interfaceDr, code);
  338. setHeaderTxt(directoryType, dgv);
  339. }
  340. GridViewSetter gridSetter = new GridViewSetter();
  341. gridSetter.DatagridviewColumnWidthAdaptation(dgvCenterDirectory);
  342. }
  343. private int queryHISDirectory(int currentPage, int pageSize, out string errMsg)
  344. {
  345. errMsg = "";
  346. string directoryType = string.Empty;
  347. switch (rbgDirecType_C.SelectedIndex)
  348. {
  349. case 0:
  350. {
  351. directoryType = "drugs";
  352. break;
  353. }
  354. case 1:
  355. {
  356. directoryType = "diagnosi";
  357. break;
  358. }
  359. case 2:
  360. {
  361. directoryType = "consumables";
  362. break;
  363. }
  364. }
  365. JObject joHISRtn = new JObject();
  366. JObject joRtn = new JObject();
  367. InvokeHelper invoker = new InvokeHelper();
  368. string flag = "";
  369. //全部是先调HIS,然后再匹配医保平台的对照关系
  370. if (rbAll.Checked)
  371. {
  372. JArray jaPagination = new JArray();
  373. JArray jaParams = new JArray();
  374. flag = "All";
  375. dynamic joParam = new JObject();
  376. joParam.code = "";
  377. joParam.descripts = "";
  378. joParam.FindType = new JArray();
  379. joParam.TypeID = "";
  380. joParam.alias = tbHISDirectoryFilter.Text;
  381. joParam.include = "Hosp";
  382. joParam.groupID = "324";
  383. joParam.hospID = Global.inf.hisHospitalDr;
  384. joParam.interfaceDr = Global.inf.interfaceDr;
  385. joParam.type = directoryType;
  386. joParam.flag = flag;
  387. joParam.specInput = txtSpecFilter.Text.Trim();
  388. jaParams.Add(joParam);
  389. dynamic joPagination = new JObject();
  390. joPagination.pageSize = pageSize;
  391. //joPagination.pageSize = 2;
  392. joPagination.currentPage = currentPage;
  393. joPagination.sortColumn = "Code";
  394. joPagination.sortOrder = "asc";
  395. jaPagination.Add(joPagination);
  396. //该服务需要改写,需要跟(CloudMedicalInsurancePlatform.Tables.MapRelation)进行关联
  397. //joInParams.code = "09010038";
  398. if (hIS.getHISDir(jaPagination, jaParams, out joHISRtn, out errMsg) != 0)
  399. {
  400. return -1;
  401. }
  402. joRtn = mIS.ConvertHISDir(joHISRtn);
  403. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  404. {
  405. return -1;
  406. }
  407. }
  408. //已对照是先调云医保,然后再匹配HIS
  409. if (rbMaped.Checked)
  410. {
  411. JArray jaPagination = new JArray();
  412. JArray jaParams = new JArray();
  413. flag = "Maped";
  414. dynamic joParam = new JObject();
  415. joParam.alias = tbHISDirectoryFilter.Text;
  416. joParam.HospitalDr = Global.inf.hospitalDr;
  417. joParam.InterfaceDr = Global.inf.interfaceDr;
  418. joParam.hisType = directoryType;
  419. jaParams.Add(joParam);
  420. dynamic joPagination = new JObject();
  421. joPagination.pageSize = pageSize;
  422. joPagination.currentPage = currentPage;
  423. joPagination.sortColumn = "HisCode";
  424. joPagination.sortOrder = "asc";
  425. jaPagination.Add(joPagination);
  426. JObject joMIRtn = mIS.GetMappedHISDir(jaPagination, jaParams);
  427. if (JsonHelper.parseIrisRtnValue(joMIRtn, out errMsg) != 0)
  428. {
  429. return -1;
  430. }
  431. //传给HIS,进行匹配
  432. joParam = new JObject();
  433. joParam.TotalCount = joMIRtn["result"]["TotalCount"];
  434. joParam.type = directoryType;
  435. joParam.flag = flag;
  436. joParam.hospID = Global.inf.hisHospitalDr;
  437. joParam.interfaceDr = Global.inf.interfaceDr;
  438. joParam.alias = tbHISDirectoryFilter.Text;
  439. joParam.include = "Hosp";
  440. joParam.groupID = "324";
  441. joParam.compareArr = joMIRtn["result"]["Data"];
  442. jaParams = new JArray();
  443. jaParams.Add(joParam);
  444. if (hIS.getHISDir(jaPagination, jaParams, out joRtn, out errMsg) != 0)
  445. {
  446. return -1;
  447. }
  448. }
  449. //if (rbNoMaped.Checked) { flag = "NoMaped"; }
  450. if (rbNoMaped.Checked)
  451. {
  452. JArray jaPagination = new JArray();
  453. JArray jaParams = new JArray();
  454. flag = "All";
  455. dynamic joParam = new JObject();
  456. joParam.code = "";
  457. joParam.descripts = "";
  458. joParam.FindType = new JArray();
  459. joParam.TypeID = "";
  460. joParam.alias = tbHISDirectoryFilter.Text;
  461. joParam.include = "Hosp";
  462. joParam.groupID = "324";
  463. joParam.hospID = Global.inf.hisHospitalDr;
  464. joParam.interfaceDr = Global.inf.interfaceDr;
  465. joParam.type = directoryType;
  466. joParam.flag = flag;
  467. joParam.specInput = "";
  468. jaParams.Add(joParam);
  469. dynamic joPagination = new JObject();
  470. joPagination.pageSize = pageSize;
  471. //joPagination.pageSize = 2;
  472. joPagination.currentPage = currentPage;
  473. joPagination.sortColumn = "Code";
  474. joPagination.sortOrder = "asc";
  475. jaPagination.Add(joPagination);
  476. //1.获取全部HIS目录
  477. if (hIS.getHISDir(jaPagination, jaParams, out joHISRtn, out errMsg) != 0)
  478. {
  479. return -1;
  480. }
  481. joRtn = mIS.GetNoMappHISDir(joHISRtn);
  482. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  483. {
  484. return -1;
  485. }
  486. }
  487. DataTable dt = (DataTable)joRtn["result"]["Data"].ToObject(typeof(DataTable));
  488. dtExport = dt;
  489. int totalCount = int.Parse(joRtn["result"]["TotalCount"].ToString());
  490. pgHISDirect.TotalCount = totalCount;
  491. //if (rbNoMaped.Checked)
  492. // pgHISDirect.PageSize = pageSize;
  493. //else
  494. // pgHISDirect.PageSize = 50;
  495. pgHISDirect.PageSize = pageSize;
  496. dgvHISDirectory.DataSource = null;
  497. dgvHISDirectory.DataSource = dt;
  498. dgvHISDirectory.Columns[0].ReadOnly = true;
  499. GridViewSetter gridSetter = new GridViewSetter();
  500. gridSetter.SetHeaderTextOfMapping_HisDirectory(dgvHISDirectory);
  501. gridSetter.DatagridviewColumnWidthAdaptation(dgvHISDirectory);
  502. return 0;
  503. }
  504. private void queryCenterDirectory_09010012(int currentPage, int pageSize)
  505. {
  506. string directoryType = string.Empty;
  507. switch (rbgDirecType_C.SelectedIndex)
  508. {
  509. case 0:
  510. {
  511. directoryType = "drugs";
  512. break;
  513. }
  514. case 1:
  515. {
  516. directoryType = "diagnosi";
  517. break;
  518. }
  519. case 2:
  520. {
  521. directoryType = "consumables";
  522. break;
  523. }
  524. }
  525. dynamic joInParams = new JObject();
  526. joInParams.pagination = new JArray() as dynamic;
  527. joInParams.session = new JArray() as dynamic;
  528. JArray jaParams = new JArray();
  529. dynamic joParams = new JObject();
  530. joParams.code = "";
  531. joParams.descripts = "";
  532. joParams.FindType = new JArray();
  533. joParams.TypeID = "";
  534. joParams.alias = "";
  535. joParams.include = "Hosp";
  536. joParams.groupID = "324";
  537. joParams.hospID = "25";
  538. joParams.type = directoryType;
  539. joParams.specInput = "";
  540. jaParams.Add(joParams);
  541. joInParams.Add("params", JArray.FromObject(jaParams));
  542. dynamic joSession = new JObject();
  543. joSession.userID = "";
  544. joSession.locID = "";
  545. joSession.groupID = "";
  546. joSession.hospID = "";
  547. joSession.sessionID = "";
  548. joSession.hospCode = "";
  549. joSession.language = "";
  550. joSession.hostName = "";
  551. joSession.ipv4 = "";
  552. joSession.ipv6 = "";
  553. joSession.mac = "";
  554. joInParams.session.Add(joSession);
  555. dynamic joPagination = new JObject();
  556. joPagination.pageSize = pageSize;
  557. joPagination.currentPage = currentPage;
  558. joPagination.sortColumn = "Code";
  559. joPagination.sortOrder = "asc";
  560. joInParams.pagination.Add(joPagination);
  561. joInParams.code = "09010012";
  562. string sInput = joInParams.ToString();
  563. string sRtn = invoker.invokeInsuService(joInParams, "");
  564. JObject jsonRtn = JObject.Parse(sRtn);
  565. if (jsonRtn["result"]["Data"] == null)
  566. {
  567. MessageBox.Show("该节点不存在");
  568. return;
  569. }
  570. JObject joRtn = JObject.Parse(sRtn);
  571. DataTable dt = (DataTable)joRtn["result"]["Data"].ToObject(typeof(DataTable));
  572. int totalCount = int.Parse(joRtn["result"]["TotalCount"].ToString());
  573. pgCenterDirect.TotalCount = totalCount;
  574. pgCenterDirect.PageSize = 50;
  575. dgvCenterDirectory.DataSource = dt;
  576. }
  577. private void Mapping()
  578. {
  579. int iHis = dgvHISDirectory.CurrentRow.Index;
  580. if (dgvCenterDirectory.CurrentRow == null)
  581. {
  582. MessageBox.Show("请查询中心目录");
  583. return;
  584. }
  585. int iCenter = dgvCenterDirectory.CurrentRow.Index;
  586. DataTable dtHis = (DataTable)dgvHISDirectory.DataSource;
  587. DataTable dtCenter = (DataTable)dgvCenterDirectory.DataSource;
  588. dgvHISDirectory.Rows[iHis].Cells["insuCode"].Value = dgvCenterDirectory.Rows[iCenter].Cells["Code"].Value.ToString();
  589. dgvHISDirectory.Rows[iHis].Cells["insuName"].Value = dgvCenterDirectory.Rows[iCenter].Cells["Name"].Value.ToString();
  590. int hisType = rbgDirecType_C.SelectedIndex + 1;
  591. string hisTypeName = rbgDirecType_C.Items[hisType - 1].ToString(); ;
  592. JArray jaParams = new JArray();
  593. dynamic jsonTemp = new JObject();
  594. jsonTemp.ID = dtHis.Rows[iHis]["MapID"];
  595. jsonTemp.HospitalDr = Global.inf.hospitalDr;
  596. jsonTemp.updateUserID = Global.user.ID;
  597. jsonTemp.InterfaceDr = Global.inf.interfaceDr;
  598. jsonTemp.HISCode = dgvHISDirectory.Rows[iHis].Cells["itemCode"].Value;
  599. jsonTemp.HISName = dgvHISDirectory.Rows[iHis].Cells["itemDesc"].Value;
  600. jsonTemp.ChargeItemDr = dtHis.Rows[iHis]["ID"];
  601. jsonTemp.DiretoryDr = dtCenter.Rows[iCenter]["medInsuDirectoryID"];
  602. //1.已对照 2.已对照但未上传 3 已对照且已上传
  603. jsonTemp.State = 1;
  604. jsonTemp.HisType = hisType;
  605. jsonTemp.HisTypeName = hisTypeName;
  606. jsonTemp.InsuCode = dgvCenterDirectory.Rows[dgvCenterDirectory.CurrentRow.Index].Cells["Code"].Value;
  607. jsonTemp.InsuName = dgvCenterDirectory.Rows[dgvCenterDirectory.CurrentRow.Index].Cells["Name"].Value;
  608. jsonTemp.UpdateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  609. jaParams.Add(jsonTemp);
  610. JObject joIn = new JObject();
  611. joIn.Add(new JProperty("params", jaParams));
  612. joIn.Add("code", "09010040");
  613. InvokeHelper invoker = new InvokeHelper();
  614. JObject joRtn = invoker.invokeInsuService(joIn.ToString(), "插入对照信息");
  615. //JObject joRtn = JObject.Parse(irisRtn);
  616. if ((int)joRtn["errorCode"] == 0)
  617. {
  618. dgvHISDirectory.Rows[iHis].Cells["flag"].Value = "已对照";
  619. }
  620. else
  621. {
  622. dgvHISDirectory.Rows[iHis].Cells["flag"].Value = "对照失败";
  623. }
  624. }
  625. private void CancleMapping()
  626. {
  627. int iHis = dgvHISDirectory.CurrentRow.Index;
  628. DataTable dtHis = (DataTable)dgvHISDirectory.DataSource;
  629. JArray jaParams = new JArray();
  630. dynamic jsonTemp = new JObject();
  631. jsonTemp.ID = dtHis.Rows[iHis]["MapID"];
  632. jsonTemp.HospitalDr = Global.inf.hospitalDr;
  633. jsonTemp.updateUserID = Global.user.ID;
  634. jsonTemp.InterfaceDr = Global.inf.interfaceDr;
  635. jsonTemp.HISCode = dgvHISDirectory.Rows[iHis].Cells["itemCode"].Value;
  636. jsonTemp.UpdateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  637. jaParams.Add(jsonTemp);
  638. JObject joIn = new JObject();
  639. joIn.Add(new JProperty("params", jaParams));
  640. joIn.Add("code", "09010041");
  641. InvokeHelper invoker = new InvokeHelper();
  642. JObject joRtn = invoker.invokeInsuService(joIn.ToString(), "取消对照");
  643. if ((int)joRtn["errorCode"] == 0)
  644. {
  645. dgvHISDirectory.Rows[iHis].Cells["insuCode"].Value = "";
  646. dgvHISDirectory.Rows[iHis].Cells["insuName"].Value = "";
  647. dgvHISDirectory.Rows[iHis].Cells["flag"].Value = "";
  648. }
  649. else
  650. {
  651. dgvHISDirectory.Rows[iHis].Cells["flag"].Value = "取消失败";
  652. }
  653. }
  654. public void loadTextDebug()
  655. {
  656. DataImoport bus = new DataImoport();
  657. string txtPath = @"E:\insu\Demo\bin\Debug\20230101535395327567680436.txt";
  658. JObject joImportRtn = bus.importDataToIrisByTxt(txtPath, 50, 2, uiProcessBar1);
  659. }
  660. /// <summary>
  661. /// 医保目录单个版本号的下载
  662. /// </summary>
  663. /// <param name="ver"></param>
  664. /// <param name="directoryType"></param>
  665. /// <param name="uiProcessBar"></param>
  666. /// <param name="errorMessage"></param>
  667. /// <returns></returns>
  668. public int downloadDicionary(JObject joData, Sunny.UI.UIProcessBar uiProcessBar, string dictCode,out string errorMessage)
  669. {
  670. errorMessage = "";
  671. int iResult = -1;
  672. try
  673. {
  674. JObject joRtn = cBus.DownDictionay(joData);
  675. if (JsonHelper.parseCenterRtnValue(joRtn, out errorMessage) == 0)
  676. {
  677. DataImoport DI = new DataImoport();
  678. JArray jaList = JArray.Parse(JsonHelper.getDestValue(joRtn, "output.list"));
  679. JObject joImportRtn = DI.importDictionary(uiProcessBar, jaList, dictCode);
  680. if (JsonHelper.parseIrisRtnValue(joImportRtn, out errorMessage) == 0)
  681. {
  682. iResult = 0;
  683. }
  684. else
  685. {
  686. errorMessage = "导入数据出现错误,请查看日志!" + errorMessage;
  687. }
  688. }
  689. return iResult;
  690. }
  691. catch (Exception ex)
  692. {
  693. errorMessage = "downloadDicionary提示:" + ex.Message;
  694. return -1;
  695. }
  696. }
  697. #endregion
  698. private void Form1_Load(object sender, EventArgs e)
  699. {
  700. this.WindowState = FormWindowState.Maximized;
  701. rbgDirecType.ValueChanged += new Sunny.UI.UIRadioButtonGroup.OnValueChanged(rbgDirecType_ValueChanged);
  702. LabExplain.Visible = false;
  703. }
  704. private void btnDownload_Click(object sender, EventArgs e)
  705. {
  706. string errorMessage = string.Empty;
  707. string ver = tbVer.Text;
  708. JObject input = new JObject();
  709. input["ver"] = ver;
  710. // 目录查询
  711. switch(rbgDirecType.SelectedIndex)
  712. {
  713. case 15:
  714. break;
  715. case 8: //字典
  716. {
  717. if (tbDicDate.Text == "")
  718. {
  719. MessageBox.Show("请输入查询日期!");
  720. return;
  721. }
  722. // 支持批量
  723. string[] dictText = tbDicType.Text.Trim().Split(",".ToCharArray());
  724. dictText.ToList().ForEach((dict) =>
  725. {
  726. this.downloadDict(dict);
  727. });
  728. break;
  729. }
  730. //case 12:
  731. // {
  732. // downloadMedData(TradeEnum.ICPC3AdmReason, ver, uiProcessBar1);
  733. // break;
  734. // }
  735. //case 13:
  736. // {
  737. // downloadMedData(TradeEnum.ICPC3Treatment, ver, uiProcessBar1);
  738. // break;
  739. // }
  740. default:
  741. {
  742. MedDirDownloadProcess mp = new MedDirDownloadProcess();
  743. if (rbSingleDown.Checked)
  744. {
  745. if (mp.SingleDownload(ver, rbgDirecType.SelectedIndex, uiProcessBar1, out errorMessage) != 0)
  746. {
  747. MessageBox.Show("医保目录下载失败:" + errorMessage);
  748. return;
  749. }
  750. }
  751. if (rbAutoDown.Checked)
  752. {
  753. mp.VerChangeEvent += Mp_VerChangeEvent;
  754. if (mp.AutoDownload(rbgDirecType.SelectedIndex, uiProcessBar1, out errorMessage) != 0)
  755. {
  756. MessageBox.Show("医保目录下载失败:" + errorMessage);
  757. return;
  758. }
  759. }
  760. break;
  761. }
  762. }
  763. btnQuery_Click(sender, e);
  764. }
  765. private void Mp_VerChangeEvent(object sender, string ver)
  766. {
  767. tbVer.Text = ver;
  768. }
  769. private void downloadDict(string dictCode)
  770. {
  771. try
  772. {
  773. string errorMessage = "";
  774. dynamic joData = new JObject();
  775. joData.type = dictCode; //字典类型
  776. joData.parentValue = ""; //父字典键值
  777. joData.admdvs = Global.inf.areaCode; //行政区划 就医地
  778. joData.date = tbDicDate.Text; //查询日期
  779. joData.vali_flag = "1"; //有效标志
  780. if (downloadDicionary(joData, uiProcessBar1,dictCode, out errorMessage) != 0)
  781. {
  782. MessageBox.Show("医保字典下载失败:" + errorMessage);
  783. }
  784. }
  785. catch (Exception e)
  786. {
  787. }
  788. }
  789. private int downloadMedData(TradeEnum trade,string version,Sunny.UI.UIProcessBar uiProcessBar)
  790. {
  791. string errorMessage = "";
  792. if (rbAutoDown.Checked)
  793. {
  794. JObject joMaxVerNO = mIS.getDirectoryMaxVersionNO(rbgDirecType.SelectedIndex);
  795. string ver = joMaxVerNO["result"]["MaxVersionNO"].ToString();
  796. if (!string.IsNullOrEmpty(ver))
  797. {
  798. version = ver;
  799. tbVer.Text = ver;
  800. }
  801. }
  802. JObject joRtn = cBus.DownDirecotry(trade, version);
  803. if (JsonHelper.parseCenterRtnValue(joRtn, out errorMessage) == 0)
  804. {
  805. //解析
  806. DataImoport DI = new DataImoport();
  807. JObject joImportRtn = DI.importMedDataToIris(trade,joRtn,uiProcessBar);
  808. if (JsonHelper.parseIrisRtnValue(joImportRtn, out errorMessage) == 0)
  809. {
  810. //递归调用
  811. if (rbAutoDown.Checked)
  812. {
  813. downloadMedData(trade, version, uiProcessBar);
  814. }
  815. }
  816. return 0;
  817. }
  818. MessageBox.Show(errorMessage);
  819. return -1;
  820. }
  821. private void btnQuery_Click(object sender, EventArgs e)
  822. {
  823. #region 校验查询条件
  824. if ((rbgDirecType.SelectedIndex < 0) || (rbgDirecType.SelectedIndex > 20))
  825. {
  826. MessageBox.Show("请先选择查询类型!");
  827. return;
  828. }
  829. if (rbgDirecType.SelectedIndex > 13)
  830. {
  831. if (rbgDirecType.SelectedIndex != 20)
  832. {
  833. if ((TexDate.Text == "") || (TexDate.Text == "输入日期 2021-01-01"))
  834. {
  835. MessageBox.Show("查询条件-请输入查询日期!");
  836. return;
  837. }
  838. if ((TexDQYS.Text == "") || (TexDQYS.Text == "当前页数"))
  839. {
  840. MessageBox.Show("查询条件-请输入当前页数!");
  841. return;
  842. }
  843. if ((TexBYSJL.Text == "") || (TexBYSJL.Text == "本页数据量"))
  844. {
  845. MessageBox.Show("查询条件-请输入本页数据量!");
  846. return;
  847. }
  848. }
  849. else
  850. {
  851. if ((TexYYMC.Text == "") || (TexYYMC.Text == "输入医院名称模糊查找"))
  852. {
  853. MessageBox.Show("查询条件-请输入医院名称模糊查找!");
  854. return;
  855. }
  856. }
  857. }
  858. #endregion
  859. queryHISInsuDirectory(rbgDirecType.SelectedIndex, 1, 20, dgvDirectoy, Global.inf.interfaceDr);
  860. }
  861. private void btnQueryHISDirectory_Click(object sender, EventArgs e)
  862. {
  863. this.dgvHISDirectory.SelectionChanged -= this.dgvHISDirectory_SelectionChanged;
  864. int iCount = 50;
  865. if (rbNoMaped.Checked)
  866. {
  867. iCount = 300;
  868. }
  869. string errMsg;
  870. if (queryHISDirectory(1, iCount, out errMsg) != 0)
  871. {
  872. MessageBox.Show(errMsg);
  873. return;
  874. }
  875. this.dgvHISDirectory.SelectionChanged += this.dgvHISDirectory_SelectionChanged;
  876. }
  877. private void btnQueryCenterDirectory_Click(object sender, EventArgs e)
  878. {
  879. if ((tbCenterDirectoryFilter.Text == "") && (tbInsuCode.Text == "") && (tbApprovalNO.Text == "") &&
  880. (tbManufacturer.Text == "") && (tbSpecifications.Text == "") && (tbDosageForm.Text == ""))
  881. {
  882. return;
  883. }
  884. //查询区域通用目录
  885. JObject joRtn = mIS.getInterface_TY(Global.inf.interfaceDr.ToString(),"");
  886. string InsuCurrencyCataLogue = JsonHelper.getDestValue(joRtn, "InsuCurrencyCataLogue"); //通用目录编码 6
  887. string InterfaceName_TY = JsonHelper.getDestValue(joRtn, "InterfaceName_TY"); //通用目录名称
  888. string HospName_TY = JsonHelper.getDestValue(joRtn, "HospitalName"); //目录名称
  889. string HospitalDr_TY = JsonHelper.getDestValue(joRtn, "HospitalDr_TY"); //区域通用目录医院ID
  890. if (InsuCurrencyCataLogue != "")
  891. {
  892. queryHISInsuDirectory(rbgDirecType_C.SelectedIndex, 1, 50, dgvCenterDirectory, int.Parse(InsuCurrencyCataLogue));
  893. LabExplain.Visible = true;
  894. LabExplain.Text = "当前接口已设置区域通用目录,数据源:" + HospName_TY + " ,如果确认没有所查目录请联系数据源医院新增维护!";
  895. }
  896. else
  897. {
  898. queryHISInsuDirectory(rbgDirecType_C.SelectedIndex, 1, 50, dgvCenterDirectory, Global.inf.interfaceDr);
  899. LabExplain.Visible = true;
  900. LabExplain.Text = "当前接口未设置区域通用目录,数据源:" + HospName_TY;
  901. }
  902. }
  903. private void pgDownload_PageChanged(object sender, object pagingSource, int pageIndex, int count)
  904. {
  905. queryHISInsuDirectory(rbgDirecType.SelectedIndex, pageIndex, count, dgvDirectoy, Global.inf.interfaceDr);
  906. }
  907. private void pgHISDirect_PageChanged(object sender, object pagingSource, int pageIndex, int count)
  908. {
  909. string errMsg;
  910. int iCount = 50;
  911. if (rbNoMaped.Checked) iCount = 300;
  912. if (queryHISDirectory(pageIndex, iCount, out errMsg) != 0)
  913. {
  914. MessageBox.Show(errMsg);
  915. return;
  916. }
  917. }
  918. private void pgCenterDirect_PageChanged(object sender, object pagingSource, int pageIndex, int count)
  919. {
  920. queryHISInsuDirectory(rbgDirecType_C.SelectedIndex, pageIndex, count, dgvCenterDirectory, Global.inf.interfaceDr);
  921. }
  922. private void rbgDirecType_ValueChanged(object sender, int index, string text)
  923. {
  924. //选定项不同调用的接口也不相同,Index值大于
  925. if (rbgDirecType.SelectedIndex > 13)
  926. {
  927. uiGroupBox1.Visible = false;
  928. uiGroupBox5.Visible = false;
  929. uiGroupBox2.Visible = true;
  930. //uiGroupBox3.Visible = true;
  931. uiProcessBar1.Visible = false;
  932. uiGroupBox2.Left = rbgDirecType.Width + rbgDirecType.Left + 5;
  933. uiGroupBox3.Left = uiGroupBox2.Width+rbgDirecType.Width + rbgDirecType.Left + 10;
  934. dgvDirectoy.DataSource = null;
  935. }
  936. else
  937. {
  938. uiGroupBox1.Visible = true;
  939. uiGroupBox5.Visible = true;
  940. uiGroupBox2.Visible = true;
  941. //uiGroupBox3.Visible = false;
  942. uiProcessBar1.Visible = true;
  943. uiGroupBox1.Left = rbgDirecType.Width + rbgDirecType.Left + 5;
  944. uiGroupBox5.Left = uiGroupBox1.Width + rbgDirecType.Width + rbgDirecType.Left + 10;
  945. uiGroupBox2.Left = uiGroupBox5.Width + uiGroupBox1.Width + rbgDirecType.Width + rbgDirecType.Left + 15;
  946. uiGroupBox3.Left = uiGroupBox2.Width + uiGroupBox5.Width + uiGroupBox1.Width + rbgDirecType.Width + rbgDirecType.Left + 20;
  947. uiProcessBar1.Left = rbgDirecType.Width + rbgDirecType.Left + 5;
  948. uiProcessBar1.Width = uiGroupBox1.Width + uiGroupBox5.Width + uiGroupBox2.Width + 10;
  949. }
  950. setHeaderTxt(rbgDirecType.SelectedIndex, dgvDirectoy);
  951. }
  952. private void toolStripMenuItem2_Click(object sender, EventArgs e)
  953. {
  954. CancleMapping();
  955. }
  956. private void tsmiMapping_Click(object sender, EventArgs e)
  957. {
  958. Mapping();
  959. }
  960. private void dgvHISDirectory_DoubleClick(object sender, EventArgs e)
  961. {
  962. int currentPage = pgHISDirect.ActivePage;
  963. string flag = dgvHISDirectory.Rows[dgvHISDirectory.CurrentRow.Index].Cells["flag"].Value.ToString();
  964. if (flag == "未对照")
  965. {
  966. Mapping();
  967. }
  968. else
  969. if (flag == "已对照")
  970. {
  971. CancleMapping();
  972. }
  973. if (rbAll.Checked)
  974. {
  975. string errMsg;
  976. if (queryHISDirectory(1, 50, out errMsg) != 0)
  977. {
  978. MessageBox.Show(errMsg);
  979. return;
  980. }
  981. }
  982. }
  983. private void dgvDirectoy_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  984. {
  985. }
  986. private void dgvDirectoy_CellContentClick(object sender, DataGridViewCellEventArgs e)
  987. {
  988. }
  989. private void uiRadioButton1_CheckedChanged(object sender, EventArgs e)
  990. {
  991. }
  992. private void dgvDirectoy_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
  993. {
  994. //自动编号,与数据无关
  995. Rectangle rectangle = new Rectangle(e.RowBounds.Location.X,
  996. e.RowBounds.Location.Y,
  997. dgvDirectoy.RowHeadersWidth - 4,
  998. e.RowBounds.Height);
  999. TextRenderer.DrawText(e.Graphics,
  1000. (e.RowIndex + 1).ToString(),
  1001. dgvDirectoy.RowHeadersDefaultCellStyle.Font,
  1002. rectangle,
  1003. dgvDirectoy.RowHeadersDefaultCellStyle.ForeColor,
  1004. TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
  1005. }
  1006. private void rbAll_ValueChanged(object sender, bool value)
  1007. {
  1008. //if (rbAll.Checked)
  1009. //{
  1010. // btnQueryHISDirectory_Click(null, new EventArgs());
  1011. //}
  1012. }
  1013. private void rbMaped_CheckedChanged(object sender, EventArgs e)
  1014. {
  1015. //if (rbMaped.Checked)
  1016. //{
  1017. // string errMsg;
  1018. // if (queryHISDirectory(1, 50, out errMsg) != 0)
  1019. // {
  1020. // MessageBox.Show(errMsg);
  1021. // return;
  1022. // }
  1023. //}
  1024. }
  1025. private void btAddDir_Click(object sender, EventArgs e)
  1026. {
  1027. if (rbgDirecType.SelectedIndex == 8)
  1028. {
  1029. string errMsg = "";
  1030. AddSingleDictionary addDictionary = new AddSingleDictionary();
  1031. if (addDictionary.ShowDialog() == DialogResult.OK)
  1032. {
  1033. if (UpdateDictionaryBySelf(addDictionary, out errMsg) != 0)
  1034. {
  1035. MessageBox.Show(errMsg);
  1036. }
  1037. else
  1038. {
  1039. MessageBox.Show("新增成功!");
  1040. }
  1041. }
  1042. }
  1043. else
  1044. {
  1045. AddSingleDirectory addDirectory = new AddSingleDirectory(rbgDirecType.SelectedIndex);
  1046. if (addDirectory.ShowDialog() == DialogResult.OK)
  1047. {
  1048. JObject joRtn = mIS.UpdateDirectoryBySelf(addDirectory.joPamam);
  1049. string error = "";
  1050. if (JsonHelper.parseIrisRtnValue(joRtn, out error) != 0)
  1051. {
  1052. MessageBox.Show("新增失败:" + error);
  1053. }
  1054. else
  1055. {
  1056. MessageBox.Show("新增成功");
  1057. }
  1058. }
  1059. }
  1060. }
  1061. private void btEditDir_Click(object sender, EventArgs e)
  1062. {
  1063. DataTable dt = (DataTable)dgvDirectoy.DataSource;
  1064. if ((dt == null) || (dt.Rows.Count < 1))
  1065. {
  1066. MessageBox.Show("表中无数据,请检查!");
  1067. return;
  1068. }
  1069. DataRow dr = dt.Rows[dgvDirectoy.CurrentRow.Index];
  1070. AddSingleDirectory addDirectory = new AddSingleDirectory(rbgDirecType.SelectedIndex, dr);
  1071. if (addDirectory.ShowDialog() == DialogResult.OK)
  1072. {
  1073. JObject joRtn = mIS.UpdateDirectoryBySelf(addDirectory.joPamam);
  1074. string error = "";
  1075. if (JsonHelper.parseIrisRtnValue(joRtn, out error) != 0)
  1076. {
  1077. MessageBox.Show("修改失败:" + error);
  1078. }
  1079. else
  1080. {
  1081. MessageBox.Show("修改成功");
  1082. }
  1083. }
  1084. }
  1085. private void btnExit_Click(object sender, EventArgs e)
  1086. {
  1087. Close();
  1088. }
  1089. /// <summary>
  1090. /// 几个医保查询的交易组织入参
  1091. /// </summary>
  1092. /// <param name="Index"></param>
  1093. /// <param name="funNo"></param>
  1094. /// <returns></returns>
  1095. private JObject GetInput(int Index, out TradeEnum trade)
  1096. {
  1097. trade = TradeEnum.MedicalServiceDirectory;
  1098. dynamic joData = new JObject();
  1099. switch (Index)
  1100. {
  1101. case 14://民族药品目
  1102. {
  1103. trade = TradeEnum.NationalityDrug;
  1104. joData.med_list_codg = tbDirectoryCode.Text; //医疗目录编码
  1105. joData.genname_codg = ""; //通用名编号
  1106. joData.drug_genname = ""; //药品通用名
  1107. joData.drug_prodname = tbDircetoryName.Text; //药品商品名
  1108. joData.reg_name = ""; //注册名称
  1109. joData.tcmherb_name = ""; //中草药名称
  1110. joData.mlms_name = ""; //药材名称
  1111. joData.vali_flag = ""; //有效标志
  1112. joData.rid = ""; //唯一记录号
  1113. joData.ver = ""; //版本号
  1114. joData.ver_name = ""; //版本名称
  1115. joData.opt_begn_time = ""; //经办开始时间
  1116. joData.opt_end_time = ""; //经办结束时间
  1117. joData.updt_time = TexDate.Text; //更新时间
  1118. joData.page_num = TexDQYS.Text; //当前页数
  1119. joData.page_size = TexBYSJL.Text; //本页数据量
  1120. break;
  1121. }
  1122. case 15://目录信息查询
  1123. {
  1124. trade = TradeEnum.InsuDirectory;
  1125. joData.query_date = ""; //查询时间点
  1126. joData.hilist_code = tbDirectoryCode.Text; //医保目录编码
  1127. joData.insu_admdvs = TextCbd.Text; //参保机构医保区划
  1128. joData.begndate = ""; //开始日期
  1129. joData.hilist_name = tbDircetoryName.Text; //医保目录名称
  1130. joData.wubi = ""; //五笔助记码
  1131. joData.pinyin = ""; //拼音助记码
  1132. joData.med_chrgitm_type = ""; //医疗收费项目类别
  1133. joData.chrgitm_lv = ""; //收费项目等级
  1134. joData.lmt_used_flag = ""; //限制使用标志
  1135. joData.list_type = ""; //目录类别
  1136. joData.med_use_flag = ""; //医疗使用标志
  1137. joData.matn_used_flag = ""; //生育使用标志
  1138. joData.hilist_use_type = ""; //医保目录使用类别
  1139. joData.lmt_cpnd_type = ""; //限复方使用类型
  1140. joData.vali_flag = ""; //有效标志
  1141. joData.updt_time = TexDate.Text; //更新时间
  1142. joData.page_num = TexDQYS.Text; //当前页数
  1143. joData.page_size = TexBYSJL.Text; //本页数据量
  1144. break;
  1145. }
  1146. case 16://医疗与医保目录匹配
  1147. {
  1148. trade = TradeEnum.MedicalAndInsuDirectory;
  1149. joData.query_date = ""; //查询时间点
  1150. joData.medins_list_codg = ""; //定点医药机构目录编号
  1151. joData.hilist_code = tbDirectoryCode.Text; //医保目录编码
  1152. joData.list_type = ""; //目录类别
  1153. joData.insu_admdvs = TextCbd.Text; //参保机构医保区划
  1154. joData.begndate = ""; //开始日期
  1155. joData.vali_flag = ""; //有效标志
  1156. joData.updt_time = TexDate.Text; //更新时间
  1157. joData.page_num = TexDQYS.Text; //当前页数
  1158. joData.page_size = TexBYSJL.Text; //本页数据量
  1159. break;
  1160. }
  1161. case 17://医药机构目录匹配
  1162. {
  1163. trade = TradeEnum.MedcineOrgDirectory;
  1164. joData.query_date = ""; //查询时间点
  1165. joData.fixmedins_code = ""; //定点医药机构编号
  1166. joData.medins_list_codg = ""; //定点医药机构目录编号
  1167. joData.medins_list_name = ""; //定点医药机构目录名称
  1168. joData.insu_admdvs = TextCbd.Text; //参保机构医保区划
  1169. joData.list_type = ""; //目录类别
  1170. joData.med_list_codg = tbDirectoryCode.Text; //医疗目录编码
  1171. joData.begndate = ""; //开始日期
  1172. joData.vali_flag = ""; //有效标志
  1173. joData.updt_time = TexDate.Text; //更新时间
  1174. joData.page_num = TexDQYS.Text; //当前页数
  1175. joData.page_size = TexBYSJL.Text; //本页数据量
  1176. break;
  1177. }
  1178. case 18://医保目录限价
  1179. {
  1180. trade = TradeEnum.InsuPriceLimitDirectory;
  1181. joData.query_date = ""; //查询时间点
  1182. joData.hilist_code = tbDirectoryCode.Text; //医保目录编码
  1183. joData.hilist_lmtpric_type = ""; //医保目录限价类型
  1184. joData.overlmt_dspo_way = ""; //医保目录超限处理方式
  1185. joData.insu_admdvs = TextCbd.Text; //参保机构医保区划
  1186. joData.begndate = ""; //开始日期
  1187. joData.enddate = ""; //结束日期
  1188. joData.vali_flag = ""; //有效标志
  1189. joData.rid = ""; //唯一记录号
  1190. joData.tabname = ""; //表名
  1191. joData.poolarea_no = ""; //统筹区
  1192. joData.updt_time = TexDate.Text; //更新时间
  1193. joData.page_num = TexDQYS.Text; //当前页数
  1194. joData.page_size = TexBYSJL.Text; //本页数据量
  1195. break;
  1196. }
  1197. case 19://医保目录先自付比例
  1198. {
  1199. trade = TradeEnum.PrepayPercentDirectory;
  1200. joData.query_date = ""; //查询时间点
  1201. joData.hilist_code = tbDirectoryCode.Text; //医保目录编码
  1202. joData.selfpay_prop_psn_type = "";//医保目录自付比例人员类别
  1203. joData.selfpay_prop_type = ""; //目录自付比例类别
  1204. joData.insu_admdvs = TextCbd.Text; //参保机构医保区划
  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 20://医药机构信息
  1217. {
  1218. trade = TradeEnum.MedicalOrgination;
  1219. joData.fixmedins_type = "1"; //定点医疗服务机构类型 1定点医疗机构,2定点零售药店,3工伤定点康复机构,4辅助器具配置机构,5计划生育服务机构
  1220. joData.fixmedins_name = TexYYMC.Text; //定点医药机构名称
  1221. joData.fixmedins_code = ""; //定点医药机构编号
  1222. break;
  1223. }
  1224. }
  1225. return joData;
  1226. }
  1227. private void uiButton1_Click(object sender, EventArgs e)
  1228. {
  1229. Close();
  1230. }
  1231. /// <summary>
  1232. /// 单条上传目录对照关系
  1233. /// </summary>
  1234. private void SingleUpload()
  1235. {
  1236. if ((dgvHISDirectory.CurrentRow == null))
  1237. {
  1238. MessageBox.Show("请查询HIS目录对照关系");
  1239. return;
  1240. }
  1241. string errorMsg = "", sMLLX = "";
  1242. //单条目录对照关系上传
  1243. int iHis = dgvHISDirectory.CurrentRow.Index;
  1244. DataTable dtHis = (DataTable)dgvHISDirectory.DataSource;
  1245. int hisType = rbgDirecType_C.SelectedIndex + 1; //1药品 2诊疗 3材料
  1246. //string hisTypeName = rbgDirecType_C.Items[hisType - 1].ToString();
  1247. if (hisType == 1)
  1248. {
  1249. sMLLX = "101"; //101西药中成药 102中药饮片 103自制剂 104民族药 201医疗服务项目 301医用耗材 501长护服务项目 105其他
  1250. }
  1251. else if (hisType == 2)
  1252. {
  1253. sMLLX = "201";
  1254. }
  1255. else if (hisType == 3)
  1256. {
  1257. sMLLX = "301";
  1258. }
  1259. string InsuCode = dtHis.Rows[iHis]["InsuCode"].ToString();
  1260. string InsuName = dtHis.Rows[iHis]["InsuName"].ToString();
  1261. string HisCode = dtHis.Rows[iHis]["itemCode"].ToString();
  1262. string HisName = dtHis.Rows[iHis]["itemDesc"].ToString();
  1263. string UpdateDate = DateTime.Now.ToString("yyyy-MM-dd");
  1264. string MapId = dtHis.Rows[iHis]["MapID"].ToString();
  1265. JArray dataArray = new JArray();
  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", "2023-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. dataArray.Add(joData);
  1283. // 单条与多条保持一致
  1284. JObject joInput = new JObject();
  1285. joInput.Add("data", dataArray);
  1286. InvokeHelper invoker = new InvokeHelper();
  1287. Global.pat.insuplc_admdvs = Global.inf.areaCode;
  1288. JObject joRtn = invoker.invokeCenterService(TradeEnum.DirectoryContrastUpload, joInput);
  1289. if (JsonHelper.parseCenterRtnValue(joRtn, out errorMsg) != 0)
  1290. {
  1291. MessageBox.Show("目录对照关系上传失败:" + errorMsg);
  1292. }
  1293. else
  1294. {
  1295. UpdateUploadStatus(MapId, 3);
  1296. MessageBox.Show("目录对照关系上传成功!");
  1297. }
  1298. }
  1299. /// <summary>
  1300. /// 单条撤销目录对照关系上传
  1301. /// </summary>
  1302. private void SingleCancelUpload()
  1303. {
  1304. if ((dgvHISDirectory.CurrentRow == null) || (rbMaped.Checked != true))
  1305. {
  1306. MessageBox.Show("请查询HIS目录对照关系");
  1307. return;
  1308. }
  1309. string errorMsg = "", sMLLX = "";
  1310. //撤销目录对照关系
  1311. DataTable dtHis = (DataTable)dgvHISDirectory.DataSource;
  1312. int iHis = dgvHISDirectory.CurrentRow.Index;
  1313. string InsuCode = dtHis.Rows[iHis]["InsuCode"].ToString();
  1314. string HisCode = dtHis.Rows[iHis]["HisCode"].ToString();
  1315. string MapId = dtHis.Rows[iHis]["MapID"].ToString();
  1316. int hisType = rbgDirecType_C.SelectedIndex + 1; //1药品 2诊疗 3材料
  1317. //string hisTypeName = rbgDirecType_C.Items[hisType - 1].ToString();
  1318. if (hisType == 1)
  1319. {
  1320. sMLLX = "101"; //101西药中成药 102中药饮片 103自制剂 104民族药 201医疗服务项目 301医用耗材 501长护服务项目 105其他
  1321. }
  1322. else if (hisType == 2)
  1323. {
  1324. sMLLX = "201";
  1325. }
  1326. else if (hisType == 3)
  1327. {
  1328. sMLLX = "301";
  1329. }
  1330. //调用3302目录对照撤销
  1331. JObject joData = new JObject();
  1332. joData.Add("fixmedins_code", Global.inf.hospitalNO);
  1333. joData.Add("fixmedins_hilist_id", HisCode);
  1334. joData.Add("list_type", sMLLX); //目录类别
  1335. joData.Add("med_list_codg", InsuCode); //医疗目录编码
  1336. JObject joInput = new JObject();
  1337. joInput.Add("data", joData);
  1338. InvokeHelper invoker = new InvokeHelper();
  1339. Global.pat.insuplc_admdvs = Global.inf.areaCode;
  1340. JObject joRtn = invoker.invokeCenterService(TradeEnum.DirectoryContrastCancel, joInput);
  1341. if (JsonHelper.parseCenterRtnValue(joRtn, out errorMsg) != 0)
  1342. {
  1343. MessageBox.Show("目录对照撤销失败:" + errorMsg);
  1344. }
  1345. else
  1346. {
  1347. UpdateUploadStatus(MapId, 2);
  1348. MessageBox.Show("目录对照撤销成功!");
  1349. }
  1350. }
  1351. /// <summary>
  1352. /// 全部上传目录对照关系
  1353. /// </summary>
  1354. private void AllUpLoad()
  1355. {
  1356. if ((dgvHISDirectory.CurrentRow == null))
  1357. {
  1358. MessageBox.Show("请查询HIS目录对照关系");
  1359. return;
  1360. }
  1361. string sInputStr = "", sMLLX = "", errorMsg = "", Msg = "";
  1362. Boolean bOk = true;
  1363. JObject InputjoRtn = new JObject();
  1364. string UpdateDate = DateTime.Now.ToString("yyyy-MM-dd");
  1365. int hisType = rbgDirecType_C.SelectedIndex + 1; //1药品 2诊疗 3材料
  1366. if (hisType == 1)
  1367. {
  1368. sMLLX = "101"; //101西药中成药 102中药饮片 103自制剂 104民族药 201医疗服务项目 301医用耗材 501长护服务项目 105其他
  1369. }
  1370. else if (hisType == 2)
  1371. {
  1372. sMLLX = "201";
  1373. }
  1374. else if (hisType == 3)
  1375. {
  1376. sMLLX = "301";
  1377. }
  1378. List<String> mapIdList = new List<string>();
  1379. DataTable dtHis = (DataTable)dgvHISDirectory.DataSource;
  1380. JArray dataArray = new JArray();
  1381. for (int i = 0; i < dtHis.Rows.Count; i++)
  1382. {
  1383. string InsuCode = dtHis.Rows[i]["InsuCode"].ToString(); //医保目录编码
  1384. string InsuName = dtHis.Rows[i]["InsuName"].ToString(); //医保目录名称
  1385. string HisCode = dtHis.Rows[i]["itemCode"].ToString(); //HIS目录编码
  1386. string HisName = dtHis.Rows[i]["itemDesc"].ToString(); //HIS目录名称
  1387. mapIdList.Add(dtHis.Rows[i]["MapID"].ToString()); //ID
  1388. //调用3301目录对照上传
  1389. JObject joData = new JObject();
  1390. joData.Add("fixmedins_hilist_id", HisCode);
  1391. joData.Add("fixmedins_hilist_name", HisName);
  1392. joData.Add("list_type", sMLLX); //目录类别
  1393. joData.Add("med_list_codg", InsuCode); //医疗目录编码
  1394. joData.Add("begndate", "2023-10-01"); //开始日期
  1395. joData.Add("enddate", UpdateDate); //结束日期
  1396. joData.Add("aprvno", "");
  1397. joData.Add("dosform", "");
  1398. joData.Add("exct_cont", "");
  1399. joData.Add("item_cont", "");
  1400. joData.Add("prcunt", "");
  1401. joData.Add("spec", "");
  1402. joData.Add("pacspec", "");
  1403. joData.Add("memo", "");
  1404. dataArray.Add(joData);
  1405. }
  1406. JObject joInput = new JObject();
  1407. joInput.Add("data", dataArray);
  1408. Global.pat.insuplc_admdvs = Global.inf.areaCode;
  1409. InvokeHelper invoker = new InvokeHelper();
  1410. JObject joRtn = invoker.invokeCenterService(TradeEnum.DirectoryContrastUpload, joInput);
  1411. if (JsonHelper.parseCenterRtnValue(joRtn, out errorMsg) != 0)
  1412. {
  1413. bOk = false;
  1414. Msg = Msg + "<" + joInput.ToString() + ":" + errorMsg + ">";
  1415. }
  1416. if (bOk == false)
  1417. {
  1418. MessageBox.Show("全部目录对照关系上传成功,部分上传异常:" + Msg);
  1419. }
  1420. else
  1421. {
  1422. UpdateUploadStatus(string.Join(",",mapIdList.ToArray()),3);
  1423. MessageBox.Show("全部目录对照关系上传成功!");
  1424. }
  1425. }
  1426. private void UpdateUploadStatus(string ids, int state)
  1427. {
  1428. if (string.IsNullOrEmpty(ids)) return;
  1429. dynamic joInput = new JObject();
  1430. joInput.HospitalDr = Global.inf.hospitalDr;
  1431. joInput.InterfaceDr = Global.inf.interfaceDr;
  1432. joInput.ID = ids;
  1433. joInput.state = state;
  1434. JObject joRtn = invoker.invokeInsuService(JsonHelper.setIrisInpar("09010103", joInput).ToString(), "更新上传状态");
  1435. if (joRtn["errorCode"].Text() != "0")
  1436. {
  1437. Global.writeLog("更新状态失败!" + joRtn["errorMessage"].ToString());
  1438. }
  1439. }
  1440. /// <summary>
  1441. /// 全部撤销目录对照关系上传
  1442. /// </summary>
  1443. private void AllCancelUpload()
  1444. {
  1445. if ((dgvHISDirectory.CurrentRow == null) || (rbMaped.Checked != true))
  1446. {
  1447. MessageBox.Show("请查询HIS目录对照关系");
  1448. return;
  1449. }
  1450. string sMLLX = "", errorMsg = "", Msg = "";
  1451. Boolean bOk = true;
  1452. string UpdateDate = DateTime.Now.ToString("yyyy-MM-dd");
  1453. int hisType = rbgDirecType_C.SelectedIndex + 1; //1药品 2诊疗 3材料
  1454. if (hisType == 1)
  1455. {
  1456. sMLLX = "101"; //101西药中成药 102中药饮片 103自制剂 104民族药 201医疗服务项目 301医用耗材 501长护服务项目 105其他
  1457. }
  1458. else if (hisType == 2)
  1459. {
  1460. sMLLX = "201";
  1461. }
  1462. else if (hisType == 3)
  1463. {
  1464. sMLLX = "301";
  1465. }
  1466. DataTable dtHis = (DataTable)dgvHISDirectory.DataSource;
  1467. List<String> mapIdList = new List<string>();
  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. mapIdList.Add(dtHis.Rows[i]["MapID"].ToString()); //ID
  1473. //调用3302目录对照撤销
  1474. JObject joData = new JObject();
  1475. joData.Add("fixmedins_code", Global.inf.hospitalNO);
  1476. joData.Add("fixmedins_hilist_id", HisCode);
  1477. joData.Add("list_type", sMLLX); //目录类别
  1478. joData.Add("med_list_codg", InsuCode); //医疗目录编码
  1479. JObject joInput = new JObject();
  1480. joInput.Add("data", joData);
  1481. InvokeHelper invoker = new InvokeHelper();
  1482. JObject joRtn = invoker.invokeCenterService(TradeEnum.DirectoryContrastCancel, joInput);
  1483. if (JsonHelper.parseCenterRtnValue(joRtn, out errorMsg) != 0)
  1484. {
  1485. bOk = false;
  1486. Msg = Msg + "<" + joInput.ToString()+":" + errorMsg + ">";
  1487. }
  1488. }
  1489. if (bOk == false)
  1490. {
  1491. MessageBox.Show("全部撤销目录对照关系上传成功,部分撤销异常:" + Msg);
  1492. }
  1493. else
  1494. {
  1495. UpdateUploadStatus(string.Join(",", mapIdList.ToArray()), 2);
  1496. MessageBox.Show("全部撤销目录对照关系上传成功!");
  1497. }
  1498. }
  1499. private void ToolStripMenuItem_Upload_Click(object sender, EventArgs e)
  1500. {
  1501. SingleUpload();
  1502. }
  1503. private void ToolStripMenuItem_CancelUpload_Click(object sender, EventArgs e)
  1504. {
  1505. SingleCancelUpload();
  1506. }
  1507. private void rbgDirecType_C_ValueChanged(object sender, int index, string text)
  1508. {
  1509. tbHISDirectoryFilter.Text = "";
  1510. uiTextBox1.Text = "";
  1511. rbAll.Checked = true;
  1512. rbMaped.Checked = false;
  1513. rbNoMaped.Checked = false;
  1514. tbCenterDirectoryFilter.Text = "";
  1515. tbInsuCode.Text = "";
  1516. tbApprovalNO.Text = "";
  1517. dgvCenterDirectory.DataSource = null;
  1518. btnQueryHISDirectory_Click(null, new EventArgs());
  1519. }
  1520. private void rbNoMaped_CheckedChanged(object sender, EventArgs e)
  1521. {
  1522. //if (rbNoMaped.Checked)
  1523. //{
  1524. // string errMsg;
  1525. // if (queryHISDirectory(1, 300, out errMsg) != 0)
  1526. // {
  1527. // MessageBox.Show(errMsg);
  1528. // return;
  1529. // }
  1530. //}
  1531. }
  1532. private void dgvHISDirectory_RowStateChanged(object sender, DataGridViewRowStateChangedEventArgs e)
  1533. {
  1534. e.Row.HeaderCell.Value = string.Format("{0}", e.Row.Index + 1);
  1535. }
  1536. private void dgvCenterDirectory_RowStateChanged(object sender, DataGridViewRowStateChangedEventArgs e)
  1537. {
  1538. e.Row.HeaderCell.Value = string.Format("{0}", e.Row.Index + 1);
  1539. }
  1540. private void updateLimitPrice()
  1541. {
  1542. SelfpayPercentForm selfpay = new SelfpayPercentForm();
  1543. selfpay.CenterCode = dgvDirectoy.Rows[dgvDirectoy.SelectedIndex].Cells["Code"].Value + "";
  1544. selfpay.ShowDialog();
  1545. }
  1546. private void btSignIn_Click(object sender, EventArgs e)
  1547. {
  1548. if (mIS.isSigned(ref Global.curEvt.signno) != true)
  1549. {
  1550. JObject joRtn = new JObject();
  1551. CallResult callResult = new SignInProcess().Process(joRtn);
  1552. string error = "";
  1553. if (JsonHelper.parseIrisRtnValue(JObject.FromObject(callResult.PureData), out error) != 0)
  1554. {
  1555. MessageBox.Show($"签到失败!{error}");
  1556. }
  1557. else
  1558. {
  1559. MessageBox.Show("签到成功!");
  1560. }
  1561. }
  1562. else
  1563. {
  1564. MessageBox.Show("今日已签到!");
  1565. }
  1566. }
  1567. private void tsmiSingleUpdateAuxInfo_Click(object sender, EventArgs e)
  1568. {
  1569. string error;
  1570. int iDir = dgvDirectoy.CurrentRow.Index;
  1571. if (dgvDirectoy.CurrentRow == null)
  1572. {
  1573. MessageBox.Show("请查询中心目录");
  1574. return;
  1575. }
  1576. JObject jo = new JObject();
  1577. jo.Add("code", dgvDirectoy.Rows[iDir].Cells["code"].Value.ToString());
  1578. jo.Add("HisType", rbgDirecType.SelectedIndex + 1);
  1579. if (updateAuxInfo(jo,out error) != 0)
  1580. {
  1581. MessageBox.Show(error);
  1582. }
  1583. else
  1584. {
  1585. MessageBox.Show(error);
  1586. }
  1587. }
  1588. public string getDataRowValue(DataRow dr, string columnName)
  1589. {
  1590. if (!dr.Table.Columns.Contains(columnName))
  1591. {
  1592. return "";
  1593. }
  1594. else
  1595. {
  1596. return dr[columnName].ToString();
  1597. }
  1598. }
  1599. //更新目录信息(附属信息)
  1600. private int updateAuxInfo(JObject jo,out string err)
  1601. {
  1602. err = "";
  1603. tbDirectoryCode.Text = JsonHelper.getDestValue(jo,"code");
  1604. dynamic joData = GetInput(15, out TradeEnum trade);
  1605. JObject joRtn = cBus.InvokeMedicalInsuranceInquiry(trade, joData);
  1606. if (joRtn["infcode"].ToString() == "0")
  1607. {
  1608. DataTable dtAuxInfo = (DataTable)joRtn["output"]["data"].ToObject(typeof(DataTable));
  1609. DateTime dtToday = DateTime.Today;
  1610. string chrgitm_lv = "";
  1611. string begndate = "";
  1612. string enddate = "";
  1613. string list_type = "";
  1614. string med_chrgitm_type = "";
  1615. int iAdpater = 0;
  1616. foreach (DataRow dr in dtAuxInfo.Rows)
  1617. {
  1618. DateTime dtBegin = getDataRowValue(dr, "begndate") == "" ? Convert.ToDateTime("2000-01-01 00:00:00") : Convert.ToDateTime(getDataRowValue(dr, "begndate"));
  1619. DateTime dtEnd = getDataRowValue(dr, "enddate") == "" ? Convert.ToDateTime("2099-01-01 00:00:00") : Convert.ToDateTime(getDataRowValue(dr, "enddate"));
  1620. if ((dtBegin < dtToday) && (dtToday < dtEnd))
  1621. {
  1622. iAdpater++;
  1623. chrgitm_lv = dr["chrgitm_lv"].ToString();
  1624. begndate = dr["begndate"].ToString();
  1625. enddate = dr["enddate"].ToString();
  1626. list_type = dr["list_type"].ToString();
  1627. med_chrgitm_type = dr["med_chrgitm_type"].ToString();
  1628. }
  1629. }
  1630. //有且只能有一条数据符合
  1631. if (iAdpater == 1)
  1632. {
  1633. JObject joPamam = new JObject();
  1634. joPamam.Add("Code", JsonHelper.getDestValue(jo, "code"));
  1635. joPamam.Add("HisType", JsonHelper.getDestValue(jo, "HisType"));
  1636. joPamam.Add("StartDate", begndate);
  1637. joPamam.Add("EndDate", enddate);
  1638. joPamam.Add("ChargeItemLevel", chrgitm_lv);
  1639. joPamam.Add("ListType", list_type);
  1640. joPamam.Add("ChargeItemType", med_chrgitm_type);
  1641. JObject joUpdateRtn = mIS.UpdateDirectoryBySelf(joPamam);
  1642. string error = "";
  1643. if (JsonHelper.parseIrisRtnValue(joUpdateRtn, out error) != 0)
  1644. {
  1645. err = "修改失败:" + error;
  1646. return -1;
  1647. }
  1648. else
  1649. {
  1650. err = "修改成功";
  1651. return 0;
  1652. }
  1653. }
  1654. else
  1655. {
  1656. err = "中心返回符合条数的记录不唯一或者为空,请检查!";
  1657. return -1;
  1658. }
  1659. }
  1660. else
  1661. {
  1662. err = "查询中心数据出错,请检查!";
  1663. return -1;
  1664. }
  1665. }
  1666. //更新目录信息(附属信息)
  1667. private int updateCellingPrice(JObject jo, out string err)
  1668. {
  1669. err = "";
  1670. tbDirectoryCode.Text = JsonHelper.getDestValue(jo, "code");
  1671. dynamic joData = GetInput(18, out TradeEnum trade);
  1672. JObject joRtn = cBus.InvokeMedicalInsuranceInquiry(trade, joData);
  1673. if (joRtn["infcode"].ToString() == "0")
  1674. {
  1675. DataTable dtAuxInfo = (DataTable)joRtn["output"]["data"].ToObject(typeof(DataTable));
  1676. DateTime dtToday = DateTime.Today;
  1677. string cellingPrice = "";
  1678. string begndate = "";
  1679. string enddate = "";
  1680. int iAdpater = 0;
  1681. foreach (DataRow dr in dtAuxInfo.Rows)
  1682. {
  1683. DateTime dtBegin = getDataRowValue(dr, "begndate") == "" ? Convert.ToDateTime("2000-01-01 00:00:00") : Convert.ToDateTime(getDataRowValue(dr, "begndate"));
  1684. DateTime dtEnd = getDataRowValue(dr, "enddate") == "" ? Convert.ToDateTime("2099-01-01 00:00:00") : Convert.ToDateTime(getDataRowValue(dr, "enddate"));
  1685. if ((dtBegin < dtToday) && (dtToday < dtEnd))
  1686. {
  1687. iAdpater++;
  1688. cellingPrice = dr["hilist_pric_uplmt_amt"].ToString();
  1689. begndate = dr["begndate"].ToString();
  1690. enddate = dr["enddate"].ToString();
  1691. }
  1692. }
  1693. //有且只能有一条数据符合
  1694. if (iAdpater == 1)
  1695. {
  1696. JObject joPamam = new JObject();
  1697. joPamam.Add("Code", JsonHelper.getDestValue(jo, "code"));
  1698. joPamam.Add("HisType", JsonHelper.getDestValue(jo, "HisType"));
  1699. joPamam.Add("StartDate", begndate);
  1700. joPamam.Add("EndDate", enddate);
  1701. joPamam.Add("CeilingPrice", cellingPrice);
  1702. JObject joUpdateRtn = mIS.UpdateDirectoryBySelf(joPamam);
  1703. string error = "";
  1704. if (JsonHelper.parseIrisRtnValue(joUpdateRtn, out error) != 0)
  1705. {
  1706. err = "修改失败:" + error;
  1707. return -1;
  1708. }
  1709. else
  1710. {
  1711. err = "修改成功";
  1712. return 0;
  1713. }
  1714. }
  1715. else
  1716. {
  1717. err = "中心返回符合条数的记录不唯一或者为空,请检查!";
  1718. return -1;
  1719. }
  1720. }
  1721. else
  1722. {
  1723. err = "查询中心数据出错,请检查!";
  1724. return -1;
  1725. }
  1726. }
  1727. private int updateSelfRatioInfo(JObject jo, out string err)
  1728. {
  1729. err = "";
  1730. tbDirectoryCode.Text = JsonHelper.getDestValue(jo, "code");
  1731. dynamic joData = GetInput(19, out TradeEnum trade);
  1732. JObject joRtn = cBus.InvokeMedicalInsuranceInquiry(trade, joData);
  1733. if (joRtn["infcode"].ToString() == "0")
  1734. {
  1735. DataTable dtRatioInfo = (DataTable)joRtn["output"]["data"].ToObject(typeof(DataTable));
  1736. DateTime dtToday = DateTime.Today;
  1737. string cellingPrice = "";
  1738. string begndate = "";
  1739. string enddate = "";
  1740. int iAdpater = 0;
  1741. var dataArray = JArray.FromObject(joRtn["output"]["data"]);
  1742. DateTime today = DateTime.Today;
  1743. var groupedResult = dataArray
  1744. .Where(item =>
  1745. {
  1746. if (DateTime.TryParse(item["enddate"]?.ToString(), out var endDate))
  1747. {
  1748. return endDate.Date >= today.Date;
  1749. }
  1750. return false;
  1751. })
  1752. .GroupBy(item => item["selfpay_prop_psn_type"]?.ToString());
  1753. JArray joArray = new JArray();
  1754. foreach (var group in groupedResult)
  1755. {
  1756. foreach (var item in group)
  1757. {
  1758. // 将 JsonNode 转换为 JObject
  1759. JObject jObj = JObject.Parse(item.ToString());
  1760. dynamic joTmp = new JObject();
  1761. joTmp.HospitalDr = Global.inf.hospitalDr;
  1762. joTmp.InterfaceDr = Global.inf.interfaceDr;
  1763. joTmp.updateUserID = Global.user.ID;
  1764. joTmp.Code = jObj["hilist_code"];
  1765. joTmp.PersonnelType = jObj["selfpay_prop_psn_type"];
  1766. joTmp.ProportionType = jObj["selfpay_prop_type"];
  1767. joTmp.Proportion = jObj["selfpay_prop"];
  1768. joTmp.BeginDate = jObj["begndate"];
  1769. joTmp.EndDate = jObj["enddate"];
  1770. joTmp.InsuranceAreaCode = jObj["insu_admdvs"];
  1771. joTmp.PoolAreaNO = jObj["poolarea_no"];
  1772. joTmp.ValidFlag = jObj["vali_flag"];
  1773. joTmp.RequiredID = jObj["rid"];
  1774. joArray.Add(joTmp);
  1775. }
  1776. }
  1777. string errMsg = "";
  1778. InvokeHelper invoker = new InvokeHelper();
  1779. joRtn = invoker.invokeInsuService(JsonHelper.setIrisInpar("09010085", joArray).ToString(), "设置自费比例");
  1780. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  1781. {
  1782. err = errMsg;
  1783. return -1;
  1784. }
  1785. else {
  1786. err = ("更新成功!");
  1787. return 0;
  1788. }
  1789. }
  1790. else
  1791. {
  1792. err = "查询中心数据出错,请检查!";
  1793. return -1;
  1794. }
  1795. }
  1796. private void tsmiUpdateCellingPrice_Click(object sender, EventArgs e)
  1797. {
  1798. string error;
  1799. int iDir = dgvDirectoy.CurrentRow.Index;
  1800. if (dgvDirectoy.CurrentRow == null)
  1801. {
  1802. MessageBox.Show("请查询中心目录");
  1803. return;
  1804. }
  1805. JObject jo = new JObject();
  1806. jo.Add("code", dgvDirectoy.Rows[iDir].Cells["code"].Value.ToString());
  1807. jo.Add("HisType", rbgDirecType.SelectedIndex + 1);
  1808. if (updateCellingPrice(jo,out error) != 0)
  1809. {
  1810. MessageBox.Show(error);
  1811. }
  1812. else
  1813. {
  1814. MessageBox.Show(error);
  1815. }
  1816. }
  1817. private void btTripMenu_Click(object sender, EventArgs e)
  1818. {
  1819. uiContextMenuStrip1.Show(((Sunny.UI.UIButton)sender), new Point(0, btTripMenu.Height));
  1820. }
  1821. private void tsmExportAllMappedData_Click(object sender, EventArgs e)
  1822. {
  1823. // 创建 DataLoader 并传递 queryExportData 方法
  1824. DataLoader _dataLoader;
  1825. _dataLoader = new DataLoader(queryExportData_CallBack, this);
  1826. _dataLoader.Start(new object[] { 0 }, (result, errMsg) =>
  1827. {
  1828. // 在这里处理结果和错误信息
  1829. if (result == 0)
  1830. {
  1831. MessageBox.Show(errMsg);
  1832. }
  1833. else
  1834. {
  1835. MessageBox.Show(errMsg);
  1836. }
  1837. });
  1838. }
  1839. private int queryExportData(out string errMsg)
  1840. {
  1841. errMsg = "";
  1842. int currentPage = 1; int pageSize = 50;
  1843. string directoryType = string.Empty;
  1844. switch (rbgDirecType_C.SelectedIndex)
  1845. {
  1846. case 0:
  1847. {
  1848. directoryType = "drugs";
  1849. break;
  1850. }
  1851. case 1:
  1852. {
  1853. directoryType = "diagnosi";
  1854. break;
  1855. }
  1856. case 2:
  1857. {
  1858. directoryType = "consumables";
  1859. break;
  1860. }
  1861. }
  1862. JObject joHISRtn = new JObject();
  1863. JObject joRtn = new JObject();
  1864. string flag = "";
  1865. //全部是先调HIS,然后再匹配医保平台的对照关系
  1866. if (rbAll.Checked)
  1867. {
  1868. JArray jaPagination = new JArray();
  1869. JArray jaParams = new JArray();
  1870. flag = "All";
  1871. dynamic joParam = new JObject();
  1872. joParam.code = "";
  1873. joParam.descripts = "";
  1874. joParam.FindType = new JArray();
  1875. joParam.TypeID = "";
  1876. joParam.alias = tbHISDirectoryFilter.Text;
  1877. joParam.include = "Hosp";
  1878. joParam.groupID = "324";
  1879. joParam.hospID = Global.inf.hisHospitalDr;
  1880. joParam.interfaceDr = Global.inf.interfaceDr;
  1881. joParam.type = directoryType;
  1882. joParam.flag = flag;
  1883. joParam.specInput = txtSpecFilter.Text.Trim();
  1884. jaParams.Add(joParam);
  1885. dynamic joPagination = new JObject();
  1886. joPagination.pageSize = pageSize;
  1887. //joPagination.pageSize = 2;
  1888. joPagination.currentPage = currentPage;
  1889. joPagination.sortColumn = "Code";
  1890. joPagination.sortOrder = "asc";
  1891. jaPagination.Add(joPagination);
  1892. //该服务需要改写,需要跟(CloudMedicalInsurancePlatform.Tables.MapRelation)进行关联
  1893. //joInParams.code = "09010038";
  1894. if (hIS.getHISDir(jaPagination, jaParams, out joHISRtn, out errMsg) != 0)
  1895. {
  1896. return -1;
  1897. }
  1898. int count = int.Parse(JsonHelper.getDestValue(joHISRtn, "result.TotalCount"));
  1899. if (count > pageSize)
  1900. {
  1901. joPagination["pageSize"] = count;
  1902. jaPagination = new JArray();
  1903. jaPagination.Add(joPagination);
  1904. if (hIS.getHISDir(jaPagination, jaParams, out joHISRtn, out errMsg) != 0)
  1905. {
  1906. return -1;
  1907. }
  1908. }
  1909. int defaultCount = 200;
  1910. dtExport = null;
  1911. if (count > defaultCount)
  1912. {
  1913. JArray jaHisDir = JArray.Parse(JsonHelper.getDestValue(joHISRtn, "result.Data"));
  1914. JArray jaTmp = new JArray();
  1915. for (int i = 0; i < count; i++)
  1916. {
  1917. JObject joTmp = (JObject)jaHisDir[i];
  1918. foreach (var property in joTmp.Properties())
  1919. {
  1920. if (property.Value.Type == JTokenType.Integer || property.Value.Type == JTokenType.Float)
  1921. {
  1922. property.Value = new JValue(property.Value.ToString());
  1923. }
  1924. }
  1925. jaTmp.Add(joTmp);
  1926. if ((((i + 1) % defaultCount) == 0) || (i + 1 == count))
  1927. {
  1928. JObject joConvert = new JObject();
  1929. joConvert.Add("errorCode", 0);
  1930. joConvert.Add("errorMessage", "查询成功");
  1931. JObject joResult = new JObject();
  1932. if ((i % defaultCount) == 0)
  1933. {
  1934. joResult.Add("TotalCount", defaultCount);
  1935. }
  1936. else
  1937. {
  1938. joResult.Add("TotalCount", (i + 1) % defaultCount);
  1939. }
  1940. joResult.Add("Data", jaTmp);
  1941. joConvert.Add("result", joResult);
  1942. joRtn = mIS.ConvertHISDir(joConvert);
  1943. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  1944. {
  1945. return -1;
  1946. }
  1947. else
  1948. {
  1949. DataTable dtTmp = (DataTable)joRtn["result"]["Data"].ToObject(typeof(DataTable));
  1950. if (dtExport == null)
  1951. {
  1952. dtExport = dtTmp.Clone();
  1953. dtExport.Merge(dtTmp);
  1954. }
  1955. else
  1956. {
  1957. dtExport.Merge(dtTmp);
  1958. }
  1959. jaTmp = new JArray();
  1960. }
  1961. }
  1962. }
  1963. }
  1964. else
  1965. {
  1966. joRtn = mIS.ConvertHISDir(joHISRtn);
  1967. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  1968. {
  1969. return -1;
  1970. }
  1971. dtExport = (DataTable)joRtn["result"]["Data"].ToObject(typeof(DataTable));
  1972. }
  1973. }
  1974. //已对照是先调云医保,然后再匹配HIS
  1975. if (rbMaped.Checked)
  1976. {
  1977. JArray jaPagination = new JArray();
  1978. JArray jaParams = new JArray();
  1979. flag = "Maped";
  1980. dynamic joParam = new JObject();
  1981. joParam.alias = tbHISDirectoryFilter.Text;
  1982. joParam.HospitalDr = Global.inf.hospitalDr;
  1983. joParam.InterfaceDr = Global.inf.interfaceDr;
  1984. joParam.hisType = directoryType;
  1985. jaParams.Add(joParam);
  1986. dynamic joPagination = new JObject();
  1987. joPagination.pageSize = pageSize;
  1988. joPagination.currentPage = currentPage;
  1989. joPagination.sortColumn = "HisCode";
  1990. joPagination.sortOrder = "asc";
  1991. jaPagination.Add(joPagination);
  1992. JObject joMIRtn = mIS.GetMappedHISDir(jaPagination, jaParams);
  1993. if (JsonHelper.parseIrisRtnValue(joMIRtn, out errMsg) != 0)
  1994. {
  1995. return -1;
  1996. }
  1997. //传给HIS,进行匹配
  1998. joParam = new JObject();
  1999. joParam.TotalCount = joMIRtn["result"]["TotalCount"];
  2000. joParam.type = directoryType;
  2001. joParam.flag = flag;
  2002. joParam.hospID = Global.inf.hisHospitalDr;
  2003. joParam.interfaceDr = Global.inf.interfaceDr;
  2004. joParam.alias = tbHISDirectoryFilter.Text;
  2005. joParam.include = "Hosp";
  2006. joParam.groupID = "324";
  2007. joParam.compareArr = joMIRtn["result"]["Data"];
  2008. jaParams = new JArray();
  2009. jaParams.Add(joParam);
  2010. if (hIS.getHISDir(jaPagination, jaParams, out joRtn, out errMsg) != 0)
  2011. {
  2012. return -1;
  2013. }
  2014. }
  2015. //if (rbNoMaped.Checked) { flag = "NoMaped"; }
  2016. if (rbNoMaped.Checked)
  2017. {
  2018. JArray jaPagination = new JArray();
  2019. JArray jaParams = new JArray();
  2020. flag = "All";
  2021. dynamic joParam = new JObject();
  2022. joParam.code = "";
  2023. joParam.descripts = "";
  2024. joParam.FindType = new JArray();
  2025. joParam.TypeID = "";
  2026. joParam.alias = tbHISDirectoryFilter.Text;
  2027. joParam.include = "Hosp";
  2028. joParam.groupID = "324";
  2029. joParam.hospID = Global.inf.hisHospitalDr;
  2030. joParam.interfaceDr = Global.inf.interfaceDr;
  2031. joParam.type = directoryType;
  2032. joParam.flag = flag;
  2033. joParam.specInput = "";
  2034. jaParams.Add(joParam);
  2035. dynamic joPagination = new JObject();
  2036. joPagination.pageSize = pageSize;
  2037. //joPagination.pageSize = 2;
  2038. joPagination.currentPage = currentPage;
  2039. joPagination.sortColumn = "Code";
  2040. joPagination.sortOrder = "asc";
  2041. jaPagination.Add(joPagination);
  2042. //1.获取全部HIS目录
  2043. if (hIS.getHISDir(jaPagination, jaParams, out joHISRtn, out errMsg) != 0)
  2044. {
  2045. return -1;
  2046. }
  2047. joRtn = mIS.GetNoMappHISDir(joHISRtn);
  2048. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  2049. {
  2050. return -1;
  2051. }
  2052. }
  2053. return 0;
  2054. }
  2055. private int queryExportData_CallBack(object[] o,out string errMsg, DataLoader.ProgressCallback callback, DataLoader.ProgressMaxCallback maxCallback, BackgroundWorker worker)
  2056. {
  2057. if (queryExportData(out errMsg) != 0)
  2058. {
  2059. return -1;
  2060. }
  2061. //test.Stop();
  2062. this.pgHISDirect.PageChanged += new Sunny.UI.UIPagination.OnPageChangeEventHandler(this.pgHISDirect_PageChanged);
  2063. if (dtExport.Rows.Count > 0)
  2064. {
  2065. string directoryType = string.Empty;
  2066. string sBZ = "";
  2067. switch (rbgDirecType_C.SelectedIndex)
  2068. {
  2069. case 0:
  2070. {
  2071. directoryType = "药品";
  2072. break;
  2073. }
  2074. case 1:
  2075. {
  2076. directoryType = "诊疗";
  2077. break;
  2078. }
  2079. case 2:
  2080. {
  2081. directoryType = "材料";
  2082. break;
  2083. }
  2084. }
  2085. if (rbAll.Checked) sBZ = "全部";
  2086. else
  2087. if (rbMaped.Checked) sBZ = "已对照";
  2088. else
  2089. if (rbNoMaped.Checked) sBZ = "未对照";
  2090. string LSH = DateTime.Now.ToString("yyyy-MM-dd"); //DateTime.Now.ToString("MMddHHmmssffff");
  2091. string filename = LSH + "(" + directoryType + ")医保目录" + sBZ + "信息.xls";
  2092. string sFliePathName = Global.curEvt.path + "\\MapRelation\\" + filename;
  2093. //string sFliePathName = @"D:\" + LSH + "(" + directoryType + ")医保目录" + sBZ + "信息.xls";
  2094. //如果不存在目录,则创建目录
  2095. if (!Directory.Exists(Global.curEvt.path + "\\MapRelation"))
  2096. {
  2097. //创建文件夹
  2098. DirectoryInfo dirInfo = Directory.CreateDirectory(Global.curEvt.path + "\\MapRelation");
  2099. }
  2100. //如存在同名文件不询问直接删除
  2101. if (File.Exists(sFliePathName))
  2102. {
  2103. File.Delete(sFliePathName);
  2104. }
  2105. //新版方法,用的EPPLUS,方便
  2106. ExportToExcel.ExportDataTableToExcel(dtExport, sFliePathName);
  2107. if (true)
  2108. {
  2109. errMsg = ($"导出成功,文件保存路径:{sFliePathName}");
  2110. return 0;
  2111. }
  2112. else
  2113. {
  2114. errMsg = ("导出失败!");
  2115. return -1;
  2116. }
  2117. }
  2118. else
  2119. {
  2120. errMsg = "查询数据集为空!";
  2121. return -1;
  2122. }
  2123. }
  2124. private void tsmUploadAllMappedData_Click(object sender, EventArgs e)
  2125. {
  2126. AllUpLoad();
  2127. }
  2128. private void tsmCancelAllUploadedData_Click(object sender, EventArgs e)
  2129. {
  2130. AllCancelUpload();
  2131. }
  2132. private void tsmUpdateCellPriceOfAllMapped_Click(object sender, EventArgs e)
  2133. {
  2134. batchUpdateMappedInsuInfo(updateCellPriceWrapper);
  2135. }
  2136. private void tsmUpdateAllMapped_Click(object sender, EventArgs e)
  2137. {
  2138. batchUpdateMappedInsuInfo(updateAuxAndCellPriceWrapper);
  2139. }
  2140. private void batchUpdateMappedInsuInfo( Func<JObject, OutParamWrapper, int> _action)
  2141. {
  2142. action = _action;
  2143. string sqlStr = $"select * from HB_MedInsuMapRelation where Interface_Dr='{Global.inf.interfaceDr}' and Hospital_Dr ='{Global.inf.hospitalDr}'";
  2144. JObject joSqlstr = new JObject();
  2145. joSqlstr.Add("sqlStr", sqlStr);
  2146. JObject joRtn = mIS.QueryMappedData(joSqlstr, "查询所有已对照数据");
  2147. iTotalCount = int.Parse(joRtn["result"]["total"].ToString());
  2148. dtAllMapped = (DataTable)joRtn["result"]["data"].ToObject(typeof(DataTable));
  2149. DataLoader _dataLoader;
  2150. _dataLoader = new DataLoader(updateMappedInsuInfo,this);
  2151. _dataLoader.SetProgressBar(ProgressBarStyle.Continuous,"正在更新...",50);
  2152. _dataLoader.Start(new object[] { iTotalCount }, (result, errMsg) =>
  2153. {
  2154. // 在这里处理结果和错误信息
  2155. if (result == 0)
  2156. {
  2157. MessageBox.Show(errMsg);
  2158. }
  2159. else
  2160. {
  2161. MessageBox.Show(errMsg);
  2162. }
  2163. });
  2164. }
  2165. private int updateMappedInsuInfo(object[] o,out string errMsg, DataLoader.ProgressCallback callback, DataLoader.ProgressMaxCallback maxCallback, BackgroundWorker worker)
  2166. {
  2167. int iFalse = 0;
  2168. int iCount = 0;
  2169. List<string> errList = new List<string>();
  2170. if (maxCallback != null)
  2171. {
  2172. maxCallback(iTotalCount);
  2173. }
  2174. foreach (DataRow dr in dtAllMapped.Rows)
  2175. {
  2176. JObject jo = new JObject();
  2177. jo.Add("code", dr["InsuCode"].ToString());
  2178. jo.Add("HisType", dr["HisType"].ToString());
  2179. OutParamWrapper outParWarp = new OutParamWrapper();
  2180. if (action(jo, outParWarp) != 0)
  2181. {
  2182. iFalse++;
  2183. errList.Add(outParWarp.Value);
  2184. Global.writeLog(outParWarp.Value);
  2185. }
  2186. iCount++;
  2187. // 检查是否应取消操作
  2188. if (worker.CancellationPending)
  2189. {
  2190. errMsg = "操作取消!";
  2191. return -1; // 或者其他表示取消的返回值
  2192. }
  2193. if (callback != null)
  2194. {
  2195. callback(iCount);
  2196. }
  2197. }
  2198. if (iFalse != 0)
  2199. {
  2200. errMsg = ($"总共{iCount}条数据更新完成,但有{iFalse}条更新发生错误!");
  2201. Global.writeLog($"{errMsg}\r\n{errList}");
  2202. }
  2203. else
  2204. {
  2205. errMsg = ($"全部数据({iCount}条)更新完成");
  2206. }
  2207. return iFalse;
  2208. }
  2209. private int updateAuxAndCellPriceWrapper(JObject jo, OutParamWrapper outParamWrapper)
  2210. {
  2211. string err;
  2212. int iresult = updateAuxAndCellPrice(jo, out err);
  2213. outParamWrapper.Value = err;
  2214. return iresult;
  2215. }
  2216. private int updateCellPriceWrapper(JObject jo, OutParamWrapper outParamWrapper)
  2217. {
  2218. string err;
  2219. int iresult = updateCellingPrice(jo, out err);
  2220. outParamWrapper.Value = err;
  2221. return iresult;
  2222. }
  2223. private int updateSelfRatioWrapper(JObject jo, OutParamWrapper outParamWrapper)
  2224. {
  2225. string err;
  2226. int iresult = updateSelfRatioInfo(jo, out err);
  2227. outParamWrapper.Value = err;
  2228. return iresult;
  2229. }
  2230. private int updateAuxInfoWrapper(JObject jo, OutParamWrapper outParamWrapper)
  2231. {
  2232. string err;
  2233. int iresult = updateAuxInfo(jo, out err);
  2234. outParamWrapper.Value = err;
  2235. return iresult;
  2236. }
  2237. private int updateAuxAndCellPrice(JObject jo, out string error)
  2238. {
  2239. string err ="";
  2240. int iResult=0;
  2241. error = "";
  2242. if (updateAuxInfo(jo, out err) != 0)
  2243. {
  2244. error = $"更新目录信息失败{err}";
  2245. iResult--;
  2246. }
  2247. err = "";
  2248. if (updateCellingPrice(jo, out err) != 0)
  2249. {
  2250. error = $"{error};更新限价信息失败{err}";
  2251. iResult--;
  2252. }
  2253. return iResult;
  2254. }
  2255. private void tsmUpdateLevelTypeOfAllMappedData_Click(object sender, EventArgs e)
  2256. {
  2257. batchUpdateMappedInsuInfo(updateAuxInfoWrapper);
  2258. }
  2259. private void tsmSingleUpdateInsuInfo_Click(object sender, EventArgs e)
  2260. {
  2261. if ((dgvHISDirectory.CurrentRow == null) || (rbMaped.Checked != true))
  2262. {
  2263. MessageBox.Show("请查询HIS目录对照关系,注意选择已对照!");
  2264. return;
  2265. }
  2266. int iMapped = dgvHISDirectory.CurrentRow.Index;
  2267. string insuCode = dgvHISDirectory.Rows[iMapped].Cells["insuCode"].Value.ToString();
  2268. if (string.IsNullOrEmpty(insuCode))
  2269. {
  2270. MessageBox.Show("未检测到对应的医保目录,请检查该目录是否已对照!");
  2271. return;
  2272. }
  2273. JObject jo = new JObject();
  2274. jo.Add("code", dgvHISDirectory.Rows[iMapped].Cells["insuCode"].Value.ToString());
  2275. jo.Add("HisType", rbgDirecType_C.SelectedIndex + 1);
  2276. string error;
  2277. if (updateAuxAndCellPrice(jo, out error) != 0)
  2278. {
  2279. MessageBox.Show($"更新失败{error}");
  2280. }
  2281. else
  2282. {
  2283. MessageBox.Show("更新成功!");
  2284. }
  2285. }
  2286. private void dgvHISDirectory_SelectionChanged(object sender, EventArgs e)
  2287. {
  2288. int i = dgvHISDirectory.CurrentRow.Index;
  2289. if (dgvHISDirectory.Rows[i].Cells["insuCode"].Value.ToString() != "")
  2290. {
  2291. tbInsuCode.Text = dgvHISDirectory.Rows[i].Cells["insuCode"].Value.ToString();
  2292. tbCenterDirectoryFilter.Text = "";
  2293. tbApprovalNO.Text = "";
  2294. }
  2295. else
  2296. {
  2297. tbInsuCode.Text = "";
  2298. if (rbOnlyName.Checked)
  2299. {
  2300. tbInsuCode.Text = "";
  2301. tbApprovalNO.Text = "";
  2302. tbCenterDirectoryFilter.Text = "%" + dgvHISDirectory.Rows[i].Cells["itemDesc"].Value.ToString() + "%";
  2303. }
  2304. if (rbOnlyApprNO.Checked)
  2305. {
  2306. tbCenterDirectoryFilter.Text = "";
  2307. tbInsuCode.Text = "";
  2308. tbApprovalNO.Text = "%" + dgvHISDirectory.Rows[i].Cells["pprovalNo"].Value.ToString() + "%";
  2309. }
  2310. if (rbBoth.Checked)
  2311. {
  2312. tbInsuCode.Text = "";
  2313. tbCenterDirectoryFilter.Text = "%" + dgvHISDirectory.Rows[i].Cells["itemDesc"].Value.ToString() + "%";
  2314. tbApprovalNO.Text = "%" + dgvHISDirectory.Rows[i].Cells["pprovalNo"].Value.ToString() + "%";
  2315. }
  2316. }
  2317. }
  2318. private void tsmSingleUpdateSelfRatioInfo_Click(object sender, EventArgs e)
  2319. {
  2320. if ((dgvHISDirectory.CurrentRow == null) || (rbMaped.Checked != true))
  2321. {
  2322. MessageBox.Show("请查询HIS目录对照关系,注意选择已对照!");
  2323. return;
  2324. }
  2325. int iMapped = dgvHISDirectory.CurrentRow.Index;
  2326. string insuCode = dgvHISDirectory.Rows[iMapped].Cells["insuCode"].Value.ToString();
  2327. if (string.IsNullOrEmpty(insuCode))
  2328. {
  2329. MessageBox.Show("未检测到对应的医保目录,请检查该目录是否已对照!");
  2330. return;
  2331. }
  2332. JObject jo = new JObject();
  2333. jo.Add("code", dgvHISDirectory.Rows[iMapped].Cells["insuCode"].Value.ToString());
  2334. jo.Add("HisType", rbgDirecType_C.SelectedIndex + 1);
  2335. string error;
  2336. if (updateSelfRatioInfo(jo, out error) != 0)
  2337. {
  2338. MessageBox.Show($"更新失败{error}");
  2339. }
  2340. else
  2341. {
  2342. MessageBox.Show("更新成功!");
  2343. }
  2344. }
  2345. private void tsmUpdateSelfRatioOfAllMapped_Click(object sender, EventArgs e)
  2346. {
  2347. batchUpdateMappedInsuInfo(updateSelfRatioWrapper);
  2348. }
  2349. public int UpdateDictionaryBySelf(AddSingleDictionary addDic, out string errMsg)
  2350. {
  2351. string outParam = "", HBDictionaryDr = "";
  2352. JObject joRtn;
  2353. JObject jo = addDic.joPamam;
  2354. try
  2355. {
  2356. //if (JsonHelper.getDestValue(jo, "operateType") == "0")
  2357. //{
  2358. //插入并获取字典主表的DR
  2359. JObject joDic = JObject.FromObject(jo["dicObj"]);
  2360. joRtn = mIS.insertDictionary(joDic);
  2361. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  2362. {
  2363. return -1;
  2364. }
  2365. else
  2366. {
  2367. HBDictionaryDr = JsonHelper.getDestValue(joRtn, "data.HBDictionaryDr");
  2368. if (HBDictionaryDr == "")
  2369. {
  2370. errMsg = "HBDictionaryDr返回值为空";
  2371. return -1;
  2372. }
  2373. }
  2374. //}
  2375. //else
  2376. //{
  2377. // if (addDic.dr != null)
  2378. // {
  2379. // HBDictionaryDr = addDic.dr["hBDictionaryID"].ToString();
  2380. // }
  2381. // else
  2382. // {
  2383. // errMsg = "修改状态下未获得字典主表ID!请联系管理员";
  2384. // return -1;
  2385. // }
  2386. //}
  2387. //插入明细表
  2388. JObject joDicDetail = JObject.FromObject(jo["detailObj"]);
  2389. joDicDetail.Add("HBDictionaryDr", HBDictionaryDr);
  2390. JArray jaParams = new JArray();
  2391. jaParams.Add(joDicDetail);
  2392. joRtn = mIS.insertDictionaryDataDetail(jaParams);
  2393. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  2394. {
  2395. return -1;
  2396. }
  2397. else
  2398. {
  2399. return 0;
  2400. }
  2401. }
  2402. catch (Exception ex)
  2403. {
  2404. errMsg = ex.Message;
  2405. return -1;
  2406. }
  2407. }
  2408. private string SelectExcelFile()
  2409. {
  2410. //打开窗口选择文件
  2411. OpenFileDialog openFileDialog = new OpenFileDialog
  2412. {
  2413. InitialDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop), // 设置初始目录
  2414. Filter = "Excel files (*.xlsx)|*.xlsx", // 设置文件过滤器
  2415. FilterIndex = 1, // 设置默认的文件过滤器索引
  2416. RestoreDirectory = true // 对话框关闭前是否恢复原始目录
  2417. };
  2418. string selectedFilePath = "";
  2419. if (openFileDialog.ShowDialog() == DialogResult.OK)
  2420. {
  2421. selectedFilePath = openFileDialog.FileName;
  2422. }
  2423. return selectedFilePath;
  2424. }
  2425. private int ImportMapRelation(object[] o, out string errMsg, DataLoader.ProgressCallback callback, DataLoader.ProgressMaxCallback maxCallback, BackgroundWorker worker)
  2426. {
  2427. int iFalse = 0;
  2428. string err = "";
  2429. string excelPath = o[0].ToString();
  2430. errMsg = "";
  2431. //加载EXCEL
  2432. using (ExcelPackage package = new ExcelPackage(excelPath))
  2433. {
  2434. ExcelWorksheet worksheet = package.Workbook.Worksheets[0];
  2435. int colCount = worksheet.Dimension.End.Column; //get Column Count
  2436. int rowCount = worksheet.Dimension.End.Row ; //get row count
  2437. if (maxCallback != null)
  2438. {
  2439. maxCallback(rowCount - 1); //去除首行
  2440. }
  2441. //建立索引字典
  2442. Dictionary<string, int> indexDic = new Dictionary<string, int>();
  2443. //通过第一行来确定每列的数据与后台对应关系
  2444. for (int col = 1; col <= colCount; col++)
  2445. {
  2446. string colHearder = worksheet.Cells[1, col].Value?.ToString().Trim();
  2447. switch (colHearder)
  2448. {
  2449. case "HIS编码":
  2450. indexDic.Add("HISCode", col);
  2451. break;
  2452. case "HIS名称":
  2453. indexDic.Add("HISName", col);
  2454. break;
  2455. case "目录类型":
  2456. indexDic.Add("HisType", col);
  2457. break;
  2458. case "医保编码":
  2459. indexDic.Add("InsuCode", col);
  2460. break;
  2461. case "医保名称":
  2462. indexDic.Add("InsuName", col);
  2463. break;
  2464. default:
  2465. break;
  2466. }
  2467. }
  2468. Global.writeLog(JsonConvert.SerializeObject(indexDic));
  2469. JArray jaTmp = new JArray();
  2470. for (int row = 2; row <= rowCount; row++)
  2471. {
  2472. // 检查是否应取消操作
  2473. if (worker.CancellationPending)
  2474. {
  2475. errMsg = "操作取消!";
  2476. return -1; // 或者其他表示取消的返回值
  2477. }
  2478. JObject joTmp = new JObject();
  2479. //for (int col = 1; col <= colCount; col++)
  2480. //{
  2481. joTmp.Add("HospitalDr", Global.inf.hospitalDr); //医院编号
  2482. joTmp.Add("InterfaceDr", Global.inf.interfaceDr); // 接口编号 - HBMedInsuInterface 类型(假设用字符串表示)
  2483. //joTmp.Add("ChargeItemDr", worksheet.Cells[row, indexDic["ChargeItemDr"]]?.Value?.ToString().Trim()); // 收费项ID - %Integer
  2484. joTmp.Add("HISCode", worksheet.Cells[row, indexDic["HISCode"]]?.Value?.ToString().Trim()); // HIS编码 - %String
  2485. joTmp.Add("HISName", worksheet.Cells[row, indexDic["HISName"]]?.Value?.ToString().Trim()); // HIS名称 - %String
  2486. //joTmp.Add("DiretoryDr", worksheet.Cells[row, indexDic["Direcotry_Dr"]]?.Value?.ToString().Trim()); // 医保目录Dr - HBMedInsuDirectory(字符串处理)
  2487. joTmp.Add("HisType", worksheet.Cells[row, indexDic["HisType"]]?.Value?.ToString().Trim()); // 医院目录类型 - %String
  2488. joTmp.Add("State", "1"); // 状态 - 1.已对照 2.已对照但未上传 3 已对照且已上传
  2489. joTmp.Add("UpdateDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); // 更新时间 - %DateTime
  2490. joTmp.Add("InsuCode", worksheet.Cells[row, indexDic["InsuCode"]]?.Value?.ToString().Trim()); // 医保编码 - %String
  2491. joTmp.Add("InsuName", worksheet.Cells[row, indexDic["InsuName"]]?.Value?.ToString().Trim()); // 医保名称
  2492. //}
  2493. jaTmp.Add(joTmp);
  2494. if (callback != null)
  2495. {
  2496. callback(row - 1);
  2497. }
  2498. //每50条传一次
  2499. if (((row - 1) % 50 == 0) || ((row + 0) == rowCount))
  2500. {
  2501. JObject joIn = new JObject();
  2502. joIn.Add(new JProperty("params", jaTmp));
  2503. joIn.Add("code", "09010040");
  2504. InvokeHelper invoker = new InvokeHelper();
  2505. JObject joRtn = invoker.invokeInsuService(joIn.ToString(), "导入对照关系");
  2506. // 更新对照关系表返回的数据
  2507. if (JsonHelper.parseIrisRtnValue(joRtn, out err) != 0)
  2508. {
  2509. iFalse++;
  2510. errMsg = errMsg + "\r\n" + err;
  2511. }
  2512. jaTmp = new JArray();
  2513. }
  2514. }
  2515. }
  2516. return iFalse ;
  2517. }
  2518. private void tsmImportMapRelation_Click(object sender, EventArgs e)
  2519. {
  2520. object[] o = new object[] { SelectExcelFile() } ;
  2521. DataLoader _dataLoader;
  2522. _dataLoader = new DataLoader(ImportMapRelation, this);
  2523. _dataLoader.SetProgressBar(ProgressBarStyle.Continuous, "正在导入...", 50);
  2524. _dataLoader.Start(o,(result, errMsg) =>
  2525. {
  2526. MessageBox.Show(errMsg);
  2527. });
  2528. }
  2529. private void tsmImportExcelDir_Click(object sender, EventArgs e)
  2530. {
  2531. object[] o = new object[] { SelectExcelFile() };
  2532. DataLoader _dataLoader;
  2533. _dataLoader = new DataLoader(ImportExcelDir, this);
  2534. _dataLoader.SetProgressBar(ProgressBarStyle.Continuous, "正在导入...", 50);
  2535. _dataLoader.Start(o, (result, errMsg) =>
  2536. {
  2537. MessageBox.Show(errMsg);
  2538. });
  2539. }
  2540. private int ImportExcelDir(object[] o, out string errMsg, DataLoader.ProgressCallback callback, DataLoader.ProgressMaxCallback maxCallback, BackgroundWorker worker)
  2541. {
  2542. int iFalse = 0;
  2543. string err = "";
  2544. string excelPath = o[0]?.ToString();
  2545. if (string.IsNullOrEmpty(excelPath))
  2546. {
  2547. errMsg = "文件路径无效。";
  2548. return -1;
  2549. }
  2550. // 定义字段映射:Excel列名 -> JSON字段名
  2551. var columnMapping = new Dictionary<string, string>
  2552. {
  2553. //{ "医院编号", "HospitalDr" },
  2554. //{ "接口编号", "InterfaceDr" },
  2555. { "医保编码", "Code" },
  2556. { "医保名称", "Name" },
  2557. { "医院目录类型", "HisType" },
  2558. { "医院类型名称", "HisTypeName" },
  2559. { "医保本地编码", "LocateCode" },
  2560. { "医保本地名称", "LocateName" },
  2561. { "本位码", "DrugSafetyStandardCode" },
  2562. { "剂型编码", "DosageFormCode" },
  2563. { "剂型名称", "DosageFormName" },
  2564. { "类别编码", "CategoryCode" },
  2565. { "类别名称", "CategoryName" },
  2566. { "规格", "Specification" },
  2567. { "规格代码", "SpecificationCode" },
  2568. { "包装单位", "UnitOfPackag" },
  2569. { "计价单位", "UnitOfValuation" },
  2570. { "开始日期", "StartDate" },
  2571. { "结束日期", "EndDate" },
  2572. { "拼音助记码", "PinyinSearchCode" },
  2573. { "说明", "Instructions" },
  2574. { "除外内容", "ExceptContent" },
  2575. { "项目内涵", "Connotation" },
  2576. { "有效标志", "ValidFlag" },
  2577. { "备注", "Note" },
  2578. { "批准文号", "ApprovalNO" },
  2579. { "版本号", "VersionNO" },
  2580. { "版本名称", "VersionName" },
  2581. { "使用标志", "UseFlag" },
  2582. { "特殊药品标志", "SpecialFlag" },
  2583. { "限制标志", "LimitFlag" },
  2584. { "限制范围", "LimitRange" },
  2585. { "唯一记录号", "UniqueRecordNO" },
  2586. { "厂家", "Manufacturers" },
  2587. { "国家项目编码", "NationalCode" },
  2588. { "国家项目名称", "NationalName" },
  2589. { "更新时间", "UpdateTime" },
  2590. { "收费项目等级", "ChargeItemLevel" },
  2591. { "收费项目等级名称", "ChargeItemLevelName" },
  2592. { "自付比例", "SelfPercent" },
  2593. { "医疗收费项目类别", "ChargeItemType" },
  2594. { "收费标准", "ChargeStandards" },
  2595. { "最高限价", "CeilingPrice" },
  2596. { "包装材质", "PackagingMaterial" },
  2597. { "最小包装数量", "MinPackagingQuantity" },
  2598. { "最小制剂单位", "MinDosageUnit" },
  2599. { "最小包装单位", "MinPackagingUnit" },
  2600. { "累计增负标志", "CumulativeNegativeBurdenFlag" },
  2601. { "目录类型", "ListType" },
  2602. { "目录支付比例", "DirectoryPayPercent" }
  2603. };
  2604. errMsg = "";
  2605. //加载EXCEL
  2606. using (ExcelPackage package = new ExcelPackage(excelPath))
  2607. {
  2608. var worksheet = package.Workbook.Worksheets[0];
  2609. int colCount = worksheet.Dimension?.Columns ?? 0;
  2610. int rowCount = worksheet.Dimension?.Rows ?? 0;
  2611. if (rowCount < 2)
  2612. {
  2613. errMsg = "Excel 文件中没有有效的数据行。";
  2614. return -1;
  2615. }
  2616. if (maxCallback != null)
  2617. maxCallback(rowCount - 1);
  2618. // 建立索引字典
  2619. var indexDic = new Dictionary<string, int>();
  2620. for (int col = 1; col <= colCount; col++)
  2621. {
  2622. var header = worksheet.Cells[1, col].Value?.ToString().Trim();
  2623. if (columnMapping.TryGetValue(header, out string jsonField))
  2624. {
  2625. indexDic[jsonField] = col;
  2626. }
  2627. else
  2628. {
  2629. // 可选:记录未识别的列头
  2630. Global.writeLog($"未知列头: {header}");
  2631. }
  2632. }
  2633. Global.writeLog(JsonConvert.SerializeObject(indexDic));
  2634. JArray jaTmp = new JArray();
  2635. for (int row = 2; row <= rowCount; row++)
  2636. {
  2637. Global.writeLog(callback.Target.GetType().Name);
  2638. // 检查是否应取消操作
  2639. if ( worker.CancellationPending)
  2640. {
  2641. errMsg = "操作取消!";
  2642. return -1; // 或者其他表示取消的返回值
  2643. }
  2644. if (callback != null)
  2645. callback(row - 1);
  2646. JObject joTmp = new JObject();
  2647. foreach (var pair in indexDic)
  2648. {
  2649. string fieldName = pair.Key;
  2650. int colIndex = pair.Value;
  2651. var cellValue = worksheet.Cells[row, colIndex]?.Value?.ToString().Trim();
  2652. joTmp.Add(fieldName, cellValue ?? string.Empty);
  2653. }
  2654. //手动增加医院ID 和接口ID
  2655. joTmp.Add("HospitalDr", Global.inf.hospitalDr); //医院编号
  2656. joTmp.Add("InterfaceDr", Global.inf.interfaceDr); // 接口编号
  2657. jaTmp.Add(joTmp);
  2658. //每50条传一次
  2659. if (((row - 1) % 50 == 0) || ((row ) == rowCount))
  2660. {
  2661. JObject joIn = new JObject();
  2662. joIn.Add(new JProperty("params", jaTmp));
  2663. joIn.Add("code", "09010035");
  2664. InvokeHelper invoker = new InvokeHelper();
  2665. JObject joRtn = invoker.invokeInsuService(joIn.ToString(), "更新医保目录");
  2666. // 更新对照关系表返回的数据
  2667. if (JsonHelper.parseIrisRtnValue(joRtn, out err) != 0)
  2668. {
  2669. iFalse++;
  2670. errMsg = errMsg + "\r\n" + err;
  2671. }
  2672. jaTmp = new JArray();
  2673. }
  2674. }
  2675. }
  2676. if (iFalse == 0)
  2677. {
  2678. errMsg = "全部导入";
  2679. }
  2680. else
  2681. {
  2682. errMsg = "导入有错误,请检查日志";
  2683. }
  2684. return iFalse;
  2685. }
  2686. private void tsmExportMappedDataByLeft_Click(object sender, EventArgs e)
  2687. {
  2688. }
  2689. }
  2690. public class OutParamWrapper
  2691. {
  2692. public string Value { get; set; }
  2693. }
  2694. }