1574 lines
100 KiB
C#
1574 lines
100 KiB
C#
using Newtonsoft.Json;
|
||
using RabbitMQ.Client;
|
||
using RabbitMQ.Client.Events;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.ComponentModel;
|
||
using System.Configuration;
|
||
using System.Data;
|
||
using System.Diagnostics;
|
||
using System.Drawing;
|
||
using System.Drawing.Imaging;
|
||
using System.IO;
|
||
using System.Linq;
|
||
using System.Net;
|
||
using System.Text;
|
||
using System.Text.RegularExpressions;
|
||
using System.Threading;
|
||
using System.Windows.Forms;
|
||
using System.Xml;
|
||
using System.Xml.Linq;
|
||
using 云心电ECG数据解析服务端;
|
||
|
||
namespace _1200gFtp
|
||
{
|
||
public partial class Form1 : Form
|
||
{
|
||
public Form1()
|
||
{
|
||
InitializeComponent();
|
||
}
|
||
FileSystemWatcher watcher = new FileSystemWatcher();
|
||
OssUnity oss = new OssUnity();
|
||
private void Form1_Load(object sender, EventArgs e)
|
||
{
|
||
//this.WindowState = FormWindowState.Minimized;
|
||
textBox1.Text = File.ReadAllText(Application.StartupPath + @"\dataPath.txt");
|
||
}
|
||
|
||
/// <summary>
|
||
/// 初始化监听
|
||
/// </summary>
|
||
/// <param name="StrWarcherPath">需要监听的目录</param>
|
||
/// <param name="FilterType">需要监听的文件类型(筛选器字符串)</param>
|
||
/// <param name="IsEnableRaising">是否启用监听</param>
|
||
/// <param name="IsInclude">是否监听子目录</param>
|
||
private void WatcherStrat(string StrWarcherPath, string FilterType, bool IsEnableRaising, bool IsInclude)
|
||
{
|
||
//初始化监听
|
||
watcher.BeginInit();
|
||
//设置监听文件类型
|
||
watcher.Filter = FilterType;
|
||
//设置是否监听子目录
|
||
watcher.IncludeSubdirectories = IsInclude;
|
||
//设置是否启用监听?
|
||
watcher.EnableRaisingEvents = IsEnableRaising;
|
||
//设置需要监听的更改类型(如:文件或者文件夹的属性,文件或者文件夹的创建时间;NotifyFilters枚举的内容)
|
||
watcher.NotifyFilter = NotifyFilters.Attributes | NotifyFilters.CreationTime | NotifyFilters.DirectoryName | NotifyFilters.FileName | NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.Security | NotifyFilters.Size;
|
||
//设置监听的路径
|
||
watcher.Path = StrWarcherPath;
|
||
//注册创建文件或目录时的监听事件
|
||
watcher.Created += new FileSystemEventHandler(watch_created);
|
||
watcher.Changed += new FileSystemEventHandler(watch_changed);
|
||
//结束初始化
|
||
watcher.EndInit();
|
||
}
|
||
|
||
private void watch_changed(object sender, FileSystemEventArgs e)
|
||
{
|
||
////事件内容
|
||
//string fileName = e.FullPath;
|
||
//if (System.IO.Path.GetExtension(fileName).ToUpper().Equals(".XML", StringComparison.CurrentCultureIgnoreCase))
|
||
// ftpDataPost(fileName);
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 获取文件MD5值
|
||
/// </summary>
|
||
/// <param name="fileName">文件绝对路径</param>
|
||
/// <returns>MD5值</returns>
|
||
public static string GetMD5HashFromFile(string fileName)
|
||
{
|
||
try
|
||
{
|
||
FileStream file = new FileStream(fileName, FileMode.Open);
|
||
System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
|
||
byte[] retVal = md5.ComputeHash(file);
|
||
file.Close();
|
||
|
||
StringBuilder sb = new StringBuilder();
|
||
for (int i = 0; i < retVal.Length; i++)
|
||
{
|
||
sb.Append(retVal[i].ToString("X2"));
|
||
}
|
||
return sb.ToString();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
throw new Exception("GetMD5HashFromFile() fail,error:" + ex.Message);
|
||
}
|
||
}
|
||
|
||
|
||
///编码
|
||
public static string EncodeBase64(string code_type, string code)
|
||
{
|
||
string encode = "";
|
||
byte[] bytes = Encoding.GetEncoding(code_type).GetBytes(code);
|
||
try
|
||
{
|
||
encode = Convert.ToBase64String(bytes);
|
||
}
|
||
catch
|
||
{
|
||
encode = code;
|
||
}
|
||
return encode;
|
||
}
|
||
///解码
|
||
public static string DecodeBase64(string code_type, string code)
|
||
{
|
||
string decode = "";
|
||
byte[] bytes = Convert.FromBase64String(code);
|
||
try
|
||
{
|
||
decode = Encoding.GetEncoding(code_type).GetString(bytes);
|
||
}
|
||
catch
|
||
{
|
||
decode = code;
|
||
}
|
||
return decode;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 将患者姓名 和 his结果里的患者姓名进行对比 如果姓名匹配 那么就将这个人的 patientid 修改为 his结果里的 jianchaid
|
||
/// </summary>
|
||
/// <param name="FHEDM"></param>
|
||
patientInfo ComparePatientInfo(FlyHisEcgDataModel FHEDM, string pName)
|
||
{
|
||
if (!string.IsNullOrEmpty(pName))
|
||
{
|
||
for (int i = 0; i < FHEDM.rows.Count; i++)
|
||
|
||
if (FHEDM.rows[i].name == pName)
|
||
{
|
||
return FHEDM.rows[i];
|
||
}
|
||
}
|
||
else
|
||
return null;
|
||
|
||
return null;
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 提交诊断结论到福乐云
|
||
/// </summary>
|
||
/// <param name=""></param>
|
||
string submitInfoToFLY(FLYecgReport FER)
|
||
{
|
||
string jsonContent = JsonConvert.SerializeObject(FER);
|
||
string token = commonOptions.gettoken(ConfigurationManager.AppSettings["flowygtUserName"], ConfigurationManager.AppSettings["flowygtUserPwd"], ConfigurationManager.AppSettings["flowygtLoginUrl"]);//获取token
|
||
string resultStr = commonOptions.PostByParas(ConfigurationManager.AppSettings["flowygtReportAddUrl"], token, jsonContent);
|
||
return resultStr;
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 上传诊断结论到福乐云平台
|
||
/// </summary>
|
||
string FlySubmit(string patientId, int status1)
|
||
{
|
||
//上传报告到福乐云平台
|
||
FLYecgReport FER = new FLYecgReport();
|
||
FER.appointmentId = patientId;
|
||
FER.status = status1;//状态 0-已预约 1-已登记 2-审核中 3-已上传报告 4-查看报告8-撤回登记 9-取消预约 7-检查中 5-.放弃诊断 6.-已退费
|
||
return submitInfoToFLY(FER);
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 上传心电图图片文件到福乐云平台
|
||
/// </summary>
|
||
void FlyEcgReportFileSubmit(string appointment_id, string imgPath)
|
||
{
|
||
byte[] fileData = File.ReadAllBytes(imgPath);
|
||
FileInfo fileInfo = new FileInfo(imgPath);
|
||
Dictionary<string, object> dic = new Dictionary<string, object>();
|
||
dic.Add("appointment_id", appointment_id);
|
||
string token = commonOptions.gettoken(ConfigurationManager.AppSettings["flowygtUserName"], ConfigurationManager.AppSettings["flowygtUserPwd"], ConfigurationManager.AppSettings["flowygtLoginUrl"]);//获取token
|
||
commonOptions.PostFile2(ConfigurationManager.AppSettings["flowygtUploadFileUrl"], imgPath, dic, token);
|
||
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 提交患者信息到福乐云
|
||
/// </summary>
|
||
/// <param name=""></param>
|
||
string submitPatientInfoToFLY(string patientId1,string examid,string orgid,string orgname)
|
||
{
|
||
|
||
string sql = "select * from tb_patientexamlist where regId='" + patientId1 + "' and examId='"+ examid + "'";
|
||
DataTable dt_1 = MySQLHelper.GetTable(sql);
|
||
PatientMd PMD = new PatientMd();
|
||
string orgSN = string.Empty;
|
||
string orgName = string.Empty;
|
||
if (dt_1.Rows.Count == 1)
|
||
{
|
||
PMD.ID = dt_1.Rows[0]["ID"].ToString();
|
||
PMD.PatientID = dt_1.Rows[0]["regId"].ToString();
|
||
PMD.PatientName = dt_1.Rows[0]["pName"].ToString();
|
||
PMD.P_Id ="-";
|
||
PMD.Gender = dt_1.Rows[0]["gender"].ToString();
|
||
PMD.Birthday = dt_1.Rows[0]["birthday"].ToString();
|
||
PMD.Folk ="";
|
||
// DataTable dt_org = SqliteOptions_sql.CreateInstance().ExcuteSqlite("select * from tb_org where orgID='" + dt_1.Rows[0]["orgID"].ToString() + "'");
|
||
orgSN = orgid;
|
||
orgName = orgname;
|
||
}
|
||
patientInfoFLY pfy = new patientInfoFLY();
|
||
|
||
|
||
pfy.patientName = PMD.PatientName;
|
||
pfy.idCard = !string.IsNullOrEmpty(PMD.P_Id) ? PMD.P_Id : "-";
|
||
pfy.sex = PMD.Gender;
|
||
pfy.birthday = PMD.Birthday;
|
||
try
|
||
{
|
||
pfy.yearold = (DateTime.Now.Year - DateTime.Parse(PMD.Birthday).Year).ToString();
|
||
}
|
||
catch { }
|
||
pfy.area = "心脏";
|
||
pfy.Items = "Items";
|
||
pfy.appointmentTimes = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||
pfy.symptom = "无";
|
||
pfy.hospitalCode = orgSN;
|
||
pfy.hospitalName = orgName;
|
||
pfy.departmentCode = "0235";
|
||
pfy.departmentName = "心电图室";
|
||
pfy.resDoctorCode = "5216";
|
||
pfy.resDoctorName = "心电图医生";
|
||
pfy.patientType = "门诊";
|
||
pfy.patientTypeCode = 0;
|
||
pfy.nation = PMD.Folk;
|
||
pfy.appointmentId = PMD.PatientID;
|
||
pfy.wearTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||
pfy.patientCode = PMD.ID;
|
||
string jsonContent = JsonConvert.SerializeObject(pfy);
|
||
|
||
string token = commonOptions.gettoken(ConfigurationManager.AppSettings["flowygtUserName"], ConfigurationManager.AppSettings["flowygtUserPwd"], ConfigurationManager.AppSettings["flowygtLoginUrl"]);//获取token
|
||
string resultStr = commonOptions.PostByParas(ConfigurationManager.AppSettings["flowygtRegistrationAddUrl"], token, jsonContent);
|
||
return resultStr;
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 将患者信息插入数据库中并自动申请判读
|
||
/// </summary>
|
||
/// <param name="epi"></param>
|
||
void excuteOption(string ecgFilePath, int excuteIndex)
|
||
{
|
||
try
|
||
{
|
||
|
||
|
||
string newEcgFilePath = ecgFilePath;
|
||
|
||
FileInfo fi1 = new FileInfo(newEcgFilePath);
|
||
//if (fi1.Extension.ToUpper() == ".BMP")
|
||
//{
|
||
// ecgFilePath = fi1.FullName.Replace(fi1.Extension, ".jpg");
|
||
// using (Image image = Image.FromFile(newEcgFilePath))
|
||
// {
|
||
// // 将图片保存为JPG格式
|
||
// image.Save(ecgFilePath, ImageFormat.Jpeg);
|
||
// }
|
||
// fi1.Delete();//转成jpg后 将bmp图删掉
|
||
//}
|
||
|
||
analysisParas alp = new analysisParas();
|
||
if (fi1.Extension.ToUpper() == ".XML")
|
||
{
|
||
////解析XML并生成jpg心电图
|
||
//ecgCreate ec = new ecgCreate();
|
||
//ecgFilePath = ec.createEcgBmpFile(fi1.FullName, "心电图报告");
|
||
//if (File.Exists(ecgFilePath))
|
||
//{
|
||
// fi1.Delete();//转成jpg后 将XML图删掉
|
||
//}
|
||
//else
|
||
//{
|
||
// fi1.Delete();//转成jpg后 将XML图删掉
|
||
// return;
|
||
//}
|
||
|
||
//解析XML并生成jpg心电图
|
||
// ecgCreate ec = new ecgCreate();
|
||
Hl7EcgOptions hl7EcgOptions = new Hl7EcgOptions();
|
||
ecgFilePath = hl7EcgOptions.createEcgBmpByHL7XMLFile(fi1.FullName, "心电图报告");//根据 hl7 xml文件绘制心电图报告
|
||
alp = hl7EcgOptions.getAnalysisParas(fi1.FullName);//读取hl7 xml文件里的分析数据和患者信息
|
||
//将分析参数写入到分析参数表中
|
||
//-----------------------------------
|
||
if (string.IsNullOrEmpty(alp.patientid))
|
||
alp.patientid = Guid.NewGuid().ToString("N");
|
||
|
||
if (File.Exists(ecgFilePath))
|
||
{
|
||
fi1.Delete();//转成jpg后 将XML图删掉
|
||
}
|
||
else
|
||
{
|
||
fi1.Delete();//转成jpg后 将XML图删掉
|
||
return;
|
||
}
|
||
|
||
|
||
|
||
|
||
}
|
||
|
||
|
||
|
||
FileInfo fi = new FileInfo(ecgFilePath);
|
||
string patientId2 = alp.patientid;
|
||
string patientname = alp.patientName;
|
||
string examid = string.Empty;
|
||
//if (fi.Name.Contains("["))
|
||
// patientId2 = fi.Name.Substring(fi.Name.IndexOf('[') + 1, fi.Name.IndexOf(']') - fi.Name.IndexOf('[') - 1);
|
||
//else
|
||
// patientId2 = Guid.NewGuid().ToString();
|
||
//if(string.IsNullOrEmpty(patientId2))
|
||
// patientId2 = Guid.NewGuid().ToString();
|
||
//if (fi.Name.IndexOf('[') > 0)
|
||
// patientname = fi.Name.Substring(0, fi.Name.IndexOf('['));
|
||
string orgSN = fi.Directory.Name;
|
||
DataTable dt_org1 = MySQLHelper.GetTable("select * from tb_org where orgSN='" + orgSN + "'");
|
||
// DataTable dt_org1 = DbHelperMySQL.Query(a).Tables[0];
|
||
// DataTable dt_org1 = SqliteOptions_sql.CreateInstance().ExcuteSqlite("select * from tb_org where orgSN='" + orgSN + "'");
|
||
string orgid = "";
|
||
string highLevelOrgid = "";
|
||
string inHisCode = "";
|
||
string oragname = string.Empty;
|
||
if (dt_org1.Rows.Count == 1)
|
||
{
|
||
orgid = dt_org1.Rows[0]["orgID"].ToString();
|
||
highLevelOrgid = dt_org1.Rows[0]["highLevelOrgID"].ToString();
|
||
inHisCode = dt_org1.Rows[0]["inHisCode"].ToString().Trim();//在福乐云his中的机构代码
|
||
oragname = dt_org1.Rows[0]["orgName"].ToString();
|
||
}
|
||
string queryDate = fi.CreationTime.ToString("yyyy-MM-dd");//文件的创建时间作为 his中患者信息查询的 查询日期
|
||
//获取福乐云HIS接口的token
|
||
string hisToken = commonOptions.getHisToken(ConfigurationManager.AppSettings["hisGetEcgTokenUrl"], ConfigurationManager.AppSettings["hisAppkey"], ConfigurationManager.AppSettings["appsecret"]);
|
||
FlyHisEcgDataModel FHEDM = commonOptions.GetHisEcgData(ConfigurationManager.AppSettings["hisGetEcgDataUrl"], inHisCode, queryDate, hisToken);
|
||
// 将患者姓名 和 his结果里的患者姓名进行对比 如果姓名匹配 那么就将这个人的 patientid 修改为 his结果里的 jianchaid
|
||
patientInfo pi = ComparePatientInfo(FHEDM, patientname);
|
||
if (pi != null)
|
||
{
|
||
patientId2 = pi.jianchaid;//检查id作为患者patientid
|
||
// alp.patientid = patientId2;
|
||
examid = pi.jianchabh;
|
||
}
|
||
|
||
if (string.IsNullOrEmpty(examid))
|
||
examid = Guid.NewGuid().ToString("N");
|
||
//string returnStrx = FlySubmit(patientId2,7);//收到心电数据后,将心电数据状态传到福乐云平台
|
||
|
||
|
||
string newEcgFilePath1 = fi.DirectoryName + @"\" + patientId2 + fi.Extension;
|
||
fi.CopyTo(newEcgFilePath1);
|
||
#region 插入业务数据
|
||
//插入tb_patientexamlist表数据
|
||
string idStr = Guid.NewGuid().ToString();
|
||
string gender1 = pi != null ? pi.sex : "";
|
||
string birthday1 = pi != null ? pi.birthdate : "null";
|
||
StringBuilder patientexamlist = new StringBuilder();
|
||
patientexamlist.Append(" insert into ");
|
||
patientexamlist.Append(" tb_patientexamlist ");
|
||
patientexamlist.Append("(");
|
||
patientexamlist.Append("ID,examId,pName,gender,birthday,examDate,deviceType,se_dc,examItemName,reportstatus,applicationDate,orgName,orgId,createDate,");
|
||
patientexamlist.Append("examItemCode,regId");
|
||
patientexamlist.Append(")");
|
||
patientexamlist.Append("values (");
|
||
patientexamlist.Append("'" + Guid.NewGuid().ToString("N") + "','" + examid + "','" + patientname + "','" + gender1 + "'," + birthday1 + ",'" + fi.CreationTime.ToString("yyyy-MM-dd HH:mm:ss") + "',");
|
||
patientexamlist.Append("'ECG','1/1','心电图','待分析','" + fi.CreationTime.ToString("yyyy-MM-dd HH:mm:ss") + "','" + oragname + "','" + orgid + "','" + fi.CreationTime.ToString("yyyy-MM-dd HH:mm:ss") + "',");
|
||
patientexamlist.Append(" '','"+ patientId2 + "'");
|
||
patientexamlist.Append(")");
|
||
bool bol = MySQLHelper.ExecuteNonQuery(patientexamlist.ToString());
|
||
|
||
//先创建ftp文件夹
|
||
FtpHelper.MakeDir(patientId2);
|
||
//上传心电图xml转换的图片
|
||
string returnStr = FtpHelper.FileUpLoad(fi.FullName, patientId2, patientId2 + fi.Extension);
|
||
if (returnStr == "上传成功")
|
||
{
|
||
textBox2.AppendText(patientexamlist.ToString() + "文件: " + fi.Name + " 上传成功:" + patientId2 + fi.Extension + " | " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n");
|
||
fi.Delete();
|
||
}
|
||
//把生成的json文件进行上传和插入表
|
||
string ecgAnalysisJson = JsonConvert.SerializeObject(alp);//把心电数据保存成json文件
|
||
string jsonFilePath = fi1.DirectoryName + @"\" + Guid.NewGuid().ToString() + ".txt";
|
||
File.WriteAllText(jsonFilePath, ecgAnalysisJson, Encoding.UTF8);//保存json文件到指定的目标统一http访问目录下
|
||
FileInfo filejson = new FileInfo(jsonFilePath);
|
||
if (filejson.Exists)
|
||
{
|
||
//插入表tb_ecganalysisparas
|
||
StringBuilder ecganalysisparas = new StringBuilder();
|
||
ecganalysisparas.Append(" insert into ");
|
||
ecganalysisparas.Append(" tb_ecganalysisparas ");
|
||
ecganalysisparas.Append("(");
|
||
ecganalysisparas.Append(" ID,orgId,examId,CollectionTime,HR,P_Axle,QRS_Axle,T_Axle,PTimeLimit,PR,qrsTimeLimit,QT,QTC,RV5,SV1,RV5_SV1,snapshotTime,");
|
||
ecganalysisparas.Append(" ecgJsonDataFilePath,createDate,regId");
|
||
ecganalysisparas.Append(")");
|
||
ecganalysisparas.Append("values (");
|
||
ecganalysisparas.Append(" '" + Guid.NewGuid().ToString("N") + "','" + orgid + "','" + examid + "','" + fi.CreationTime.ToString("yyyy-MM-dd HH:mm:ss") + "',");
|
||
ecganalysisparas.Append(" '" + alp.heartRate + "','" + alp.P_degrees + "','" + alp.QRS_degrees + "','" + alp.T_degrees + "','" + alp.P + "','" + alp.PR + "','" + alp.QRS + "',");
|
||
ecganalysisparas.Append("'" + alp.QT + "','" + alp.QTc + "','" + alp.RV5 + "','" + alp.SV1 + "','" + alp.RV5PLUSSV1 + "','" + fi.CreationTime.ToString("yyyy-MM-dd HH:mm:ss") + "',");
|
||
ecganalysisparas.Append(" '" + ConfigurationManager.AppSettings["jsonurl"] + patientId2+"/"+ patientId2 + filejson.Extension + "','" + fi.CreationTime.ToString("yyyy-MM-dd HH:mm:ss") + "','" + patientId2 + "'");
|
||
ecganalysisparas.Append(" )");
|
||
bool bolecganalysisparas = MySQLHelper.ExecuteNonQuery(ecganalysisparas.ToString());
|
||
//上传心电图xml转换的图片
|
||
string returnStrjson = FtpHelper.FileUpLoad(filejson.FullName, patientId2, patientId2 + filejson.Extension);
|
||
if (returnStrjson == "上传成功")
|
||
{
|
||
textBox2.AppendText("文件: " + filejson.Name + " 上传成功:" + patientId2 + filejson.Extension + " | " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n");
|
||
filejson.Delete();
|
||
}
|
||
}
|
||
#endregion
|
||
#region 之前的
|
||
//string sql = "select * from Tb_PatientInfo where PatientID='" + patientId2 + "' and orgID='" + orgid + "' and isXinDianTu = '1'";
|
||
//DataTable dt_getData = SqliteOptions_sql.CreateInstance().ExcuteSqlite(sql);
|
||
//if (dt_getData.Rows.Count == 1)
|
||
//{
|
||
// string patientId = dt_getData.Rows[0]["PatientID"].ToString();
|
||
// string sql1 = "update Tb_PatientInfo set CreateDate='" + fi.CreationTime.ToString("yyyy-MM-dd HH:mm:ss") + "' where PatientID='" + patientId + "'";
|
||
// SqliteOptions_sql.CreateInstance().SqliteUpdate(sql1);
|
||
// //string fileMd5 = GetMD5HashFromFile(fi.FullName);
|
||
// //string returnMd5 = oss.PutObject("aecgdatas", patientId + fi.Extension, ecgFilePath);
|
||
// string returnStr = FtpHelper.FileUpLoad(fi.FullName, "", patientId2 + fi.Extension);//把生成的心电图和心电json文件 放到一个统一的http访问的一个文件夹里
|
||
// if (returnStr == "上传成功")
|
||
// {
|
||
// textBox2.AppendText(sql1 + "文件: " + fi.Name + "修改成功:" + patientId + fi.Extension + " | " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n");
|
||
// fi.Delete();
|
||
// // fi_1.Delete();
|
||
// }
|
||
//}
|
||
//else
|
||
//{
|
||
// string idStr = Guid.NewGuid().ToString();
|
||
// string gender1 = pi != null ? pi.sex : "";
|
||
// string birthday1 = pi != null ? pi.birthdate : "";
|
||
// string sql2 = "insert into Tb_PatientInfo (ID,PatientID,CreateDate,isXinDianTu,orgID,highLevelOrgID,medicalSN,PatientName,Gender,Birthday) values ('" + idStr + "','" + patientId2 + "','" + fi.CreationTime.ToString("yyyy-MM-dd HH:mm:ss") + "','1','" + orgid + "','" + highLevelOrgid + "','','" + patientname + "','" + gender1 + "','" + birthday1 + "')";
|
||
// SqliteOptions_sql.CreateInstance().SqliteAdd(sql2);
|
||
// //string fileMd5 = GetMD5HashFromFile(fi.FullName);
|
||
// //string returnMd5 = oss.PutObject("aecgdatas", patientId2 + fi.Extension, ecgFilePath);
|
||
// string returnStr = FtpHelper.FileUpLoad(fi.FullName, "", patientId2 + fi.Extension);
|
||
// if (returnStr == "上传成功")
|
||
// {
|
||
// textBox2.AppendText(sql2 + "文件: " + fi.Name + " 上传成功:" + patientId2 + fi.Extension + " | " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n");
|
||
// fi.Delete();
|
||
// // fi_1.Delete();
|
||
// }
|
||
//}
|
||
#endregion
|
||
|
||
|
||
string returnStrxs = submitPatientInfoToFLY(patientId2,examid,orgid, oragname);//先把患者信息提交到福乐云医共体平台
|
||
string returnStrx = FlySubmit(patientId2, 3);//收到心电数据后,将心电数据状态传到福乐云平台
|
||
FileInfo fi_1 = new FileInfo(newEcgFilePath1);
|
||
if (fi_1.Exists)
|
||
{
|
||
FlyEcgReportFileSubmit(patientId2, newEcgFilePath1);//不管三七二十一,先把收到的心电图文件到福乐云平台
|
||
fi_1.Delete();
|
||
}
|
||
|
||
//if (!fi_1.Exists)
|
||
// FlyEcgReportFileSubmit(patientId2, ecgFilePath);//不管三七二十一,先把收到的心电图文件到福乐云平台
|
||
//else
|
||
// FlyEcgReportFileSubmit(patientId2, newEcgFilePath1);//不管三七二十一,先把收到的心电图文件到福乐云平台
|
||
|
||
|
||
|
||
//string sql = "select * from Tb_PatientInfo where PatientID='" + patientId2 + "' and orgID='" + orgid + "' and isXinDianTu = '1'";
|
||
//DataTable dt_getData = SqliteOptions_sql.CreateInstance().ExcuteSqlite(sql);
|
||
//if (dt_getData.Rows.Count == 1)
|
||
//{
|
||
// string patientId = dt_getData.Rows[0]["PatientID"].ToString();
|
||
// string sql1 = "update Tb_PatientInfo set CreateDate='" + fi.CreationTime.ToString("yyyy-MM-dd HH:mm:ss") + "' where PatientID='" + patientId + "'";
|
||
// SqliteOptions_sql.CreateInstance().SqliteUpdate(sql1);
|
||
// //string fileMd5 = GetMD5HashFromFile(fi.FullName);
|
||
// //string returnMd5 = oss.PutObject("aecgdatas", patientId + fi.Extension, ecgFilePath);
|
||
// string returnStr = FtpHelper.FileUpLoad(fi.FullName, "", patientId2 + fi.Extension);
|
||
// if (returnStr == "上传成功")
|
||
// {
|
||
// textBox2.AppendText(sql1+"文件: " + fi.Name + "修改成功:" + patientId + fi.Extension + " | " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n");
|
||
// fi.Delete();
|
||
// fi_1.Delete();
|
||
// }
|
||
//}
|
||
//else
|
||
//{
|
||
// string idStr = Guid.NewGuid().ToString();
|
||
// string gender1 = pi != null ? pi.sex : "";
|
||
// string birthday1 = pi != null ? pi.birthdate : "";
|
||
// string sql2 = "insert into Tb_PatientInfo (ID,PatientID,CreateDate,isXinDianTu,orgID,highLevelOrgID,medicalSN,PatientName,Gender,Birthday) values ('" + idStr + "','" + patientId2 + "','" + fi.CreationTime.ToString("yyyy-MM-dd HH:mm:ss") + "','1','" + orgid + "','" + highLevelOrgid + "','','"+ patientname + "','"+ gender1 + "','"+ birthday1 + "')";
|
||
// SqliteOptions_sql.CreateInstance().SqliteAdd(sql2);
|
||
// //string fileMd5 = GetMD5HashFromFile(fi.FullName);
|
||
// //string returnMd5 = oss.PutObject("aecgdatas", patientId2 + fi.Extension, ecgFilePath);
|
||
// string returnStr = FtpHelper.FileUpLoad(fi.FullName, "", patientId2 + fi.Extension);
|
||
// if (returnStr == "上传成功")
|
||
// {
|
||
// textBox2.AppendText(sql2 + "文件: " + fi.Name + " 上传成功:" + patientId2 + fi.Extension + " | " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n");
|
||
// fi.Delete();
|
||
// fi_1.Delete();
|
||
// }
|
||
//}
|
||
|
||
|
||
|
||
}
|
||
catch { }
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
void ftpDataPost(string filePath, int excuteIndex)
|
||
{
|
||
//if (Path.GetExtension(filePath).ToUpper().Equals(".JPG", StringComparison.CurrentCultureIgnoreCase)|| Path.GetExtension(filePath).ToUpper().Equals(".BMP", StringComparison.CurrentCultureIgnoreCase) || Path.GetExtension(filePath).ToUpper().Equals(".XML", StringComparison.CurrentCultureIgnoreCase))
|
||
if (Path.GetExtension(filePath).ToUpper().Equals(".XML", StringComparison.CurrentCultureIgnoreCase))
|
||
{
|
||
excuteOption(filePath, excuteIndex);
|
||
}
|
||
|
||
}
|
||
|
||
|
||
private delegate void DoDataDelegate(object txtContent);
|
||
private void DoData(object txtContent)
|
||
{
|
||
try
|
||
{
|
||
if (textBox2.InvokeRequired)
|
||
{
|
||
DoDataDelegate d = DoData;
|
||
textBox2.Invoke(d, txtContent);
|
||
}
|
||
else
|
||
{
|
||
if (checkBox1.Checked)
|
||
textBox2.AppendText(txtContent + "\r\n");
|
||
}
|
||
}
|
||
catch { }
|
||
}
|
||
|
||
|
||
void fileBackUp(FileInfo fi)
|
||
{
|
||
string newFilePath = textBox1.Text + @"\dataBackUp\" + fi.Name;
|
||
File.Move(fi.FullName, newFilePath);
|
||
}
|
||
/// <summary>
|
||
/// 创建文件或者目录时的监听事件
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void watch_created(object sender, FileSystemEventArgs e)
|
||
{
|
||
////事件内容
|
||
//string fileName = e.FullPath;
|
||
//if (System.IO.Path.GetExtension(fileName).ToUpper().Equals(".XML", StringComparison.CurrentCultureIgnoreCase))
|
||
// ftpDataPost(fileName);
|
||
}
|
||
|
||
|
||
|
||
string backUpDirectory;
|
||
private void button1_Click(object sender, EventArgs e)
|
||
{
|
||
if (string.IsNullOrEmpty(textBox1.Text))
|
||
{
|
||
FolderBrowserDialog FBD = new FolderBrowserDialog();
|
||
if (FBD.ShowDialog() == DialogResult.OK)
|
||
{
|
||
// WatcherStrat(FBD.SelectedPath, "*.*", true, true);
|
||
File.WriteAllText(Application.StartupPath + @"\dataPath.txt", FBD.SelectedPath);
|
||
textBox1.Text = FBD.SelectedPath;
|
||
DirectoryInfo di = new DirectoryInfo(FBD.SelectedPath);
|
||
|
||
//创建一个监听目录之外的 备份目录
|
||
string parentDirectory = di.Parent.Name;
|
||
backUpDirectory = di.Parent.Name + @"\backUpDatas";
|
||
if (!Directory.Exists(backUpDirectory))
|
||
Directory.CreateDirectory(backUpDirectory);
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
void uploadDataToOss(FileInfo fi)
|
||
{
|
||
if (fi != null && fi.Exists)
|
||
{
|
||
OssUnity oss = new OssUnity();
|
||
//上传文件到oss
|
||
string returnMd5 = oss.PutObject("1200g", fi.Name, fi.FullName);
|
||
//////上传成功,删除本地文件
|
||
//fi.Delete();
|
||
}
|
||
}
|
||
|
||
patientInfoModel ReadXMLByPath(patientInfoModel pfm, string xmlPath)
|
||
{
|
||
string caseName = "";
|
||
string age = "0";
|
||
string sex = "";
|
||
string hospitalRoom = "";
|
||
string HR = string.Empty, PR = string.Empty, P = string.Empty, QRS = string.Empty, T = string.Empty, QT = string.Empty, QTc = string.Empty, PAxis = string.Empty, QRSAxis = string.Empty, TAxis = string.Empty, R_V5 = string.Empty, S_V1 = string.Empty;
|
||
string startTime = string.Empty, endTime = string.Empty;
|
||
string autoDiagResult = string.Empty;
|
||
EcgViewModel EVM = ReadXMLByPath(xmlPath);
|
||
try
|
||
{
|
||
XmlDocument doc1 = new XmlDocument();
|
||
doc1.Load(xmlPath);
|
||
//获取当前XML文档的根 一级
|
||
XmlNode oNode = doc1.DocumentElement;
|
||
//获取根节点的所有子节点列表
|
||
XmlNodeList oList = oNode.ChildNodes;
|
||
//标记当前节点
|
||
XmlNode oCurrentNode;
|
||
//遍历所有二级节点
|
||
for (int i = 0; i < oList.Count; i++)
|
||
{
|
||
//二级
|
||
oCurrentNode = oList[i];
|
||
//检测当前节点的名称,节点的值是否与已知匹配
|
||
if (oCurrentNode.Name.Equals("caseinformation"))
|
||
{
|
||
//检测是否有子节点 三级
|
||
if (oCurrentNode.HasChildNodes)
|
||
{
|
||
//遍历当前节点的所有子节点
|
||
for (int n = 0; n < oCurrentNode.ChildNodes.Count; n++)
|
||
{
|
||
//检测当前节点的子节点名称是否与已知匹配
|
||
if (oCurrentNode.ChildNodes[n].Name.ToLower() == "otherparam")
|
||
{
|
||
//遍历当前节点的所有子节点
|
||
for (int ii = 0; ii < oCurrentNode.ChildNodes[n].ChildNodes.Count; ii++)
|
||
{
|
||
if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.Equals("caseName"))
|
||
{
|
||
caseName = oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText;
|
||
}
|
||
if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.Equals("sex"))
|
||
{
|
||
sex = oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText;
|
||
}
|
||
if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.Equals("age"))
|
||
{
|
||
age = oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText;
|
||
}
|
||
if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.Equals("hr"))
|
||
{
|
||
hospitalRoom = oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText;
|
||
}
|
||
}
|
||
}
|
||
|
||
//检测当前节点的子节点名称是否与已知匹配
|
||
if (oCurrentNode.ChildNodes[n].Name == "Parameters")
|
||
{
|
||
//遍历当前节点的所有子节点
|
||
for (int ii = 0; ii < oCurrentNode.ChildNodes[n].ChildNodes.Count; ii++)
|
||
{
|
||
if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.Equals("HR"))//心率
|
||
{
|
||
HR = oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText;
|
||
}
|
||
if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.Equals("PRInterval"))
|
||
{
|
||
PR = oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText;
|
||
}
|
||
if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.Equals("PDuration"))
|
||
{
|
||
P = oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText;
|
||
}
|
||
if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.Equals("QRSDuration"))
|
||
{
|
||
QRS = oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText;
|
||
}
|
||
|
||
if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.Equals("TDuration"))
|
||
{
|
||
T = oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText;
|
||
}
|
||
if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.Equals("QTInterval"))
|
||
{
|
||
QT = oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText;
|
||
}
|
||
if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.Equals("QTcInterval"))
|
||
{
|
||
QTc = oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText;
|
||
}
|
||
if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.Equals("PAxis"))
|
||
{
|
||
PAxis = oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText;
|
||
}
|
||
if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.Equals("QRSAxis"))
|
||
{
|
||
QRSAxis = oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText;
|
||
}
|
||
if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.Equals("TAxis"))
|
||
{
|
||
TAxis = oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText;
|
||
}
|
||
if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.Equals("R_V5"))
|
||
{
|
||
R_V5 = oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText;
|
||
}
|
||
if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.Equals("S_V1"))
|
||
{
|
||
S_V1 = oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText;
|
||
}
|
||
|
||
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
if (oCurrentNode.Name.Equals("effectiveTime"))
|
||
{
|
||
|
||
//检测是否有子节点 三级
|
||
if (oCurrentNode.HasChildNodes)
|
||
{
|
||
//遍历当前节点的所有子节点
|
||
for (int n = 0; n < oCurrentNode.ChildNodes.Count; n++)
|
||
{
|
||
//检测当前节点的子节点名称是否与已知匹配
|
||
if (oCurrentNode.ChildNodes[n].Name == "low")
|
||
{
|
||
startTime = oCurrentNode.ChildNodes[n].Attributes["value"].Value;
|
||
}
|
||
if (oCurrentNode.ChildNodes[n].Name == "high")
|
||
{
|
||
endTime = oCurrentNode.ChildNodes[n].Attributes["value"].Value;
|
||
}
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
catch (Exception ex) { }
|
||
pfm.patientName = caseName;
|
||
pfm.patientSex = sex.Trim() == "1" ? "男" : "女";
|
||
pfm.testDate = startTime.Insert(8, "T");
|
||
pfm.evidence = EVM.AutoResult;
|
||
if (string.IsNullOrEmpty(pfm.evidence.Trim()))
|
||
pfm.evidence = "-";
|
||
//pfm.startTime =startTime;
|
||
//pfm.endTime =endTime;
|
||
if (string.IsNullOrEmpty(age))
|
||
age = "0";
|
||
|
||
pfm.isPanDu = hospitalRoom == "1" ? true : false;
|
||
pfm.patientAge = int.Parse(age);
|
||
return pfm;
|
||
}
|
||
|
||
private void button2_Click(object sender, EventArgs e)
|
||
{
|
||
string postContent = "{\"c_file_name\": \"BJXHYY_ECG12000_XD001\",\"c_source\": \"门诊\",\"c_case_state\":\"未判读\",\"p_name\":\"测试患者3\",\"p_gender\":\"女\",\"p_birth\":\"1985-12-17\",\"c_create_time\":\"2019-12-22\"}";
|
||
string returnStr = HttpPost(postContent);
|
||
}
|
||
|
||
|
||
private string HttpPost(string postDataStr)
|
||
{
|
||
string Url = "http://ecggl.drchip.cn/api/Case";
|
||
WebRequest request = WebRequest.Create(Url);
|
||
request.Method = "POST";
|
||
request.ContentType = "application/json";
|
||
byte[] buf = Encoding.UTF8.GetBytes(postDataStr);
|
||
byte[] byteArray = System.Text.Encoding.Default.GetBytes(postDataStr);
|
||
request.ContentLength = Encoding.UTF8.GetByteCount(postDataStr);
|
||
request.GetRequestStream().Write(buf, 0, buf.Length);
|
||
WebResponse response = request.GetResponse();
|
||
Stream myResponseStream = response.GetResponseStream();
|
||
StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"));
|
||
string retString = myStreamReader.ReadToEnd();
|
||
myStreamReader.Close();
|
||
myResponseStream.Close();
|
||
|
||
return retString;
|
||
}
|
||
|
||
private void button3_Click(object sender, EventArgs e)
|
||
{
|
||
//patientInfoModel pfm = ReadXMLByPath(@"C:\Users\PETER\Desktop\芯动心电网络管理系统\FTP数据\e30c180b-2512-4073-ae7a-d65be041f424.XML");
|
||
//string jsonStr = JsonConvert.SerializeObject(pfm);
|
||
//string returnStr = HttpPost(jsonStr);
|
||
}
|
||
|
||
private void timer1_Tick(object sender, EventArgs e)
|
||
{
|
||
ftpDataJieXi();//解析FTP传上来的xml
|
||
// startExe();
|
||
}
|
||
|
||
void startExe()
|
||
{
|
||
//try
|
||
//{
|
||
string exePath = File.ReadAllText(Application.StartupPath + @"\exePath.txt", Encoding.Default);
|
||
// MessageBox.Show(exePath);
|
||
Process[] mProcs = Process.GetProcessesByName(@"HbAutoDiagnosisPro");
|
||
Process[] mProcs1 = Process.GetProcessesByName(@"HL_Holter");
|
||
if (mProcs.Length == 0)
|
||
{
|
||
if (mProcs1.Length > 0)
|
||
foreach (var p in mProcs1)
|
||
p.Kill();
|
||
Process.Start(exePath);
|
||
|
||
//System.Diagnostics.Process myprocess = new System.Diagnostics.Process();
|
||
//System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(exePath, "");
|
||
//myprocess.StartInfo = startInfo;
|
||
//myprocess.StartInfo.UseShellExecute = false;
|
||
//myprocess.Start();
|
||
}
|
||
//}
|
||
//catch (Exception ex) { MessageBox.Show(ex.ToString()); }
|
||
|
||
}
|
||
|
||
//解析FTP传上来的xml
|
||
void ftpDataJieXi()
|
||
{
|
||
timer1.Enabled = false;
|
||
try
|
||
{
|
||
if (!string.IsNullOrEmpty(textBox1.Text))
|
||
{
|
||
string[] diList = Directory.GetDirectories(textBox1.Text);
|
||
foreach (string dir in diList)
|
||
{
|
||
List<FileInfo> fileList = GetFiles(dir);
|
||
for (int i = 0; i < fileList.Count; i++)
|
||
{
|
||
string fileName = fileList[i].FullName;
|
||
//if (System.IO.Path.GetExtension(fileName).ToUpper().Equals(".JPG", StringComparison.CurrentCultureIgnoreCase) || System.IO.Path.GetExtension(fileName).ToUpper().Equals(".BMP", StringComparison.CurrentCultureIgnoreCase) || System.IO.Path.GetExtension(fileName).ToUpper().Equals(".XML", StringComparison.CurrentCultureIgnoreCase))
|
||
if (System.IO.Path.GetExtension(fileName).ToUpper().Equals(".XML", StringComparison.CurrentCultureIgnoreCase))
|
||
ftpDataPost(fileName, 0);
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{ textBox2.AppendText("异常:" + ex.ToString() + "\r\n"); }
|
||
timer1.Enabled = true;
|
||
}
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// 遍历当前目录及子目录
|
||
/// </summary>
|
||
/// <param name="strPath">文件路径</param>
|
||
/// <returns>所有文件</returns>
|
||
private List<FileInfo> GetFiles(string strPath)
|
||
{
|
||
List<FileInfo> lstFiles = new List<FileInfo>();
|
||
List<string> lstDirect = new List<string>();
|
||
lstDirect.Add(strPath);
|
||
DirectoryInfo diFliles = null;
|
||
GetDirectorys(strPath, ref lstDirect);
|
||
foreach (string str in lstDirect)
|
||
{
|
||
try
|
||
{
|
||
diFliles = new DirectoryInfo(str);
|
||
lstFiles.AddRange(diFliles.GetFiles());
|
||
}
|
||
catch
|
||
{
|
||
continue;
|
||
}
|
||
}
|
||
return lstFiles;
|
||
}
|
||
|
||
|
||
private static void GetDirectorys(string strPath, ref List<string> lstDirect)
|
||
{
|
||
DirectoryInfo diFliles = new DirectoryInfo(strPath);
|
||
DirectoryInfo[] diArr = diFliles.GetDirectories();
|
||
//DirectorySecurity directorySecurity = null;
|
||
foreach (DirectoryInfo di in diArr)
|
||
{
|
||
try
|
||
{
|
||
//directorySecurity = new DirectorySecurity(di.FullName, AccessControlSections.Access);
|
||
//if (!directorySecurity.AreAccessRulesProtected)
|
||
//{
|
||
lstDirect.Add(di.FullName);
|
||
GetDirectorys(di.FullName, ref lstDirect);
|
||
//}
|
||
}
|
||
catch
|
||
{
|
||
continue;
|
||
}
|
||
}
|
||
}
|
||
|
||
private void button4_Click(object sender, EventArgs e)
|
||
{
|
||
string sms_return = SMS.smsSend("18601017090,13121767333,13811297861,18055162573,18656976035", "【判读完成】姓名:潘小婷,判读结论:室颤,HRV变异严重,STT改变。");
|
||
}
|
||
|
||
private void button5_Click(object sender, EventArgs e)
|
||
{
|
||
textBox2.Text = string.Empty;
|
||
}
|
||
|
||
|
||
Thread th_rabbitMQ;
|
||
private void button6_Click(object sender, EventArgs e)
|
||
{
|
||
//var factory = new ConnectionFactory();
|
||
//factory.HostName = "39.98.107.44";//主机名,Rabbit会拿这个IP生成一个endpoint,这个很熟悉吧,就是socket绑定的那个终结点。
|
||
//factory.Port = 5672;
|
||
//factory.UserName = "ygt";//默认用户名,用户可以在服务端自定义创建,有相关命令行
|
||
//factory.Password = "ygt";//默认密码
|
||
//factory.VirtualHost = "ygt";
|
||
//using (var connection = factory.CreateConnection())//连接服务器,即正在创建终结点。
|
||
//{
|
||
// //创建一个通道,这个就是Rabbit自己定义的规则了,如果自己写消息队列,这个就可以开脑洞设计了
|
||
// //这里Rabbit的玩法就是一个通道channel下包含多个队列Queue
|
||
// using (var channel = connection.CreateModel())
|
||
// {
|
||
// //channel.ExchangeDeclare("ygt.ecg.jk.exchange", ExchangeType.Direct, false, false, null);
|
||
// ////channel.ExchangeDeclare("ygt.ecg.jk.exchange", ExchangeType.Topic, false, false, null);
|
||
// channel.QueueDeclare("ygt.ecg.jk.queue", true, false, false, null);
|
||
// channel.BasicQos(0, 1, false);
|
||
// //channel.QueueBind("ygt.ecg.jk.queue", "ygt.ecg.jk.exchange", "ygt.ecg.jk.key");
|
||
// var consumer = new QueueingBasicConsumer(channel);
|
||
// channel.BasicConsume("ygt.ecg.jk.queue", false, consumer);
|
||
// // consumer.Received += OnDataReceived;
|
||
|
||
// while (true)
|
||
// {
|
||
// var ea = (BasicDeliverEventArgs)consumer.Queue.Dequeue();
|
||
// var body = ea.Body;
|
||
// var message = Encoding.UTF8.GetString(body);
|
||
// submitHis03(message);// 提交数据到 his03
|
||
// Thread.Sleep(2000);
|
||
// string messageStr = message;
|
||
// channel.BasicAck(ea.DeliveryTag, false);
|
||
// }
|
||
// }
|
||
//}
|
||
|
||
th_rabbitMQ = new Thread(new ThreadStart(rabbitMQ));
|
||
th_rabbitMQ.IsBackground = true;
|
||
th_rabbitMQ.Start();
|
||
}
|
||
|
||
void rabbitMQ()
|
||
{
|
||
DoData("MQ数据接收中\r\n");
|
||
var factory = new ConnectionFactory();
|
||
factory.HostName = "10.1.99.39";//主机名,Rabbit会拿这个IP生成一个endpoint,这个很熟悉吧,就是socket绑定的那个终结点。
|
||
factory.Port = 5672;
|
||
factory.UserName = "ygt-hb";//默认用户名,用户可以在服务端自定义创建,有相关命令行
|
||
factory.Password = "ygt-hb";//默认密码
|
||
factory.VirtualHost = "ygt-hb";
|
||
using (var connection = factory.CreateConnection())//连接服务器,即正在创建终结点。
|
||
{
|
||
//创建一个通道,这个就是Rabbit自己定义的规则了,如果自己写消息队列,这个就可以开脑洞设计了
|
||
//这里Rabbit的玩法就是一个通道channel下包含多个队列Queue
|
||
using (var channel = connection.CreateModel())
|
||
{
|
||
channel.QueueDeclare("ygt.xd.ecg.cd.queue", true, false, false, null);
|
||
channel.BasicQos(0, 1, false);
|
||
var consumer = new QueueingBasicConsumer(channel);
|
||
channel.BasicConsume("ygt.xd.ecg.cd.queue", false, consumer);
|
||
// consumer.Received += OnDataReceived;
|
||
while (true)
|
||
{
|
||
var ea = (BasicDeliverEventArgs)consumer.Queue.Dequeue();
|
||
var body = ea.Body;
|
||
var message = Encoding.UTF8.GetString(body);
|
||
DoData("接收到MQ消息:" + message + "\r\n");
|
||
submitHis03(message);// 提交数据到 his03
|
||
Thread.Sleep(2000);
|
||
string messageStr = message;
|
||
channel.BasicAck(ea.DeliveryTag, false);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
public static void OnDataReceived(object sender, BasicDeliverEventArgs e)
|
||
{
|
||
var body = e.Body;
|
||
var message = Encoding.UTF8.GetString(body);
|
||
Console.WriteLine("已接收: {0}", message);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 提交数据到 his03
|
||
/// </summary>
|
||
/// <param name="jsonStr"></param>
|
||
void submitHis03(string jsonStr)
|
||
{
|
||
panduReturnModel prm = JsonConvert.DeserializeObject<panduReturnModel>(jsonStr);
|
||
DataTable dt01 = SqliteOptions_sql.CreateInstance().ExcuteSqlite("select * from guanxinPatients where applyId='" + prm.applyId + "'");
|
||
if (dt01.Rows.Count > 0)
|
||
{
|
||
string jsonStr2 = DecodeBase64("utf-8", dt01.Rows[0]["patientJson"].ToString());
|
||
his03Model hm = JsonConvert.DeserializeObject<his03Model>(jsonStr2);
|
||
hm.pdfUrl = dt01.Rows[0]["pdfUrl"].ToString();
|
||
hm.dicomUrl = dt01.Rows[0]["dicomUrl"].ToString();
|
||
hm.testDate = Convert.ToDateTime(prm.reportTime).ToString("yyyyMMddTHHmmss");
|
||
hm.evidence = prm.reportFeatures;// 心电图xml里的自动结论
|
||
hm.conclusion = prm.reportConclusion;// 如果没有判读的 xml 这个字段为空即可。
|
||
string jsonStr1 = JsonConvert.SerializeObject(hm);
|
||
jsonStr1 = ("[" + jsonStr1 + "]");
|
||
//string returnStr = netOptions.HttpPost("http://his.hebjcws.com:7086/pm-s-report/ECG/HIS03", jsonStr1, "POST");
|
||
string returnStr = netOptions.HttpPost(apiList.his03, jsonStr1, "POST");
|
||
DoData(returnStr + "远程判读已传给his03|MQ数据接收中:" + jsonStr1 + "\r\n");
|
||
}
|
||
}
|
||
private void button7_Click(object sender, EventArgs e)
|
||
{
|
||
// string yy = "eyJzdGF0dXMiOjAsImFnZSI6MjQsImNvbmNsdXNpb24iOiIiLCJldmlkZW5jZSI6IumrmOS+p+WjgeW/g+ail+mZiOaXp+acnzvnlLXovbTovbvluqblj7PlgY87IiwidGVzdERhdGUiOiIyMDE5MTIyMVQxNDE1NTciLCJkaWNvbVVybCI6Imh0dHA6Ly8xMC4xMy4xLjM2OjkwODkvQjQzQjE2NUQ0QjJGRkY1MjZCNkM3RTUyOEQzQUJDOUUuWE1MIiwicGRmVXJsIjoiaHR0cDovLzEwLjEzLjEuMzY6OTA4OS9CNDNCMTY1RDRCMkZGRjUyNkI2QzdFNTI4RDNBQkM5RS5qcGciLCJwZXJzb25ObyI6IjIwMDAwMDYwMTgxMzE3Iiwic291cmNlVHlwZSI6IjIiLCJwZXJzb25JZCI6IjhhOGQ4MWEzNmZjMmMxOWUwMTcwNTZhZDhkNTMyYTI0IiwidHlwZSI6IjIiLCJwb3NJZCI6IjUwY2U5Y2M1LTYzMmMtN2M4My1lMDUzLTEyNjQwMTBhZGRmNSIsInNhbXBsZXN0YXRlIjoi5ZCmIiwicGF0aWVudFR5cGUiOiLkvY/pmaIiLCJkaXNlYXNlIjoi5LiK5ZG85ZC46YGT5oSf5p+TIiwiYXBwbHlUaW1lIjoiMjAyMDAyMThUMTMxMzE3IiwiaXRlbVByaWNlIjoiOCIsIml0ZW1OYW1lIjoi5bi46KeE5b+D55S15Zu+5qOA5p+lIiwiaXRlbUlkIjoiOGE4ZDgxYTE2YTljMmM0YTAxNmM3OTIwNWM4NjUyYjkiLCJkb2N0b3JOYW1lIjoi5byg5by6IiwiZG9jdG9ySWQiOiIwN2RjZjU5Zi1hZTQ5LTRjZWYtOGE4MC0yYTVkMGM5OTljNDAiLCJkZXBhcnRtZW50SWQiOiJkM2ZkZGIyOC03NWY2LTQ0MzItYWQ4Yi01ODg3MDgyNzk0MDYiLCJiZWROdW0iOiIxNeWupDQy5bqKIiwiYWdlVW5pdCI6IuWygSIsInNleCI6IuWlsyIsImlkZW50aXR5Q29kZSI6IjEzMDI4MzE5OTUxMDI5NzcwOCIsIm5hbWUiOiLmnpfnj4oiLCJoaXNDb2RlIjoiMjAwMDAwNjAiLCJpZCI6IjhhOGQ4MWEzNmZjMmMxOWUwMTcwNTZiNmZjOGEyYTdlIn0=";
|
||
// string jsonStr111= DecodeBase64("utf-8", yy);
|
||
//// string jsonStr111 = "{\"applyId\":\"8a8d81aa7058ab1601705c85c8630024\",\"applyStatus\":2,\"auditorTime\":\"2020-02-19 16:24:48\",\"auditorUserId\":\"8a81e39f6d6d77b9017056bd4c83130b\",\"auditorUserName\":\"测试医生\",\"crisis\":\"0\",\"diagnosticPosId\":\"8a81e39f6d6d77b901703d17065a0cfd\",\"patientBirthday\":\"1996-02-19 08:00:00\",\"patientId\":\"130283199510297708\",\"patientName\":\"林珊\",\"patientSex\":\"女\",\"positive\":\"2\",\"reportConclusion\":\"测试数据。\",\"reportFeatures\":\"测试数据。\",\"reportPdf\":\"http://10.13.1.42:9096/ygt-diagnose-service/diagnose_res/pdf/20200219/8a8d81aa705b812901705c85c8b1001d.pdf\",\"reportTime\":\"2020-02-19 16:24:48\",\"reportUserId\":\"8a81e39f6d6d77b9017056bd4c83130b\",\"reportUserName\":\"测试医生\",\"supplierId\":\"8a8d81aa703d250601703d7c10f40004\"}";
|
||
// // string jsonStr111 = "{\"status\":0,\"age\":40,\"conclusion\":\"\",\"evidence\":\"高侧壁心梗陈旧期;电轴轻度右偏;\",\"testDate\":\"20191221T141557\",\"dicomUrl\":\"https://zjkecgdatas.oss-cn-beijing.aliyuncs.com/D8B72AB5BD32A797B9D4AAF87D5E184B.XML\",\"pdfUrl\":\"https://zjkecgdatas.oss-cn-beijing.aliyuncs.com/D8B72AB5BD32A797B9D4AAF87D5E184B.jpg\",\"personNo\":\"2002140007143601\",\"sourceType\":\"1\",\"personId\":\"2c9a9cad7041fe9f017042d6500c02ec\",\"type\":\"2\",\"posId\":\"2c9580826a94e012016a968c21920164\",\"samplestate\":\"否\",\"patientType\":\"门诊\",\"disease\":\"沙门氏菌(亚利桑那)小肠炎\",\"applyTime\":\"20200214T163601\",\"itemPrice\":\"3\",\"itemName\":\"无创心电监测\",\"itemId\":\"ff8080816bbacdf9016bc00b83f90333\",\"doctorName\":\"基层医生\",\"departmentName\":\"全科\",\"doctorId\":\"2c9580826ab8eca6016ab9db50600000\",\"departmentId\":\"2c9580826a94e012016a968df29601bd\",\"ageUnit\":\"岁\",\"birthday\":\"1980-01-01 00:00:00.0\",\"sex\":\"男\",\"identityCode\":\"450101198001010772\",\"name\":\"联调测试004\",\"hisCode\":\"2002140007\",\"id\":\"2c9a9cad7041fe9f017042d727a702fb\"}";
|
||
// his03Model hm = JsonConvert.DeserializeObject<his03Model>(jsonStr111);
|
||
// hm.pdfUrl = "http://10.13.1.42:9096/ygt-diagnose-service/diagnose_res/pdf/20200219/8a8d81aa705b812901705c85c8b1001d.pdf";
|
||
// //hm.dicomUrl = "https://zjkecgdatas.oss-cn-beijing.aliyuncs.com/8B63CCE5E3856D86460CB4CDA856C63C.XML";
|
||
// hm.testDate = "20200219T165609";
|
||
// hm.evidence = "高侧壁心梗陈旧期;电轴轻度右偏;";// 心电图xml里的自动结论
|
||
// hm.conclusion = "测试数据。";// 如果没有判读的 xml 这个字段为空即可。
|
||
//// hm.posId = "50ce9cc5-632c-7c83-e053-1264010addf5";
|
||
// string jsonStr = JsonConvert.SerializeObject(hm);
|
||
// jsonStr = ("[" + jsonStr + "]");
|
||
|
||
// //string returnStr= netOptions.HttpPost("http://39.99.134.67:8080/pm-s-report/ECG/HIS03", jsonStr, "POST");
|
||
// string returnStr = netOptions.HttpPost("http://47.104.9.78:8033/pm-s-report/ECG/HIS03", jsonStr, "POST");
|
||
|
||
string tt = "[{\"status\":0,\"posId\":\"50ce9cc5-632c-7c83-e053-1264010addf5\",\"id\":\"8a8d81a36fc2c19e017056b3d1452a67\",\"testDate\":\"20200219T183430\",\"hisCode\":\"20000062\",\"name\":\"刘艳芳\",\"identityCode\":\"130728198911015028\",\"sex\":\"女\",\"age\":30,\"ageUnit\":\"岁\",\"itemId\":\"8a8d81a16a9c2c4a016c79205c8652b9\",\"itemName\":\"常规心电图检查\",\"departmentId\":\"d3fddb28-75f6-4432-ad8b-588708279406\",\"doctorId\":\"07dcf59f-ae49-4cef-8a80-2a5d0c999c40\",\"patientType\":\"住院\",\"evidence\":\"心电图正常\",\"pdfUrl\":\"http://10.13.1.36:9089/A375510E9601A39CB51628F14AD9E2EF.jpg\",\"optName\":null,\"auditName\":null,\"bedNum\":\"15室40床\",\"testNum\":null,\"barCode\":null,\"specimenType\":null,\"dicomUrl\":\"http://10.13.1.36:9089/A375510E9601A39CB51628F14AD9E2EF.XML\",\"conclusion\":\"心电图正常2\",\"departmentName\":null,\"doctorName\":\"张强\",\"birthday\":null,\"negaPosiTive\":null}]";
|
||
string returnStr = netOptions.HttpPost("http://47.104.9.78:8033/pm-s-report/ECG/HIS03", tt, "POST");
|
||
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// 读取XML文件
|
||
/// </summary>
|
||
/// <param name="path"></param>
|
||
/// <returns></returns>
|
||
private EcgViewModel ReadXMLByPath(string path)
|
||
{
|
||
var evm = new EcgViewModel
|
||
{
|
||
DicData = new Dictionary<string, string>()
|
||
};
|
||
try
|
||
{
|
||
XmlDocument doc1 = new XmlDocument();
|
||
doc1.Load(path);
|
||
//获取当前XML文档的根 一级
|
||
XmlNode oNode = doc1.DocumentElement;
|
||
//获取根节点的所有子节点列表
|
||
XmlNodeList oList = oNode.ChildNodes;
|
||
//标记当前节点
|
||
XmlNode oCurrentNode;
|
||
//遍历所有二级节点
|
||
for (int i = 0; i < oList.Count; i++)
|
||
{
|
||
//二级
|
||
oCurrentNode = oList[i];
|
||
|
||
//检测当前节点的名称,节点的值是否与已知匹配 effectiveTime
|
||
if (oCurrentNode.Name.Equals("effectiveTime"))
|
||
{
|
||
if (oCurrentNode.HasChildNodes)
|
||
{
|
||
for (int n = 0; n < oCurrentNode.ChildNodes.Count; n++)
|
||
{
|
||
if (oCurrentNode.ChildNodes[n].Name.ToLower().Equals("low"))
|
||
{
|
||
var low = oCurrentNode.ChildNodes[n].Attributes["value"].Value;
|
||
evm.StartTime = Convert.ToDateTime(low.Substring(0, 4) + "-" + low.Substring(4, 2) + "-" + low.Substring(6, 2) + " " + low.Substring(8, 2) + ":" + low.Substring(10, 2) + ":" + low.Substring(12, 2));
|
||
}
|
||
if (oCurrentNode.ChildNodes[n].Name.ToLower().Equals("high"))
|
||
{
|
||
var high = oCurrentNode.ChildNodes[n].Attributes["value"].Value;
|
||
evm.StartTime = Convert.ToDateTime(high.Substring(0, 4) + "-" + high.Substring(4, 2) + "-" + high.Substring(6, 2) + " " + high.Substring(8, 2) + ":" + high.Substring(10, 2) + ":" + high.Substring(12, 2));
|
||
}
|
||
}
|
||
}
|
||
}
|
||
// //检测当前节点的名称,节点的值是否与已知匹配 component
|
||
if (oCurrentNode.Name.Equals("component"))
|
||
{
|
||
if (oCurrentNode.HasChildNodes)
|
||
{
|
||
for (int n = 0; n < oCurrentNode.ChildNodes.Count; n++)
|
||
{
|
||
var seriesNodes = oCurrentNode.ChildNodes[n];
|
||
var series = seriesNodes.Name.ToLower();
|
||
if (series == "series")
|
||
{
|
||
for (int k = 0; k < seriesNodes.ChildNodes.Count; k++)
|
||
{
|
||
var componentNodes = seriesNodes.ChildNodes[k];
|
||
var component = componentNodes.Name.ToLower();
|
||
if (component == "component")
|
||
{
|
||
for (int j = 0; j < componentNodes.ChildNodes.Count; j++)
|
||
{
|
||
var sequenceSetNodes = componentNodes.ChildNodes[j];
|
||
var sequenceSet = componentNodes.ChildNodes[j].Name.ToLower();
|
||
if (sequenceSet == "sequenceset")
|
||
{
|
||
for (int q = 0; q < sequenceSetNodes.ChildNodes.Count; q++)
|
||
{
|
||
var component_Nodes = sequenceSetNodes.ChildNodes[q];
|
||
var components = sequenceSetNodes.ChildNodes[q].Name.ToLower();
|
||
if (components == "component")
|
||
{
|
||
for (int w = 0; w < component_Nodes.ChildNodes.Count; w++)
|
||
{
|
||
var sequenceNodes = component_Nodes.ChildNodes[w];
|
||
var sequence = component_Nodes.ChildNodes[w].Name.ToLower();
|
||
if (sequence == "sequence")
|
||
{
|
||
for (int r = 0; r < sequenceNodes.ChildNodes.Count; r++)
|
||
{
|
||
var codeNodes = sequenceNodes.ChildNodes[r];
|
||
var code = codeNodes.Name.ToLower();
|
||
if (code == "code")
|
||
{
|
||
var codeAttributes = codeNodes.Attributes["code"].Value;
|
||
switch (codeAttributes)
|
||
{
|
||
case "TIME_ABSOLUTE":
|
||
break;
|
||
case "MDC_ECG_LEAD_I":
|
||
var valueNodes_I = sequenceNodes.ChildNodes[r + 1];
|
||
var value_I = valueNodes_I.Name.ToLower();
|
||
if (value_I == "value")
|
||
{
|
||
for (int m = 0; m < valueNodes_I.ChildNodes.Count; m++)
|
||
{
|
||
var digits_I = valueNodes_I.ChildNodes[m].Name.ToLower();
|
||
if (digits_I == "digits")
|
||
{
|
||
var digits_I_data = valueNodes_I.ChildNodes[m].InnerText;
|
||
evm.DicData.Add("I", digits_I_data);
|
||
}
|
||
}
|
||
}
|
||
break;
|
||
case "MDC_ECG_LEAD_II":
|
||
var valueNodes_II = sequenceNodes.ChildNodes[r + 1];
|
||
var value_II = valueNodes_II.Name.ToLower();
|
||
if (value_II == "value")
|
||
{
|
||
for (int m = 0; m < valueNodes_II.ChildNodes.Count; m++)
|
||
{
|
||
var digits_II = valueNodes_II.ChildNodes[m].Name.ToLower();
|
||
if (digits_II == "digits")
|
||
{
|
||
var digits_II_data = valueNodes_II.ChildNodes[m].InnerText;
|
||
evm.DicData.Add("II", digits_II_data);
|
||
}
|
||
}
|
||
}
|
||
break;
|
||
case "MDC_ECG_LEAD_III":
|
||
var valueNodes_III = sequenceNodes.ChildNodes[r + 1];
|
||
var value_III = valueNodes_III.Name.ToLower();
|
||
if (value_III == "value")
|
||
{
|
||
for (int m = 0; m < valueNodes_III.ChildNodes.Count; m++)
|
||
{
|
||
var digits_III = valueNodes_III.ChildNodes[m].Name.ToLower();
|
||
if (digits_III == "digits")
|
||
{
|
||
var digits_III_data = valueNodes_III.ChildNodes[m].InnerText;
|
||
evm.DicData.Add("III", digits_III_data);
|
||
}
|
||
}
|
||
}
|
||
break;
|
||
case "MDC_ECG_LEAD_AVR":
|
||
var valueNodes_AVR = sequenceNodes.ChildNodes[r + 1];
|
||
var value_AVR = valueNodes_AVR.Name.ToLower();
|
||
if (value_AVR == "value")
|
||
{
|
||
for (int m = 0; m < valueNodes_AVR.ChildNodes.Count; m++)
|
||
{
|
||
var digits_AVR = valueNodes_AVR.ChildNodes[m].Name.ToLower();
|
||
if (digits_AVR == "digits")
|
||
{
|
||
var digits_AVR_data = valueNodes_AVR.ChildNodes[m].InnerText;
|
||
evm.DicData.Add("AVR", digits_AVR_data);
|
||
}
|
||
}
|
||
}
|
||
break;
|
||
case "MDC_ECG_LEAD_AVL":
|
||
var valueNodes_AVL = sequenceNodes.ChildNodes[r + 1];
|
||
var value_AVL = valueNodes_AVL.Name.ToLower();
|
||
if (value_AVL == "value")
|
||
{
|
||
for (int m = 0; m < valueNodes_AVL.ChildNodes.Count; m++)
|
||
{
|
||
var digits_AVL = valueNodes_AVL.ChildNodes[m].Name.ToLower();
|
||
if (digits_AVL == "digits")
|
||
{
|
||
var digits_AVL_data = valueNodes_AVL.ChildNodes[m].InnerText;
|
||
evm.DicData.Add("AVL", digits_AVL_data);
|
||
}
|
||
}
|
||
}
|
||
break;
|
||
case "MDC_ECG_LEAD_AVF":
|
||
var valueNodes_AVF = sequenceNodes.ChildNodes[r + 1];
|
||
var value_AVF = valueNodes_AVF.Name.ToLower();
|
||
if (value_AVF == "value")
|
||
{
|
||
for (int m = 0; m < valueNodes_AVF.ChildNodes.Count; m++)
|
||
{
|
||
var digits_AVF = valueNodes_AVF.ChildNodes[m].Name.ToLower();
|
||
if (digits_AVF == "digits")
|
||
{
|
||
var digits_AVF_data = valueNodes_AVF.ChildNodes[m].InnerText;
|
||
evm.DicData.Add("AVF", digits_AVF_data);
|
||
}
|
||
}
|
||
}
|
||
break;
|
||
case "MDC_ECG_LEAD_V1":
|
||
var valueNodes_V1 = sequenceNodes.ChildNodes[r + 1];
|
||
var value_V1 = valueNodes_V1.Name.ToLower();
|
||
if (value_V1 == "value")
|
||
{
|
||
for (int m = 0; m < valueNodes_V1.ChildNodes.Count; m++)
|
||
{
|
||
var digits_V1 = valueNodes_V1.ChildNodes[m].Name.ToLower();
|
||
if (digits_V1 == "digits")
|
||
{
|
||
var digits_V1_data = valueNodes_V1.ChildNodes[m].InnerText;
|
||
evm.DicData.Add("V1", digits_V1_data);
|
||
}
|
||
}
|
||
}
|
||
break;
|
||
case "MDC_ECG_LEAD_V2":
|
||
var valueNodes_V2 = sequenceNodes.ChildNodes[r + 1];
|
||
var value_V2 = valueNodes_V2.Name.ToLower();
|
||
if (value_V2 == "value")
|
||
{
|
||
for (int m = 0; m < valueNodes_V2.ChildNodes.Count; m++)
|
||
{
|
||
var digits_V2 = valueNodes_V2.ChildNodes[m].Name.ToLower();
|
||
if (digits_V2 == "digits")
|
||
{
|
||
var digits_V2_data = valueNodes_V2.ChildNodes[m].InnerText;
|
||
evm.DicData.Add("V2", digits_V2_data);
|
||
}
|
||
}
|
||
}
|
||
break;
|
||
case "MDC_ECG_LEAD_V3":
|
||
var valueNodes_V3 = sequenceNodes.ChildNodes[r + 1];
|
||
var value_V3 = valueNodes_V3.Name.ToLower();
|
||
if (value_V3 == "value")
|
||
{
|
||
for (int m = 0; m < valueNodes_V3.ChildNodes.Count; m++)
|
||
{
|
||
var digits_V3 = valueNodes_V3.ChildNodes[m].Name.ToLower();
|
||
if (digits_V3 == "digits")
|
||
{
|
||
var digits_V3_data = valueNodes_V3.ChildNodes[m].InnerText;
|
||
evm.DicData.Add("V3", digits_V3_data);
|
||
}
|
||
}
|
||
}
|
||
break;
|
||
case "MDC_ECG_LEAD_V4":
|
||
var valueNodes_V4 = sequenceNodes.ChildNodes[r + 1];
|
||
var value_V4 = valueNodes_V4.Name.ToLower();
|
||
if (value_V4 == "value")
|
||
{
|
||
for (int m = 0; m < valueNodes_V4.ChildNodes.Count; m++)
|
||
{
|
||
var digits_V4 = valueNodes_V4.ChildNodes[m].Name.ToLower();
|
||
if (digits_V4 == "digits")
|
||
{
|
||
var digits_V4_data = valueNodes_V4.ChildNodes[m].InnerText;
|
||
evm.DicData.Add("V4", digits_V4_data);
|
||
}
|
||
}
|
||
}
|
||
break;
|
||
case "MDC_ECG_LEAD_V5":
|
||
var valueNodes_V5 = sequenceNodes.ChildNodes[r + 1];
|
||
var value_V5 = valueNodes_V5.Name.ToLower();
|
||
if (value_V5 == "value")
|
||
{
|
||
for (int m = 0; m < valueNodes_V5.ChildNodes.Count; m++)
|
||
{
|
||
var digits_V5 = valueNodes_V5.ChildNodes[m].Name.ToLower();
|
||
if (digits_V5 == "digits")
|
||
{
|
||
var digits_V5_data = valueNodes_V5.ChildNodes[m].InnerText;
|
||
evm.DicData.Add("V5", digits_V5_data);
|
||
}
|
||
}
|
||
}
|
||
break;
|
||
case "MDC_ECG_LEAD_V6":
|
||
var valueNodes_V6 = sequenceNodes.ChildNodes[r + 1];
|
||
var value_V6 = valueNodes_V6.Name.ToLower();
|
||
if (value_V6 == "value")
|
||
{
|
||
for (int m = 0; m < valueNodes_V6.ChildNodes.Count; m++)
|
||
{
|
||
var digits_V6 = valueNodes_V6.ChildNodes[m].Name.ToLower();
|
||
if (digits_V6 == "digits")
|
||
{
|
||
var digits_V6_data = valueNodes_V6.ChildNodes[m].InnerText;
|
||
evm.DicData.Add("V6", digits_V6_data);
|
||
}
|
||
}
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if (component == "subjectof")
|
||
{
|
||
for (int jj = 0; jj < componentNodes.ChildNodes.Count; jj++)
|
||
{
|
||
var annotationSetNodes = componentNodes.ChildNodes[jj];
|
||
var annotationSet = annotationSetNodes.Name.ToLower();
|
||
if (annotationSet == "annotationset")
|
||
{
|
||
for (int kk = 0; kk < annotationSetNodes.ChildNodes.Count; kk++)
|
||
{
|
||
var componentNodes_Of = annotationSetNodes.ChildNodes[kk];
|
||
var component_Of = componentNodes_Of.Name.ToLower();
|
||
if (component_Of == "component")
|
||
{
|
||
for (int ww = 0; ww < componentNodes_Of.ChildNodes.Count; ww++)
|
||
{
|
||
var annotationNodes = componentNodes_Of.ChildNodes[ww];
|
||
var annotation = annotationNodes.Name.ToLower();
|
||
if (annotation == "annotation")
|
||
{
|
||
for (int qq = 0; qq < annotationNodes.ChildNodes.Count; qq++)
|
||
{
|
||
var componentNodes_an = annotationNodes.ChildNodes[qq];
|
||
var component_an = componentNodes_an.Name.ToLower();
|
||
if (component_an == "component")
|
||
{
|
||
for (int rr = 0; rr < componentNodes_an.ChildNodes.Count; rr++)
|
||
{
|
||
var annotationNodes_com = componentNodes_an.ChildNodes[rr];
|
||
var annotation_com = annotationNodes_com.Name.ToLower();
|
||
if (annotation_com == "annotation")
|
||
{
|
||
for (int tt = 0; tt < annotationNodes_com.ChildNodes.Count; tt++)
|
||
{
|
||
var codeNodes_annotation = annotationNodes_com.ChildNodes[tt];
|
||
var component_annotation = codeNodes_annotation.Name.ToLower();
|
||
if (component_annotation == "component")
|
||
{
|
||
for (int uu = 0; uu < codeNodes_annotation.ChildNodes.Count; uu++)
|
||
{
|
||
var annotationNodes_uu = codeNodes_annotation.ChildNodes[uu];
|
||
var annotation_uu = annotationNodes_uu.Name.ToLower();
|
||
if (annotation_uu == "annotation")
|
||
{
|
||
for (int pp = 0; pp < annotationNodes_uu.ChildNodes.Count; pp++)
|
||
{
|
||
var ann_code = annotationNodes_uu.ChildNodes[pp].Name.ToLower();
|
||
if (ann_code == "code")
|
||
{
|
||
var annotation_code = annotationNodes_uu.ChildNodes[pp].Attributes["code"].Value;
|
||
if (annotation_code == "MDC_ECG_INTERPRETATION_STATEMENT")
|
||
{
|
||
//诊断结论
|
||
evm.AutoResult = annotationNodes_uu.ChildNodes[pp + 1].InnerText;
|
||
break;//跳出循环
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
}
|
||
}
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
//检测当前节点的名称,节点的值是否与已知匹配 caseinformation
|
||
if (oCurrentNode.Name.Equals("caseinformation"))
|
||
{
|
||
//检测是否有子节点 三级
|
||
if (oCurrentNode.HasChildNodes)
|
||
{
|
||
//遍历当前节点的所有子节点
|
||
for (int n = 0; n < oCurrentNode.ChildNodes.Count; n++)
|
||
{
|
||
//检测当前节点的子节点名称是否与已知匹配
|
||
if (oCurrentNode.ChildNodes[n].Name.ToLower() == "otherparam")
|
||
{
|
||
//遍历当前节点的所有子节点
|
||
for (int ii = 0; ii < oCurrentNode.ChildNodes[n].ChildNodes.Count; ii++)
|
||
{
|
||
if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.ToLower().Equals("casename"))
|
||
{
|
||
evm.PatientName = oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText;
|
||
}
|
||
if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.ToLower().Equals("sex"))
|
||
{
|
||
evm.Gender = oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText;
|
||
}
|
||
if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.ToLower().Equals("age"))
|
||
{
|
||
evm.Age = Convert.ToInt32(oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText);
|
||
}
|
||
}
|
||
}
|
||
|
||
//检测当前节点的子节点名称是否与已知匹配
|
||
if (oCurrentNode.ChildNodes[n].Name == "Parameters")
|
||
{
|
||
//遍历当前节点的所有子节点
|
||
for (int ii = 0; ii < oCurrentNode.ChildNodes[n].ChildNodes.Count; ii++)
|
||
{
|
||
if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.Equals("HR"))//心率
|
||
{
|
||
evm.Heart = Convert.ToInt32(oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText);
|
||
}
|
||
if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.Equals("PRInterval"))
|
||
{
|
||
evm.PR = Convert.ToInt32(oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText);
|
||
}
|
||
if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.Equals("PDuration"))
|
||
{
|
||
evm.PDuration = Convert.ToInt32(oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText);
|
||
}
|
||
if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.Equals("QRSDuration"))
|
||
{
|
||
evm.QRS = Convert.ToInt32(oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText);
|
||
}
|
||
|
||
if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.Equals("TDuration"))
|
||
{
|
||
evm.TDuration = Convert.ToInt32(oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText);
|
||
}
|
||
if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.Equals("QTInterval"))
|
||
{
|
||
evm.QT = Convert.ToInt32(oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText);
|
||
}
|
||
if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.Equals("QTcInterval"))
|
||
{
|
||
evm.QTc = Convert.ToInt32(oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText);
|
||
}
|
||
if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.Equals("PAxis"))
|
||
{
|
||
evm.PAxis = Convert.ToDouble(oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText);
|
||
}
|
||
if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.Equals("QRSAxis"))
|
||
{
|
||
evm.QRSAxis = Convert.ToDouble(oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText);
|
||
}
|
||
if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.Equals("TAxis"))
|
||
{
|
||
evm.TAxis = Convert.ToDouble(oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText);
|
||
}
|
||
if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.Equals("R_V5"))
|
||
{
|
||
evm.RV5 = Convert.ToDouble(oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText);
|
||
}
|
||
if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.Equals("S_V1"))
|
||
{
|
||
evm.SV1 = Convert.ToDouble(oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
}
|
||
return evm;
|
||
}
|
||
|
||
private void button8_Click(object sender, EventArgs e)
|
||
{
|
||
string ftpFile1 = Application.StartupPath + @"\ftpFile\ecg20191221141557.XML";
|
||
string ftpFile2 = Application.StartupPath + @"\ftpFile\ecg20191221141557.jpg";
|
||
string ftpFileName = Guid.NewGuid().ToString() + ".XML";
|
||
string ssss = FtpHelper.FileUpLoad(ftpFile1, "", ftpFileName);
|
||
textBox2.Text = ssss;
|
||
}
|
||
|
||
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
|
||
{
|
||
if (th_rabbitMQ != null)
|
||
th_rabbitMQ.Abort();//终止 rabbitMQ数据接收线程
|
||
}
|
||
}
|
||
}
|