123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using PTMedicalInsurance.Common;
- using PTMedicalInsurance.Helper;
- using PTMedicalInsurance.FormSetter;
- using PTMedicalInsurance.Business;
- using PTMedicalInsurance.Variables;
- using System.IO;
- using Newtonsoft.Json.Linq;
- namespace PTMedicalInsurance.Forms
- {
- public partial class PrescriptionCirculation : Form
- {
- //设置业务实例
- CenterBusiness cBus = new CenterBusiness();
- HisMainBusiness hBus = new HisMainBusiness();
- HisIrisServices hIS = new HisIrisServices();
- MIIrisServices mIS = new MIIrisServices();
- InvokeHelper invoker = new InvokeHelper();
- InsuServices iris = new InsuServices();
- public string patInfo = "", ReadCardOutParam = "", CertNo = "";
- public string AdmID = "", AdmLoc = "", AdmDoc = "";
- //1.声明自适应类实例
- AutoResizeForm asc = new AutoResizeForm();
- public PrescriptionCirculation()
- {
- InitializeComponent();
- asc.controllInitializeSize(this);
- asc.controlAutoSize(this);
- GridViewSetter grdSetter = new GridViewSetter();
-
- grdSetter.SetHeaderTextOfHISRegister(dgv_HISRegInfo);
- grdSetter.SetHeaderTextOfHISPrescFee(dgv_PrescriptionInfo);
- grdSetter.DatagridviewColumnWidthAdaptation(dgv_HISRegInfo);
- grdSetter.DatagridviewColumnWidthAdaptation(dgv_PrescriptionInfo);
- dtST.Text = DateTime.Now.ToString("yyyy-MM-01 00:00:00");
- dtED.Text = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
- if (CertNo != "")
- {
- string outParam = "";
- DataTable dt = null;
- if (GetHISRegInfo("2023-06-14 00:00:00", "2023-06-14 23:59:59", "45050219890708002X", ref outParam, ref dt) != 0)
- {
- MessageBox.Show(outParam);
- return;
- }
- dgv_HISRegInfo.DataSource = dt;
- }
- }
- public PrescriptionCirculation(string PatInfo)
- {
- InitializeComponent();
- asc.controllInitializeSize(this);
- asc.controlAutoSize(this);
- GridViewSetter grdSetter = new GridViewSetter();
- grdSetter.SetHeaderTextOfHISRegister(dgv_HISRegInfo);
- grdSetter.SetHeaderTextOfHISPrescFee(dgv_PrescriptionInfo);
- grdSetter.DatagridviewColumnWidthAdaptation(dgv_HISRegInfo);
- grdSetter.DatagridviewColumnWidthAdaptation(dgv_PrescriptionInfo);
- dtST.Text = DateTime.Now.ToString("yyyy-MM-01 00:00:00");
- dtED.Text = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
- if (PatInfo != "")
- {
- string outParam = "";
- DataTable dt = null;
- if (GetHISRegInfo(dtST.Text, dtED.Text, PatInfo, ref outParam, ref dt) != 0)
- {
- MessageBox.Show(outParam);
- return;
- }
- dgv_HISRegInfo.DataSource = dt;
- tb_CertNo.Text = PatInfo;
- }
- }
- /// <summary>
- /// 获取HIS就诊信息
- /// </summary>
- /// <param name="dtST"></param>
- /// <param name="dtED"></param>
- /// <param name="PatInfo"></param>
- /// <param name="errMsg"></param>
- /// <param name="DT"></param>
- /// <returns></returns>
- private int GetHISRegInfo(string dtST,string dtED,string PatInfo,ref string errMsg,ref DataTable DT)
- {
- dynamic joTmp = new JObject();
- joTmp.Add("stDate", dtST);
- joTmp.Add("endDate", dtED);
- joTmp.Add("patInfo", PatInfo);
- JObject joRtnHISRegInfo = hIS.GetHISRegInfo(joTmp);
- if (JsonHelper.parseIrisRtnValue(joRtnHISRegInfo, out errMsg) != 0)
- {
- errMsg = "获取HIS患者就诊信息失败,请联系管理员!" + errMsg;
- return -1;
- }
- else
- {
- if ((joRtnHISRegInfo["result"]["rows"].ToString() == "[]"))
- {
- errMsg = "查询HIS就诊信息结果为空!";
- return -1;
- }
- else
- {
- DT = (DataTable)joRtnHISRegInfo["result"]["rows"].ToObject(typeof(DataTable));
- return 0;
- }
- }
- }
- /// <summary>
- /// 获取HIS费用明细信息
- /// </summary>
- /// <param name="PrescNo"></param>
- /// <param name="errMsg"></param>
- /// <param name="DT"></param>
- /// <returns></returns>
- private int GetHISPrescFeeInfo(string PrescNo, ref string errMsg, ref DataTable DT)
- {
- dynamic joTmp = new JObject();
- joTmp.Add("prescNo", PrescNo);
- JObject joRtnHISPrescFeeInfo = hIS.GetHISPrescFeeInfo(joTmp);
- if (JsonHelper.parseIrisRtnValue(joRtnHISPrescFeeInfo, out errMsg) != 0)
- {
- errMsg = "获取HIS患者处方信息失败,请联系管理员!" + errMsg;
- return -1;
- }
- else
- {
- if ((joRtnHISPrescFeeInfo["result"]["rows"].ToString() == "[]"))
- {
- errMsg = "查询HIS处方信息结果为空!";
- return -1;
- }
- else
- {
- DT = (DataTable)joRtnHISPrescFeeInfo["result"]["rows"].ToObject(typeof(DataTable));
- return 0;
- }
- }
- }
- /// <summary>
- /// 获取医保挂号信息-医保平台
- /// </summary>
- /// <returns></returns>
- private int GetInsuRegInfo(ref string errMsg)
- {
- AdmID = dgv_HISRegInfo.Rows[dgv_HISRegInfo.CurrentRow.Index].Cells["admID"].Value.ToString();
- AdmDoc = dgv_HISRegInfo.Rows[dgv_HISRegInfo.CurrentRow.Index].Cells["doc"].Value.ToString();
- AdmLoc = dgv_HISRegInfo.Rows[dgv_HISRegInfo.CurrentRow.Index].Cells["loc"].Value.ToString();
- string sqlStr = " SELECT top 1 * FROM BS_MedInsuRegisterInfo " //DateDiff(dd,OccurTime,getdate())=0
- + " WHERE Type=3 And RegState=1 "
- + " and OccurTime> '" + dtST.Text + "' And OccurTime<'" + dtED.Text + "'"
- + " and Hospital_Dr='" + Global.inf.hospitalDr + "'" //and PersonalNO='" + Global.pat.psn_no + "'
- + " and Adm_Dr='" + AdmID + "'"
- + " And AdmInDepName='" + AdmLoc + "'"
- + " And ChiefPhyDocName='" + AdmDoc + "'"
- + " ORDER BY ID DESC ";
- JObject joSqlstr = new JObject();
- joSqlstr.Add("sqlStr", sqlStr);
- JArray jaParam = new JArray();
- jaParam.Add(joSqlstr);
- JObject joSettlQuery = new JObject();
- joSettlQuery.Add("params", jaParam);
- joSettlQuery.Add("code", "09010062");
- InvokeHelper invoker = new InvokeHelper();
- JObject joRtn = invoker.invokeInsuService(joSettlQuery.ToString(), "查询门诊挂号");
- try
- {
- if (joRtn["result"]["data"].ToString() == "[]")
- {
- errMsg = "医保挂号查询结果为空!";
- return -1;
- }
- else
- {
- DataTable dtInsu = (DataTable)joRtn["result"]["data"].ToObject(typeof(DataTable));
- if (dtInsu.Rows.Count > 1)
- {
- //gb_InsuReg.Visible = true;
- errMsg="注意:该患者存在多条医保挂号记录!";
- Global.pat.mdtrtID = dtInsu.Rows[0]["InsuRegID"].ToString();
- }
- else
- {
- Global.pat.mdtrtID = dtInsu.Rows[0]["InsuRegID"].ToString();
- }
- }
- return 0;
- }
- catch (Exception eX)
- {
- MessageBox.Show(eX.Message);
- return -1;
- }
- }
- private int GetPreVerificationInput(string AdmID,string prescNo,ref string outParam)
- {
- dynamic joTmp = new JObject();
- joTmp.Add("prescNo", prescNo);
- joTmp.Add("admID", AdmID);
- JObject joRtnPreVerificationData = hIS.GetPreVerificationData(joTmp);
- if (JsonHelper.parseIrisRtnValue(joRtnPreVerificationData, out outParam) != 0)
- {
- outParam = "获取处方流传预核验数据失败,请联系管理员!" + outParam;
- return -1;
- }
- else
- {
- if (joRtnPreVerificationData["dllinput"]["params"].ToString() == "[]")
- {
- outParam = "获取处方流传预核验数据结果为空!";
- return -1;
- }
- else
- {
- outParam = joRtnPreVerificationData["dllinput"]["params"].ToString();
- }
- return 0;
- }
- }
- private void btnClose_Click(object sender, EventArgs e)
- {
- Close();
- }
- private void btnPresUpload_Click(object sender, EventArgs e)
- {
- }
- private void dgv_HISRegInfo_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
- {
- string outParam = "";
- DataTable dt = null;
- string prescNo = dgv_HISRegInfo.Rows[dgv_HISRegInfo.CurrentRow.Index].Cells["prescNo"].Value.ToString();
- string admID = dgv_HISRegInfo.Rows[dgv_HISRegInfo.CurrentRow.Index].Cells["admID"].Value.ToString();
- if (prescNo == "") return;
- //获取HIS处方明细信息
- if (GetHISPrescFeeInfo(prescNo, ref outParam, ref dt) != 0)
- {
- MessageBox.Show(outParam);
- return;
- }
- dgv_PrescriptionInfo.DataSource = dt;
- }
- private void btnUpload_Pre_Click(object sender, EventArgs e)
- {
- if ((dgv_HISRegInfo.Rows.Count == 0) || (dgv_PrescriptionInfo.Rows.Count == 0))
- {
- MessageBox.Show("请先查询该患者HIS就诊信息和处方信息!");
- return;
- }
- string OutMsg = "";
- string prescNo = dgv_HISRegInfo.Rows[dgv_HISRegInfo.CurrentRow.Index].Cells["prescNo"].Value.ToString();
- string admID = dgv_HISRegInfo.Rows[dgv_HISRegInfo.CurrentRow.Index].Cells["admID"].Value.ToString();
- //获取医保挂号信息
- if (GetInsuRegInfo(ref OutMsg) == 0)
- {
- MessageBox.Show(Global.pat.mdtrtID);
- }
- JObject joPreInput = new JObject();
- if (GetPreVerificationInput(admID, prescNo, ref OutMsg) != 0)
- {
- MessageBox.Show(OutMsg);
- return;
- }
- return;
- #region【电子处方预核验流程】
- ///【查询当前病人是否已门诊挂号】 比对HIS就诊记录与医保登记记录表信息
- if (Global.pat.mdtrtID == "")
- {
- #region【读卡】
- string errMsg, outParam;
- if (ReadCardOutParam == "")
- {
- //打开读卡窗口,操作员选择读卡类型后进行读卡器读卡,再进行1101获取参保信息
- if (hBus.readCard(out ReadCardOutParam) != 0)
- {
- MessageBox.Show(JsonHelper.setExceptionJson(-100, "读卡失败!", ReadCardOutParam).ToString());
- return;
- }
- else
- {
- //展示患者信息界面
- if (hBus.showPatInfo(ReadCardOutParam, out patInfo) != 0)
- {
- MessageBox.Show("读卡成功,展示患者信息界面失败:" + patInfo);
- return;
- }
- if (hBus.setGlobalPatAfaterShowPatInfo(ReadCardOutParam, out errMsg) != 0)
- {
- MessageBox.Show(JsonHelper.setExceptionJson(-1, "setGlobalPatAfaterShowPatInfo", errMsg).ToString());
- return;
- }
- }
- }
- #endregion
- #region【医保挂号-就诊信息上传】
- patInfo = ReadCardOutParam;
- if (hBus.setGlobalPatAfaterShowPatInfo(patInfo, out errMsg) != 0)
- {
- MessageBox.Show(JsonHelper.setExceptionJson(-1, "setGlobalPatAfaterShowPatInfo", errMsg).ToString());
- return;
- }
- //显示登记面板
- if (hBus.showOutPatRegisterForm(out outParam) != 0)
- {
- MessageBox.Show(JsonHelper.setExceptionJson(-1, "显示登记面板", outParam).ToString());
- return;
- }
- JObject joReg = JObject.Parse(outParam);
- //医保挂号
- JObject jo2201Inpar = JObject.Parse(JsonHelper.getDestProperty(joReg, "data"));
- JObject jo2201Inpar_plain = JObject.Parse(JsonHelper.getDestProperty(joReg, "data"));
- jo2201Inpar = JObject.Parse(JsonHelper.setCenterInpar("2201", jo2201Inpar));
- jo2201Inpar_plain = JObject.Parse(JsonHelper.setCenterInpar_plain("2201", jo2201Inpar_plain));
- //此处先取到就诊信息上传的入参,只要挂号成功就保存到云HIS后台(保存后台需要用到2203入参)
- JObject jo2203AInpar = new JObject();
- JObject jo2203AInpar_plain = new JObject();
- jo2203AInpar.Add("mdtrtinfo", JObject.Parse(JsonHelper.getDestValue(joReg, "mdtrtinfo")));
- jo2203AInpar.Add("diseinfo", JArray.Parse(JsonHelper.getDestValue(joReg, "diseinfo")));
- JObject jo2201Rtn = invoker.invokeCenterService("2201", jo2201Inpar);
- if (JsonHelper.parseCenterRtnValue(jo2201Rtn, out errMsg) != 0)
- {
- MessageBox.Show(JsonHelper.setExceptionJson(-1, "医保挂号", errMsg).ToString());
- return;
- }
- else
- {
- Global.pat.mdtrtID = JsonHelper.getDestValue(jo2201Rtn, "output.data.mdtrt_id");
- //插入患者本次就诊用的参保信息
- if (hBus.insertPatCurInsuInfo(patInfo, out outParam) != 0)
- {
- if (DialogResult.Yes != MessageBox.Show(outParam, " 是否继续? ", MessageBoxButtons.YesNo))
- {
- MessageBox.Show(JsonHelper.setExceptionJson(-1, "插入患者本次就诊用的参保信息,请联系管理员!是否继续?", outParam).ToString());
- return;
- }
- }
- jo2203AInpar["mdtrtinfo"]["mdtrt_id"] = Global.pat.mdtrtID;
- jo2203AInpar_plain = JObject.Parse(JsonHelper.setCenterInpar_plain("2203A", jo2203AInpar));
- jo2203AInpar = JObject.Parse(JsonHelper.setCenterInpar("2203A", jo2203AInpar));
- //门诊登记信息,插入云医保平台
- jo2201Rtn.Add("validflag", 1);
- jo2201Rtn.Add("regstate", 1);
- jo2201Rtn.Add("type", 3);
- Global.writeLog(jo2201Inpar_plain.ToString());
- if (mIS.saveOutpatRegisterInfo(jo2201Inpar_plain, jo2201Rtn, jo2203AInpar_plain, out errMsg) != 0)
- {
- MessageBox.Show(JsonHelper.setExceptionJson(-1, "中心登记成功但医保平台保存失败,请联系管理员!", errMsg).ToString());
- return;
- }
- }
- #endregion
- }
- else
- {
-
- }
- #endregion
- }
- private void btnReadCard_Click(object sender, EventArgs e)
- {
- CertNo = tb_CertNo.Text;
- if (tb_CertNo.Text != "")
- {
- CertNo = tb_CertNo.Text;
- Global.pat.certNO = tb_CertNo.Text;
- }
- #region【读卡】
- string OutParam, errMsg;
- //打开读卡窗口,操作员选择读卡类型后进行读卡器读卡,再进行1101获取参保信息
- if (tb_CertNo.Text == "")
- {
- if (hBus.readCard(out OutParam) != 0)
- {
- MessageBox.Show(JsonHelper.setExceptionJson(-100, "读卡失败!", OutParam).ToString());
- return;
- }
- else
- {
- //展示患者信息界面
- ReadCardOutParam = OutParam;
- if (hBus.showPatInfo(OutParam, out patInfo) != 0)
- {
- MessageBox.Show("读卡成功,展示患者信息界面失败:" + patInfo);
- return;
- }
- }
- }
- #endregion
-
- #region【查询HIS就诊信息-用身份证号查询患者当日的就诊记录】
- tb_CertNo.Text = Global.pat.certNO;
- string outParam = "";
- DataTable dt = null;
- if (GetHISRegInfo(dtST.Text, dtED.Text, Global.pat.certNO, ref outParam,ref dt) != 0)
- {
- MessageBox.Show(outParam);
- return;
- }
- dgv_HISRegInfo.DataSource = dt;
- #endregion
- #region【调用医保平台获取医保登记信息-根据HIS就诊信息查找医保登记信息 (接诊医生、接诊科室)】
- /*
- AdmID = dgv_HISRegInfo.Rows[dgv_HISRegInfo.CurrentRow.Index].Cells["admID"].Value.ToString();
- AdmDoc = dgv_HISRegInfo.Rows[dgv_HISRegInfo.CurrentRow.Index].Cells["doc"].Value.ToString();
- AdmLoc = dgv_HISRegInfo.Rows[dgv_HISRegInfo.CurrentRow.Index].Cells["loc"].Value.ToString();
- gb_InsuReg.Visible = true;
- string sqlStr = " SELECT * FROM BS_MedInsuRegisterInfo " //DateDiff(dd,OccurTime,getdate())=0
- + " WHERE Type=3 And RegState=1 and OccurTime> '" + dtST.Text + "' And OccurTime<'" + dtED.Text+"'"
- + " and PersonalNO='" + Global.pat.psn_no + "' and Hospital_Dr='" + Global.inf.hospitalDr + "'"
- + " and Adm_Dr='" + AdmID + "'"
- + " And AdmInDepName='" + AdmLoc +"'"
- + " And ChiefPhyDocName='"+ AdmDoc+"'";
- JObject joSqlstr = new JObject();
- joSqlstr.Add("sqlStr", sqlStr);
- JArray jaParam = new JArray();
- jaParam.Add(joSqlstr);
- JObject joSettlQuery = new JObject();
- joSettlQuery.Add("params", jaParam);
- joSettlQuery.Add("code", "09010062");
- InvokeHelper invoker = new InvokeHelper();
- JObject joRtn = invoker.invokeInsuService(joSettlQuery.ToString(), "查询门诊挂号");
- try
- {
- if (joRtn["result"]["data"].ToString() == "[]")
- {
- MessageBox.Show("查询结果为空!");
- return;
- }
- else
- {
- DataTable dtInsu = (DataTable)joRtn["result"]["data"].ToObject(typeof(DataTable));
-
- if (dtInsu.Rows.Count > 1)
- {
- //gb_InsuReg.Visible = true;
- dgv_MdtrtInfo.DataSource = dtInsu;
- MessageBox.Show("注意:该患者今日存在多条医保挂号记录,请选择!");
- }
- else
- {
- bReg = true;
- Global.pat.mdtrtID = dtInsu.Rows[0]["InsuRegID"].ToString();
- }
- }
- }
- catch (Exception eX)
- {
- MessageBox.Show(eX.Message);
- }
- */
- #endregion
- }
- }
- }
|