using Microsoft.Office.Core;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PTMedicalInsurance.Business;
using PTMedicalInsurance.Common;
using PTMedicalInsurance.Forms.BasicDatas.services;
using PTMedicalInsurance.FormSetter;
using PTMedicalInsurance.Helper;
using PTMedicalInsurance.Variables;
using Sunny.UI;
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 DataTable = System.Data.DataTable;
using Global = PTMedicalInsurance.Variables.Global;
namespace PTMedicalInsurance.Forms.BasicDatas
{
public partial class DirectoryMap : Form
{
private Form mainForm;
MIIrisServices mIS = new MIIrisServices();
HisIrisServices hIS = new HisIrisServices();
InvokeHelper invoker = new InvokeHelper();
private HisDirectoryCategoryEnum hisDirectoryCategory;
private MapFlagEnum mapFlag;
private int pageSize = 50;
private int currentPage = 1;
private string sortColumn = "Code";
private DirectoryMapService directoryMapService = new DirectoryMapService();
private GridViewSetter gvdSetter = new GridViewSetter();
private string errMsg;
private string directoryCategoryDesc; //目录大类中文说明,配合目录导出使用
private string mapFlagDesc; //对照标志中文说明,配合目录导出使用
private string cylCode; //柱镜度数编码
private string cylName;
private string pdCode; //棱镜度数编码
private string pdName;
public DirectoryMap()
{
InitializeComponent();
}
public DirectoryMap(Form frm)
{
InitializeComponent();
InitForm(frm);
}
/////
///// 标题设置映射字典
/////
//private Dictionary miDirHeaderTextJsonFileMap = new Dictionary
//{
// { HisDirectoryCategoryEnum.none, "Map_MiDir_Default.json" }, //对照界面中心目录药品
// { HisDirectoryCategoryEnum.drugs, "Map_MiDir_Drug.json" }, //对照界面中心目录药品
// { HisDirectoryCategoryEnum.diagnosi, "Map_MiDir_MedicalService.json" },//对照界面中心目录诊疗
// { HisDirectoryCategoryEnum.consumables, "Map_MiDir_Consumables.json" },//对照界面中心目录材料
// { HisDirectoryCategoryEnum.usedFreq, "Map_MiDir_UsedFreq.json" },//对照界面使用频次
// { HisDirectoryCategoryEnum.medcWay, "Map_MiDir_MedcWay.json" },//对照界面用法
//};
/////
///// 标题设置映射字典
/////
//private Dictionary hisDirHeaderTextJsonFileMap = new Dictionary
//{
// { HisDirectoryCategoryEnum.none, "Map_HisDir_Default.json" }, //对照界面中心目录药品
// { HisDirectoryCategoryEnum.drugs, "Map_HisDir_Drug.json" }, //对照界面HIS目录药品
// { HisDirectoryCategoryEnum.diagnosi, "Map_HisDir_MedicalService.json" },//对照界面HIS目录诊疗
// { HisDirectoryCategoryEnum.consumables, "Map_HisDir_Consumables.json" },//对照界面HIS目录材料
// { HisDirectoryCategoryEnum.usedFreq, "Map_HisDir_UsedFreq.json" },//对照界面使用频次
// { HisDirectoryCategoryEnum.medcWay, "Map_HisDir_MedcWay.json" },//对照界面用法
//};
private static Dictionary BuildMap(string prefix)
{
// 使用 typeof 获取类型,然后 Cast 回枚举类型
return Enum.GetValues(typeof(HisDirectoryCategoryEnum))
.Cast()
.ToDictionary(
e => e,
e => $"Map_{prefix}_{e}.json"
);
}
// 调用方式不变
private Dictionary miDirHeaderTextJsonFileMap = BuildMap("MiDir");
private Dictionary hisDirHeaderTextJsonFileMap = BuildMap("HisDir");
private void InitForm(Form frm)
{
mainForm = frm;
CheckForIllegalCrossThreadCalls = false;
// 禁用关闭按钮
this.FormBorderStyle = FormBorderStyle.None;
// 隐藏标题栏
this.ControlBox = false;
// 其他可能需要的配置
this.TopLevel = false;
this.Dock = DockStyle.Fill; // 根据需要设置 Dock 属性
//设置HIS字典晶体编码
SetHisDictonaryCombox(ref dblkCYL, "CrystalDegree");
SetHisDictonaryCombox(ref dblkPD, "CylindricalDegree");
//
rbgDirecType_C.SelectedIndex = 0;
rbOnlyName.Checked = rbAll.Checked = true;
//
gvdSetter.SetHeaderTextOfMapping_HisDirectory(dgvHISDirectory);
//
dgvCenterDirectory.DataError += directoryMapService.dataGridView_DataError;
}
#region
#region 控件设置
private JArray ConvertHisDicToStandardInsuDic(JArray jaHis)
{
if (jaHis == null || jaHis.Count == 0)
return new JArray(); // 或 return null; 根据调用方约定
var jaInsu = new JArray();
foreach (JObject joHis in jaHis)
{
var joInsu = new JObject
{
//["Code"] = joHis["code"]?.ToString(),
//HIS需要ID
["Code"] = joHis["id"]?.ToString(),
["Name"] = joHis["descripts"]?.ToString(),
["SearchCode"] = joHis["descriptsSPCode"]?.ToString()
};
jaInsu.Add(joInsu);
}
return jaInsu;
}
private void SetHisDictonaryCombox(ref PTControl.DBLookupCombox dblcbx,string dictType)
{
ComboxSetter comboxSetter = new ComboxSetter();
DataTable dt = comboxSetter.GetDBLKComboxTable(ConvertHisDicToStandardInsuDic(hIS.QueryHisDictionary(dictType, "")));
comboxSetter.SetDBLKCombox(ref dblcbx,dt);
}
private void SetHisDirectoryCategory()
{
switch (rbgDirecType_C.SelectedIndex)
{
case 0:
hisDirectoryCategory = HisDirectoryCategoryEnum.drugs;
directoryCategoryDesc = "药品";
break;
case 1:
hisDirectoryCategory = HisDirectoryCategoryEnum.medicalServices;
directoryCategoryDesc = "诊疗";
break;
case 2:
hisDirectoryCategory = HisDirectoryCategoryEnum.consumables;
directoryCategoryDesc = "材料";
break;
case 3:
hisDirectoryCategory = HisDirectoryCategoryEnum.Frequence;
directoryCategoryDesc = "使用频次";
break;
case 4:
hisDirectoryCategory = HisDirectoryCategoryEnum.Usage;
directoryCategoryDesc = "用药途径(用法)";
break;
default:
hisDirectoryCategory = HisDirectoryCategoryEnum.none;
break;
}
if (hisDirectoryCategory != HisDirectoryCategoryEnum.consumables)
{
ckbCryQuery.Enabled = false;
ckbCryQuery.Checked = false;
}
else
{
ckbCryQuery.Enabled = true;
}
}
private void SetMapFlag()
{
if (rbAll.Checked)
{
mapFlag = MapFlagEnum.All;
mapFlagDesc = "全部";
sortColumn = "Code";
}
else if (rbMaped.Checked)
{
mapFlag = MapFlagEnum.Mapped;
mapFlagDesc = "已对照";
sortColumn = "HisCode";
}
else if (rbNoMaped.Checked)
{
mapFlag = MapFlagEnum.NoMapped;
mapFlagDesc = "未对照";
sortColumn = "Code";
}
else
{
mapFlag = MapFlagEnum.None;
mapFlagDesc = "未知";
sortColumn = "Code";
}
}
#endregion
#region 获取入参
private JObject GetHisDictInput()
{
return hIS.GetHisDictInput(hisDirectoryCategory.ToString(),"");
}
private JObject GetHisDirInput()
{
JArray jaPagination = new JArray();
JArray jaParams = new JArray();
string 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;
//type 增加类型IOL(人工晶状体),params节点增加 CrystalDegree 柱镜度数 CylindricalDegree 棱镜度数,当且仅当type为IOL时才判断这两个入参的值。并返回符合条件的晶体
//当ytpe为IOL 时,只搜索晶体。1.code 为空,CrystalDegree 为空,CylindricalDegree 为空,返回所有晶体数据 2.code 为空,CrystalDegree 有值a,CylindricalDegree 为空,返回所有柱镜度数为a的晶体 3.code 为空,CrystalDegree 为空,CylindricalDegree 有值,报错,棱镜度数有值,柱镜度数必须有值 4.code 为空,CrystalDegree 有值a,CylindricalDegree 有值b,返回所有柱镜度数为a,棱镜度数为b的晶体
//5.code有值 a,参考上述逻辑,再返回code为a的所有晶体数据 6.CrystalDegree ,CylindricalDegree 传返回的id
if ((hisDirectoryCategory == HisDirectoryCategoryEnum.consumables) && ckbCryQuery.Checked)
{
joParam.type = "IOL";
joParam.CrystalDegree = cylCode;
joParam.CylindricalDegree = pdCode;
}
else
{
joParam.type = hisDirectoryCategory.ToString();
}
joParam.flag = mapFlag.ToString();
joParam.specInput = txtSpecFilter.Text.Trim();
jaParams.Add(joParam);
dynamic joPagination = new JObject();
joPagination.pageSize = pageSize;
//joPagination.pageSize = 2;
joPagination.currentPage = currentPage;
joPagination.sortColumn = sortColumn;
joPagination.sortOrder = "asc";
jaPagination.Add(joPagination);
JObject joRtn = new JObject();
joRtn.Add("params", jaParams);
joRtn.Add("pagination",jaPagination);
return joRtn;
}
private JObject GetInsuDirInput()
{
JObject joInput = new JObject {
{ "currentPage" , currentPage },
{ "pageSize" , pageSize },
{ "serviceCode" , "09010042" },
{ "directoryType" , (int)hisDirectoryCategory },
{ "directoryCode" , tbInsuCode.Text },
{ "directoryName" , tbCenterDirectoryFilter.Text },
{ "approvalNO" , tbApprovalNO.Text },
{ "dosageForm" , tbDosageForm.Text },
{ "specifications" , tbSpecifications.Text },
{ "manufacturers" , tbManufacturer.Text },
{ "directoryDr" , Global.inf.interfaceDr }
};
return joInput;
}
private string GetDictTypeCode()
{
switch (hisDirectoryCategory)
{
case HisDirectoryCategoryEnum.none:
case HisDirectoryCategoryEnum.drugs:
case HisDirectoryCategoryEnum.medicalServices:
case HisDirectoryCategoryEnum.consumables:
return "N/A";
case HisDirectoryCategoryEnum.Frequence:
return "USED_FRQU";
case HisDirectoryCategoryEnum.Usage:
return "MEDC_WAY";
default:
return "N/A";
}
}
private JObject GetInsuDictInput()
{
JObject joInput = new JObject {
{ "currentPage" , currentPage },
{ "pageSize" , pageSize },
{ "serviceCode" , "09010043" },
{ "directoryType" , 9 },
{ "directoryCode" , GetDictTypeCode() },
{ "directoryName" , tbCenterDirectoryFilter.Text },
{ "approvalNO" , "" },
{ "dosageForm" , "" },
{ "specifications" , "" },
{ "manufacturers" , "" },
{ "directoryDr" , Global.inf.interfaceDr }
};
return joInput;
}
///
/// 获取更新医保信息的入参
///
///
///
///
///
private JObject GetUpdateInsuInfoInput(int Index, UpdateDirecotryCondition frm, out TradeEnum trade)
{
trade = TradeEnum.MedicalServiceDirectory;
dynamic joData = new JObject();
switch (Index)
{
case 14://民族药品目
{
trade = TradeEnum.NationalityDrug;
joData.med_list_codg = frm.Code; //医疗目录编码
joData.genname_codg = ""; //通用名编号
joData.drug_genname = ""; //药品通用名
joData.drug_prodname = frm.Name; //药品商品名
joData.reg_name = ""; //注册名称
joData.tcmherb_name = ""; //中草药名称
joData.mlms_name = ""; //药材名称
joData.vali_flag = ""; //有效标志
joData.rid = ""; //唯一记录号
joData.ver = ""; //版本号
joData.ver_name = ""; //版本名称
joData.opt_begn_time = ""; //经办开始时间
joData.opt_end_time = ""; //经办结束时间
joData.updt_time = frm.UpdateTime; //更新时间
joData.page_num = frm.CurrentPage; //当前页数
joData.page_size = frm.PageSize; //本页数据量
break;
}
case 15://目录信息查询
{
trade = TradeEnum.InsuDirectory;
joData.query_date = ""; //查询时间点
joData.hilist_code = frm.Code; //医保目录编码
joData.insu_admdvs = frm.InsuAdmDvs; //参保机构医保区划
joData.begndate = ""; //开始日期
joData.hilist_name = frm.Name; //医保目录名称
joData.wubi = ""; //五笔助记码
joData.pinyin = ""; //拼音助记码
joData.med_chrgitm_type = ""; //医疗收费项目类别
joData.chrgitm_lv = ""; //收费项目等级
joData.lmt_used_flag = ""; //限制使用标志
joData.list_type = ""; //目录类别
joData.med_use_flag = ""; //医疗使用标志
joData.matn_used_flag = ""; //生育使用标志
joData.hilist_use_type = ""; //医保目录使用类别
joData.lmt_cpnd_type = ""; //限复方使用类型
joData.vali_flag = ""; //有效标志
joData.updt_time = frm.UpdateTime; //更新时间
joData.page_num = frm.CurrentPage; //当前页数
joData.page_size = frm.PageSize; //本页数据量
break;
}
case 16://医疗与医保目录匹配
{
trade = TradeEnum.MedicalAndInsuDirectory;
joData.query_date = ""; //查询时间点
joData.medins_list_codg = ""; //定点医药机构目录编号
joData.hilist_code = frm.Code; //医保目录编码
joData.list_type = ""; //目录类别
joData.insu_admdvs = frm.InsuAdmDvs; //参保机构医保区划
joData.begndate = ""; //开始日期
joData.vali_flag = ""; //有效标志
joData.updt_time = frm.UpdateTime; //更新时间
joData.page_num = frm.CurrentPage; //当前页数
joData.page_size = frm.PageSize; //本页数据量
break;
}
case 17://医药机构目录匹配
{
trade = TradeEnum.MedcineOrgDirectory;
joData.query_date = ""; //查询时间点
joData.fixmedins_code = ""; //定点医药机构编号
joData.medins_list_codg = ""; //定点医药机构目录编号
joData.medins_list_name = ""; //定点医药机构目录名称
joData.insu_admdvs = frm.InsuAdmDvs; //参保机构医保区划
joData.list_type = ""; //目录类别
joData.med_list_codg = frm.Code; //医疗目录编码
joData.begndate = ""; //开始日期
joData.vali_flag = ""; //有效标志
joData.updt_time = frm.UpdateTime; //更新时间
joData.page_num = frm.CurrentPage; //当前页数
joData.page_size = frm.PageSize; //本页数据量
break;
}
case 18://医保目录限价
{
trade = TradeEnum.InsuPriceLimitDirectory;
joData.query_date = ""; //查询时间点
joData.hilist_code = frm.Code; //医保目录编码
joData.hilist_lmtpric_type = ""; //医保目录限价类型
joData.overlmt_dspo_way = ""; //医保目录超限处理方式
joData.insu_admdvs = frm.InsuAdmDvs; //参保机构医保区划
joData.begndate = ""; //开始日期
joData.enddate = ""; //结束日期
joData.vali_flag = ""; //有效标志
joData.rid = ""; //唯一记录号
joData.tabname = ""; //表名
joData.poolarea_no = ""; //统筹区
joData.updt_time = frm.UpdateTime; //更新时间
joData.page_num = frm.CurrentPage; //当前页数
joData.page_size = frm.PageSize; //本页数据量
break;
}
case 19://医保目录先自付比例
{
trade = TradeEnum.PrepayPercentDirectory;
joData.query_date = ""; //查询时间点
joData.hilist_code = frm.Code; //医保目录编码
joData.selfpay_prop_psn_type = "";//医保目录自付比例人员类别
joData.selfpay_prop_type = ""; //目录自付比例类别
joData.insu_admdvs = frm.InsuAdmDvs; //参保机构医保区划
joData.begndate = ""; //开始日期
joData.enddate = ""; //结束日期
joData.vali_flag = ""; //有效标志
joData.rid = ""; //唯一记录号
joData.tabname = ""; //表名
joData.poolarea_no = ""; //统筹区
joData.updt_time = frm.UpdateTime; //更新时间
joData.page_num = frm.CurrentPage; //当前页数
joData.page_size = frm.PageSize; //本页数据量
break;
}
}
return joData;
}
#endregion
#region 查询
private void Query()
{
dgvHISDirectory.SelectionChanged -= dgvHISDirectory_SelectionChanged;
try
{
switch (rbgDirecType_C.SelectedIndex)
{
case 0:
case 1:
case 2:
QueryDirectory();
break;
case 3:
case 4://查询HIS的字典数据,暂无分页
QueryDictionary();
break;
default:
break;
}
}
catch (Exception)
{
throw;
}
finally
{
dgvHISDirectory.SelectionChanged += dgvHISDirectory_SelectionChanged;
}
}
private void QueryDirectory()
{
JObject joRtn = new JObject();
joRtn = directoryMapService.QueryDirectory(GetHisDirInput(), mapFlag);
if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
{
MessageBox.Show(errMsg);
}
else
{
DataTable dt = (DataTable)joRtn["result"]["Data"].ToObject(typeof(DataTable));
int totalCount = int.Parse(joRtn["result"]["TotalCount"].ToString());
pgHISDirect.TotalCount = totalCount;
pgHISDirect.PageSize = pageSize;
dgvHISDirectory.DataSource = dt;
if (directoryMapService.SetDgvDirectoryHeader(hisDirHeaderTextJsonFileMap.GetValue(hisDirectoryCategory), dgvHISDirectory, out errMsg) != 0)
{
MessageBox.Show(errMsg);
return;
}
dgvHISDirectory.Columns[0].ReadOnly = true;
}
}
private void QueryDictionary()
{
JObject joRtn = new JObject();
joRtn = directoryMapService.QueryDictionary(GetHisDictInput(), mapFlag,GetDictTypeCode());
if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0)
{
MessageBox.Show(errMsg);
}
else
{
DataTable dt = (DataTable)joRtn["result"]["Data"].ToObject(typeof(DataTable));
pgHISDirect.PageSize = pageSize;
dgvHISDirectory.DataSource = dt;
if (directoryMapService.SetDgvDirectoryHeader(hisDirHeaderTextJsonFileMap.GetValue(hisDirectoryCategory), dgvHISDirectory, out errMsg) != 0)
{
MessageBox.Show(errMsg);
return;
}
dgvHISDirectory.Columns[0].ReadOnly = true;
}
}
private void QueryMi()
{
switch (rbgDirecType_C.SelectedIndex)
{
case 0:
case 1:
case 2:
QueryMiDirectory();
break;
case 3:
case 4://查询HIS的字典数据,暂无分页
QueryMiDictionary();
break;
default:
break;
}
}
private void QueryMiDirectory()
{
JObject joRtn = new JObject();
joRtn = directoryMapService.QueryMiDirectory(GetInsuDirInput());
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("未查询到数据");
dgvCenterDirectory.DataSource = null;
return;
}
DataTable dt = (DataTable)joRtn["result"]["rows"].ToObject(typeof(DataTable));
int totalCount = int.Parse(joRtn["result"]["total"].ToString());
pgCenterDirect.TotalCount = totalCount;
pgCenterDirect.PageSize = pageSize;
dgvCenterDirectory.DataSource = dt;
if (directoryMapService.SetDgvDirectoryHeader(miDirHeaderTextJsonFileMap.GetValue(hisDirectoryCategory), dgvCenterDirectory, out errMsg) != 0)
{
MessageBox.Show(errMsg);
return;
}
dgvCenterDirectory.Columns[0].ReadOnly = true;
}
private void QueryMiDictionary()
{
JObject joRtn = new JObject();
switch (rbgDirecType_C.SelectedIndex)
{
case 0:
case 1:
case 2:
joRtn = directoryMapService.QueryMiDirectory(GetInsuDirInput());
break;
case 3:
case 4://查询HIS的字典数据,暂无分页
joRtn = directoryMapService.QueryMiDictionary(GetInsuDictInput());
break;
default:
break;
}
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("未查询到数据");
dgvCenterDirectory.DataSource = null;
return;
}
DataTable dt = (DataTable)joRtn["result"]["rows"].ToObject(typeof(DataTable));
int totalCount = int.Parse(joRtn["result"]["total"].ToString());
pgCenterDirect.TotalCount = totalCount;
pgCenterDirect.PageSize = pageSize;
dgvCenterDirectory.DataSource = dt;
if (directoryMapService.SetDgvDirectoryHeader(miDirHeaderTextJsonFileMap.GetValue(hisDirectoryCategory), dgvCenterDirectory, out errMsg) != 0)
{
MessageBox.Show(errMsg);
return;
}
dgvCenterDirectory.Columns[0].ReadOnly = true;
}
#endregion
#region 对照
private void Mapping()
{
switch (rbgDirecType_C.SelectedIndex)
{
case 0:
case 1:
case 2:
DirectoryMapping();
break;
case 3:
case 4://查询HIS的字典数据,暂无分页
DictionaryMapping();
break;
default:
break;
}
}
private void DictionaryMapping()
{
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["descripts"].Value.ToString();
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["code"].Value;
jsonTemp.HISName = dgvHISDirectory.Rows[iHis].Cells["descripts"].Value;
jsonTemp.ChargeItemDr = dtHis.Rows[iHis]["id"];
jsonTemp.DiretoryDr = dtCenter.Rows[iCenter]["dictionaryDataDetailID"];
//1.已对照 2.已对照但未上传 3 已对照且已上传
jsonTemp.State = 1;
jsonTemp.HisType = $"DIC-{GetDictTypeCode()}";
jsonTemp.HisTypeName = rbgDirecType_C.Items[(int)hisDirectoryCategory - 1].ToString();
jsonTemp.InsuCode = dgvCenterDirectory.Rows[dgvCenterDirectory.CurrentRow.Index].Cells["code"].Value;
jsonTemp.InsuName = dgvCenterDirectory.Rows[dgvCenterDirectory.CurrentRow.Index].Cells["descripts"].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 = "已对照";
//dgvHISDirectory.Rows[iHis].Cells["MapID"].Value =joRtn["data"]["mapID"].ToString();
//dtHis.Rows[iHis]["MapID"] = joRtn["data"]["mapID"].ToString();
}
else
{
dgvHISDirectory.Rows[iHis].Cells["flag"].Value = "对照失败";
}
}
private void DirectoryMapping()
{
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();
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.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 = (int)hisDirectoryCategory;
jsonTemp.HisTypeName = rbgDirecType_C.Items[(int)hisDirectoryCategory - 1].ToString();
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 = "已对照";
//dgvHISDirectory.Rows[iHis].Cells["MapID"].Value = joRtn["data"]["mapID"].ToString();
//dtHis.Rows[iHis]["MapID"] = joRtn["data"]["mapID"].ToString();
}
else
{
dgvHISDirectory.Rows[iHis].Cells["flag"].Value = "对照失败";
}
}
private void CancelMapping()
{
switch (rbgDirecType_C.SelectedIndex)
{
case 0:
case 1:
case 2:
CancelDirectoryMapping();
break;
case 3:
case 4://查询HIS的字典数据,暂无分页
CancelDictionaryMapping();
break;
default:
break;
}
}
private void CancelDirectoryMapping()
{
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 = "";
dgvHISDirectory.Rows[iHis].Cells["MapID"].Value = 0;
}
else
{
dgvHISDirectory.Rows[iHis].Cells["flag"].Value = "取消失败";
}
}
private void CancelDictionaryMapping()
{
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["code"].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 = "";
dgvHISDirectory.Rows[iHis].Cells["MapID"].Value = 0;
}
else
{
dgvHISDirectory.Rows[iHis].Cells["flag"].Value = "取消失败";
}
}
#endregion
#region 导出
private int queryExportData_CallBack(DataLoaderContext context, out string errMsg)
{
errMsg = "";
return 0;
}
#endregion
#region 批量更新
private void batchUpdateMappedInsuInfo(int index)
{
//获取入参条件
TradeEnum trade;
JObject joCondition = new JObject();
UpdateDirecotryCondition updateDirecotryCondition = new UpdateDirecotryCondition();
if (updateDirecotryCondition.ShowDialog() == DialogResult.Cancel)
{
//MessageBox.Show("");
return;
}
else
{
joCondition = GetUpdateInsuInfoInput(index,updateDirecotryCondition,out trade);
joCondition.Add("funno", trade.GetCode());
}
//查表
string sqlStr = $"select * from HB_MedInsuMapRelation where Interface_Dr='{Global.inf.interfaceDr}' and Hospital_Dr ='{Global.inf.hospitalDr}'";
JObject joSqlstr = new JObject();
joSqlstr.Add("sqlStr", sqlStr);
JObject joRtn = mIS.QueryMappedData(joSqlstr, "查询所有已对照数据");
JObject joResult = JObject.FromObject(joRtn["result"]);
joResult.Add("condition", joCondition);
directoryMapService.batchUpdateMappedInsuInfo(joResult, this);
}
#endregion
#endregion
private void btTripMenu_Click(object sender, EventArgs e)
{
cmsIntegratedMenu.Show(((Sunny.UI.UIButton)sender), new Point(0, btTripMenu.Height));
}
private void rbgDirecType_C_ValueChanged(object sender, int index, string text)
{
SetHisDirectoryCategory();
}
private void rbAll_ValueChanged(object sender, bool value)
{
SetMapFlag();
}
private void btnQueryHISDirectory_Click(object sender, EventArgs e)
{
currentPage = 1;
Query();
}
private void tsmExportAllMappedData_Click(object sender, EventArgs e)
{
MessageBox.Show("请点击按左侧类别导出!");
}
private void tsmExportMappedDataByLeft_Click(object sender, EventArgs e)
{
ProgressWrapper _dataLoader;
_dataLoader = new ProgressWrapper(queryExportData_CallBack, this);
_dataLoader.SetProgressBar(ProgressBarStyle.Marquee, "正在导出...", 50);
_dataLoader.Start(new object[] { 0 }, (result, errMsg) =>
{
// 在这里处理结果和错误信息
if (result == 0)
{
MessageBox.Show(errMsg);
}
else
{
MessageBox.Show(errMsg);
}
});
}
private void pgHISDirect_PageChanged(object sender, object pagingSource, int pageIndex, int count)
{
//当两者均为1说明点击的是查询按钮
if (!((currentPage == 1) && (pageIndex == 1)))
{
currentPage = pageIndex;
Query();
}
}
private void btnQueryCenterDirectory_Click(object sender, EventArgs e)
{
currentPage = 1;
QueryMi();
}
private void pgCenterDirect_PageChanged(object sender, object pagingSource, int pageIndex, int count)
{
if (!((currentPage == 1) && (pageIndex == 1)))
{
currentPage = pageIndex;
QueryMi();
}
}
private void tsmiMapping_Click(object sender, EventArgs e)
{
Mapping();
}
private void tsmiCancleMapping_Click(object sender, EventArgs e)
{
CancelMapping();
}
private void tsmUpdateCellPriceOfAllMapped_Click(object sender, EventArgs e)
{
batchUpdateMappedInsuInfo(18);
}
private void btSetCenterDirHeaderText_Click(object sender, EventArgs e)
{
//获取数据源
DataGridViewHeaderSetForm frm = new DataGridViewHeaderSetForm(miDirHeaderTextJsonFileMap.GetValue(hisDirectoryCategory), (DataTable)dgvCenterDirectory.DataSource);
frm.StartPosition = FormStartPosition.CenterParent;
if (frm.ShowDialog() == DialogResult.OK)
{
}
}
private void btSetHisDirHeaderText_Click(object sender, EventArgs e)
{
//获取数据源
DataGridViewHeaderSetForm frm = new DataGridViewHeaderSetForm(hisDirHeaderTextJsonFileMap.GetValue(hisDirectoryCategory), (DataTable)dgvHISDirectory.DataSource);
frm.StartPosition = FormStartPosition.CenterParent;
if (frm.ShowDialog() == DialogResult.OK)
{
}
}
private void dgvHISDirectory_SelectionChanged(object sender, EventArgs e)
{
switch (rbgDirecType_C.SelectedIndex)
{
case 0:
case 1:
case 2:
dgvHISDirectory_directory_SelectionChanged(sender,e);
break;
case 3:
case 4://查询HIS的字典数据,暂无分页
dgvHISDirectory_Dict_SelectionChanged(sender, e);
break;
default:
break;
}
}
private void dgvHISDirectory_directory_SelectionChanged(object sender, EventArgs e)
{
DataGridViewRow dr = dgvHISDirectory.CurrentRow;
if (dr == null)
{
return; // 防止没有选中行
}
if (!dgvHISDirectory.Columns.Contains("InsuCode"))
{
Global.writeLog("未找到InsuCode");
// 可以在这里调试:打印所有列名
foreach (DataGridViewColumn col in dgvHISDirectory.Columns)
{
System.Diagnostics.Debug.WriteLine($"列名: {col.Name}");
Global.writeLog($"列名: {col.Name},值:{dr.Cells[col.Name].Value}");
}
return;
}
// 先检查列是否存在
DataGridViewCell cell = dr.Cells["InsuCode"];
if (cell == null || cell.Value == null || cell.Value == DBNull.Value)
{
return;
}
if (cell != null)
{
if (cell.Value.ToString() != "")
{
tbInsuCode.Text = cell.Value.ToString();
tbCenterDirectoryFilter.Text = "";
tbApprovalNO.Text = "";
}
else
{
tbInsuCode.Text = "";
if (rbOnlyName.Checked)
{
tbInsuCode.Text = "";
tbApprovalNO.Text = "";
tbCenterDirectoryFilter.Text = "%" + dr.Cells["itemDesc"].Value.ToString() + "%";
}
if (rbOnlyApprNO.Checked)
{
tbCenterDirectoryFilter.Text = "";
tbInsuCode.Text = "";
tbApprovalNO.Text = "%" + dr.Cells["pprovalNo"].Value.ToString() + "%";
}
if (rbBoth.Checked)
{
tbInsuCode.Text = "";
tbCenterDirectoryFilter.Text = "%" +dr.Cells["itemDesc"].Value.ToString() + "%";
tbApprovalNO.Text = "%" + dr.Cells["pprovalNo"].Value.ToString() + "%";
}
}
}
}
private void dgvHISDirectory_Dict_SelectionChanged(object sender, EventArgs e)
{
DataGridViewRow dr = dgvHISDirectory.CurrentRow;
if (dr == null)
{
return; // 防止没有选中行
}
if (!dgvHISDirectory.Columns.Contains("InsuCode"))
{
Global.writeLog("未找到InsuCode");
// 可以在这里调试:打印所有列名
foreach (DataGridViewColumn col in dgvHISDirectory.Columns)
{
System.Diagnostics.Debug.WriteLine($"列名: {col.Name}");
Global.writeLog($"列名: {col.Name},值:{dr.Cells[col.Name].Value}");
}
return;
}
// 先检查列是否存在
DataGridViewCell cell = dr.Cells["InsuCode"];
if (cell == null || cell.Value == null || cell.Value == DBNull.Value)
{
return;
}
if (cell != null)
{
if (cell.Value.ToString() != "")
{
tbInsuCode.Text = cell.Value.ToString();
tbCenterDirectoryFilter.Text = "";
tbApprovalNO.Text = "";
}
else
{
tbInsuCode.Text = "";
tbInsuCode.Text = "";
tbApprovalNO.Text = "";
//tbCenterDirectoryFilter.Text = "%" + dr.Cells["descripts"].Value.ToString() + "%";
tbCenterDirectoryFilter.Text = dr.Cells["descripts"].Value.ToString() ;
//if (rbOnlyName.Checked)
//{
// tbInsuCode.Text = "";
// tbApprovalNO.Text = "";
// tbCenterDirectoryFilter.Text = "%" + dr.Cells["descripts"].Value.ToString() + "%";
//}
//if (rbOnlyApprNO.Checked)
//{
// tbCenterDirectoryFilter.Text = "";
// tbInsuCode.Text = "";
// tbApprovalNO.Text = "%" + dr.Cells["pprovalNo"].Value.ToString() + "%";
//}
//if (rbBoth.Checked)
//{
// tbInsuCode.Text = "";
// tbCenterDirectoryFilter.Text = "%" + dr.Cells["itemDesc"].Value.ToString() + "%";
// tbApprovalNO.Text = "%" + dr.Cells["pprovalNo"].Value.ToString() + "%";
//}
}
}
}
private void ckbCryQuery_CheckedChanged(object sender, EventArgs e)
{
if (ckbCryQuery.Checked)
{
gbCryLocaled.Enabled = true;
}
else
{
dblkCYL.Text = "";
dblkPD.Text = "";
gbCryLocaled.Enabled = false;
}
}
private void dblkCYL_AfterSelector(object sender, PTControl.AfterSelectorEventArgs e)
{
DataGridViewRow row = e.Value as DataGridViewRow;
DataRowView dataRow = row.DataBoundItem as DataRowView;
cylCode = dataRow["Code"].ToString().Trim();
cylName = dataRow["Name"].ToString().Trim();
}
private void dblkPD_AfterSelector(object sender, PTControl.AfterSelectorEventArgs e)
{
DataGridViewRow row = e.Value as DataGridViewRow;
DataRowView dataRow = row.DataBoundItem as DataRowView;
pdCode = dataRow["Code"].ToString().Trim();
pdName = dataRow["Name"].ToString().Trim();
}
}
}