HisMainBusiness.cs 101 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084
  1. /******************************************************************************
  2. * 文件名称: HisMainBusiness.cs
  3. * 文件说明: HIS主体交易的封装
  4. * 当前版本: V1.0
  5. * 创建日期: 2022-06-20
  6. *
  7. * * 2020-06-20: 增加 HisMainBusiness 类
  8. * ***** 2020-06-20: 增加 CardReader 方法,获取URL地址,USER信息,地方版SSCard.dll使用
  9. * ***** 2020-06-20: 增加 CardReader 方法重载,国家版电子凭证使用
  10. * ***** 2020-06-20: 增加 Init 方法,SSCard环境初始化
  11. * ***** 2020-06-20: 增加 ReadCardBas 方法,读社保卡
  12. * ***** 2020-06-20: 增加 VerifyPIN 方法,验证密码
  13. * ***** 2020-06-20: 增加 ChangePIN 方法,修改密码
  14. * ***** 2020-06-20: 增加 ReadSFZ 方法,读身份证
  15. * ***** 2020-06-20: 增加 GetQRBase 方法,读二维码
  16. * ***** 2020-06-20: 增加 NationEcTrans 方法,读电子凭证(国家版)
  17. ******************************************************************************/
  18. using System;
  19. using System.Collections.Generic;
  20. using System.Linq;
  21. using System.Text;
  22. using System.Threading.Tasks;
  23. using System.Windows.Forms;
  24. using Newtonsoft.Json.Linq;
  25. using PTMedicalInsurance.Common;
  26. using PTMedicalInsurance.Helper;
  27. using PTMedicalInsurance.Variables;
  28. using PTMedicalInsurance.Forms;
  29. using System.Data;
  30. using System.Reflection;
  31. using System.IO;
  32. using System.IO.Compression;
  33. using FastReport.DevComponents.Editors;
  34. namespace PTMedicalInsurance.Business
  35. {
  36. class HisMainBusiness
  37. {
  38. private InvokeHelper invoker = new InvokeHelper();
  39. private HisIrisServices hIS = new HisIrisServices();
  40. private MIIrisServices mIS = new MIIrisServices();
  41. private CenterBusiness cBus = new CenterBusiness();
  42. /// <summary>
  43. /// 获取HIS的IRIS配置信息
  44. /// </summary>
  45. /// <param name="con"></param>
  46. public void getHisConfingue(out IrisConfigue con)
  47. {
  48. IniFile ini = new IniFile(Global.curEvt.path + @"\INSUConfigure.ini");
  49. con.ip = ini.ReadValue("HIS", "ip");
  50. con.url = ini.ReadValue("HIS", "url");
  51. con.authorization = ini.ReadValue("HIS", "authorization");
  52. }
  53. /// <summary>
  54. /// 获取医保平台的iris配置信息
  55. /// </summary>
  56. /// <param name="con"></param>
  57. public void getInsuConfingue(out IrisConfigue con)
  58. {
  59. IniFile ini = new IniFile(Global.curEvt.path + @"\INSUConfigure.ini");
  60. con.ip = ini.ReadValue("INSU", "ip");
  61. con.url = ini.ReadValue("INSU", "url");
  62. con.authorization = ini.ReadValue("INSU", "authorization");
  63. }
  64. /// <summary>
  65. /// 获取Session信息(目前只获取操作员信息)
  66. /// </summary>
  67. /// <param name="joSession"></param>
  68. public void getSessionInfo(JObject joSession)
  69. {
  70. Global.user.ID = JsonHelper.getDestValue(joSession, "userCode");
  71. Global.user.name = JsonHelper.getDestValue(joSession, "userName");
  72. Global.user.type = "3";
  73. Global.user.officeID = JsonHelper.getDestValue(joSession, "locID");
  74. Global.user.officeName = JsonHelper.getDestValue(joSession, "locDesc");
  75. }
  76. /// <summary>
  77. /// 根据壳程序传入的入参设置全局接口变量
  78. /// </summary>
  79. /// <param name="joInpar"></param>
  80. /// <param name="inf"></param>
  81. public void setGlobalInterface(JObject joInpar,out InterfaceInfo inf)
  82. {
  83. inf = new InterfaceInfo();
  84. inf.hospitalDr = int.Parse(JsonHelper.getDestValue(joInpar, "HospitalDr"));
  85. inf.hisHospitalDr = int.Parse(JsonHelper.getDestValue(joInpar, "hisHospitalDr"));
  86. inf.hospitalName = JsonHelper.getDestValue(joInpar, "HospitalName");
  87. inf.interfaceDr = int.Parse(JsonHelper.getDestValue(joInpar, "ID"));
  88. inf.interfaceID = JsonHelper.getDestValue(joInpar, "InterfaceID");
  89. //inf.oper = "3";
  90. inf.centerURL = JsonHelper.getDestValue(joInpar, "CenterURL");
  91. inf.ecURL = JsonHelper.getDestValue(joInpar, "CenterURL2");
  92. inf.areaCode = JsonHelper.getDestValue(joInpar, "AreaCode");
  93. inf.dllName = JsonHelper.getDestValue(joInpar, "DLLName");
  94. inf.hospitalNO = JsonHelper.getDestValue(joInpar, "HospitalNO");
  95. inf.version = "v1.0";
  96. inf.signatureType = "SM3";
  97. inf.recivedSystem = "YBXT";
  98. inf.AK = "";
  99. inf.SK = "";
  100. inf.dev_safe_info = "";
  101. inf.dev_no = Global.curEvt.mac;
  102. inf.cardURL = inf.centerURL;
  103. inf.cainfo = "";
  104. }
  105. /// <summary>
  106. /// 根据壳程序传入的入参设置全局接口变量
  107. /// </summary>
  108. /// <param name="joInpar"></param>
  109. /// <param name="inf"></param>
  110. public void setGlobalInterface_Plat(JObject joInpar, out InterfaceInfo inf)
  111. {
  112. inf = new InterfaceInfo();
  113. inf.hospitalDr = int.Parse(JsonHelper.getDestValue(joInpar, "hospitalID"));
  114. inf.hisHospitalDr = int.Parse(JsonHelper.getDestValue(joInpar, "hisHospitalDr"));
  115. inf.hospitalName = JsonHelper.getDestValue(joInpar, "hospitalName");
  116. inf.interfaceDr = int.Parse(JsonHelper.getDestValue(joInpar, "medInsuInterfaceID"));
  117. inf.interfaceID = JsonHelper.getDestValue(joInpar, "interfaceNO");
  118. //inf.oper = "3";
  119. inf.centerURL = JsonHelper.getDestValue(joInpar, "centerURL");
  120. inf.ecURL = JsonHelper.getDestValue(joInpar, "centerURL2");
  121. inf.areaCode = JsonHelper.getDestValue(joInpar, "areaCode");
  122. inf.dllName = JsonHelper.getDestValue(joInpar, "dLLName");
  123. inf.hospitalNO = JsonHelper.getDestValue(joInpar, "hospitalNO");
  124. inf.version = "v1.0";
  125. inf.signatureType = "SM3";
  126. inf.recivedSystem = "YBXT";
  127. inf.AK = "";
  128. inf.SK = "";
  129. inf.dev_safe_info = "";
  130. inf.dev_no = Global.curEvt.mac;
  131. inf.cardURL = inf.centerURL;
  132. inf.cainfo = "";
  133. }
  134. /// <summary>
  135. /// 初始化环境
  136. /// </summary>
  137. /// <param name="inParam"></param>
  138. /// <returns></returns>
  139. public int initEnvironment(string inParam,out string error)
  140. {
  141. error = string.Empty;
  142. try
  143. {
  144. //获取HIS和医保平台的IRIS配置信息
  145. getHisConfingue(out Global.hisConfig);
  146. getInsuConfingue(out Global.insuConfig);
  147. getLocalConfingue();
  148. JObject joInparam = JObject.Parse(inParam);
  149. JObject JoSession = JObject.Parse(JsonHelper.getDestValue(joInparam, "session[0]"));
  150. string hisHospitalDr = JsonHelper.getDestValue(JoSession, "hospID");
  151. JObject joInterface = JObject.Parse(JsonHelper.getDestValue(joInparam, "interfaceinfo"));
  152. joInterface.Add("hisHospitalDr", hisHospitalDr);
  153. if (joInterface != null)
  154. {
  155. //获取当前接口详细信息
  156. if (Global.businessType == "P1")
  157. {
  158. setGlobalInterface_Plat(joInterface, out Global.inf);
  159. }
  160. else
  161. {
  162. setGlobalInterface(joInterface, out Global.inf);
  163. }
  164. JObject joSession = JObject.Parse(JsonHelper.getDestValue(joInparam, "session[0]"));
  165. if (joSession != null)
  166. {
  167. //获取当前用户信息
  168. getSessionInfo(joSession);
  169. return 0;
  170. }
  171. else
  172. {
  173. error = "初始化环境失败:session获取失败!";
  174. return -1;
  175. }
  176. }
  177. else
  178. {
  179. error = "初始化环境失败:interfaceinfo获取失败!";
  180. return -1;
  181. }
  182. }
  183. catch (Exception ex)
  184. {
  185. error ="初始化环境失败:" + ex.Message;
  186. return -1;
  187. }
  188. }
  189. /// <summary>
  190. /// 读卡
  191. /// </summary>
  192. /// <returns></returns>
  193. public int readCard(out string outParam)
  194. {
  195. outParam = "";
  196. string errorMsg = "";
  197. string sInput = "";
  198. string sOutPar;
  199. JObject joCardInfo = new JObject();
  200. ChooseCard cc = new ChooseCard();
  201. CardReader_HN CardRead = new CardReader_HN();
  202. try
  203. {
  204. #region【湖北省基线版医保接口直接调用1101参数传空调用银海COM进行读卡弹框选项】
  205. /*
  206. if (cc.ShowDialog() == DialogResult.OK)
  207. {
  208. #region【电子凭证】
  209. if (cc.sP_CertType == "01")
  210. {
  211. Global.pat.mdtrtcertType = "01";
  212. Global.pat.certType = "01";
  213. Random rd = new Random();
  214. int iNum = rd.Next();
  215. string sLSH = DateTime.Now.ToString("YYYYMMDDHHNNSS") + Global.inf.hospitalNO + iNum.ToString().Substring(0, 5);
  216. joCardInfo.Add("operatorId", Global.user.ID);
  217. joCardInfo.Add("operatorName", Global.user.name);
  218. joCardInfo.Add("officeId", Global.user.officeID);
  219. joCardInfo.Add("officeName", Global.user.officeName);
  220. joCardInfo.Add("orgId", Global.inf.hospitalNO);
  221. joCardInfo.Add("businessType", cc.sL_CertCodeType);
  222. //认证方式
  223. //二维码
  224. if (cc.EcCertDecodeType == "0")
  225. {
  226. joCardInfo.Add("deviceType", cc.sL_CertCodeType);
  227. }
  228. //电子凭证
  229. else if (cc.EcCertDecodeType == "1")
  230. {
  231. joCardInfo.Add("outBizNo", sLSH);
  232. joCardInfo.Add("extData", "");
  233. }
  234. //刷脸、先授权后解码
  235. else if (cc.EcCertDecodeType == "2") //刷脸
  236. {
  237. JObject JoGetAuthInfo = new JObject();
  238. JoGetAuthInfo.Add("outBizNo", sLSH);
  239. JoGetAuthInfo.Add("extData", "");
  240. JObject JoInputAuth = new JObject();
  241. JoInputAuth.Add("orgId", Global.inf.hospitalNO);
  242. JoInputAuth.Add("transType", "cn.nhsa.ec.auth");
  243. JoInputAuth.Add("data", JoGetAuthInfo);
  244. JoInputAuth.Add("extra", "");
  245. //调用刷脸认证接口cn.nhsa.ec.auth返回授权信息authNo
  246. CardRead.NationEcTrans(Global.inf.ecURL, JoInputAuth.ToString(), out sOutPar);
  247. if (JsonHelper.getDestValue(JObject.Parse(sOutPar), "code") != "0")
  248. {
  249. outParam = "调用刷脸认证接口cn.nhsa.ec.auth失败:" + sOutPar;
  250. return -1;
  251. }
  252. //成功返回授权信息
  253. string auth = sOutPar;
  254. JObject JoAuthOut = new JObject();
  255. JoAuthOut.Add("outBizNo", DateTime.Now.ToString("YYYYMMDDHHNNSS") + Global.inf.hospitalNO + iNum.ToString().Substring(0, 5));
  256. JoAuthOut.Add("authNo", auth);
  257. JoAuthOut.Add("extData", "");
  258. joCardInfo = (JObject)JoAuthOut.DeepClone();
  259. }
  260. //调用电子凭证动态库NationECCode.dll获取身份信息
  261. JObject JoInput = new JObject();
  262. JoInput.Add("orgId", Global.inf.hospitalNO);
  263. JoInput.Add("transType",cc.sL_EcCertDecodeTradeNO);
  264. JoInput.Add("data", joCardInfo);
  265. JoInput.Add("extra", "");
  266. //MessageBox.Show("电子凭证解码地址:" + Global.inf.ecURL + ",入参:" + JoInput.ToString());
  267. CardRead.NationEcTrans(Global.inf.ecURL, JoInput.ToString(), out sOutPar);
  268. if (JsonHelper.getDestValue(JObject.Parse(sOutPar), "code") != "0")
  269. {
  270. outParam = "调用电子凭证失败:" + sOutPar;
  271. return -1;
  272. }
  273. Global.pat.ecToken = JsonHelper.getDestValue(JObject.Parse(sOutPar), "data.ecToken");
  274. Global.pat.name = JsonHelper.getDestValue(JObject.Parse(sOutPar), "data.userName");
  275. Global.pat.IDType = JsonHelper.getDestValue(JObject.Parse(sOutPar), "data.idType");
  276. Global.pat.IDNO = JsonHelper.getDestValue(JObject.Parse(sOutPar), "data.idNo");
  277. Global.pat.insuplc_admdvs = JsonHelper.getDestValue(JObject.Parse(sOutPar), "data.insuOrg");
  278. Global.pat.mdtrtcertNO = Global.pat.ecToken;
  279. Global.pat.certType = Global.pat.IDType;
  280. Global.pat.certNO = Global.pat.IDNO;
  281. }
  282. #endregion
  283. #region【身份证】
  284. if (cc.sP_CertType == "02")
  285. {
  286. Global.pat.mdtrtcertType = "02";
  287. Global.pat.mdtrtcertNO = cc.sP_CertNO;
  288. Global.pat.certType = "01";
  289. Global.pat.certNO = cc.sP_IDNO;
  290. Global.pat.name = cc.PatName;
  291. Global.pat.card.SN = "";
  292. }
  293. #endregion
  294. #region【社保卡】
  295. if (cc.sP_CertType == "03")
  296. {
  297. //【社保卡-异地】
  298. if (cc.bOtherProvLocal)
  299. {
  300. Global.pat.bOtherProvLocal = true;
  301. Global.pat.insuplc_admdvs = Global.pat.card.SearchAdmCode;
  302. if (CardRead.ReadCardBas_HSM_Step1(cc.sL_CardType, Global.inf.hospitalNO, out sOutPar) != 0)
  303. {
  304. outParam = "社保卡读卡异常ReadCardBas_HSM_Step1:" + sOutPar;
  305. return -1;
  306. }
  307. else
  308. {
  309. //【9201卡内部认证】
  310. JObject joData9201 = new JObject();
  311. joData9201.Add("mac", sOutPar);
  312. //Global.pat.insuplc_admdvs = tools.getDestPosStrBySpliter(sOutPar, 1); //参保地
  313. InvokeHelper invoker9201 = new InvokeHelper();
  314. JObject joRtn9201 = invoker9201.invokeCenterService("9201", JsonHelper.setCenterInpar("9201", joData9201));
  315. if (JsonHelper.parseCenterRtnValue(joRtn9201, out errorMsg) != 0)
  316. {
  317. outParam = "卡内部认证9201交易失败:" + errorMsg;
  318. return -1;
  319. }
  320. else
  321. {
  322. outParam = joRtn9201.ToString();
  323. Global.pat.card.pKey = JsonHelper.getDestValue(JObject.Parse(outParam), "output.crtf_ide_data"); //认证鉴别数据
  324. }
  325. if (CardRead.ReadCardBas_HSM_Step2(Global.pat.card.pKey,out sOutPar) != 0)
  326. {
  327. outParam = "社保卡读卡异常ReadCardBas_HSM_Step2:" + errorMsg;
  328. return -1;
  329. }
  330. }
  331. }
  332. else //【社保卡-本地】
  333. {
  334. if (CardRead.ReadCardBas(cc.sL_CardType,Global.inf.hospitalNO,out sOutPar) != 0)
  335. {
  336. outParam = "社保卡读卡异常ReadCardBas:" + sOutPar;
  337. return -1;
  338. }
  339. }
  340. //【社保卡读卡成功返回】
  341. Global.pat.insuplc_admdvs = tools.getDestPosStrBySpliter(sOutPar, 1); //参保地
  342. Global.pat.card.NO = tools.getDestPosStrBySpliter(sOutPar, 2); //社会保障号码
  343. Global.pat.certNO = tools.getDestPosStrBySpliter(sOutPar, 3); //卡号
  344. Global.pat.card.SN = tools.getDestPosStrBySpliter(sOutPar, 4); //卡识别码
  345. Global.pat.name = tools.getDestPosStrBySpliter(sOutPar, 5); //姓名
  346. Global.pat.certType = "90";
  347. Global.pat.mdtrtcertType = "03";
  348. Global.pat.mdtrtcertNO = Global.pat.certNO;
  349. Global.pat.certNO = Global.pat.card.NO;
  350. }
  351. #endregion
  352. //是否异地
  353. Global.pat.bOtherProvLocal = cc.bOtherProvLocal;
  354. }
  355. else
  356. {
  357. outParam = "收款员取消读卡!";
  358. return -1;
  359. }
  360. */
  361. #endregion
  362. #region【1101获取身份信息】
  363. JObject joData = new JObject();
  364. joData.Add("mdtrt_cert_type", Global.pat.mdtrtcertType);
  365. joData.Add("mdtrt_cert_no", Global.pat.mdtrtcertNO);
  366. joData.Add("card_sn", Global.pat.card.SN);
  367. joData.Add("begntime", "");
  368. joData.Add("psn_cert_type", Global.pat.certType);
  369. joData.Add("certno", Global.pat.certNO); //证件号码
  370. joData.Add("psn_name", Global.pat.name);
  371. JObject joInput = new JObject();
  372. joInput.Add("data",joData);
  373. InvokeHelper invoker = new InvokeHelper();
  374. JObject joRtn = invoker.invokeCenterService("1101", JsonHelper.setCenterInpar("1101", joInput));
  375. if (JsonHelper.parseCenterRtnValue(joRtn, out errorMsg) != 0)
  376. {
  377. outParam = "读卡失败:" + errorMsg;
  378. return -1;
  379. }
  380. else
  381. {
  382. //joRtn.Add("cardinfo",joCardInfo);
  383. outParam = joRtn.ToString();
  384. Global.pat.insuplc_admdvs = JsonHelper.getDestValue(JObject.Parse(outParam), "output.insuinfo.insuplc_admdvs"); //参保地
  385. //Global.pat.card.NO = JsonHelper.getDestValue(JObject.Parse(outParam), "output.baseinfo.insuplc_admdvs"); //社会保障号码
  386. Global.pat.certNO = JsonHelper.getDestValue(JObject.Parse(outParam), "output.baseinfo.certno"); //证件号码
  387. Global.pat.card.SN = ""; //卡识别码
  388. Global.pat.name = JsonHelper.getDestValue(JObject.Parse(outParam), "output.baseinfo.psn_name"); //姓名
  389. Global.pat.certType = JsonHelper.getDestValue(JObject.Parse(outParam), "output.baseinfo.psn_cert_type"); //人员证件类型
  390. Global.pat.mdtrtcertType = "02"; //就诊凭证类型
  391. Global.pat.mdtrtcertNO = JsonHelper.getDestValue(JObject.Parse(outParam), "output.baseinfo.certno"); //就诊凭证编号
  392. Global.pat.certNO = JsonHelper.getDestValue(JObject.Parse(outParam), "output.baseinfo.certno"); //证件号码
  393. Global.pat.psn_no = JsonHelper.getDestValue(JObject.Parse(outParam), "output.baseinfo.psn_no"); //人员编号
  394. Global.pat.emp_name = JsonHelper.getDestValue(JObject.Parse(outParam), "output.insuinfo.emp_name"); //单位名称
  395. Global.pat.insuType = JsonHelper.getDestValue(JObject.Parse(outParam), "output.insuinfo.insutype"); //险种类型
  396. //Global.pat.psn_type = JsonHelper.getDestValue(JObject.Parse(outParam), "output.insuinfo.psn_type"); //人员类别
  397. Global.pat.ecToken = JsonHelper.getDestValue(JObject.Parse(outParam), "output.exp_content.ectoken"); //电子令牌
  398. //if (Global.pat.ecToken != "")
  399. //{
  400. // Global.pat.mdtrtcertType = "01";
  401. // Global.pat.mdtrtcertNO = Global.pat.ecToken;
  402. //}
  403. outParam = outParam.Replace(@"\", "").Replace("\"{", "{").Replace("}\"", "}");
  404. return 0;
  405. }
  406. #endregion
  407. }
  408. catch (Exception ex)
  409. {
  410. outParam = "异常:" + ex.Message;
  411. return -1;
  412. }
  413. }
  414. /// <summary>
  415. /// 展示患者信息界面,转换相关编码为中文,并获取操作员选中的信息
  416. /// </summary>
  417. /// <param name="patInfo"></param>
  418. /// <param name="outparam"></param>
  419. /// <returns></returns>
  420. public int showPatInfo(String patInfo,out string outparam )
  421. {
  422. outparam = "";
  423. //展示信息界面
  424. JObject joOutparam = JObject.Parse(patInfo);
  425. JObject joOutput = JObject.Parse(JsonHelper.getDestValue(joOutparam, "output"));
  426. //编码转换
  427. JArray jaConvertCode = new JArray();
  428. JObject joConvertCodeParam = new JObject();
  429. joConvertCodeParam.Add("hospitalDr", Global.inf.hospitalDr);
  430. joConvertCodeParam.Add("interfaceDr", Global.inf.interfaceDr);
  431. joConvertCodeParam.Add("output", joOutput);
  432. jaConvertCode.Add(joConvertCodeParam);
  433. JObject joConvertCode = new JObject();
  434. joConvertCode.Add("code", "09010054");
  435. joConvertCode.Add("params", jaConvertCode);
  436. InvokeHelper invoker = new InvokeHelper();
  437. JObject joConvertCodeRtn = invoker.invokeInsuService(joConvertCode.ToString(), "患者信息编码转换");
  438. PatientInsuInfo frmPatientInfo = new PatientInsuInfo(joConvertCodeRtn);
  439. //相关信息转换到登记面板
  440. try
  441. {
  442. if (frmPatientInfo.ShowDialog() == DialogResult.OK)
  443. {
  444. //原来用的是转换后的
  445. //frmPatientInfo.joSelectedInsuInfo.Add("mdtrt_cert_type", Global.pat.mdtrtcertType);
  446. //frmPatientInfo.joSelectedInsuInfo.Add("mdtrt_cert_no", Global.pat.mdtrtcertNO);
  447. //joOutparam.Property("output").AddBeforeSelf(new JProperty("selectedInsuInfo", frmPatientInfo.joSelectedInsuInfo));
  448. //现在用转换之前的
  449. JArray jaInsuInfo = JArray.Parse(JsonHelper.getDestValue(joOutput, "insuinfo"));
  450. JArray jaIdInfo = JArray.Parse(JsonHelper.getDestValue(joOutput, "idetinfo"));
  451. JObject joSelectedInsuInfo = (JObject)jaInsuInfo[frmPatientInfo.insuInfoIndex];
  452. JObject joSelectedIdInfo;
  453. if (jaIdInfo.Count != 0)
  454. {
  455. joSelectedIdInfo = (JObject)jaIdInfo[frmPatientInfo.idInfoIndex];
  456. }
  457. else
  458. {
  459. joSelectedIdInfo = new JObject();
  460. }
  461. joSelectedInsuInfo.Add("mdtrt_cert_type", Global.pat.mdtrtcertType);
  462. joSelectedInsuInfo.Add("mdtrt_cert_no", Global.pat.mdtrtcertNO);
  463. joOutparam.Property("output").AddBeforeSelf(new JProperty("selectedInsuInfo", joSelectedInsuInfo));
  464. //joOutparam.Property("output").AddBeforeSelf(new JProperty("selectedIdInfo", joSelectedInsuInfo));
  465. joOutparam.Property("output").AddBeforeSelf(new JProperty("selectedIdInfo", joSelectedIdInfo));//特殊身份标识患者信息组织
  466. outparam = joOutparam.ToString();
  467. return 0;
  468. }
  469. else
  470. {
  471. outparam = JsonHelper.setExceptionJson(-1, "门诊读卡", "收款员取消读卡").ToString();
  472. return -1;
  473. }
  474. }
  475. catch (Exception e)
  476. {
  477. outparam = JsonHelper.setExceptionJson(-1, "患者参保信息展示", e.Message).ToString();
  478. return -1;
  479. }
  480. }
  481. /// <summary>
  482. /// 校验HIS信息与医保参保信息姓名是否一致
  483. /// </summary>
  484. /// <param name="insuName"></param>
  485. /// <param name="errMsg"></param>
  486. /// <returns></returns>
  487. public int checkName(string insuName, out string errMsg)
  488. {
  489. try
  490. {
  491. errMsg = "";
  492. string hisPatBaseInfo = "";
  493. if (hIS.GetHisPatBaseInfo(out hisPatBaseInfo) != 0)
  494. {
  495. errMsg = hisPatBaseInfo;
  496. return -1;
  497. }
  498. string hisPatName = JsonHelper.getDestValue(JObject.Parse(hisPatBaseInfo), "result.patName");
  499. if (hisPatName != insuName)
  500. {
  501. errMsg = "患者姓名(" + hisPatName + ")与参保人姓名(" + insuName + ")不一致,请检查!";
  502. return -1;
  503. }
  504. else
  505. {
  506. return 0;
  507. }
  508. }
  509. catch (Exception ex)
  510. {
  511. errMsg = "核对HIS与医保平台姓名一致性发生异常:" + ex.Message;
  512. return -1;
  513. }
  514. }
  515. /// <summary>
  516. /// 弹窗提示患者医保类型和是否暂停参保
  517. /// </summary>
  518. /// <param name="insuName"></param>
  519. /// <param name="errMsg"></param>
  520. /// <returns></returns>
  521. public int InsuMessage(out string InMeage)
  522. {
  523. //弹窗提示患者信息
  524. String T_message = "";
  525. //湖北省基线版武汉市判断医保类型
  526. if (Global.pat.insuplc_admdvs.Substring(0, 4) == "4201")
  527. {
  528. T_message = "武汉市医保";
  529. }
  530. else if (Global.pat.insuplc_admdvs.Substring(0, 4) == "4299")
  531. {
  532. T_message = "湖北省医保";
  533. }
  534. else if (Global.pat.insuplc_admdvs.Substring(0, 2) == "42" && Global.pat.insuplc_admdvs.Substring(0, 4) != "4201" && Global.pat.insuplc_admdvs.Substring(0, 4) != "4299")
  535. {
  536. T_message = "省内异地";
  537. }
  538. else if (Global.pat.insuplc_admdvs.Substring(0, 2) != "42")
  539. {
  540. T_message = "跨省异地";
  541. }
  542. if (Global.pat.insuType.ToString() == "310")
  543. {
  544. T_message = T_message + "职工";
  545. }
  546. if (Global.pat.insuType.ToString() == "390")
  547. {
  548. T_message = T_message + "居民";
  549. }
  550. if (string.IsNullOrEmpty(Global.pat.paus_insu_date))
  551. {
  552. T_message = T_message + "/"+"正常参保";
  553. }
  554. else
  555. {
  556. T_message = T_message + "/" + "暂停参保";
  557. }
  558. InMeage = "当前选择参保信息:"+T_message;
  559. return 0;
  560. }
  561. /// <summary>
  562. /// 患者读卡并获取中心信息(1101)后设置PAT结构体
  563. /// </summary>
  564. /// <param name="patInfo"></param>
  565. /// <param name="errMsg"></param>
  566. /// <returns></returns>
  567. public int setGlobalPatAfaterShowPatInfo(string patInfo,out string errMsg)
  568. {
  569. JObject joPatInfo;
  570. errMsg = "";
  571. try
  572. {
  573. joPatInfo = JObject.Parse(patInfo);
  574. //基本信息
  575. Global.pat.certNO = JsonHelper.getDestValue(joPatInfo, "output.baseinfo.certno");
  576. Global.pat.psn_no = JsonHelper.getDestValue(joPatInfo, "output.baseinfo.psn_no");
  577. Global.pat.gend = JsonHelper.getDestValue(joPatInfo, "output.baseinfo.gend");
  578. Global.pat.brdy = JsonHelper.getDestValue(joPatInfo, "output.baseinfo.brdy");
  579. Global.pat.naty = JsonHelper.getDestValue(joPatInfo, "output.baseinfo.naty");
  580. Global.pat.age = JsonHelper.getDestValue(joPatInfo, "output.baseinfo.age");
  581. Global.pat.certType = JsonHelper.getDestValue(joPatInfo, "output.baseinfo.psn_cert_type");
  582. //if (Global.pat.name != JsonHelper.getDestValue(joPatInfo, "output.baseinfo.psn_name"))
  583. //{
  584. // errMsg = "患者姓名(" + Global.pat.name + ")与参保人姓名(" + JsonHelper.getDestValue(joPatInfo, "output.baseinfo.psn_name") + ")不一致,请检查!";
  585. // return -1;
  586. //}
  587. Global.pat.name = JsonHelper.getDestValue(joPatInfo, "output.baseinfo.psn_name");
  588. //选中的参保信息
  589. Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joPatInfo, "selectedInsuInfo.insuplc_admdvs");
  590. Global.pat.psn_insu_date = JsonHelper.getDestValue(joPatInfo, "selectedInsuInfo.psn_insu_date");
  591. Global.pat.cvlserv_flag = JsonHelper.getDestValue(joPatInfo, "selectedInsuInfo.cvlserv_flag");
  592. Global.pat.balc = JsonHelper.getDestValue(joPatInfo, "selectedInsuInfo.balc");
  593. Global.pat.emp_name = JsonHelper.getDestValue(joPatInfo, "selectedInsuInfo.emp_name");
  594. Global.pat.psn_type = JsonHelper.getDestValue(joPatInfo, "selectedInsuInfo.psn_type");
  595. Global.pat.psn_insu_stas = JsonHelper.getDestValue(joPatInfo, "selectedInsuInfo.psn_insu_stas");
  596. Global.pat.insuType = JsonHelper.getDestValue(joPatInfo, "selectedInsuInfo.insutype");
  597. Global.pat.paus_insu_date = JsonHelper.getDestValue(joPatInfo, "selectedInsuInfo.paus_insu_date");
  598. //卡片信息
  599. //Global.pat.cardSN = JsonHelper.getDestValue(joPatInfo, "selectedInsuInfo.paus_insu_date");
  600. //选中的身份信息
  601. return 0;
  602. }
  603. catch (Exception ex)
  604. {
  605. errMsg = "获取患者信息发生异常:" + ex.Message;
  606. return -1;
  607. }
  608. }
  609. /// <summary>
  610. /// 显示住院患者登记面板,返回登记入参
  611. /// </summary>
  612. /// <param name="regInfo"></param>
  613. /// <returns></returns>
  614. public int showInPatRegisterForm(out string regInfo)
  615. {
  616. //调用服务获取门诊诊断信息
  617. string diagnoses;
  618. if (hIS.getPatDiagnoses(Global.pat, out diagnoses) != 0)
  619. {
  620. regInfo = JsonHelper.setExceptionJson(-1, "getPatDiagnoses", diagnoses).ToString();
  621. return -1;
  622. }
  623. JObject joHisRtnInfo = JObject.Parse(diagnoses);
  624. //组织登记入参
  625. JObject joReg = new JObject();
  626. try
  627. {
  628. JArray jaDiagnoses = JArray.Parse(JsonHelper.getDestValue(joHisRtnInfo, "diseinfo"));
  629. string dscg_maindiag_code = "",dscg_maindiag_name = "";
  630. // 对诊断数组进行转换 转换下主要诊断
  631. JArray jaConvertedDiagnoses = new JArray();
  632. JArray jaInPatDiagnoses = new JArray();
  633. JArray jaOutPatDiagnoses = new JArray();
  634. for (int i = 0; i < jaDiagnoses.Count; i++)
  635. {
  636. string diag_type = JsonHelper.getDestValue((JObject)jaDiagnoses[i], "diag_type");
  637. switch (diag_type)
  638. {
  639. case "1":
  640. {
  641. jaDiagnoses[i]["diag_type_name"] = new JObject();
  642. jaDiagnoses[i]["diag_type_name"] = "西医主要诊断";
  643. break;
  644. }
  645. case "2":
  646. {
  647. jaDiagnoses[i]["diag_type_name"] = new JObject();
  648. jaDiagnoses[i]["diag_type_name"] = "西医其他诊断";
  649. break;
  650. }
  651. case "3":
  652. {
  653. jaDiagnoses[i]["diag_type_name"] = new JObject();
  654. jaDiagnoses[i]["diag_type_name"] = "中医主病诊断";
  655. break;
  656. }
  657. case "4":
  658. {
  659. jaDiagnoses[i]["diag_type_name"] = new JObject();
  660. jaDiagnoses[i]["diag_type_name"] = "中医主证诊断";
  661. break;
  662. }
  663. }
  664. //if (jaDiagnoses[i]["diaTypeCode"].ToString() == "ADD") //ADD 入院 OPD 门诊
  665. //{
  666. // jaConvertedDiagnoses.Add(jaDiagnoses[i]);
  667. //}
  668. if (jaDiagnoses[i]["diaTypeCode"].ToString() == "ADD") //ADD 入院 OPD 门诊
  669. {
  670. jaInPatDiagnoses.Add(jaDiagnoses[i]);
  671. }
  672. if (jaDiagnoses[i]["diaTypeCode"].ToString() == "OPD") //ADD 入院 OPD 门诊
  673. {
  674. jaOutPatDiagnoses.Add(jaDiagnoses[i]);
  675. }
  676. }
  677. if (jaInPatDiagnoses.Count > 0)
  678. {
  679. jaConvertedDiagnoses = (JArray)jaInPatDiagnoses.DeepClone();
  680. }
  681. else
  682. {
  683. jaConvertedDiagnoses = (JArray)jaOutPatDiagnoses.DeepClone();
  684. }
  685. for (int i = 0; i < jaConvertedDiagnoses.Count; i++)
  686. {
  687. jaConvertedDiagnoses[i]["diag_srt_no"] = i + 1;
  688. if (jaConvertedDiagnoses[i]["maindiag_flag"].ToString() == "1")
  689. {
  690. dscg_maindiag_code = jaConvertedDiagnoses[i]["diag_code"].ToString();
  691. dscg_maindiag_name = jaConvertedDiagnoses[i]["diag_name"].ToString();
  692. }
  693. }
  694. //登记面板实例
  695. OutpatientRegistration frmReg = new OutpatientRegistration();
  696. frmReg.dblkcbxSettelmentWay.Enabled = false;
  697. DataTable dt = (DataTable)frmReg.dblkcbxInsuranceType.DataSource;
  698. int selectedIndex = 0;
  699. for (int i = 0; i < dt.Rows.Count; i++)
  700. {
  701. if (dt.Rows[i]["Code"].ToString() == Global.pat.insuType)
  702. {
  703. selectedIndex = i;
  704. frmReg.dblkcbxInsuranceType.Text = dt.Rows[i]["Name"].ToString();
  705. frmReg.insuType = dt.Rows[i]["Code"].ToString();
  706. }
  707. }
  708. DataTable dtMedType = (DataTable)frmReg.dblkcbxMedicalType.DataSource;
  709. for (int i = 0; i < dtMedType.Rows.Count; i++)
  710. {
  711. if (dtMedType.Rows[i]["Code"].ToString() == "21")
  712. {
  713. frmReg.dblkcbxMedicalType.Text = dtMedType.Rows[i]["Name"].ToString();
  714. frmReg.med_type = dtMedType.Rows[i]["Code"].ToString();
  715. }
  716. }
  717. frmReg.DtDiagnose = (DataTable)jaConvertedDiagnoses.ToObject(typeof(DataTable));
  718. //展示登记面板
  719. if (frmReg.ShowDialog() == DialogResult.OK)
  720. {
  721. string diseCodg ="",diseName = "";
  722. diseCodg = frmReg.diseCodg;
  723. diseName = frmReg.diseName;
  724. //哈尔滨要求必须传病种。普通疾病传主诊断
  725. //if (string.IsNullOrEmpty(frmReg.diseCodg))
  726. //{
  727. // diseCodg = JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.dscg_maindiag_code");
  728. //};
  729. //if (string.IsNullOrEmpty(frmReg.diseName))
  730. //{
  731. // diseName = JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.dscg_maindiag_name");
  732. //}
  733. JObject joMdtrtinfo = new JObject();
  734. joMdtrtinfo.Add("psn_no", Global.pat.psn_no); //人员编号
  735. joMdtrtinfo.Add("insutype", Global.pat.insuType); //险种类型
  736. joMdtrtinfo.Add("coner_name", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.coner_name")); //联系人姓名
  737. joMdtrtinfo.Add("tel", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.tel")); //联系电话
  738. joMdtrtinfo.Add("begntime", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.begntime")); //开始时间
  739. joMdtrtinfo.Add("mdtrt_cert_type", Global.pat.mdtrtcertType); //就诊凭证类型
  740. joMdtrtinfo.Add("mdtrt_cert_no", Global.pat.mdtrtcertNO); //就诊凭证编号
  741. joMdtrtinfo.Add("med_type", frmReg.med_type); //医疗类别
  742. //joMdtrtinfo.Add("ipt_no", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.ipt_no")); //住院号
  743. joMdtrtinfo.Add("ipt_no", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.medrcdno")); //住院号//根据武汉要求改为病案号
  744. joMdtrtinfo.Add("medrcdno", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.medrcdno")); //病历号
  745. joMdtrtinfo.Add("atddr_no", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.atddr_no")); //主治医生编码
  746. joMdtrtinfo.Add("chfpdr_name", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.chfpdr_name")); //主诊医师姓名
  747. joMdtrtinfo.Add("adm_diag_dscr", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.adm_diag_dscr")); //入院诊断描述
  748. joMdtrtinfo.Add("adm_dept_codg", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.adm_dept_codg")); //入院科室编码
  749. joMdtrtinfo.Add("adm_dept_name", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.adm_dept_name")); //入院科室名称
  750. joMdtrtinfo.Add("adm_bed", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.adm_bed")); //入院床位
  751. joMdtrtinfo.Add("dscg_maindiag_code", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.dscg_maindiag_code")); //住院主诊断代码
  752. joMdtrtinfo.Add("dscg_maindiag_name", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.dscg_maindiag_name")); //住院主诊断名称
  753. //joMdtrtinfo.Add("dscg_maindiag_code", dscg_maindiag_code); //住院主诊断代码
  754. //joMdtrtinfo.Add("dscg_maindiag_name", dscg_maindiag_name); //住院主诊断名称
  755. joMdtrtinfo.Add("main_cond_dscr", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.main_cond_dscr")); //主要病情描述
  756. joMdtrtinfo.Add("dise_codg", diseCodg); //病种编码
  757. joMdtrtinfo.Add("dise_name", diseName); //病种名称
  758. joMdtrtinfo.Add("oprn_oprt_code", frmReg.oprn_oprt_code); //手术操作代码
  759. joMdtrtinfo.Add("oprn_oprt_name", frmReg.oprn_oprt_name); //手术操作名称
  760. joMdtrtinfo.Add("fpsc_no", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.fpsc_no")); //计划生育服务证号
  761. joMdtrtinfo.Add("matn_type", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.matn_type")); //生育类别
  762. joMdtrtinfo.Add("birctrl_type", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.birctrl_type")); //计划生育手术类别
  763. joMdtrtinfo.Add("latechb_flag", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.latechb_flag")); //晚育标志
  764. joMdtrtinfo.Add("geso_val", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.geso_val")); //孕周数
  765. joMdtrtinfo.Add("fetts", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.fetts")); //胎次
  766. joMdtrtinfo.Add("fetus_cnt", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.fetus_cnt")); //胎儿数
  767. joMdtrtinfo.Add("pret_flag", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.pret_flag")); //早产标志
  768. joMdtrtinfo.Add("birctrl_matn_date", ""); //计划生育手术或生育日期 JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.birctrl_matn_date") 20230228医保中心校验传正确时间或空
  769. joMdtrtinfo.Add("dise_type_code", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.dise_type_code")); //病种类型
  770. joMdtrtinfo.Add("exp_content", Global.pat.ExpContent); //字段扩展
  771. joMdtrtinfo.Add("insuplc_admdvs", Global.pat.insuplc_admdvs); //参保地医保区划
  772. joMdtrtinfo.Add("mdtrtarea_admvs", Global.inf.areaCode); //就医地医保区划
  773. joReg.Add("mdtrtinfo", joMdtrtinfo);
  774. joReg.Add("diseinfo", jaConvertedDiagnoses);
  775. Global.pat.disCode = diseCodg;
  776. Global.pat.disName = diseName;
  777. Global.pat.medType = frmReg.med_type;
  778. regInfo = joReg.ToString();
  779. return 0;
  780. }
  781. else
  782. {
  783. regInfo = "收费员取消操作!";
  784. return -1;
  785. }
  786. }
  787. catch (Exception ex)
  788. {
  789. regInfo = "登记界面显示异常:" + ex.Message;
  790. return -1;
  791. }
  792. }
  793. /// <summary>
  794. /// 显示出院登记界面,返回出院登记和结算的入参
  795. /// </summary>
  796. /// <param name="joSumFee"></param>
  797. /// <param name="outParam"></param>
  798. /// <returns></returns>
  799. public int showDischargeRegisterForm(string funNO, JObject joSumFee, JObject joHisRtnInfo, out string outParam)
  800. {
  801. outParam = "";
  802. string errMsg;
  803. try
  804. {
  805. JArray jaDiagnoses = JArray.Parse(JsonHelper.getDestValue(joHisRtnInfo, "diseinfo"));
  806. //选择结算方式等
  807. OutpatientRegistration frmReg = new OutpatientRegistration();
  808. frmReg.dblkcbxInsuranceType.Enabled = true;
  809. DataTable dt = (DataTable)frmReg.dblkcbxInsuranceType.DataSource;
  810. int selectedIndex = 0;
  811. for (int i = 0; i < dt.Rows.Count; i++)
  812. {
  813. if (dt.Rows[i]["Code"].ToString() == Global.pat.insuType)
  814. {
  815. selectedIndex = i;
  816. frmReg.dblkcbxInsuranceType.Text = dt.Rows[i]["Name"].ToString();
  817. frmReg.insuType = dt.Rows[i]["Code"].ToString();
  818. }
  819. }
  820. dt = (DataTable)frmReg.dblkcbxMedicalType.DataSource;
  821. for (int i = 0; i < dt.Rows.Count; i++)
  822. {
  823. if (dt.Rows[i]["Code"].ToString() == Global.pat.medType)
  824. {
  825. frmReg.dblkcbxMedicalType.Text = dt.Rows[i]["Name"].ToString();
  826. frmReg.med_type = dt.Rows[i]["Code"].ToString();
  827. }
  828. }
  829. if (Global.pat.RYorCY == "1")
  830. {
  831. DataTable dtMedType = (DataTable)frmReg.dblkcbxMedicalType.DataSource;
  832. for (int i = 0; i < dtMedType.Rows.Count; i++)
  833. {
  834. if (dtMedType.Rows[i]["Code"].ToString() == "21")
  835. {
  836. frmReg.dblkcbxMedicalType.Text = dtMedType.Rows[i]["Name"].ToString();
  837. frmReg.med_type = dtMedType.Rows[i]["Code"].ToString();
  838. }
  839. }
  840. }
  841. DataTable dtSettlWay = (DataTable)frmReg.dblkcbxSettelmentWay.DataSource;
  842. for (int i = 0; i < dtSettlWay.Rows.Count; i++)
  843. {
  844. if (dtSettlWay.Rows[i]["Code"].ToString() == "01")
  845. {
  846. frmReg.dblkcbxSettelmentWay.Text = dtSettlWay.Rows[i]["Name"].ToString();
  847. frmReg.psn_setlway = dtSettlWay.Rows[i]["Code"].ToString();
  848. }
  849. }
  850. DataTable DTdiseCodg = (DataTable)frmReg.dblkcbxDisease.DataSource;
  851. for (int i = 0; i < DTdiseCodg.Rows.Count; i++)
  852. {
  853. if (DTdiseCodg.Rows[i]["Code"].ToString() == Global.pat.DiseasecCode)
  854. {
  855. frmReg.dblkcbxDisease.Text = DTdiseCodg.Rows[i]["Name"].ToString();
  856. frmReg.diseCodg = DTdiseCodg.Rows[i]["Code"].ToString();
  857. }
  858. }
  859. if (frmReg.dblkcbxInsuranceType.Text != "")
  860. frmReg.dblkcbxInsuranceType.Enabled = false;
  861. if (frmReg.dblkcbxMedicalType.Text != "")
  862. frmReg.dblkcbxMedicalType.Enabled = false;
  863. if (frmReg.dblkcbxDisease.Text != "")
  864. frmReg.dblkcbxDisease.Enabled = false;
  865. // 对诊断数组进行转换 转换下主要诊断
  866. JArray jaConvertedDiagnoses = new JArray();
  867. string dscg_maindiag_code = "", dscg_maindiag_name = "";
  868. for (int i = 0; i < jaDiagnoses.Count; i++)
  869. {
  870. string diag_type = JsonHelper.getDestValue((JObject)jaDiagnoses[i], "diag_type");
  871. switch (diag_type)
  872. {
  873. case "1":
  874. {
  875. jaDiagnoses[i]["diag_type_name"] = new JObject();
  876. jaDiagnoses[i]["diag_type_name"] = "西医主要诊断";
  877. break;
  878. }
  879. case "2":
  880. {
  881. jaDiagnoses[i]["diag_type_name"] = new JObject();
  882. jaDiagnoses[i]["diag_type_name"] = "西医其他诊断";
  883. break;
  884. }
  885. case "3":
  886. {
  887. jaDiagnoses[i]["diag_type_name"] = new JObject();
  888. jaDiagnoses[i]["diag_type_name"] = "中医主病诊断";
  889. break;
  890. }
  891. case "4":
  892. {
  893. jaDiagnoses[i]["diag_type_name"] = new JObject();
  894. jaDiagnoses[i]["diag_type_name"] = "中医主证诊断";
  895. break;
  896. }
  897. }
  898. if (Global.pat.RYorCY == "1")
  899. {
  900. if (jaDiagnoses[i]["diaTypeCode"].ToString() == "ADD") //ADD 入院 OPD 门诊
  901. {
  902. jaConvertedDiagnoses.Add(jaDiagnoses[i]);
  903. }
  904. }
  905. else if (Global.pat.RYorCY == "2")
  906. {
  907. if (jaDiagnoses[i]["diaTypeCode"].ToString() == "DIS") //ADD 入院 OPD 门诊
  908. {
  909. jaConvertedDiagnoses.Add(jaDiagnoses[i]);
  910. }
  911. }
  912. else
  913. {
  914. if (jaDiagnoses[i]["diaTypeCode"].ToString() == "OPD") //ADD 入院 OPD 门诊
  915. {
  916. jaConvertedDiagnoses.Add(jaDiagnoses[i]);
  917. }
  918. }
  919. }
  920. for (int i = 0; i < jaConvertedDiagnoses.Count; i++)
  921. {
  922. jaConvertedDiagnoses[i]["diag_srt_no"] = i + 1;
  923. if (jaConvertedDiagnoses[i]["maindiag_flag"].ToString() == "1")
  924. {
  925. dscg_maindiag_code = jaConvertedDiagnoses[i]["diag_code"].ToString();
  926. dscg_maindiag_name = jaConvertedDiagnoses[i]["diag_name"].ToString();
  927. }
  928. //增加就诊ID
  929. jaConvertedDiagnoses[i]["mdtrt_id"] = new JObject();
  930. jaConvertedDiagnoses[i]["mdtrt_id"] = Global.pat.mdtrtID;
  931. }
  932. frmReg.DtDiagnose = (DataTable)jaConvertedDiagnoses.ToObject(typeof(DataTable));
  933. if (frmReg.ShowDialog() == DialogResult.OK)
  934. {
  935. string diseCodg = "", diseName = "";
  936. //哈尔滨要求必须传病种。普通疾病传主诊断
  937. if (string.IsNullOrEmpty(frmReg.diseCodg))
  938. {
  939. diseCodg = JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.dscg_maindiag_code");
  940. };
  941. if (string.IsNullOrEmpty(frmReg.diseName))
  942. {
  943. diseName = JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.dscg_maindiag_name");
  944. };
  945. //出院登记入参
  946. //单病种出院登记 病种信息取入院登记入参
  947. if (Global.pat.RYorCY == "2")
  948. {
  949. if (Global.pat.medType == "26")
  950. {
  951. diseCodg = Global.pat.DiseasecCode;
  952. diseName = Global.pat.DiseasecName;
  953. }
  954. else
  955. {
  956. frmReg.insuType = Global.pat.insuType;
  957. }
  958. }
  959. JObject joDscgInfo = new JObject();
  960. joDscgInfo.Add("mdtrt_id", Global.pat.mdtrtID);
  961. joDscgInfo.Add("psn_no", Global.pat.psn_no); //人员编号
  962. joDscgInfo.Add("insutype", frmReg.insuType); //险种类型
  963. //joDscgInfo.Add("coner_name", JsonHelper.getJsonValue(joHisPatInfo, "coner_name")); //联系人姓名
  964. //joDscgInfo.Add("tel", JsonHelper.getJsonValue(joHisPatInfo, "tel")); //联系电话
  965. joDscgInfo.Add("endtime", Global.pat.hisDischargeTime); //结束时间DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  966. joDscgInfo.Add("dise_codg", diseCodg); //病种编码
  967. joDscgInfo.Add("dise_name", diseName); //病种名称
  968. joDscgInfo.Add("oprn_oprt_code", frmReg.oprn_oprt_code); //手术操作代码
  969. joDscgInfo.Add("oprn_oprt_name", frmReg.oprn_oprt_name); //手术操作名称
  970. joDscgInfo.Add("fpsc_no", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.fpsc_no")); //计划生育服务证号
  971. joDscgInfo.Add("matn_type", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.matn_type")); //生育类别
  972. joDscgInfo.Add("birctrl_type", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.birctrl_type")); //计划生育手术类别
  973. joDscgInfo.Add("latechb_flag", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.latechb_flag")); //晚育标志
  974. joDscgInfo.Add("geso_val", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.geso_val")); //孕周数
  975. joDscgInfo.Add("fetts", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.fetts")); //胎次
  976. joDscgInfo.Add("fetus_cnt", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.fetus_cnt")); //胎儿数
  977. joDscgInfo.Add("pret_flag", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.pret_flag")); //早产标志
  978. joDscgInfo.Add("birctrl_matn_date", ""); //计划生育手术或生育日期 JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.birctrl_matn_date") 20230228医保中心校验传正确时间或空
  979. joDscgInfo.Add("cop_flag", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.dise_type_code")); //伴有并发症标志
  980. joDscgInfo.Add("dscg_dept_codg", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.adm_dept_codg")); //出院科室编码
  981. joDscgInfo.Add("dscg_dept_name", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.adm_dept_name")); //出院科室名称
  982. joDscgInfo.Add("dscg_bed", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.adm_bed")); //出院床位
  983. joDscgInfo.Add("dscg_way", "1"); //离院方式
  984. joDscgInfo.Add("die_date", ""); //死亡日期
  985. joDscgInfo.Add("exp_content", Global.pat.ExpContent); //字段扩展
  986. joDscgInfo.Add("insuplc_admdvs", Global.pat.insuplc_admdvs); //参保地医保区划
  987. joDscgInfo.Add("mdtrtarea_admvs", Global.inf.areaCode); //就医地医保区划
  988. JObject joRegInpar = new JObject();
  989. joRegInpar.Add("dscginfo", joDscgInfo);
  990. joRegInpar.Add("diseinfo", jaConvertedDiagnoses);
  991. //结算入参
  992. JObject joSetlInpar = new JObject();
  993. joSetlInpar.Add("psn_no", Global.pat.psn_no);
  994. joSetlInpar.Add("chrg_bchno", Global.pat.adm_Dr.ToString());
  995. joSetlInpar.Add("mdtrt_cert_type", Global.pat.mdtrtcertType);
  996. joSetlInpar.Add("mdtrt_cert_no", Global.pat.mdtrtcertNO);
  997. joSetlInpar.Add("med_type", Global.pat.medType);
  998. joSetlInpar.Add("medfee_sumamt", JsonHelper.getDestValue(joSumFee, "data.Sumamt"));
  999. joSetlInpar.Add("psn_setlway", frmReg.psn_setlway); //结算方式
  1000. joSetlInpar.Add("mdtrt_id", Global.pat.mdtrtID);
  1001. joSetlInpar.Add("acct_used_flag", frmReg.personAccountUsedFlag);//个人账户使用标志
  1002. joSetlInpar.Add("insutype", frmReg.insuType);//险种类型
  1003. //joSetlInpar.Add("insuplc_admdvs", Global.pat.insuplc_admdvs);
  1004. //joSetlInpar.Add("mdtrtarea_admvs", Global.inf.areaCode);
  1005. joSetlInpar.Add("invono", "");
  1006. joSetlInpar.Add("mid_setl_flag", "0");
  1007. joSetlInpar.Add("fulamt_ownpay_amt", JsonHelper.getDestValue(joSumFee, "data.FullOwnPayAmount"));
  1008. joSetlInpar.Add("overlmt_selfpay", JsonHelper.getDestValue(joSumFee, "data.OverLimitAmount"));
  1009. joSetlInpar.Add("preselfpay_amt", JsonHelper.getDestValue(joSumFee, "data.PreSelfPayAmount"));
  1010. joSetlInpar.Add("dscgTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  1011. JObject joDataExp = new JObject();
  1012. joDataExp.Add("acct_payamt", "0.00");
  1013. joDataExp.Add("cla_trt_flag", "");
  1014. joSetlInpar.Add("exp_content", Global.pat.ExpContent); //11111
  1015. JObject joOut = new JObject();
  1016. joOut.Add("DischargeRegister", joRegInpar);
  1017. joOut.Add("Settlement", joSetlInpar);
  1018. joOut.Add("errorCode", 0);
  1019. outParam = joOut.ToString();
  1020. return 0;
  1021. }
  1022. else
  1023. {
  1024. outParam = "收款员取消结算";
  1025. return -1;
  1026. }
  1027. }
  1028. catch (Exception ex)
  1029. {
  1030. outParam = "showDischargeRegisterForm 异常:" + ex.Message;
  1031. return -1;
  1032. }
  1033. }
  1034. public int showOutPatRegisterForm(out string regInfo)
  1035. {
  1036. //调用服务获取门诊诊断信息
  1037. string diagnoses;
  1038. if (hIS.getPatDiagnoses(Global.pat, out diagnoses) != 0)
  1039. {
  1040. regInfo = JsonHelper.setExceptionJson(-1, "getPatDiagnoses", diagnoses).ToString();
  1041. return -1;
  1042. }
  1043. JObject joHisRtnInfo = JObject.Parse(diagnoses);
  1044. //组织入参
  1045. JObject joReg = new JObject();
  1046. try
  1047. {
  1048. JArray jaDiagnoses = JArray.Parse(JsonHelper.getDestValue(joHisRtnInfo, "diseinfo"));
  1049. //登记面板实例
  1050. OutpatientRegistration frmReg = new OutpatientRegistration();
  1051. //frmReg.dblkcbxSettelmentWay.Enabled = false;
  1052. //险种类型
  1053. DataTable dtInsuType = (DataTable)frmReg.dblkcbxInsuranceType.DataSource;
  1054. for (int i = 0; i < dtInsuType.Rows.Count; i++)
  1055. {
  1056. if (dtInsuType.Rows[i]["Code"].ToString() == Global.pat.insuType)
  1057. {
  1058. frmReg.dblkcbxInsuranceType.Text = dtInsuType.Rows[i]["Name"].ToString();
  1059. frmReg.insuType = dtInsuType.Rows[i]["Code"].ToString();
  1060. }
  1061. }
  1062. //医疗类别
  1063. DataTable dtMedType = (DataTable)frmReg.dblkcbxMedicalType.DataSource;
  1064. for (int i = 0; i < dtMedType.Rows.Count; i++)
  1065. {
  1066. if (Global.pat.insuType == "390") //湖北居民默认 110104 门诊统筹
  1067. {
  1068. if (dtMedType.Rows[i]["Code"].ToString() == "110104")
  1069. {
  1070. frmReg.dblkcbxMedicalType.Text = dtMedType.Rows[i]["Name"].ToString();
  1071. frmReg.med_type = dtMedType.Rows[i]["Code"].ToString();
  1072. }
  1073. }
  1074. else
  1075. {
  1076. if (dtMedType.Rows[i]["Code"].ToString() == "11")
  1077. {
  1078. frmReg.dblkcbxMedicalType.Text = dtMedType.Rows[i]["Name"].ToString();
  1079. frmReg.med_type = dtMedType.Rows[i]["Code"].ToString();
  1080. }
  1081. }
  1082. }
  1083. //结算方式
  1084. DataTable dtSettlWay = (DataTable)frmReg.dblkcbxSettelmentWay.DataSource;
  1085. for (int i = 0; i < dtSettlWay.Rows.Count; i++)
  1086. {
  1087. if (dtSettlWay.Rows[i]["Code"].ToString() == "01")
  1088. {
  1089. frmReg.dblkcbxSettelmentWay.Text = dtSettlWay.Rows[i]["Name"].ToString();
  1090. frmReg.psn_setlway = dtSettlWay.Rows[i]["Code"].ToString();
  1091. }
  1092. }
  1093. //转换下主要诊断
  1094. for (int i = 0; i < jaDiagnoses.Count; i++)
  1095. {
  1096. string diag_type = JsonHelper.getDestValue((JObject)jaDiagnoses[i], "diag_type");
  1097. switch (diag_type)
  1098. {
  1099. case "1":
  1100. {
  1101. jaDiagnoses[i]["diag_type_name"] = new JObject();
  1102. jaDiagnoses[i]["diag_type_name"] = "西医主要诊断";
  1103. break;
  1104. }
  1105. case "2":
  1106. {
  1107. jaDiagnoses[i]["diag_type_name"] = new JObject();
  1108. jaDiagnoses[i]["diag_type_name"] = "西医其他诊断";
  1109. break;
  1110. }
  1111. case "3":
  1112. {
  1113. jaDiagnoses[i]["diag_type_name"] = new JObject();
  1114. jaDiagnoses[i]["diag_type_name"] = "中医主病诊断";
  1115. break;
  1116. }
  1117. case "4":
  1118. {
  1119. jaDiagnoses[i]["diag_type_name"] = new JObject();
  1120. jaDiagnoses[i]["diag_type_name"] = "中医主证诊断";
  1121. break;
  1122. }
  1123. }
  1124. }
  1125. frmReg.DtDiagnose = (DataTable)jaDiagnoses.ToObject(typeof(DataTable));
  1126. //展示登记面板
  1127. if (frmReg.ShowDialog() == DialogResult.OK)
  1128. {
  1129. string diseCodg = "", diseName = "";
  1130. //哈尔滨要求必须传病种。普通疾病传主诊断
  1131. if (string.IsNullOrEmpty(frmReg.diseCodg))
  1132. {
  1133. diseCodg = JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.dscg_maindiag_code");
  1134. };
  1135. if (string.IsNullOrEmpty(frmReg.diseName))
  1136. {
  1137. diseName = JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.dscg_maindiag_name");
  1138. };
  1139. //组织挂号入参
  1140. JObject joRegInpar = new JObject();
  1141. string occurTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  1142. joRegInpar.Add("psn_no", Global.pat.psn_no);
  1143. joRegInpar.Add("insutype", frmReg.insuType);
  1144. joRegInpar.Add("begntime", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.begntime"));//挂号时间 这里之所以不取当前时间是因为就诊信息上传会关联判断挂号的时间DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  1145. joRegInpar.Add("mdtrt_cert_type", Global.pat.mdtrtcertType);
  1146. joRegInpar.Add("mdtrt_cert_no", Global.pat.mdtrtcertNO);
  1147. joRegInpar.Add("ipt_otp_no", Global.pat.adm_Dr);
  1148. joRegInpar.Add("atddr_no", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.atddr_no"));
  1149. joRegInpar.Add("dr_name", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.chfpdr_name"));
  1150. joRegInpar.Add("dept_code", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.adm_dept_codg"));
  1151. joRegInpar.Add("dept_name", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.adm_dept_name"));
  1152. joRegInpar.Add("exp_content", Global.pat.ExpContent);
  1153. joRegInpar.Add("caty", "72");
  1154. joReg.Add("data", joRegInpar);
  1155. //组织就诊信息入参
  1156. JObject joMdtrtinfo = new JObject();
  1157. for (int i = 0; i < jaDiagnoses.Count; i++)
  1158. {
  1159. jaDiagnoses[i]["vali_flag"] = new JObject();
  1160. jaDiagnoses[i]["vali_flag"] = "1";
  1161. }
  1162. joMdtrtinfo.Add("mdtrt_id", Global.pat.mdtrtID);
  1163. joMdtrtinfo.Add("psn_no", Global.pat.psn_no); //人员编号
  1164. Global.pat.medType = frmReg.med_type;
  1165. joMdtrtinfo.Add("med_type", frmReg.med_type); //医疗类别
  1166. joMdtrtinfo.Add("begntime", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.begntime")); //开始时间
  1167. joMdtrtinfo.Add("main_cond_dscr", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.main_cond_dscr")); //主要病情描述
  1168. joMdtrtinfo.Add("dise_codg", diseCodg); //病种编码
  1169. joMdtrtinfo.Add("dise_name", diseName); //病种名称
  1170. joMdtrtinfo.Add("birctrl_type", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.birctrl_type")); //计划生育手术类别
  1171. joMdtrtinfo.Add("birctrl_matn_date", ""); //计划生育手术或生育日期 JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.birctrl_matn_date") 20230228医保中心校验传正确时间或空
  1172. joMdtrtinfo.Add("matn_type", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.matn_type")); //生育类别
  1173. joMdtrtinfo.Add("geso_val", JsonHelper.getDestValue(joHisRtnInfo, "mdtrtinfo.geso_val")); //孕周数
  1174. joMdtrtinfo.Add("exp_content", ""); //字段扩展
  1175. //组织结算入参
  1176. JObject joSetlInpar = new JObject();
  1177. joSetlInpar.Add("psn_no", Global.pat.psn_no);
  1178. joSetlInpar.Add("mdtrt_cert_type", Global.pat.mdtrtcertType);
  1179. joSetlInpar.Add("mdtrt_cert_no", Global.pat.mdtrtcertNO);
  1180. joSetlInpar.Add("med_type", Global.pat.medType);
  1181. joSetlInpar.Add("medfee_sumamt", "");
  1182. joSetlInpar.Add("psn_setlway", frmReg.psn_setlway); //结算方式
  1183. joSetlInpar.Add("mdtrt_id", Global.pat.mdtrtID);
  1184. joSetlInpar.Add("chrg_bchno", Global.pat.adm_Dr.ToString());
  1185. joSetlInpar.Add("acct_used_flag", frmReg.personAccountUsedFlag);//个人账户使用标志
  1186. joSetlInpar.Add("insutype", frmReg.insuType);//险种类型
  1187. joSetlInpar.Add("pub_hosp_rfom_flag", "");
  1188. joSetlInpar.Add("exp_content", Global.pat.ExpContent);
  1189. joReg.Add("mdtrtinfo", joMdtrtinfo);
  1190. joReg.Add("diseinfo", jaDiagnoses);
  1191. joReg.Add("settlement", joSetlInpar);
  1192. regInfo = joReg.ToString();
  1193. return 0;
  1194. }
  1195. else
  1196. {
  1197. regInfo = "收费员取消操作!";
  1198. return -1;
  1199. }
  1200. }
  1201. catch (Exception ex)
  1202. {
  1203. regInfo = "登记界面显示异常:" + ex.Message;
  1204. return -1;
  1205. }
  1206. }
  1207. /// <summary>
  1208. /// 上传费用到中心
  1209. /// </summary>
  1210. /// <returns></returns>
  1211. ///
  1212. public int uploadFee(string funNO,int singleCount,out string outParam)
  1213. {
  1214. outParam = "";
  1215. //获取IS费用
  1216. if (hIS.getHisFee(Global.pat, out outParam) != 0)
  1217. {
  1218. return -1;
  1219. }
  1220. //调用医保平台转换HIS费用(转换医保编码等)
  1221. JObject joHisFee = JObject.Parse(outParam);
  1222. if (mIS.convertHisFeeWithInsuCode(joHisFee, out outParam) != 0)
  1223. {
  1224. return -2;
  1225. }
  1226. JArray jaFeeDetail = JArray.Parse(JsonHelper.getDestValue(JObject.Parse(outParam), "data"));
  1227. //按指定条数分割后上传,保存,更新
  1228. if (uploadFeeToCenter(funNO, singleCount, jaFeeDetail, out outParam) != 0)
  1229. {
  1230. return -3;
  1231. }
  1232. else
  1233. {
  1234. outParam = "成功";
  1235. return 0;
  1236. }
  1237. }
  1238. public int uploadFeeToCenter(string funNO,int singleCount,JArray jaFeeDetail, out string outParam)
  1239. {
  1240. outParam = "";
  1241. string errMsg;
  1242. try
  1243. {
  1244. JArray jaTmp = new JArray();
  1245. for (int i = 0; i < jaFeeDetail.Count; i++)
  1246. {
  1247. jaFeeDetail[i]["chrg_bchno"] = Global.pat.adm_Dr.ToString();
  1248. jaFeeDetail[i]["med_type"] = Global.pat.medType;
  1249. if (jaFeeDetail[i]["validFlag"].ToString() == "N") continue;
  1250. jaTmp.Add(jaFeeDetail[i]);
  1251. if (((i + 1) % singleCount == 0) || ((i + 1) == jaFeeDetail.Count))
  1252. {
  1253. JObject joFeeDetail = new JObject();
  1254. joFeeDetail.Add("feedetail", jaTmp);
  1255. JObject joRtn = invoker.invokeCenterService(funNO, JsonHelper.setCenterInpar(funNO, joFeeDetail.ToString()));
  1256. if (JsonHelper.parseCenterRtnValue(joRtn, out errMsg) != 0)
  1257. {
  1258. outParam = errMsg;
  1259. return -1;
  1260. }
  1261. else
  1262. {
  1263. //成功后插入医保平台
  1264. if (mIS.insertFee(jaTmp, out errMsg) != 0)
  1265. {
  1266. outParam = outParam + errMsg;
  1267. return -1;
  1268. }
  1269. //更新2301返回的数据
  1270. if (mIS.updateFee(JArray.Parse(JsonHelper.getDestValue(joRtn, "output.result")), out errMsg) != 0)
  1271. {
  1272. outParam = outParam + errMsg;
  1273. return -1;
  1274. }
  1275. }
  1276. jaTmp = new JArray();
  1277. }
  1278. }
  1279. return 0;
  1280. }
  1281. catch (Exception ex)
  1282. {
  1283. outParam = "uploadFee 异常:" + ex.Message;
  1284. return -1;
  1285. }
  1286. }
  1287. /// <summary>
  1288. /// 获取登记时候传入的信息,并赋值给patients结构体
  1289. /// </summary>
  1290. /// <param name="businessType"></param>
  1291. /// <param name="inparam"></param>
  1292. /// <param name="pat"></param>
  1293. public void GetRegPatInfo(string businessType, JObject joInparam,out Patients pat)
  1294. {
  1295. pat = new Patients();
  1296. try
  1297. {
  1298. switch (businessType)
  1299. {
  1300. case "M2"://门诊登记
  1301. {
  1302. break;
  1303. }
  1304. case "M2C"://门诊登记撤销
  1305. {
  1306. break;
  1307. }
  1308. case "Z0"://住院修改
  1309. {
  1310. break;
  1311. }
  1312. case "Z2"://入院登记
  1313. {
  1314. pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInparam, "params[0].admID"));
  1315. pat.psn_no = JsonHelper.getDestValue(joInparam, "params[0].patientInfo.output.baseinfo.psn_no");
  1316. pat.insuType = JsonHelper.getDestValue(joInparam, "params[0].patientInfo.selectedInsuInfo.insutype");
  1317. pat.insuplc_admdvs = JsonHelper.getDestValue(joInparam, "params[0].patientInfo.selectedInsuInfo.insuplc_admdvs");
  1318. pat.mdtrtcertType = JsonHelper.getDestValue(joInparam, "params[0].patientInfo.selectedInsuInfo.mdtrt_cert_type");
  1319. pat.mdtrtcertNO = JsonHelper.getDestValue(joInparam, "params[0].patientInfo.selectedInsuInfo.mdtrt_cert_no");
  1320. pat.name = JsonHelper.getDestValue(joInparam, "params[0].patientInfo.output.baseinfo.psn_name");
  1321. pat.psn_type = JsonHelper.getDestValue(joInparam, "params[0].patientInfo.selectedInsuInfo.psn_type");
  1322. pat.certType = JsonHelper.getDestValue(joInparam, "params[0].patientInfo.output.baseinfo.psn_cert_type");
  1323. pat.certNO = JsonHelper.getDestValue(joInparam, "params[0].patientInfo.output.baseinfo.certno");
  1324. pat.billID = JsonHelper.getDestValue(joInparam, "params[0].billID");
  1325. pat.card.SN = JsonHelper.getDestValue(joInparam, "params[0].patientInfo.cardinfo.card_sn");
  1326. break;
  1327. }
  1328. case "Z2C"://入院登记取消
  1329. {
  1330. pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInparam, "params[0].admID"));
  1331. pat.psn_no = JsonHelper.getDestValue(joInparam, "params[0].psn_no");
  1332. pat.mdtrtID = JsonHelper.getDestValue(joInparam, "params[0].mdtrt_id");
  1333. //pat.insuplc_admdvs = JsonHelper.getDestValue(joInparam, "params[0].insuplc_admdvs");
  1334. pat.insuplc_admdvs = JsonHelper.getDestValue(joInparam, "insuAdmObj.insuplc_admdvs");
  1335. break;
  1336. }
  1337. case "Z6"://出院登记
  1338. {
  1339. pat.hisDischargeTime = Convert.ToDateTime(JsonHelper.getDestValue(joInparam, "insuAdmObj.disDateTime")).ToString("yyyy-MM-dd HH:mm:ss");
  1340. break;
  1341. }
  1342. case "Z6C"://出院登记取消
  1343. {
  1344. pat.psn_no = JsonHelper.getDestValue(joInparam, "insuAdmObj.psn_no");
  1345. pat.mdtrtID = JsonHelper.getDestValue(joInparam, "insuAdmObj.mdtrt_id");
  1346. pat.insuplc_admdvs = JsonHelper.getDestValue(joInparam, "insuAdmObj.insuplc_admdvs");
  1347. break;
  1348. }
  1349. default:
  1350. {
  1351. break;
  1352. }
  1353. }
  1354. //如果患者异地的则就医地需要该为419900
  1355. if (Global.pat.insuplc_admdvs != "")
  1356. {
  1357. if (Global.pat.insuplc_admdvs.Substring(0, 4) != Global.inf.areaCode.Substring(0, 4))
  1358. {
  1359. Global.inf.areaCode = "419900";
  1360. }
  1361. }
  1362. }
  1363. catch (Exception ex)
  1364. {
  1365. Global.writeLog("GetRegPatInfo(" + businessType + ")", JsonHelper.Compress(joInparam),"PAT结构体设置异常:" + ex.Message);
  1366. }
  1367. }
  1368. /// <summary>
  1369. /// 获取费用上传时前端传入的信息,并赋值给patients结构体
  1370. /// </summary>
  1371. /// <param name="businessType"></param>
  1372. /// <param name="joInparam"></param>
  1373. /// <param name="pat"></param>
  1374. public void GetFeeHisInfo(string businessType, JObject joInparam, out Patients pat)
  1375. {
  1376. pat = new Patients();
  1377. try
  1378. {
  1379. switch (businessType)
  1380. {
  1381. case "M3"://门诊费用上传
  1382. {
  1383. break;
  1384. }
  1385. case "M3C"://门诊费用撤销
  1386. {
  1387. break;
  1388. }
  1389. case "Z3"://入院费用上传
  1390. {
  1391. pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInparam, "insuAdmObj.admID"));
  1392. pat.psn_no = JsonHelper.getDestValue(joInparam, "insuAdmObj.psn_no");
  1393. pat.mdtrtID = JsonHelper.getDestValue(joInparam, "insuAdmObj.mdtrt_id");
  1394. pat.insuplc_admdvs = JsonHelper.getDestValue(joInparam, "insuAdmObj.insuplc_admdvs");
  1395. pat.name = JsonHelper.getDestValue(joInparam, "insuAdmObj.psn_name");
  1396. pat.billID = JsonHelper.getDestValue(joInparam, "params[0].billID");
  1397. pat.recordID = "";
  1398. break;
  1399. }
  1400. case "Z3C"://住院费用上传取消
  1401. {
  1402. pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInparam, "insuAdmObj.admID"));
  1403. pat.psn_no = JsonHelper.getDestValue(joInparam, "insuAdmObj.psn_no");
  1404. pat.mdtrtID = JsonHelper.getDestValue(joInparam, "insuAdmObj.mdtrt_id");
  1405. pat.insuplc_admdvs = JsonHelper.getDestValue(joInparam, "insuAdmObj.insuplc_admdvs");
  1406. break;
  1407. }
  1408. default:
  1409. {
  1410. break;
  1411. }
  1412. }
  1413. //如果患者异地的则就医地需要该为369900
  1414. if (Global.pat.insuplc_admdvs != "")
  1415. {
  1416. if (Global.pat.insuplc_admdvs.Substring(0, 4) != Global.inf.areaCode.Substring(0, 4))
  1417. {
  1418. Global.inf.areaCode = "369900";
  1419. }
  1420. }
  1421. }
  1422. catch (Exception ex)
  1423. {
  1424. Global.writeLog("GetFeeHisInfo(" + businessType + ")", JsonHelper.Compress(joInparam), "PAT结构体设置异常:" + ex.Message);
  1425. }
  1426. }
  1427. /// <summary>
  1428. /// 获取结算时前端传入的信息,并赋值给patients结构体
  1429. /// </summary>
  1430. /// <param name="businessType"></param>
  1431. /// <param name="joInparam"></param>
  1432. /// <param name="pat"></param>
  1433. public void GetSettlementHisInfo(string businessType, JObject joInparam, out Patients pat)
  1434. {
  1435. pat = new Patients();
  1436. switch (businessType)
  1437. {
  1438. case "M4"://门诊预结算
  1439. {
  1440. break;
  1441. }
  1442. case "M4C"://门诊预结算撤销
  1443. {
  1444. break;
  1445. }
  1446. case "M5"://门诊结算
  1447. {
  1448. pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInparam, "params[0].admID"));
  1449. pat.recordID = JsonHelper.getDestValue(joInparam, "params[0].recordID");
  1450. pat.billID = JsonHelper.getDestValue(joInparam, "params[0].billID");
  1451. Global.pat.insuplc_admdvs = "";
  1452. break;
  1453. }
  1454. case "M5C"://门诊结算撤销
  1455. {
  1456. pat.psn_no = JsonHelper.getDestValue(joInparam, "insuAdmObj.psn_no");
  1457. pat.mdtrtID = JsonHelper.getDestValue(joInparam, "insuAdmObj.mdtrt_id");
  1458. pat.settlID = JsonHelper.getDestValue(joInparam, "insuAdmObj.setl_id");
  1459. pat.insuplc_admdvs = JsonHelper.getDestValue(joInparam, "insuAdmObj.insuplc_admdvs");
  1460. pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInparam, "params[0].admID"));
  1461. pat.recordID = JsonHelper.getDestValue(joInparam, "params[0].recordID");
  1462. pat.billID = JsonHelper.getDestValue(joInparam, "params[0].billID");
  1463. break;
  1464. }
  1465. case "Z4"://住院预结算
  1466. {
  1467. pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInparam, "insuAdmObj.admID"));
  1468. pat.psn_no = JsonHelper.getDestValue(joInparam, "insuAdmObj.psn_no");
  1469. pat.mdtrtID = JsonHelper.getDestValue(joInparam, "insuAdmObj.mdtrt_id");
  1470. pat.insuplc_admdvs = JsonHelper.getDestValue(joInparam, "insuAdmObj.insuplc_admdvs");
  1471. pat.name = JsonHelper.getDestValue(joInparam, "insuAdmObj.psn_name");
  1472. pat.billID = JsonHelper.getDestValue(joInparam, "params[0].billID");
  1473. break;
  1474. }
  1475. case "Z4C"://住院预结算撤销
  1476. {
  1477. pat.psn_no = JsonHelper.getDestValue(joInparam, "insuAdmObj.psn_no");
  1478. pat.mdtrtID = JsonHelper.getDestValue(joInparam, "insuAdmObj.mdtrt_id");
  1479. pat.settlID = JsonHelper.getDestValue(joInparam, "insuAdmObj.setl_id");
  1480. pat.insuplc_admdvs = JsonHelper.getDestValue(joInparam, "insuAdmObj.insuplc_admdvs");
  1481. pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInparam, "params[0].admID"));
  1482. pat.recordID = JsonHelper.getDestValue(joInparam, "params[0].recordID");
  1483. pat.billID = JsonHelper.getDestValue(joInparam, "params[0].billID");
  1484. break;
  1485. }
  1486. case "Z5"://住院结算
  1487. {
  1488. pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInparam, "insuAdmObj.admID"));
  1489. pat.psn_no = JsonHelper.getDestValue(joInparam, "insuAdmObj.psn_no");
  1490. pat.mdtrtID = JsonHelper.getDestValue(joInparam, "insuAdmObj.mdtrt_id");
  1491. pat.insuplc_admdvs = JsonHelper.getDestValue(joInparam, "insuAdmObj.insuplc_admdvs");
  1492. pat.name = JsonHelper.getDestValue(joInparam, "insuAdmObj.psn_name");
  1493. pat.billID = JsonHelper.getDestValue(joInparam, "params[0].billID");
  1494. pat.hisDischargeTime = Convert.ToDateTime(JsonHelper.getDestValue(joInparam, "insuAdmObj.disDateTime")).ToString("yyyy-MM-dd HH:mm:ss");
  1495. break;
  1496. }
  1497. case "Z5C"://住院结算撤销
  1498. {
  1499. pat.adm_Dr = int.Parse(JsonHelper.getDestValue(joInparam, "insuAdmObj.admID"));
  1500. pat.psn_no = JsonHelper.getDestValue(joInparam, "insuAdmObj.psn_no");
  1501. pat.mdtrtID = JsonHelper.getDestValue(joInparam, "insuAdmObj.mdtrt_id");
  1502. pat.insuplc_admdvs = JsonHelper.getDestValue(joInparam, "insuAdmObj.insuplc_admdvs");
  1503. pat.name = JsonHelper.getDestValue(joInparam, "insuAdmObj.psn_name");
  1504. pat.billID = JsonHelper.getDestValue(joInparam, "params[0].billID");
  1505. pat.settlID = JsonHelper.getDestValue(joInparam, "insuAdmObj.setl_id");
  1506. pat.SettID_HISJSB = pat.settlID; //这里是通过09010059交易获取到的结算ID
  1507. break;
  1508. }
  1509. default:
  1510. {
  1511. break;
  1512. }
  1513. }
  1514. //如果患者异地的则就医地需要该为369900
  1515. //if (Global.pat.insuplc_admdvs != "")
  1516. //{
  1517. // if (Global.pat.insuplc_admdvs.Substring(0, 4) != Global.inf.areaCode.Substring(0, 4))
  1518. // {
  1519. // Global.inf.areaCode = "369900";
  1520. // }
  1521. //}
  1522. }
  1523. ///对目录下载业务的封装
  1524. ///
  1525. public JObject DownloadDirectory(string funNO,string inParam)
  1526. {
  1527. string errorMessage = "", sRtn = "";
  1528. JObject joRtn = new JObject();
  1529. try
  1530. {
  1531. JObject joCenterRtn = cBus.DownDirecotry(funNO,inParam);
  1532. if (JsonHelper.parseCenterRtnValue(joCenterRtn,out errorMessage) != 0)
  1533. {
  1534. joRtn = JsonHelper.setExceptionJson(-100, "下载异常", errorMessage);
  1535. return joRtn;
  1536. }
  1537. string filename = JsonHelper.getDestValue(joCenterRtn, "output.filename");
  1538. //MessageBox.Show("1306查询目录文件号返回:"+ joCenterRtn.ToString());
  1539. JObject jo9102Rtn = cBus.SaveFile(joCenterRtn);
  1540. if (JsonHelper.parseIrisRtnValue(jo9102Rtn,out errorMessage) != 0)
  1541. {
  1542. joRtn = JsonHelper.setExceptionJson(-100, "保存文件异常", errorMessage);
  1543. return joRtn;
  1544. }
  1545. //解压缩
  1546. string zipFilePath = jo9102Rtn["filePath"].ToString();
  1547. string txtFileDir = System.Environment.CurrentDirectory + "\\Download";
  1548. string txtFilePath = txtFileDir + "\\" + filename.Substring(0, filename.Length - 4);
  1549. //string txtFilePath = Global.curEvt.path + "\\Download\\" + filename;
  1550. //MessageBox.Show("解压缩的txtFilePath:"+ zipFilePath+"|解压到目标路径:"+ txtFileDir+"|文件解析路径:"+ txtFilePath);
  1551. //昆明下载下来的文件是解压后的TXT
  1552. if (tools.ExtractFile(zipFilePath, txtFileDir, out errorMessage) != 0)
  1553. {
  1554. joRtn = JsonHelper.setExceptionJson(-100, "提取文件", errorMessage);
  1555. return joRtn;
  1556. }
  1557. joRtn = (JObject)jo9102Rtn.DeepClone();
  1558. joRtn["filePath"] = txtFilePath;
  1559. return joRtn;
  1560. }
  1561. catch (Exception ex)
  1562. {
  1563. joRtn = JsonHelper.setExceptionJson(-100, "下载中心目录", errorMessage);
  1564. return joRtn;
  1565. }
  1566. finally
  1567. {
  1568. Global.writeLog("HisMainBusiness.DownloadDirectory", inParam, joRtn.ToString());
  1569. }
  1570. }
  1571. /// <summary>
  1572. /// 字典下载
  1573. /// </summary>
  1574. /// <param name="inParam"></param>
  1575. /// <returns></returns>
  1576. public string downDictionary(string inParam)
  1577. {
  1578. JObject joCenterRtn = invoker.invokeCenterService("1901", inParam);
  1579. return joCenterRtn.ToString();
  1580. }
  1581. /// <summary>
  1582. /// 展示结算信息界面
  1583. /// </summary>
  1584. /// <param name="joSettlement"></param>
  1585. /// <param name="outParam"></param>
  1586. /// <returns></returns>
  1587. public int showSettlementForm(JObject joSettlement, out string outParam)
  1588. {
  1589. outParam = "";
  1590. string errMsg;
  1591. try
  1592. {
  1593. SettlementInfo frmSettlment = new SettlementInfo(joSettlement);
  1594. //相关信息转换到结算信息面板
  1595. if (frmSettlment.ShowDialog() == DialogResult.OK)
  1596. {
  1597. return 0;
  1598. }
  1599. else
  1600. {
  1601. outParam = "收款员取消";
  1602. return -1;
  1603. }
  1604. }
  1605. catch (Exception ex)
  1606. {
  1607. outParam = "showSettlementForm 异常:" + ex.Message;
  1608. return -1;
  1609. }
  1610. }
  1611. /// <summary>
  1612. /// 门诊预结算封装,返回正式结算的入参
  1613. /// </summary>
  1614. /// <param name="joSettlement"></param>
  1615. /// <param name="outParam"></param>
  1616. /// <returns></returns>
  1617. public int preSettlement_OutPat( JObject joSettlement, out string outParam)
  1618. {
  1619. outParam = "";
  1620. //预结算
  1621. JObject jo2206Data = new JObject();
  1622. jo2206Data.Add("data", joSettlement);
  1623. JObject jo2206Rtn = invoker.invokeCenterService("2206", JsonHelper.setCenterInpar("2206", jo2206Data));
  1624. if (JsonHelper.parseCenterRtnValue(jo2206Rtn, out outParam) != 0)
  1625. {
  1626. outParam = JsonHelper.setExceptionJson(-1, "出院预结算", outParam).ToString();
  1627. return -1;
  1628. }
  1629. //返回给HIS进行预结算判断
  1630. JObject joSetlinfo = JObject.Parse(JsonHelper.getDestValue(jo2206Rtn, "output.setlinfo"));
  1631. if (hIS.preSettlement(joSettlement, joSetlinfo, out outParam) != 0)
  1632. {
  1633. outParam = JsonHelper.setExceptionJson(-1, "返回结算信息给HIS", outParam).ToString();
  1634. return -1;
  1635. }
  1636. //编码转换
  1637. if (mIS.convertSettlementWithInsuCode(jo2206Rtn, out outParam) != 0)
  1638. {
  1639. outParam = JsonHelper.setExceptionJson(-1, "结算信息转换", outParam).ToString();
  1640. return -1;
  1641. }
  1642. JObject joSumFee = new JObject();
  1643. string errMsg = "";
  1644. //判断勾稽关系是否平
  1645. if (hIS.sumInsuRtnSettlInfo(JObject.Parse(JsonHelper.getDestValue(jo2206Rtn, "output.setlinfo")), out joSumFee, out errMsg) != 0)
  1646. {
  1647. outParam = "勾稽关系不符合标准,请联系管理员!" + errMsg;
  1648. return -1;
  1649. }
  1650. //展示结算信息
  1651. JObject joConverted = JObject.Parse(outParam);
  1652. if (showSettlementForm(joConverted, out outParam) != 0)
  1653. {
  1654. outParam = JsonHelper.setExceptionJson(-1, "结算信息展示", outParam).ToString();
  1655. return -1;
  1656. }
  1657. else
  1658. {
  1659. return 0;
  1660. }
  1661. }
  1662. /// <summary>
  1663. /// 预结算封装,返回正式结算的入参
  1664. /// </summary>
  1665. /// <param name="joSettlement"></param>
  1666. /// <param name="outParam"></param>
  1667. /// <returns></returns>
  1668. public int preSettlement(string funNO,out JObject joSettlement, out string outParam)
  1669. {
  1670. joSettlement = new JObject();
  1671. outParam = "";
  1672. string outPar = "";
  1673. //调用IRIS获取医保各项金额
  1674. if (mIS.getSumFee(out outPar) != 0)
  1675. {
  1676. outParam = JsonHelper.setExceptionJson(-1, "获取医保费用各项汇总金额", outPar).ToString();
  1677. return -1;
  1678. }
  1679. JObject joSumFee = JObject.Parse(outPar);
  1680. if ((JsonHelper.getDestValue(joSumFee, "data.Sumamt") == "") || (JsonHelper.getDestValue(joSumFee, "data.Sumamt") == "0"))
  1681. {
  1682. outParam = "请先右击选择【医保费用上传】!";
  1683. return -1;
  1684. }
  1685. //从云医保平台获取患者详细的医保登记信息
  1686. int type;
  1687. if (funNO == "2206")
  1688. {
  1689. type = 3; //门诊预结算
  1690. }
  1691. else
  1692. {
  1693. type = 1; //住院预结算
  1694. }
  1695. if (mIS.queryRegisterInfo(type, out outParam) != 0)
  1696. {
  1697. outParam = JsonHelper.setExceptionJson(-1, "查询患者云平台登记信息", outParam).ToString();
  1698. return -1;
  1699. }
  1700. JObject joReg = JObject.Parse(outParam);
  1701. Global.pat.medType = JsonHelper.getDestValue(joReg, "data.MedicalType");
  1702. Global.pat.insuType = JsonHelper.getDestValue(joReg, "data.InsuType");
  1703. Global.pat.mdtrtcertType = JsonHelper.getDestValue(joReg, "data.CertificateType");
  1704. Global.pat.mdtrtcertNO = JsonHelper.getDestValue(joReg, "data.CertificateNO");
  1705. Global.pat.certType = JsonHelper.getDestValue(joReg, "data.CertificateType");
  1706. Global.pat.certNO = JsonHelper.getDestValue(joReg, "data.CertificateNO");
  1707. Global.pat.insuplc_admdvs = JsonHelper.getDestValue(joReg, "data.InsuranceAreaCode");
  1708. Global.pat.psn_type = Global.pat.insuType; //后面再改
  1709. if ((Global.pat.RYorCY == "2") && (Global.pat.medType == "26"))
  1710. {
  1711. Global.pat.DiseasecCode = JsonHelper.getDestValue(joReg, "data.DiseasecCode");
  1712. Global.pat.DiseasecName = JsonHelper.getDestValue(joReg, "data.DiseasecName");
  1713. }
  1714. //昆明结算前读卡核验身份
  1715. //string patInfo = "";
  1716. //if (readCard(out patInfo) != 0)
  1717. //{
  1718. // outParam = JsonHelper.setExceptionJson(-1, "readCard", patInfo).ToString();
  1719. // return -1;
  1720. //}
  1721. //调用服务获取门诊诊断信息
  1722. string diagnoses;
  1723. if (hIS.getPatDiagnoses(Global.pat, out diagnoses) != 0)
  1724. {
  1725. outParam = JsonHelper.setExceptionJson(-1, "getPatDiagnoses", diagnoses).ToString();
  1726. return -1;
  1727. }
  1728. JObject joDiagnoses = JObject.Parse(diagnoses);
  1729. //展示出院登记界面,选择结算方式等
  1730. if (showDischargeRegisterForm(funNO, joSumFee, joDiagnoses, out outParam) != 0)
  1731. {
  1732. outParam = JsonHelper.setExceptionJson(-1, "展示出院预结算界面", outParam).ToString();
  1733. return -1;
  1734. }
  1735. JObject joRtn = JObject.Parse(outParam);
  1736. JObject jo2303Inpar = JObject.Parse(JsonHelper.getDestValue(joRtn, "Settlement"));
  1737. JObject jo2402Inpar = JObject.Parse(JsonHelper.getDestValue(joRtn, "DischargeRegister"));
  1738. //昆明出院登记放再预结算之前
  1739. JObject jo2402Rtn = invoker.invokeCenterService("2402", JsonHelper.setCenterInpar("2402", jo2402Inpar));
  1740. string errMsg;
  1741. if (JsonHelper.parseCenterRtnValue(jo2402Rtn, out errMsg) != 0)
  1742. {
  1743. outParam = JsonHelper.setExceptionJson(-1, "预结算失败:出院登记失败", errMsg).ToString();
  1744. return -1;
  1745. }
  1746. //预结算
  1747. JObject jo2303Data = new JObject();
  1748. jo2303Data.Add("data", jo2303Inpar);
  1749. JObject jo2303Rtn = invoker.invokeCenterService(funNO, JsonHelper.setCenterInpar(funNO, jo2303Data));
  1750. if (JsonHelper.parseCenterRtnValue(jo2303Rtn, out outParam) != 0)
  1751. {
  1752. outParam = JsonHelper.setExceptionJson(-1, "出院预结算", outParam).ToString();
  1753. return -1;
  1754. }
  1755. //预结算结果传给HIS进行HIS判断
  1756. if (funNO == "2303")
  1757. {
  1758. //返回给HIS
  1759. JObject joSetlinfo = JObject.Parse(JsonHelper.getDestValue(jo2303Rtn, "output.setlinfo"));
  1760. JObject joParam = new JObject();
  1761. joParam.Add("admID", Global.pat.adm_Dr);
  1762. joParam.Add("recordID", Global.pat.recordID);
  1763. joParam.Add("billID", Global.pat.billID);
  1764. if (hIS.preSettlementInfo(joParam, joSetlinfo, out outParam) != 0)
  1765. {
  1766. outParam = JsonHelper.setExceptionJson(-1, "出院预结算", outParam).ToString();
  1767. return -1;
  1768. }
  1769. }
  1770. //编码转换
  1771. if (mIS.convertSettlementWithInsuCode(jo2303Rtn, out outParam) != 0)
  1772. {
  1773. outParam = JsonHelper.setExceptionJson(-1, "结算信息转换", outParam).ToString();
  1774. return -1;
  1775. }
  1776. //展示结算信息
  1777. JObject joConverted = JObject.Parse(outParam);
  1778. if (showSettlementForm(joConverted, out outParam) != 0)
  1779. {
  1780. outParam = JsonHelper.setExceptionJson(-1, "结算信息展示", outParam).ToString();
  1781. return -1;
  1782. }
  1783. else
  1784. {
  1785. joSettlement = (JObject)joRtn.DeepClone();
  1786. return 0;
  1787. }
  1788. }
  1789. public int returnToFrontEndAfterSettlement(JObject joCenterRtn,JObject joHisServieRtn, out string outParam)
  1790. {
  1791. outParam = "";
  1792. try
  1793. {
  1794. JObject johisInsuInfo = JObject.Parse(JsonHelper.getDestValue(joHisServieRtn, "result"));
  1795. johisInsuInfo.Add("setl_id", JsonHelper.getDestValue(joCenterRtn, "output.setlinfo.setl_id"));
  1796. JObject joTmp = (JObject)joCenterRtn.DeepClone();
  1797. joTmp.Add("hisInsuInfo", johisInsuInfo);
  1798. outParam = joTmp.ToString();
  1799. return 0;
  1800. }
  1801. catch (Exception ex)
  1802. {
  1803. outParam = "returnToFrontEndAfterSettlement:" + ex.Message;
  1804. return -1;
  1805. }
  1806. }
  1807. /// <summary>
  1808. /// 插入患者该次就诊参保信息
  1809. /// </summary>
  1810. /// <param name="mdtrtID"></param>
  1811. /// <param name="patInfo"></param>
  1812. /// <param name="outparam"></param>
  1813. /// <returns></returns>
  1814. public int insertPatCurInsuInfo(String patInfo, out string outparam)
  1815. {
  1816. Global.writeLog(" " + patInfo);
  1817. outparam = "";
  1818. try
  1819. {
  1820. JObject joPatInfo = JObject.Parse(patInfo);
  1821. JObject joBaseInfo = JObject.Parse(JsonHelper.getDestValue(joPatInfo, "output.baseinfo"));
  1822. JObject joInsuInfo = JObject.Parse(JsonHelper.getDestValue(joPatInfo, "selectedInsuInfo"));
  1823. JObject joIdetInfo = JObject.Parse(JsonHelper.getDestValue(joPatInfo, "selectedIdInfo"));
  1824. if (mIS.insertPatCurInsuInfo(joBaseInfo, joInsuInfo, joIdetInfo, out outparam) != 0)
  1825. {
  1826. return -1;
  1827. }
  1828. else
  1829. {
  1830. return 0;
  1831. }
  1832. }
  1833. catch (Exception e)
  1834. {
  1835. outparam = "插入患者该次就诊参保信息失败:" + e.Message;
  1836. return -1;
  1837. }
  1838. }
  1839. public void getLocalConfingue()
  1840. {
  1841. IniFile ini = new IniFile(Global.curEvt.path + @"\INSUConfigure.ini");
  1842. Global.curEvt.ext.isOpenAnalysis = (ini.ReadValue("PreAndInProcessAnalysis", "isOpenAnalysis") == "1");
  1843. }
  1844. /// <summary>
  1845. /// 事前分析
  1846. /// </summary>
  1847. /// <param name="outparam"></param>
  1848. /// <returns></returns>
  1849. public int PreAnalysis(string trig_scen, string inparam, out string outparam)
  1850. {
  1851. outparam = "";
  1852. try
  1853. {
  1854. ////先签到
  1855. //JObject jo9001Rtn = new JObject();
  1856. //cBus.signIn(out jo9001Rtn);
  1857. if (trig_scen == "5")
  1858. {
  1859. outparam = inparam;
  1860. }
  1861. else
  1862. {
  1863. //获取HIS返回的内容
  1864. if (hIS.PreAnalysis(out outparam) != 0)
  1865. {
  1866. return -1;
  1867. }
  1868. }
  1869. PreAndInProcessAnalysis preAnalysis = new PreAndInProcessAnalysis(outparam);
  1870. if (preAnalysis.setPatientByHisBaseInfo(out outparam) != 0)
  1871. {
  1872. return -1;
  1873. }
  1874. outparam = preAnalysis.Get3101Inpar(trig_scen, Global.pat).ToString();
  1875. JObject joRtn = invoker.invokeCenterService("3101", JsonHelper.setCenterInpar("3101", outparam));
  1876. if (JsonHelper.parseCenterRtnValue(joRtn, out outparam) != 0)
  1877. {
  1878. return -1;
  1879. }
  1880. else
  1881. {
  1882. JArray jaResult = JArray.Parse(JsonHelper.getDestValue(joRtn, "output.result"));
  1883. if (jaResult.HasValues)
  1884. {
  1885. PreAndInProcessAnalysisForm paipaForm = new PreAndInProcessAnalysisForm(joRtn);
  1886. if (paipaForm.ShowDialog() == DialogResult.OK)
  1887. {
  1888. return 0;
  1889. }
  1890. else
  1891. {
  1892. outparam = "事前事中审核不通过,操作员取消!";
  1893. return -1;
  1894. }
  1895. }
  1896. else
  1897. return 0;
  1898. }
  1899. }
  1900. catch (Exception ex)
  1901. {
  1902. outparam = ex.Message;
  1903. return -1;
  1904. }
  1905. }
  1906. }
  1907. }