MedInsuQuery.cs 58 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249
  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. //1.声明自适应类实例
  28. AutoResizeForm asc = new AutoResizeForm();
  29. private InvokeHelper invoker = new InvokeHelper();
  30. private HisIrisServices hIS = new HisIrisServices();
  31. private MIIrisServices mIS = new MIIrisServices();
  32. public MedInsuQuery()
  33. {
  34. InitializeComponent();
  35. asc.controllInitializeSize(this);
  36. asc.controlAutoSize(this);
  37. }
  38. private void btnClose_Click(object sender, EventArgs e)
  39. {
  40. this.Close();
  41. }
  42. private void MedInsuQuery_Load(object sender, EventArgs e)
  43. {
  44. //this.WindowState = FormWindowState.Maximized;
  45. tbcMain.SelectedIndex = 1;
  46. dpST.Text = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  47. dpED.Text = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  48. dt_ST.Text = DateTime.Now.ToString("yyyy-MM-01 00:00:00");
  49. dt_ET.Text = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  50. date_st.Text = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  51. date_et.Text = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  52. dtp_st.Text = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  53. dtp_et.Text = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  54. dpt_ST.Text = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  55. dpt_ET.Text = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  56. DT_ST1.Text = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  57. DT_ET1.Text = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  58. dtTHSJ.Text = DateTime.Now.ToString();
  59. // dgvSettlRecord.AutoGenerateColumns = false;
  60. cbbLevel.SelectedIndex = 0;
  61. cbbOverPrice.SelectedIndex = 0;
  62. GridViewSetter grdSetter = new GridViewSetter();
  63. grdSetter.SetHeaderTextOfMedInsuHosPerInfo(dgvSettlRecord);
  64. grdSetter.SetHeaderTextOfSettltMentFeelDetailInfo(dgvInsuFeeUpload);
  65. grdSetter.DatagridviewColumnWidthAdaptation(dgvInsuFeeUpload);
  66. grdSetter.SetHeaderTextOfMIPatCurrentInsuInfo(dgv_4001);
  67. grdSetter.SetHeaderTextOfSettlList(dgvSettleData);
  68. grdSetter.SetHeaderTextOfSettltMentFeelDetailInfo(dgvFeeInfo);
  69. grdSetter.SetHeaderTextOfHISRegister(dgv_HISRegInfo);
  70. grdSetter.SetHeaderTextOfHISPrescFee(dgv_PrescriptionInfo);
  71. grdSetter.SetHeaderTextOfBillInfo(dgv_BillInfo);
  72. grdSetter.SetHeaderTextOfBillDetailInfo(dgv_BillDetailInfo);
  73. grdSetter.DatagridviewColumnWidthAdaptation(dgv_HISRegInfo);
  74. grdSetter.DatagridviewColumnWidthAdaptation(dgv_PrescriptionInfo);
  75. grdSetter.DatagridviewColumnWidthAdaptation(dgv_BillInfo);
  76. grdSetter.DatagridviewColumnWidthAdaptation(dgv_BillDetailInfo);
  77. rbg_Type.SelectedIndex = 0;
  78. tbJGBM.Text = Global.inf.hospitalNO;
  79. dtTHSJ.Text= DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  80. }
  81. private void btnQuery_Click(object sender, EventArgs e)
  82. {
  83. btnPrint.Enabled = false;
  84. string sCZYXM = Global.user.name;
  85. string SqlHeard = " Adm_Dr,MdtrtID,Name as PatientName,Age,PsnCertNO,Gend,PsnType,EmpName,AdmInDepName,insuplcAdmdvs,sZYZT AS sZTSM, "
  86. + " AdmBed,RegDate,MainDiagName,AttendDoctorNO,ChiefPhyDocName,'"+ sCZYXM+ "' as OpertName,'' as InHospNo,''Address ";
  87. string SqlStrMain = " SELECT a.*,b.*,a.PatientName AS Name,a.PsnType AS PsnTypeCode,'在院' sZYZT FROM BS_MIPatCurrentInsuInfo a LEFT JOIN BS_MedInsuRegisterInfo b "
  88. + " ON a.MdtrtID=b.InsuRegID AND a.Interface_Dr=b.Interface_Dr AND a.Hospital_Dr=b.Hospital_Dr "
  89. + " WHERE b.Type=1 AND b.ValidFlag=1 AND b.Hospital_Dr= " + Global.inf.hospitalDr + " AND b.Interface_Dr= " + Global.inf.interfaceDr
  90. + " AND b.InsuRegID NOT IN (SELECT MdtrtID FROM BS_MedInsuSettlement WHERE MdtrtID=b.InsuRegID AND BillType=1 AND ValidFlag=1 AND AdmType=2) "
  91. + " AND b.RegDate<='" + dpED.Text + "' AND b.RegDate>'" + dpST.Text + "' " //
  92. + " UNION ALL "
  93. + " SELECT a.*,b.*,a.PatientName AS Name,a.PsnType AS PsnTypeCode,'已结算' AS sZYZT "
  94. + " FROM BS_MIPatCurrentInsuInfo a LEFT JOIN BS_MedInsuRegisterInfo b "
  95. + " ON a.MdtrtID=b.InsuRegID AND a.Interface_Dr=b.Interface_Dr AND a.Hospital_Dr=b.Hospital_Dr "
  96. + " 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 "
  97. + " 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
  98. + " AND c.AdmType=2 AND c.SettlementDateTime<='" + dpED.Text + "' AND c.SettlementDateTime>'" + dpST.Text + "' "; //
  99. string sqlStr = " SELECT "+ SqlHeard + " FROM ("+ SqlStrMain +") M ";
  100. //MessageBox.Show(sqlStr);
  101. JObject joSqlstr = new JObject();
  102. joSqlstr.Add("sqlStr", sqlStr);
  103. joSqlstr.Add("Type", "MedInsuHosPInfo");
  104. joSqlstr.Add("hospID", Global.inf.hisHospitalDr);
  105. JArray jaParam = new JArray();
  106. jaParam.Add(joSqlstr);
  107. JObject joSettlQuery = new JObject();
  108. joSettlQuery.Add("params", jaParam);
  109. joSettlQuery.Add("code", "09010059");
  110. InvokeHelper invoker = new InvokeHelper();
  111. JObject joRtn = invoker.invokeInsuService(joSettlQuery.ToString(), "查询结算信息");
  112. //MessageBox.Show(joRtn.ToString());
  113. if (joRtn["result"]["data"].ToString() == "[]")
  114. {
  115. MessageBox.Show("查询结果为空!");
  116. return;
  117. }
  118. DataTable dt = (DataTable)joRtn["result"]["data"].ToObject(typeof(DataTable));
  119. dgvSettlRecord.DataSource = dt;
  120. if (dt.Rows.Count != 0)
  121. {
  122. btnPrint.Enabled = true;
  123. dtExport = dt;
  124. //从HIS获取患者的床号(分床前医保登记的病人床号没有写入医保平台登记表)
  125. for (int i = 0; i < dt.Rows.Count; i++)
  126. {
  127. string BedNo, BedDocName, InHospNo, Address;
  128. JObject joTmp = new JObject();
  129. joTmp.Add("admID", dt.Rows[i]["Adm_Dr"].ToString());
  130. JObject joRtn2 = invoker.invokeHISService(JsonHelper.setIrisInpar("05110014", joTmp).ToString(), "获取患者就诊信息");
  131. if (JsonHelper.parseIrisRtnValue(joRtn2, out string errMsg) == 0)
  132. {
  133. BedNo = JsonHelper.getDestValue(JObject.Parse(joRtn2.ToString()), "mdtrtinfo.adm_bed");
  134. BedDocName = JsonHelper.getDestValue(JObject.Parse(joRtn2.ToString()), "mdtrtinfo.chfpdr_name");
  135. InHospNo = JsonHelper.getDestValue(JObject.Parse(joRtn2.ToString()), "mdtrtinfo.medrcdno");
  136. Address = JsonHelper.getDestValue(JObject.Parse(joRtn2.ToString()), "mdtrtinfo.Address");
  137. dt.Rows[i]["AdmBed"] = BedNo;
  138. dt.Rows[i]["AttendDoctorNO"] = BedDocName;
  139. dt.Rows[i]["InHospNo"] = InHospNo;
  140. dt.Rows[i]["Address"] = Address;
  141. }
  142. else
  143. {
  144. if (errMsg.IndexOf("请重新登录") > 0)
  145. {
  146. MessageBox.Show("获取患者信息失败,请重新登录系统!");
  147. break;
  148. }
  149. }
  150. }
  151. }
  152. }
  153. private void btnPrint_Click(object sender, EventArgs e)
  154. {
  155. string LSH = DateTime.Now.ToString("yyyy-MM-dd"); //DateTime.Now.ToString("MMddHHmmssffff");
  156. string sFliePathName = @"C:\Users\Administrator\Desktop\" + LSH + "医保在院患者登记或结算信息.xls";
  157. string ReturnFileName = ExportToExcel.DataTabletoExcel(dtExport, sFliePathName);
  158. if (ReturnFileName != "")
  159. {
  160. MessageBox.Show("导出成功,文件保存路径:【" + ReturnFileName + "】");
  161. System.Diagnostics.Process.Start(ReturnFileName); //打开excel文件
  162. }
  163. else
  164. {
  165. MessageBox.Show("导出失败!");
  166. }
  167. }
  168. private void btnOK_Click(object sender, EventArgs e)
  169. {
  170. string sqlStr;
  171. sqlStr = " SELECT a.Adm_Dr,c.Name, b.HISCode, b.MedInsuNO, b.Price,b.Sumamt,b.ChargeItemLevel,c.ChargeItemLevelName,b.SelfPayProp, ";
  172. sqlStr = sqlStr + " b.UpLimitAmount,b.OverLimitAmount,b.InScopeAmount,b.FullOwnPayAmount,b.PreSelfPayAmount,b.LimitUsedFlag ";
  173. sqlStr = sqlStr + " FROM BS_MedInsuSettlement a LEFT JOIN BS_MedInsuFeeUploadRecord b ";
  174. sqlStr = sqlStr + " ON a.Hospital_Dr=b.Hospital_Dr AND a.MdtrtID=b.MdtrtID AND a.PersonnelNO=b.PersonnelNO ";
  175. 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 ";
  176. sqlStr = sqlStr + " WHERE b.MedInsuNO<>'' and a.ValidFlag=1 AND a.BillType=1 AND a.AdmType=2 ";
  177. sqlStr = sqlStr + " AND a.Interface_Dr=" + Global.inf.interfaceDr;
  178. sqlStr = sqlStr + " AND a.Hospital_Dr= " + Global.inf.hospitalDr;
  179. sqlStr = sqlStr + " AND a.OccurTime>'" + dt_ST.Text + "'";
  180. sqlStr = sqlStr + " AND a.OccurTime<'" + dt_ET.Text + "'";
  181. if (tb_InHospNo.Text != "")
  182. {
  183. sqlStr = sqlStr + " and a.BillID='" + tb_InHospNo.Text + "'";
  184. }
  185. if (tb_SettleID.Text != "")
  186. {
  187. sqlStr = sqlStr + " and a.SettlementID='" + tb_SettleID.Text + "'";
  188. }
  189. if (cbbOverPrice.Text == "是")
  190. {
  191. sqlStr = sqlStr + " AND b.OverLimitAmount>0 ";
  192. }
  193. else if (cbbOverPrice.Text == "否")
  194. {
  195. sqlStr = sqlStr + " AND b.OverLimitAmount<=0 ";
  196. }
  197. if (cbbLevel.Text == "甲类")
  198. {
  199. sqlStr = sqlStr + " AND b.ChargeItemLevel='01' ";
  200. }
  201. else if (cbbLevel.Text == "乙类")
  202. {
  203. sqlStr = sqlStr + " AND b.ChargeItemLevel='02' ";
  204. }
  205. else if (cbbLevel.Text == "丙类")
  206. {
  207. sqlStr = sqlStr + " AND b.ChargeItemLevel='03' ";
  208. }
  209. JObject joSqlstr = new JObject();
  210. joSqlstr.Add("sqlStr", sqlStr);
  211. JArray jaParam = new JArray();
  212. jaParam.Add(joSqlstr);
  213. JObject joSettlQuery = new JObject();
  214. joSettlQuery.Add("params", jaParam);
  215. joSettlQuery.Add("code", "09010118");
  216. JObject joRtn = invoker.invokeInsuService(joSettlQuery.ToString(), "查询医保结算费用信息");
  217. DataTable dt = (DataTable)joRtn["result"]["data"].ToObject(typeof(DataTable));
  218. dgvInsuFeeUpload.DataSource = dt;
  219. }
  220. private void uiButton3_Click(object sender, EventArgs e)
  221. {
  222. //string sqlStr = " SELECT * FROM BS_MedInsuSettlement WHERE Hospital_Dr=" + Global.inf.hospitalDr;
  223. //sqlStr = sqlStr + " and OccurTime>'" + DT_ST1.Text + "'";
  224. //sqlStr = sqlStr + " and OccurTime<'" + DT_ET1.Text + "'";
  225. //sqlStr = sqlStr + " and Interface_Dr=" + Global.inf.interfaceDr + "";
  226. //sqlStr = sqlStr + " and CertificateNO= " + tb_CertNo.Text;
  227. //sqlStr = sqlStr + " and BillType=1 and ValidFlag=1 ";
  228. string sqlstr = " SELECT a.InsuranceAreaCode, b.* FROM BS_MedInsuSettlement a LEFT JOIN BS_MIPatCurrentInsuInfo b ";
  229. sqlstr = sqlstr + " ON a.PersonnelNO=b.PersonalNO AND a.Interface_Dr=b.Interface_Dr ";
  230. sqlstr = sqlstr + " WHERE a.ValidFlag=1 AND a.BillType=1 ";
  231. sqlstr = sqlstr + " and a.OccurTime>'" + DT_ST1.Text + "'";
  232. sqlstr = sqlstr + " and a.OccurTime<'" + DT_ET1.Text + "'";
  233. sqlstr = sqlstr + " and a.Interface_Dr='" + Global.inf.interfaceDr + "'";
  234. if (tb_CertNo.Text!="")
  235. sqlstr = sqlstr + " and a.CertificateNO='" + tb_CertNo.Text + "'";
  236. JObject joSqlstr = new JObject();
  237. joSqlstr.Add("sqlStr", sqlstr);
  238. joSqlstr.Add("Type", "4001");
  239. JArray jaParam = new JArray();
  240. jaParam.Add(joSqlstr);
  241. JObject joSettlQuery = new JObject();
  242. joSettlQuery.Add("params", jaParam);
  243. joSettlQuery.Add("code", "09010059");
  244. JObject joRtn = invoker.invokeInsuService(joSettlQuery.ToString(), "查询结算信息");
  245. DataTable dt = (DataTable)joRtn["result"]["data"].ToObject(typeof(DataTable));
  246. dgv_4001.DataSource = dt;
  247. }
  248. private void uiButton4_Click(object sender, EventArgs e)
  249. {
  250. string errorMsg = "";
  251. if (dgv_4001.CurrentRow == null)
  252. {
  253. MessageBox.Show("请查询患者参保信息");
  254. return;
  255. }
  256. int iCenter = dgv_4001.CurrentRow.Index;
  257. string psn_no = dgv_4001.Rows[iCenter].Cells["PersonalNO"].Value.ToString();
  258. string psn_cert_type = dgv_4001.Rows[iCenter].Cells["PsnCertType"].Value.ToString();
  259. string certno = dgv_4001.Rows[iCenter].Cells["PsnCertNO"].Value.ToString();
  260. string psn_name = dgv_4001.Rows[iCenter].Cells["PatientName"].Value.ToString();
  261. string gend = dgv_4001.Rows[iCenter].Cells["Gend"].Value.ToString();
  262. string naty = dgv_4001.Rows[iCenter].Cells["Naty"].Value.ToString();
  263. string brdy = dgv_4001.Rows[iCenter].Cells["Brdy"].Value.ToString();
  264. string age = dgv_4001.Rows[iCenter].Cells["Age"].Value.ToString();
  265. string balc = dgv_4001.Rows[iCenter].Cells["Balc"].Value.ToString();
  266. string insutype = dgv_4001.Rows[iCenter].Cells["Insutype"].Value.ToString();
  267. string psn_type = dgv_4001.Rows[iCenter].Cells["PsnType"].Value.ToString();
  268. string psn_insu_stas = dgv_4001.Rows[iCenter].Cells["PsnInsuStas"].Value.ToString();
  269. string psn_insu_date = dgv_4001.Rows[iCenter].Cells["PsnInsuDate"].Value.ToString();
  270. string paus_insu_date = dgv_4001.Rows[iCenter].Cells["PausInsuDate"].Value.ToString();
  271. string cvlserv_flag = dgv_4001.Rows[iCenter].Cells["Cvlservflag"].Value.ToString();
  272. string insuplc_admdvs = dgv_4001.Rows[iCenter].Cells["insuplcAdmdvs"].Value.ToString();
  273. string emp_name = dgv_4001.Rows[iCenter].Cells["EmpName"].Value.ToString();
  274. JObject joInput = new JObject();
  275. JObject joData = new JObject();
  276. joData.Add("psn_no", psn_no);
  277. joData.Add("psn_cert_type", psn_cert_type);
  278. joData.Add("certno", certno);
  279. joData.Add("psn_name", psn_name);
  280. joData.Add("gend", gend);
  281. joData.Add("naty", naty);
  282. joData.Add("brdy", brdy);
  283. joData.Add("age", age);
  284. joData.Add("balc", balc);
  285. joData.Add("insutype", insutype);
  286. joData.Add("psn_type", psn_type);
  287. joData.Add("psn_insu_stas", psn_insu_stas);
  288. joData.Add("psn_insu_date", psn_insu_date);
  289. joData.Add("paus_insu_date", paus_insu_date);
  290. joData.Add("cvlserv_flag", cvlserv_flag);
  291. joData.Add("insuplc_admdvs", insuplc_admdvs);
  292. joData.Add("emp_name", emp_name);
  293. joInput.Add("data", joData);
  294. JObject joRtn = invoker.invokeCenterServiceF("4001", JsonHelper.setCenterInparF("4001", joInput));
  295. if (JsonHelper.parseCenterRtnValue(joRtn, out errorMsg) != 0)
  296. {
  297. MessageBox.Show("患者信息上传失败:" + errorMsg);
  298. return;
  299. }
  300. MessageBox.Show("患者信息上传成功");
  301. }
  302. private void uiButton7_Click(object sender, EventArgs e)
  303. {
  304. string sqlStr = " SELECT * FROM BS_MedInsuSettlement WHERE Hospital_Dr=" + Global.inf.hospitalDr;
  305. sqlStr = sqlStr + " and OccurTime>'" + dpt_ST.Text + "'";
  306. sqlStr = sqlStr + " and OccurTime<'" + dpt_ET.Text + "'";
  307. sqlStr = sqlStr + " and Interface_Dr=" + Global.inf.interfaceDr + "";
  308. sqlStr = sqlStr + " and BillType=1 and ValidFlag=1 ";
  309. if ((rbg_Type.SelectedIndex == 0) || (rbg_Type.SelectedIndex == 3))
  310. sqlStr = sqlStr + "and AdmType=1";
  311. else if ((rbg_Type.SelectedIndex == 1) || (rbg_Type.SelectedIndex == 2))
  312. sqlStr = sqlStr + "and AdmType=2";
  313. if (tb_CertNo2.Text != "")
  314. sqlStr = sqlStr + " and CertificateNO= " + tb_CertNo2.Text;
  315. JObject joSqlstr = new JObject();
  316. joSqlstr.Add("sqlStr", sqlStr);
  317. JArray jaParam = new JArray();
  318. jaParam.Add(joSqlstr);
  319. JObject joSettlQuery = new JObject();
  320. joSettlQuery.Add("params", jaParam);
  321. joSettlQuery.Add("code", "09010059");
  322. JObject joRtn = invoker.invokeInsuService(joSettlQuery.ToString(), "查询结算信息");
  323. DataTable dt = (DataTable)joRtn["result"]["data"].ToObject(typeof(DataTable));
  324. dgvSettleData.DataSource = dt;
  325. }
  326. private void dgvSettleData_DoubleClick(object sender, EventArgs e)
  327. {
  328. if (dgvSettleData.CurrentRow == null)
  329. {
  330. MessageBox.Show("请先查询医保结算信息");
  331. return;
  332. }
  333. int iCenter = dgvSettleData.CurrentRow.Index;
  334. string PersonnelNO = dgvSettleData.Rows[iCenter].Cells["PersonnelNO"].Value.ToString(); //MdtrtID
  335. string SettlementID = dgvSettleData.Rows[iCenter].Cells["SettlementID"].Value.ToString();
  336. string MdtrtID = dgvSettleData.Rows[iCenter].Cells["MdtrtID"].Value.ToString();
  337. string sqlStr;
  338. sqlStr = " SELECT a.Adm_Dr,c.Name, b.HISCode, b.MedInsuNO, b.Price,b.Sumamt,b.ChargeItemLevel,c.ChargeItemLevelName,b.SelfPayProp, ";
  339. sqlStr = sqlStr + " b.UpLimitAmount,b.OverLimitAmount,b.InScopeAmount,b.FullOwnPayAmount,b.PreSelfPayAmount,b.LimitUsedFlag ";
  340. sqlStr = sqlStr + " FROM BS_MedInsuSettlement a LEFT JOIN BS_MedInsuFeeUploadRecord b ";
  341. sqlStr = sqlStr + " ON a.Hospital_Dr=b.Hospital_Dr AND a.MdtrtID=b.MdtrtID AND a.PersonnelNO=b.PersonnelNO ";
  342. 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 ";
  343. sqlStr = sqlStr + " WHERE b.MedInsuNO<>'' and a.ValidFlag=1 AND a.BillType=1 "; //AND a.AdmType=2
  344. sqlStr = sqlStr + " AND a.Interface_Dr=" + Global.inf.interfaceDr;
  345. sqlStr = sqlStr + " AND a.Hospital_Dr= " + Global.inf.hospitalDr;
  346. sqlStr = sqlStr + " AND a.OccurTime>'" + dpt_ST.Text + "'";
  347. sqlStr = sqlStr + " AND a.OccurTime<'" + dpt_ET.Text + "'";
  348. sqlStr = sqlStr + " AND a.PersonnelNO='" + PersonnelNO + "'";
  349. sqlStr = sqlStr + " AND a.SettlementID='" + SettlementID + "'";
  350. sqlStr = sqlStr + " AND a.MdtrtID='" + MdtrtID + "'";
  351. if (tb_CertNo2.Text != "")
  352. sqlStr = sqlStr + " And a.CertificateNO='" + tb_CertNo2.Text + "' ";
  353. JObject joSqlstr = new JObject();
  354. joSqlstr.Add("sqlStr", sqlStr);
  355. JArray jaParam = new JArray();
  356. jaParam.Add(joSqlstr);
  357. JObject joSettlQuery = new JObject();
  358. joSettlQuery.Add("params", jaParam);
  359. joSettlQuery.Add("code", "09010118");
  360. JObject joRtn = invoker.invokeInsuService(joSettlQuery.ToString(), "查询医保结算费用信息");
  361. DataTable dt = (DataTable)joRtn["result"]["data"].ToObject(typeof(DataTable));
  362. dgvFeeInfo.DataSource = dt;
  363. }
  364. /// <summary>
  365. /// 上传费用明细
  366. /// </summary>
  367. /// <param name="sender"></param>
  368. /// <param name="e"></param>
  369. private void uiButton5_Click(object sender, EventArgs e)
  370. {
  371. string outParam = "成功", funNO = "";
  372. if (rbg_Type.SelectedIndex == 0)
  373. funNO = "4303";
  374. else if (rbg_Type.SelectedIndex == 1)
  375. funNO = "4403";
  376. else if (rbg_Type.SelectedIndex == 2)
  377. funNO = "4801";
  378. else if (rbg_Type.SelectedIndex == 3)
  379. funNO = "4802";
  380. if (dgvSettleData.CurrentRow == null)
  381. {
  382. MessageBox.Show("请先查询患者结算信息");
  383. return;
  384. }
  385. int iCenter = dgvSettleData.CurrentRow.Index;
  386. Global.pat.mdtrtID = dgvSettleData.Rows[iCenter].Cells["MdtrtID"].Value.ToString();
  387. Global.pat.medType = dgvSettleData.Rows[iCenter].Cells["MedicalType"].Value.ToString();
  388. Global.pat.psn_no = dgvSettleData.Rows[iCenter].Cells["PersonnelNO"].Value.ToString();
  389. Global.pat.adm_Dr = int.Parse(dgvSettleData.Rows[iCenter].Cells["AdmID"].Value.ToString());
  390. Global.pat.billID = dgvSettleData.Rows[iCenter].Cells["BillID"].Value.ToString();
  391. Global.pat.recordID = dgvSettleData.Rows[iCenter].Cells["RecordID"].Value.ToString();
  392. //获取IS费用
  393. if (hIS.getHisFee(Global.pat, out outParam) != 0)
  394. {
  395. MessageBox.Show("获取HIS费用信息失败:" + outParam);
  396. return;
  397. }
  398. //调用医保平台转换HIS费用(转换医保编码等)
  399. JObject joHisFee = JObject.Parse(outParam);
  400. if (mIS.convertHisFeeWithInsuCode(joHisFee, out outParam) != 0)
  401. {
  402. MessageBox.Show("调用医保平台转换HIS费用(转换医保编码等)失败:" + outParam);
  403. return;
  404. }
  405. JArray jaFeeDetail = JArray.Parse(JsonHelper.getDestValue(JObject.Parse(outParam), "data"));
  406. //按指定条数分割后上传
  407. if (uploadFeeToCenter(funNO, 300, jaFeeDetail, out outParam) != 0)
  408. {
  409. MessageBox.Show("按指定条数分割后上传失败:" + outParam);
  410. return;
  411. }
  412. else
  413. {
  414. MessageBox.Show("上传成功!" + outParam);
  415. return;
  416. }
  417. }
  418. public int uploadFeeToCenter(string funNO, int singleCount, JArray jaFeeDetail, out string outParam)
  419. {
  420. outParam = "";
  421. string errMsg, type = "feedetail";
  422. try
  423. {
  424. if (rbg_Type.SelectedIndex == 0)
  425. type = "outfeedetail";
  426. else if (rbg_Type.SelectedIndex == 1)
  427. type = "feedetail";
  428. else if (rbg_Type.SelectedIndex == 2)
  429. type = "feedetail";
  430. else if (rbg_Type.SelectedIndex == 3)
  431. type = "outfeedetail";
  432. JArray jaTmp = new JArray();
  433. for (int i = 0; i < jaFeeDetail.Count; i++)
  434. {
  435. jaFeeDetail[i]["chrg_bchno"] = Global.pat.adm_Dr.ToString();
  436. jaFeeDetail[i]["med_type"] = Global.pat.medType;
  437. if (jaFeeDetail[i]["validFlag"].ToString() == "N") continue;
  438. jaTmp.Add(jaFeeDetail[i]);
  439. if (((i + 1) % singleCount == 0) || ((i + 1) == jaFeeDetail.Count))
  440. {
  441. JObject joFeeDetail = new JObject();
  442. joFeeDetail.Add(type, jaTmp);
  443. JObject joRtn = invoker.invokeCenterServiceF(funNO, JsonHelper.setCenterInparF(funNO, joFeeDetail));
  444. //if (JsonHelper.parseCenterRtnValue(joRtn, out errMsg) != 0)
  445. //{
  446. // outParam = errMsg;
  447. // return -1;
  448. //}
  449. jaTmp = new JArray();
  450. }
  451. }
  452. return 0;
  453. }
  454. catch (Exception ex)
  455. {
  456. outParam = "uploadFee 异常:" + ex.Message;
  457. return -1;
  458. }
  459. }
  460. private void uiButton16_Click(object sender, EventArgs e)
  461. {
  462. string errorMsg;
  463. if (dgv_HISRegInfo.DataSource == null)
  464. return;
  465. if (dgv_HISRegInfo.Rows[dgv_HISRegInfo.CurrentRow.Index].Cells["ID"].Value.ToString() == "")
  466. return;
  467. presNo = dgv_HISRegInfo.Rows[dgv_HISRegInfo.CurrentRow.Index].Cells["prescNo"].Value.ToString();
  468. try
  469. {
  470. JObject joTmp = new JObject();
  471. joTmp.Add("startDate", dtp_st.Text);
  472. joTmp.Add("endDate", dtp_et.Text);
  473. joTmp.Add("hospCode", JsonHelper.getDestValue((JObject)Global.curEvt.jaSession[0], "hospCode"));
  474. joTmp.Add("prescNo", presNo); //处方号
  475. JObject joRtn = invoker.invokeHISService(JsonHelper.setIrisInpar("05110038", joTmp).ToString(), "获取门诊处方风险提示参数");
  476. if (JsonHelper.parseIrisRtnValue(joRtn, out errorMsg) != 0)
  477. {
  478. MessageBox.Show("获取门诊处方风险提示参数失败,请联系管理员!" + errorMsg);
  479. return;
  480. }
  481. else
  482. {
  483. if ((joRtn["result"].ToString() == "[]") || (joRtn["result"].ToString() == ""))
  484. {
  485. MessageBox.Show("调用HIS接口服务05110038获取门诊处方风险提示参数结果为空!");
  486. return;
  487. }
  488. //调用接口上传至中心
  489. JObject joInput = new JObject();
  490. joInput = JObject.Parse(joRtn["result"][0].ToString());
  491. //joInput["treatmentRecord"]["patientinfo"]["psn_no"] = Global.pat.mdtrtID;
  492. joInput["treatmentRecord"]["patientinfo"]["brdy"] = joInput["treatmentRecord"]["patientinfo"]["brdy"] + " 00:00:00";
  493. JObject joRtn10001 = invoker.invokeCenterServiceF("10001", JsonHelper.setCenterInparF("10001", joInput));
  494. if (JsonHelper.parseCenterRtnValue(joRtn10001, out errorMsg) != 0)
  495. {
  496. MessageBox.Show("门诊处方风险提示失败:" + errorMsg);
  497. return;
  498. }
  499. MessageBox.Show("门诊处方风险提示成功");
  500. }
  501. }
  502. catch (Exception ex)
  503. {
  504. MessageBox.Show("异常:" + ex.Message);
  505. return;
  506. }
  507. }
  508. /// <summary>
  509. /// 新华网人员类别与医保人员类别对照关系
  510. /// </summary>
  511. /// <param name="param"></param>
  512. /// <returns></returns>
  513. public string GetPsnType(string param)
  514. {
  515. if ((param == "11") || (param == "11021") || (param == "11031") ||
  516. (param == "1101") || (param == "1102") || (param == "1103") ||
  517. (param == "1111") || (param == "1113") || (param == "116006") ||
  518. (param == "116011") || (param == "116012") || (param == "116013") ||
  519. (param == "116014") || (param == "116015") || (param == "116017") ||
  520. (param == "136046") || (param == "136048") || (param == "136050") ||
  521. (param == "116018") || (param == "116019") || (param == "116020") ||
  522. (param == "116021") || (param == "136042") || (param == "136044") ||
  523. (param == "5005") || (param == "5007") || (param == "5010") ||
  524. (param == "5011") || (param == "5015") || (param == "5019") ||
  525. (param == "5022") || (param == "5028") || (param == "5029") ||
  526. (param == "5032") || (param == "5035") || (param == "5038") ||
  527. (param == "5041") || (param == "5044") || (param == "5048") ||
  528. (param == "5050") || (param == "1117") || (param == "1118") ||
  529. (param == "116041") || (param == "116042") || (param == "116043") ||
  530. (param == "116044") || (param == "116045") || (param == "116046") ||
  531. (param == "11032") || (param == "11033") || (param == "11034") ||
  532. (param == "116047") || (param == "116048") || (param == "116022") ||
  533. (param == "116031") || (param == "116032") || (param == "116033") ||
  534. (param == "5053") || (param == "5054") || (param == "5055") ||
  535. (param == "5059") || (param == "116090") || (param == "116050") ||
  536. (param == "116051") || (param == "995330"))
  537. return "1025100"; //在职
  538. else if ((param == "1105") || (param == "3601") || (param == "3602"))
  539. return "1025200"; //农民工
  540. else if ((param == "12") || (param == "1112") || (param == "1201") ||
  541. (param == "1202") || (param == "1114") || (param == "1203") ||
  542. (param == "12031") || (param == "136047") || (param == "1205") ||
  543. (param == "995311") || (param == "136049") || (param == "126001") ||
  544. (param == "136051") || (param == "126002") || (param == "136052") ||
  545. (param == "126003") || (param == "126004") || (param == "126009") ||
  546. (param == "995319") || (param == "126010") || (param == "995307") ||
  547. (param == "126013") || (param == "126015") || (param == "126016") ||
  548. (param == "126017") || (param == "126018") || (param == "126019") ||
  549. (param == "126022") || (param == "136055") || (param == "126023") ||
  550. (param == "126024") || (param == "126025") || (param == "126026") ||
  551. (param == "126027") || (param == "136035") || (param == "136039") ||
  552. (param == "136040") || (param == "136041") || (param == "136043") ||
  553. (param == "136045") || (param == "126031") || (param == "126032") ||
  554. (param == "126033") || (param == "5006") || (param == "5008") ||
  555. (param == "5012") || (param == "5013") || (param == "5016") ||
  556. (param == "5017") || (param == "5020") || (param == "5023") ||
  557. (param == "5030") || (param == "5033") || (param == "5036") ||
  558. (param == "5039") || (param == "5042") || (param == "5045") ||
  559. (param == "5049") || (param == "5051") || (param == "120701") ||
  560. (param == "120703") || (param == "120707") || (param == "120708") ||
  561. (param == "120711") || (param == "120712") || (param == "120715") ||
  562. (param == "120716") || (param == "120719") || (param == "120720") ||
  563. (param == "120723") || (param == "120724") || (param == "120727") ||
  564. (param == "120728") || (param == "120731") || (param == "120733") ||
  565. (param == "120735") || (param == "120737") || (param == "126041") ||
  566. (param == "126042") || (param == "126043") || (param == "126044") ||
  567. (param == "126045") || (param == "126046") || (param == "12032") ||
  568. (param == "12033") || (param == "12034") || (param == "12035") ||
  569. (param == "126047") || (param == "126048") || (param == "116088") ||
  570. (param == "126064") || (param == "126065") || (param == "126117") ||
  571. (param == "126216") || (param == "126037") || (param == "126067") ||
  572. (param == "126066") || (param == "126034") || (param == "5056") ||
  573. (param == "5057") || (param == "5058") || (param == "126316") ||
  574. (param == "126317") || (param == "5060") || (param == "126090") ||
  575. (param == "995331"))
  576. return "1025300"; //退休人员
  577. else
  578. if ((param == "13") || (param == "1300") || (param == "1300") ||
  579. (param == "995309") || (param == "136053") || (param == "136001") ||
  580. (param == "136002") || (param == "136004") || (param == "136005") ||
  581. (param == "136006") || (param == "136007") || (param == "136008") ||
  582. (param == "136009") || (param == "136010") || (param == "136011") ||
  583. (param == "136012") || (param == "136014") || (param == "136015") ||
  584. (param == "136016") || (param == "136017") || (param == "136018") ||
  585. (param == "136019") || (param == "136020") || (param == "136021") ||
  586. (param == "136022") || (param == "136023") || (param == "136024") ||
  587. (param == "136090") || (param == "13031") || (param == "136026") ||
  588. (param == "136029") || (param == "136030") || (param == "136031") ||
  589. (param == "5001") || (param == "5002") || (param == "5003") ||
  590. (param == "5004") || (param == "5009") || (param == "5018") ||
  591. (param == "5021") || (param == "5024") || (param == "5031") ||
  592. (param == "5034") || (param == "5037") || (param == "5040") ||
  593. (param == "5043") || (param == "5046") || (param == "5047") ||
  594. (param == "5052") || (param == "137001") || (param == "137002") ||
  595. (param == "137003") || (param == "136054") || (param == "130102") ||
  596. (param == "5088"))
  597. return "1025400"; //离休
  598. else
  599. if ((param == "14") || (param == "1405") || (param == "156006") || (param == "156007"))
  600. return "1025500"; //居民(未成年)
  601. else
  602. if ((param == "1401") || (param == "140101"))
  603. return "1025600"; //新生儿
  604. else
  605. if ((param == "1402"))
  606. return "1025700"; //学龄前儿童
  607. else
  608. if (param == "1403")
  609. return "1025800"; //中小学生
  610. else
  611. if ((param == "1404") || (param == "140890") || (param == "140891") ||
  612. (param == "156008") || (param == "140401") || (param == "140402") ||
  613. (param == "140403"))
  614. return "1025900"; //大学生
  615. else
  616. if ((param == "995301") || (param == "1405"))
  617. return "1025110"; //未成年(未入学)
  618. else
  619. if (param == "15")
  620. return "1025111"; //居民(成年)
  621. else
  622. if (param == "1501")
  623. return "1025112"; //普通居民(成年)
  624. else
  625. if ((param == "16") || (param == "160104") || (param == "140805") ||
  626. (param == "160100") || (param == "160101") || (param == "160102") ||
  627. (param == "160103"))
  628. return "1025113"; //居民(老年)
  629. else
  630. return "1025111"; //居民(成年)
  631. }
  632. /// <summary>
  633. /// 根据HIS就诊ID查询患者参保信息
  634. /// </summary>
  635. /// <param name="admID"></param>
  636. /// <param name="errorMsg"></param>
  637. /// <returns></returns>
  638. public int GetInsuPersonInfo(string admID, out JObject joRtn, out string errorMsg)
  639. {
  640. joRtn = null;
  641. string sqlstr = " SELECT TOP 1 * FROM BS_MIPatCurrentInsuInfo WHERE AdmID='" + admID + "'";
  642. sqlstr = sqlstr + " and Interface_Dr='" + Global.inf.interfaceDr + "' ORDER BY ID DESC";
  643. JObject joSqlstr = new JObject();
  644. joSqlstr.Add("sqlStr", sqlstr);
  645. JArray jaParam = new JArray();
  646. jaParam.Add(joSqlstr);
  647. JObject joQuery = new JObject();
  648. joQuery.Add("params", jaParam);
  649. joQuery.Add("code", "09010082");
  650. JObject joQueryRtn = invoker.invokeInsuService(joQuery.ToString(), "查询人员参保信息");
  651. if (JsonHelper.parseIrisRtnValue(joQueryRtn, out errorMsg) != 0)
  652. {
  653. MessageBox.Show("查询人员参保信息失败,请联系管理员!" + errorMsg);
  654. return -1;
  655. }
  656. joRtn = joQueryRtn;
  657. return 0;
  658. }
  659. public string GetInsuFeeInfo(string admID, string InsuCode)
  660. {
  661. string sqlStr;
  662. sqlStr = " SELECT admID as Adm_Dr,'' as Name,''as HISCode,MedInsuNO,Price,Sumamt, ";
  663. sqlStr = sqlStr + " ChargeItemLevel,SelfPayProp,UpLimitAmount,OverLimitAmount,InScopeAmount,";
  664. sqlStr = sqlStr + " FullOwnPayAmount,PreSelfPayAmount,LimitUsedFlag From BS_MedInsuFeeUploadRecord ";
  665. sqlStr = sqlStr + " WHERE Hospital_Dr= " + Global.inf.hospitalDr;
  666. sqlStr = sqlStr + " AND admID='" + admID + "'";
  667. sqlStr = sqlStr + " AND MedInsuNO='" + InsuCode + "'";
  668. JObject joSqlstr = new JObject();
  669. joSqlstr.Add("sqlStr", sqlStr);
  670. JArray jaParam = new JArray();
  671. jaParam.Add(joSqlstr);
  672. JObject joSettlQuery = new JObject();
  673. joSettlQuery.Add("params", jaParam);
  674. joSettlQuery.Add("code", "09010118");
  675. JObject joRtn = invoker.invokeInsuService(joSettlQuery.ToString(), "查询医保结算费用信息");
  676. decimal SelfPayProp = decimal.Parse(JsonHelper.getDestValue(joRtn, "result.data[0].SelfPayProp"));
  677. //1007100-医保个人,1007200-医保统筹,1007300-现金
  678. if (SelfPayProp == 0)
  679. return "1007200";
  680. else
  681. return "1007300";
  682. }
  683. private void uiButton13_Click(object sender, EventArgs e)
  684. {
  685. string errorMsg;
  686. string participateType = "1024200", personnelType;
  687. if ((dgv_BillInfo.DataSource == null) || (dgv_BillInfo.Rows[dgv_BillInfo.CurrentRow.Index].Cells["billCode"].Value.ToString() == ""))
  688. {
  689. MessageBox.Show("请先查询单据信息!");
  690. return;
  691. }
  692. if ((dgv_BillDetailInfo.DataSource == null) || (dgv_BillDetailInfo.Rows[dgv_BillDetailInfo.CurrentRow.Index].Cells["billID"].Value.ToString() == ""))
  693. {
  694. MessageBox.Show("请先查询明细信息!");
  695. return;
  696. }
  697. try
  698. {
  699. string entId = dgv_BillInfo.Rows[dgv_BillInfo.CurrentRow.Index].Cells["entId"].Value.ToString();
  700. string billCode = dgv_BillInfo.Rows[dgv_BillInfo.CurrentRow.Index].Cells["billCode"].Value.ToString();
  701. string billTime = dgv_BillInfo.Rows[dgv_BillInfo.CurrentRow.Index].Cells["billTime"].Value.ToString();
  702. string InsuredType = dgv_BillInfo.Rows[dgv_BillInfo.CurrentRow.Index].Cells["participateType"].Value.ToString(); //险种类型
  703. string admID = dgv_BillInfo.Rows[dgv_BillInfo.CurrentRow.Index].Cells["admID"].Value.ToString();
  704. if (InsuredType.Substring(0, 2) == "31")
  705. {
  706. participateType = "1024100"; //职工
  707. }
  708. else if (InsuredType.Substring(0, 2) == "39")
  709. {
  710. participateType = "1024200"; //居民
  711. }
  712. //人员类别
  713. if (GetInsuPersonInfo(admID, out JObject joQueryRtn, out errorMsg) != 0)
  714. {
  715. MessageBox.Show("查询参保人员信息失败!" + errorMsg);
  716. return;
  717. }
  718. personnelType = GetPsnType(JsonHelper.getDestValue(joQueryRtn, "result.rows[0].psnType").ToString());
  719. JObject joData = JObject.Parse(JsonHelper.getDestValue(joInput20002, "result[0]").ToString());
  720. joData["participateType"] = participateType;
  721. joData["personnelType"] = personnelType;
  722. JArray jaFeeDetail = JArray.Parse(JsonHelper.getDestValue(joInput20002, "result[0].detail"));
  723. //for (int i = 0; i < jaFeeDetail.Count; i++)
  724. //{
  725. // string InsuCode = jaFeeDetail[i]["medicalDrugId"].ToString();
  726. // if (InsuCode != "未对照")
  727. // {
  728. // string toPay = GetInsuFeeInfo(admID, InsuCode);
  729. // }
  730. //}
  731. JObject joInput = new JObject();
  732. joInput.Add("data", joData);
  733. JObject joRtn = invoker.invokeCenterServiceF("20002", JsonHelper.setCenterInparF("20002", joInput));
  734. if (JsonHelper.parseCenterRtnValue(joRtn, out errorMsg) != 0)
  735. {
  736. MessageBox.Show("事后单据鉴核信息提报失败,中心返回:" + errorMsg);
  737. return;
  738. }
  739. MessageBox.Show("事后单据鉴核信息提报成功!" + errorMsg);
  740. }
  741. catch (Exception ex)
  742. {
  743. MessageBox.Show("事后单据鉴核信息提报异常:" + ex.Message);
  744. return;
  745. }
  746. }
  747. private void dgv_BillInfo_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  748. {
  749. string outParam = "";
  750. DataTable dt = null;
  751. string errMsg;
  752. if (dgv_BillInfo.DataSource == null)
  753. return;
  754. if (dgv_BillInfo.Rows[dgv_BillInfo.CurrentRow.Index].Cells["billCode"].Value.ToString() == "")
  755. return;
  756. string billID = dgv_BillInfo.Rows[dgv_BillInfo.CurrentRow.Index].Cells["billCode"].Value.ToString();
  757. try
  758. {
  759. JObject joTmp = new JObject();
  760. joTmp.Add("startDate", date_st.Text.Substring(0, 10));
  761. joTmp.Add("endDate", date_et.Text.Substring(0, 10));
  762. joTmp.Add("hospCode", JsonHelper.getDestValue((JObject)Global.curEvt.jaSession[0], "hospCode"));
  763. joTmp.Add("billID", billID);
  764. JObject joRtn = invoker.invokeHISService(JsonHelper.setIrisInpar("05110039", joTmp).ToString(), "组织事后单据鉴核信息填报参数");
  765. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  766. {
  767. MessageBox.Show("组织事后单据鉴核信息填报参数失败,请联系管理员!" + errMsg);
  768. return;
  769. }
  770. else
  771. {
  772. joInput20002 = joRtn;
  773. JObject detail = new JObject();
  774. string result = JsonHelper.getDestValue(joRtn, "result[0]").ToString();
  775. detail = JObject.Parse(result);
  776. dt = (DataTable)detail["detail"].ToObject(typeof(DataTable));
  777. dgv_BillDetailInfo.DataSource = dt;
  778. }
  779. }
  780. catch (Exception ex)
  781. {
  782. MessageBox.Show("组织事后单据鉴核信息填报参数异常:" + ex.Message);
  783. return;
  784. }
  785. }
  786. public int queryHISDirectory(out string errMsg)
  787. {
  788. errMsg = "";
  789. string pageSize = "500";
  790. string flag = "Maped";
  791. JObject joHISRtn = new JObject();
  792. JObject joRtn = new JObject();
  793. JArray jaPagination = new JArray();
  794. JArray jaParams = new JArray();
  795. dynamic joParam = new JObject();
  796. joParam.alias = "";
  797. joParam.HospitalDr = Global.inf.hospitalDr;
  798. joParam.InterfaceDr = Global.inf.interfaceDr;
  799. joParam.hisType = "drugs";
  800. jaParams.Add(joParam);
  801. dynamic joPagination = new JObject();
  802. joPagination.pageSize = pageSize;
  803. joPagination.currentPage = "1";
  804. joPagination.sortColumn = "HisCode";
  805. joPagination.sortOrder = "asc";
  806. jaPagination.Add(joPagination);
  807. JObject joMIRtn = mIS.GetMappedHISDir(jaPagination, jaParams);
  808. if (JsonHelper.parseIrisRtnValue(joMIRtn, out errMsg) != 0)
  809. {
  810. return -1;
  811. }
  812. //传给HIS,进行匹配
  813. joParam = new JObject();
  814. joParam.TotalCount = joMIRtn["result"]["TotalCount"];
  815. joParam.type = "drugs";
  816. joParam.flag = flag;
  817. joParam.hospID = Global.inf.hisHospitalDr;
  818. joParam.interfaceDr = Global.inf.interfaceDr;
  819. joParam.alias = "";
  820. joParam.include = "Hosp";
  821. joParam.groupID = "324";
  822. joParam.specInput = "";//增加规格过滤
  823. joParam.compareArr = joMIRtn["result"]["Data"];
  824. jaParams = new JArray();
  825. jaParams.Add(joParam);
  826. if (hIS.getHISDir(jaPagination, jaParams, out joRtn, out errMsg) != 0)
  827. {
  828. return -1;
  829. }
  830. DataTable dt = (DataTable)joRtn["result"]["Data"].ToObject(typeof(DataTable));
  831. dtExport = dt;
  832. int totalCount = int.Parse(joRtn["result"]["TotalCount"].ToString());
  833. //pgHISDirect.TotalCount = totalCount;
  834. //pgHISDirect.PageSize = pageSize;
  835. dgvMedInsuMapRelation.DataSource = null;
  836. dgvMedInsuMapRelation.DataSource = dt;
  837. dgvMedInsuMapRelation.Columns[0].ReadOnly = true;
  838. GridViewSetter gridSetter = new GridViewSetter();
  839. gridSetter.SetHeaderTextOfMapping_HisDirectory(dgvMedInsuMapRelation);
  840. gridSetter.DatagridviewColumnWidthAdaptation(dgvMedInsuMapRelation);
  841. return 0;
  842. }
  843. private void uiButton9_Click(object sender, EventArgs e)
  844. {
  845. if (queryHISDirectory(out string errMsg) != 0)
  846. {
  847. MessageBox.Show(errMsg);
  848. return;
  849. }
  850. }
  851. private void uiButton10_Click(object sender, EventArgs e)
  852. {
  853. string errorMsg;
  854. if (dgvMedInsuMapRelation.CurrentRow == null)
  855. {
  856. MessageBox.Show("请先查询医保药品对照信息");
  857. return;
  858. }
  859. int iCenter = dgvMedInsuMapRelation.CurrentRow.Index;
  860. string insuCode = dgvMedInsuMapRelation.Rows[iCenter].Cells["insuCode"].Value.ToString(); //中心编码
  861. string insuName = dgvMedInsuMapRelation.Rows[iCenter].Cells["insuName"].Value.ToString(); //中心编码
  862. string itemCode = dgvMedInsuMapRelation.Rows[iCenter].Cells["itemCode"].Value.ToString(); //医院编码
  863. string itemDesc = dgvMedInsuMapRelation.Rows[iCenter].Cells["itemDesc"].Value.ToString(); //医院名称
  864. SaleBillInfo sbi = new SaleBillInfo(insuCode, insuName);
  865. try
  866. {
  867. if (sbi.ShowDialog() == DialogResult.OK)
  868. {
  869. JObject joInput = new JObject();
  870. JObject joData = new JObject();
  871. joData.Add("entId", sbi.entId);
  872. joData.Add("code", sbi.code);
  873. joData.Add("medicalDrugId", sbi.medicalDrugId);
  874. joData.Add("queryTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  875. joData.Add("salePkg", sbi.salePkg);
  876. joData.Add("unpackCount", sbi.unpackCount);
  877. joData.Add("drugSalePrice", sbi.drugSalePrice);
  878. joData.Add("batchNo", sbi.batchNo);
  879. joInput.Add("data", joData);
  880. JObject joRtn = invoker.invokeCenterServiceF("20001", JsonHelper.setCenterInparFT("20001", joInput));
  881. if (JsonHelper.parseCenterRtnValue(joRtn, out errorMsg) != 0)
  882. {
  883. MessageBox.Show("医保药品鉴核数据采集事前鉴核服务上传失败:" + errorMsg);
  884. return;
  885. }
  886. else
  887. {
  888. DataTable dtData = (DataTable)joRtn["output"]["data"].ToObject(typeof(DataTable));
  889. DataTable dtVerifyResult = (DataTable)joRtn["output"]["verifyResult"].ToObject(typeof(DataTable));
  890. DataTable dtTraceCodeVo = (DataTable)joRtn["output"]["traceCodeVo"].ToObject(typeof(DataTable));
  891. DataTable dtMedDrugInfo = (DataTable)joRtn["output"]["medDrugInfo"].ToObject(typeof(DataTable));
  892. dgvData.DataSource = dtData;
  893. dgvVerifyResult.DataSource = dtVerifyResult;
  894. dgvTraceCodeVo.DataSource = dtTraceCodeVo;
  895. dgvMedDrugInfo.DataSource = dtMedDrugInfo;
  896. MessageBox.Show("医保药品鉴核数据采集事前鉴核服务上传成功");
  897. }
  898. }
  899. else
  900. {
  901. MessageBox.Show("操作员已取消!");
  902. return;
  903. }
  904. }
  905. catch (Exception ex)
  906. {
  907. MessageBox.Show("异常:" + ex.Message);
  908. return;
  909. }
  910. }
  911. private void uiButton11_Click(object sender, EventArgs e)
  912. {
  913. string errorMsg;
  914. JObject joInput = new JObject();
  915. JObject joData = new JObject();
  916. joData.Add("ent_id", tbJGBM.Text);
  917. joData.Add("bill_code", tbDJBH.Text);
  918. joData.Add("bill_time", dtTHSJ.Text);
  919. joInput.Add("data", joData);
  920. JObject joRtn = invoker.invokeCenterServiceF("20003", JsonHelper.setCenterInparF("20003", joInput));
  921. if (JsonHelper.parseCenterRtnValue(joRtn, out errorMsg) != 0)
  922. {
  923. MessageBox.Show("医保销售单据退货上传失败:" + errorMsg);
  924. return;
  925. }
  926. else
  927. {
  928. MessageBox.Show("医保销售单据退货上传成功!" + errorMsg);
  929. }
  930. }
  931. private void uiButton15_Click(object sender, EventArgs e)
  932. {
  933. string errMsg;
  934. dgv_BillInfo.DataSource = null;
  935. dgv_BillDetailInfo.DataSource = null;
  936. try
  937. {
  938. JObject joTmp = new JObject();
  939. joTmp.Add("startDate",date_st.Text.Substring(0,10));
  940. joTmp.Add("endDate", date_et.Text.Substring(0, 10));
  941. joTmp.Add("hospCode", JsonHelper.getDestValue((JObject)Global.curEvt.jaSession[0], "hospCode"));
  942. joTmp.Add("billID", "");
  943. JObject joRtn = invoker.invokeHISService(JsonHelper.setIrisInpar("05110039", joTmp).ToString(), "组织事后单据鉴核信息填报参数");
  944. if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
  945. {
  946. MessageBox.Show("组织事后单据鉴核信息填报参数失败,请联系管理员!" + errMsg);
  947. return;
  948. }
  949. else
  950. {
  951. DataTable dt = (DataTable)joRtn["result"].ToObject(typeof(DataTable));
  952. dgv_BillInfo.DataSource = dt;
  953. }
  954. }
  955. catch (Exception ex)
  956. {
  957. MessageBox.Show("组织事后单据鉴核信息填报参数异常:" + ex.Message);
  958. return;
  959. }
  960. }
  961. /// <summary>
  962. /// 获取HIS就诊信息
  963. /// </summary>
  964. /// <param name="dtST"></param>
  965. /// <param name="dtED"></param>
  966. /// <param name="PatInfo"></param>
  967. /// <param name="errMsg"></param>
  968. /// <param name="DT"></param>
  969. /// <returns></returns>
  970. private int GetHISRegInfo(string dtST, string dtED, string PatInfo, ref string errMsg, ref DataTable DT)
  971. {
  972. dynamic joTmp = new JObject();
  973. joTmp.Add("stDate", dtST);
  974. joTmp.Add("endDate", dtED);
  975. joTmp.Add("patInfo", PatInfo);
  976. JObject joRtnHISRegInfo = hIS.GetHISRegInfo(joTmp);
  977. if (JsonHelper.parseIrisRtnValue(joRtnHISRegInfo, out errMsg) != 0)
  978. {
  979. errMsg = "获取HIS患者就诊信息失败,请联系管理员!" + errMsg;
  980. return -1;
  981. }
  982. else
  983. {
  984. if ((joRtnHISRegInfo["result"]["rows"].ToString() == "[]"))
  985. {
  986. errMsg = "查询HIS就诊信息结果为空!";
  987. return -1;
  988. }
  989. else
  990. {
  991. DT = (DataTable)joRtnHISRegInfo["result"]["rows"].ToObject(typeof(DataTable));
  992. return 0;
  993. }
  994. }
  995. }
  996. private void uiButton18_Click(object sender, EventArgs e)
  997. {
  998. string errMsg;
  999. if (tb_SFZH.Text == "")
  1000. {
  1001. MessageBox.Show("请先输入患者身份证号进行查找患者未结算处方信息!");
  1002. return;
  1003. }
  1004. else
  1005. {
  1006. dgv_HISRegInfo.DataSource = null;
  1007. dgv_PrescriptionInfo.DataSource = null;
  1008. CertNo = tb_SFZH.Text;
  1009. Global.pat.certNO = tb_SFZH.Text;
  1010. }
  1011. #region【查询HIS就诊信息-用身份证号查询患者当日的就诊记录】
  1012. string outParam = "";
  1013. DataTable dt1 = null;
  1014. if (GetHISRegInfo(dtp_st.Text, dtp_et.Text, Global.pat.certNO, ref outParam, ref dt1) != 0)
  1015. {
  1016. MessageBox.Show(outParam);
  1017. return;
  1018. }
  1019. dgv_HISRegInfo.DataSource = dt1;
  1020. #endregion
  1021. #region【根据处方号查询处方明细信息】
  1022. presAdmDoc = dgv_HISRegInfo.Rows[0].Cells["doc"].Value.ToString();
  1023. presAdmLoc = dgv_HISRegInfo.Rows[0].Cells["loc"].Value.ToString();
  1024. presNo = dgv_HISRegInfo.Rows[0].Cells["prescNo"].Value.ToString();
  1025. presAdmID = dgv_HISRegInfo.Rows[0].Cells["admID"].Value.ToString();
  1026. Global.pat.adm_Dr = int.Parse(presAdmID);
  1027. if (presNo == "") return;
  1028. DataTable dt2 = null;
  1029. //获取HIS处方明细信息
  1030. if (GetHISPrescFeeInfo(presNo, ref outParam, ref dt2) != 0)
  1031. {
  1032. MessageBox.Show(outParam);
  1033. return;
  1034. }
  1035. dgv_PrescriptionInfo.DataSource = dt2;
  1036. #endregion
  1037. }
  1038. /// <summary>
  1039. /// 获取HIS费用明细信息
  1040. /// </summary>
  1041. /// <param name="PrescNo"></param>
  1042. /// <param name="errMsg"></param>
  1043. /// <param name="DT"></param>
  1044. /// <returns></returns>
  1045. private int GetHISPrescFeeInfo(string PrescNo, ref string errMsg, ref DataTable DT)
  1046. {
  1047. dynamic joTmp = new JObject();
  1048. joTmp.Add("prescNo", PrescNo);
  1049. JObject joRtnHISPrescFeeInfo = hIS.GetHISPrescFeeInfo(joTmp);
  1050. if (JsonHelper.parseIrisRtnValue(joRtnHISPrescFeeInfo, out errMsg) != 0)
  1051. {
  1052. errMsg = "获取HIS患者处方信息失败,请联系管理员!" + errMsg;
  1053. return -1;
  1054. }
  1055. else
  1056. {
  1057. if ((joRtnHISPrescFeeInfo["result"]["rows"].ToString() == "[]"))
  1058. {
  1059. errMsg = "查询HIS处方信息结果为空!";
  1060. return -1;
  1061. }
  1062. else
  1063. {
  1064. DT = (DataTable)joRtnHISPrescFeeInfo["result"]["rows"].ToObject(typeof(DataTable));
  1065. return 0;
  1066. }
  1067. }
  1068. }
  1069. private void dgv_HISRegInfo_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  1070. {
  1071. if (dgv_HISRegInfo.DataSource == null)
  1072. return;
  1073. if (dgv_HISRegInfo.Rows[dgv_HISRegInfo.CurrentRow.Index].Cells["ID"].Value.ToString() == "")
  1074. return;
  1075. string outParam = "";
  1076. DataTable dt = null;
  1077. presAdmDoc = dgv_HISRegInfo.Rows[dgv_HISRegInfo.CurrentRow.Index].Cells["doc"].Value.ToString();
  1078. presAdmLoc = dgv_HISRegInfo.Rows[dgv_HISRegInfo.CurrentRow.Index].Cells["loc"].Value.ToString();
  1079. presNo = dgv_HISRegInfo.Rows[dgv_HISRegInfo.CurrentRow.Index].Cells["prescNo"].Value.ToString();
  1080. presAdmID = dgv_HISRegInfo.Rows[dgv_HISRegInfo.CurrentRow.Index].Cells["admID"].Value.ToString();
  1081. Global.pat.adm_Dr = int.Parse(presAdmID);
  1082. if (presNo == "") return;
  1083. //获取HIS处方明细信息
  1084. if (GetHISPrescFeeInfo(presNo, ref outParam, ref dt) != 0)
  1085. {
  1086. MessageBox.Show(outParam);
  1087. return;
  1088. }
  1089. dgv_PrescriptionInfo.DataSource = dt;
  1090. }
  1091. }
  1092. }