BasicData.cs 60 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547
  1. using Newtonsoft.Json;
  2. using Newtonsoft.Json.Linq;
  3. using PTMedicalInsurance.Business;
  4. using PTMedicalInsurance.Helper;
  5. using PTMedicalInsurance.Variables;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.ComponentModel;
  9. using System.Data;
  10. using System.Drawing;
  11. using System.IO;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Threading.Tasks;
  15. using System.Windows.Forms;
  16. using PTMedicalInsurance.FormSetter;
  17. namespace PTMedicalInsurance.Forms
  18. {
  19. public partial class BasicData : Form
  20. {
  21. //设置实例
  22. CenterBusiness cBus = new CenterBusiness();
  23. HisMainBusiness hBus = new HisMainBusiness();
  24. HisIrisServices hIS = new HisIrisServices();
  25. MIIrisServices mIS = new MIIrisServices();
  26. InvokeHelper invoker = new InvokeHelper();
  27. private JObject joDirInfoOfCenterRtn; //中心返回的目录信息
  28. public BasicData()
  29. {
  30. InitializeComponent();
  31. this.dgvInsuDirInfo.DataError += delegate (object sender, DataGridViewDataErrorEventArgs e) { };//屏蔽单元格错误
  32. rbgDirecType.SelectedIndex = 0;
  33. rbgDirecType_C.SelectedIndex = 0;
  34. rbgDownType_3.SelectedIndex = 5;
  35. rbSingleDown.Checked = true;
  36. this.rbgDirecType.ValueChanged += new Sunny.UI.UIRadioButtonGroup.OnValueChanged(this.rbgDirecType_ValueChanged);
  37. this.pgDownload.PageChanged += new Sunny.UI.UIPagination.OnPageChangeEventHandler(this.pgDownload_PageChanged);
  38. this.pgCenterDirect.PageChanged += new Sunny.UI.UIPagination.OnPageChangeEventHandler(this.pgCenterDirect_PageChanged);
  39. Font rowFont = new Font("UTF-8", 8);
  40. Font columnFont = new Font("UTF-8", 9);
  41. rbgDirecType.SelectedIndex = 8;
  42. rbAll.Checked = true;
  43. GridViewSetter gvs = new GridViewSetter();
  44. gvs.SetHeaderTextOfLimitPrice(dgvLimitPriceInfo);
  45. gvs.SetHeaderTextOfSelfPay(dgvSelfPayRiotInfo);
  46. gvs.SetHeaderTextOfInsuDir(dgvInsuDirInfo);
  47. }
  48. #region 函数封装
  49. private void queryInsuDirectory(int currentPage, int pageSize, int directoryType,int interfaceDr,string code)
  50. {
  51. try
  52. {
  53. string dirCode = "";
  54. string dirName = "";
  55. string approvalNO = "";
  56. Sunny.UI.UIDataGridView dgv;
  57. Sunny.UI.UIPagination pg;
  58. if (tbBasicData.SelectedIndex == 0)
  59. {
  60. dirCode = tbDirectoryCode.Text;
  61. dirName = tbDircetoryName.Text;
  62. approvalNO = "";
  63. dgv = dgvDirectoy;
  64. pg = pgDownload;
  65. }
  66. else
  67. {
  68. dirName = tbCenterDirectoryFilter.Text;
  69. dirCode = tbInsuCode.Text;
  70. dgv = dgvCenterDirectory;
  71. approvalNO = tbApprovalNO.Text;
  72. pg = pgCenterDirect;
  73. }
  74. JObject joInput = new JObject {
  75. { "currentPage" , currentPage },
  76. { "pageSize" , pageSize },
  77. { "serviceCode" , code },
  78. { "directoryType" , directoryType },
  79. { "directoryCode" , dirCode },
  80. { "directoryName" , dirName },
  81. { "approvalNO" , approvalNO },
  82. { "directoryDr" , interfaceDr }
  83. };
  84. if ((rbgDirecType.SelectedIndex == 8) && (tbDicType.Text != ""))
  85. {
  86. joInput.Add("type",tbDicType.Text);
  87. }
  88. JObject joRtn = mIS.getMIDirectoryByPagination(joInput);
  89. if (joRtn["errorCode"].ToString() != "0")
  90. {
  91. MessageBox.Show("IRIS数据返回错误:" + joRtn["errorMessage"].ToString());
  92. return;
  93. }
  94. if (joRtn["result"]["rows"] == null)
  95. {
  96. MessageBox.Show("该节点不存在");
  97. return;
  98. }
  99. if (joRtn["result"]["total"].ToString() == "0")
  100. {
  101. MessageBox.Show("未查询到数据");
  102. dgv.DataSource = null;
  103. return;
  104. }
  105. DataTable dt = (DataTable)joRtn["result"]["rows"].ToObject(typeof(DataTable));
  106. int totalCount = int.Parse(joRtn["result"]["total"].ToString());
  107. pg.TotalCount = totalCount;
  108. pg.PageSize = pageSize;
  109. dgv.DataSource = dt;
  110. dgv.Columns[0].ReadOnly = true;
  111. }
  112. catch (Exception ex)
  113. {
  114. MessageBox.Show("查询异常:" + ex.Message);
  115. }
  116. }
  117. private void setHeaderTxt(int directoryType, Sunny.UI.UIDataGridView dgv)
  118. {
  119. GridViewSetter gvdSetter = new GridViewSetter();
  120. switch (directoryType)
  121. {
  122. case 0://药品
  123. {
  124. gvdSetter.SetHeaderTextOfDrug(dgv);
  125. break;
  126. }
  127. case 1://诊疗
  128. {
  129. gvdSetter.SetHeaderTextOfMedicalService(dgv);
  130. break;
  131. }
  132. case 2://材料
  133. {
  134. gvdSetter.SetHeaderTextOfMaterials(dgv);
  135. break;
  136. }
  137. case 3://疾病诊断
  138. {
  139. gvdSetter.SetHeaderTextOfDiagnose(dgv);
  140. break;
  141. }
  142. case 4://手术
  143. {
  144. gvdSetter.SetHeaderTextOfDiagnose(dgv);
  145. break;
  146. }
  147. case 5://慢性病
  148. {
  149. gvdSetter.SetHeaderTextOfDiagnose(dgv);
  150. break;
  151. }
  152. case 6://DRGs
  153. {
  154. gvdSetter.SetHeaderTextOfDiagnose(dgv);
  155. break; ;
  156. }
  157. case 7://日间手术
  158. {
  159. gvdSetter.SetHeaderTextOfDiagnose(dgv);
  160. break; ;
  161. }
  162. case 8://字典表
  163. {
  164. gvdSetter.SetHeaderTextOfDictionary(dgv);
  165. break;
  166. }
  167. }
  168. }
  169. private void queryHISInsuDirectory(int directoryType, int pageIndex, int count, Sunny.UI.UIDataGridView dgv, int interfaceDr)
  170. {
  171. string code = "09010042";
  172. if (tbBasicData.SelectedIndex == 0)
  173. {
  174. if (rbgDirecType.SelectedIndex == 8)
  175. { code = "09010043"; }
  176. }
  177. queryInsuDirectory(pageIndex, count, directoryType + 1, interfaceDr, code);
  178. setHeaderTxt(directoryType, dgv);
  179. }
  180. private int queryHISDirectory(int currentPage, int pageSize,out string errMsg)
  181. {
  182. errMsg = "";
  183. string directoryType = string.Empty;
  184. switch (rbgDirecType_C.SelectedIndex)
  185. {
  186. case 0:
  187. {
  188. directoryType = "drugs";
  189. break;
  190. }
  191. case 1:
  192. {
  193. directoryType = "diagnosi";
  194. break;
  195. }
  196. case 2:
  197. {
  198. directoryType = "consumables";
  199. break;
  200. }
  201. }
  202. JObject joHISRtn = new JObject();
  203. JObject joRtn = new JObject();
  204. InvokeHelper invoker = new InvokeHelper();
  205. string flag = "";
  206. //全部是先调HIS,然后再匹配医保平台的对照关系
  207. if (rbAll.Checked) {
  208. JArray jaPagination = new JArray();
  209. JArray jaParams = new JArray();
  210. flag = "All";
  211. dynamic joParam = new JObject();
  212. joParam.code = "";
  213. joParam.descripts = "";
  214. joParam.FindType = new JArray();
  215. joParam.TypeID = "";
  216. joParam.alias = tbHISDirectoryFilter.Text;
  217. joParam.include = "Hosp";
  218. joParam.groupID = "324";
  219. joParam.hospID = Global.inf.hisHospitalDr;
  220. joParam.interfaceDr = Global.inf.interfaceDr;
  221. joParam.type = directoryType;
  222. joParam.flag = flag;
  223. joParam.specInput = "";
  224. jaParams.Add(joParam);
  225. dynamic joPagination = new JObject();
  226. joPagination.pageSize = pageSize;
  227. //joPagination.pageSize = 2;
  228. joPagination.currentPage = currentPage;
  229. joPagination.sortColumn = "Code";
  230. joPagination.sortOrder = "asc";
  231. jaPagination.Add(joPagination);
  232. //该服务需要改写,需要跟(CloudMedicalInsurancePlatform.Tables.MapRelation)进行关联
  233. //joInParams.code = "09010038";
  234. if (hIS.getHISDir(jaPagination, jaParams,out joHISRtn, out errMsg) != 0)
  235. {
  236. return -1;
  237. }
  238. joRtn = mIS.ConvertHISDir(joHISRtn);
  239. if (JsonHelper.parseIrisRtnValue(joRtn,out errMsg) != 0)
  240. {
  241. return -1;
  242. }
  243. }
  244. //已对照是先调云医保,然后再匹配HIS
  245. if (rbMaped.Checked) {
  246. dgvHISDirectory.DataSource = null;
  247. JArray jaPagination = new JArray();
  248. JArray jaParams = new JArray();
  249. flag = "Maped";
  250. dynamic joParam = new JObject();
  251. joParam.alias = tbHISDirectoryFilter.Text;
  252. joParam.HospitalDr = Global.inf.hospitalDr;
  253. joParam.InterfaceDr = Global.inf.interfaceDr;
  254. joParam.hisType = directoryType;
  255. jaParams.Add(joParam);
  256. dynamic joPagination = new JObject();
  257. joPagination.pageSize = pageSize;
  258. joPagination.currentPage = currentPage;
  259. joPagination.sortColumn = "HisCode";
  260. joPagination.sortOrder = "asc";
  261. jaPagination.Add(joPagination);
  262. JObject joMIRtn = mIS.GetMappedHISDir(jaPagination,jaParams);
  263. if (JsonHelper.parseIrisRtnValue(joMIRtn, out errMsg) != 0)
  264. {
  265. return -1;
  266. }
  267. //传给HIS,进行匹配
  268. joParam = new JObject();
  269. joParam.TotalCount = joMIRtn["result"]["TotalCount"];
  270. JArray jaMIRtn = JArray.Parse(JsonHelper.getDestValue(joMIRtn, "result.Data"));
  271. if (jaMIRtn.Count == 0)
  272. {
  273. errMsg = "未查询到已对照数据!";
  274. return -1;
  275. }
  276. joParam.type = directoryType;
  277. joParam.flag = flag;
  278. joParam.hospID = Global.inf.hisHospitalDr;
  279. joParam.interfaceDr = Global.inf.interfaceDr;
  280. joParam.alias = tbHISDirectoryFilter.Text;
  281. joParam.include = "Hosp";
  282. joParam.groupID = "324";
  283. joParam.compareArr = joMIRtn["result"]["Data"];
  284. jaParams = new JArray();
  285. jaParams.Add(joParam);
  286. if (hIS.getHISDir(jaPagination, jaParams, out joRtn, out errMsg) != 0)
  287. {
  288. return -1;
  289. }
  290. else
  291. {
  292. JArray jaData = JArray.Parse(JsonHelper.getDestValue(joRtn,"result.Data"));
  293. for (int i = 0; i < jaData.Count; i++)
  294. {
  295. jaData[i]["flag"] = new JObject();
  296. jaData[i]["flag"] = "已对照";
  297. }
  298. joRtn["result"]["Data"] = jaData;
  299. Global.writeLog(joRtn.ToString());
  300. }
  301. }
  302. if (rbNoMaped.Checked) { flag = "NoMaped"; }
  303. DataTable dt = (DataTable)joRtn["result"]["Data"].ToObject(typeof(DataTable));
  304. int totalCount = int.Parse(joRtn["result"]["TotalCount"].ToString());
  305. pgHISDirect.TotalCount = totalCount;
  306. pgHISDirect.PageSize = 50;
  307. dgvHISDirectory.DataSource = dt;
  308. dgvHISDirectory.Columns[0].ReadOnly = true;
  309. return 0;
  310. }
  311. private void queryCenterDirectory_09010012(int currentPage, int pageSize)
  312. {
  313. string directoryType = string.Empty;
  314. switch (rbgDirecType_C.SelectedIndex)
  315. {
  316. case 0:
  317. {
  318. directoryType = "drugs";
  319. break;
  320. }
  321. case 1:
  322. {
  323. directoryType = "diagnosi";
  324. break;
  325. }
  326. case 2:
  327. {
  328. directoryType = "consumables";
  329. break;
  330. }
  331. }
  332. dynamic joInParams = new JObject();
  333. joInParams.pagination = new JArray() as dynamic;
  334. joInParams.session = new JArray() as dynamic;
  335. JArray jaParams = new JArray();
  336. dynamic joParams = new JObject();
  337. joParams.code = "";
  338. joParams.descripts = "";
  339. joParams.FindType = new JArray();
  340. joParams.TypeID = "";
  341. joParams.alias = "";
  342. joParams.include = "Hosp";
  343. joParams.groupID = "324";
  344. joParams.hospID = "25";
  345. joParams.type = directoryType;
  346. joParams.specInput = "";
  347. jaParams.Add(joParams);
  348. joInParams.Add("params", JArray.FromObject(jaParams));
  349. dynamic joSession = new JObject();
  350. joSession.userID = "";
  351. joSession.locID = "";
  352. joSession.groupID = "";
  353. joSession.hospID = "";
  354. joSession.sessionID = "";
  355. joSession.hospCode = "";
  356. joSession.language = "";
  357. joSession.hostName = "";
  358. joSession.ipv4 = "";
  359. joSession.ipv6 = "";
  360. joSession.mac = "";
  361. joInParams.session.Add(joSession);
  362. dynamic joPagination = new JObject();
  363. joPagination.pageSize = pageSize;
  364. joPagination.currentPage = currentPage;
  365. joPagination.sortColumn = "Code";
  366. joPagination.sortOrder = "asc";
  367. joInParams.pagination.Add(joPagination);
  368. joInParams.code = "09010012";
  369. string sInput = joInParams.ToString();
  370. string sRtn = invoker.invokeInsuService(joInParams,"");
  371. JObject jsonRtn = JObject.Parse(sRtn);
  372. if (jsonRtn["result"]["Data"] == null)
  373. {
  374. MessageBox.Show("该节点不存在");
  375. return;
  376. }
  377. JObject joRtn = JObject.Parse(sRtn);
  378. DataTable dt = (DataTable)joRtn["result"]["Data"].ToObject(typeof(DataTable));
  379. int totalCount = int.Parse(joRtn["result"]["TotalCount"].ToString());
  380. pgCenterDirect.TotalCount = totalCount;
  381. pgCenterDirect.PageSize = 50;
  382. dgvCenterDirectory.DataSource = dt;
  383. }
  384. private void Mapping()
  385. {
  386. int iHis = dgvHISDirectory.CurrentRow.Index;
  387. if (dgvCenterDirectory.CurrentRow == null)
  388. {
  389. MessageBox.Show("请查询中心目录");
  390. return;
  391. }
  392. int iCenter = dgvCenterDirectory.CurrentRow.Index;
  393. DataTable dtHis = (DataTable)dgvHISDirectory.DataSource;
  394. DataTable dtCenter = (DataTable)dgvCenterDirectory.DataSource;
  395. dgvHISDirectory.Rows[iHis].Cells["insuCode"].Value = dgvCenterDirectory.Rows[iCenter].Cells["Code"].Value.ToString();
  396. dgvHISDirectory.Rows[iHis].Cells["insuName"].Value = dgvCenterDirectory.Rows[iCenter].Cells["Name"].Value.ToString();
  397. int hisType = rbgDirecType_C.SelectedIndex + 1;
  398. string hisTypeName = rbgDirecType_C.Items[hisType-1].ToString(); ;
  399. JArray jaParams = new JArray();
  400. dynamic jsonTemp = new JObject();
  401. if (dtHis.Rows[iHis]["MapID"].ToString() == "0")
  402. {
  403. jsonTemp.ID = "";
  404. }
  405. else
  406. {
  407. jsonTemp.ID = dtHis.Rows[iHis]["MapID"];
  408. }
  409. jsonTemp.HospitalDr = Global.inf.hospitalDr;
  410. jsonTemp.updateUserID = Global.user.ID;
  411. jsonTemp.InterfaceDr = Global.inf.interfaceDr;
  412. jsonTemp.HISCode = dgvHISDirectory.Rows[iHis].Cells["itemCode"].Value;
  413. jsonTemp.HISName = dgvHISDirectory.Rows[iHis].Cells["itemDesc"].Value;
  414. jsonTemp.ChargeItemDr = dtHis.Rows[iHis]["ID"];
  415. jsonTemp.DiretoryDr = dtCenter.Rows[iCenter]["medInsuDirectoryID"];
  416. //1.已对照 2.已对照但未上传 3 已对照且已上传
  417. jsonTemp.State = 1;
  418. jsonTemp.HisType = hisType;
  419. jsonTemp.HisTypeName = hisTypeName;
  420. jsonTemp.InsuCode = dgvCenterDirectory.Rows[dgvCenterDirectory.CurrentRow.Index].Cells["Code"].Value;
  421. jsonTemp.InsuName = dgvCenterDirectory.Rows[dgvCenterDirectory.CurrentRow.Index].Cells["Name"].Value;
  422. jsonTemp.UpdateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  423. jaParams.Add(jsonTemp);
  424. JObject joIn = new JObject();
  425. joIn.Add(new JProperty("params", jaParams));
  426. joIn.Add("code", "09010040");
  427. InvokeHelper invoker = new InvokeHelper();
  428. JObject joRtn = invoker.invokeInsuService(joIn.ToString(),"插入对照信息");
  429. //JObject joRtn = JObject.Parse(irisRtn);
  430. if ((int)joRtn["errorCode"] == 0)
  431. {
  432. dgvHISDirectory.Rows[iHis].Cells["flag"].Value = "已对照";
  433. }
  434. else
  435. {
  436. dgvHISDirectory.Rows[iHis].Cells["flag"].Value = "对照失败";
  437. }
  438. }
  439. private void CancleMapping()
  440. {
  441. int iHis = dgvHISDirectory.CurrentRow.Index;
  442. DataTable dtHis = (DataTable)dgvHISDirectory.DataSource;
  443. JArray jaParams = new JArray();
  444. dynamic jsonTemp = new JObject();
  445. jsonTemp.ID = dtHis.Rows[iHis]["MapID"];
  446. jsonTemp.HospitalDr = Global.inf.hospitalDr;
  447. jsonTemp.updateUserID = Global.user.ID;
  448. jsonTemp.InterfaceDr = Global.inf.interfaceDr;
  449. jsonTemp.HISCode = dgvHISDirectory.Rows[iHis].Cells["itemCode"].Value;
  450. jsonTemp.UpdateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  451. jaParams.Add(jsonTemp);
  452. JObject joIn = new JObject();
  453. joIn.Add(new JProperty("params", jaParams));
  454. joIn.Add("code", "09010041");
  455. InvokeHelper invoker = new InvokeHelper();
  456. JObject joRtn = invoker.invokeInsuService(joIn.ToString(),"取消对照");
  457. if ((int)joRtn["errorCode"] == 0)
  458. {
  459. dgvHISDirectory.Rows[iHis].Cells["insuCode"].Value = "";
  460. dgvHISDirectory.Rows[iHis].Cells["insuName"].Value = "";
  461. dgvHISDirectory.Rows[iHis].Cells["flag"].Value = "未对照";
  462. dtHis.Rows[iHis]["MapID"] = 0;
  463. }
  464. else
  465. {
  466. dgvHISDirectory.Rows[iHis].Cells["flag"].Value = "取消失败";
  467. }
  468. }
  469. /// <summary>
  470. /// 医保目录单个版本号的下载
  471. /// </summary>
  472. /// <param name="ver"></param>
  473. /// <param name="directoryType"></param>
  474. /// <param name="uiProcessBar"></param>
  475. /// <param name="errorMessage"></param>
  476. /// <returns></returns>
  477. public int SingleDownload(string ver, int directoryType, Sunny.UI.UIProcessBar uiProcessBar, out string errorMessage)
  478. {
  479. string txtPath = string.Empty;
  480. errorMessage = "";
  481. int iResult = -1;
  482. string funNo = "";
  483. switch (directoryType)
  484. {
  485. case 0://药品
  486. {
  487. funNo = "1301"; //"1301";
  488. break;
  489. }
  490. case 1://诊疗
  491. {
  492. funNo = "1365";
  493. break;
  494. }
  495. case 2://材料
  496. {
  497. funNo = "1364";
  498. break;
  499. }
  500. case 3://疾病诊断
  501. {
  502. funNo = "1307";
  503. break;
  504. }
  505. case 4://手术
  506. {
  507. funNo = "1308";
  508. break;
  509. }
  510. case 5://慢性病
  511. {
  512. funNo = "1309";
  513. break;
  514. }
  515. case 6://DRGs
  516. {
  517. funNo = "1310";
  518. break; ;
  519. }
  520. case 7://日间手术
  521. {
  522. funNo = "1311";
  523. break;
  524. }
  525. case 8://字典表
  526. {
  527. break;
  528. }
  529. }
  530. try
  531. {
  532. JObject joRtn = hBus.DownloadDirectory(funNo, ver);
  533. if (JsonHelper.parseCenterRtnValue(joRtn, out errorMessage) == 0)
  534. {
  535. txtPath = joRtn["filePath"].ToString();
  536. DataImoport bus = new DataImoport();
  537. JObject joImportRtn = bus.importDataToIrisByTxt(txtPath, 50, directoryType + 1, uiProcessBar);
  538. if (JsonHelper.parseCenterRtnValue(joImportRtn, out errorMessage) == 0)
  539. {
  540. iResult = 0;
  541. }
  542. else
  543. {
  544. errorMessage = "导入数据出现错误,请查看日志!";//joImportRtn["errorMessage"].ToString();
  545. }
  546. }
  547. return iResult;
  548. }
  549. catch (Exception ex)
  550. {
  551. errorMessage = "SingleDownload提示:" + ex.Message;
  552. return -1;
  553. }
  554. }
  555. /// <summary>
  556. /// 医保目录单个版本号的下载
  557. /// </summary>
  558. /// <param name="ver"></param>
  559. /// <param name="directoryType"></param>
  560. /// <param name="uiProcessBar"></param>
  561. /// <param name="errorMessage"></param>
  562. /// <returns></returns>
  563. public int downloadDicionary(JObject joData, Sunny.UI.UIProcessBar uiProcessBar, out string errorMessage)
  564. {
  565. errorMessage = "";
  566. int iResult = -1;
  567. try
  568. {
  569. JObject joRtn = cBus.DownDictionay(joData);
  570. if (JsonHelper.parseCenterRtnValue(joRtn, out errorMessage) == 0)
  571. {
  572. DataImoport DI = new DataImoport();
  573. JArray jaList = JArray.Parse(JsonHelper.getDestValue(joRtn, "output.list"));
  574. JObject joImportRtn = DI.importDictionary(uiProcessBar, jaList, tbDicType.Text);
  575. if (JsonHelper.parseIrisRtnValue(joImportRtn, out errorMessage) == 0)
  576. {
  577. iResult = 0;
  578. }
  579. else
  580. {
  581. errorMessage = "导入数据出现错误,请查看日志!" + errorMessage;
  582. }
  583. }
  584. return iResult;
  585. }
  586. catch (Exception ex)
  587. {
  588. errorMessage = "downloadDicionary提示:" + ex.Message;
  589. return -1;
  590. }
  591. }
  592. /// <summary>
  593. /// 自动下载医保目录,直到最新版本(返回报错)
  594. /// </summary>
  595. /// <param name="directoryType"></param>
  596. /// <param name="uiProcessBar"></param>
  597. /// <param name="errorMessage"></param>
  598. /// <returns></returns>
  599. public int AutoDownload(int directoryType, Sunny.UI.UIProcessBar uiProcessBar, out string errorMessage)
  600. {
  601. int iResult = 0;
  602. errorMessage = "";
  603. try
  604. {
  605. while (iResult == 0)
  606. {
  607. JObject joMaxVerNO = mIS.getDirectoryMaxVersionNO(directoryType);
  608. string ver = joMaxVerNO["result"]["MaxVersionNO"].ToString();
  609. iResult = JsonHelper.parseIrisRtnValue(joMaxVerNO, out errorMessage);
  610. iResult = SingleDownload(ver, directoryType, uiProcessBar, out errorMessage);
  611. }
  612. return iResult;
  613. }
  614. catch (Exception ex)
  615. {
  616. errorMessage = ex.Message;
  617. return -1;
  618. }
  619. }
  620. #endregion
  621. #region 按钮
  622. private void Form1_Load(object sender, EventArgs e)
  623. {
  624. //rbgDirecType.ValueChanged += new Sunny.UI.UIRadioButtonGroup.OnValueChanged(rbgDirecType_ValueChanged);
  625. this.WindowState = FormWindowState.Maximized;
  626. }
  627. private void btnDownload_Click(object sender, EventArgs e)
  628. {
  629. string errorMessage = string.Empty;
  630. if (rbgDirecType.SelectedIndex == 8)
  631. {
  632. dynamic joData = new JObject();
  633. joData.type = tbDicType.Text;
  634. joData.parentValue = "";
  635. joData.admdvs = "";
  636. joData.date = tbDicDate.Text;
  637. joData.vali_flag = "";
  638. if (downloadDicionary(joData, uiProcessBar1,out errorMessage) != 0)
  639. {
  640. MessageBox.Show(errorMessage);
  641. return;
  642. }
  643. }
  644. else
  645. {
  646. if (rbSingleDown.Checked)
  647. {
  648. string ver = tbVer.Text;
  649. if (tbVer.Text != "")
  650. {
  651. ver = tbVer.Text;
  652. }
  653. if (SingleDownload(ver, rbgDirecType.SelectedIndex, uiProcessBar1, out errorMessage) != 0)
  654. {
  655. MessageBox.Show(errorMessage);
  656. return;
  657. }
  658. }
  659. if (rbAutoDown.Checked)
  660. {
  661. if (AutoDownload(rbgDirecType.SelectedIndex, uiProcessBar1, out errorMessage) != 0)
  662. {
  663. MessageBox.Show(errorMessage);
  664. return;
  665. }
  666. }
  667. }
  668. btnQuery_Click(sender, e);
  669. }
  670. private void btnQuery_Click(object sender, EventArgs e)
  671. {
  672. queryHISInsuDirectory(rbgDirecType.SelectedIndex, 1, 20, dgvDirectoy,Global.inf.interfaceDr);
  673. }
  674. private void btnQueryHISDirectory_Click(object sender, EventArgs e)
  675. {
  676. string errMsg;
  677. if (queryHISDirectory(1, 50, out errMsg) != 0)
  678. {
  679. MessageBox.Show(errMsg);
  680. return;
  681. }
  682. GridViewSetter gridSetter = new GridViewSetter();
  683. gridSetter.SetHeaderTextOfMapping_HisDirectory(dgvHISDirectory);
  684. }
  685. private void btnQueryCenterDirectory_Click(object sender, EventArgs e)
  686. {
  687. queryHISInsuDirectory(rbgDirecType_C.SelectedIndex, 1, 50, dgvCenterDirectory, Global.inf.interfaceDr);
  688. }
  689. private void pgDownload_PageChanged(object sender, object pagingSource, int pageIndex, int count)
  690. {
  691. queryHISInsuDirectory(rbgDirecType.SelectedIndex, pageIndex, count,dgvDirectoy, Global.inf.interfaceDr);
  692. }
  693. private void pgHISDirect_PageChanged(object sender, object pagingSource, int pageIndex, int count)
  694. {
  695. string errMsg;
  696. if (queryHISDirectory(pageIndex, 50, out errMsg) != 0)
  697. {
  698. MessageBox.Show(errMsg);
  699. return;
  700. }
  701. }
  702. private void pgCenterDirect_PageChanged(object sender, object pagingSource, int pageIndex, int count)
  703. {
  704. queryHISInsuDirectory(rbgDirecType_C.SelectedIndex, pageIndex, count, dgvCenterDirectory, Global.inf.interfaceDr);
  705. }
  706. private void rbgDirecType_ValueChanged(object sender, int index, string text)
  707. {
  708. btnQuery_Click(null, new EventArgs());
  709. }
  710. private void toolStripMenuItem2_Click(object sender, EventArgs e)
  711. {
  712. CancleMapping();
  713. }
  714. private void tsmiMapping_Click(object sender, EventArgs e)
  715. {
  716. Mapping();
  717. }
  718. private void dgvHISDirectory_DoubleClick(object sender, EventArgs e)
  719. {
  720. int currentPage = pgHISDirect.ActivePage;
  721. string flag = dgvHISDirectory.Rows[dgvHISDirectory.CurrentRow.Index].Cells["flag"].Value.ToString();
  722. if (flag == "未对照")
  723. {
  724. Mapping();
  725. }
  726. else
  727. if (flag == "已对照")
  728. {
  729. // CancleMapping();
  730. }
  731. if (rbAll.Checked)
  732. {
  733. string errMsg;
  734. if (queryHISDirectory(1, 50, out errMsg) != 0)
  735. {
  736. MessageBox.Show(errMsg);
  737. return;
  738. }
  739. }
  740. }
  741. private void dgvDirectoy_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
  742. {
  743. //自动编号,与数据无关
  744. Rectangle rectangle = new Rectangle(e.RowBounds.Location.X,
  745. e.RowBounds.Location.Y,
  746. dgvDirectoy.RowHeadersWidth - 4,
  747. e.RowBounds.Height);
  748. TextRenderer.DrawText(e.Graphics,
  749. (e.RowIndex + 1).ToString(),
  750. dgvDirectoy.RowHeadersDefaultCellStyle.Font,
  751. rectangle,
  752. dgvDirectoy.RowHeadersDefaultCellStyle.ForeColor,
  753. TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
  754. }
  755. private void rbAll_ValueChanged(object sender, bool value)
  756. {
  757. if (rbAll.Checked)
  758. {
  759. btnQueryHISDirectory_Click(null, new EventArgs());
  760. }
  761. }
  762. private void rbMaped_CheckedChanged(object sender, EventArgs e)
  763. {
  764. if (rbMaped.Checked)
  765. {
  766. string errMsg;
  767. if (queryHISDirectory(1, 50, out errMsg) != 0)
  768. {
  769. MessageBox.Show(errMsg);
  770. return;
  771. }
  772. }
  773. }
  774. private void btAddDir_Click(object sender, EventArgs e)
  775. {
  776. AddSingleDirectory addDirectory = new AddSingleDirectory(rbgDirecType.SelectedIndex);
  777. if (addDirectory.ShowDialog() == DialogResult.OK)
  778. {
  779. JObject joRtn = mIS.UpdateDirectoryBySelf(addDirectory.joPamam);
  780. string error = "";
  781. if (JsonHelper.parseIrisRtnValue(joRtn, out error) != 0)
  782. {
  783. MessageBox.Show("新增失败:" + error);
  784. }
  785. else
  786. {
  787. MessageBox.Show("新增成功");
  788. }
  789. }
  790. }
  791. private void btEditDir_Click(object sender, EventArgs e)
  792. {
  793. DataTable dt = (DataTable)dgvDirectoy.DataSource;
  794. if ((dt == null) || (dt.Rows.Count < 1))
  795. {
  796. MessageBox.Show("表中无数据,请检查!");
  797. return;
  798. }
  799. DataRow dr = dt.Rows[dgvDirectoy.CurrentRow.Index];
  800. AddSingleDirectory addDirectory = new AddSingleDirectory(rbgDirecType.SelectedIndex, dr);
  801. if (addDirectory.ShowDialog() == DialogResult.OK)
  802. {
  803. JObject joRtn = mIS.UpdateDirectoryBySelf(addDirectory.joPamam);
  804. string error = "";
  805. if (JsonHelper.parseIrisRtnValue(joRtn, out error) != 0)
  806. {
  807. MessageBox.Show("修改失败:" + error);
  808. }
  809. else
  810. {
  811. MessageBox.Show("修改成功");
  812. }
  813. }
  814. }
  815. private void tsmUpdateDir_Click(object sender, EventArgs e)
  816. {
  817. JObject joData = new JObject();
  818. string outPar = "";
  819. try
  820. {
  821. int dirIndex = dgvDirectoy.CurrentRow.Index;
  822. int type = -1;
  823. switch (rbgDirecType.SelectedIndex)
  824. {
  825. case 0:
  826. type = 0;
  827. break;
  828. case 1:
  829. type = 5;
  830. break;
  831. case 2:
  832. type = 4;
  833. break;
  834. }
  835. if (type == -1)
  836. {
  837. MessageBox.Show("仅支持西药,诊疗,材料的更新查询!");
  838. return;
  839. }
  840. joData.Add("type",type);
  841. joData.Add("med_list_codg",dgvDirectoy.Rows[dirIndex].Cells["Code"].Value.ToString());
  842. joData.Add("fee_ocur_time", DateTime.Now.ToString("yyyy-MM-dd"));
  843. if (QueryAndShowInsuDirInfo(joData, out outPar) != 0)
  844. {
  845. MessageBox.Show(outPar);
  846. }
  847. }
  848. catch (Exception ex)
  849. {
  850. MessageBox.Show("目录查询异常:" + ex.Message);
  851. }
  852. }
  853. private void rbgDownType_3_ValueChanged(object sender, int index, string text)
  854. {
  855. DataGridView dgs = new DataGridView();
  856. GridViewSetter gvs = new GridViewSetter();
  857. //gvs.SetHeaderTextOfMoreInfo()
  858. }
  859. private void btQueryDir_2_Click(object sender, EventArgs e)
  860. {
  861. JObject joData = new JObject();
  862. string outPar = "";
  863. try
  864. {
  865. joData.Add("type", rbgDownType_3.SelectedIndex);
  866. joData.Add("med_list_codg", tbInsuCode_2.Text);
  867. joData.Add("fee_ocur_time", tbOccurDate_2.Text);
  868. if (QueryAndShowInsuDirInfo(joData, out outPar) != 0)
  869. {
  870. MessageBox.Show(outPar);
  871. }
  872. }
  873. catch (Exception ex)
  874. {
  875. MessageBox.Show("目录更新异常:" + ex.Message);
  876. }
  877. }
  878. private void dgvLimitPriceInfo_DataError(object sender, DataGridViewDataErrorEventArgs anError)
  879. {
  880. // MessageBox.Show("Error happened " + anError.Context.ToString());
  881. // string msg = String.Format("Finished Editing Cell at ({0}, {1})",
  882. //anError.ColumnIndex, anError.RowIndex);
  883. // MessageBox.Show(msg);
  884. // if (anError.Context == DataGridViewDataErrorContexts.Commit)
  885. // {
  886. // MessageBox.Show("Commit error");
  887. // }
  888. // if (anError.Context == DataGridViewDataErrorContexts.CurrentCellChange)
  889. // {
  890. // MessageBox.Show("Cell change");
  891. // }
  892. // if (anError.Context == DataGridViewDataErrorContexts.Parsing)
  893. // {
  894. // MessageBox.Show("parsing error");
  895. // }
  896. // if (anError.Context == DataGridViewDataErrorContexts.LeaveControl)
  897. // {
  898. // MessageBox.Show("leave control error");
  899. // }
  900. // if (anError.Context == DataGridViewDataErrorContexts.Formatting)
  901. // {
  902. // MessageBox.Show("Formatting control error");
  903. // }
  904. // if (anError.Context == DataGridViewDataErrorContexts.Display)
  905. // {
  906. // MessageBox.Show("Display control error");
  907. // }
  908. // if ((anError.Exception) is ConstraintException)
  909. // {
  910. // DataGridView view = (DataGridView)sender;
  911. // view.Rows[anError.RowIndex].ErrorText = "an error";
  912. // view.Rows[anError.RowIndex].Cells[anError.ColumnIndex].ErrorText = "an error";
  913. // anError.ThrowException = false;
  914. // }
  915. }
  916. #endregion
  917. #region 目录更新 ,限价更新,自付比例更新
  918. /// <summary>
  919. /// 通过1312等更新医保目录
  920. /// </summary>
  921. /// <param name="errMsg"></param>
  922. /// <returns></returns>
  923. private int UpdateDirBy1312(JObject jo, out string errMsg)
  924. {
  925. errMsg = "";
  926. try
  927. {
  928. JObject joParam = new JObject();
  929. joParam.Add("Code", JsonHelper.getDestValue(jo, "hilist_code"));
  930. joParam.Add("Name", JsonHelper.getDestValue(jo, "hilist_name"));
  931. //joParam.Add("HisType", direcType + 1);
  932. //joParam.Add("HisTypeName", hisTypeName);
  933. //joParam.Add("LocateCode", tbLocateCode.Text);
  934. //joParam.Add("LocateName", tbLocateName.Text);
  935. //joParam.Add("DrugSafetyStandardCode", tbSafetyCode.Text);
  936. //joParam.Add("DosageFormCode", tbDosageCode.Text);
  937. //joParam.Add("DosageFormName", tbDosageName.Text);
  938. joParam.Add("CategoryCode", JsonHelper.getDestValue(jo, "list_type"));
  939. //joParam.Add("CategoryName", "");
  940. //joParam.Add("Specification", tbSpecification.Text);
  941. //joParam.Add("SpecificationCode", "");
  942. //joParam.Add("UnitOfPackag", tbUnitOfPackag.Text);
  943. //joParam.Add("UnitOfValuation", tbUnitOfValuation.Text);
  944. joParam.Add("StartDate", JsonHelper.getDestValue(jo, "begndate"));
  945. joParam.Add("EndDate", JsonHelper.getDestValue(jo, "enddate"));
  946. //joParam.Add("PinyinSearchCode", pym);
  947. //joParam.Add("Instructions", rtbInstructions.Text);
  948. //joParam.Add("ExceptContent", rtbExceptContent.Text);
  949. //joParam.Add("Connotation", rtbConnotation.Text);
  950. //joParam.Add("Note", tbNote.Text);
  951. joParam.Add("ValidFlag", JsonHelper.getDestValue(jo, "vali_flag"));
  952. //joParam.Add("ApprovalNO", tbApprovalNO.Text);
  953. //joParam.Add("VersionNO", tbVersionNO.Text);
  954. //joParam.Add("VersionName", tbVersionName.Text);
  955. //joParam.Add("UseFlag", Convert.ToInt32(cbUseFlag.Checked));
  956. //joParam.Add("SpecialFlag", Convert.ToInt32(cbSpecialFlag.Checked));
  957. joParam.Add("LimitFlag", JsonHelper.getDestValue(jo, "lmt_used_flag"));
  958. //joParam.Add("LimitRange", rtbLimitRange.Text);
  959. //joParam.Add("UniqueRecordNO", JsonHelper.getDestValue(jo, ""));
  960. //joParam.Add("NationalCode", tbNationalCode.Text);
  961. //joParam.Add("NationalName", tbNationalName.Text);
  962. //joParam.Add("Manufacturers", tbManufacturers.Text);
  963. joParam.Add("UpdateTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  964. joParam.Add("ChargeItemLevel", JsonHelper.getDestValue(jo, "chrgitm_lv"));
  965. //joParam.Add("Company", tbCompany.Text);
  966. joParam.Add("ChargeItemType", JsonHelper.getDestValue(jo, "med_chrgitm_type"));
  967. JObject joRtn = mIS.UpdateDirectoryBySelf(joParam);
  968. string error = "";
  969. if (JsonHelper.parseIrisRtnValue(joRtn, out error) != 0)
  970. {
  971. errMsg = "更新失败:" + error;
  972. return -1;
  973. }
  974. else
  975. {
  976. errMsg ="更新成功";
  977. return 0;
  978. }
  979. }
  980. catch (Exception ex)
  981. {
  982. errMsg = "UpdateDir:" + ex.Message;
  983. return -1;
  984. }
  985. }
  986. /// <summary>
  987. /// 更新限价信息
  988. /// </summary>
  989. /// <param name="errMsg"></param>
  990. /// <returns></returns>
  991. private int UpdateLimitPrice(JArray ja, out string errMsg)
  992. {
  993. errMsg = "更新成功";
  994. bool bSuccess = true;
  995. try
  996. {
  997. Global.writeLog(ja.ToString());
  998. //遍历
  999. foreach (JObject jo in ja)
  1000. {
  1001. Global.writeLog(jo.ToString());
  1002. //转换为IRIS字段
  1003. JObject joTmp = new JObject();
  1004. joTmp.Add("Code", JsonHelper.getDestValue(jo, "hilist_code"));
  1005. joTmp.Add("Name", "");
  1006. joTmp.Add("LimitType", JsonHelper.getDestValue(jo, "hilist_lmtpric_type"));
  1007. joTmp.Add("DisposeWay", JsonHelper.getDestValue(jo, "overlmt_dspo_way"));
  1008. joTmp.Add("BeginDate", JsonHelper.getDestValue(jo, "begndate"));
  1009. joTmp.Add("EndDate", JsonHelper.getDestValue(jo, "enddate"));
  1010. joTmp.Add("UpLimitAmount", JsonHelper.getDestValue(jo, "hilist_pric_uplmt_amt"));
  1011. joTmp.Add("InsuranceAreaCode", JsonHelper.getDestValue(jo, "insu_admdvs"));
  1012. joTmp.Add("PoolAreaNO", JsonHelper.getDestValue(jo, "poolarea_no"));
  1013. joTmp.Add("ValidFlag", JsonHelper.getDestValue(jo, "vali_flag"));
  1014. joTmp.Add("RequiredID", JsonHelper.getDestValue(jo, "rid"));
  1015. joTmp.Add("UpdateTime", JsonHelper.getDestValue(jo, "updt_time"));
  1016. JObject joRtn = mIS.UpdateDirectoryLimitPrice(joTmp);
  1017. string error = "";
  1018. if (JsonHelper.parseIrisRtnValue(joRtn, out error) != 0)
  1019. {
  1020. bSuccess = false;
  1021. errMsg = errMsg + "更新失败:" + error;
  1022. }
  1023. }
  1024. if (bSuccess == true)
  1025. {
  1026. return 0;
  1027. }
  1028. else
  1029. {
  1030. return -1;
  1031. }
  1032. }
  1033. catch (Exception ex)
  1034. {
  1035. errMsg = "UpdateLimitPrice:" + ex.Message;
  1036. return -1;
  1037. }
  1038. }
  1039. private int UpdateSelfPayProportion(JArray ja, out string errMsg)
  1040. {
  1041. errMsg = "更新成功";
  1042. bool bSuccess = true;
  1043. try
  1044. {
  1045. //遍历
  1046. foreach (JObject jo in ja)
  1047. {
  1048. //转换为IRIS字段
  1049. JObject joTmp = new JObject();
  1050. joTmp.Add("Code", JsonHelper.getDestValue(jo, "hilist_code"));
  1051. joTmp.Add("Name", "");
  1052. joTmp.Add("PersonnelType", JsonHelper.getDestValue(jo, "selfpay_prop_psn_type"));
  1053. joTmp.Add("ProportionType", JsonHelper.getDestValue(jo, "selfpay_prop_type"));
  1054. joTmp.Add("BeginDate", JsonHelper.getDestValue(jo, "begndate"));
  1055. joTmp.Add("EndDate", JsonHelper.getDestValue(jo, "enddate"));
  1056. joTmp.Add("Proportion", JsonHelper.getDestValue(jo, "selfpay_prop"));
  1057. joTmp.Add("InsuranceAreaCode", JsonHelper.getDestValue(jo, "insu_admdvs"));
  1058. joTmp.Add("PoolAreaNO", "");
  1059. joTmp.Add("ValidFlag", JsonHelper.getDestValue(jo, "vali_flag"));
  1060. joTmp.Add("RequiredID", "");
  1061. joTmp.Add("UpdateTime", "");
  1062. JObject joRtn = mIS.UpdateDirectorySelfpayProportion(joTmp);
  1063. string error = "";
  1064. if (JsonHelper.parseIrisRtnValue(joRtn, out error) != 0)
  1065. {
  1066. bSuccess = false;
  1067. errMsg = errMsg + "更新失败:" + error;
  1068. }
  1069. }
  1070. if (bSuccess == true)
  1071. {
  1072. return 0;
  1073. }
  1074. else
  1075. {
  1076. return -1;
  1077. }
  1078. }
  1079. catch (Exception ex)
  1080. {
  1081. errMsg = "UpdateSelfPayProportion:" + ex.Message;
  1082. return -1;
  1083. }
  1084. }
  1085. /// <summary>
  1086. /// 查询并展示医保目录信息(目录信息,限价信息,比例信息更新)
  1087. /// </summary>
  1088. /// <param name="joData"></param>
  1089. /// <param name="errMsg"></param>
  1090. /// <returns></returns>
  1091. private int QueryAndShowInsuDirInfo(JObject joData, out string errMsg)
  1092. {
  1093. errMsg = "";
  1094. try
  1095. {
  1096. int type = int.Parse(JsonHelper.getDestValue(joData, "type"));
  1097. if (cBus.UpdateDirectory_HEB(joData, out errMsg) != 0)
  1098. {
  1099. return -1;
  1100. }
  1101. else
  1102. {
  1103. joDirInfoOfCenterRtn = JObject.Parse(errMsg);
  1104. return ShowInsuDirInfo(type, joDirInfoOfCenterRtn, out errMsg);
  1105. }
  1106. }
  1107. catch (Exception ex)
  1108. {
  1109. errMsg = ex.Message;
  1110. return -1;
  1111. }
  1112. }
  1113. /// <summary>
  1114. /// 查询然后更新目录信息
  1115. /// </summary>
  1116. /// <param name="joData"></param>
  1117. /// <param name="errMsg"></param>
  1118. /// <returns></returns>
  1119. private int QueryAndUpdateInsuDirInfo(JObject joData, out string errMsg)
  1120. {
  1121. errMsg = "";
  1122. try
  1123. {
  1124. if (cBus.UpdateDirectory_HEB(joData, out errMsg) != 0)
  1125. {
  1126. return -1;
  1127. }
  1128. else
  1129. {
  1130. joDirInfoOfCenterRtn = JObject.Parse(errMsg);
  1131. return UpdateInsuDirInfo(joDirInfoOfCenterRtn, out errMsg);
  1132. }
  1133. }
  1134. catch (Exception ex)
  1135. {
  1136. errMsg = ex.Message;
  1137. return -1;
  1138. }
  1139. }
  1140. /// <summary>
  1141. /// 1312,限价,自付比例信息更新到后台
  1142. /// </summary>
  1143. /// <param name="joDirInfo"></param>
  1144. /// <param name="errMsg"></param>
  1145. /// <returns></returns>
  1146. private int UpdateInsuDirInfo(JObject joDirInfo, out string errMsg)
  1147. {
  1148. errMsg = "";
  1149. try
  1150. {
  1151. JArray jaLimitPirceInfo = JArray.Parse(JsonHelper.getDestValue(joDirInfo, "output.lmtpric"));
  1152. JArray jaSelfPayRiotInfo = JArray.Parse(JsonHelper.getDestValue(joDirInfo, "output.selfpay_array"));
  1153. JObject joInsuDirInfo = JObject.Parse(JsonHelper.getDestValue(joDirInfo, "output.hilist"));
  1154. if (UpdateDirBy1312(joInsuDirInfo, out errMsg) != 0)
  1155. {
  1156. return -1;
  1157. }
  1158. if (UpdateLimitPrice(jaLimitPirceInfo, out errMsg) != 0)
  1159. {
  1160. return -1;
  1161. }
  1162. if (UpdateSelfPayProportion(jaSelfPayRiotInfo, out errMsg) != 0)
  1163. {
  1164. return -1;
  1165. }
  1166. return 0;
  1167. }
  1168. catch (Exception ex)
  1169. {
  1170. errMsg = ex.Message;
  1171. return -1;
  1172. }
  1173. }
  1174. /// <summary>
  1175. /// 展示1312,限价,自付比例等目录查询后的信息
  1176. /// </summary>
  1177. /// <param name="type"></param>
  1178. /// <param name="joDirInfo"></param>
  1179. /// <param name="errMsg"></param>
  1180. /// <returns></returns>
  1181. private int ShowInsuDirInfo(int type,JObject joDirInfo, out string errMsg)
  1182. {
  1183. errMsg = "";
  1184. try
  1185. {
  1186. if (JsonHelper.parseCenterRtnValue(joDirInfo, out errMsg) != 0)
  1187. {
  1188. return -1;
  1189. }
  1190. else
  1191. {
  1192. JArray jaLimitPirceInfo = JArray.Parse(JsonHelper.getDestValue(joDirInfo, "output.lmtpric"));
  1193. JArray jaSelfPayRiotInfo = JArray.Parse(JsonHelper.getDestValue(joDirInfo, "output.selfpay_array"));
  1194. JObject joInsuDirInfo = JObject.Parse(JsonHelper.getDestValue(joDirInfo, "output.hilist"));
  1195. JArray jaInsuDirInfo = new JArray();
  1196. jaInsuDirInfo.Add(joInsuDirInfo);
  1197. DataTable dtLimitPriceInfo = (DataTable)jaLimitPirceInfo.ToObject(typeof(DataTable));
  1198. DataTable dtSelfPayRiotInfo = (DataTable)jaSelfPayRiotInfo.ToObject(typeof(DataTable));
  1199. DataTable dtInsuDirInfo = (DataTable)jaInsuDirInfo.ToObject(typeof(DataTable));
  1200. dgvLimitPriceInfo.DataSource = dtLimitPriceInfo;
  1201. dgvSelfPayRiotInfo.DataSource = dtSelfPayRiotInfo;
  1202. dgvInsuDirInfo.DataSource = dtInsuDirInfo;
  1203. GridViewSetter gvs = new GridViewSetter();
  1204. gvs.SetHeaderTextOfLimitPrice(dgvLimitPriceInfo);
  1205. if (type == 0)//西药
  1206. {
  1207. gvs.SetHeaderTextOfMoreInfo(0, dgvMoreInfo);
  1208. JObject joMoreInfo = JObject.Parse(JsonHelper.getDestValue(joDirInfo, "output.tcmpat"));
  1209. JArray jaMoreInfo = new JArray();
  1210. jaMoreInfo.Add(joMoreInfo);
  1211. DataTable dtMoreInfo = (DataTable)jaMoreInfo.ToObject(typeof(DataTable));
  1212. dgvMoreInfo.DataSource = dtMoreInfo;
  1213. }
  1214. if (type == 5)
  1215. {
  1216. gvs.SetHeaderTextOfMoreInfo(5, dgvMoreInfo);
  1217. JObject joMoreInfo = JObject.Parse(JsonHelper.getDestValue(joDirInfo, "output.trtserv"));
  1218. JArray jaMoreInfo = new JArray();
  1219. jaMoreInfo.Add(joMoreInfo);
  1220. DataTable dtMoreInfo = (DataTable)jaMoreInfo.ToObject(typeof(DataTable));
  1221. dgvMoreInfo.DataSource = dtMoreInfo;
  1222. }
  1223. if (type == 4)
  1224. {
  1225. gvs.SetHeaderTextOfMoreInfo(4, dgvMoreInfo);
  1226. JObject joMoreInfo = JObject.Parse(JsonHelper.getDestValue(joDirInfo, "output.mcsinfo"));
  1227. JArray jaMoreInfo = new JArray();
  1228. jaMoreInfo.Add(joMoreInfo);
  1229. DataTable dtMoreInfo = (DataTable)jaMoreInfo.ToObject(typeof(DataTable));
  1230. dgvMoreInfo.DataSource = dtMoreInfo;
  1231. }
  1232. //更新后台
  1233. tbBasicData.SelectedIndex = 2;
  1234. return 0;
  1235. }
  1236. }
  1237. catch (Exception ex)
  1238. {
  1239. errMsg = "" + ex.Message;
  1240. return -1;
  1241. }
  1242. }
  1243. #endregion
  1244. private void btSave_2_Click(object sender, EventArgs e)
  1245. {
  1246. string errMsg;
  1247. if (joDirInfoOfCenterRtn == null) { return; }
  1248. if (JsonHelper.parseIrisRtnValue(joDirInfoOfCenterRtn, out errMsg) != 0) return;
  1249. if (UpdateInsuDirInfo(joDirInfoOfCenterRtn, out errMsg) != 0) MessageBox.Show(errMsg);
  1250. }
  1251. private void tsmUpdateDir_Click_1(object sender, EventArgs e)
  1252. {
  1253. JObject joData = new JObject();
  1254. string outPar = "";
  1255. try
  1256. {
  1257. int dirIndex = dgvDirectoy.CurrentRow.Index;
  1258. int type = -1;
  1259. switch (rbgDirecType.SelectedIndex)
  1260. {
  1261. case 0:
  1262. type = 0;
  1263. break;
  1264. case 1:
  1265. type = 5;
  1266. break;
  1267. case 2:
  1268. type = 4;
  1269. break;
  1270. }
  1271. if (type == -1)
  1272. {
  1273. MessageBox.Show("仅支持西药,诊疗,材料的更新!");
  1274. return;
  1275. }
  1276. joData.Add("type", type);
  1277. joData.Add("med_list_codg", dgvDirectoy.Rows[dirIndex].Cells["Code"].Value.ToString());
  1278. joData.Add("fee_ocur_time", DateTime.Now.ToString("yyyy-MM-dd"));
  1279. if (QueryAndUpdateInsuDirInfo(joData, out outPar) != 0)
  1280. {
  1281. MessageBox.Show(outPar);
  1282. }
  1283. queryHISInsuDirectory(rbgDirecType.SelectedIndex, 1, 20, dgvDirectoy, Global.inf.interfaceDr);
  1284. }
  1285. catch (Exception ex)
  1286. {
  1287. MessageBox.Show("目录更新异常:" + ex.Message);
  1288. }
  1289. }
  1290. private void toolStripMenuItem5_Click(object sender, EventArgs e)
  1291. {
  1292. if (!rbMaped.Checked)
  1293. {
  1294. MessageBox.Show("请选择已对照进行更新");
  1295. return;
  1296. }
  1297. DataTable dt = (DataTable)dgvHISDirectory.DataSource; //获取当前页的数据,注意在已对照页面更新
  1298. if ((dt == null) || (dt.Rows.Count < 1))
  1299. {
  1300. MessageBox.Show("表中无数据,请检查!");
  1301. return;
  1302. }
  1303. string htype = "";
  1304. string cxno = "";
  1305. if (rbgDirecType_C.SelectedIndex == 0)
  1306. {
  1307. htype = "1";
  1308. cxno = "1360";
  1309. }
  1310. else if (rbgDirecType_C.SelectedIndex == 1)
  1311. {
  1312. htype = "2";
  1313. cxno = "1365";
  1314. }
  1315. else if (rbgDirecType_C.SelectedIndex == 2)
  1316. {
  1317. htype = "3";
  1318. cxno = "1364";
  1319. }
  1320. // MessageBox.Show("第1列" + dt.Rows[0][0]);
  1321. // MessageBox.Show("第1行" + dt.Rows[0].ToString());
  1322. dynamic one1312 = new JObject();
  1323. //one1312.Add("query_date", "");//查询时间点 日期型
  1324. //one1312.Add("hilist_code", "");//医保目录编码 字符型 30
  1325. one1312.Add("med_list_codg", "");//医保目录编码 字符型 30
  1326. one1312.Add("fee_ocur_time", "2022-01-01");//医保目录编码 字符型 30
  1327. //one1312.Add("insu_admdvs", "");//参保机构医保区划 字符型 6 Y
  1328. //one1312.Add("begndate", ""); //开始日期 日期型
  1329. //one1312.Add("hilist_name", "");//医保目录名称 字符型 200
  1330. //one1312.Add("wubi", "");//五笔助记码 字符型 30
  1331. //one1312.Add("pinyin", "");//拼音助记码 字符型 30
  1332. //one1312.Add("med_chrgitm_type", "");//医疗收费项目类别 字符型 6 Y
  1333. //one1312.Add("chrgitm_lv", "");//收费项目等级 字符型 3 Y
  1334. //one1312.Add("lmt_used_flag", "");//限制使用标志 字符型 3 Y
  1335. //one1312.Add("list_type", "");//目录类别 字符型 30
  1336. //one1312.Add("med_use_flag", "");//医疗使用标志 字符型 3 Y
  1337. //one1312.Add("matn_used_flag", "");//生育使用标志 字符型 3 Y
  1338. //one1312.Add("hilist_use_type", "");//医保目录使用类别 字符型 3 Y
  1339. //one1312.Add("lmt_cpnd_type", ""); //限复方使用类型 字符型 3 Y
  1340. //one1312.Add("vali_flag", "");//有效标志 字符型 3 Y
  1341. //one1312.Add("updt_time", "2021-01-01");//更新时间 日期型
  1342. //one1312.Add("page_num", 1);//当前页数 数值型 4
  1343. //one1312.Add("page_size", 50);//本页数据量 数值型 4
  1344. dynamic data1312 = new JObject();
  1345. dynamic joPamam = new JObject();//更新HIS医保目录入参
  1346. //joPamam.Add("Code", "");
  1347. //joPamam.Add("Name", "");
  1348. joPamam.Add("HisType", htype);
  1349. //joPamam.Add("ChargeItemLevel", "");
  1350. //joPamam.Add("ListType", "");
  1351. int i;
  1352. string sfdl = "";
  1353. for (i = 0; i < dt.Rows.Count; i++)
  1354. {
  1355. one1312.med_list_codg = dt.Rows[i][12].ToString();//每行的第13列是医保编码
  1356. //if (htype == "3")
  1357. //{
  1358. // one1312.hilist_code = dt.Rows[i][12].ToString();//每行的第13列是医保编码,长春截取15位,医保目录只有15位,武汉是20位
  1359. //}
  1360. data1312.data = one1312;
  1361. JObject jo1312Rtn = invoker.invokeCenterService(cxno, data1312.ToString());
  1362. if (JsonHelper.parseCenterReturnJson(jo1312Rtn, out string errorMsg) == 0)
  1363. {
  1364. joPamam.CeilingPrice = "999999";
  1365. joPamam.Code = dt.Rows[i][12].ToString();//哈尔滨医保查询医保编码字母都是小写
  1366. if (!string.IsNullOrEmpty(JsonHelper.getDestValue(jo1312Rtn, "output.hilist.vali_flag")))//判断返回结束时间为空的
  1367. //if (Convert.ToString(dt_result.Rows[n]["vali_flag"])=="1"&& Convert.ToString(dt_result.Rows[n]["poolarea_no"]) == "230100")
  1368. {
  1369. //医保返参取值
  1370. //joPamam.Code = dt_result.Rows[n][3].ToString();//长春第四位医保编码
  1371. //joPamam.Code = dt_result.Rows[i]["hilist_code"].ToString();
  1372. joPamam.Name = jo1312Rtn["output"]["hilist"]["hilist_name"];
  1373. joPamam.ChargeItemLevel = jo1312Rtn["output"]["hilist"]["chrgitm_lv"];//长春第28位收费项目等级
  1374. if (joPamam.ChargeItemLevel == "01")
  1375. {
  1376. joPamam.ChargeItemLevelName = "甲类";
  1377. }
  1378. else if (joPamam.ChargeItemLevel == "02")
  1379. {
  1380. joPamam.ChargeItemLevelName = "乙类";
  1381. }
  1382. else if (joPamam.ChargeItemLevel == "03")
  1383. {
  1384. joPamam.ChargeItemLevelName = "丙类";
  1385. }
  1386. joPamam.ListType = jo1312Rtn["output"]["hilist"]["list_type"];//取医保目录类别 101 201 301
  1387. joPamam.ChargeItemType = jo1312Rtn["output"]["hilist"]["med_chrgitm_type"];//取医疗收费类别 01.02.03....
  1388. }
  1389. //取医保目录价格,哈尔滨三级医院
  1390. DataTable dt_result = (DataTable)jo1312Rtn["output"]["lmtpric"].ToObject(typeof(DataTable));
  1391. if (dt_result.Rows.Count>0) {
  1392. for (int n = 0; n < dt_result.Rows.Count; n++)
  1393. {
  1394. if (dt_result.Rows[n]["hilist_lmtpric_type"].ToString() == "3")//取医院等级为三的限价
  1395. {
  1396. joPamam.CeilingPrice = dt_result.Rows[n]["hilist_pric_uplmt_amt"].ToString();
  1397. }
  1398. }
  1399. }
  1400. JObject joRtn = mIS.UpdateDirectoryBySelf(joPamam);
  1401. }
  1402. }
  1403. MessageBox.Show("更新完成!");
  1404. }
  1405. }
  1406. }