using Newtonsoft.Json.Linq;
using PTMedicalInsurance.Common;
using PTMedicalInsurance.Helper;
using PTMedicalInsurance.Variables;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml.Linq;
namespace PTMedicalInsurance.Business.HIS
{
///
/// HIS下载业务
///
class DownLoad
{
private PTMedicalInsurance.Business.Center.DownLoad cDL = new PTMedicalInsurance.Business.Center.DownLoad();
private PTMedicalInsurance.Business.MI.DataImport mDI = new PTMedicalInsurance.Business.MI.DataImport();
///
/// 根据指定版本号下载医保目录
///
///
///
///
///
///
public int DownloadMIDiretoryBySpecifyVerNO(string ver, int directoryType, Control uiProcessBar, out string errMsg, out string currentMaxVerNO )
{
string txtPath = string.Empty;
currentMaxVerNO = "";
errMsg = "";
int iResult = -1;
string funNo = "";
XElement xe = new XElement("input","") ;
string fileName = DateTime.Now.ToString("yyyyMMddHHmmssffff");
switch (directoryType)
{
case 0://医保目录
{
funNo = "91A"; //"1301";
xe = new XElement("input",
new XElement("prm_aaalsh", ver),
new XElement("prm_outputfile", Global.curEvt.path + "\\DownLoad\\" + fileName + "_" + funNo + ".txt"));
break;
}
case 1://ICD10
{
funNo = "61";
xe = new XElement("input",
new XElement("prm_aaalsh", ver),
new XElement("prm_outputfile", Global.curEvt.path + "\\DownLoad\\" + fileName + "_" + funNo + ".txt"));
break;
}
case 2://字典
{
funNo = "57";
break;
}
case 3://国家医生编码
{
funNo = "GB001";
xe = new XElement("input",
new XElement("prm_akb020", Global.inf.hospitalNO),
new XElement("page_num",1),
new XElement("page_size", 999),
new XElement("prm_outputfile", Global.curEvt.path + "\\DownLoad\\" + fileName + "_" + funNo + ".txt"));
break;
}
case 4://国家护士编码
{
funNo = "GB002";
xe = new XElement("input",
new XElement("prm_akb020", Global.inf.hospitalNO),
new XElement("page_num", 1),
new XElement("page_size", 999),
new XElement("prm_outputfile", Global.curEvt.path + "\\DownLoad\\" + fileName + "_" + funNo + ".txt"));
break;
}
case 5://国家医院机构信息
{
funNo = "GB003";
xe = new XElement("input",
new XElement("prm_akb020", Global.inf.hospitalNO),
new XElement("prm_outputfile", Global.curEvt.path + "\\DownLoad\\" + fileName + "_" + funNo + ".txt"));
break;
}
case 6://自付比例
{
funNo = "91C"; //"1301";
xe = new XElement("input",
new XElement("prm_aaalsh", ver),
new XElement("prm_outputfile", Global.curEvt.path + "\\DownLoad\\" + fileName + "_" + funNo + ".txt"));
break;
}
case 7://医保限价
{
funNo = "91B"; //"1301";
xe = new XElement("input",
new XElement("prm_aaalsh", ver),
new XElement("prm_outputfile", Global.curEvt.path + "\\DownLoad\\" + fileName + "_" + funNo + ".txt"));
break;
}
}
try
{
JObject joRtn = new JObject();
if (directoryType == 2)
joRtn = cDL.DownloadDictionary(funNo, xe);
else
joRtn = cDL.DownloadDirectory(funNo,xe);
if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) == 0)
{
JObject joImportRtn = new JObject();
switch (directoryType)
{
case 0://医保目录 导入目录表
{
txtPath = JsonHelper.getDestValue(joRtn, "result.input.prm_outputfile");
joImportRtn = mDI.insertDirectoryToMIIrisByTxt(txtPath, 50, directoryType, (Sunny.UI.UIProcessBar)uiProcessBar,out currentMaxVerNO );
break;
}
case 1://ICD10 导入目录表
{
txtPath = JsonHelper.getDestValue(joRtn, "result.input.prm_outputfile");
joImportRtn = mDI.insertDirectoryToMIIrisByTxt(txtPath, 50, directoryType, (Sunny.UI.UIProcessBar)uiProcessBar, out currentMaxVerNO);
break;
}
case 2://字典 导入字典表
{
JArray jaList = JArray.Parse(JsonHelper.getDestValue(joRtn, "result.output.sqldata.row"));
joImportRtn = mDI.importDictionary((Sunny.UI.UIProcessBar)uiProcessBar, jaList);
break;
}
case 3://国家医生编码 前台展示
{
try
{
txtPath = JsonHelper.getDestValue(joRtn, "result.input.prm_outputfile");
DataTable dt = TxtHelper.ToDataTable(txtPath, 16);
PTMedicalInsurance.Forms.BasicDatas.FormSetter fs = new Forms.BasicDatas.FormSetter();
fs.SetHeaderTextOfDownloadDoctorInfo((DataGridView)uiProcessBar);
((DataGridView)uiProcessBar).DataSource = dt;
joImportRtn = JsonHelper.setIrisReturnValue(0,"",null);
}
catch (Exception subEx)
{
joImportRtn = JsonHelper.setIrisReturnValue(0, subEx.Message, null);
}
break;
}
case 4://国家护士编码 前台展示
{
try
{
txtPath = JsonHelper.getDestValue(joRtn, "result.input.prm_outputfile");
DataTable dt = TxtHelper.ToDataTable(txtPath, 14);
PTMedicalInsurance.Forms.BasicDatas.FormSetter fs = new Forms.BasicDatas.FormSetter();
fs.SetHeaderTextOfDownloadNurseInfo((DataGridView)uiProcessBar);
((DataGridView)uiProcessBar).DataSource = dt;
joImportRtn = JsonHelper.setIrisReturnValue(0, "", null);
}
catch (Exception subEx)
{
joImportRtn = JsonHelper.setIrisReturnValue(0, subEx.Message, null);
}
break;
}
case 5://国家医院机构信息 前台展示
{
try
{
txtPath = JsonHelper.getDestValue(joRtn, "result.input.prm_outputfile");
DataTable dt = TxtHelper.ToDataTable(txtPath, 32);
PTMedicalInsurance.Forms.BasicDatas.FormSetter fs = new Forms.BasicDatas.FormSetter();
fs.SetHeaderTextOfDownloadHospitalInfo((DataGridView)uiProcessBar);
((DataGridView)uiProcessBar).DataSource = dt;
joImportRtn = JsonHelper.setIrisReturnValue(0, "", null);
}
catch (Exception subEx)
{
joImportRtn = JsonHelper.setIrisReturnValue(0, subEx.Message, null);
}
break;
}
case 6://医保目录自付比例 导入目录表
{
txtPath = JsonHelper.getDestValue(joRtn, "result.input.prm_outputfile");
joImportRtn = mDI.insertDirectoryToMIIrisByTxt(txtPath, 50, directoryType, (Sunny.UI.UIProcessBar)uiProcessBar, out currentMaxVerNO);
break;
}
case 7://医保限价 导入目录表
{
txtPath = JsonHelper.getDestValue(joRtn, "result.input.prm_outputfile");
joImportRtn = mDI.insertDirectoryToMIIrisByTxt(txtPath, 50, directoryType, (Sunny.UI.UIProcessBar)uiProcessBar, out currentMaxVerNO);
break;
}
}
if (JsonHelper.parseIrisRtnValue(joImportRtn, out errMsg) == 0)
{
iResult = 0;
}
else
{
errMsg = "导入数据出现错误,请查看日志!" + errMsg;//joImportRtn["errorMessage"].ToString();
}
}
return iResult;
}
catch (Exception ex)
{
errMsg = "PTMedicalInsurance.Business.HIS.DownLoad.DownloadMIDiretoryBySpecifyVerNO提示:" + ex.Message;
return -1;
}
}
}
}