BasicData.cs 126 KB

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