BasicData.cs 102 KB

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