123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377 |
- using Newtonsoft.Json;
- using Newtonsoft.Json.Linq;
- using PTMedicalInsurance.Business;
- using PTMedicalInsurance.Helper;
- using PTMedicalInsurance.Variables;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using PTMedicalInsurance.FormSetter;
- using PTMedicalInsurance.Common;
- using PTMedicalInsurance.Forms.BasicDatas;
- namespace PTMedicalInsurance.Forms
- {
- public partial class BasicData : Form
- {
- //设置实例
- CenterBusiness cBus = new CenterBusiness();
- HisMainBusiness hBus = new HisMainBusiness();
- HisIrisServices hIS = new HisIrisServices();
- MIIrisServices mIS = new MIIrisServices();
- InvokeHelper invoker = new InvokeHelper();
- private bool isStopLoopDownload = false;
- DataTable dtExport;
- public BasicData()
- {
- InitializeComponent();
- this.tcBasicData.TabPages[3].Parent = null;
- rbgDirecType.SelectedIndex = 0;
- rbgDirecType_C.SelectedIndex = 0;
- rbgDirecType.SelectedIndex = 8;
- rbgDownItemType_4.SelectedIndex = 0;
- rbgInsuDirecType_C.SelectedIndex = 0;
- rbSingleDown.Checked = true;
- this.rbgDirecType.ValueChanged += new Sunny.UI.UIRadioButtonGroup.OnValueChanged(this.rbgDirecType_ValueChanged);
- this.pgDownload.PageChanged += new Sunny.UI.UIPagination.OnPageChangeEventHandler(this.pgDownload_PageChanged);
- this.pgCenterDirect.PageChanged += new Sunny.UI.UIPagination.OnPageChangeEventHandler(this.pgCenterDirect_PageChanged);
- this.pgHISDirect.PageChanged += new Sunny.UI.UIPagination.OnPageChangeEventHandler(this.pgHISDirect_PageChanged);
- Font rowFont = new Font("UTF-8", 8);
- Font columnFont = new Font("UTF-8", 9);
- rbAll.Checked = true;
- this.rbAll.ValueChanged += new Sunny.UI.UIRadioButton.OnValueChanged(this.rbAll_ValueChanged);
- GridViewSetter gvs = new GridViewSetter();
- gvs.SetHeaderTextOfInsuDir(dgvInsuDirInfo);
- gvs.SetHeaderTextOfMapping_HisDirectory(dgvHISDirectory);
- }
- #region 函数封装
- private void queryInsuDirectory(int currentPage, int pageSize, int directoryType, int interfaceDr, string code)
- {
- try
- {
- string dirCode = "";
- string dirName = "";
- string verNO = "";
- string approvalNO = "";
- Sunny.UI.UIDataGridView dgv;
- Sunny.UI.UIPagination pg;
- if (tcBasicData.SelectedIndex == 1)
- {
- dirCode = tbDirectoryCode.Text;
- dirName = tbDircetoryName.Text;
- verNO = tbDirectoryVerNO.Text;
- approvalNO = "";
- dgv = dgvDirectoy;
- pg = pgDownload;
- }
- else
- {
- dirName = tbCenterDirectoryFilter.Text;
- dirCode = tbInsuCode.Text;
- dgv = dgvCenterDirectory;
- approvalNO = tbApprovalNO.Text;
- pg = pgCenterDirect;
- }
- JObject joInput = new JObject {
- { "currentPage" , currentPage },
- { "pageSize" , pageSize },
- { "serviceCode" , code },
- { "directoryType" , directoryType },
- { "directoryCode" , dirCode },
- { "directoryName" , dirName },
- { "approvalNO" , approvalNO },
- { "verNO" , verNO },
- { "directoryDr" , interfaceDr }
- };
- JObject joRtn = mIS.getMIDirectoryByPagination(joInput);
- if (joRtn["errorCode"].ToString() != "0")
- {
- MessageBox.Show("IRIS数据返回错误:" + joRtn["errorMessage"].ToString());
- return;
- }
- if (joRtn["result"]["rows"] == null)
- {
- MessageBox.Show("该节点不存在");
- return;
- }
- if (joRtn["result"]["total"].ToString() == "0")
- {
- MessageBox.Show("未查询到数据");
- dgv.DataSource = null;
- return;
- }
- DataTable dt = (DataTable)joRtn["result"]["rows"].ToObject(typeof(DataTable));
- int totalCount = int.Parse(joRtn["result"]["total"].ToString());
- pg.TotalCount = totalCount;
- pg.PageSize = pageSize;
- dgv.DataSource = dt;
- dgv.Columns[0].ReadOnly = true;
- }
- catch (Exception ex)
- {
- MessageBox.Show("查询异常:" + ex.Message);
- }
- }
- private void setHeaderTxt(int directoryType, Sunny.UI.UIDataGridView dgv)
- {
- GridViewSetter gvdSetter = new GridViewSetter();
- switch (directoryType)
- {
- case 0://药品
- {
- gvdSetter.SetHeaderTextOfDrug(dgv);
- break;
- }
- case 1://诊疗
- {
- gvdSetter.SetHeaderTextOfMedicalService(dgv);
- break;
- }
- case 2://材料
- {
- gvdSetter.SetHeaderTextOfMaterials(dgv);
- break;
- }
- case 3://疾病诊断
- {
- gvdSetter.SetHeaderTextOfDiagnose(dgv);
- break;
- }
- case 4://手术
- {
- gvdSetter.SetHeaderTextOfDiagnose(dgv);
- break;
- }
- case 5://慢性病
- {
- gvdSetter.SetHeaderTextOfDiagnose(dgv);
- break;
- }
- case 6://DRGs
- {
- gvdSetter.SetHeaderTextOfDiagnose(dgv);
- break; ;
- }
- case 7://日间手术
- {
- gvdSetter.SetHeaderTextOfDiagnose(dgv);
- break; ;
- }
- case 8://字典表
- {
- gvdSetter.SetHeaderTextOfDictionary(dgv);
- break;
- }
- case 9://中药饮片
- {
- gvdSetter.SetHeaderTextOfDiagnose(dgv);
- break;
- }
- case 10://医疗机构制剂
- {
- gvdSetter.SetHeaderTextOfDiagnose(dgv);
- break;
- }
- case 11://民族药品
- {
- gvdSetter.SetHeaderTextOfDiagnose(dgv);
- break;
- }
- case 12://肿瘤形态学
- {
- gvdSetter.SetHeaderTextOfDiagnose(dgv);
- break;
- }
- case 13://中医疾病目录
- {
- gvdSetter.SetHeaderTextOfDiagnose(dgv);
- break;
- }
- case 14://中医证候目录
- {
- gvdSetter.SetHeaderTextOfDiagnose(dgv);
- break;
- }
- }
- }
- private void queryHISInsuDirectory(int directoryType, int pageIndex, int count, Sunny.UI.UIDataGridView dgv, int interfaceDr)
- {
- string code = "09010042";
- if (tcBasicData.SelectedIndex == 1)
- {
- if (rbgDirecType.SelectedIndex == 8)
- { code = "09010043"; }
- }
- queryInsuDirectory(pageIndex, count, directoryType + 1, interfaceDr, code);
- if (tcBasicData.SelectedIndex == 1)
- {
- setHeaderTxt(directoryType, dgv);
- }
- else
- {
- setHeaderTxt(directoryType, dgv);
- }
-
- }
- private int queryHISDirectory(int currentPage, int pageSize, out string errMsg)
- {
- errMsg = "";
- string directoryType = string.Empty;
- switch (rbgDirecType_C.SelectedIndex)
- {
- case 0:
- {
- directoryType = "drugs";
- break;
- }
- case 1:
- {
- directoryType = "diagnosi";
- break;
- }
- case 2:
- {
- directoryType = "consumables";
- break;
- }
- }
- JObject joHISRtn = new JObject();
- JObject joRtn = new JObject();
- InvokeHelper invoker = new InvokeHelper();
- string flag = "";
- //全部是先调HIS,然后再匹配医保平台的对照关系
- if (rbAll.Checked)
- {
- JArray jaPagination = new JArray();
- JArray jaParams = new JArray();
- flag = "All";
- dynamic joParam = new JObject();
- joParam.code = "";
- joParam.descripts = "";
- joParam.FindType = new JArray();
- joParam.TypeID = "";
- joParam.alias = tbHISDirectoryFilter.Text;
- joParam.include = "Hosp";
- joParam.groupID = "324";
- joParam.hospID = Global.inf.hisHospitalDr;
- joParam.interfaceDr = Global.inf.interfaceDr;
- joParam.type = directoryType;
- joParam.flag = flag;
- joParam.specInput = "";
- jaParams.Add(joParam);
- dynamic joPagination = new JObject();
- joPagination.pageSize = pageSize;
- //joPagination.pageSize = 2;
- joPagination.currentPage = currentPage;
- joPagination.sortColumn = "Code";
- joPagination.sortOrder = "asc";
- jaPagination.Add(joPagination);
- //该服务需要改写,需要跟(CloudMedicalInsurancePlatform.Tables.MapRelation)进行关联
- //joInParams.code = "09010038";
- if (hIS.getHISDir(jaPagination, jaParams, out joHISRtn, out errMsg) != 0)
- {
- return -1;
- }
- joRtn = mIS.ConvertHISDir(joHISRtn);
- if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
- {
- return -1;
- }
- }
- //已对照是先调云医保,然后再匹配HIS
- if (rbMaped.Checked)
- {
- JArray jaPagination = new JArray();
- JArray jaParams = new JArray();
- flag = "Maped";
- dynamic joParam = new JObject();
- joParam.alias = tbHISDirectoryFilter.Text;
- joParam.InsuAlias = tbMappedInfo.Text;
- joParam.HospitalDr = Global.inf.hospitalDr;
- joParam.InterfaceDr = Global.inf.interfaceDr;
- joParam.hisType = directoryType;
- jaParams.Add(joParam);
- dynamic joPagination = new JObject();
- joPagination.pageSize = pageSize;
- joPagination.currentPage = currentPage;
- joPagination.sortColumn = "HisCode";
- joPagination.sortOrder = "asc";
- jaPagination.Add(joPagination);
- JObject joMIRtn = mIS.GetMappedHISDir(jaPagination, jaParams);
- if (JsonHelper.parseIrisRtnValue(joMIRtn, out errMsg) != 0)
- {
- return -1;
- }
- JArray jaMaped = JArray.FromObject(joMIRtn["result"]["Data"]);
- if (jaMaped.Count < 1)
- {
- errMsg = "未查询到对照数据!";
- dgvHISDirectory.DataSource = null;
- return -1;
- }
- //传给HIS,进行匹配
- joParam = new JObject();
- joParam.TotalCount = joMIRtn["result"]["TotalCount"];
- joParam.type = directoryType;
- joParam.flag = flag;
- joParam.hospID = Global.inf.hisHospitalDr;
- joParam.interfaceDr = Global.inf.interfaceDr;
- joParam.alias = tbHISDirectoryFilter.Text;
- joParam.include = "Hosp";
- joParam.groupID = "324";
- joParam.compareArr = joMIRtn["result"]["Data"];
- jaParams = new JArray();
- jaParams.Add(joParam);
- if (hIS.getHISDir(jaPagination, jaParams, out joRtn, out errMsg) != 0)
- {
- return -1;
- }
- else
- {
- JArray jaData = JArray.Parse(JsonHelper.getDestValue(joRtn, "result.Data"));
- for (int i = 0; i < jaData.Count; i++)
- {
- jaData[i]["flag"] = new JObject();
- jaData[i]["flag"] = "已对照";
- }
- joRtn["result"]["Data"] = jaData;
- Global.writeLog(joRtn.ToString());
- }
- }
- //未对照
- if (rbNoMaped.Checked)
- {
- JArray jaPagination = new JArray();
- JArray jaParams = new JArray();
- flag = "All";
- dynamic joParam = new JObject();
- joParam.code = "";
- joParam.descripts = "";
- joParam.FindType = new JArray();
- joParam.TypeID = "";
- joParam.alias = tbHISDirectoryFilter.Text;
- joParam.include = "Hosp";
- joParam.groupID = "324";
- joParam.hospID = Global.inf.hisHospitalDr;
- joParam.interfaceDr = Global.inf.interfaceDr;
- joParam.type = directoryType;
- joParam.flag = flag;
- joParam.specInput = "";
- jaParams.Add(joParam);
- dynamic joPagination = new JObject();
- joPagination.pageSize = pageSize; //pageSize;
- //joPagination.pageSize = 2;
- joPagination.currentPage = currentPage;
- joPagination.sortColumn = "Code";
- joPagination.sortOrder = "asc";
- jaPagination.Add(joPagination);
- //1.获取全部HIS目录
- if (hIS.getHISDir(jaPagination, jaParams, out joHISRtn, out errMsg) != 0)
- {
- return -1;
- }
- joRtn = mIS.GetNoMappHISDir(joHISRtn);
- if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
- {
- return -1;
- }
- }
- DataTable dt = (DataTable)joRtn["result"]["Data"].ToObject(typeof(DataTable));
- dtExport = dt;
- int totalCount = int.Parse(joRtn["result"]["TotalCount"].ToString());
- pgHISDirect.TotalCount = totalCount;
- pgHISDirect.PageSize = 50;
- dgvHISDirectory.DataSource = null;
- dgvHISDirectory.DataSource = dt;
- dgvHISDirectory.Columns[0].ReadOnly = true;
- return 0;
- }
- private void queryCenterDirectory_09010012(int currentPage, int pageSize)
- {
- string directoryType = string.Empty;
- switch (rbgDirecType_C.SelectedIndex)
- {
- case 0:
- {
- directoryType = "drugs";
- break;
- }
- case 1:
- {
- directoryType = "diagnosi";
- break;
- }
- case 2:
- {
- directoryType = "consumables";
- break;
- }
- }
- dynamic joInParams = new JObject();
- joInParams.pagination = new JArray() as dynamic;
- joInParams.session = new JArray() as dynamic;
- JArray jaParams = new JArray();
- dynamic joParams = new JObject();
- joParams.code = "";
- joParams.descripts = "";
- joParams.FindType = new JArray();
- joParams.TypeID = "";
- joParams.alias = "";
- joParams.include = "Hosp";
- joParams.groupID = "324";
- joParams.hospID = "25";
- joParams.type = directoryType;
- joParams.specInput = "";
- jaParams.Add(joParams);
- joInParams.Add("params", JArray.FromObject(jaParams));
- dynamic joSession = new JObject();
- joSession.userID = "";
- joSession.locID = "";
- joSession.groupID = "";
- joSession.hospID = "";
- joSession.sessionID = "";
- joSession.hospCode = "";
- joSession.language = "";
- joSession.hostName = "";
- joSession.ipv4 = "";
- joSession.ipv6 = "";
- joSession.mac = "";
- joInParams.session.Add(joSession);
- dynamic joPagination = new JObject();
- joPagination.pageSize = pageSize;
- joPagination.currentPage = currentPage;
- joPagination.sortColumn = "Code";
- joPagination.sortOrder = "asc";
- joInParams.pagination.Add(joPagination);
- joInParams.code = "09010012";
- string sInput = joInParams.ToString();
- string sRtn = invoker.invokeInsuService(joInParams, "");
- JObject jsonRtn = JObject.Parse(sRtn);
- if (jsonRtn["result"]["Data"] == null)
- {
- MessageBox.Show("该节点不存在");
- return;
- }
- JObject joRtn = JObject.Parse(sRtn);
- DataTable dt = (DataTable)joRtn["result"]["Data"].ToObject(typeof(DataTable));
- int totalCount = int.Parse(joRtn["result"]["TotalCount"].ToString());
- pgCenterDirect.TotalCount = totalCount;
- pgCenterDirect.PageSize = 50;
- dgvCenterDirectory.DataSource = dt;
- }
- private void Mapping()
- {
- JObject joRtn = new JObject();
- JObject joIn = new JObject();
- int iRtn = -1;
- try
- {
- int iHis = dgvHISDirectory.CurrentRow.Index;
- if (dgvCenterDirectory.CurrentRow == null)
- {
- MessageBox.Show("请查询中心目录");
- return;
- }
- int iCenter = dgvCenterDirectory.CurrentRow.Index;
- DataTable dtHis = (DataTable)dgvHISDirectory.DataSource;
- DataTable dtCenter = (DataTable)dgvCenterDirectory.DataSource;
- dgvHISDirectory.Rows[iHis].Cells["insuCode"].Value = dgvCenterDirectory.Rows[iCenter].Cells["Code"].Value.ToString();
- dgvHISDirectory.Rows[iHis].Cells["insuName"].Value = dgvCenterDirectory.Rows[iCenter].Cells["Name"].Value.ToString();
- int hisType = rbgDirecType_C.SelectedIndex + 1;
- string hisTypeName = rbgDirecType_C.Items[hisType - 1].ToString(); ;
- JArray jaParams = new JArray();
- dynamic jsonTemp = new JObject();
- if (dtHis.Rows[iHis]["MapID"].ToString() == "0")
- {
- jsonTemp.ID = "";
- }
- else
- {
- jsonTemp.ID = dtHis.Rows[iHis]["MapID"];
- }
- jsonTemp.HospitalDr = Global.inf.hospitalDr;
- jsonTemp.updateUserID = Global.user.ID;
- jsonTemp.InterfaceDr = Global.inf.interfaceDr;
- jsonTemp.HISCode = dgvHISDirectory.Rows[iHis].Cells["itemCode"].Value;
- jsonTemp.HISName = dgvHISDirectory.Rows[iHis].Cells["itemDesc"].Value;
- jsonTemp.ChargeItemDr = dtHis.Rows[iHis]["ID"];
- jsonTemp.DiretoryDr = dtCenter.Rows[iCenter]["medInsuDirectoryID"];
- //1.已对照 2.已对照但未上传 3 已对照且已上传
- jsonTemp.State = 1;
- jsonTemp.HisType = hisType;
- jsonTemp.HisTypeName = hisTypeName;
- jsonTemp.InsuCode = dgvCenterDirectory.Rows[dgvCenterDirectory.CurrentRow.Index].Cells["Code"].Value;
- jsonTemp.InsuName = dgvCenterDirectory.Rows[dgvCenterDirectory.CurrentRow.Index].Cells["Name"].Value;
- jsonTemp.UpdateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
- jaParams.Add(jsonTemp);
- joIn = new JObject();
- joIn.Add(new JProperty("params", jaParams));
- joIn.Add("code", "09010040");
- InvokeHelper invoker = new InvokeHelper();
- joRtn = invoker.invokeInsuService(joIn.ToString(), "插入对照信息");
- //JObject joRtn = JObject.Parse(irisRtn);
- iRtn = (int)joRtn["errorCode"];
- if (iRtn == 0)
- {
- dgvHISDirectory.Rows[iHis].Cells["flag"].Value = "已对照";
- }
- else
- {
- dgvHISDirectory.Rows[iHis].Cells["flag"].Value = "对照失败";
- }
- }
- finally
- {
- invoker.saveYHLog("数据对照", joIn.ToString(),DateTime.Now.ToString("yyyyMMddHHmmssnnn") ,"",joRtn.ToString(),iRtn,$"{Global.user.ID}:{Global.user.name}");
- Global.writeLog($"数据对照({Global.user.ID}:{Global.user.name})", joIn.ToString(),joRtn.ToString());
- }
- }
- private void CancleMapping()
- {
- int iHis = dgvHISDirectory.CurrentRow.Index;
- DataTable dtHis = (DataTable)dgvHISDirectory.DataSource;
- JArray jaParams = new JArray();
- dynamic jsonTemp = new JObject();
- jsonTemp.ID = dtHis.Rows[iHis]["MapID"];
- jsonTemp.HospitalDr = Global.inf.hospitalDr;
- jsonTemp.updateUserID = Global.user.ID;
- jsonTemp.InterfaceDr = Global.inf.interfaceDr;
- jsonTemp.HISCode = dgvHISDirectory.Rows[iHis].Cells["itemCode"].Value;
- jsonTemp.UpdateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
- jaParams.Add(jsonTemp);
- JObject joIn = new JObject();
- joIn.Add(new JProperty("params", jaParams));
- joIn.Add("code", "09010041");
- InvokeHelper invoker = new InvokeHelper();
- JObject joRtn = invoker.invokeInsuService(joIn.ToString(), "取消对照");
- if ((int)joRtn["errorCode"] == 0)
- {
- dgvHISDirectory.Rows[iHis].Cells["insuCode"].Value = "";
- dgvHISDirectory.Rows[iHis].Cells["insuName"].Value = "";
- dgvHISDirectory.Rows[iHis].Cells["flag"].Value = "未对照";
- dtHis.Rows[iHis]["MapID"] = 0;
- }
- else
- {
- dgvHISDirectory.Rows[iHis].Cells["flag"].Value = "取消失败";
- }
- }
- /// <summary>
- /// 医保目录单个版本号的下载
- /// </summary>
- /// <param name="ver"></param>
- /// <param name="directoryType"></param>
- /// <param name="uiProcessBar"></param>
- /// <param name="errorMessage"></param>
- /// <returns></returns>
- public int SingleDownload(out string errorMessage, out string currentMaxVerNO)
- {
- errorMessage = "";
- currentMaxVerNO = "";
- PTMedicalInsurance.Business.HIS.DownLoad hDL = new Business.HIS.DownLoad();
- try
- {
- if (isStopLoopDownload)
- {
- errorMessage = "操作员主动停止下载";
- return -1;
- }
- return hDL.DownloadMIDiretoryBySpecifyVerNO(tbVer_4.Text, rbgDownItemType_4.SelectedIndex, pbDownload_4, out errorMessage, out currentMaxVerNO);
- }
- catch (Exception ex)
- {
- errorMessage = "SingleDownload提示:" + ex.Message;
- return -1;
- }
- }
- /// <summary>
- /// 自动下载医保目录,直到最新版本(返回报错)
- /// </summary>
- /// <param name="directoryType"></param>
- /// <param name="uiProcessBar"></param>
- /// <param name="errorMessage"></param>
- /// <returns></returns>
- public int AutoDownload(int directoryType,out string errorMessage)
- {
- int iResult = 0;
- errorMessage = "";
- string currentMaxVerNO;
- try
- {
- while (iResult == 0)
- {
- JObject joMaxVerNO = mIS.getDirectoryMaxVersionNO(directoryType);
- string ver = joMaxVerNO["result"]["MaxVersionNO"].ToString();
- tbVer_4.Text = ver;
- //iResult = JsonHelper.parseIrisRtnValue(joMaxVerNO, out errorMessage);
- iResult = SingleDownload(out errorMessage, out currentMaxVerNO);
- }
- return iResult;
- }
- catch (Exception ex)
- {
- errorMessage = ex.Message;
- return -1;
- }
- }
- public int loopDownloadBySpecVerNO(out string errorMessage)
- {
- int iResult = 0;
- errorMessage = "";
- string currentMaxVerNO;
- try
- {
- while (iResult == 0)
- {
- //tbVer_4.Text = ver;
- //iResult = JsonHelper.parseIrisRtnValue(joMaxVerNO, out errorMessage);
- iResult = SingleDownload(out errorMessage, out currentMaxVerNO);
- tbVer_4.Text = currentMaxVerNO;
- }
- return iResult;
- }
- catch (Exception ex)
- {
- errorMessage = ex.Message;
- return -1;
- }
- }
- #endregion
- private void Form1_Load(object sender, EventArgs e)
- {
- //rbgDirecType.ValueChanged += new Sunny.UI.UIRadioButtonGroup.OnValueChanged(rbgDirecType_ValueChanged);
- this.WindowState = FormWindowState.Maximized;
- }
- private void btnDownload_Click(object sender, EventArgs e)
- {
- }
- private void btnQuery_Click(object sender, EventArgs e)
- {
- queryHISInsuDirectory(rbgDirecType.SelectedIndex, 1, 20, dgvDirectoy, Global.inf.interfaceDr);
- }
- private void btnQueryHISDirectory_Click(object sender, EventArgs e)
- {
- this.dgvHISDirectory.SelectionChanged -= this.dgvHISDirectory_SelectionChanged;
- string errMsg;
- int iCount = 50;
- if (rbNoMaped.Checked) iCount = 5000;
- if (queryHISDirectory(1, iCount, out errMsg) != 0)
- {
- MessageBox.Show(errMsg);
- return;
- }
- this.dgvHISDirectory.SelectionChanged += this.dgvHISDirectory_SelectionChanged;
- }
- private void btnQueryCenterDirectory_Click(object sender, EventArgs e)
- {
- queryHISInsuDirectory(rbgInsuDirecType_C.SelectedIndex, 1, 50, dgvCenterDirectory, Global.inf.interfaceDr);
- }
- private void pgDownload_PageChanged(object sender, object pagingSource, int pageIndex, int count)
- {
- queryHISInsuDirectory(rbgDirecType.SelectedIndex, pageIndex, count, dgvDirectoy, Global.inf.interfaceDr);
- }
- private void pgHISDirect_PageChanged(object sender, object pagingSource, int pageIndex, int count)
- {
- string errMsg;
- if (queryHISDirectory(pageIndex, 50, out errMsg) != 0)
- {
- MessageBox.Show(errMsg);
- return;
- }
- }
- private void pgCenterDirect_PageChanged(object sender, object pagingSource, int pageIndex, int count)
- {
- queryHISInsuDirectory(rbgDirecType_C.SelectedIndex, pageIndex, count, dgvCenterDirectory, Global.inf.interfaceDr);
- }
- private void rbgDirecType_ValueChanged(object sender, int index, string text)
- {
- btnQuery_Click(null, new EventArgs());
- }
- private void toolStripMenuItem2_Click(object sender, EventArgs e)
- {
- CancleMapping();
- }
- private void tsmiMapping_Click(object sender, EventArgs e)
- {
- Mapping();
- }
- private void dgvHISDirectory_DoubleClick(object sender, EventArgs e)
- {
- }
- private void dgvDirectoy_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
- {
- //自动编号,与数据无关
- Rectangle rectangle = new Rectangle(e.RowBounds.Location.X,
- e.RowBounds.Location.Y,
- dgvDirectoy.RowHeadersWidth - 4,
- e.RowBounds.Height);
- TextRenderer.DrawText(e.Graphics,
- (e.RowIndex + 1).ToString(),
- dgvDirectoy.RowHeadersDefaultCellStyle.Font,
- rectangle,
- dgvDirectoy.RowHeadersDefaultCellStyle.ForeColor,
- TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
- }
- private void rbAll_ValueChanged(object sender, bool value)
- {
- if (rbAll.Checked)
- {
- btnQueryHISDirectory_Click(null, new EventArgs());
- }
- }
- private void rbMaped_CheckedChanged(object sender, EventArgs e)
- {
- if (rbMaped.Checked)
- {
- string errMsg;
- if (queryHISDirectory(1, 50, out errMsg) != 0)
- {
- MessageBox.Show(errMsg);
- return;
- }
- }
- }
- private void btAddDir_Click(object sender, EventArgs e)
- {
- if (rbgDirecType.SelectedIndex == 8)
- {
- string errMsg = "";
- AddSingleDictionary addDictionary = new AddSingleDictionary();
- if (addDictionary.ShowDialog() == DialogResult.OK)
- {
- if (UpdateDictionaryBySelf(addDictionary, out errMsg) != 0)
- {
- MessageBox.Show(errMsg);
- }
- else
- {
- MessageBox.Show("新增成功!");
- }
- }
- }
- else
- {
- AddSingleDirectory addDirectory = new AddSingleDirectory(rbgDirecType.SelectedIndex);
- if (addDirectory.ShowDialog() == DialogResult.OK)
- {
- JObject joRtn = mIS.UpdateDirectoryBySelf(addDirectory.joPamam);
- string error = "";
- if (JsonHelper.parseIrisRtnValue(joRtn, out error) != 0)
- {
- MessageBox.Show("新增失败:" + error);
- }
- else
- {
- MessageBox.Show("新增成功");
- }
- }
- }
- }
- private void btEditDir_Click(object sender, EventArgs e)
- {
- DataTable dt = (DataTable)dgvDirectoy.DataSource;
- if ((dt == null) || (dt.Rows.Count < 1))
- {
- MessageBox.Show("表中无数据,请检查!");
- return;
- }
- DataRow dr = dt.Rows[dgvDirectoy.CurrentRow.Index];
- if (rbgDirecType.SelectedIndex == 8)
- {
- string errMsg;
- AddSingleDictionary addDictionary = new AddSingleDictionary(dr);
- if (addDictionary.ShowDialog() == DialogResult.OK)
- {
- if (UpdateDictionaryBySelf(addDictionary, out errMsg) != 0)
- {
- MessageBox.Show(errMsg);
- }
- else
- {
- MessageBox.Show("修改成功!");
- }
- }
- }
- else
- {
-
- AddSingleDirectory addDirectory = new AddSingleDirectory(rbgDirecType.SelectedIndex, dr);
- if (addDirectory.ShowDialog() == DialogResult.OK)
- {
- JObject joRtn = mIS.UpdateDirectoryBySelf(addDirectory.joPamam);
- string error = "";
- if (JsonHelper.parseIrisRtnValue(joRtn, out error) != 0)
- {
- MessageBox.Show("修改失败:" + error);
- }
- else
- {
- MessageBox.Show("修改成功");
- }
- }
- }
- }
-
- private void rbgDownType_3_ValueChanged(object sender, int index, string text)
- {
- DataGridView dgs = new DataGridView();
- GridViewSetter gvs = new GridViewSetter();
- //gvs.SetHeaderTextOfMoreInfo()
- }
- private void btDownload_4_Click(object sender, EventArgs e)
- {
- isStopLoopDownload = false;
- string errMsg = "";
- string currentMaxVerNO;
- if (rbSingleDown.Checked)
- {
- if (SingleDownload(out errMsg, out currentMaxVerNO) != 0)
- {
- MessageBox.Show("下载失败:" + errMsg);
- }
- }
- else if (rbAutoDown.Checked)
- {
- if (AutoDownload(rbgDownItemType_4.SelectedIndex,out errMsg) != 0)
- {
- MessageBox.Show("下载失败:" + errMsg);
- }
- }
- else
- {
- if (loopDownloadBySpecVerNO(out errMsg) != 0)
- {
- MessageBox.Show("下载失败:" + errMsg);
- }
- }
- }
- private void dgvDownload_4_CellContentClick(object sender, DataGridViewCellEventArgs e)
- {
- }
- private void dgvDirectoy_CellContentClick(object sender, DataGridViewCellEventArgs e)
- {
- }
- private void btnExport_Click(object sender, EventArgs e)
- {
- this.pgHISDirect.PageChanged -= new Sunny.UI.UIPagination.OnPageChangeEventHandler(this.pgHISDirect_PageChanged);
- // 创建 DataLoader 并传递 queryExportData 方法
- DataLoader _dataLoader;
- _dataLoader = new DataLoader((out string errMsg) => queryExportData_CallBack(out errMsg), this);
- _dataLoader.StartQueryExportData((result, errMsg) =>
- {
- // 在这里处理结果和错误信息
- if (result == 0)
- {
- MessageBox.Show(errMsg);
- }
- else
- {
- MessageBox.Show(errMsg);
- }
- });
- }
- private int queryExportData(out string errMsg)
- {
- errMsg = "";
- int currentPage = 1; int pageSize = 50;
- string directoryType = string.Empty;
- switch (rbgDirecType_C.SelectedIndex)
- {
- case 0:
- {
- directoryType = "drugs";
- break;
- }
- case 1:
- {
- directoryType = "diagnosi";
- break;
- }
- case 2:
- {
- directoryType = "consumables";
- break;
- }
- }
- JObject joHISRtn = new JObject();
- JObject joRtn = new JObject();
- string flag = "";
- //全部是先调HIS,然后再匹配医保平台的对照关系
- if (rbAll.Checked)
- {
- JArray jaPagination = new JArray();
- JArray jaParams = new JArray();
- flag = "All";
- dynamic joParam = new JObject();
- joParam.code = "";
- joParam.descripts = "";
- joParam.FindType = new JArray();
- joParam.TypeID = "";
- joParam.alias = tbHISDirectoryFilter.Text;
- joParam.include = "Hosp";
- joParam.groupID = "324";
- joParam.hospID = Global.inf.hisHospitalDr;
- joParam.interfaceDr = Global.inf.interfaceDr;
- joParam.type = directoryType;
- joParam.flag = flag;
- //joParam.specInput = txtSpecFilter.Text.Trim();
- jaParams.Add(joParam);
- dynamic joPagination = new JObject();
- joPagination.pageSize = pageSize;
- //joPagination.pageSize = 2;
- joPagination.currentPage = currentPage;
- joPagination.sortColumn = "Code";
- joPagination.sortOrder = "asc";
- jaPagination.Add(joPagination);
- //该服务需要改写,需要跟(CloudMedicalInsurancePlatform.Tables.MapRelation)进行关联
- //joInParams.code = "09010038";
- if (hIS.getHISDir(jaPagination, jaParams, out joHISRtn, out errMsg) != 0)
- {
- return -1;
- }
- int count = int.Parse(JsonHelper.getDestValue(joHISRtn, "result.TotalCount"));
- if (count > pageSize)
- {
- joPagination["pageSize"] = count;
- jaPagination = new JArray();
- jaPagination.Add(joPagination);
- if (hIS.getHISDir(jaPagination, jaParams, out joHISRtn, out errMsg) != 0)
- {
- return -1;
- }
- }
- int defaultCount = 200;
- dtExport = null;
- if (count > defaultCount)
- {
- JArray jaHisDir = JArray.Parse(JsonHelper.getDestValue(joHISRtn, "result.Data"));
- JArray jaTmp = new JArray();
- for (int i = 0; i < count; i++)
- {
- JObject joTmp = (JObject)jaHisDir[i];
- foreach (var property in joTmp.Properties())
- {
- if (property.Value.Type == JTokenType.Integer || property.Value.Type == JTokenType.Float)
- {
- property.Value = new JValue(property.Value.ToString());
- }
- }
- jaTmp.Add(joTmp);
- if ((((i + 1) % defaultCount) == 0) || (i + 1 == count))
- {
- JObject joConvert = new JObject();
- joConvert.Add("errorCode", 0);
- joConvert.Add("errorMessage", "查询成功");
- JObject joResult = new JObject();
- if ((i % defaultCount) == 0)
- {
- joResult.Add("TotalCount", defaultCount);
- }
- else
- {
- joResult.Add("TotalCount", (i + 1) % defaultCount);
- }
- joResult.Add("Data", jaTmp);
- joConvert.Add("result", joResult);
- joRtn = mIS.ConvertHISDir(joConvert);
- if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
- {
- return -1;
- }
- else
- {
- DataTable dtTmp = (DataTable)joRtn["result"]["Data"].ToObject(typeof(DataTable));
- if (dtExport == null)
- {
- dtExport = dtTmp.Clone();
- dtExport.Merge(dtTmp);
- }
- else
- {
- dtExport.Merge(dtTmp);
- }
- jaTmp = new JArray();
- }
- }
- }
- }
- else
- {
- joRtn = mIS.ConvertHISDir(joHISRtn);
- if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
- {
- return -1;
- }
- dtExport = (DataTable)joRtn["result"]["Data"].ToObject(typeof(DataTable));
- }
- }
- //已对照是先调云医保,然后再匹配HIS
- if (rbMaped.Checked)
- {
- JArray jaPagination = new JArray();
- JArray jaParams = new JArray();
- flag = "Maped";
- dynamic joParam = new JObject();
- joParam.alias = tbHISDirectoryFilter.Text;
- joParam.HospitalDr = Global.inf.hospitalDr;
- joParam.InterfaceDr = Global.inf.interfaceDr;
- joParam.hisType = directoryType;
- jaParams.Add(joParam);
- dynamic joPagination = new JObject();
- joPagination.pageSize = pageSize;
- joPagination.currentPage = currentPage;
- joPagination.sortColumn = "HisCode";
- joPagination.sortOrder = "asc";
- jaPagination.Add(joPagination);
- JObject joMIRtn = mIS.GetMappedHISDir(jaPagination, jaParams);
- if (JsonHelper.parseIrisRtnValue(joMIRtn, out errMsg) != 0)
- {
- return -1;
- }
- //传给HIS,进行匹配
- joParam = new JObject();
- joParam.TotalCount = joMIRtn["result"]["TotalCount"];
- joParam.type = directoryType;
- joParam.flag = flag;
- joParam.hospID = Global.inf.hisHospitalDr;
- joParam.interfaceDr = Global.inf.interfaceDr;
- joParam.alias = tbHISDirectoryFilter.Text;
- joParam.include = "Hosp";
- joParam.groupID = "324";
- joParam.compareArr = joMIRtn["result"]["Data"];
- jaParams = new JArray();
- jaParams.Add(joParam);
- if (hIS.getHISDir(jaPagination, jaParams, out joRtn, out errMsg) != 0)
- {
- return -1;
- }
- }
- //if (rbNoMaped.Checked) { flag = "NoMaped"; }
- if (rbNoMaped.Checked)
- {
- JArray jaPagination = new JArray();
- JArray jaParams = new JArray();
- flag = "All";
- dynamic joParam = new JObject();
- joParam.code = "";
- joParam.descripts = "";
- joParam.FindType = new JArray();
- joParam.TypeID = "";
- joParam.alias = tbHISDirectoryFilter.Text;
- joParam.include = "Hosp";
- joParam.groupID = "324";
- joParam.hospID = Global.inf.hisHospitalDr;
- joParam.interfaceDr = Global.inf.interfaceDr;
- joParam.type = directoryType;
- joParam.flag = flag;
- joParam.specInput = "";
- jaParams.Add(joParam);
- dynamic joPagination = new JObject();
- joPagination.pageSize = pageSize;
- //joPagination.pageSize = 2;
- joPagination.currentPage = currentPage;
- joPagination.sortColumn = "Code";
- joPagination.sortOrder = "asc";
- jaPagination.Add(joPagination);
- //1.获取全部HIS目录
- if (hIS.getHISDir(jaPagination, jaParams, out joHISRtn, out errMsg) != 0)
- {
- return -1;
- }
- joRtn = mIS.GetNoMappHISDir(joHISRtn);
- if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
- {
- return -1;
- }
- }
- return 0;
- }
- private int queryExportData_CallBack(out string errMsg)
- {
- if (queryExportData(out errMsg) != 0)
- {
- return -1;
- }
- //test.Stop();
- this.Invoke((MethodInvoker)delegate {
- this.pgHISDirect.PageChanged += new Sunny.UI.UIPagination.OnPageChangeEventHandler(this.pgHISDirect_PageChanged);
- });
-
- if (dtExport.Rows.Count > 0)
- {
- string directoryType = string.Empty;
- string sBZ = "";
- switch (rbgDirecType_C.SelectedIndex)
- {
- case 0:
- {
- directoryType = "药品";
- break;
- }
- case 1:
- {
- directoryType = "诊疗";
- break;
- }
- case 2:
- {
- directoryType = "材料";
- break;
- }
- }
- if (rbAll.Checked) sBZ = "全部";
- else
- if (rbMaped.Checked) sBZ = "已对照";
- else
- if (rbNoMaped.Checked) sBZ = "未对照";
- string LSH = DateTime.Now.ToString("yyyy-MM-dd"); //DateTime.Now.ToString("MMddHHmmssffff");
- string filename = LSH + "(" + directoryType + ")医保目录" + sBZ + "信息.xls";
- string sFliePathName = Global.curEvt.path + "\\MapRelation\\" + filename;
- //string sFliePathName = @"D:\" + LSH + "(" + directoryType + ")医保目录" + sBZ + "信息.xls";
- //如果不存在目录,则创建目录
- if (!Directory.Exists(Global.curEvt.path + "\\MapRelation"))
- {
- //创建文件夹
- DirectoryInfo dirInfo = Directory.CreateDirectory(Global.curEvt.path + "\\MapRelation");
- }
-
- //如存在同名文件不询问直接删除
- if (File.Exists(sFliePathName))
- {
- File.Delete(sFliePathName);
- }
-
- //新版方法,用的EPPLUS,方便
- ExportToExcel.ExportDataTableToExcel(dtExport, sFliePathName);
- if (true)
- {
- errMsg = ($"导出成功,文件保存路径:{sFliePathName}");
- return 0;
- }
- else
- {
- errMsg = ("导出失败!");
- return -1;
- }
- }
- else
- {
- errMsg = "查询数据集为空!";
- return -1;
- }
- }
- private void dgvHISDirectory_RowEnter(object sender, DataGridViewCellEventArgs e)
- {
- tbCenterDirectoryFilter.Text = "%" + dgvHISDirectory.SelectedRows[0].Cells["itemDesc"].Value.ToString() + "%";
- tbApprovalNO.Text = dgvHISDirectory.SelectedRows[0].Cells["pprovalNo"].Value.ToString();
- }
- private void dgvHISDirectory_SelectionChanged(object sender, EventArgs e)
- {
- int i = dgvHISDirectory.CurrentRow.Index;
- if (dgvHISDirectory.Rows[i].Cells["insuCode"].Value.ToString() != "")
- {
- tbInsuCode.Text = dgvHISDirectory.Rows[i].Cells["insuCode"].Value.ToString();
- tbCenterDirectoryFilter.Text = "";
- tbApprovalNO.Text = "";
- }
- else
- {
- tbInsuCode.Text = "";
- tbCenterDirectoryFilter.Text = "%" + dgvHISDirectory.Rows[i].Cells["itemDesc"].Value.ToString() + "%";
- tbApprovalNO.Text = "%" + dgvHISDirectory.Rows[i].Cells["pprovalNo"].Value.ToString() + "%";
- }
- }
- private void btStopLoopDownload_Click(object sender, EventArgs e)
- {
- isStopLoopDownload = true;
- }
- private void tsmShowAuxInfo_Click(object sender, EventArgs e)
- {
- if (dgvDirectoy.CurrentRow != null)
- {
- // 获取当前行中 "code" 列的单元格值,并转换为字符串
- string code = dgvDirectoy.CurrentRow.Cells["code"].Value?.ToString() ?? string.Empty;
- LimitPriceAndSelfpayPropInfo frm = new LimitPriceAndSelfpayPropInfo(code);
- frm.Show();
- }
- else
- {
- // 没有选中的行,处理这种情况
- MessageBox.Show("请选择一行。");
- }
-
- }
- public int UpdateDictionaryBySelf(AddSingleDictionary addDic, out string errMsg)
- {
- string outParam = "", HBDictionaryDr = "";
- JObject joRtn;
- JObject jo = addDic.joPamam;
- try
- {
- //if (JsonHelper.getDestValue(jo, "operateType") == "0")
- //{
- //插入并获取字典主表的DR
- JObject joDic = JObject.FromObject(jo["dicObj"]);
- joRtn = mIS.insertDictionary(joDic);
- if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
- {
- return -1;
- }
- else
- {
- HBDictionaryDr = JsonHelper.getDestValue(joRtn, "data.HBDictionaryDr");
- if (HBDictionaryDr == "")
- {
- errMsg = "HBDictionaryDr返回值为空";
- return -1;
- }
- }
-
- //插入明细表
- JObject joDicDetail = JObject.FromObject(jo["detailObj"]);
- joDicDetail.Add("HBDictionaryDr", HBDictionaryDr);
- JArray jaParams = new JArray();
- jaParams.Add(joDicDetail);
- joRtn = mIS.insertDictionaryDataDetail(jaParams);
- if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
- {
- return -1;
- }
- else
- {
- return 0;
- }
- }
- catch (Exception ex)
- {
- errMsg = ex.Message;
- return -1;
- }
- }
- }
- }
|