MedInsuQuery.cs 93 KB

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