MedInsuQuery.cs 94 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148
  1. using Newtonsoft.Json.Linq;
  2. using System;
  3. using System.IO;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Data;
  7. using System.Drawing;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12. using PTMedicalInsurance.Common;
  13. using PTMedicalInsurance.Helper;
  14. using PTMedicalInsurance.FormSetter;
  15. using PTMedicalInsurance.Business;
  16. using PTMedicalInsurance.Variables;
  17. namespace PTMedicalInsurance.Forms
  18. {
  19. public partial class MedInsuQuery : Form
  20. {
  21. DataTable dtExport;
  22. JObject joRtn10001 = new JObject();
  23. JObject joInput20002 = new JObject();
  24. public string patInfo = "", ReadCardOutParam = "", CertNo = "";
  25. public string presAdmLoc = "", presAdmDoc = "", presAdmID = "", presNo = "", hiRxno = "";
  26. public string DrCode = "", DrName = "", DrInsuCode = "", DrCertNo = "";
  27. public string IID;
  28. //1.声明自适应类实例
  29. AutoResizeForm asc = new AutoResizeForm();
  30. private InvokeHelper invoker = new InvokeHelper();
  31. private HisIrisServices hIS = new HisIrisServices();
  32. private MIIrisServices mIS = new MIIrisServices();
  33. HisMainBusiness hBus = new HisMainBusiness();
  34. CenterBusiness cBus = new CenterBusiness();
  35. private IrisServices IS = new IrisServices();
  36. public MedInsuQuery()
  37. {
  38. InitializeComponent();
  39. asc.controllInitializeSize(this);
  40. asc.controlAutoSize(this);
  41. }
  42. public MedInsuQuery(JObject jo)
  43. {
  44. InitializeComponent();
  45. Global.pat.certNO = JsonHelper.getDestValue(jo, "idNo");
  46. IID = JsonHelper.getDestValue(jo, "idNo");
  47. if (!string.IsNullOrEmpty(Global.pat.admID))
  48. {
  49. string hisPatBaseInfo = "";
  50. if (hIS.GetHisPatBaseInfo(out hisPatBaseInfo) != 0)
  51. {
  52. }
  53. }
  54. //jaVolaItems = JArray.Parse(JsonHelper.getDestValue(jo, "output.result"));
  55. //dtVolaItems = (DataTable)jo["output"]["result"].ToObject(typeof(DataTable));
  56. //dgvVolaItems.DataSource = dtVolaItems;
  57. //grdSetter.SetHeaderTextOfPAIPAVolaItem(dgvVolaItems);
  58. //tbJrID.Text = JsonHelper.getDestValue(jo, "output.result[0].jr_id");
  59. //tbRuleID.Text = JsonHelper.getDestValue(jo, "output.result[0].rule_id");
  60. //tbPatID.Text = JsonHelper.getDestValue(jo, "output.result[0].patn_id");
  61. //tbMdtrdID.Text = JsonHelper.getDestValue(jo, "output.result[0].mdtrt_id");
  62. //tbVolaAmt.Text = JsonHelper.getDestValue(jo, "output.result[0].vola_amt");
  63. //tbVolaAmtStas.Text = JsonHelper.getDestValue(jo, "output.result[0].vola_amt_stas");
  64. //tbSevDeg.Text = JsonHelper.getDestValue(jo, "output.result[0].sev_deg");
  65. //tbVolaBhvrType.Text = JsonHelper.getDestValue(jo, "output.result[0].vola_bhvr_type");
  66. //tbVolaEvid.Text = JsonHelper.getDestValue(jo, "output.result[0].vola_evid");
  67. //tbRuleName.Text = JsonHelper.getDestValue(jo, "output.result[0].rule_name");
  68. //rbtVolaContent.Text = JsonHelper.getDestValue(jo, "output.result[0].vola_cont");
  69. }
  70. public MedInsuQuery(int iPage)
  71. {
  72. InitializeComponent();
  73. asc.controllInitializeSize(this);
  74. asc.controlAutoSize(this);
  75. tbcMain.SelectedIndex = iPage;
  76. }
  77. private void btnClose_Click(object sender, EventArgs e)
  78. {
  79. this.Close();
  80. }
  81. private void MedInsuQuery_Load(object sender, EventArgs e)
  82. {
  83. //this.WindowState = FormWindowState.Maximized;
  84. tbcMain.SelectedIndex = 6;
  85. dpST.Text = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  86. dpED.Text = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  87. dt_ST.Text = DateTime.Now.ToString("yyyy-MM-01 00:00:00");
  88. dt_ET.Text = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  89. date_st.Text = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  90. date_et.Text = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  91. dtp_st.Text = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  92. dtp_et.Text = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  93. dpt_ST.Text = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  94. dpt_ET.Text = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  95. dptST2.Text = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  96. dptET2.Text = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  97. DT_ST1.Text = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  98. DT_ET1.Text = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  99. dptST.Text = DateTime.Now.AddDays(-30).ToString("yyyy-MM-dd 00:00:00");
  100. dptET.Text = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  101. dtTHSJ.Text = DateTime.Now.ToString();
  102. // dgvSettlRecord.AutoGenerateColumns = false;
  103. cbbLevel.SelectedIndex = 0;
  104. cbbOverPrice.SelectedIndex = 0;
  105. GridViewSetter grdSetter = new GridViewSetter();
  106. grdSetter.SetHeaderTextOfMedInsuHosPerInfo(dgvSettlRecord);
  107. grdSetter.SetHeaderTextOfSettlList(dgvSettlRecord2);
  108. grdSetter.SetHeaderTextOfSettltMentFeelDetailInfo(dgvInsuFeeUpload);
  109. grdSetter.DatagridviewColumnWidthAdaptation(dgvInsuFeeUpload);
  110. //grdSetter.SetHeaderTextOfMIPatCurrentInsuInfo(dgv_4001);
  111. grdSetter.SetHeaderTextOfSettlList(dgvSettleData);
  112. grdSetter.SetHeaderTextOfSettltMentFeelDetailInfo(dgvFeeInfo);
  113. grdSetter.SetHeaderTextOfHISRegister(dgv_HISRegInfo);
  114. grdSetter.SetHeaderTextOfHISPrescFee(dgv_PrescriptionInfo);
  115. grdSetter.SetHeaderTextOfBillInfo(dgv_BillInfo);
  116. grdSetter.SetHeaderTextOfBillDetailInfo(dgv_BillDetailInfo);
  117. grdSetter.SetHeaderTextOf5205DrugDetailInfo(dgv5205);
  118. grdSetter.DatagridviewColumnWidthAdaptation(dgv_HISRegInfo);
  119. grdSetter.DatagridviewColumnWidthAdaptation(dgv_PrescriptionInfo);
  120. grdSetter.DatagridviewColumnWidthAdaptation(dgv_BillInfo);
  121. grdSetter.DatagridviewColumnWidthAdaptation(dgv_BillDetailInfo);
  122. grdSetter.DatagridviewColumnWidthAdaptation(dgv5205);
  123. rbg_Type.SelectedIndex = 0;
  124. tbJGBM.Text = Global.inf.hospitalNO;
  125. dtTHSJ.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  126. rbg_BussnisType.SelectedIndex = 0;
  127. if (!string.IsNullOrEmpty(IID))
  128. {
  129. tbcMain.TabPages.Clear();
  130. tbcMain.TabPages.Add(tab5205);
  131. }
  132. }
  133. private void btnQuery_Click(object sender, EventArgs e)
  134. {
  135. btnPrint.Enabled = false;
  136. string sCZYXM = Global.user.name;
  137. string SqlHeard = " Adm_Dr,MdtrtID,Name as PatientName,Age,PsnCertNO,Gend,PsnType,EmpName,AdmInDepName,insuplcAdmdvs,sZYZT AS sZTSM, "
  138. + " AdmBed,RegDate,MainDiagName,AttendDoctorNO,ChiefPhyDocName,'" + sCZYXM + "' as OpertName,'' as InHospNo,''Address ";
  139. string SqlStrMain = " SELECT a.*,b.*,a.PatientName AS Name,a.PsnType AS PsnTypeCode,'在院' sZYZT FROM BS_MIPatCurrentInsuInfo a LEFT JOIN BS_MedInsuRegisterInfo b "
  140. + " ON a.MdtrtID=b.InsuRegID AND a.Interface_Dr=b.Interface_Dr AND a.Hospital_Dr=b.Hospital_Dr "
  141. + " WHERE b.Type=1 AND b.ValidFlag=1 AND b.Hospital_Dr= " + Global.inf.hospitalDr + " AND b.Interface_Dr= " + Global.inf.interfaceDr
  142. + " AND b.InsuRegID NOT IN (SELECT MdtrtID FROM BS_MedInsuSettlement WHERE MdtrtID=b.InsuRegID AND BillType=1 AND ValidFlag=1 AND AdmType=2) "
  143. + " AND b.RegDate<='" + dpED.Text + "' AND b.RegDate>'" + dpST.Text + "' " //
  144. + " UNION ALL "
  145. + " SELECT a.*,b.*,a.PatientName AS Name,a.PsnType AS PsnTypeCode,'已结算' AS sZYZT "
  146. + " FROM BS_MIPatCurrentInsuInfo a LEFT JOIN BS_MedInsuRegisterInfo b "
  147. + " ON a.MdtrtID=b.InsuRegID AND a.Interface_Dr=b.Interface_Dr AND a.Hospital_Dr=b.Hospital_Dr "
  148. + " LEFT JOIN BS_MedInsuSettlement c ON a.MdtrtID=b.InsuRegID AND b.InsuRegID=c.MdtrtID AND a.Interface_Dr=b.Interface_Dr AND b.Interface_Dr=c.Interface_Dr "
  149. + " WHERE b.Type=1 AND b.ValidFlag=1 AND c.BillType=1 AND b.Hospital_Dr= " + Global.inf.hospitalDr + " AND b.Interface_Dr= " + Global.inf.interfaceDr
  150. + " AND c.AdmType=2 AND c.SettlementDateTime<='" + dpED.Text + "' AND c.SettlementDateTime>'" + dpST.Text + "' "; //
  151. string sqlStr = " SELECT " + SqlHeard + " FROM (" + SqlStrMain + ") M ";
  152. //MessageBox.Show(sqlStr);
  153. JObject joSqlstr = new JObject();
  154. joSqlstr.Add("sqlStr", sqlStr);
  155. joSqlstr.Add("Type", "MedInsuHosPInfo");
  156. joSqlstr.Add("hospID", Global.inf.hisHospitalDr);
  157. JArray jaParam = new JArray();
  158. jaParam.Add(joSqlstr);
  159. JObject joSettlQuery = new JObject();
  160. joSettlQuery.Add("params", jaParam);
  161. joSettlQuery.Add("code", "09010059");
  162. InvokeHelper invoker = new InvokeHelper();
  163. JObject joRtn = invoker.invokeInsuService(joSettlQuery.ToString(), "查询结算信息");
  164. //MessageBox.Show(joRtn.ToString());
  165. if (joRtn["result"]["data"].ToString() == "[]")
  166. {
  167. MessageBox.Show("查询结果为空!");
  168. return;
  169. }
  170. DataTable dt = (DataTable)joRtn["result"]["data"].ToObject(typeof(DataTable));
  171. dgvSettlRecord.DataSource = dt;
  172. if (dt.Rows.Count != 0)
  173. {
  174. btnPrint.Enabled = true;
  175. dtExport = dt;
  176. //从HIS获取患者的床号(分床前医保登记的病人床号没有写入医保平台登记表)
  177. for (int i = 0; i < dt.Rows.Count; i++)
  178. {
  179. string BedNo, BedDocName, InHospNo, Address;
  180. JObject joTmp = new JObject();
  181. joTmp.Add("admID", dt.Rows[i]["Adm_Dr"].ToString());
  182. JObject joRtn2 = invoker.invokeHISService(JsonHelper.setIrisInpar("05110014", joTmp).ToString(), "获取患者就诊信息");
  183. if (JsonHelper.parseIrisRtnValue(joRtn2, out string errMsg) == 0)
  184. {
  185. BedNo = JsonHelper.getDestValue(JObject.Parse(joRtn2.ToString()), "mdtrtinfo.adm_bed");
  186. BedDocName = JsonHelper.getDestValue(JObject.Parse(joRtn2.ToString()), "mdtrtinfo.chfpdr_name");
  187. InHospNo = JsonHelper.getDestValue(JObject.Parse(joRtn2.ToString()), "mdtrtinfo.medrcdno");
  188. Address = JsonHelper.getDestValue(JObject.Parse(joRtn2.ToString()), "mdtrtinfo.Address");
  189. dt.Rows[i]["AdmBed"] = BedNo;
  190. dt.Rows[i]["AttendDoctorNO"] = BedDocName;
  191. dt.Rows[i]["InHospNo"] = InHospNo;
  192. dt.Rows[i]["Address"] = Address;
  193. }
  194. else
  195. {
  196. if (errMsg.IndexOf("请重新登录") > 0)
  197. {
  198. MessageBox.Show("获取患者信息失败,请重新登录系统!");
  199. break;
  200. }
  201. }
  202. }
  203. }
  204. }
  205. private void btnPrint_Click(object sender, EventArgs e)
  206. {
  207. string LSH = DateTime.Now.ToString("yyyy-MM-dd"); //DateTime.Now.ToString("MMddHHmmssffff");
  208. string sFliePathName = @"C:\Users\Administrator\Desktop\" + LSH + "医保在院患者登记或结算信息.xls";
  209. string ReturnFileName = ExportToExcel.DataTabletoExcel(dtExport, sFliePathName);
  210. if (ReturnFileName != "")
  211. {
  212. MessageBox.Show("导出成功,文件保存路径:【" + ReturnFileName + "】");
  213. System.Diagnostics.Process.Start(ReturnFileName); //打开excel文件
  214. }
  215. else
  216. {
  217. MessageBox.Show("导出失败!");
  218. }
  219. }
  220. private void btnOK_Click(object sender, EventArgs e)
  221. {
  222. string sqlStr;
  223. sqlStr = " SELECT a.Adm_Dr,c.InsuName as HISName,a.PatientName Name, b.HISCode, b.MedInsuNO, b.Price,b.Sumamt,";
  224. sqlStr = sqlStr + " b.ChargeItemLevel,'' ChargeItemLevelName,b.SelfPayProp, b.UpLimitAmount,b.OverLimitAmount, ";
  225. sqlStr = sqlStr + " b.InScopeAmount,b.FullOwnPayAmount,b.PreSelfPayAmount,b.LimitUsedFlag, b.MedicalChargeItemType,\"Count\" ";
  226. sqlStr = sqlStr + " FROM BS_MedInsuSettlement a LEFT JOIN BS_MedInsuFeeUploadRecord b ";
  227. sqlStr = sqlStr + " ON a.Hospital_Dr=b.Hospital_Dr AND a.MdtrtID=b.MdtrtID AND a.PersonnelNO=b.PersonnelNO ";
  228. sqlStr = sqlStr + " LEFT JOIN HB_MedInsuMapRelation c ON b.MedInsuNO=c.InsuCode AND a.Interface_Dr=c.Interface_Dr AND a.Hospital_Dr=c.Hospital_Dr ";
  229. sqlStr = sqlStr + " WHERE b.MedInsuNO<>'' and a.ValidFlag=1 AND a.BillType=1 AND a.AdmType=2 ";
  230. sqlStr = sqlStr + " AND a.Interface_Dr=" + Global.inf.interfaceDr;
  231. sqlStr = sqlStr + " AND a.Hospital_Dr= " + Global.inf.hospitalDr;
  232. sqlStr = sqlStr + " AND a.OccurTime>'" + dt_ST.Text + "'";
  233. sqlStr = sqlStr + " AND a.OccurTime<'" + dt_ET.Text + "'";
  234. if (tb_InHospNo.Text != "")
  235. {
  236. sqlStr = sqlStr + " and a.BillID='" + tb_InHospNo.Text + "'";
  237. }
  238. if (tb_SettleID.Text != "")
  239. {
  240. sqlStr = sqlStr + " and a.SettlementID='" + tb_SettleID.Text + "'";
  241. }
  242. if (cbbOverPrice.Text == "是")
  243. {
  244. sqlStr = sqlStr + " AND b.OverLimitAmount>0 ";
  245. }
  246. else if (cbbOverPrice.Text == "否")
  247. {
  248. sqlStr = sqlStr + " AND b.OverLimitAmount<=0 ";
  249. }
  250. if (cbbLevel.Text == "甲类")
  251. {
  252. sqlStr = sqlStr + " AND b.ChargeItemLevel='01' ";
  253. }
  254. else if (cbbLevel.Text == "乙类")
  255. {
  256. sqlStr = sqlStr + " AND b.ChargeItemLevel='02' ";
  257. }
  258. else if (cbbLevel.Text == "丙类")
  259. {
  260. sqlStr = sqlStr + " AND b.ChargeItemLevel='03' ";
  261. }
  262. JObject joSqlstr = new JObject();
  263. joSqlstr.Add("sqlStr", sqlStr);
  264. JArray jaParam = new JArray();
  265. jaParam.Add(joSqlstr);
  266. JObject joSettlQuery = new JObject();
  267. joSettlQuery.Add("params", jaParam);
  268. joSettlQuery.Add("code", "09010118");
  269. JObject joRtn = invoker.invokeInsuService(joSettlQuery.ToString(), "查询医保结算费用信息");
  270. DataTable dt = (DataTable)joRtn["result"]["data"].ToObject(typeof(DataTable));
  271. dgvInsuFeeUpload.DataSource = dt;
  272. }
  273. private void uiButton3_Click(object sender, EventArgs e)
  274. {
  275. string sqlstr = " SELECT distinct '' as status,a.InsuranceAreaCode, b.PersonalNO,b.PsnCertType,b.PsnCertNO, ";
  276. sqlstr = sqlstr + " b.PatientName,b.Gend,b.Naty,b.Brdy,0 Age,0 Balc,b.Insutype,b.PsnType,b.PsnInsuStas,b.PsnInsuDate, ";
  277. sqlstr = sqlstr + " b.PausInsuDate,b.Cvlservflag,b.insuplcAdmdvs,b.EmpName ";
  278. sqlstr = sqlstr + " FROM BS_MedInsuSettlement a ";
  279. sqlstr = sqlstr + " RIGHT JOIN BS_MIPatCurrentInsuInfo b ";
  280. sqlstr = sqlstr + " ON a.PersonnelNO=b.PersonalNO AND a.Interface_Dr=b.Interface_Dr ";
  281. sqlstr = sqlstr + " AND a.InsuranceType=b.Insutype "; //AND a.PersonType=b.PsnType
  282. sqlstr = sqlstr + " WHERE a.ValidFlag=1 AND a.BillType=1 AND a.ReversalFlag<>1 ";
  283. sqlstr = sqlstr + " and a.OccurTime>'" + DT_ST1.Text + "'";
  284. sqlstr = sqlstr + " and a.OccurTime<'" + DT_ET1.Text + "'";
  285. //sqlstr = sqlstr + " and a.Interface_Dr='" + Global.inf.interfaceDr + "'";
  286. sqlstr = sqlstr + " and a.Hospital_Dr='" + Global.inf.hospitalDr + "'";
  287. if (tb_CertNo.Text != "")
  288. sqlstr = sqlstr + " and a.CertificateNO='" + tb_CertNo.Text + "'";
  289. JObject joSqlstr = new JObject();
  290. joSqlstr.Add("sqlStr", sqlstr);
  291. joSqlstr.Add("Type", "4001");
  292. joSqlstr.Add("beginTime", DT_ST1.Text);
  293. joSqlstr.Add("endTime", DT_ET1.Text);
  294. joSqlstr.Add("certNo", tb_CertNo.Text);
  295. joSqlstr.Add("hospitalDr", Global.inf.hospitalDr);
  296. JArray jaParam = new JArray();
  297. jaParam.Add(joSqlstr);
  298. JObject joSettlQuery = new JObject();
  299. joSettlQuery.Add("params", jaParam);
  300. joSettlQuery.Add("code", "09010059");
  301. JObject joRtn = invoker.invokeInsuService(joSettlQuery.ToString(), "查询结算信息");
  302. DataTable dt = (DataTable)joRtn["result"]["data"].ToObject(typeof(DataTable));
  303. dgv_4001.DataSource = dt;
  304. }
  305. private void uiButton4_Click(object sender, EventArgs e)
  306. {
  307. string errorMsg = "";
  308. if (dgv_4001.CurrentRow == null)
  309. {
  310. MessageBox.Show("请查询患者参保信息");
  311. return;
  312. }
  313. int iCenter = dgv_4001.CurrentRow.Index;
  314. string psn_no = dgv_4001.Rows[iCenter].Cells["PersonalNO"].Value.ToString();
  315. string psn_cert_type = dgv_4001.Rows[iCenter].Cells["PsnCertType"].Value.ToString();
  316. string certno = dgv_4001.Rows[iCenter].Cells["PsnCertNO"].Value.ToString();
  317. string psn_name = dgv_4001.Rows[iCenter].Cells["PatientName"].Value.ToString();
  318. string gend = dgv_4001.Rows[iCenter].Cells["Gend"].Value.ToString();
  319. string naty = dgv_4001.Rows[iCenter].Cells["Naty"].Value.ToString();
  320. string brdy = dgv_4001.Rows[iCenter].Cells["Brdy"].Value.ToString();
  321. //string age = dgv_4001.Rows[iCenter].Cells["Age"].Value.ToString();
  322. string balc = dgv_4001.Rows[iCenter].Cells["Balc"].Value.ToString();
  323. string insutype = dgv_4001.Rows[iCenter].Cells["Insutype"].Value.ToString();
  324. string psn_type = dgv_4001.Rows[iCenter].Cells["PsnType"].Value.ToString();
  325. string psn_insu_stas = dgv_4001.Rows[iCenter].Cells["PsnInsuStas"].Value.ToString();
  326. string psn_insu_date = dgv_4001.Rows[iCenter].Cells["PsnInsuDate"].Value.ToString();
  327. string paus_insu_date = dgv_4001.Rows[iCenter].Cells["PausInsuDate"].Value.ToString();
  328. string cvlserv_flag = dgv_4001.Rows[iCenter].Cells["Cvlservflag"].Value.ToString();
  329. string insuplc_admdvs = dgv_4001.Rows[iCenter].Cells["insuplcAdmdvs"].Value.ToString();
  330. string emp_name = dgv_4001.Rows[iCenter].Cells["EmpName"].Value.ToString();
  331. JObject joInput = new JObject();
  332. JObject joData = new JObject();
  333. joData.Add("psn_no", psn_no);
  334. joData.Add("psn_cert_type", psn_cert_type);
  335. joData.Add("certno", certno);
  336. joData.Add("psn_name", psn_name);
  337. joData.Add("gend", gend);
  338. joData.Add("naty", naty);
  339. joData.Add("brdy", brdy);
  340. joData.Add("age", "");
  341. joData.Add("balc", balc);
  342. joData.Add("insutype", insutype);
  343. joData.Add("psn_type", psn_type);
  344. joData.Add("psn_insu_stas", psn_insu_stas);
  345. joData.Add("psn_insu_date", psn_insu_date);
  346. joData.Add("paus_insu_date", paus_insu_date);
  347. joData.Add("cvlserv_flag", cvlserv_flag);
  348. joData.Add("insuplc_admdvs", insuplc_admdvs);
  349. joData.Add("emp_name", emp_name);
  350. joInput.Add("data", joData);
  351. JObject joRtn = invoker.invokeCenterServiceF("4001", JsonHelper.setCenterInparF("4001", joInput));
  352. if (JsonHelper.parseCenterRtnValue(joRtn, out errorMsg) != 0)
  353. {
  354. MessageBox.Show("患者信息上传失败:" + errorMsg);
  355. return;
  356. }
  357. MessageBox.Show("患者信息上传成功");
  358. }
  359. private void uiButton7_Click(object sender, EventArgs e)
  360. {
  361. uiLabel1.Text = "";
  362. string sqlStr = " SELECT * FROM BS_MedInsuSettlement WHERE Hospital_Dr=" + Global.inf.hospitalDr;
  363. sqlStr = sqlStr + " and BillType=1 and ValidFlag=1 "; //and ReversalFlag<>1
  364. sqlStr = sqlStr + " and OccurTime>'" + dpt_ST.Text + "'";
  365. sqlStr = sqlStr + " and OccurTime<'" + dpt_ET.Text + "'";
  366. //sqlStr = sqlStr + " and Interface_Dr=" + Global.inf.interfaceDr + "";
  367. sqlStr = sqlStr + " and Hospital_Dr=" + Global.inf.hospitalDr + " ";
  368. if ((rbg_Type.SelectedIndex == 0) || (rbg_Type.SelectedIndex == 3))
  369. sqlStr = sqlStr + "and AdmType=1";
  370. else
  371. if ((rbg_Type.SelectedIndex == 1) || (rbg_Type.SelectedIndex == 2))
  372. sqlStr = sqlStr + " and AdmType=2";
  373. if (tb_Name.Text != "")
  374. {
  375. sqlStr = sqlStr + " and PatientName='" + tb_Name.Text + "'";
  376. }
  377. if (tb_SetlID.Text != "")
  378. {
  379. sqlStr = sqlStr + " and SettlementID='" + tb_SetlID.Text + "'";
  380. }
  381. if (tb_CertNo2.Text != "")
  382. {
  383. sqlStr = sqlStr + " and CertificateNO='" + tb_CertNo2.Text + "'";
  384. }
  385. if (tb_AdmID.Text != "")
  386. {
  387. sqlStr = sqlStr + "and Adm_Dr='" + tb_AdmID.Text + "'";
  388. }
  389. //sqlStr = sqlStr + " AND ReversalFlag<>1 ";
  390. JObject joSqlstr = new JObject();
  391. joSqlstr.Add("sqlStr", sqlStr);
  392. JArray jaParam = new JArray();
  393. jaParam.Add(joSqlstr);
  394. JObject joSettlQuery = new JObject();
  395. joSettlQuery.Add("params", jaParam);
  396. joSettlQuery.Add("code", "09010059");
  397. JObject joRtn = invoker.invokeInsuService(joSettlQuery.ToString(), "查询结算信息");
  398. DataTable dt = (DataTable)joRtn["result"]["data"].ToObject(typeof(DataTable));
  399. dgvSettleData.DataSource = dt;
  400. }
  401. private void dgvSettleData_DoubleClick(object sender, EventArgs e)
  402. {
  403. uiButton5_Click(sender, e);
  404. }
  405. /// <summary>
  406. /// 上传费用明细
  407. /// </summary>
  408. /// <param name="sender"></param>
  409. /// <param name="e"></param>
  410. private void uiButton5_Click(object sender, EventArgs e)
  411. {
  412. string outParam = "成功", funNO = "";
  413. if (rbg_Type.SelectedIndex == 0)
  414. funNO = "4303";
  415. else if (rbg_Type.SelectedIndex == 1)
  416. funNO = "4403";
  417. else if (rbg_Type.SelectedIndex == 2)
  418. funNO = "4801";
  419. else if (rbg_Type.SelectedIndex == 3)
  420. funNO = "4802";
  421. if (dgvSettleData.CurrentRow == null)
  422. {
  423. MessageBox.Show("请先查询患者结算信息");
  424. return;
  425. }
  426. int iCenter = dgvSettleData.CurrentRow.Index;
  427. Global.pat.mdtrtID = dgvSettleData.Rows[iCenter].Cells["MdtrtID"].Value.ToString();
  428. Global.pat.medType = dgvSettleData.Rows[iCenter].Cells["MedicalType"].Value.ToString();
  429. Global.pat.psn_no = dgvSettleData.Rows[iCenter].Cells["PersonnelNO"].Value.ToString();
  430. Global.pat.adm_Dr = int.Parse(dgvSettleData.Rows[iCenter].Cells["AdmID"].Value.ToString());
  431. Global.pat.billID = dgvSettleData.Rows[iCenter].Cells["BillID"].Value.ToString();
  432. Global.pat.recordID = dgvSettleData.Rows[iCenter].Cells["RecordID"].Value.ToString();
  433. Global.pat.certNO = dgvSettleData.Rows[iCenter].Cells["CertificateNO"].Value.ToString();
  434. Global.pat.name = dgvSettleData.Rows[iCenter].Cells["PatientName"].Value.ToString();
  435. Global.pat.brdy = dgvSettleData.Rows[iCenter].Cells["BirthDay"].Value.ToString();
  436. Global.pat.gend = dgvSettleData.Rows[iCenter].Cells["Gender"].Value.ToString();
  437. //获取IS费用
  438. if (hIS.getHisFee(Global.pat, out outParam) != 0)
  439. {
  440. MessageBox.Show("获取HIS费用信息失败:" + outParam);
  441. return;
  442. }
  443. //调用医保平台转换HIS费用(转换医保编码等)
  444. JObject joHisFee = JObject.Parse(outParam);
  445. if (mIS.convertHisFeeWithInsuCodeHF(joHisFee, out outParam) != 0)
  446. {
  447. MessageBox.Show("调用医保平台转换HIS费用(转换医保编码等)失败:" + outParam);
  448. return;
  449. }
  450. JArray jaFeeDetail = JArray.Parse(JsonHelper.getDestValue(JObject.Parse(outParam), "data"));
  451. //按指定条数分割后上传
  452. if (uploadFeeToCenter(funNO, 300, jaFeeDetail, out outParam) != 0)
  453. {
  454. MessageBox.Show("按指定条数分割后上传失败:" + outParam);
  455. return;
  456. }
  457. else
  458. {
  459. MessageBox.Show("上传成功!" + outParam);
  460. return;
  461. }
  462. }
  463. public int uploadFeeToCenter(string funNO, int singleCount, JArray jaFeeDetail, out string outParam)
  464. {
  465. outParam = "";
  466. string errMsg, type = "feedetail";
  467. try
  468. {
  469. if (rbg_Type.SelectedIndex == 0)
  470. type = "outfeedetail";
  471. else if (rbg_Type.SelectedIndex == 1)
  472. type = "feedetail";
  473. else if (rbg_Type.SelectedIndex == 2)
  474. type = "feedetail";
  475. else if (rbg_Type.SelectedIndex == 3)
  476. type = "outfeedetail";
  477. JArray jaTmp = new JArray();
  478. for (int i = 0; i < jaFeeDetail.Count; i++)
  479. {
  480. jaFeeDetail[i]["chrg_bchno"] = Global.pat.adm_Dr.ToString();
  481. jaFeeDetail[i]["med_type"] = Global.pat.medType;
  482. jaFeeDetail[i]["bilg_dept_codg"] = "A10";
  483. jaFeeDetail[i]["certno"] = Global.pat.certNO;
  484. jaFeeDetail[i]["psn_name"] = Global.pat.name;
  485. jaFeeDetail[i]["gend"] = Global.pat.gend;
  486. jaFeeDetail[i]["brdy"] = Global.pat.brdy;
  487. jaFeeDetail[i]["mdtrt_sn"] = Global.pat.adm_Dr;
  488. if (jaFeeDetail[i]["validFlag"].ToString() == "N") continue;
  489. jaTmp.Add(jaFeeDetail[i]);
  490. if (((i + 1) % singleCount == 0) || ((i + 1) == jaFeeDetail.Count))
  491. {
  492. JObject joFeeDetail = new JObject();
  493. joFeeDetail.Add(type, jaTmp);
  494. JObject joRtn = invoker.invokeCenterServiceF(funNO, JsonHelper.setCenterInparF(funNO, joFeeDetail));
  495. //if (JsonHelper.parseCenterRtnValue(joRtn, out errMsg) != 0)
  496. //{
  497. // outParam = errMsg;
  498. // return -1;
  499. //}
  500. jaTmp = new JArray();
  501. }
  502. }
  503. return 0;
  504. }
  505. catch (Exception ex)
  506. {
  507. outParam = "uploadFee 异常:" + ex.Message;
  508. return -1;
  509. }
  510. }
  511. private void uiButton16_Click(object sender, EventArgs e)
  512. {
  513. string errorMsg;
  514. try
  515. {
  516. if (dgv_HISRegInfo.DataSource == null)
  517. return;
  518. if (dgv_HISRegInfo.Rows[dgv_HISRegInfo.CurrentRow.Index].Cells["ID"].Value.ToString() == "")
  519. return;
  520. presNo = dgv_HISRegInfo.Rows[dgv_HISRegInfo.CurrentRow.Index].Cells["prescNo"].Value.ToString();
  521. JObject joTmp = new JObject();
  522. joTmp.Add("startDate", dtp_st.Text);
  523. joTmp.Add("endDate", dtp_et.Text);
  524. joTmp.Add("hospCode", JsonHelper.getDestValue((JObject)Global.curEvt.jaSession[0], "hospCode"));
  525. joTmp.Add("prescNo", presNo); //处方号
  526. JObject joRtn = invoker.invokeHISService(JsonHelper.setIrisInpar("05110038", joTmp).ToString(), "获取门诊处方风险提示参数");
  527. if (JsonHelper.parseIrisRtnValue(joRtn, out errorMsg) != 0)
  528. {
  529. MessageBox.Show("获取门诊处方风险提示参数失败,请联系管理员!" + errorMsg);
  530. return;
  531. }
  532. else
  533. {
  534. if ((joRtn["result"].ToString() == "[]") || (joRtn["result"].ToString() == ""))
  535. {
  536. MessageBox.Show("调用HIS接口服务05110038获取处方号【" + presNo + "】门诊处方风险提示参数结果为空!");
  537. return;
  538. }
  539. //调用接口上传至中心
  540. JObject joInput = new JObject();
  541. joInput = JObject.Parse(joRtn["result"][0].ToString());
  542. //joInput["treatmentRecord"]["patientinfo"]["psn_no"] = Global.pat.mdtrtID;
  543. joInput["treatmentRecord"]["patientinfo"]["brdy"] = joInput["treatmentRecord"]["patientinfo"]["brdy"] + " 00:00:00";
  544. JObject joRtn10001 = invoker.invokeCenterServiceF("10001", JsonHelper.setCenterInparF("10001", joInput));
  545. if (JsonHelper.parseCenterRtnValue(joRtn10001, out errorMsg) != 0)
  546. {
  547. MessageBox.Show("门诊处方风险提示上传失败:" + errorMsg);
  548. return;
  549. }
  550. MessageBox.Show("门诊处方风险提示上传成功");
  551. }
  552. }
  553. catch (Exception ex)
  554. {
  555. MessageBox.Show("异常:" + ex.Message);
  556. return;
  557. }
  558. }
  559. /// <summary>
  560. /// 新华网人员类别与医保人员类别对照关系
  561. /// </summary>
  562. /// <param name="param"></param>
  563. /// <returns></returns>
  564. public string GetPsnType(string param)
  565. {
  566. if ((param == "11") || (param == "11021") || (param == "11031") ||
  567. (param == "1101") || (param == "1102") || (param == "1103") ||
  568. (param == "1111") || (param == "1113") || (param == "116006") ||
  569. (param == "116011") || (param == "116012") || (param == "116013") ||
  570. (param == "116014") || (param == "116015") || (param == "116017") ||
  571. (param == "136046") || (param == "136048") || (param == "136050") ||
  572. (param == "116018") || (param == "116019") || (param == "116020") ||
  573. (param == "116021") || (param == "136042") || (param == "136044") ||
  574. (param == "5005") || (param == "5007") || (param == "5010") ||
  575. (param == "5011") || (param == "5015") || (param == "5019") ||
  576. (param == "5022") || (param == "5028") || (param == "5029") ||
  577. (param == "5032") || (param == "5035") || (param == "5038") ||
  578. (param == "5041") || (param == "5044") || (param == "5048") ||
  579. (param == "5050") || (param == "1117") || (param == "1118") ||
  580. (param == "116041") || (param == "116042") || (param == "116043") ||
  581. (param == "116044") || (param == "116045") || (param == "116046") ||
  582. (param == "11032") || (param == "11033") || (param == "11034") ||
  583. (param == "116047") || (param == "116048") || (param == "116022") ||
  584. (param == "116031") || (param == "116032") || (param == "116033") ||
  585. (param == "5053") || (param == "5054") || (param == "5055") ||
  586. (param == "5059") || (param == "116090") || (param == "116050") ||
  587. (param == "116051") || (param == "995330"))
  588. return "1025100"; //在职
  589. else if ((param == "1105") || (param == "3601") || (param == "3602"))
  590. return "1025200"; //农民工
  591. else if ((param == "12") || (param == "1112") || (param == "1201") ||
  592. (param == "1202") || (param == "1114") || (param == "1203") ||
  593. (param == "12031") || (param == "136047") || (param == "1205") ||
  594. (param == "995311") || (param == "136049") || (param == "126001") ||
  595. (param == "136051") || (param == "126002") || (param == "136052") ||
  596. (param == "126003") || (param == "126004") || (param == "126009") ||
  597. (param == "995319") || (param == "126010") || (param == "995307") ||
  598. (param == "126013") || (param == "126015") || (param == "126016") ||
  599. (param == "126017") || (param == "126018") || (param == "126019") ||
  600. (param == "126022") || (param == "136055") || (param == "126023") ||
  601. (param == "126024") || (param == "126025") || (param == "126026") ||
  602. (param == "126027") || (param == "136035") || (param == "136039") ||
  603. (param == "136040") || (param == "136041") || (param == "136043") ||
  604. (param == "136045") || (param == "126031") || (param == "126032") ||
  605. (param == "126033") || (param == "5006") || (param == "5008") ||
  606. (param == "5012") || (param == "5013") || (param == "5016") ||
  607. (param == "5017") || (param == "5020") || (param == "5023") ||
  608. (param == "5030") || (param == "5033") || (param == "5036") ||
  609. (param == "5039") || (param == "5042") || (param == "5045") ||
  610. (param == "5049") || (param == "5051") || (param == "120701") ||
  611. (param == "120703") || (param == "120707") || (param == "120708") ||
  612. (param == "120711") || (param == "120712") || (param == "120715") ||
  613. (param == "120716") || (param == "120719") || (param == "120720") ||
  614. (param == "120723") || (param == "120724") || (param == "120727") ||
  615. (param == "120728") || (param == "120731") || (param == "120733") ||
  616. (param == "120735") || (param == "120737") || (param == "126041") ||
  617. (param == "126042") || (param == "126043") || (param == "126044") ||
  618. (param == "126045") || (param == "126046") || (param == "12032") ||
  619. (param == "12033") || (param == "12034") || (param == "12035") ||
  620. (param == "126047") || (param == "126048") || (param == "116088") ||
  621. (param == "126064") || (param == "126065") || (param == "126117") ||
  622. (param == "126216") || (param == "126037") || (param == "126067") ||
  623. (param == "126066") || (param == "126034") || (param == "5056") ||
  624. (param == "5057") || (param == "5058") || (param == "126316") ||
  625. (param == "126317") || (param == "5060") || (param == "126090") ||
  626. (param == "995331"))
  627. return "1025300"; //退休人员
  628. else
  629. if ((param == "13") || (param == "1300") || (param == "1300") ||
  630. (param == "995309") || (param == "136053") || (param == "136001") ||
  631. (param == "136002") || (param == "136004") || (param == "136005") ||
  632. (param == "136006") || (param == "136007") || (param == "136008") ||
  633. (param == "136009") || (param == "136010") || (param == "136011") ||
  634. (param == "136012") || (param == "136014") || (param == "136015") ||
  635. (param == "136016") || (param == "136017") || (param == "136018") ||
  636. (param == "136019") || (param == "136020") || (param == "136021") ||
  637. (param == "136022") || (param == "136023") || (param == "136024") ||
  638. (param == "136090") || (param == "13031") || (param == "136026") ||
  639. (param == "136029") || (param == "136030") || (param == "136031") ||
  640. (param == "5001") || (param == "5002") || (param == "5003") ||
  641. (param == "5004") || (param == "5009") || (param == "5018") ||
  642. (param == "5021") || (param == "5024") || (param == "5031") ||
  643. (param == "5034") || (param == "5037") || (param == "5040") ||
  644. (param == "5043") || (param == "5046") || (param == "5047") ||
  645. (param == "5052") || (param == "137001") || (param == "137002") ||
  646. (param == "137003") || (param == "136054") || (param == "130102") ||
  647. (param == "5088"))
  648. return "1025400"; //离休
  649. else
  650. if ((param == "14") || (param == "1405") || (param == "156006") || (param == "156007"))
  651. return "1025500"; //居民(未成年)
  652. else
  653. if ((param == "1401") || (param == "140101"))
  654. return "1025600"; //新生儿
  655. else
  656. if ((param == "1402"))
  657. return "1025700"; //学龄前儿童
  658. else
  659. if (param == "1403")
  660. return "1025800"; //中小学生
  661. else
  662. if ((param == "1404") || (param == "140890") || (param == "140891") ||
  663. (param == "156008") || (param == "140401") || (param == "140402") ||
  664. (param == "140403"))
  665. return "1025900"; //大学生
  666. else
  667. if ((param == "995301") || (param == "1405"))
  668. return "1025110"; //未成年(未入学)
  669. else
  670. if (param == "15")
  671. return "1025111"; //居民(成年)
  672. else
  673. if (param == "1501")
  674. return "1025112"; //普通居民(成年)
  675. else
  676. if ((param == "16") || (param == "160104") || (param == "140805") ||
  677. (param == "160100") || (param == "160101") || (param == "160102") ||
  678. (param == "160103"))
  679. return "1025113"; //居民(老年)
  680. else
  681. return "1025111"; //居民(成年)
  682. }
  683. /// <summary>
  684. /// 根据HIS就诊ID查询患者参保信息
  685. /// </summary>
  686. /// <param name="admID"></param>
  687. /// <param name="errorMsg"></param>
  688. /// <returns></returns>
  689. public int GetInsuPersonInfo(string admID, out JObject joRtn, out string errorMsg)
  690. {
  691. joRtn = null;
  692. string sqlstr = " SELECT TOP 1 * FROM BS_MIPatCurrentInsuInfo WHERE AdmID='" + admID + "'";
  693. sqlstr = sqlstr + " and Interface_Dr='" + Global.inf.interfaceDr + "' ORDER BY ID DESC";
  694. JObject joSqlstr = new JObject();
  695. joSqlstr.Add("sqlStr", sqlstr);
  696. JArray jaParam = new JArray();
  697. jaParam.Add(joSqlstr);
  698. JObject joQuery = new JObject();
  699. joQuery.Add("params", jaParam);
  700. joQuery.Add("code", "09010082");
  701. JObject joQueryRtn = invoker.invokeInsuService(joQuery.ToString(), "查询人员参保信息");
  702. if (JsonHelper.parseIrisRtnValue(joQueryRtn, out errorMsg) != 0)
  703. {
  704. MessageBox.Show("查询人员参保信息失败,请联系管理员!" + errorMsg);
  705. return -1;
  706. }
  707. joRtn = joQueryRtn;
  708. return 0;
  709. }
  710. public string GetInsuFeeInfo(string admID, string InsuCode)
  711. {
  712. string sqlStr;
  713. sqlStr = " SELECT admID as Adm_Dr,'' as Name,''as HISCode,MedInsuNO,Price,Sumamt, ";
  714. sqlStr = sqlStr + " ChargeItemLevel,SelfPayProp,UpLimitAmount,OverLimitAmount,InScopeAmount,";
  715. sqlStr = sqlStr + " FullOwnPayAmount,PreSelfPayAmount,LimitUsedFlag From BS_MedInsuFeeUploadRecord ";
  716. sqlStr = sqlStr + " WHERE Hospital_Dr= " + Global.inf.hospitalDr;
  717. sqlStr = sqlStr + " AND admID='" + admID + "'";
  718. sqlStr = sqlStr + " AND MedInsuNO='" + InsuCode + "'";
  719. JObject joSqlstr = new JObject();
  720. joSqlstr.Add("sqlStr", sqlStr);
  721. JArray jaParam = new JArray();
  722. jaParam.Add(joSqlstr);
  723. JObject joSettlQuery = new JObject();
  724. joSettlQuery.Add("params", jaParam);
  725. joSettlQuery.Add("code", "09010118");
  726. JObject joRtn = invoker.invokeInsuService(joSettlQuery.ToString(), "查询医保结算费用信息");
  727. decimal SelfPayProp = decimal.Parse(JsonHelper.getDestValue(joRtn, "result.data[0].SelfPayProp"));
  728. //1007100-医保个人,1007200-医保统筹,1007300-现金
  729. if (SelfPayProp == 0)
  730. return "1007200";
  731. else
  732. return "1007300";
  733. }
  734. private void uiButton13_Click(object sender, EventArgs e)
  735. {
  736. string errorMsg;
  737. string participateType = "1024200", personnelType;
  738. if ((dgv_BillInfo.DataSource == null) || (dgv_BillInfo.Rows[dgv_BillInfo.CurrentRow.Index].Cells["billCode"].Value.ToString() == ""))
  739. {
  740. MessageBox.Show("请先查询单据信息!");
  741. return;
  742. }
  743. if ((dgv_BillDetailInfo.DataSource == null) || (dgv_BillDetailInfo.Rows[dgv_BillDetailInfo.CurrentRow.Index].Cells["billID"].Value.ToString() == ""))
  744. {
  745. MessageBox.Show("请先查询明细信息!");
  746. return;
  747. }
  748. try
  749. {
  750. string entId = dgv_BillInfo.Rows[dgv_BillInfo.CurrentRow.Index].Cells["entId"].Value.ToString();
  751. string billCode = dgv_BillInfo.Rows[dgv_BillInfo.CurrentRow.Index].Cells["billCode"].Value.ToString();
  752. string billTime = dgv_BillInfo.Rows[dgv_BillInfo.CurrentRow.Index].Cells["billTime"].Value.ToString();
  753. string InsuredType = dgv_BillInfo.Rows[dgv_BillInfo.CurrentRow.Index].Cells["participateType"].Value.ToString(); //险种类型
  754. string admID = dgv_BillInfo.Rows[dgv_BillInfo.CurrentRow.Index].Cells["admID"].Value.ToString();
  755. if (InsuredType.Substring(0, 2) == "31")
  756. {
  757. participateType = "1024100"; //职工
  758. }
  759. else if (InsuredType.Substring(0, 2) == "39")
  760. {
  761. participateType = "1024200"; //居民
  762. }
  763. //人员类别
  764. if (GetInsuPersonInfo(admID, out JObject joQueryRtn, out errorMsg) != 0)
  765. {
  766. MessageBox.Show("查询参保人员信息失败!" + errorMsg);
  767. return;
  768. }
  769. personnelType = GetPsnType(JsonHelper.getDestValue(joQueryRtn, "result.rows[0].psnType").ToString());
  770. JObject joData = JObject.Parse(JsonHelper.getDestValue(joInput20002, "result[0]").ToString());
  771. joData["participateType"] = participateType;
  772. joData["personnelType"] = personnelType;
  773. JArray jaFeeDetail = JArray.Parse(JsonHelper.getDestValue(joInput20002, "result[0].detail"));
  774. //for (int i = 0; i < jaFeeDetail.Count; i++)
  775. //{
  776. // string InsuCode = jaFeeDetail[i]["medicalDrugId"].ToString();
  777. // if (InsuCode != "未对照")
  778. // {
  779. // string toPay = GetInsuFeeInfo(admID, InsuCode);
  780. // }
  781. //}
  782. JObject joInput = new JObject();
  783. joInput.Add("data", joData);
  784. JObject joRtn = invoker.invokeCenterServiceF("20002", JsonHelper.setCenterInparF("20002", joInput));
  785. if (JsonHelper.parseCenterRtnValue(joRtn, out errorMsg) != 0)
  786. {
  787. MessageBox.Show("事后单据鉴核信息提报失败,中心返回:" + errorMsg);
  788. return;
  789. }
  790. MessageBox.Show("事后单据鉴核信息提报成功!" + errorMsg);
  791. }
  792. catch (Exception ex)
  793. {
  794. MessageBox.Show("事后单据鉴核信息提报异常:" + ex.Message);
  795. return;
  796. }
  797. }
  798. private void dgv_BillInfo_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  799. {
  800. }
  801. private void uiButton19_Click(object sender, EventArgs e)
  802. {
  803. string errorMsg = "";
  804. if (dgv_4001.CurrentRow == null)
  805. {
  806. MessageBox.Show("请查询患者参保信息");
  807. return;
  808. }
  809. for (int i = 0; i < dgv_4001.Rows.Count; i++)
  810. {
  811. //int iCenter = dgv_4001.CurrentRow.Index;
  812. string psn_no = dgv_4001.Rows[i].Cells["PersonalNO"].Value.ToString();
  813. string psn_cert_type = dgv_4001.Rows[i].Cells["PsnCertType"].Value.ToString();
  814. string certno = dgv_4001.Rows[i].Cells["PsnCertNO"].Value.ToString();
  815. string psn_name = dgv_4001.Rows[i].Cells["PatientName"].Value.ToString();
  816. string gend = dgv_4001.Rows[i].Cells["Gend"].Value.ToString();
  817. string naty = dgv_4001.Rows[i].Cells["Naty"].Value.ToString();
  818. string brdy = dgv_4001.Rows[i].Cells["Brdy"].Value.ToString();
  819. string age = dgv_4001.Rows[i].Cells["Age"].Value.ToString();
  820. string balc = dgv_4001.Rows[i].Cells["Balc"].Value.ToString();
  821. string insutype = dgv_4001.Rows[i].Cells["Insutype"].Value.ToString();
  822. string psn_type = dgv_4001.Rows[i].Cells["PsnType"].Value.ToString();
  823. string psn_insu_stas = dgv_4001.Rows[i].Cells["PsnInsuStas"].Value.ToString();
  824. string psn_insu_date = dgv_4001.Rows[i].Cells["PsnInsuDate"].Value.ToString();
  825. string paus_insu_date = dgv_4001.Rows[i].Cells["PausInsuDate"].Value.ToString();
  826. string cvlserv_flag = dgv_4001.Rows[i].Cells["Cvlservflag"].Value.ToString();
  827. string insuplc_admdvs = dgv_4001.Rows[i].Cells["insuplcAdmdvs"].Value.ToString();
  828. string emp_name = dgv_4001.Rows[i].Cells["EmpName"].Value.ToString();
  829. JObject joInput = new JObject();
  830. JObject joData = new JObject();
  831. joData.Add("psn_no", psn_no);
  832. joData.Add("psn_cert_type", psn_cert_type);
  833. joData.Add("certno", certno);
  834. joData.Add("psn_name", psn_name);
  835. joData.Add("gend", gend);
  836. joData.Add("naty", naty);
  837. joData.Add("brdy", brdy);
  838. joData.Add("age", age);
  839. joData.Add("balc", balc);
  840. joData.Add("insutype", insutype);
  841. joData.Add("psn_type", psn_type);
  842. joData.Add("psn_insu_stas", psn_insu_stas);
  843. joData.Add("psn_insu_date", psn_insu_date);
  844. joData.Add("paus_insu_date", paus_insu_date);
  845. joData.Add("cvlserv_flag", cvlserv_flag);
  846. joData.Add("insuplc_admdvs", insuplc_admdvs);
  847. joData.Add("emp_name", emp_name);
  848. joInput.Add("data", joData);
  849. JObject joRtn = invoker.invokeCenterServiceF("4001", JsonHelper.setCenterInparF("4001", joInput));
  850. if (JsonHelper.parseCenterRtnValue(joRtn, out errorMsg) != 0)
  851. {
  852. MessageBox.Show("患者信息上传失败:" + errorMsg);
  853. return;
  854. }
  855. }
  856. MessageBox.Show("患者信息上传成功");
  857. }
  858. private void dgvSettleData_CellClick(object sender, DataGridViewCellEventArgs e)
  859. {
  860. if (dgvSettleData.CurrentRow == null)
  861. {
  862. MessageBox.Show("请先查询医保结算信息");
  863. return;
  864. }
  865. int iCenter = dgvSettleData.CurrentRow.Index;
  866. string PersonnelNO = dgvSettleData.Rows[iCenter].Cells["PersonnelNO"].Value.ToString(); //MdtrtID
  867. string SettlementID = dgvSettleData.Rows[iCenter].Cells["SettlementID"].Value.ToString();
  868. string MdtrtID = dgvSettleData.Rows[iCenter].Cells["MdtrtID"].Value.ToString();
  869. string sqlStr;
  870. sqlStr = " SELECT a.Adm_Dr,c.Name, b.HISCode, b.MedInsuNO, b.Price,b.Sumamt,b.ChargeItemLevel,c.ChargeItemLevelName,b.SelfPayProp, ";
  871. sqlStr = sqlStr + " b.UpLimitAmount,b.OverLimitAmount,b.InScopeAmount,b.FullOwnPayAmount,b.PreSelfPayAmount,b.LimitUsedFlag ";
  872. sqlStr = sqlStr + " FROM BS_MedInsuSettlement a LEFT JOIN BS_MedInsuFeeUploadRecord b ";
  873. sqlStr = sqlStr + " ON a.Hospital_Dr=b.Hospital_Dr AND a.MdtrtID=b.MdtrtID AND a.PersonnelNO=b.PersonnelNO ";
  874. sqlStr = sqlStr + " LEFT JOIN HB_MedInsuDirectory c ON b.MedInsuNO=c.Code AND a.Interface_Dr=c.Interface_Dr AND a.Hospital_Dr=c.Hospital_Dr ";
  875. sqlStr = sqlStr + " WHERE b.MedInsuNO<>'' and a.ValidFlag=1 AND a.BillType=1 "; //AND a.AdmType=2
  876. sqlStr = sqlStr + " AND a.Interface_Dr=" + Global.inf.interfaceDr;
  877. sqlStr = sqlStr + " AND a.Hospital_Dr= " + Global.inf.hospitalDr;
  878. sqlStr = sqlStr + " AND a.OccurTime>'" + dpt_ST.Text + "'";
  879. sqlStr = sqlStr + " AND a.OccurTime<'" + dpt_ET.Text + "'";
  880. sqlStr = sqlStr + " AND a.PersonnelNO='" + PersonnelNO + "'";
  881. sqlStr = sqlStr + " AND a.SettlementID='" + SettlementID + "'";
  882. sqlStr = sqlStr + " AND a.MdtrtID='" + MdtrtID + "'";
  883. if (tb_CertNo2.Text != "")
  884. sqlStr = sqlStr + " And a.CertificateNO='" + tb_CertNo2.Text + "' ";
  885. JObject joSqlstr = new JObject();
  886. joSqlstr.Add("sqlStr", sqlStr);
  887. JArray jaParam = new JArray();
  888. jaParam.Add(joSqlstr);
  889. JObject joSettlQuery = new JObject();
  890. joSettlQuery.Add("params", jaParam);
  891. joSettlQuery.Add("code", "09010118");
  892. JObject joRtn = invoker.invokeInsuService(joSettlQuery.ToString(), "查询医保结算费用信息");
  893. DataTable dt = (DataTable)joRtn["result"]["data"].ToObject(typeof(DataTable));
  894. dgvFeeInfo.DataSource = dt;
  895. }
  896. private void uiButton20_Click(object sender, EventArgs e)
  897. {
  898. string outParam = "成功", funNO = "";
  899. if (rbg_Type.SelectedIndex == 0)
  900. funNO = "4303";
  901. else if (rbg_Type.SelectedIndex == 1)
  902. funNO = "4403";
  903. else if (rbg_Type.SelectedIndex == 2)
  904. funNO = "4801";
  905. else if (rbg_Type.SelectedIndex == 3)
  906. funNO = "4802";
  907. if (dgvSettleData.CurrentRow == null)
  908. {
  909. MessageBox.Show("请先查询患者结算信息");
  910. return;
  911. }
  912. for (int i = 0; i < dgvSettleData.Rows.Count; i++)
  913. {
  914. int iCenter = dgvSettleData.CurrentRow.Index;
  915. Global.pat.mdtrtID = dgvSettleData.Rows[i].Cells["MdtrtID"].Value.ToString();
  916. Global.pat.medType = dgvSettleData.Rows[i].Cells["MedicalType"].Value.ToString();
  917. Global.pat.psn_no = dgvSettleData.Rows[i].Cells["PersonnelNO"].Value.ToString();
  918. Global.pat.adm_Dr = int.Parse(dgvSettleData.Rows[i].Cells["AdmID"].Value.ToString());
  919. Global.pat.billID = dgvSettleData.Rows[i].Cells["BillID"].Value.ToString();
  920. Global.pat.recordID = dgvSettleData.Rows[i].Cells["RecordID"].Value.ToString();
  921. Global.pat.certNO = dgvSettleData.Rows[i].Cells["CertificateNO"].Value.ToString();
  922. Global.pat.name = dgvSettleData.Rows[i].Cells["PatientName"].Value.ToString();
  923. Global.pat.brdy = dgvSettleData.Rows[i].Cells["BirthDay"].Value.ToString();
  924. Global.pat.gend = dgvSettleData.Rows[i].Cells["Gender"].Value.ToString();
  925. //获取IS费用
  926. if (hIS.getHisFee(Global.pat, out outParam) != 0)
  927. {
  928. MessageBox.Show("获取HIS费用信息失败:" + outParam+", 姓名:"+ Global.pat.name + ", 医保登记流水号:"+ Global.pat.mdtrtID+", AdmID:"+ Global.pat.adm_Dr);
  929. continue;
  930. }
  931. //调用医保平台转换HIS费用(转换医保编码等)
  932. JObject joHisFee = JObject.Parse(outParam);
  933. if (mIS.convertHisFeeWithInsuCodeHF(joHisFee, out outParam) != 0)
  934. {
  935. MessageBox.Show("调用医保平台转换HIS费用(转换医保编码等)失败:" + outParam + ", 姓名:" + Global.pat.name + ", 医保登记流水号:" + Global.pat.mdtrtID + ", AdmID:" + Global.pat.adm_Dr);
  936. continue;
  937. }
  938. JArray jaFeeDetail = JArray.Parse(JsonHelper.getDestValue(JObject.Parse(outParam), "data"));
  939. //按指定条数分割后上传
  940. if (uploadFeeToCenter(funNO, 300, jaFeeDetail, out outParam) != 0)
  941. {
  942. //MessageBox.Show("按指定条数分割后上传失败:" + outParam);
  943. //return;
  944. }
  945. else
  946. continue;
  947. }
  948. MessageBox.Show("上传成功!" + outParam);
  949. }
  950. private void rbg_Type_ValueChanged(object sender, int index, string text)
  951. {
  952. dgvSettleData.DataSource = null;
  953. dgvFeeInfo.DataSource = null;
  954. }
  955. private void uiButton21_Click(object sender, EventArgs e)
  956. {
  957. string errorMsg;
  958. if (dgv_HISRegInfo.DataSource == null)
  959. return;
  960. if (dgv_HISRegInfo.Rows[dgv_HISRegInfo.CurrentRow.Index].Cells["ID"].Value.ToString() == "")
  961. return;
  962. for (int i = 0; i < dgv_HISRegInfo.Rows.Count; i++)
  963. {
  964. presNo = dgv_HISRegInfo.Rows[dgv_HISRegInfo.CurrentRow.Index].Cells["prescNo"].Value.ToString();
  965. JObject joTmp = new JObject();
  966. joTmp.Add("startDate", dtp_st.Text);
  967. joTmp.Add("endDate", dtp_et.Text);
  968. joTmp.Add("hospCode", JsonHelper.getDestValue((JObject)Global.curEvt.jaSession[0], "hospCode"));
  969. joTmp.Add("prescNo", presNo); //处方号
  970. JObject joRtn = invoker.invokeHISService(JsonHelper.setIrisInpar("05110038", joTmp).ToString(), "获取门诊处方风险提示参数");
  971. if (JsonHelper.parseIrisRtnValue(joRtn, out errorMsg) != 0)
  972. {
  973. MessageBox.Show("获取门诊处方风险提示参数失败,请联系管理员!" + errorMsg);
  974. return;
  975. }
  976. else
  977. {
  978. if ((joRtn["result"].ToString() == "[]") || (joRtn["result"].ToString() == ""))
  979. {
  980. MessageBox.Show("调用HIS接口服务05110038获取处方号【" + presNo + "】门诊处方风险提示参数结果为空!!");
  981. return;
  982. }
  983. //调用接口上传至中心
  984. JObject joInput = new JObject();
  985. joInput = JObject.Parse(joRtn["result"][0].ToString());
  986. //joInput["treatmentRecord"]["patientinfo"]["psn_no"] = Global.pat.mdtrtID;
  987. joInput["treatmentRecord"]["patientinfo"]["brdy"] = joInput["treatmentRecord"]["patientinfo"]["brdy"] + " 00:00:00";
  988. JObject joRtn10001 = invoker.invokeCenterServiceF("10001", JsonHelper.setCenterInparF("10001", joInput));
  989. if (JsonHelper.parseCenterRtnValue(joRtn10001, out errorMsg) != 0)
  990. {
  991. MessageBox.Show("门诊处方风险提示上传失败:" + errorMsg);
  992. return;
  993. }
  994. }
  995. }
  996. MessageBox.Show("门诊处方风险提示上传成功");
  997. }
  998. private void dgv_HISRegInfo_CellClick(object sender, DataGridViewCellEventArgs e)
  999. {
  1000. if (dgv_HISRegInfo.DataSource == null)
  1001. return;
  1002. if (dgv_HISRegInfo.Rows[dgv_HISRegInfo.CurrentRow.Index].Cells["ID"].Value.ToString() == "")
  1003. return;
  1004. string outParam = "";
  1005. DataTable dt = null;
  1006. presAdmDoc = dgv_HISRegInfo.Rows[dgv_HISRegInfo.CurrentRow.Index].Cells["doc"].Value.ToString();
  1007. presAdmLoc = dgv_HISRegInfo.Rows[dgv_HISRegInfo.CurrentRow.Index].Cells["loc"].Value.ToString();
  1008. presNo = dgv_HISRegInfo.Rows[dgv_HISRegInfo.CurrentRow.Index].Cells["prescNo"].Value.ToString();
  1009. presAdmID = dgv_HISRegInfo.Rows[dgv_HISRegInfo.CurrentRow.Index].Cells["admID"].Value.ToString();
  1010. Global.pat.adm_Dr = int.Parse(presAdmID);
  1011. if (presNo == "") return;
  1012. //获取HIS处方明细信息
  1013. if (GetHISPrescFeeInfo(presNo, ref outParam, ref dt) != 0)
  1014. {
  1015. MessageBox.Show(outParam);
  1016. return;
  1017. }
  1018. dgv_PrescriptionInfo.DataSource = dt;
  1019. }
  1020. private void dgv_BillInfo_CellClick(object sender, DataGridViewCellEventArgs e)
  1021. {
  1022. string outParam = "";
  1023. DataTable dt = null;
  1024. string errMsg;
  1025. if (dgv_BillInfo.DataSource == null)
  1026. return;
  1027. if (dgv_BillInfo.Rows[dgv_BillInfo.CurrentRow.Index].Cells["billCode"].Value.ToString() == "")
  1028. return;
  1029. string billID = dgv_BillInfo.Rows[dgv_BillInfo.CurrentRow.Index].Cells["billCode"].Value.ToString();
  1030. try
  1031. {
  1032. JObject joTmp = new JObject();
  1033. joTmp.Add("startDate", date_st.Text.Substring(0, 10));
  1034. joTmp.Add("endDate", date_et.Text.Substring(0, 10));
  1035. joTmp.Add("hospCode", JsonHelper.getDestValue((JObject)Global.curEvt.jaSession[0], "hospCode"));
  1036. joTmp.Add("billID", billID);
  1037. JObject joRtn = invoker.invokeHISService(JsonHelper.setIrisInpar("05110039", joTmp).ToString(), "组织事后单据鉴核信息填报参数");
  1038. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  1039. {
  1040. MessageBox.Show("组织事后单据鉴核信息填报参数失败,请联系管理员!" + errMsg);
  1041. return;
  1042. }
  1043. else
  1044. {
  1045. joInput20002 = joRtn;
  1046. JObject detail = new JObject();
  1047. string result = JsonHelper.getDestValue(joRtn, "result[0]").ToString();
  1048. detail = JObject.Parse(result);
  1049. dt = (DataTable)detail["detail"].ToObject(typeof(DataTable));
  1050. dgv_BillDetailInfo.DataSource = dt;
  1051. }
  1052. }
  1053. catch (Exception ex)
  1054. {
  1055. MessageBox.Show("组织事后单据鉴核信息填报参数异常:" + ex.Message);
  1056. return;
  1057. }
  1058. }
  1059. private void btnReadCard_Click(object sender, EventArgs e)
  1060. {
  1061. string outParam = "", errMsg = "";
  1062. if (hBus.readCard(out outParam) != 0)
  1063. {
  1064. MessageBox.Show("读卡失败!" + outParam);
  1065. return;
  1066. }
  1067. else
  1068. {
  1069. string patInfo = outParam;
  1070. //展示患者信息界面
  1071. if (hBus.showPatInfo(patInfo, out outParam) != 0)
  1072. {
  1073. MessageBox.Show("参保信息展示异常!" + outParam);
  1074. return;
  1075. }
  1076. else
  1077. {
  1078. if (hBus.setGlobalPatAfaterShowPatInfo(outParam, out errMsg) != 0)
  1079. {
  1080. MessageBox.Show("setGlobalPatAfaterShowPatInfo全局变量赋值异常!" + errMsg);
  1081. return;
  1082. }
  1083. }
  1084. }
  1085. }
  1086. private void btn5205_Click(object sender, EventArgs e)
  1087. {
  1088. string outParam = "", errMsg = "";
  1089. JObject joData = new JObject();
  1090. JObject joInput = new JObject();
  1091. JObject joRtn = new JObject();
  1092. string errorMsg = "";
  1093. joData.Add("mdtrt_cert_type", "02");
  1094. joData.Add("mdtrt_cert_no", Global.pat.certNO);
  1095. joData.Add("card_sn","");
  1096. joData.Add("begntime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  1097. joData.Add("psn_cert_type", "01");
  1098. joData.Add("certno", Global.pat.certNO); //证件号码
  1099. joData.Add("psn_name", Global.pat.name);
  1100. joInput.Add("data", joData);
  1101. if (Global.inf.areaCode == "340100")
  1102. {
  1103. Global.inf.interfaceDr = 17;
  1104. Global.inf.areaCode = "340100";
  1105. Global.inf.centerURL = "http://10.67.240.74:8086/1.0.0/hsa-fsi-";
  1106. }else
  1107. {
  1108. Global.inf.interfaceDr = 15;
  1109. Global.inf.areaCode = "349900";
  1110. Global.inf.centerURL = "http://10.66.155.173:8086/1.0.0/hsa-fsi-";
  1111. }
  1112. joRtn = invoker.invokeCenterService("1101", JsonHelper.setCenterInpar("1101", joInput));
  1113. if (JsonHelper.parseCenterRtnValue(joRtn, out errorMsg) == 0)
  1114. {
  1115. outParam = joRtn.ToString();
  1116. Global.pat.insuplc_admdvs = JsonHelper.getDestValue(JObject.Parse(outParam), "output.insuinfo.insuplc_admdvs"); //参保地
  1117. Global.pat.psn_no = JsonHelper.getDestValue(JObject.Parse(outParam), "output.baseinfo.psn_no"); //人员编号
  1118. }
  1119. else
  1120. {
  1121. //joRtn.Add("cardinfo",joCardInfo);
  1122. if (Global.inf.areaCode == "349900")
  1123. {
  1124. Global.inf.interfaceDr = 17;
  1125. Global.pat.insuplc_admdvs = "340100";
  1126. Global.inf.areaCode = "340100";
  1127. Global.inf.centerURL = "http://10.67.240.74:8086/1.0.0/hsa-fsi-";
  1128. }
  1129. else
  1130. {
  1131. Global.inf.areaCode = "349900";
  1132. Global.pat.insuplc_admdvs = "349900";
  1133. Global.inf.centerURL = "http://10.66.155.173:8086/1.0.0/hsa-fsi-";
  1134. Global.inf.interfaceDr = 15;
  1135. }
  1136. //签到
  1137. if (cBus.signIn(out joRtn) != 0)
  1138. {
  1139. MessageBox.Show("医保签到异常,请检查医保环境!");
  1140. }
  1141. else
  1142. {
  1143. Global.curEvt.signno = JsonHelper.getDestValue(joRtn, "output.signinoutb.sign_no");
  1144. //插入签到表
  1145. if (mIS.saveSignRecord(Global.curEvt.signno, out errMsg) != 0)
  1146. {
  1147. //MessageBox.Show("中心签到成功但插入签到表失败!");
  1148. }
  1149. else
  1150. {
  1151. //签到成功
  1152. }
  1153. }
  1154. joRtn = invoker.invokeCenterService("1101", JsonHelper.setCenterInpar("1101", joInput));
  1155. outParam = joRtn.ToString();
  1156. Global.pat.insuplc_admdvs = JsonHelper.getDestValue(JObject.Parse(outParam), "output.insuinfo.insuplc_admdvs"); //参保地
  1157. Global.pat.psn_no = JsonHelper.getDestValue(JObject.Parse(outParam), "output.baseinfo.psn_no"); //人员编号
  1158. }
  1159. //if (string.IsNullOrEmpty(Global.pat.psn_no))
  1160. //{
  1161. // MessageBox.Show("未获取到该患者的医保个人编号,请确认患者建卡信息是否维护身份证号!");
  1162. // return;
  1163. //}
  1164. JObject joInput1 = new JObject();
  1165. JObject joData1 = new JObject();
  1166. joData1.Add("psn_no", Global.pat.psn_no);
  1167. //joData1.Add("psn_no", "34010000000005004087");//合肥
  1168. //joData1.Add("psn_no", "34990010039324");//省医保
  1169. joData1.Add("begntime", dptST.Text);
  1170. joData1.Add("endtime", dptET.Text);
  1171. joInput1.Add("data", joData1);
  1172. JObject joRtn1 = invoker.invokeCenterService("5205", JsonHelper.setCenterInpar("5205", joInput1));
  1173. if (JsonHelper.parseCenterRtnValue(joRtn, out errMsg) != 0)
  1174. {
  1175. MessageBox.Show("人员慢特病用药记录查询失败:" + errMsg);
  1176. return;
  1177. }
  1178. else
  1179. {
  1180. }
  1181. JObject joOutput = JObject.Parse(JsonHelper.getDestValue(joRtn1, "output"));
  1182. JArray joIDInfo = JArray.Parse(JsonHelper.getDestValue(joOutput, "feedetail"));
  1183. if (joIDInfo.Count > 0)
  1184. {
  1185. for (int i = 0; i < joIDInfo.Count; i++)
  1186. {
  1187. Utils.convertTimestamp((JObject)joIDInfo[i], "fee_ocur_time");
  1188. }
  1189. }
  1190. //dgv5205.DataSource = (DataTable)joRtn["output"]["feedetail"].ToObject(typeof(DataTable));
  1191. dgv5205.DataSource = (DataTable)joIDInfo.ToObject(typeof(DataTable));
  1192. }
  1193. private void btnTotle_Click(object sender, EventArgs e)
  1194. {
  1195. string sqlStr = " SELECT * FROM BS_MedInsuSettlement WHERE Hospital_Dr=" + Global.inf.hospitalDr;
  1196. sqlStr = sqlStr + " and AdmType=2 and BillType=1 and ValidFlag=1 "; //and ValidFlag=1
  1197. sqlStr = sqlStr + " and OccurTime>'" + dptST2.Text + "'";
  1198. sqlStr = sqlStr + " and OccurTime<'" + dptET2.Text + "'";
  1199. if (tbName.Text != "")
  1200. {
  1201. sqlStr = sqlStr + " and PatientName='" + tbName.Text + "'";
  1202. }
  1203. if (tbPatSettlID.Text != "")
  1204. {
  1205. sqlStr = sqlStr + " and SettlementID='" + tbPatSettlID.Text + "'";
  1206. }
  1207. if (tbCertNo.Text != "")
  1208. {
  1209. sqlStr = sqlStr + " and CertificateNO='" + tbCertNo.Text + "'";
  1210. }
  1211. if (tb_AdmDr.Text != "")
  1212. {
  1213. sqlStr = sqlStr + "and Adm_Dr='" + tb_AdmDr.Text + "'";
  1214. }
  1215. sqlStr = sqlStr + " AND ReversalFlag<>1 ";
  1216. JObject joSqlstr = new JObject();
  1217. joSqlstr.Add("sqlStr", sqlStr);
  1218. JArray jaParam = new JArray();
  1219. jaParam.Add(joSqlstr);
  1220. JObject joSettlQuery = new JObject();
  1221. joSettlQuery.Add("params", jaParam);
  1222. joSettlQuery.Add("code", "09010059");
  1223. JObject joRtn = invoker.invokeInsuService(joSettlQuery.ToString(), "查询结算信息");
  1224. DataTable dt = (DataTable)joRtn["result"]["data"].ToObject(typeof(DataTable));
  1225. dgvSettlRecord2.DataSource = dt;
  1226. }
  1227. private void uiButton23_Click(object sender, EventArgs e)
  1228. {
  1229. string errorMsg = "";
  1230. if (dgvSettlRecord2.RowCount <= 0)
  1231. {
  1232. MessageBox.Show("请先查询结算数据!");
  1233. return;
  1234. }
  1235. int i = dgvSettlRecord2.CurrentRow.Index;
  1236. DataTable dt = (DataTable)dgvSettlRecord2.DataSource;
  1237. string MdtrtID = dt.Rows[i]["MdtrtID"].ToString();
  1238. string AdmID = dt.Rows[i]["AdmID"].ToString();
  1239. //4101-医疗保障及金额结算清单信息上传
  1240. if (rbg_BussnisType.SelectedIndex == 0)
  1241. {
  1242. if (upLoadSetlBillInfo(MdtrtID, AdmID, out errorMsg) != 0)
  1243. {
  1244. MessageBox.Show("上传失败!" + errorMsg);
  1245. return;
  1246. }
  1247. }
  1248. //4401-住院病案首页信息
  1249. else if (rbg_BussnisType.SelectedIndex == 1)
  1250. {
  1251. if (upLoadMedRecordInfo(AdmID, out errorMsg) != 0)
  1252. {
  1253. MessageBox.Show("上传失败!" + errorMsg);
  1254. return;
  1255. }
  1256. }
  1257. //4701-电子病历上传
  1258. else if (rbg_BussnisType.SelectedIndex == 2)
  1259. {
  1260. if (upLoadElectronicMedicalInfo(AdmID, out errorMsg) != 0)
  1261. {
  1262. MessageBox.Show("上传失败!" + errorMsg);
  1263. return;
  1264. }
  1265. }
  1266. //4402-医嘱信息上传
  1267. else
  1268. {
  1269. if (upLoadDoctorAdviceInfo(AdmID, out errorMsg) != 0)
  1270. {
  1271. MessageBox.Show("上传失败!" + errorMsg);
  1272. return;
  1273. }
  1274. }
  1275. MessageBox.Show("上传成功!");
  1276. }
  1277. private void uiButton22_Click(object sender, EventArgs e)
  1278. {
  1279. if (dgvSettlRecord2.RowCount <= 0)
  1280. {
  1281. MessageBox.Show("请先查询结算数据!");
  1282. return;
  1283. }
  1284. if (rbg_BussnisType.SelectedIndex == 0)
  1285. {
  1286. for (int i = 0; i < dgvSettlRecord2.Rows.Count; i++)
  1287. {
  1288. int iCenter = dgvSettlRecord2.CurrentRow.Index;
  1289. string MdtrtID = dgvSettlRecord2.Rows[i].Cells["MdtrtID"].Value.ToString();
  1290. string AdmID = dgvSettlRecord2.Rows[i].Cells["AdmID"].Value.ToString();
  1291. upLoadSetlBillInfo(MdtrtID, AdmID, out string errorMsg);
  1292. }
  1293. }
  1294. else if (rbg_BussnisType.SelectedIndex == 1)
  1295. {
  1296. for (int i = 0; i < dgvSettlRecord2.Rows.Count; i++)
  1297. {
  1298. int iCenter = dgvSettlRecord2.CurrentRow.Index;
  1299. string AdmID = dgvSettlRecord2.Rows[i].Cells["AdmID"].Value.ToString();
  1300. upLoadMedRecordInfo(AdmID, out string errorMsg);
  1301. }
  1302. }
  1303. else if (rbg_BussnisType.SelectedIndex == 2)
  1304. {
  1305. for (int i = 0; i < dgvSettlRecord2.Rows.Count; i++)
  1306. {
  1307. int iCenter = dgvSettlRecord2.CurrentRow.Index;
  1308. string AdmID = dgvSettlRecord2.Rows[i].Cells["AdmID"].Value.ToString();
  1309. upLoadElectronicMedicalInfo(AdmID, out string errorMsg);
  1310. }
  1311. }
  1312. else
  1313. {
  1314. for (int i = 0; i < dgvSettlRecord2.Rows.Count; i++)
  1315. {
  1316. int iCenter = dgvSettlRecord2.CurrentRow.Index;
  1317. string AdmID = dgvSettlRecord2.Rows[i].Cells["AdmID"].Value.ToString();
  1318. upLoadDoctorAdviceInfo(AdmID, out string errorMsg);
  1319. }
  1320. }
  1321. MessageBox.Show("全部上传完成!");
  1322. }
  1323. public int upLoadSetlBillInfo(string MdtrtID, string AdmID, out string OutMsg)
  1324. {
  1325. if (GetSettltBillParam(MdtrtID, out JObject joHisRtn, out OutMsg) != 0)
  1326. {
  1327. OutMsg = "从HIS获取医保结算清单入参信息失败" + OutMsg;
  1328. return -1;
  1329. }
  1330. // 解析为 JObject
  1331. JObject jsonObject = joHisRtn;
  1332. // 获取 iteminfo 数组
  1333. JArray itemInfoArray = (JArray)joHisRtn["result"]["iteminfo"];
  1334. // 遍历数组并修改 med_chrgitm
  1335. foreach (var item in itemInfoArray)
  1336. {
  1337. if (item["med_chrgitm"] != null && item["med_chrgitm"].Value<int>() == 0)
  1338. {
  1339. item["med_chrgitm"] = 14;
  1340. }
  1341. }
  1342. // 转换回 JSON 字符串
  1343. joHisRtn = jsonObject;
  1344. //MessageBox.Show(JsonHelper.getDestValue(joHisRtn, "result"));
  1345. string insutype = JsonHelper.getDestValue(joHisRtn, "result.setlinfo.hi_type");
  1346. if (insutype == "1") //企业保险办法
  1347. insutype = "310"; //职工基本医疗保险
  1348. else if (insutype == "2") //机关事业保险办法
  1349. insutype = "999"; //其他医疗保险 医疗保障类型(mdcs_type)
  1350. else if (insutype == "3") //居民医疗保险办法
  1351. insutype = "390"; //城乡居民基本医疗保险
  1352. else if (insutype == "4") //离休老干
  1353. insutype = "340"; //离休人员医疗保障
  1354. joHisRtn["result"]["setlinfo"]["hi_type"] = insutype;
  1355. joHisRtn["result"]["setlinfo"]["mdtrt_sn"] = AdmID;
  1356. //MessageBox.Show(joHisRtn.ToString());
  1357. JObject joInput = JObject.Parse(JsonHelper.getDestValue(joHisRtn, "result"));
  1358. JObject joRtn = invoker.invokeCenterServiceF("4101", JsonHelper.setCenterInparF("4101", joInput));
  1359. //JObject joRtn = invoker.invokeCenterServiceF("4101", JsonHelper.getDestValue(joHisRtn, "result"));
  1360. if (JsonHelper.parseCenterRtnValue(joRtn, out OutMsg) != 0)
  1361. {
  1362. OutMsg = "医保结算清单信息上传失败:" + OutMsg;
  1363. return -1;
  1364. }
  1365. return 0;
  1366. }
  1367. public int upLoadMedRecordInfo(string AdmID, out string OutMsg)
  1368. {
  1369. if (GetMedicalRecordParam(AdmID, out JObject joHisRtn, out OutMsg) != 0)
  1370. {
  1371. OutMsg = "从HIS获取医保病案首页入参信息失败" + OutMsg;
  1372. return -1;
  1373. }
  1374. //MessageBox.Show(JsonHelper.getDestValue(joHisRtn, "result.baseinfo"));
  1375. string prfs = JsonHelper.getDestValue(joHisRtn, "result.baseinfo.prfs");
  1376. string rh_code = JsonHelper.getDestValue(joHisRtn, "result.baseinfo.rh_code"); //血型
  1377. string dscg_way = JsonHelper.getDestValue(joHisRtn, "result.baseinfo.dscg_way"); //离院方式
  1378. if ((prfs == "/") || (prfs == "") || (prfs == "-") || (prfs == "无"))
  1379. prfs = "90";
  1380. if (prfs.Contains("11,13,17,21,24,27,31,37,51,54,70,80,90") == false)
  1381. prfs = "90";
  1382. if ((rh_code == "/") || (rh_code == "") || (rh_code == "-") || (rh_code == "无"))
  1383. rh_code = "3";
  1384. if ((dscg_way == "/") || (dscg_way == "") || (dscg_way == "-") || (dscg_way == "无"))
  1385. dscg_way = "9";
  1386. joHisRtn["result"]["baseinfo"]["prfs"] = prfs;
  1387. joHisRtn["result"]["baseinfo"]["abo_code"] = "9";
  1388. joHisRtn["result"]["baseinfo"]["medfee_paymtd_code"] = "99";
  1389. joHisRtn["result"]["baseinfo"]["rh_code"] = rh_code;
  1390. joHisRtn["result"]["baseinfo"]["dscg_way"] = dscg_way;
  1391. JObject joInput = JObject.Parse(JsonHelper.getDestValue(joHisRtn, "result"));
  1392. JObject joRtn = invoker.invokeCenterServiceF("4401", JsonHelper.setCenterInparF("4401", joInput));
  1393. //JObject joRtn = invoker.invokeCenterServiceF("4401", JsonHelper.getDestValue(joHisRtn, "result"));
  1394. if (JsonHelper.parseCenterRtnValue(joRtn, out OutMsg) != 0)
  1395. {
  1396. OutMsg = "医保结算清单信息上传失败:" + OutMsg;
  1397. return -1;
  1398. }
  1399. return 0;
  1400. }
  1401. /// <summary>
  1402. /// 电子病历上传
  1403. /// </summary>
  1404. /// <param name="AdmID"></param>
  1405. /// <param name="OutMsg"></param>
  1406. /// <returns></returns>
  1407. public int upLoadElectronicMedicalInfo(string AdmID, out string OutMsg)
  1408. {
  1409. if (GetElectronicMedicalRecordParam(AdmID, out JObject joHisRtn, out OutMsg) != 0)
  1410. {
  1411. OutMsg = "从HIS获取电子病历入参信息失败" + OutMsg;
  1412. return -1;
  1413. }
  1414. //MessageBox.Show(joHisRtn.ToString());
  1415. JObject joInput = JObject.Parse(JsonHelper.getDestValue(joHisRtn, "result"));
  1416. JObject joRtn = invoker.invokeCenterServiceF("4701", JsonHelper.setCenterInparF("4701", joInput));
  1417. //JObject joRtn = invoker.invokeCenterServiceF("4701", JsonHelper.getDestValue(joHisRtn, "result"));
  1418. if (JsonHelper.parseCenterRtnValue(joRtn, out OutMsg) != 0)
  1419. {
  1420. OutMsg = "电子病历信息上传失败:" + OutMsg;
  1421. return -1;
  1422. }
  1423. return 0;
  1424. }
  1425. /// <summary>
  1426. /// 住院医嘱信息上传
  1427. /// </summary>
  1428. /// <param name="AdmID"></param>
  1429. /// <param name="OutMsg"></param>
  1430. /// <returns></returns>
  1431. public int upLoadDoctorAdviceInfo(string AdmID, out string OutMsg)
  1432. {
  1433. if (GetDoctorAdviceParam(AdmID, out JObject joHisRtn, out OutMsg) != 0)
  1434. {
  1435. OutMsg = "从HIS获取住院医嘱信息失败" + OutMsg;
  1436. return -1;
  1437. }
  1438. JArray ja = JArray.Parse(JsonHelper.getDestValue(joHisRtn, "result"));
  1439. JObject joInput = new JObject();
  1440. joInput.Add("data", ja);
  1441. JObject joRtn = invoker.invokeCenterServiceF("4402", JsonHelper.setCenterInparF("4402", joInput));
  1442. if (JsonHelper.parseCenterRtnValue(joRtn, out OutMsg) != 0)
  1443. {
  1444. OutMsg = "住院医嘱信息上传失败:" + OutMsg;
  1445. return -1;
  1446. }
  1447. return 0;
  1448. }
  1449. /// <summary>
  1450. /// 获取HIS医保结算清单入参
  1451. /// </summary>
  1452. /// <param name="MdtrtID"></param>
  1453. /// <param name="joSetlBill"></param>
  1454. /// <returns></returns>
  1455. public int GetSettltBillParam(string MdtrtID, out JObject joSetlBill, out string outMsg)
  1456. {
  1457. JObject jo = new JObject();
  1458. jo.Add("insuAdmNo", MdtrtID);
  1459. jo.Add("funNo", "4101");
  1460. jo.Add("type", "InsuRiskManagement");
  1461. joSetlBill = IS.GetHISSettleBillParam(jo);
  1462. if (JsonHelper.parseIrisRtnValue(joSetlBill, out outMsg) != 0)
  1463. {
  1464. outMsg = "获取HIS医保结算清单入参失败,请联系管理员!" + outMsg;
  1465. return -1;
  1466. }
  1467. if (JsonHelper.getDestValue(joSetlBill, "result.setlinfo") == "")
  1468. {
  1469. return -1;
  1470. }
  1471. return 0;
  1472. }
  1473. /// <summary>
  1474. /// 获取HIS医保结算清单入参
  1475. /// </summary>
  1476. /// <param name="MdtrtID"></param>
  1477. /// <param name="joSetlBill"></param>
  1478. /// <returns></returns>
  1479. public int GetMedicalRecordParam(string AdmID, out JObject joMedRecord, out string outMsg)
  1480. {
  1481. JObject jo = new JObject();
  1482. jo.Add("admID", AdmID);
  1483. jo.Add("interfaceID", Global.inf.interfaceDr);
  1484. //jo.Add("funNo", "4401");
  1485. //jo.Add("type", "InsuRiskManagement");
  1486. joMedRecord = IS.GetHISMedicalRecordParam(jo);
  1487. if (JsonHelper.parseIrisRtnValue(joMedRecord, out outMsg) != 0)
  1488. {
  1489. outMsg = "获取HIS医保病案首页入参失败,请联系管理员!" + outMsg;
  1490. return -1;
  1491. }
  1492. if (JsonHelper.getDestValue(joMedRecord, "result.baseinfo") == "")
  1493. {
  1494. return -1;
  1495. }
  1496. return 0;
  1497. }
  1498. /// <summary>
  1499. /// 获取HIS电子病历入参
  1500. /// </summary>
  1501. /// <param name="AdmID"></param>
  1502. /// <param name="joSetlBill"></param>
  1503. /// <returns></returns>
  1504. public int GetElectronicMedicalRecordParam(string AdmID, out JObject joMedRecord, out string outMsg)
  1505. {
  1506. JObject jo = new JObject();
  1507. jo.Add("admID", AdmID);
  1508. jo.Add("interfaceID", Global.inf.interfaceDr);
  1509. //jo.Add("funNo", "4701");
  1510. //jo.Add("type", "InsuRiskManagement");
  1511. joMedRecord = IS.GetHISElectronicMedicalRecordParam(jo);
  1512. if (JsonHelper.parseIrisRtnValue(joMedRecord, out outMsg) != 0)
  1513. {
  1514. outMsg = "获取HIS电子病历入参失败,请联系管理员!" + outMsg;
  1515. return -1;
  1516. }
  1517. if (JsonHelper.getDestValue(joMedRecord, "result") == "")
  1518. {
  1519. return -1;
  1520. }
  1521. return 0;
  1522. }
  1523. /// <summary>
  1524. /// 获取HIS住院医嘱信息入参
  1525. /// </summary>
  1526. /// <param name="AdmID"></param>
  1527. /// <param name="joSetlBill"></param>
  1528. /// <returns></returns>
  1529. public int GetDoctorAdviceParam(string AdmID, out JObject joMedRecord, out string outMsg)
  1530. {
  1531. JObject jo = new JObject();
  1532. jo.Add("admID", AdmID);
  1533. jo.Add("interfaceID", Global.inf.interfaceDr);
  1534. //jo.Add("funNo", "4701");
  1535. //jo.Add("type", "InsuRiskManagement");
  1536. joMedRecord = IS.GetDoctorAdviceParam(jo);
  1537. JArray ja = JArray.Parse(JsonHelper.getDestValue(joMedRecord, "result"));
  1538. if (JsonHelper.parseIrisRtnValue(joMedRecord, out outMsg) != 0)
  1539. {
  1540. outMsg = "获取HIS住院医嘱信息入参失败,请联系管理员!" + outMsg;
  1541. return -1;
  1542. }
  1543. if (ja.Count <= 0)
  1544. {
  1545. return -1;
  1546. }
  1547. return 0;
  1548. }
  1549. private void uiButton25_Click(object sender, EventArgs e)
  1550. {
  1551. this.Close();
  1552. }
  1553. public int queryHISDirectory(out string errMsg)
  1554. {
  1555. errMsg = "";
  1556. string pageSize = "500";
  1557. string flag = "Maped";
  1558. JObject joHISRtn = new JObject();
  1559. JObject joRtn = new JObject();
  1560. JArray jaPagination = new JArray();
  1561. JArray jaParams = new JArray();
  1562. dynamic joParam = new JObject();
  1563. joParam.alias = "";
  1564. joParam.HospitalDr = Global.inf.hospitalDr;
  1565. joParam.InterfaceDr = Global.inf.interfaceDr;
  1566. joParam.hisType = "drugs";
  1567. jaParams.Add(joParam);
  1568. dynamic joPagination = new JObject();
  1569. joPagination.pageSize = pageSize;
  1570. joPagination.currentPage = "1";
  1571. joPagination.sortColumn = "HisCode";
  1572. joPagination.sortOrder = "asc";
  1573. jaPagination.Add(joPagination);
  1574. JObject joMIRtn = mIS.GetMappedHISDir(jaPagination, jaParams);
  1575. if (JsonHelper.parseIrisRtnValue(joMIRtn, out errMsg) != 0)
  1576. {
  1577. return -1;
  1578. }
  1579. //传给HIS,进行匹配
  1580. joParam = new JObject();
  1581. joParam.TotalCount = joMIRtn["result"]["TotalCount"];
  1582. joParam.type = "drugs";
  1583. joParam.flag = flag;
  1584. joParam.hospID = Global.inf.hisHospitalDr;
  1585. joParam.interfaceDr = Global.inf.interfaceDr;
  1586. joParam.alias = "";
  1587. joParam.include = "Hosp";
  1588. joParam.groupID = "324";
  1589. joParam.specInput = "";//增加规格过滤
  1590. joParam.compareArr = joMIRtn["result"]["Data"];
  1591. jaParams = new JArray();
  1592. jaParams.Add(joParam);
  1593. if (hIS.getHISDir(jaPagination, jaParams, out joRtn, out errMsg) != 0)
  1594. {
  1595. return -1;
  1596. }
  1597. DataTable dt = (DataTable)joRtn["result"]["Data"].ToObject(typeof(DataTable));
  1598. dtExport = dt;
  1599. int totalCount = int.Parse(joRtn["result"]["TotalCount"].ToString());
  1600. //pgHISDirect.TotalCount = totalCount;
  1601. //pgHISDirect.PageSize = pageSize;
  1602. dgvMedInsuMapRelation.DataSource = null;
  1603. dgvMedInsuMapRelation.DataSource = dt;
  1604. dgvMedInsuMapRelation.Columns[0].ReadOnly = true;
  1605. GridViewSetter gridSetter = new GridViewSetter();
  1606. gridSetter.SetHeaderTextOfMapping_HisDirectory(dgvMedInsuMapRelation);
  1607. gridSetter.DatagridviewColumnWidthAdaptation(dgvMedInsuMapRelation);
  1608. return 0;
  1609. }
  1610. private void uiButton9_Click(object sender, EventArgs e)
  1611. {
  1612. if (queryHISDirectory(out string errMsg) != 0)
  1613. {
  1614. MessageBox.Show(errMsg);
  1615. return;
  1616. }
  1617. }
  1618. private void uiButton10_Click(object sender, EventArgs e)
  1619. {
  1620. string errorMsg;
  1621. if (dgvMedInsuMapRelation.CurrentRow == null)
  1622. {
  1623. MessageBox.Show("请先查询医保药品对照信息");
  1624. return;
  1625. }
  1626. int iCenter = dgvMedInsuMapRelation.CurrentRow.Index;
  1627. string insuCode = dgvMedInsuMapRelation.Rows[iCenter].Cells["insuCode"].Value.ToString(); //中心编码
  1628. string insuName = dgvMedInsuMapRelation.Rows[iCenter].Cells["insuName"].Value.ToString(); //中心编码
  1629. string itemCode = dgvMedInsuMapRelation.Rows[iCenter].Cells["itemCode"].Value.ToString(); //医院编码
  1630. string itemDesc = dgvMedInsuMapRelation.Rows[iCenter].Cells["itemDesc"].Value.ToString(); //医院名称
  1631. SaleBillInfo sbi = new SaleBillInfo(insuCode, insuName);
  1632. try
  1633. {
  1634. if (sbi.ShowDialog() == DialogResult.OK)
  1635. {
  1636. JObject joInput = new JObject();
  1637. JObject joData = new JObject();
  1638. joData.Add("entId", sbi.entId);
  1639. joData.Add("code", sbi.code);
  1640. joData.Add("medicalDrugId", sbi.medicalDrugId);
  1641. joData.Add("queryTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  1642. joData.Add("salePkg", sbi.salePkg);
  1643. joData.Add("unpackCount", sbi.unpackCount);
  1644. joData.Add("drugSalePrice", sbi.drugSalePrice);
  1645. joData.Add("batchNo", sbi.batchNo);
  1646. joInput.Add("data", joData);
  1647. JObject joRtn = invoker.invokeCenterServiceF("20001", JsonHelper.setCenterInparFT("20001", joInput));
  1648. if (JsonHelper.parseCenterRtnValue(joRtn, out errorMsg) != 0)
  1649. {
  1650. MessageBox.Show("医保药品鉴核数据采集事前鉴核服务上传失败:" + errorMsg);
  1651. return;
  1652. }
  1653. else
  1654. {
  1655. DataTable dtData = (DataTable)joRtn["output"]["data"].ToObject(typeof(DataTable));
  1656. DataTable dtVerifyResult = (DataTable)joRtn["output"]["verifyResult"].ToObject(typeof(DataTable));
  1657. DataTable dtTraceCodeVo = (DataTable)joRtn["output"]["traceCodeVo"].ToObject(typeof(DataTable));
  1658. DataTable dtMedDrugInfo = (DataTable)joRtn["output"]["medDrugInfo"].ToObject(typeof(DataTable));
  1659. dgvData.DataSource = dtData;
  1660. dgvVerifyResult.DataSource = dtVerifyResult;
  1661. dgvTraceCodeVo.DataSource = dtTraceCodeVo;
  1662. dgvMedDrugInfo.DataSource = dtMedDrugInfo;
  1663. MessageBox.Show("医保药品鉴核数据采集事前鉴核服务上传成功");
  1664. }
  1665. }
  1666. else
  1667. {
  1668. MessageBox.Show("操作员已取消!");
  1669. return;
  1670. }
  1671. }
  1672. catch (Exception ex)
  1673. {
  1674. MessageBox.Show("异常:" + ex.Message);
  1675. return;
  1676. }
  1677. }
  1678. private void uiButton11_Click(object sender, EventArgs e)
  1679. {
  1680. string errorMsg;
  1681. JObject joInput = new JObject();
  1682. JObject joData = new JObject();
  1683. joData.Add("ent_id", tbJGBM.Text);
  1684. joData.Add("bill_code", tbDJBH.Text);
  1685. joData.Add("bill_time", dtTHSJ.Text);
  1686. joInput.Add("data", joData);
  1687. JObject joRtn = invoker.invokeCenterServiceF("20003", JsonHelper.setCenterInparF("20003", joInput));
  1688. if (JsonHelper.parseCenterRtnValue(joRtn, out errorMsg) != 0)
  1689. {
  1690. MessageBox.Show("医保销售单据退货上传失败:" + errorMsg);
  1691. return;
  1692. }
  1693. else
  1694. {
  1695. MessageBox.Show("医保销售单据退货上传成功!" + errorMsg);
  1696. }
  1697. }
  1698. private void uiButton15_Click(object sender, EventArgs e)
  1699. {
  1700. string errMsg;
  1701. dgv_BillInfo.DataSource = null;
  1702. dgv_BillDetailInfo.DataSource = null;
  1703. try
  1704. {
  1705. JObject joTmp = new JObject();
  1706. joTmp.Add("startDate",date_st.Text.Substring(0,10));
  1707. joTmp.Add("endDate", date_et.Text.Substring(0, 10));
  1708. joTmp.Add("hospCode", JsonHelper.getDestValue((JObject)Global.curEvt.jaSession[0], "hospCode"));
  1709. joTmp.Add("billID", "");
  1710. JObject joRtn = invoker.invokeHISService(JsonHelper.setIrisInpar("05110039", joTmp).ToString(), "组织事后单据鉴核信息填报参数");
  1711. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  1712. {
  1713. MessageBox.Show("组织事后单据鉴核信息填报参数失败,请联系管理员!" + errMsg);
  1714. return;
  1715. }
  1716. else
  1717. {
  1718. DataTable dt = (DataTable)joRtn["result"].ToObject(typeof(DataTable));
  1719. dgv_BillInfo.DataSource = dt;
  1720. }
  1721. }
  1722. catch (Exception ex)
  1723. {
  1724. MessageBox.Show("组织事后单据鉴核信息填报参数异常:" + ex.Message);
  1725. return;
  1726. }
  1727. }
  1728. /// <summary>
  1729. /// 获取HIS就诊信息
  1730. /// </summary>
  1731. /// <param name="dtST"></param>
  1732. /// <param name="dtED"></param>
  1733. /// <param name="PatInfo"></param>
  1734. /// <param name="errMsg"></param>
  1735. /// <param name="DT"></param>
  1736. /// <returns></returns>
  1737. private int GetHISRegInfo(string dtST, string dtED, string PatInfo, ref string errMsg, ref DataTable DT)
  1738. {
  1739. dynamic joTmp = new JObject();
  1740. joTmp.Add("stDate", dtST);
  1741. joTmp.Add("endDate", dtED);
  1742. joTmp.Add("patInfo", PatInfo);
  1743. JObject joRtnHISRegInfo = hIS.GetHISRegInfo(joTmp);
  1744. if (JsonHelper.parseIrisRtnValue(joRtnHISRegInfo, out errMsg) != 0)
  1745. {
  1746. errMsg = "获取HIS患者就诊信息失败,请联系管理员!" + errMsg;
  1747. return -1;
  1748. }
  1749. else
  1750. {
  1751. if ((joRtnHISRegInfo["result"]["rows"].ToString() == "[]"))
  1752. {
  1753. errMsg = "查询HIS就诊信息结果为空!";
  1754. return -1;
  1755. }
  1756. else
  1757. {
  1758. DT = (DataTable)joRtnHISRegInfo["result"]["rows"].ToObject(typeof(DataTable));
  1759. return 0;
  1760. }
  1761. }
  1762. }
  1763. private void uiButton18_Click(object sender, EventArgs e)
  1764. {
  1765. string errMsg;
  1766. //if (tb_SFZH.Text == "")
  1767. //{
  1768. // MessageBox.Show("请先输入患者身份证号进行查找患者未结算处方信息!");
  1769. // return;
  1770. //}
  1771. //else
  1772. //{
  1773. // dgv_HISRegInfo.DataSource = null;
  1774. // dgv_PrescriptionInfo.DataSource = null;
  1775. // CertNo = tb_SFZH.Text;
  1776. // Global.pat.certNO = tb_SFZH.Text;
  1777. //}
  1778. dgv_HISRegInfo.DataSource = null;
  1779. dgv_PrescriptionInfo.DataSource = null;
  1780. CertNo = tb_SFZH.Text;
  1781. Global.pat.certNO = tb_SFZH.Text;
  1782. #region【查询HIS就诊信息-用身份证号查询患者当日的就诊记录】
  1783. string outParam = "";
  1784. DataTable dt1 = null;
  1785. if (GetHISRegInfo(dtp_st.Text, dtp_et.Text, Global.pat.certNO, ref outParam, ref dt1) != 0)
  1786. {
  1787. MessageBox.Show(outParam);
  1788. return;
  1789. }
  1790. dgv_HISRegInfo.DataSource = dt1;
  1791. #endregion
  1792. #region【根据处方号查询处方明细信息】
  1793. presAdmDoc = dgv_HISRegInfo.Rows[0].Cells["doc"].Value.ToString();
  1794. presAdmLoc = dgv_HISRegInfo.Rows[0].Cells["loc"].Value.ToString();
  1795. presNo = dgv_HISRegInfo.Rows[0].Cells["prescNo"].Value.ToString();
  1796. presAdmID = dgv_HISRegInfo.Rows[0].Cells["admID"].Value.ToString();
  1797. Global.pat.adm_Dr = int.Parse(presAdmID);
  1798. if (presNo == "") return;
  1799. DataTable dt2 = null;
  1800. //获取HIS处方明细信息
  1801. if (GetHISPrescFeeInfo(presNo, ref outParam, ref dt2) != 0)
  1802. {
  1803. MessageBox.Show(outParam);
  1804. return;
  1805. }
  1806. dgv_PrescriptionInfo.DataSource = dt2;
  1807. #endregion
  1808. }
  1809. /// <summary>
  1810. /// 获取HIS费用明细信息
  1811. /// </summary>
  1812. /// <param name="PrescNo"></param>
  1813. /// <param name="errMsg"></param>
  1814. /// <param name="DT"></param>
  1815. /// <returns></returns>
  1816. private int GetHISPrescFeeInfo(string PrescNo, ref string errMsg, ref DataTable DT)
  1817. {
  1818. dynamic joTmp = new JObject();
  1819. joTmp.Add("prescNo", PrescNo);
  1820. JObject joRtnHISPrescFeeInfo = hIS.GetHISPrescFeeInfo(joTmp);
  1821. if (JsonHelper.parseIrisRtnValue(joRtnHISPrescFeeInfo, out errMsg) != 0)
  1822. {
  1823. errMsg = "获取HIS患者处方信息失败,请联系管理员!" + errMsg;
  1824. return -1;
  1825. }
  1826. else
  1827. {
  1828. if ((joRtnHISPrescFeeInfo["result"]["rows"].ToString() == "[]"))
  1829. {
  1830. errMsg = "查询HIS处方信息结果为空!";
  1831. return -1;
  1832. }
  1833. else
  1834. {
  1835. DT = (DataTable)joRtnHISPrescFeeInfo["result"]["rows"].ToObject(typeof(DataTable));
  1836. return 0;
  1837. }
  1838. }
  1839. }
  1840. private void dgv_HISRegInfo_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  1841. {
  1842. uiButton16_Click(sender, e);
  1843. }
  1844. }
  1845. }