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; 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 JObject joDirInfoOfCenterRtn; //中心返回的目录信息 public BasicData() { InitializeComponent(); this.dgvInsuDirInfo.DataError += delegate (object sender, DataGridViewDataErrorEventArgs e) { };//屏蔽单元格错误 rbgDirecType.SelectedIndex = 0; rbgDirecType_C.SelectedIndex = 0; rbgDownType_3.SelectedIndex = 5; 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); Font rowFont = new Font("UTF-8", 8); Font columnFont = new Font("UTF-8", 9); rbgDirecType.SelectedIndex = 8; rbAll.Checked = true; GridViewSetter gvs = new GridViewSetter(); gvs.SetHeaderTextOfLimitPrice(dgvLimitPriceInfo); gvs.SetHeaderTextOfSelfPay(dgvSelfPayRiotInfo); gvs.SetHeaderTextOfInsuDir(dgvInsuDirInfo); } #region 函数封装 private void queryInsuDirectory(int currentPage, int pageSize, int directoryType,int interfaceDr,string code) { try { string dirCode = ""; string dirName = ""; string approvalNO = ""; Sunny.UI.UIDataGridView dgv; Sunny.UI.UIPagination pg; if (tbBasicData.SelectedIndex == 0) { dirCode = tbDirectoryCode.Text; dirName = tbDircetoryName.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 }, { "directoryDr" , interfaceDr } }; if ((rbgDirecType.SelectedIndex == 8) && (tbDicType.Text != "")) { joInput.Add("type",tbDicType.Text); } 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; } } } private void queryHISInsuDirectory(int directoryType, int pageIndex, int count, Sunny.UI.UIDataGridView dgv, int interfaceDr) { string code = "09010042"; if (tbBasicData.SelectedIndex == 0) { if (rbgDirecType.SelectedIndex == 8) { code = "09010043"; } } queryInsuDirectory(pageIndex, count, directoryType + 1, interfaceDr, code); 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) { dgvHISDirectory.DataSource = null; 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"]; JArray jaMIRtn = JArray.Parse(JsonHelper.getDestValue(joMIRtn, "result.Data")); if (jaMIRtn.Count == 0) { errMsg = "未查询到已对照数据!"; return -1; } 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) { flag = "NoMaped"; } DataTable dt = (DataTable)joRtn["result"]["Data"].ToObject(typeof(DataTable)); int totalCount = int.Parse(joRtn["result"]["TotalCount"].ToString()); pgHISDirect.TotalCount = totalCount; pgHISDirect.PageSize = 50; 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() { 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); JObject joIn = new JObject(); joIn.Add(new JProperty("params", jaParams)); joIn.Add("code", "09010040"); InvokeHelper invoker = new InvokeHelper(); JObject joRtn = invoker.invokeInsuService(joIn.ToString(),"插入对照信息"); //JObject joRtn = JObject.Parse(irisRtn); if ((int)joRtn["errorCode"] == 0) { dgvHISDirectory.Rows[iHis].Cells["flag"].Value = "已对照"; } else { dgvHISDirectory.Rows[iHis].Cells["flag"].Value = "对照失败"; } } 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 = "取消失败"; } } /// /// 医保目录单个版本号的下载 /// /// /// /// /// /// public int SingleDownload(string ver, int directoryType, Sunny.UI.UIProcessBar uiProcessBar, out string errorMessage) { string txtPath = string.Empty; errorMessage = ""; int iResult = -1; string funNo = ""; switch (directoryType) { case 0://药品 { funNo = "1301"; //"1301"; break; } case 1://诊疗 { funNo = "1365"; break; } case 2://材料 { funNo = "1364"; break; } case 3://疾病诊断 { funNo = "1307"; break; } case 4://手术 { funNo = "1308"; break; } case 5://慢性病 { funNo = "1309"; break; } case 6://DRGs { funNo = "1310"; break; ; } case 7://日间手术 { funNo = "1311"; break; } case 8://字典表 { break; } } try { JObject joRtn = hBus.DownloadDirectory(funNo, ver); if (JsonHelper.parseCenterRtnValue(joRtn, out errorMessage) == 0) { txtPath = joRtn["filePath"].ToString(); DataImoport bus = new DataImoport(); JObject joImportRtn = bus.importDataToIrisByTxt(txtPath, 50, directoryType + 1, uiProcessBar); if (JsonHelper.parseCenterRtnValue(joImportRtn, out errorMessage) == 0) { iResult = 0; } else { errorMessage = "导入数据出现错误,请查看日志!";//joImportRtn["errorMessage"].ToString(); } } return iResult; } catch (Exception ex) { errorMessage = "SingleDownload提示:" + ex.Message; return -1; } } /// /// 医保目录单个版本号的下载 /// /// /// /// /// /// public int downloadDicionary(JObject joData, Sunny.UI.UIProcessBar uiProcessBar, out string errorMessage) { errorMessage = ""; int iResult = -1; try { JObject joRtn = cBus.DownDictionay(joData); if (JsonHelper.parseCenterRtnValue(joRtn, out errorMessage) == 0) { DataImoport DI = new DataImoport(); JArray jaList = JArray.Parse(JsonHelper.getDestValue(joRtn, "output.list")); JObject joImportRtn = DI.importDictionary(uiProcessBar, jaList, tbDicType.Text); if (JsonHelper.parseIrisRtnValue(joImportRtn, out errorMessage) == 0) { iResult = 0; } else { errorMessage = "导入数据出现错误,请查看日志!" + errorMessage; } } return iResult; } catch (Exception ex) { errorMessage = "downloadDicionary提示:" + ex.Message; return -1; } } /// /// 自动下载医保目录,直到最新版本(返回报错) /// /// /// /// /// public int AutoDownload(int directoryType, Sunny.UI.UIProcessBar uiProcessBar, out string errorMessage) { int iResult = 0; errorMessage = ""; try { while (iResult == 0) { JObject joMaxVerNO = mIS.getDirectoryMaxVersionNO(directoryType); string ver = joMaxVerNO["result"]["MaxVersionNO"].ToString(); iResult = JsonHelper.parseIrisRtnValue(joMaxVerNO, out errorMessage); iResult = SingleDownload(ver, directoryType, uiProcessBar, out errorMessage); } return iResult; } catch (Exception ex) { errorMessage = ex.Message; return -1; } } #endregion #region 按钮 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) { string errorMessage = string.Empty; if (rbgDirecType.SelectedIndex == 8) { dynamic joData = new JObject(); joData.type = tbDicType.Text; joData.parentValue = ""; joData.admdvs = ""; joData.date = tbDicDate.Text; joData.vali_flag = ""; if (downloadDicionary(joData, uiProcessBar1,out errorMessage) != 0) { MessageBox.Show(errorMessage); return; } } else { if (rbSingleDown.Checked) { string ver = tbVer.Text; if (tbVer.Text != "") { ver = tbVer.Text; } if (SingleDownload(ver, rbgDirecType.SelectedIndex, uiProcessBar1, out errorMessage) != 0) { MessageBox.Show(errorMessage); return; } } if (rbAutoDown.Checked) { if (AutoDownload(rbgDirecType.SelectedIndex, uiProcessBar1, out errorMessage) != 0) { MessageBox.Show(errorMessage); return; } } } btnQuery_Click(sender, 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) { string errMsg; if (queryHISDirectory(1, 50, out errMsg) != 0) { MessageBox.Show(errMsg); return; } GridViewSetter gridSetter = new GridViewSetter(); gridSetter.SetHeaderTextOfMapping_HisDirectory(dgvHISDirectory); } private void btnQueryCenterDirectory_Click(object sender, EventArgs e) { queryHISInsuDirectory(rbgDirecType_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) { int currentPage = pgHISDirect.ActivePage; string flag = dgvHISDirectory.Rows[dgvHISDirectory.CurrentRow.Index].Cells["flag"].Value.ToString(); if (flag == "未对照") { Mapping(); } else if (flag == "已对照") { // CancleMapping(); } if (rbAll.Checked) { string errMsg; if (queryHISDirectory(1, 50, out errMsg) != 0) { MessageBox.Show(errMsg); return; } } } 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) { 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]; 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 tsmUpdateDir_Click(object sender, EventArgs e) { JObject joData = new JObject(); string outPar = ""; try { int dirIndex = dgvDirectoy.CurrentRow.Index; int type = -1; switch (rbgDirecType.SelectedIndex) { case 0: type = 0; break; case 1: type = 5; break; case 2: type = 4; break; } if (type == -1) { MessageBox.Show("仅支持西药,诊疗,材料的更新查询!"); return; } joData.Add("type",type); joData.Add("med_list_codg",dgvDirectoy.Rows[dirIndex].Cells["Code"].Value.ToString()); joData.Add("fee_ocur_time", DateTime.Now.ToString("yyyy-MM-dd")); if (QueryAndShowInsuDirInfo(joData, out outPar) != 0) { MessageBox.Show(outPar); } } catch (Exception ex) { MessageBox.Show("目录查询异常:" + ex.Message); } } private void rbgDownType_3_ValueChanged(object sender, int index, string text) { DataGridView dgs = new DataGridView(); GridViewSetter gvs = new GridViewSetter(); //gvs.SetHeaderTextOfMoreInfo() } private void btQueryDir_2_Click(object sender, EventArgs e) { JObject joData = new JObject(); string outPar = ""; try { joData.Add("type", rbgDownType_3.SelectedIndex); joData.Add("med_list_codg", tbInsuCode_2.Text); joData.Add("fee_ocur_time", tbOccurDate_2.Text); if (QueryAndShowInsuDirInfo(joData, out outPar) != 0) { MessageBox.Show(outPar); } } catch (Exception ex) { MessageBox.Show("目录更新异常:" + ex.Message); } } private void dgvLimitPriceInfo_DataError(object sender, DataGridViewDataErrorEventArgs anError) { // MessageBox.Show("Error happened " + anError.Context.ToString()); // string msg = String.Format("Finished Editing Cell at ({0}, {1})", //anError.ColumnIndex, anError.RowIndex); // MessageBox.Show(msg); // if (anError.Context == DataGridViewDataErrorContexts.Commit) // { // MessageBox.Show("Commit error"); // } // if (anError.Context == DataGridViewDataErrorContexts.CurrentCellChange) // { // MessageBox.Show("Cell change"); // } // if (anError.Context == DataGridViewDataErrorContexts.Parsing) // { // MessageBox.Show("parsing error"); // } // if (anError.Context == DataGridViewDataErrorContexts.LeaveControl) // { // MessageBox.Show("leave control error"); // } // if (anError.Context == DataGridViewDataErrorContexts.Formatting) // { // MessageBox.Show("Formatting control error"); // } // if (anError.Context == DataGridViewDataErrorContexts.Display) // { // MessageBox.Show("Display control error"); // } // if ((anError.Exception) is ConstraintException) // { // DataGridView view = (DataGridView)sender; // view.Rows[anError.RowIndex].ErrorText = "an error"; // view.Rows[anError.RowIndex].Cells[anError.ColumnIndex].ErrorText = "an error"; // anError.ThrowException = false; // } } #endregion #region 目录更新 ,限价更新,自付比例更新 /// /// 通过1312等更新医保目录 /// /// /// private int UpdateDirBy1312(JObject jo, out string errMsg) { errMsg = ""; try { JObject joParam = new JObject(); joParam.Add("Code", JsonHelper.getDestValue(jo, "hilist_code")); joParam.Add("Name", JsonHelper.getDestValue(jo, "hilist_name")); //joParam.Add("HisType", direcType + 1); //joParam.Add("HisTypeName", hisTypeName); //joParam.Add("LocateCode", tbLocateCode.Text); //joParam.Add("LocateName", tbLocateName.Text); //joParam.Add("DrugSafetyStandardCode", tbSafetyCode.Text); //joParam.Add("DosageFormCode", tbDosageCode.Text); //joParam.Add("DosageFormName", tbDosageName.Text); joParam.Add("CategoryCode", JsonHelper.getDestValue(jo, "list_type")); //joParam.Add("CategoryName", ""); //joParam.Add("Specification", tbSpecification.Text); //joParam.Add("SpecificationCode", ""); //joParam.Add("UnitOfPackag", tbUnitOfPackag.Text); //joParam.Add("UnitOfValuation", tbUnitOfValuation.Text); joParam.Add("StartDate", JsonHelper.getDestValue(jo, "begndate")); joParam.Add("EndDate", JsonHelper.getDestValue(jo, "enddate")); //joParam.Add("PinyinSearchCode", pym); //joParam.Add("Instructions", rtbInstructions.Text); //joParam.Add("ExceptContent", rtbExceptContent.Text); //joParam.Add("Connotation", rtbConnotation.Text); //joParam.Add("Note", tbNote.Text); joParam.Add("ValidFlag", JsonHelper.getDestValue(jo, "vali_flag")); //joParam.Add("ApprovalNO", tbApprovalNO.Text); //joParam.Add("VersionNO", tbVersionNO.Text); //joParam.Add("VersionName", tbVersionName.Text); //joParam.Add("UseFlag", Convert.ToInt32(cbUseFlag.Checked)); //joParam.Add("SpecialFlag", Convert.ToInt32(cbSpecialFlag.Checked)); joParam.Add("LimitFlag", JsonHelper.getDestValue(jo, "lmt_used_flag")); //joParam.Add("LimitRange", rtbLimitRange.Text); //joParam.Add("UniqueRecordNO", JsonHelper.getDestValue(jo, "")); //joParam.Add("NationalCode", tbNationalCode.Text); //joParam.Add("NationalName", tbNationalName.Text); //joParam.Add("Manufacturers", tbManufacturers.Text); joParam.Add("UpdateTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); joParam.Add("ChargeItemLevel", JsonHelper.getDestValue(jo, "chrgitm_lv")); //joParam.Add("Company", tbCompany.Text); joParam.Add("ChargeItemType", JsonHelper.getDestValue(jo, "med_chrgitm_type")); JObject joRtn = mIS.UpdateDirectoryBySelf(joParam); string error = ""; if (JsonHelper.parseIrisRtnValue(joRtn, out error) != 0) { errMsg = "更新失败:" + error; return -1; } else { errMsg ="更新成功"; return 0; } } catch (Exception ex) { errMsg = "UpdateDir:" + ex.Message; return -1; } } /// /// 更新限价信息 /// /// /// private int UpdateLimitPrice(JArray ja, out string errMsg) { errMsg = "更新成功"; bool bSuccess = true; try { Global.writeLog(ja.ToString()); //遍历 foreach (JObject jo in ja) { Global.writeLog(jo.ToString()); //转换为IRIS字段 JObject joTmp = new JObject(); joTmp.Add("Code", JsonHelper.getDestValue(jo, "hilist_code")); joTmp.Add("Name", ""); joTmp.Add("LimitType", JsonHelper.getDestValue(jo, "hilist_lmtpric_type")); joTmp.Add("DisposeWay", JsonHelper.getDestValue(jo, "overlmt_dspo_way")); joTmp.Add("BeginDate", JsonHelper.getDestValue(jo, "begndate")); joTmp.Add("EndDate", JsonHelper.getDestValue(jo, "enddate")); joTmp.Add("UpLimitAmount", JsonHelper.getDestValue(jo, "hilist_pric_uplmt_amt")); joTmp.Add("InsuranceAreaCode", JsonHelper.getDestValue(jo, "insu_admdvs")); joTmp.Add("PoolAreaNO", JsonHelper.getDestValue(jo, "poolarea_no")); joTmp.Add("ValidFlag", JsonHelper.getDestValue(jo, "vali_flag")); joTmp.Add("RequiredID", JsonHelper.getDestValue(jo, "rid")); joTmp.Add("UpdateTime", JsonHelper.getDestValue(jo, "updt_time")); JObject joRtn = mIS.UpdateDirectoryLimitPrice(joTmp); string error = ""; if (JsonHelper.parseIrisRtnValue(joRtn, out error) != 0) { bSuccess = false; errMsg = errMsg + "更新失败:" + error; } } if (bSuccess == true) { return 0; } else { return -1; } } catch (Exception ex) { errMsg = "UpdateLimitPrice:" + ex.Message; return -1; } } private int UpdateSelfPayProportion(JArray ja, out string errMsg) { errMsg = "更新成功"; bool bSuccess = true; try { //遍历 foreach (JObject jo in ja) { //转换为IRIS字段 JObject joTmp = new JObject(); joTmp.Add("Code", JsonHelper.getDestValue(jo, "hilist_code")); joTmp.Add("Name", ""); joTmp.Add("PersonnelType", JsonHelper.getDestValue(jo, "selfpay_prop_psn_type")); joTmp.Add("ProportionType", JsonHelper.getDestValue(jo, "selfpay_prop_type")); joTmp.Add("BeginDate", JsonHelper.getDestValue(jo, "begndate")); joTmp.Add("EndDate", JsonHelper.getDestValue(jo, "enddate")); joTmp.Add("Proportion", JsonHelper.getDestValue(jo, "selfpay_prop")); joTmp.Add("InsuranceAreaCode", JsonHelper.getDestValue(jo, "insu_admdvs")); joTmp.Add("PoolAreaNO", ""); joTmp.Add("ValidFlag", JsonHelper.getDestValue(jo, "vali_flag")); joTmp.Add("RequiredID", ""); joTmp.Add("UpdateTime", ""); JObject joRtn = mIS.UpdateDirectorySelfpayProportion(joTmp); string error = ""; if (JsonHelper.parseIrisRtnValue(joRtn, out error) != 0) { bSuccess = false; errMsg = errMsg + "更新失败:" + error; } } if (bSuccess == true) { return 0; } else { return -1; } } catch (Exception ex) { errMsg = "UpdateSelfPayProportion:" + ex.Message; return -1; } } /// /// 查询并展示医保目录信息(目录信息,限价信息,比例信息更新) /// /// /// /// private int QueryAndShowInsuDirInfo(JObject joData, out string errMsg) { errMsg = ""; try { int type = int.Parse(JsonHelper.getDestValue(joData, "type")); if (cBus.UpdateDirectory_HEB(joData, out errMsg) != 0) { return -1; } else { joDirInfoOfCenterRtn = JObject.Parse(errMsg); return ShowInsuDirInfo(type, joDirInfoOfCenterRtn, out errMsg); } } catch (Exception ex) { errMsg = ex.Message; return -1; } } /// /// 查询然后更新目录信息 /// /// /// /// private int QueryAndUpdateInsuDirInfo(JObject joData, out string errMsg) { errMsg = ""; try { if (cBus.UpdateDirectory_HEB(joData, out errMsg) != 0) { return -1; } else { joDirInfoOfCenterRtn = JObject.Parse(errMsg); return UpdateInsuDirInfo(joDirInfoOfCenterRtn, out errMsg); } } catch (Exception ex) { errMsg = ex.Message; return -1; } } /// /// 1312,限价,自付比例信息更新到后台 /// /// /// /// private int UpdateInsuDirInfo(JObject joDirInfo, out string errMsg) { errMsg = ""; try { JArray jaLimitPirceInfo = JArray.Parse(JsonHelper.getDestValue(joDirInfo, "output.lmtpric")); JArray jaSelfPayRiotInfo = JArray.Parse(JsonHelper.getDestValue(joDirInfo, "output.selfpay_array")); JObject joInsuDirInfo = JObject.Parse(JsonHelper.getDestValue(joDirInfo, "output.hilist")); if (UpdateDirBy1312(joInsuDirInfo, out errMsg) != 0) { return -1; } if (UpdateLimitPrice(jaLimitPirceInfo, out errMsg) != 0) { return -1; } if (UpdateSelfPayProportion(jaSelfPayRiotInfo, out errMsg) != 0) { return -1; } return 0; } catch (Exception ex) { errMsg = ex.Message; return -1; } } /// /// 展示1312,限价,自付比例等目录查询后的信息 /// /// /// /// /// private int ShowInsuDirInfo(int type,JObject joDirInfo, out string errMsg) { errMsg = ""; try { if (JsonHelper.parseCenterRtnValue(joDirInfo, out errMsg) != 0) { return -1; } else { JArray jaLimitPirceInfo = JArray.Parse(JsonHelper.getDestValue(joDirInfo, "output.lmtpric")); JArray jaSelfPayRiotInfo = JArray.Parse(JsonHelper.getDestValue(joDirInfo, "output.selfpay_array")); JObject joInsuDirInfo = JObject.Parse(JsonHelper.getDestValue(joDirInfo, "output.hilist")); JArray jaInsuDirInfo = new JArray(); jaInsuDirInfo.Add(joInsuDirInfo); DataTable dtLimitPriceInfo = (DataTable)jaLimitPirceInfo.ToObject(typeof(DataTable)); DataTable dtSelfPayRiotInfo = (DataTable)jaSelfPayRiotInfo.ToObject(typeof(DataTable)); DataTable dtInsuDirInfo = (DataTable)jaInsuDirInfo.ToObject(typeof(DataTable)); dgvLimitPriceInfo.DataSource = dtLimitPriceInfo; dgvSelfPayRiotInfo.DataSource = dtSelfPayRiotInfo; dgvInsuDirInfo.DataSource = dtInsuDirInfo; GridViewSetter gvs = new GridViewSetter(); gvs.SetHeaderTextOfLimitPrice(dgvLimitPriceInfo); if (type == 0)//西药 { gvs.SetHeaderTextOfMoreInfo(0, dgvMoreInfo); JObject joMoreInfo = JObject.Parse(JsonHelper.getDestValue(joDirInfo, "output.tcmpat")); JArray jaMoreInfo = new JArray(); jaMoreInfo.Add(joMoreInfo); DataTable dtMoreInfo = (DataTable)jaMoreInfo.ToObject(typeof(DataTable)); dgvMoreInfo.DataSource = dtMoreInfo; } if (type == 5) { gvs.SetHeaderTextOfMoreInfo(5, dgvMoreInfo); JObject joMoreInfo = JObject.Parse(JsonHelper.getDestValue(joDirInfo, "output.trtserv")); JArray jaMoreInfo = new JArray(); jaMoreInfo.Add(joMoreInfo); DataTable dtMoreInfo = (DataTable)jaMoreInfo.ToObject(typeof(DataTable)); dgvMoreInfo.DataSource = dtMoreInfo; } if (type == 4) { gvs.SetHeaderTextOfMoreInfo(4, dgvMoreInfo); JObject joMoreInfo = JObject.Parse(JsonHelper.getDestValue(joDirInfo, "output.mcsinfo")); JArray jaMoreInfo = new JArray(); jaMoreInfo.Add(joMoreInfo); DataTable dtMoreInfo = (DataTable)jaMoreInfo.ToObject(typeof(DataTable)); dgvMoreInfo.DataSource = dtMoreInfo; } //更新后台 tbBasicData.SelectedIndex = 2; return 0; } } catch (Exception ex) { errMsg = "" + ex.Message; return -1; } } #endregion private void btSave_2_Click(object sender, EventArgs e) { string errMsg; if (joDirInfoOfCenterRtn == null) { return; } if (JsonHelper.parseIrisRtnValue(joDirInfoOfCenterRtn, out errMsg) != 0) return; if (UpdateInsuDirInfo(joDirInfoOfCenterRtn, out errMsg) != 0) MessageBox.Show(errMsg); } private void tsmUpdateDir_Click_1(object sender, EventArgs e) { JObject joData = new JObject(); string outPar = ""; try { int dirIndex = dgvDirectoy.CurrentRow.Index; int type = -1; switch (rbgDirecType.SelectedIndex) { case 0: type = 0; break; case 1: type = 5; break; case 2: type = 4; break; } if (type == -1) { MessageBox.Show("仅支持西药,诊疗,材料的更新!"); return; } joData.Add("type", type); joData.Add("med_list_codg", dgvDirectoy.Rows[dirIndex].Cells["Code"].Value.ToString()); joData.Add("fee_ocur_time", DateTime.Now.ToString("yyyy-MM-dd")); if (QueryAndUpdateInsuDirInfo(joData, out outPar) != 0) { MessageBox.Show(outPar); } queryHISInsuDirectory(rbgDirecType.SelectedIndex, 1, 20, dgvDirectoy, Global.inf.interfaceDr); } catch (Exception ex) { MessageBox.Show("目录更新异常:" + ex.Message); } } private void toolStripMenuItem5_Click(object sender, EventArgs e) { if (!rbMaped.Checked) { MessageBox.Show("请选择已对照进行更新"); return; } DataTable dt = (DataTable)dgvHISDirectory.DataSource; //获取当前页的数据,注意在已对照页面更新 if ((dt == null) || (dt.Rows.Count < 1)) { MessageBox.Show("表中无数据,请检查!"); return; } string htype = ""; string cxno = ""; if (rbgDirecType_C.SelectedIndex == 0) { htype = "1"; cxno = "1360"; } else if (rbgDirecType_C.SelectedIndex == 1) { htype = "2"; cxno = "1365"; } else if (rbgDirecType_C.SelectedIndex == 2) { htype = "3"; cxno = "1364"; } // MessageBox.Show("第1列" + dt.Rows[0][0]); // MessageBox.Show("第1行" + dt.Rows[0].ToString()); dynamic one1312 = new JObject(); //one1312.Add("query_date", "");//查询时间点 日期型 //one1312.Add("hilist_code", "");//医保目录编码 字符型 30 one1312.Add("med_list_codg", "");//医保目录编码 字符型 30 one1312.Add("fee_ocur_time", "2022-01-01");//医保目录编码 字符型 30 //one1312.Add("insu_admdvs", "");//参保机构医保区划 字符型 6 Y //one1312.Add("begndate", ""); //开始日期 日期型 //one1312.Add("hilist_name", "");//医保目录名称 字符型 200 //one1312.Add("wubi", "");//五笔助记码 字符型 30 //one1312.Add("pinyin", "");//拼音助记码 字符型 30 //one1312.Add("med_chrgitm_type", "");//医疗收费项目类别 字符型 6 Y //one1312.Add("chrgitm_lv", "");//收费项目等级 字符型 3 Y //one1312.Add("lmt_used_flag", "");//限制使用标志 字符型 3 Y //one1312.Add("list_type", "");//目录类别 字符型 30 //one1312.Add("med_use_flag", "");//医疗使用标志 字符型 3 Y //one1312.Add("matn_used_flag", "");//生育使用标志 字符型 3 Y //one1312.Add("hilist_use_type", "");//医保目录使用类别 字符型 3 Y //one1312.Add("lmt_cpnd_type", ""); //限复方使用类型 字符型 3 Y //one1312.Add("vali_flag", "");//有效标志 字符型 3 Y //one1312.Add("updt_time", "2021-01-01");//更新时间 日期型 //one1312.Add("page_num", 1);//当前页数 数值型 4 //one1312.Add("page_size", 50);//本页数据量 数值型 4 dynamic data1312 = new JObject(); dynamic joPamam = new JObject();//更新HIS医保目录入参 //joPamam.Add("Code", ""); //joPamam.Add("Name", ""); joPamam.Add("HisType", htype); //joPamam.Add("ChargeItemLevel", ""); //joPamam.Add("ListType", ""); int i; string sfdl = ""; for (i = 0; i < dt.Rows.Count; i++) { one1312.med_list_codg = dt.Rows[i][12].ToString();//每行的第13列是医保编码 //if (htype == "3") //{ // one1312.hilist_code = dt.Rows[i][12].ToString();//每行的第13列是医保编码,长春截取15位,医保目录只有15位,武汉是20位 //} data1312.data = one1312; JObject jo1312Rtn = invoker.invokeCenterService(cxno, data1312.ToString()); if (JsonHelper.parseCenterReturnJson(jo1312Rtn, out string errorMsg) == 0) { joPamam.CeilingPrice = "999999"; joPamam.Code = dt.Rows[i][12].ToString();//哈尔滨医保查询医保编码字母都是小写 if (!string.IsNullOrEmpty(JsonHelper.getDestValue(jo1312Rtn, "output.hilist.vali_flag")))//判断返回结束时间为空的 //if (Convert.ToString(dt_result.Rows[n]["vali_flag"])=="1"&& Convert.ToString(dt_result.Rows[n]["poolarea_no"]) == "230100") { //医保返参取值 //joPamam.Code = dt_result.Rows[n][3].ToString();//长春第四位医保编码 //joPamam.Code = dt_result.Rows[i]["hilist_code"].ToString(); joPamam.Name = jo1312Rtn["output"]["hilist"]["hilist_name"]; joPamam.ChargeItemLevel = jo1312Rtn["output"]["hilist"]["chrgitm_lv"];//长春第28位收费项目等级 if (joPamam.ChargeItemLevel == "01") { joPamam.ChargeItemLevelName = "甲类"; } else if (joPamam.ChargeItemLevel == "02") { joPamam.ChargeItemLevelName = "乙类"; } else if (joPamam.ChargeItemLevel == "03") { joPamam.ChargeItemLevelName = "丙类"; } joPamam.ListType = jo1312Rtn["output"]["hilist"]["list_type"];//取医保目录类别 101 201 301 joPamam.ChargeItemType = jo1312Rtn["output"]["hilist"]["med_chrgitm_type"];//取医疗收费类别 01.02.03.... } //取医保目录价格,哈尔滨三级医院 DataTable dt_result = (DataTable)jo1312Rtn["output"]["lmtpric"].ToObject(typeof(DataTable)); if (dt_result.Rows.Count>0) { for (int n = 0; n < dt_result.Rows.Count; n++) { if (dt_result.Rows[n]["hilist_lmtpric_type"].ToString() == "3")//取医院等级为三的限价 { joPamam.CeilingPrice = dt_result.Rows[n]["hilist_pric_uplmt_amt"].ToString(); } } } JObject joRtn = mIS.UpdateDirectoryBySelf(joPamam); } } MessageBox.Show("更新完成!"); } } }