From 6f9369ef8e2fc07156f037b9824b862dfd12b49f Mon Sep 17 00:00:00 2001 From: lxd <1004405501@qq.com> Date: Wed, 25 Dec 2024 17:21:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=A1=B9=E7=9B=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1200gFtp/EcgDataDraw_New.cs | 996 ++++++++++++++ 1200gFtp/EcgViewModel.cs | 131 ++ 1200gFtp/FLYecgReport.cs | 24 + 1200gFtp/FlyHisEcgdataModel.cs | 45 + 1200gFtp/FlyHisTokenMsg.cs | 23 + 1200gFtp/Form1.Designer.cs | 239 ++++ 1200gFtp/Form1.cs | 1502 +++++++++++++++++++++ 1200gFtp/Form1.resx | 200 +++ 1200gFtp/FtpHelper.cs | 289 ++++ 1200gFtp/Hl7EcgOptions.cs | 278 ++++ 1200gFtp/OssUnity.cs | 188 +++ 1200gFtp/PatientMd.cs | 277 ++++ 1200gFtp/Program.cs | 21 + 1200gFtp/Properties/AssemblyInfo.cs | 36 + 1200gFtp/Properties/Resources.Designer.cs | 63 + 1200gFtp/Properties/Resources.resx | 117 ++ 1200gFtp/Properties/Settings.Designer.cs | 26 + 1200gFtp/Properties/Settings.settings | 7 + 1200gFtp/SMS.cs | 75 + 1200gFtp/SqliteOptions.cs | 263 ++++ 1200gFtp/analysisParas.cs | 48 + 1200gFtp/apiList.cs | 21 + 1200gFtp/app.config | 19 + 1200gFtp/baseModel.cs | 14 + 1200gFtp/commonOptions.cs | 636 +++++++++ 1200gFtp/his03Model.cs | 52 + 1200gFtp/loginPara.cs | 14 + 1200gFtp/msgModel.cs | 14 + 1200gFtp/netOptions.cs | 102 ++ 1200gFtp/o13www.ixigua.com.ico | Bin 0 -> 4286 bytes 1200gFtp/packages.config | 5 + 1200gFtp/panduReturnModel.cs | 32 + 1200gFtp/patientInfoFLY.cs | 34 + 1200gFtp/patientInfoModel.cs | 25 + 1200gFtp/returnPatientModel.cs | 16 + 1200gFtp/tokenMsg.cs | 15 + 1200gFtp/云心电ECG数据解析服务端.csproj | 138 ++ xml读取.txt | 139 ++ 云心电ECG数据解析服务端.sln | 25 + 39 files changed, 6149 insertions(+) create mode 100644 1200gFtp/EcgDataDraw_New.cs create mode 100644 1200gFtp/EcgViewModel.cs create mode 100644 1200gFtp/FLYecgReport.cs create mode 100644 1200gFtp/FlyHisEcgdataModel.cs create mode 100644 1200gFtp/FlyHisTokenMsg.cs create mode 100644 1200gFtp/Form1.Designer.cs create mode 100644 1200gFtp/Form1.cs create mode 100644 1200gFtp/Form1.resx create mode 100644 1200gFtp/FtpHelper.cs create mode 100644 1200gFtp/Hl7EcgOptions.cs create mode 100644 1200gFtp/OssUnity.cs create mode 100644 1200gFtp/PatientMd.cs create mode 100644 1200gFtp/Program.cs create mode 100644 1200gFtp/Properties/AssemblyInfo.cs create mode 100644 1200gFtp/Properties/Resources.Designer.cs create mode 100644 1200gFtp/Properties/Resources.resx create mode 100644 1200gFtp/Properties/Settings.Designer.cs create mode 100644 1200gFtp/Properties/Settings.settings create mode 100644 1200gFtp/SMS.cs create mode 100644 1200gFtp/SqliteOptions.cs create mode 100644 1200gFtp/analysisParas.cs create mode 100644 1200gFtp/apiList.cs create mode 100644 1200gFtp/app.config create mode 100644 1200gFtp/baseModel.cs create mode 100644 1200gFtp/commonOptions.cs create mode 100644 1200gFtp/his03Model.cs create mode 100644 1200gFtp/loginPara.cs create mode 100644 1200gFtp/msgModel.cs create mode 100644 1200gFtp/netOptions.cs create mode 100644 1200gFtp/o13www.ixigua.com.ico create mode 100644 1200gFtp/packages.config create mode 100644 1200gFtp/panduReturnModel.cs create mode 100644 1200gFtp/patientInfoFLY.cs create mode 100644 1200gFtp/patientInfoModel.cs create mode 100644 1200gFtp/returnPatientModel.cs create mode 100644 1200gFtp/tokenMsg.cs create mode 100644 1200gFtp/云心电ECG数据解析服务端.csproj create mode 100644 xml读取.txt create mode 100644 云心电ECG数据解析服务端.sln diff --git a/1200gFtp/EcgDataDraw_New.cs b/1200gFtp/EcgDataDraw_New.cs new file mode 100644 index 0000000..d57accb --- /dev/null +++ b/1200gFtp/EcgDataDraw_New.cs @@ -0,0 +1,996 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Drawing; +using System.Data; +using System.Windows.Forms; +using System.IO; + + +namespace 云心电ECG数据解析服务端 +{ + public class EcgDataDraw_New + { + int Amplitude = 10;//振幅 + int PaperSpeed = 25; + double AmplificationFactor = 140.00; + //int AmplificationFactor = 60; + int SamplingRate = 300; + int LeadCount = 12; + int byteLength = 2; + int Dpi = 96; + double LenthPerInch = 25.4; + int BaseLine = 0; + int LeadHeight = 0; + Pen Ecg_Pen; + Graphics Ecg_Graphics; + Bitmap Ecg_Canvas; + public List LeadInfo = new List(); + Dictionary> EcgDataList; + int FreePixs = 0; + Point FirstPosition = new Point(0, 0); + Point SecondPosition = new Point(0, 0); + Dictionary FirstPointArray = new Dictionary(); + + //存放心电数据的字典 按照 每导联顺序进行存储 + Dictionary> EcgData_Dic = new Dictionary>(); + /// + /// + /// + /// + /// + /// + /// + public void InitEcgParameter(Bitmap btmp, int leadCount, Dictionary> EcgTable, int NewDpi, List leadinfo) + { + //string[] WavePara = File.ReadAllText(Application.StartupPath + @"\WavePara.txt").Trim().Split(','); + //SamplingRate = int.Parse(WavePara[0].Trim()); + //AmplificationFactor = double.Parse(WavePara[1].Trim()); + + + SamplingRate =300; + AmplificationFactor = 10; + + Ecg_Canvas = btmp; + Ecg_Graphics = Graphics.FromImage(Ecg_Canvas); + Ecg_Graphics.Clear(Color.White);//填充指定颜色 + + LeadCount = leadCount; + LeadInfo = leadinfo; + BaseLine = (btmp.Height / LeadInfo.Count) / 2; + + LeadHeight = (btmp.Height / (LeadInfo.Count/2)); + Dpi = NewDpi; + EcgData_Dic = EcgTable; + Ecg_Pen = new Pen(Color.Gray, float.Parse("0.5")); + FreePixs = int.Parse(Math.Round((double.Parse(Dpi.ToString()) / LenthPerInch) * 5).ToString()); + } + + + /// + /// 绘制心电波形 + /// + public void Draw_EcgWave(int Draw_InitHeight,int BottomHeight,int wucan) + { + Ecg_Pen = new Pen(Color.Black, float.Parse("2")); + double IntervalPixCountPerPoint = double.Parse("0.302"); + for (int i = 0; i < LeadInfo.Count; i++) + { + int LeadIndex = LeadInfo[i];//取导联下标 0 1 2 3 ...11 + if (i < 6) + { + //BaseLine = (Ecg_Canvas.Height / (LeadInfo.Count / 2)) / 2 + (i * LeadHeight); + BaseLine = ((Ecg_Canvas.Height - Draw_InitHeight - BottomHeight) / (LeadInfo.Count / 2)) / 2 + (i * ((Ecg_Canvas.Height - Draw_InitHeight - BottomHeight) / (LeadInfo.Count / 2))) + Draw_InitHeight; + FirstPosition.Y = BaseLine; + FirstPosition.X = FreePixs; + SecondPosition.Y = BaseLine; + SecondPosition.X = FreePixs; + Point FP = new Point(FirstPosition.X + FreePixs, FirstPosition.Y); + FirstPointArray.Add(LeadIndex.ToString(), FP); + } + else + { + //BaseLine = (Ecg_Canvas.Height / (LeadInfo.Count / 2)) / 2 + ((i - 6) * LeadHeight); + BaseLine = ((Ecg_Canvas.Height - Draw_InitHeight - BottomHeight) / (LeadInfo.Count / 2)) / 2 + ((i - 6) * ((Ecg_Canvas.Height - Draw_InitHeight - BottomHeight) / (LeadInfo.Count / 2))) + Draw_InitHeight; + FirstPosition.Y = BaseLine; + FirstPosition.X = FreePixs + Ecg_Canvas.Width / 2; + SecondPosition.Y = BaseLine; + SecondPosition.X = FreePixs + Ecg_Canvas.Width / 2; + Point FP = new Point(FirstPosition.X + FreePixs, FirstPosition.Y); + FirstPointArray.Add(LeadIndex.ToString(), FP); + } + if (EcgData_Dic.Count > 0) + for (int b = 0; b < EcgData_Dic[LeadIndex].Count; b++) + { + if (i < 6) + { + if (FirstPosition.X > Ecg_Canvas.Width / 2 - 5) + break; + } + else + { + if (FirstPosition.X > Ecg_Canvas.Width) + break; + } + float y_values = 0; + try + { + //y_values = EcgData_Dic[LeadIndex][b] * (float)(96 / 25.4)*10; + y_values = EcgData_Dic[LeadIndex][b] * (float)(96 / 25.4) * (float)0.165; + } + catch { } + SecondPosition.Y = BaseLine - (Int32)y_values;//后一点Y轴位置 + + double x = double.Parse(b.ToString()) * IntervalPixCountPerPoint*1; + int nextX = (int.Parse(Math.Round(x).ToString())); + if (Math.Abs(FirstPosition.X - SecondPosition.X) < 5) + { + if (i < 6) + { + SecondPosition.X = nextX + FreePixs; + Ecg_Graphics.DrawLine(Ecg_Pen, FirstPosition, SecondPosition); + FirstPosition = SecondPosition; + } + else + { + SecondPosition.X = Ecg_Canvas.Width / 2 + FreePixs + nextX; + Ecg_Graphics.DrawLine(Ecg_Pen, FirstPosition, SecondPosition); + FirstPosition = SecondPosition; + } + } + else + FirstPosition = SecondPosition; + } + } + } + + /// + /// 绘制心电波形 + /// + public void Draw_EcgWave(int Draw_InitHeight,int BottomHeight) + { + FirstPointArray.Clear(); + Draw_InitHeight = Draw_InitHeight * FreePixs; + BottomHeight = BottomHeight * FreePixs; + Ecg_Pen = new Pen(Color.Black, float.Parse("2")); + //double IntervalPixCountPerPoint = (double.Parse(PaperSpeed.ToString()) / double.Parse(SamplingRate.ToString())) * (double.Parse(Dpi.ToString()) / LenthPerInch); + + //double IntervalPixCountPerPoint = double.Parse("0.134"); + double IntervalPixCountPerPoint = double.Parse("0.302"); + for (int i = 0; i < LeadInfo.Count; i++) + { + int LeadIndex = LeadInfo[i];//取导联下标 0 1 2 3 ...11 + if (i < 6) + { + //BaseLine = (Ecg_Canvas.Height / (LeadInfo.Count / 2)) / 2 + (i * LeadHeight); + BaseLine = ((Ecg_Canvas.Height - Draw_InitHeight - BottomHeight) / (LeadInfo.Count / 2)) / 2 + (i * ((Ecg_Canvas.Height - Draw_InitHeight - BottomHeight) / (LeadInfo.Count / 2))) + Draw_InitHeight; + FirstPosition.Y = BaseLine; + FirstPosition.X = FreePixs; + SecondPosition.Y = BaseLine; + SecondPosition.X = FreePixs; + Point FP = new Point(FirstPosition.X + FreePixs, FirstPosition.Y); + FirstPointArray.Add(LeadIndex.ToString(), FP); + } + else + { + BaseLine = ((Ecg_Canvas.Height - Draw_InitHeight - BottomHeight) / (LeadInfo.Count / 2)) / 2 + ((i - 6) * ((Ecg_Canvas.Height - Draw_InitHeight - BottomHeight) / (LeadInfo.Count / 2))) + Draw_InitHeight; + FirstPosition.Y = BaseLine; + FirstPosition.X = FreePixs + Ecg_Canvas.Width / 2; + SecondPosition.Y = BaseLine; + SecondPosition.X = FreePixs + Ecg_Canvas.Width / 2; + Point FP = new Point(FirstPosition.X + FreePixs, FirstPosition.Y); + FirstPointArray.Add(LeadIndex.ToString(), FP); + } + for (int b = 0; b < EcgData_Dic[LeadIndex].Count; b+=3) + { + if (i < 6) + { + if (FirstPosition.X > Ecg_Canvas.Width / 2 - 5) + break; + } + else + { + if (FirstPosition.X > Ecg_Canvas.Width) + break; + } + //double c = double.Parse(EcgData_Dic[LeadIndex][b].ToString()); + //double d = double.Parse((double.Parse(Dpi.ToString()) / double.Parse("96")).ToString()); + //SecondPosition.Y = BaseLine - (int)(c * d); + float y_values = 0; + try + { + //y_values = EcgData_Dic[LeadIndex][b] * (float)(300 / 25.4)*10; + y_values = EcgData_Dic[LeadIndex][b] * (float)(300 / 25.4) * (float)9.5; + } + catch { } + SecondPosition.Y = BaseLine - (Int32)y_values;//后一点Y轴位置 + + double x = double.Parse(b.ToString()) * IntervalPixCountPerPoint; + int nextX = (int.Parse(Math.Round(x).ToString())); + if (Math.Abs(FirstPosition.X - SecondPosition.X) < 5) + { + if (i < 6) + { + SecondPosition.X = nextX + FreePixs; + Ecg_Graphics.DrawLine(Ecg_Pen, FirstPosition, SecondPosition); + FirstPosition = SecondPosition; + } + else + { + SecondPosition.X = Ecg_Canvas.Width / 2 + FreePixs + nextX; + Ecg_Graphics.DrawLine(Ecg_Pen, FirstPosition, SecondPosition); + FirstPosition = SecondPosition; + } + } + else + FirstPosition = SecondPosition; + } + } + } + + + /// + /// 绘制心电报告的报告头 + /// + public void Draw_ReportHeadInfo(string ReportHeadTile, string SectionName,string IdStr) + { + Pen pen_1 = new Pen(Color.Black, float.Parse("4")); + + Font font1 = new Font("宋体", 40); + Brush brush = Brushes.Black; + + PointF point2 = new PointF(Ecg_Canvas.Width/2-200, FreePixs/2); + Ecg_Graphics.DrawString(ReportHeadTile, font1, brush, point2); + + Font font = new Font("宋体", 10); + //PointF point = new PointF(10, FreePixs * 3-20); + //Ecg_Graphics.DrawString("科室:" + SectionName, font, brush, point); + + PointF pointId = new PointF(Ecg_Canvas.Width - 3400, FreePixs * 4-20); + Ecg_Graphics.DrawString("ID:" + IdStr, font, brush, pointId); + + //PointF point1 = new PointF(Ecg_Canvas.Width-1200, FreePixs * 3-20); + //Ecg_Graphics.DrawString("报告日期:" + ReportDate, font, brush, point1); + + // Ecg_Graphics.DrawLine(pen_1, 0, FreePixs * 4-60, Ecg_Canvas.Width, FreePixs * 4-60); + } + ///// + ///// 绘制患者的心电识别的参数 + ///// + //public void Draw_EcgInfo(string[] Diag_Info_List) + //{ + // Pen pen_1 = new Pen(Color.Black, float.Parse("4")); + // Font font1 = new Font("宋体", 10); + // Brush brush = Brushes.Black; + + // PointF point = new PointF(10, FreePixs * 4+10); + // Ecg_Graphics.DrawString(Diag_Info_List[0], font1, brush, point);//姓名 + // PointF point_1 = new PointF(10, FreePixs * 5 + 25); + // Ecg_Graphics.DrawString(Diag_Info_List[1], font1, brush, point_1);//性别 + // PointF point_2 = new PointF(10, FreePixs * 6 + 35); + // Ecg_Graphics.DrawString(Diag_Info_List[2], font1, brush, point_2);//年龄 + + // PointF point_3 = new PointF(600, FreePixs * 4 + 10); + // Ecg_Graphics.DrawString(Diag_Info_List[3], font1, brush, point_3);//P + // PointF point_4 = new PointF(600, FreePixs * 5 + 25); + // Ecg_Graphics.DrawString(Diag_Info_List[4], font1, brush, point_4);//P-R + // PointF point_5 = new PointF(600, FreePixs * 6 + 35); + // Ecg_Graphics.DrawString(Diag_Info_List[5], font1, brush, point_5);//QRS + + // PointF point_6 = new PointF(1200, FreePixs * 4 + 10); + // Ecg_Graphics.DrawString(Diag_Info_List[6], font1, brush, point_6);//QT/QTC + // PointF point_7 = new PointF(1200, FreePixs * 5 + 25); + // Ecg_Graphics.DrawString(Diag_Info_List[7], font1, brush, point_7);//QRS电轴 + // PointF point_8 = new PointF(1200, FreePixs * 6 + 35); + // Ecg_Graphics.DrawString(Diag_Info_List[8], font1, brush, point_8);//RV5/SV1 + + // PointF point_9 = new PointF(1800, FreePixs * 4 + 10); + // Ecg_Graphics.DrawString(Diag_Info_List[9], font1, brush, point_9);//心率 + + + // Ecg_Graphics.DrawLine(pen_1, 0, FreePixs * 8, Ecg_Canvas.Width, FreePixs * 8); + //} + /// + /// 绘制患者的心电识别的参数 + /// + public void Draw_EcgInfo(string[] Diag_Info_List) + { + Pen pen_1 = new Pen(Color.Black, float.Parse("4")); + Font font1 = new Font("宋体", 10); + Brush brush = Brushes.Black; + + PointF point = new PointF(600, FreePixs * 4-20); + Ecg_Graphics.DrawString(Diag_Info_List[0], font1, brush, point);//姓名 + + PointF point_1 = new PointF(1200, FreePixs * 4 -20); + Ecg_Graphics.DrawString(Diag_Info_List[1], font1, brush, point_1);//性别 + + PointF point_2 = new PointF(1800, FreePixs * 4-20); + Ecg_Graphics.DrawString(Diag_Info_List[2], font1, brush, point_2);//年龄 + + + + //PointF point_4 = new PointF(600, FreePixs * 5 + 25); + //Ecg_Graphics.DrawString(Diag_Info_List[3], font1, brush, point_4);//P + + PointF point_5 = new PointF(10, FreePixs * 5 + 5); + Ecg_Graphics.DrawString(Diag_Info_List[4], font1, brush, point_5);//P-R + + PointF point_6 = new PointF(600, FreePixs * 5 + 5); + Ecg_Graphics.DrawString(Diag_Info_List[5], font1, brush, point_6);//QRS + + PointF point_3 = new PointF(1200, FreePixs * 5 + 5); + Ecg_Graphics.DrawString(Diag_Info_List[9], font1, brush, point_3);//心率 + + + PointF point_7 = new PointF(10, FreePixs * 6 + 35); + Ecg_Graphics.DrawString(Diag_Info_List[6], font1, brush, point_7);//QT/QTC + + PointF point_8 = new PointF(600, FreePixs * 6 + 35); + Ecg_Graphics.DrawString(Diag_Info_List[7], font1, brush, point_8);//QRS电轴 + + PointF point_9 = new PointF(1200, FreePixs * 6 + 35); + Ecg_Graphics.DrawString(Diag_Info_List[8], font1, brush, point_9);//RV5/SV1 + + + Ecg_Graphics.DrawLine(pen_1, 0, FreePixs * 8, Ecg_Canvas.Width, FreePixs * 8); + } + + /// + /// 绘制医生的诊断结果 + /// + public void Draw_DiagInfo(string DiagInfoContent,string ReportDoctorName,string ReportDate,string Filter,string collectTime,string dept) + { + string[] diagresultecontent = new string[DiagInfoContent.Length/48+1]; + for (int a = 0; a < DiagInfoContent.Length / 48 + 1;a++ ) + { + if (a < DiagInfoContent.Length / 48) + diagresultecontent[a] = DiagInfoContent.Substring(a * 48, 48); + else + diagresultecontent[a] = DiagInfoContent.Substring(a * 48, DiagInfoContent.Length - a * 48); + } + Pen pen_1 = new Pen(Color.Black, float.Parse("4")); + Font font1 = new Font("宋体", 12); + Brush brush = Brushes.Black; + Ecg_Graphics.DrawLine(pen_1, 0, Ecg_Canvas.Height - FreePixs * 6, Ecg_Canvas.Width, Ecg_Canvas.Height - FreePixs * 6); + + PointF point1 = new PointF(10, Ecg_Canvas.Height - FreePixs * 6 + 10); + Ecg_Graphics.DrawString("诊断提示:", font1, brush, point1);//诊断结果 + for (int i = 0; i < diagresultecontent.Length; i++) + { + PointF point5 = new PointF(230, Ecg_Canvas.Height - FreePixs * (6-i) + 10); + Ecg_Graphics.DrawString(diagresultecontent[i].Trim(), font1, brush, point5);//诊断结果 + } + + PointF pointb = new PointF(Ecg_Canvas.Width - 1800, Ecg_Canvas.Height - FreePixs * 2); + Ecg_Graphics.DrawString("科室:" + dept, font1, brush, pointb);//报告医生 + + PointF point2 = new PointF(Ecg_Canvas.Width - 1200, Ecg_Canvas.Height - FreePixs * 2); + Ecg_Graphics.DrawString("报告医生:" + ReportDoctorName, font1, brush, point2);//报告医生 + + PointF point9 = new PointF(Ecg_Canvas.Width - 600, Ecg_Canvas.Height - FreePixs * 2); + Ecg_Graphics.DrawString("报告日期:" + ReportDate, font1, brush, point9);//报告医生 + + PointF point10 = new PointF(1800, FreePixs * 6 + 35); + Ecg_Graphics.DrawString("25mm/s 10mm/mV " + Filter, font1, brush, point10);//振幅 走纸速度 滤波 + PointF point11 = new PointF(Ecg_Canvas.Width - 600, Ecg_Canvas.Height - FreePixs * 7 - 5); + Ecg_Graphics.DrawString(collectTime, font1, brush, point11);//波形的起始时间点 + + Ecg_Graphics.DrawLine(pen_1, 0, Ecg_Canvas.Height - FreePixs, Ecg_Canvas.Width, Ecg_Canvas.Height - FreePixs); + } + ///// + ///// 绘制心电波形 + ///// + //public void Draw_EcgWave() + //{ + // Ecg_Pen = new Pen(Color.Black, float.Parse("0.5")); + // for (int i = 0; i < LeadInfo.Count; i++) + // { + // int LeadIndex = LeadInfo[i];//取导联下标 0 1 2 3 ...11 + // BaseLine = (Ecg_Canvas.Height / LeadInfo.Count) / 2 + (i * LeadHeight); + // FirstPosition.Y = BaseLine; + // FirstPosition.X = FreePixs; + // SecondPosition.Y = BaseLine; + // SecondPosition.X = FreePixs; + // Point FP = new Point(FirstPosition.X + FreePixs, FirstPosition.Y); + // FirstPointArray.Add(LeadIndex.ToString(), FP); + // for (int b = 0; b < EcgDataList[LeadIndex].Count; b++) + // { + // if (FirstPosition.X > Ecg_Canvas.Width) + // break; + // if (EcgDataList[LeadIndex][b] > 0) + // SecondPosition.Y = Math.Abs(BaseLine - EcgDataList[LeadIndex][b]); + // if (EcgDataList[LeadIndex][b] < 0) + // SecondPosition.Y = BaseLine + Math.Abs(EcgDataList[LeadIndex][b]); + // double x = double.Parse(b.ToString()) * (double.Parse(Dpi.ToString()) / double.Parse(SamplingRate.ToString()));//获得点的X轴位置 + // int nextX = (int.Parse(Math.Round(x).ToString())); + // if (Math.Abs(FirstPosition.X - SecondPosition.X) < 5) + // { + // SecondPosition.X = nextX + FreePixs; + // Ecg_Graphics.DrawLine(Ecg_Pen, FirstPosition, SecondPosition); + // FirstPosition = SecondPosition; + // } + // else + // FirstPosition = SecondPosition; + // } + // } + //} + + ///// + ///// 绘制心电图的背景网格 + ///// + //public void Draw_EcgBackGroundGrid() + //{ + // Ecg_Pen = new Pen(Color.LightCoral, float.Parse("0.1")); + // bool shuxianFlag = false; + // double PointCountPerMM = Math.Abs(double.Parse(Dpi.ToString()) / LenthPerInch); + // int x = 0; + // int y = 0; + // for (int p = 0; p < Ecg_Canvas.Height / PointCountPerMM; p++) + // { + // for (int R = 0; R < Ecg_Canvas.Width / PointCountPerMM; R++) + // { + // if (x % 5 == 0 && !shuxianFlag) + // { + // Ecg_Graphics.DrawLine(Ecg_Pen, x, 0, x, Ecg_Canvas.Height); + // } + // x += int.Parse(Math.Round(double.Parse(PointCountPerMM.ToString("0.0"))).ToString()); + // if (x < Ecg_Canvas.Width && y < Ecg_Canvas.Height) + // { + // Ecg_Canvas.SetPixel(x, y, Color.LightCoral); + // } + // else + // { + // x = 0; + // break; + // } + // } + // shuxianFlag = true; + // if (y % 5 == 0) + // { + // Ecg_Graphics.DrawLine(Ecg_Pen, 0, y, Ecg_Canvas.Width, y); + // } + // y += int.Parse(Math.Round(double.Parse(PointCountPerMM.ToString("0.0"))).ToString()); + + // if (y > Ecg_Canvas.Height) + // { + // break; + // } + // } + //} + + /// + /// 绘制心电图的背景网格 + /// + public void Draw_EcgBackGroundGrid() + { + Ecg_Pen = new Pen(Color.LightCoral, float.Parse("0.1")); + //Ecg_Pen = new Pen(Color.Black, float.Parse("0.1")); + bool shuxianFlag = false; + double PointCountPerMM = Math.Abs(double.Parse(Dpi.ToString()) / LenthPerInch); + int x = 0; + int y = 400; + for (int p = 0; p < Ecg_Canvas.Height / PointCountPerMM; p++) + { + for (int R = 0; R < Ecg_Canvas.Width / PointCountPerMM; R++) + { + if (x % 5 == 0 && !shuxianFlag) + { + Ecg_Graphics.DrawLine(Ecg_Pen, x, y, x, Ecg_Canvas.Height); + } + x += int.Parse(Math.Round(double.Parse(PointCountPerMM.ToString("0.0"))).ToString()); + if (x < Ecg_Canvas.Width && y < Ecg_Canvas.Height) + { + Ecg_Canvas.SetPixel(x, y, Color.Black); + } + else + { + x = 0; + break; + } + } + shuxianFlag = true; + if (y % 5 == 0) + { + Ecg_Graphics.DrawLine(Ecg_Pen, 0, y, Ecg_Canvas.Width, y); + } + y += int.Parse(Math.Round(double.Parse(PointCountPerMM.ToString("0.0"))).ToString()); + + if (y > Ecg_Canvas.Height) + { + break; + } + } + } + + /// + /// 绘制 患者信息和分析参数 + /// + /// + public void Draw_analysisParas(analysisParas ap) + { + Pen pen_1 = new Pen(Color.Black, float.Parse("2")); + + Font font1 = new Font("楷体", 25); + Brush brush = Brushes.Black; + + PointF point2 = new PointF(20,60); + Ecg_Graphics.DrawString("ID:"+ap.patientid, font1, brush, point2);//患者id + PointF point3 = new PointF(420, 60); + Ecg_Graphics.DrawString(ap.patientName, font1, brush, point3);//姓名 + PointF point4 = new PointF(570, 60); + Ecg_Graphics.DrawString(ap.gender, font1, brush, point4);//性别 + PointF point5 = new PointF(720, 60); + Ecg_Graphics.DrawString(ap.age, font1, brush, point5);//年龄 + + PointF point6 = new PointF(20, 110); + Ecg_Graphics.DrawString("HR :" + ap.heartRate+" bpm", font1, brush, point6);//心率 + + PointF point7 = new PointF(20, 140); + Ecg_Graphics.DrawString("P :" + ap.P+" ms", font1, brush, point7);//P波 + + PointF point8= new PointF(20, 170); + Ecg_Graphics.DrawString("QRS :" + ap.QRS + " ms", font1, brush, point8);//QRS波 + + PointF point9 = new PointF(20, 200); + Ecg_Graphics.DrawString("RR :" + ap.RR + " ms", font1, brush, point9);//RR + + PointF point10 = new PointF(20, 230); + Ecg_Graphics.DrawString("PR :" + ap.PR + " ms", font1, brush, point10);//PR + + PointF point11 = new PointF(20, 260); + Ecg_Graphics.DrawString("PQ :" + ap.PQ + " ms", font1, brush, point11);//PQ + + PointF point12 = new PointF(20, 290); + Ecg_Graphics.DrawString("QT :" + ap.QT + " ms", font1, brush, point12);//QT + + PointF point13 = new PointF(20, 320); + Ecg_Graphics.DrawString("QTc :" + ap.QTc + " ms", font1, brush, point13);//QTc + + PointF point14 = new PointF(20, 350); + Ecg_Graphics.DrawString("P/QRS/T :" + ap.P_degrees+"/"+ ap.QRS_degrees+ "/" + ap.T_degrees+ " °", font1, brush, point14);//P/QRS/T 电轴 + + PointF point15 = new PointF(20, 380); + Ecg_Graphics.DrawString("RV5/SV1 :" + ap.RV5+"/"+ ap.SV1+" mV", font1, brush, point15);//RV5/SV1 + + PointF point16 = new PointF(20, 410); + Ecg_Graphics.DrawString("RV5+SV1 :" + ap.RV5PLUSSV1 + " mV", font1, brush, point16);//RV5+SV1 + + PointF point17 = new PointF(20, 440); + Ecg_Graphics.DrawString("QT/QTc :" + ap.QT+"/"+ap.QTc+" ms", font1, brush, point17);//QT/QTc + + + Font font2 = new Font("宋体", 30,FontStyle.Bold); + PointF point18 = new PointF(1000, 110); + Ecg_Graphics.DrawString("诊断信息:", font2, brush, point18);//诊断信息 + + PointF point21 = new PointF(2500, 440); + Ecg_Graphics.DrawString("报告医生:", font2, brush, point21);//报告医生 + + + PointF point19 = new PointF(120, 2300); + Ecg_Graphics.DrawString("25mm/s 10mm/mV", font1, brush, point19);//增益 走速 + + PointF point20 = new PointF(2500, 2300); + Ecg_Graphics.DrawString(ap.collectTime, font1, brush, point20);//采集时间 + + } + /// + /// 绘制心电图的背景网格 + /// + public void Draw_EcgBackGroundGrid(int GridHeight) + { + Ecg_Pen = new Pen(Color.LightCoral, float.Parse("0.1")); + //Ecg_Pen = new Pen(Color.Black, float.Parse("0.1")); + bool shuxianFlag = false; + double PointCountPerMM = Math.Abs(double.Parse(Dpi.ToString()) / LenthPerInch); + int x = 0; + for (int p = 0; p < Ecg_Canvas.Height / PointCountPerMM; p++) + { + for (int R = 0; R < Ecg_Canvas.Width / PointCountPerMM; R++) + { + if (x % 5 == 0 && !shuxianFlag) + { + Ecg_Graphics.DrawLine(Ecg_Pen, x, GridHeight, x, Ecg_Canvas.Height); + } + x += int.Parse(Math.Round(double.Parse(PointCountPerMM.ToString("0.0"))).ToString()); + if (x < Ecg_Canvas.Width && GridHeight < Ecg_Canvas.Height) + { + Ecg_Canvas.SetPixel(x, GridHeight, Color.Black); + } + else + { + x = 0; + break; + } + } + shuxianFlag = true; + if (GridHeight % 5 == 0) + { + Ecg_Graphics.DrawLine(Ecg_Pen, 0, GridHeight, Ecg_Canvas.Width, GridHeight); + } + GridHeight += int.Parse(Math.Round(double.Parse(PointCountPerMM.ToString("0.0"))).ToString()); + + if (GridHeight > Ecg_Canvas.Height) + { + break; + } + } + } + + + + /// + /// 绘制心电图的背景网格 + /// + public void Draw_EcgBackGroundGrid(int height1,int height2,int PenWidth) + { + if (PenWidth == 0) + Ecg_Pen = new Pen(Color.LightCoral, float.Parse("0.1")); + else + Ecg_Pen = new Pen(Color.Black, float.Parse("1")); + //Ecg_Pen = new Pen(Color.Black, PenWidth); + bool shuxianFlag = false; + double PointCountPerMM = Math.Abs(double.Parse(Dpi.ToString()) / LenthPerInch); + height1 = height1 * (int)PointCountPerMM; + height2 = height2 * (int)PointCountPerMM; + int x = 0; + int y = 0; + for (int p = 0; p < Ecg_Canvas.Height / PointCountPerMM; p++) + { + for (int R = 0; R < Ecg_Canvas.Width / PointCountPerMM; R++) + { + if (x % 5 == 0 && !shuxianFlag) + { + //Ecg_Graphics.DrawLine(Ecg_Pen, x, 0, x, Ecg_Canvas.Height); + Ecg_Graphics.DrawLine(Ecg_Pen, x, height1, x, height2); + } + x += int.Parse(Math.Round(double.Parse(PointCountPerMM.ToString("0.0"))).ToString()); + if (x < Ecg_Canvas.Width && y < Ecg_Canvas.Height) + { + if (y >= height1 && y <= height2) + Ecg_Canvas.SetPixel(x, y, Color.Black); + //Ecg_Canvas.SetPixel(x, y, Color.LightCoral); + } + else + { + x = 0; + break; + } + } + shuxianFlag = true; + if (y % 5 == 0) + { + if (y >= height1 && y <= height2) + Ecg_Graphics.DrawLine(Ecg_Pen, 0, y, Ecg_Canvas.Width, y); + } + y += int.Parse(Math.Round(double.Parse(PointCountPerMM.ToString("0.0"))).ToString()); + + if (y > Ecg_Canvas.Height) + { + break; + } + } + } + /// + /// 绘制心电图的大网格 5mm大网格 + /// + public void Draw_BigGrid() + { + Ecg_Pen = new Pen(Color.LightCoral, float.Parse("0.1")); + bool shuxianFlag = false; + double PointCountPerMM = Math.Abs(double.Parse(Dpi.ToString()) / LenthPerInch); + int x = 0; + int y = 0; + for (int p = 0; p < Ecg_Canvas.Height / PointCountPerMM; p++) + { + for (int R = 0; R < Ecg_Canvas.Width / PointCountPerMM; R++) + { + if (x % 5 == 0 && !shuxianFlag) + { + Ecg_Graphics.DrawLine(Ecg_Pen, x, 0, x, Ecg_Canvas.Height); + } + x += int.Parse(Math.Round(double.Parse(PointCountPerMM.ToString("0.0"))).ToString()); + if (x < Ecg_Canvas.Width && y < Ecg_Canvas.Height) + { + //Ecg_Canvas.SetPixel(x, y, Color.LightCoral); + } + else + { + x = 0; + break; + } + } + shuxianFlag = true; + if (y % 5 == 0) + { + Ecg_Graphics.DrawLine(Ecg_Pen, 0, y, Ecg_Canvas.Width, y); + } + y += int.Parse(Math.Round(double.Parse(PointCountPerMM.ToString("0.0"))).ToString()); + + if (y > Ecg_Canvas.Height) + { + break; + } + } + } + + /// + /// 绘制心电图的定标电压和导联名称 + /// + public void Draw_CalibrationVoltage_And_LeadName() + { + Ecg_Pen = new Pen(Color.Black, float.Parse("1.5")); + string[] LeadNameArray = new string[12] { "I", "II", "III", "aVR", "aVL", "aVF", "V1", "V2", "V3", "V4", "V5", "V6" }; + + //报告标题下画一条线 + Pen Ecg_Penx = new Pen(Color.Black, float.Parse("3")); + Ecg_Graphics.DrawLine(Ecg_Penx, 0, 100, 3319, 100); + for (int d = 0; d < LeadInfo.Count; d++) + { + if (d < 6) + { + Ecg_Graphics.DrawLine(Ecg_Pen, 0, FirstPointArray[LeadInfo[d].ToString()].Y, Int16.Parse(Math.Round(double.Parse(FreePixs.ToString()) / 3).ToString()), FirstPointArray[LeadInfo[d].ToString()].Y); + Ecg_Graphics.DrawLine(Ecg_Pen, Int16.Parse(Math.Round(double.Parse(FreePixs.ToString()) / 3).ToString()), FirstPointArray[LeadInfo[d].ToString()].Y, Int16.Parse(Math.Round(double.Parse(FreePixs.ToString()) / 3).ToString()), FirstPointArray[LeadInfo[d].ToString()].Y - Int16.Parse(Math.Round(double.Parse(FreePixs.ToString()) * 2).ToString())); + Ecg_Graphics.DrawLine(Ecg_Pen, Int16.Parse(Math.Round(double.Parse(FreePixs.ToString()) / 3).ToString()), FirstPointArray[LeadInfo[d].ToString()].Y - Int16.Parse(Math.Round(double.Parse(FreePixs.ToString()) * 2).ToString()), Int16.Parse(Math.Round(double.Parse(FreePixs.ToString()) / 3).ToString()) * 2, FirstPointArray[LeadInfo[d].ToString()].Y - Int16.Parse(Math.Round(double.Parse(FreePixs.ToString()) * 2).ToString())); + Ecg_Graphics.DrawLine(Ecg_Pen, Int16.Parse(Math.Round(double.Parse(FreePixs.ToString()) / 3).ToString()) * 2, FirstPointArray[LeadInfo[d].ToString()].Y - Int16.Parse(Math.Round(double.Parse(FreePixs.ToString()) * 2).ToString()), Int16.Parse(Math.Round(double.Parse(FreePixs.ToString()) / 3).ToString()) * 2, FirstPointArray[LeadInfo[d].ToString()].Y); + Ecg_Graphics.DrawLine(Ecg_Pen, Int16.Parse(Math.Round(double.Parse(FreePixs.ToString()) / 3).ToString()) * 2, FirstPointArray[LeadInfo[d].ToString()].Y, Int16.Parse(Math.Round(double.Parse(FreePixs.ToString()) / 3).ToString()) * 3, FirstPointArray[LeadInfo[d].ToString()].Y); + string str = LeadNameArray[LeadInfo[d]]; + Font font = new Font("宋体", 25); + Brush brush = Brushes.Black; + if (d < FirstPointArray.Count) + { + PointF point = new PointF(0, FirstPointArray[LeadInfo[d].ToString()].Y); + Ecg_Graphics.DrawString(str, font, brush, point); + } + } + else + { + Ecg_Graphics.DrawLine(Ecg_Pen, Ecg_Canvas.Width / 2, FirstPointArray[LeadInfo[d].ToString()].Y, Ecg_Canvas.Width / 2 + Int16.Parse(Math.Round(double.Parse(FreePixs.ToString()) / 3).ToString()), FirstPointArray[LeadInfo[d].ToString()].Y); + Ecg_Graphics.DrawLine(Ecg_Pen, Ecg_Canvas.Width / 2 + Int16.Parse(Math.Round(double.Parse(FreePixs.ToString()) / 3).ToString()), FirstPointArray[LeadInfo[d].ToString()].Y, Ecg_Canvas.Width / 2 + Int16.Parse(Math.Round(double.Parse(FreePixs.ToString()) / 3).ToString()), FirstPointArray[LeadInfo[d].ToString()].Y - 2 * FreePixs); + Ecg_Graphics.DrawLine(Ecg_Pen, Ecg_Canvas.Width / 2 + Int16.Parse(Math.Round(double.Parse(FreePixs.ToString()) / 3).ToString()), FirstPointArray[LeadInfo[d].ToString()].Y - 2 * FreePixs, Ecg_Canvas.Width / 2 + Int16.Parse(Math.Round((double.Parse(FreePixs.ToString()) / 3) * 2).ToString()), FirstPointArray[LeadInfo[d].ToString()].Y - 2 * FreePixs); + Ecg_Graphics.DrawLine(Ecg_Pen, Ecg_Canvas.Width / 2 + Int16.Parse(Math.Round((double.Parse(FreePixs.ToString()) / 3) * 2).ToString()), FirstPointArray[LeadInfo[d].ToString()].Y - 2 * FreePixs, Ecg_Canvas.Width / 2 + Int16.Parse(Math.Round((double.Parse(FreePixs.ToString()) / 3) * 2).ToString()), FirstPointArray[LeadInfo[d].ToString()].Y); + Ecg_Graphics.DrawLine(Ecg_Pen, Ecg_Canvas.Width / 2 + (FreePixs / 3) * 2, FirstPointArray[LeadInfo[d].ToString()].Y, Ecg_Canvas.Width / 2 + FreePixs, FirstPointArray[LeadInfo[d].ToString()].Y); + string str = LeadNameArray[LeadInfo[d]]; + Font font = new Font("宋体", 25); + Brush brush = Brushes.Black; + if (d < FirstPointArray.Count) + { + PointF point = new PointF(Ecg_Canvas.Width / 2, FirstPointArray[LeadInfo[d].ToString()].Y); + Ecg_Graphics.DrawString(str, font, brush, point); + } + } + } + } + + + /// + /// 获得心电数据 + /// + /// + public Dictionary> GetEcgData(DataTable EcgDataTable) + { + string[] WavePara = File.ReadAllText(Application.StartupPath + @"\WavePara.txt").Trim().Split(','); + SamplingRate = int.Parse(WavePara[0].Trim()); + AmplificationFactor = double.Parse(WavePara[1].Trim()); + + Dictionary> get_EcgDataList = new Dictionary>(); + for (int y = 0; y < EcgDataTable.Rows.Count; y++) + { + byte[] ecgdata = (byte[])EcgDataTable.Rows[y]["pureData"]; + Int16[,] ecg = new Int16[LeadCount, ecgdata.Length / (LeadCount * byteLength)]; + Int16[,] EcgPixData = new Int16[LeadCount, ecgdata.Length / (LeadCount * byteLength)]; + int index = 0; + for (int q = 0; q < LeadCount; q++) + { + for (int i = 0; i < SamplingRate*5; i++) + { + byte a = ecgdata[index]; + index++; + byte b = ecgdata[index]; + index++; + ecg[q, i] = (Int16)(a + (b << 8)); + string sss = ((double.Parse(ecg[q, i].ToString()) / AmplificationFactor) * 10.0).ToString(); + double cc = double.Parse(sss) * double.Parse(Dpi.ToString()) / double.Parse(LenthPerInch.ToString()); + if (get_EcgDataList.ContainsKey(q)) + get_EcgDataList[q].Add(cc); + //get_EcgDataList[q].Add(short.Parse(cc.ToString())); + else + { + + short f = (short)cc; + List ecg_List = new List(); + ecg_List.Add((double)f); + //ecg_List.Add(short.Parse(cc.ToString())); + get_EcgDataList.Add(q, ecg_List); + } + } + } + } + return get_EcgDataList; + } + /// + /// 获得心电数据 + /// + /// + public Dictionary> GetEcgData(DataTable EcgDataTable,bool ReturnFloat) + { + string[] WavePara = File.ReadAllText(Application.StartupPath + @"\WavePara.txt").Trim().Split(','); + SamplingRate = int.Parse(WavePara[0].Trim()); + AmplificationFactor = double.Parse(WavePara[1].Trim()); + + Dictionary> get_EcgDataList = new Dictionary>(); + for (int y = 0; y < EcgDataTable.Rows.Count; y++) + { + byte[] ecgdata = (byte[])EcgDataTable.Rows[y]["pureData"]; + Int16[,] ecg = new Int16[LeadCount, ecgdata.Length / (LeadCount * byteLength)]; + Int16[,] EcgPixData = new Int16[LeadCount, ecgdata.Length / (LeadCount * byteLength)]; + int index = 0; + for (int q = 0; q < LeadCount; q++) + { + for (int i = 0; i < SamplingRate*5; i++) + { + byte a = ecgdata[index]; + index++; + byte b = ecgdata[index]; + index++; + ecg[q, i] = (Int16)(a + (b << 8)); + double sss = double.Parse(ecg[q, i].ToString()) / AmplificationFactor; + float resulte_cc = (float)sss; + //double cc = double.Parse(sss) * double.Parse(Dpi.ToString()) / double.Parse(LenthPerInch.ToString()); + if (get_EcgDataList.ContainsKey(q)) + get_EcgDataList[q].Add(resulte_cc); + //get_EcgDataList[q].Add(short.Parse(cc.ToString())); + else + { + List ecg_List = new List(); + ecg_List.Add(resulte_cc); + get_EcgDataList.Add(q, ecg_List); + } + } + } + } + return get_EcgDataList; + } + ///// + ///// 波形放大或缩小 + ///// + //public void AmplifyOrLessen(int OptionParameter) + //{ + + // // double a = Math.Abs(double.Parse(Dpi.ToString()) / LenthPerInch) * OptionParameter; + // // int WaveAmplify = (int)a; + // Ecg_Pen = new Pen(Color.Black, float.Parse("0.5")); + // for (int i = 0; i < LeadInfo.Count; i++) + // { + // int LeadIndex = LeadInfo[i];//取导联下标 0 1 2 3 ...11 + // BaseLine = (Ecg_Canvas.Height / LeadInfo.Count) / 2 + (i * LeadHeight); + // FirstPosition.Y = BaseLine; + // FirstPosition.X = FreePixs; + // SecondPosition.Y = BaseLine; + // SecondPosition.X = FreePixs; + + // Point FP = new Point(FirstPosition.X + FreePixs, FirstPosition.Y); + // FirstPointArray.Add(LeadIndex.ToString(), FP); + // for (int b = 0; b < EcgDataList[LeadIndex].Count; b++) + // { + // if (FirstPosition.X > Ecg_Canvas.Width) + // break; + // if (EcgDataList[LeadIndex][b] > 0) + // SecondPosition.Y = Math.Abs(BaseLine - EcgDataList[LeadIndex][b]) + OptionParameter; + // if (EcgDataList[LeadIndex][b] < 0) + // SecondPosition.Y = BaseLine + Math.Abs(EcgDataList[LeadIndex][b]) + OptionParameter; + // double x = double.Parse(b.ToString()) * (double.Parse(Dpi.ToString()) / double.Parse(SamplingRate.ToString())) * (PaperSpeed * OptionParameter)/Amplitude;//获得点的X轴位置 + // int nextX = (int.Parse(Math.Round(x).ToString())); + // if (Math.Abs(FirstPosition.X - SecondPosition.X) < 5) + // { + // SecondPosition.X = nextX + FreePixs; + // Ecg_Graphics.DrawLine(Ecg_Pen, FirstPosition, SecondPosition); + // FirstPosition = SecondPosition; + // } + // else + // FirstPosition = SecondPosition; + // } + // } + //} + +//**************************动态播放十二导联波形************************************************************************************ + /// + /// 绘制屏幕墙窗体背景 + /// + /// + public void DrawBackGround(Graphics Graphics) + { + Graphics.FillRectangle(Brushes.White, Graphics.ClipBounds); + } + public void DrawStandardGrid(PictureBox EV, Graphics Graphics) + { + int GridSize = int.Parse((Math.Round(double.Parse("96") * double.Parse("5") / double.Parse("25.4"))).ToString()); + Pen GridColor = new Pen(Color.LightCoral, float.Parse("0.1")); + //绘制网格大格竖线 + for (int i = 0; i < EV.Width; i += GridSize) + { + Graphics.DrawLine(GridColor, i, 0, i, EV.Height); + } + //绘制网格大格横线 + for (int i = 0; i < EV.Height; i += GridSize) + { + Graphics.DrawLine(GridColor, 0, i, EV.Width, i); + } + } + + + DateTime CurrentDateTime; + string V_WardshipId = string.Empty; + int Ecg_Index = 0;//数据队列中的游标 + double PixCountPerPoint;//求出 心电 相邻两点之间的 像素点个数 + /// + /// 绘制心电波形 + /// + //public void Play_EcgWave(PictureEdit pictureEdit3, Graphics Graphics_1, string WardshipId, DateTime CurrDatetime) + //{ + // PixCountPerPoint = double.Parse("0.3"); + // V_WardshipId = WardshipId; + // if (CurrDatetime != null) + // CurrentDateTime = CurrDatetime; + // Ecg_Pen = new Pen(Color.Black, float.Parse("0.5"));//心电波形颜色 + // FirstPointArray.Clear(); + // LeadHeight = pictureEdit3.Height / LeadInfo.Count; + // FreePixs = int.Parse(Math.Round((double.Parse(Dpi.ToString()) / LenthPerInch) * 5).ToString()); + // for (int i = 0; i < LeadInfo.Count; i++) + // { + // int LeadIndex = LeadInfo[i];//取导联下标 0 1 2 3 ...11 + // BaseLine = (pictureEdit3.Height / LeadInfo.Count) / 2 + (i * LeadHeight); + // FirstPosition.Y = BaseLine; + // FirstPosition.X = FreePixs; + // SecondPosition.Y = BaseLine; + // SecondPosition.X = FreePixs; + + // Point FP = new Point(FirstPosition.X + FreePixs, FirstPosition.Y); + // FirstPointArray.Add(LeadIndex.ToString(), FP); + // int ScreenPointCount = (int)(double.Parse(pictureEdit3.Width.ToString()) / PixCountPerPoint); + // for (int b = Ecg_Index; b < Ecg_Index + ScreenPointCount; b++) + // { + // if (EcgDataList == null) + // LoadEcgData_BaseDatabase(WardshipId);//加载心电数据队列 + // else + // if (EcgDataList[LeadIndex].Count <= 0 || b + 500 >= EcgDataList[LeadIndex].Count) + // LoadEcgData_BaseDatabase(WardshipId);//加载心电数据队列 + + + // if (b + 1 >= EcgDataList[LeadIndex].Count) + // { + // Graphics_1.DrawLine(new Pen(Brushes.Black), 0, pictureEdit3.Height / 2, pictureEdit3.Width, pictureEdit3.Height / 2); + // } + // else + // { + // if (FirstPosition.X > pictureEdit3.Width) + // break; + // if (EcgDataList[LeadIndex][b] > 0) + // SecondPosition.Y = Math.Abs(BaseLine - EcgDataList[LeadIndex][b]); + // if (EcgDataList[LeadIndex][b] < 0) + // SecondPosition.Y = BaseLine + Math.Abs(EcgDataList[LeadIndex][b]); + // double x = double.Parse(b.ToString()) * (double.Parse(Dpi.ToString()) / double.Parse(SamplingRate.ToString()));//获得点的X轴位置 + // int nextX = (int.Parse(Math.Round(x).ToString())); + // if (Math.Abs(FirstPosition.X - SecondPosition.X) < 5) + // { + // SecondPosition.X = nextX + FreePixs; + // //Ecg_Graphics.DrawLine(Ecg_Pen, FirstPosition, SecondPosition); + // Graphics_1.DrawLine(Ecg_Pen, FirstPosition, SecondPosition); + // FirstPosition = SecondPosition; + // } + // else + // FirstPosition = SecondPosition; + // } + // } + // } + // Ecg_Index += 14; + //} + + + + + + + } +} diff --git a/1200gFtp/EcgViewModel.cs b/1200gFtp/EcgViewModel.cs new file mode 100644 index 0000000..58e624e --- /dev/null +++ b/1200gFtp/EcgViewModel.cs @@ -0,0 +1,131 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace _1200gFtp +{ + public class EcgViewModel + { + ///// + ///// 机构 + ///// + //public OrgModel Org { get; set; } + /// + /// 病例ID + /// + public Guid? CaseId { get; set; } + /// + /// 患者ID + /// + + public Guid? PatientId { get; set; } + /// + /// 是否可以编辑界面 + /// + + public bool IsEdit { get; set; } + /// + /// 患者姓名 + /// + public string PatientName { get; set; } + /// + /// 性别 + /// + public string Gender { get; set; } + /// + /// 年龄 + /// + public int? Age { get; set; } + + /// + /// 部门 + /// + public string Department { get; set; } + + /// + /// 病房号 + /// + public string RoomNum { get; set; } + /// + /// 病床号 + /// + + public string BedNum { get; set; } + /// + /// 住院号 + /// + + public string HospNum { get; set; } + /// + /// 心率 + /// + public int? Heart { get; set; } + /// + /// PR间期 + /// + + public int? PR { get; set; } + /// + /// QRS时限 + /// + + public int? QRS { get; set; } + + public int? QT { get; set; } + + public int? QTc { get; set; } + /// + /// P电轴 + /// + public double? PAxis { get; set; } + /// + /// QRS电轴 + /// + public double? QRSAxis { get; set; } + /// + /// T电轴 + /// + public double? TAxis { get; set; } + /// + /// P时限 + /// + + public int? PDuration { get; set; } + /// + /// T时限 + /// + public int? TDuration { get; set; } + + public double? RV5 { get; set; } + + public double? SV1 { get; set; } + /// + /// 自动诊断 + /// + public string AutoResult { get; set; } + /// + /// 检查开始日期 + /// + + public DateTime? StartTime { get; set; } + /// + /// 检查结束日期 + /// + public DateTime? EndTime { get; set; } + /// + /// 心电数据 + /// + public Dictionary DicData { get; set; } + + /// + /// 文件路径 + /// + public string FilePath { get; set; } + /// + /// 医生ID + /// + public Guid? DocId { get; set; } + } +} diff --git a/1200gFtp/FLYecgReport.cs b/1200gFtp/FLYecgReport.cs new file mode 100644 index 0000000..d983854 --- /dev/null +++ b/1200gFtp/FLYecgReport.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace _1200gFtp +{ + public class FLYecgReport + { + public string appointmentId { get; set; } + public string reportTime { get; set;} + public string reportDoctor { get; set; } + public string reportDoctorCode { get; set; } + public string reportDepartmentCode { get; set; } + public string reportDepartmentName { get; set; } + public string reportHospitalCode { get; set; } + public string reportHospitalName { get; set; } + public string dcmFileUrl { get; set; } + public string isAbnormal { get; set; }//是否正常 是否异常0阳性1阴性 + public string remark { get; set; }//结论 + public int status { get; set; } + } +} diff --git a/1200gFtp/FlyHisEcgdataModel.cs b/1200gFtp/FlyHisEcgdataModel.cs new file mode 100644 index 0000000..b11cc5e --- /dev/null +++ b/1200gFtp/FlyHisEcgdataModel.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace _1200gFtp +{ + public class FlyHisEcgDataModel + { + public int total { get; set; } + public List rows { get; set; } + } + + public class patientInfo + { + public string jianchaid { get; set; } + public string jianchabh { get; set; } + public string name { get; set; } + public string sfz { get; set; } + public string birthdate { get; set; } + public int age { get; set; } + public string sex { get; set; } + public string yiyuanname { get; set; } + public string yiyuanid { get; set; } + public string kaifangsj { get; set; } + public string departmentCode { get; set; } + public string departmentName { get; set; } + public string resDoctorName { get; set; } + public string resDoctorCode { get; set; } + public string nation { get; set; } + public string patientCode { get; set; } + public string visitType { get; set; } + public List projects { get; set; } + public int code { get; set; } + public string msg { get; set; } + } + + public class projectsInfo + { + public string jianchamingcheng { get; set; } + public string nhbm { get; set; } + public string category { get; set;} + } +} diff --git a/1200gFtp/FlyHisTokenMsg.cs b/1200gFtp/FlyHisTokenMsg.cs new file mode 100644 index 0000000..63b34aa --- /dev/null +++ b/1200gFtp/FlyHisTokenMsg.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace _1200gFtp +{ + + //福乐云HIS的token信息结构 + public class FlyHisTokenMsgModel + { + public int code { get; set; } + public dataInfo data { get; set; } + } + + public class dataInfo + { + public string access_token { get; set; } + public string expires_in { get; set; } + } + +} diff --git a/1200gFtp/Form1.Designer.cs b/1200gFtp/Form1.Designer.cs new file mode 100644 index 0000000..6ec2c6b --- /dev/null +++ b/1200gFtp/Form1.Designer.cs @@ -0,0 +1,239 @@ +namespace _1200gFtp +{ + partial class Form1 + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows 窗体设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); + this.button1 = new System.Windows.Forms.Button(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.button2 = new System.Windows.Forms.Button(); + this.button3 = new System.Windows.Forms.Button(); + this.timer1 = new System.Windows.Forms.Timer(this.components); + this.button4 = new System.Windows.Forms.Button(); + this.textBox2 = new System.Windows.Forms.TextBox(); + this.checkBox1 = new System.Windows.Forms.CheckBox(); + this.button5 = new System.Windows.Forms.Button(); + this.button6 = new System.Windows.Forms.Button(); + this.button7 = new System.Windows.Forms.Button(); + this.button8 = new System.Windows.Forms.Button(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.groupBox1.SuspendLayout(); + this.groupBox2.SuspendLayout(); + this.SuspendLayout(); + // + // button1 + // + this.button1.Location = new System.Drawing.Point(51, 32); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(102, 39); + this.button1.TabIndex = 0; + this.button1.Text = "开始监听"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // textBox1 + // + this.textBox1.Location = new System.Drawing.Point(51, 96); + this.textBox1.Name = "textBox1"; + this.textBox1.ReadOnly = true; + this.textBox1.Size = new System.Drawing.Size(283, 28); + this.textBox1.TabIndex = 1; + // + // button2 + // + this.button2.Location = new System.Drawing.Point(196, 32); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(138, 39); + this.button2.TabIndex = 2; + this.button2.Text = "FTP接口调用"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // button3 + // + this.button3.Location = new System.Drawing.Point(417, 88); + this.button3.Name = "button3"; + this.button3.Size = new System.Drawing.Size(102, 39); + this.button3.TabIndex = 3; + this.button3.Text = "xml解析"; + this.button3.UseVisualStyleBackColor = true; + this.button3.Click += new System.EventHandler(this.button3_Click); + // + // timer1 + // + this.timer1.Enabled = true; + this.timer1.Interval = 60000; + this.timer1.Tick += new System.EventHandler(this.timer1_Tick); + // + // button4 + // + this.button4.Location = new System.Drawing.Point(816, 28); + this.button4.Name = "button4"; + this.button4.Size = new System.Drawing.Size(138, 39); + this.button4.TabIndex = 4; + this.button4.Text = "短信群发"; + this.button4.UseVisualStyleBackColor = true; + this.button4.Click += new System.EventHandler(this.button4_Click); + // + // textBox2 + // + this.textBox2.Dock = System.Windows.Forms.DockStyle.Fill; + this.textBox2.Location = new System.Drawing.Point(3, 24); + this.textBox2.Multiline = true; + this.textBox2.Name = "textBox2"; + this.textBox2.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.textBox2.Size = new System.Drawing.Size(1056, 444); + this.textBox2.TabIndex = 5; + // + // checkBox1 + // + this.checkBox1.AutoSize = true; + this.checkBox1.Checked = true; + this.checkBox1.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBox1.Location = new System.Drawing.Point(110, 189); + this.checkBox1.Name = "checkBox1"; + this.checkBox1.Size = new System.Drawing.Size(106, 22); + this.checkBox1.TabIndex = 6; + this.checkBox1.Text = "显示信息"; + this.checkBox1.UseVisualStyleBackColor = true; + // + // button5 + // + this.button5.Location = new System.Drawing.Point(290, 182); + this.button5.Name = "button5"; + this.button5.Size = new System.Drawing.Size(132, 45); + this.button5.TabIndex = 7; + this.button5.Text = "清空文本框"; + this.button5.UseVisualStyleBackColor = true; + this.button5.Click += new System.EventHandler(this.button5_Click); + // + // button6 + // + this.button6.Location = new System.Drawing.Point(426, 32); + this.button6.Name = "button6"; + this.button6.Size = new System.Drawing.Size(144, 39); + this.button6.TabIndex = 8; + this.button6.Text = "rabbitMQ调用"; + this.button6.UseVisualStyleBackColor = true; + this.button6.Click += new System.EventHandler(this.button6_Click); + // + // button7 + // + this.button7.Location = new System.Drawing.Point(609, 33); + this.button7.Name = "button7"; + this.button7.Size = new System.Drawing.Size(176, 39); + this.button7.TabIndex = 9; + this.button7.Text = "his03调用"; + this.button7.UseVisualStyleBackColor = true; + this.button7.Click += new System.EventHandler(this.button7_Click); + // + // button8 + // + this.button8.Location = new System.Drawing.Point(639, 76); + this.button8.Name = "button8"; + this.button8.Size = new System.Drawing.Size(176, 50); + this.button8.TabIndex = 10; + this.button8.Text = "FTP"; + this.button8.UseVisualStyleBackColor = true; + this.button8.Click += new System.EventHandler(this.button8_Click); + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.button8); + this.groupBox1.Controls.Add(this.checkBox1); + this.groupBox1.Controls.Add(this.button5); + this.groupBox1.Controls.Add(this.button1); + this.groupBox1.Controls.Add(this.button7); + this.groupBox1.Controls.Add(this.textBox1); + this.groupBox1.Controls.Add(this.button4); + this.groupBox1.Controls.Add(this.button6); + this.groupBox1.Controls.Add(this.button3); + this.groupBox1.Controls.Add(this.button2); + this.groupBox1.Dock = System.Windows.Forms.DockStyle.Top; + this.groupBox1.Location = new System.Drawing.Point(0, 0); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(1062, 237); + this.groupBox1.TabIndex = 11; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "操作"; + // + // groupBox2 + // + this.groupBox2.Controls.Add(this.textBox2); + this.groupBox2.Dock = System.Windows.Forms.DockStyle.Fill; + this.groupBox2.Location = new System.Drawing.Point(0, 237); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(1062, 471); + this.groupBox2.TabIndex = 12; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "信息"; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1062, 708); + this.Controls.Add(this.groupBox2); + this.Controls.Add(this.groupBox1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MaximizeBox = false; + this.Name = "Form1"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "云心电ECG数据解析服务端2024122501"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing); + this.Load += new System.EventHandler(this.Form1_Load); + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.groupBox2.ResumeLayout(false); + this.groupBox2.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Button button1; + private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.Button button3; + private System.Windows.Forms.Timer timer1; + private System.Windows.Forms.Button button4; + private System.Windows.Forms.TextBox textBox2; + private System.Windows.Forms.CheckBox checkBox1; + private System.Windows.Forms.Button button5; + private System.Windows.Forms.Button button6; + private System.Windows.Forms.Button button7; + private System.Windows.Forms.Button button8; + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.GroupBox groupBox2; + } +} + diff --git a/1200gFtp/Form1.cs b/1200gFtp/Form1.cs new file mode 100644 index 0000000..8efa1a8 --- /dev/null +++ b/1200gFtp/Form1.cs @@ -0,0 +1,1502 @@ +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"); + } + + /// + /// 初始化监听 + /// + /// 需要监听的目录 + /// 需要监听的文件类型(筛选器字符串) + /// 是否启用监听 + /// 是否监听子目录 + 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); + } + + + /// + /// 获取文件MD5值 + /// + /// 文件绝对路径 + /// MD5值 + 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; + } + + /// + /// 将患者姓名 和 his结果里的患者姓名进行对比 如果姓名匹配 那么就将这个人的 patientid 修改为 his结果里的 jianchaid + /// + /// + 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; + } + + + /// + /// 提交诊断结论到福乐云 + /// + /// + 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; + } + + + /// + /// 上传诊断结论到福乐云平台 + /// + 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); + } + + + /// + /// 上传心电图图片文件到福乐云平台 + /// + void FlyEcgReportFileSubmit(string appointment_id, string imgPath) + { + byte[] fileData = File.ReadAllBytes(imgPath); + FileInfo fileInfo = new FileInfo(imgPath); + Dictionary dic = new Dictionary(); + 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); + + } + + + /// + /// 提交患者信息到福乐云 + /// + /// + string submitPatientInfoToFLY(string patientId1) + { + string sql = "select * from Tb_PatientInfo where PatientID='" + patientId1 + "'"; + DataTable dt_1 = SqliteOptions_sql.CreateInstance().ExcuteSqlite(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]["PatientID"].ToString(); + PMD.PatientName = dt_1.Rows[0]["PatientName"].ToString(); + PMD.P_Id = dt_1.Rows[0]["P_Id"].ToString(); + PMD.Gender = dt_1.Rows[0]["Gender"].ToString(); + PMD.Birthday = dt_1.Rows[0]["Birthday"].ToString(); + PMD.Folk = dt_1.Rows[0]["Folk"].ToString(); + DataTable dt_org = SqliteOptions_sql.CreateInstance().ExcuteSqlite("select * from tb_org where orgID='" + dt_1.Rows[0]["orgID"].ToString() + "'"); + orgSN = dt_org.Rows[0]["orgSN"].ToString(); + orgName = dt_org.Rows[0]["orgName"].ToString(); + } + 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; + } + + + /// + /// 将患者信息插入数据库中并自动申请判读 + /// + /// + 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(); + string ecgAnalysisJson = JsonConvert.SerializeObject(alp);//把心电数据保存成json文件 + string jsonFilePath = fi1.DirectoryName + @"\" + Guid.NewGuid().ToString() + ".txt"; + File.WriteAllText(jsonFilePath, ecgAnalysisJson, Encoding.UTF8);//保存json文件到指定的目标统一http访问目录下 + 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; + //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 = SqliteOptions_sql.CreateInstance().ExcuteSqlite("select * from tb_org where orgSN='" + orgSN + "'"); + string orgid = ""; + string highLevelOrgid = ""; + string inHisCode = ""; + 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中的机构代码 + } + 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 + + //string returnStrx = FlySubmit(patientId2,7);//收到心电数据后,将心电数据状态传到福乐云平台 + + + string newEcgFilePath1 = fi.DirectoryName + @"\" + patientId2 + fi.Extension; + fi.CopyTo(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);//把生成的心电图和心电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(); + } + } + + string returnStrxs= submitPatientInfoToFLY(patientId2);//先把患者信息提交到福乐云医共体平台 + 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); + } + /// + /// 创建文件或者目录时的监听事件 + /// + /// + /// + 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 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; + } + + + + /// + /// 遍历当前目录及子目录 + /// + /// 文件路径 + /// 所有文件 + private List GetFiles(string strPath) + { + List lstFiles = new List(); + List lstDirect = new List(); + 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 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); + } + + /// + /// 提交数据到 his03 + /// + /// + void submitHis03(string jsonStr) + { + panduReturnModel prm = JsonConvert.DeserializeObject(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(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(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"); + + + } + + + + + /// + /// 读取XML文件 + /// + /// + /// + private EcgViewModel ReadXMLByPath(string path) + { + var evm = new EcgViewModel + { + DicData = new Dictionary() + }; + 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数据接收线程 + } + } +} diff --git a/1200gFtp/Form1.resx b/1200gFtp/Form1.resx new file mode 100644 index 0000000..34254e3 --- /dev/null +++ b/1200gFtp/Form1.resx @@ -0,0 +1,200 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + + + AAABAAEAICAAAAEAIACoEAAAFgAAACgAAAAgAAAAQAAAAAEAIAAAAAAAABAAABMLAAATCwAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQUPYAUFD6AFBQ + 1QBRUfUGUVH6BlJS7gNPT/YAUFD6AE9O+gBQTfsAUFT/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFBQ + 7gFQUPkYUFD5SVBQ+WdPT/ppT0/4WU9P+0FQUPouT035F1FH/ANQT/oAUFD9AFBQ/wAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AABQUPYAUFD5K1BQ+p5QUPr0T0/6/09P+v9PT/r/T0/6/k9P+t9PTvqhUE/6aFBQ+zBRUf8EUFD4AFBQ + 9gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAFBQ9QlQUPqIUFD6+VBP+v9PT/r+UE/6/1BQ+v9PT/r/T0/6/09P+v9QUPr+UFD6x09P + /G9QUPgYTU38AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAUFD6K09P+sNPT/r/T0/6/1BQ+v9PT/r/T0/6/09P+v9PT/r/T0/6/lBQ + +v9QUPr/UFD79E9P+qROTvs2UFD5AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAFFR9QBQUPpMUFD74k9P+v9PT/v+UFD6/09P+v9QUPr/UFD6/09P + +v9QUPr/T0/6/09P+v9PT/r/UFD6/09P+r5QUPk4UFD5AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQUP4AUFD2DU9P+olPT/r6T0/7/k9P+v5QUPr/UFD6/09P + +v9QUPr/T0/6/1BP+v9QUPr/T0/6/09P+/5QUPr/UE/6/E9P+r5QUPk3UFD8AQAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUFD2AFFR/wFQUPs+UE/62VBP+v9PT/r/T0/6/1BQ + +/9PT/r/T0/6/1BQ+v9PT/r/T0/6/09P+v5QT/r/T0/6/09P+v5PT/r/T0/6/E9P+qRQUPsYTk75AAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFBQ+wBOT/8AUFD7Ik9P+6ZPT/r9UE/6/09P + +v9PT/v+UFD6/1BP+v9PT/r/T0/7/k9P+v9PT/r/UFD6/09P+/5PT/r+T0/6/1BQ+v9PT/r/T0/79FBQ + +mhNTfkFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFBQ/wBQUPoATk74AFBQ+iRQUPmbT0/6/FBQ + +v9OTvr/TU36/1BQ+v9MTPr/TEz6/05O+/5PT/v+UE/6/1BQ+v9QT/r/UFD7/1BQ+v9PT/r+UE/6/09P + +v9QUPr/UFD6xU5O+StQUPoAAAAAAAAAAAAAAAAAUFD/AFBQ+QBQUPoAT0/3AFBQ+hZPT/lJUFD6sFBP + +v1QT/r+Tk76/11d+v6Fhfz/l5f8/4eH+/9wcPv/V1f6/0xM+v9PT/r/UFD6/09P+v9QT/r/UE/6/09P + +v5QUPr/T0/6/lBQ+v9QUPr3UFD6YVBQ+gUAAAAAAAAAAAAAAABQUPYAUFD5E1BQ+kJPT/tuT0/6oE9P + +upPT/r/T0/7/k9P+v9UVPr/n5/8/vT0/////////Pz//9ra/v+urv3/e3v7/1VV+v9OTvr/UFD6/1BP + +v9QUPr/T0/6/1BQ+v9PT/r+T0/6/k9P+v9PT/qoUFD6GQAAAAAAAAAAUFD7AFBQ+i5QUPmhT0/62VBQ + +v5PT/v/T0/6/09P+/5QT/r+Tk76/2pq+/7U1P7////////////////////////////i4v7/qqr9/2Rj + +/9NTfr/UFD6/09P+v9PT/r/T0/7/k9P+v5QT/r/T0/6/1BQ+9hQUPsrAAAAAAAAAABQUPsRUFD6kFBQ + +v9QUPr/T0/6/09P+v9PT/r/UFD6/1BQ+v9MTPr/fn77/+bm/v////////////////////////////// + ///4+P//wcH9/2xs+/9PT/r+T0/6/09P+v9QUPr/UFD6/1BQ+v9QT/r/UFD7+VBQ/EBMTPsAAAAAAFBQ + +jFQUPrnUFD6/1BQ+v9PT/r+T0/6/1BQ+v9PT/v+T0/6/0tL+v+QkPz/9/f///////////////////// + ///////////////////7+///wsL9/2Ji+/9OTvr+UE/6/09P+v9QUPv/UFD6/09P+v9PT/v/Tk77YkxM + +wUAAAAAT0/6Ok9P+v9QUPr/T0/6/1BQ+v9PT/r+T0/6/lBP+v9QUPr/S0v6/5OT/P/6+v////////// + ///////////////////////////////////6+v//fX38/k5O+v9QUPr/UFD7/09P+v5QUPr/T0/6/1BQ + +v9QUPtrT0/8BwAAAABPT/s6T0/7/lBQ+v9QUPr/T0/7/k9P+/5PT/r/T0/6/09P+/5LS/r+kpL8//n5 + //////////////////////////////////////////////39//+EhPz/T0/6/lBQ+v9QUPv/T0/6/lBQ + +v5QUPr/UE/6/1BQ+2dQUfwGAAAAAFBQ+zRQUPrvUFD6/1BQ+v9QUPr/UFD6/1BQ+v9QT/v+UFD6/0tL + +v+Njfz/9PT////////////////////////////////////////+/v//z8/+/2Zm+/5OTvr+UFD7/09P + +v9QUPr/UFD6/1BQ+v9QUPr/UFD7UFBQ/gEAAAAAUE/6J1BP+sxPT/r/UFD6/1BQ+v9PT/v+UFD6/1BQ + +v9QUPr/TEz6/4SE/P/r6/7/////////////////////////////////+Pj//8rK/v9ycvz/T0/6/1BP + +v9QUPr/UFD6/1BQ+v9PT/r/T0/6/k9P+vpPT/tAUFD/AAAAAABQUPwXUFD7o1BQ+v9PT/r/UFD6/09P + +v9QUPr/UFD6/1BQ+v9OTvr/bm77/9bW/v///////////////////////////+np/v+qqv3/Y2P7/kxM + +v5PT/r+T0/6/k9P+v5QUPr/UFD6/1BQ+/5QT/v/T0/61E5P+ikAAAAAAAAAAFBQ/QZQUPtoUFD6/lBQ + +v9PT/r/T0/6/lBQ+v9PT/r/UFD6/09P+v9UVPr/np78//P0/////////////+Li/v+6uv3/goL7/1VV + +v9NTfr+UE/6/1BQ+v9QUPr/UFD6/1BQ+v9QUPr/UFD6/k9P+v9PT/uXT0/7EgAAAAAAAAAAUFD9AFBP + +jpQUPrdUFD6/1BQ+v9QUPv+UFD6/1BQ+v9QUPr/UFD6/05O+v9cXPr/ior8/6Sj/P+Skvz+dXX7/11d + +v9MTPr/T0/6/1BQ+/9QUPr/UFD6/1BQ+v9QUPr/UFD6/1BQ+v9PT/r/T0/661BQ+1JSUvwDAAAAAAAA + AAAAAAAAUE/4DVBQ+pFQUPr+UE/6/1BQ+v9PT/r/UE/7/lBQ+v9QUPn/UFD6/05O+v9QUPr/VVX6/k9P + +v9NTfr/T0/6/1BQ+v9QUPr/UFD6/1BQ+v9QUPr/UFD6/1BQ+/9QUPr/T0/7/lBQ+v9QUPqsUFD6HFFR + /AAAAAAAAAAAAAAAAABQS/8AUFD7Ok9P+sxQT/r/UFD7/k9P+v5QUPv/UFD6/1BQ+v9QUPr/UFD6/09P + +v5PT/r/T0/7/k9P+v5QUPr/UFD6/1BQ+v9QUPr/T0/6/lBQ+v9PT/v+T0/6/09P+v5QUPr/UFD651BQ + +ldQUPgCAAAAAAAAAAAAAAAAAAAAAFBQ8QBQUPwDUFD6cU9P+vBQUPr/UFD6/1BQ+v9PT/v+UFD6/1BQ + +v9QUPr/UFD6/1BQ+v9QUPr/UE/6/1BP+v9QUPr/UFD6/1BQ+v9PT/r/UFD6/09P+v5PT/r+UFD7/1BQ + +vhQUPqKUFD9C1BQ+QAAAAAAAAAAAAAAAAAAAAAAAAAAAFBQ+wBQUPcNT0/5g1BQ+vBQUPr/UFD6/09P + +v5QUPr/UFD6/1BQ+v9QUPr/UFD6/09P+v5QUPr/UFD6/1BQ+v9QUPr/UFD6/1BQ+v9QUPr/UFD6/1BQ + +v9PT/r8UFD6p01N+xpQUP8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFBQ9gBQUPcNUFD6g1BQ + +u1PT/v/UFD6/09P+v9QUPr/T0/6/lBQ+v9QUPr/UFD6/1BQ+v9QUPr/UFD6/1BQ+v9QUPr+UFD6/lBQ + +v9PT/r/UFD68lBQ+qJQUPwpTEz7AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFBQ + 9wBQUPcNUFD6alBQ+sxQUPr+T0/6/1BQ+v9QUPr+UFD6/1BQ+v9QUPr/UFD6/1BQ+v9QUPr/UFD6/1BQ + +v9PT/r/UFD6/1BQ+ttQUPqAUFD6E1BQ/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAFBQ+ABQUPcAUFD7OFBQ+oBQUPrQUFD6/1BQ+v9QUPr/UFD6/1BQ+v9QUPr/UFD6/1BQ + +v9QUPr/UFD6/1BQ+uBQUPuRUFD6R1BQ9wtQUPsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAFBQ+wBQUPsAT0//BlBQ+zZQUPpqT0/6nU9P+tNQUPnqT0/6/VBQ + +v9PT/rxUFD62lBQ+rNQUPp8T0/6Q09P/Q1QUPkAUFD4AFBQ9gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFBQ/wBQUPwAUFD5AFFR/wNOTvsVT0/6KVBQ + +TJPT/o5UFD6Ok9P+jVQUPosUFD6HVBQ+whOTv4AT0/8AFFR/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQUP8AUFD8AE9P + +wBPT/oAUFD5AE9P+gBQUPoAT0/6AFBQ+gBQUPoAUFD7AFBQ9QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAA//w////wA///8AD//+AAf//gAD//4AAf/8AAB/+AAAf/gAAD/wAAA/wA + AAHgAAABwAAAAYAAAAGAAAAAgAAAAIAAAACAAAAAgAAAAYAAAAGAAAABwAAAAcAAAAPgAAAD4AAAB/AA + AAf4AAAf/AAAP/8AAH//gAH//+AH//////8= + + + \ No newline at end of file diff --git a/1200gFtp/FtpHelper.cs b/1200gFtp/FtpHelper.cs new file mode 100644 index 0000000..bd783d6 --- /dev/null +++ b/1200gFtp/FtpHelper.cs @@ -0,0 +1,289 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.IO; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; + +namespace _1200gFtp +{ + public class FtpHelper + { + //基本设置 + //private static string ftppath = @"ftp://" + "10.1.99.5" + "/"; + //private static string username = ""; + //private static string password = ""; + + private static string ftppath = @"ftp://" + ConfigurationManager.AppSettings["ftpUrl"] + "/"; + private static string username = ConfigurationManager.AppSettings["ftpName"]; + private static string password = ConfigurationManager.AppSettings["ftpPwd"]; + + //获取FTP上面的文件夹和文件 + public static string[] GetFolderAndFileList(string s) + { + string[] getfolderandfilelist; + FtpWebRequest request; + StringBuilder sb = new StringBuilder(); + try + { + request = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftppath)); + request.UseBinary = true; + request.Credentials = new NetworkCredential(username, password); + request.Method = WebRequestMethods.Ftp.ListDirectory; + request.UseBinary = true; + WebResponse response = request.GetResponse(); + StreamReader reader = new StreamReader(response.GetResponseStream()); + string line = reader.ReadLine(); + while (line != null) + { + sb.Append(line); + sb.Append("\n"); + Console.WriteLine(line); + line = reader.ReadLine(); + } + sb.Remove(sb.ToString().LastIndexOf('\n'), 1); + reader.Close(); + response.Close(); + return sb.ToString().Split('\n'); + } + catch (Exception ex) + { + Console.WriteLine("获取FTP上面的文件夹和文件:" + ex.Message); + getfolderandfilelist = null; + return getfolderandfilelist; + } + } + + //获取FTP上面的文件大小 + public static int GetFileSize(string fileName) + { + FtpWebRequest request; + try + { + request = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftppath + fileName)); + request.UseBinary = true; + request.Credentials = new NetworkCredential(username, password); + request.Method = WebRequestMethods.Ftp.GetFileSize; + int n = (int)request.GetResponse().ContentLength; + return n; + } + catch (Exception ex) + { + Console.WriteLine("获取FTP上面的文件大小:" + ex.Message); + return -1; + } + } + + //FTP上传文件 + public static string FileUpLoad(string filePath, string objPath = "") + { + try + { + string url = ftppath; + if (objPath != "") + url += objPath + "/"; + try + { + FtpWebRequest request = null; + try + { + FileInfo fi = new FileInfo(filePath); + using (FileStream fs = fi.OpenRead()) + { + request = (FtpWebRequest)FtpWebRequest.Create(new Uri(url + fi.Name)); + request.Credentials = new NetworkCredential(username, password); + request.KeepAlive = false; + request.Method = WebRequestMethods.Ftp.UploadFile; + request.UseBinary = true; + using (Stream stream = request.GetRequestStream()) + { + int bufferLength = 5120; + byte[] buffer = new byte[bufferLength]; + int i; + while ((i = fs.Read(buffer, 0, bufferLength)) > 0) + { + stream.Write(buffer, 0, i); + } + return "上传成功"; + } + } + } + catch (Exception ex) + { + return ex.ToString(); + } + finally + { + + } + } + catch (Exception ex) + { + return ex.ToString(); + } + finally + { + + } + } + catch (Exception ex) + { + return ex.ToString(); + } + } + + + //FTP上传文件 + public static string FileUpLoad(string filePath, string objPath ,string ftpFileName) + { + try + { + string url = ftppath; + if (objPath != "") + url += objPath + "/"; + try + { + FtpWebRequest request = null; + try + { + FileInfo fi = new FileInfo(filePath); + using (FileStream fs = fi.OpenRead()) + { + request = (FtpWebRequest)FtpWebRequest.Create(new Uri(url + ftpFileName)); + request.Credentials = new NetworkCredential(username, password); + request.KeepAlive = false; + request.Method = WebRequestMethods.Ftp.UploadFile; + request.UseBinary = true; + request.UsePassive = true; + using (Stream stream = request.GetRequestStream()) + { + int bufferLength = 5120; + byte[] buffer = new byte[bufferLength]; + int i; + while ((i = fs.Read(buffer, 0, bufferLength)) > 0) + { + stream.Write(buffer, 0, i); + } + return "上传成功"; + } + } + } + catch (Exception ex) + { + return ex.ToString(); + } + finally + { + + } + } + catch (Exception ex) + { + return ex.ToString(); + } + finally + { + + } + } + catch (Exception ex) + { + return ex.ToString(); + } + } + + + //FTP下载文件 + public static void FileDownLoad(string fileName) + { + FtpWebRequest request; + try + { + string downloadPath = @"D:"; + FileStream fs = new FileStream(downloadPath + "\\" + fileName, FileMode.Create); + request = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftppath + fileName)); + request.Method = WebRequestMethods.Ftp.DownloadFile; + request.UseBinary = true; + request.Credentials = new NetworkCredential(username, password); + request.UsePassive = false; + FtpWebResponse response = (FtpWebResponse)request.GetResponse(); + Stream stream = response.GetResponseStream(); + int bufferLength = 5120; + int i; + byte[] buffer = new byte[bufferLength]; + i = stream.Read(buffer, 0, bufferLength); + while (i > 0) + { + fs.Write(buffer, 0, i); + i = stream.Read(buffer, 0, bufferLength); + } + stream.Close(); + fs.Close(); + response.Close(); + } + catch (Exception ex) + { + Console.WriteLine("FTP下载文件:" + ex.Message); + } + } + + //FTP删除文件 + public static void FileDelete(string fileName) + { + try + { + string uri = ftppath + fileName; + FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create(new Uri(uri)); + request.UseBinary = true; + request.Credentials = new NetworkCredential(username, password); + request.KeepAlive = false; + request.Method = WebRequestMethods.Ftp.DeleteFile; + FtpWebResponse response = (FtpWebResponse)request.GetResponse(); + response.Close(); + } + catch (Exception ex) + { + Console.WriteLine("FTP删除文件:" + ex.Message); + } + } + + //FTP新建目录,上一级须先存在 + public static void MakeDir(string dirName) + { + try + { + string uri = ftppath + dirName; + FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create(new Uri(uri)); + request.UseBinary = true; + request.Credentials = new NetworkCredential(username, password); + request.Method = WebRequestMethods.Ftp.MakeDirectory; + FtpWebResponse response = (FtpWebResponse)request.GetResponse(); + response.Close(); + } + catch (Exception ex) + { + Console.WriteLine("FTP新建目录:" + ex.Message); + } + } + + //FTP删除目录,上一级须先存在 + public static void DelDir(string dirName) + { + try + { + string uri = ftppath + dirName; + FtpWebRequest reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(uri)); + reqFTP.Credentials = new NetworkCredential(username, password); + reqFTP.Method = WebRequestMethods.Ftp.RemoveDirectory; + FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse(); + response.Close(); + } + catch (Exception ex) + { + Console.WriteLine("FTP删除目录:" + ex.Message); + } + } + } +} diff --git a/1200gFtp/Hl7EcgOptions.cs b/1200gFtp/Hl7EcgOptions.cs new file mode 100644 index 0000000..16d5deb --- /dev/null +++ b/1200gFtp/Hl7EcgOptions.cs @@ -0,0 +1,278 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Drawing.Imaging; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml; + +namespace 云心电ECG数据解析服务端 +{ + public class Hl7EcgOptions + { + + + + float[] valueConvert(float[] valueArray) + { + float[] quotients = valueArray.Select(n => n / 9).ToArray();//把数值缩小9倍 这是用标准数据进行标定得到的 缩小倍数系数 + return quotients; + } + + + /// + /// 读取HL7文件中的患者信息和心电分析参数 + /// + /// + public analysisParas getAnalysisParas(string xmlFilePath) + { + try + { + FileInfo fi = new FileInfo(xmlFilePath); + XmlDocument xmlDoc = new XmlDocument(); + XmlReaderSettings settings = new XmlReaderSettings(); + settings.IgnoreComments = true;//忽略文档里面的注释 + XmlReader reader = XmlReader.Create(xmlFilePath, settings); + xmlDoc.Load(reader); + XmlNodeList xnList = xmlDoc.DocumentElement.GetElementsByTagName("annotation"); + analysisParas ap = new analysisParas(); + + //先从hl7 ecg xml文件中读取心电数据 + XmlNodeList xnListx1 = xmlDoc.DocumentElement.GetElementsByTagName("digits"); + // Dictionary> EcgTable = new Dictionary>(); + int leadDataIndex = 0; + for (int i = 0; i < 12; i++) + { + string[] ecgDataArray = new string[xnListx1.Item(leadDataIndex + i).InnerText.Split(' ').Length]; + ecgDataArray = xnListx1.Item(leadDataIndex + i).InnerText.Split(' '); + //List ecg_List = valueConvert(Array.ConvertAll(ecgDataArray, float.Parse)).ToList(); + List ecg_List = new List(); + for (int b = 0; b < ecgDataArray.Length; b++) + if (!string.IsNullOrEmpty(ecgDataArray[b])) + ecg_List.Add(float.Parse(ecgDataArray[b]) / 9); + if (i == 0) ap.LEAD_I = ecg_List; + if (i == 1) ap.LEAD_II = ecg_List; + if (i == 2) ap.LEAD_III = ecg_List; + if (i == 3) ap.LEAD_AVR = ecg_List; + if (i == 4) ap.LEAD_AVL = ecg_List; + if (i == 5) ap.LEAD_AVF = ecg_List; + if (i == 6) ap.LEAD_V1 = ecg_List; + if (i == 7) ap.LEAD_V2 = ecg_List; + if (i == 8) ap.LEAD_V3 = ecg_List; + if (i == 9) ap.LEAD_V4 = ecg_List; + if (i == 10) ap.LEAD_V5 = ecg_List; + if (i == 11) ap.LEAD_V6 = ecg_List; + // EcgTable.Add(i, ecg_List); + } + + + XmlNodeList xnList1 = xmlDoc.DocumentElement.GetElementsByTagName("family"); + ap.patientName = xnList1[0].InnerText;//姓名 + XmlNodeList xnList2 = xmlDoc.DocumentElement.GetElementsByTagName("administrativeGenderCode"); + string valStr = xnList2[0].OuterXml; + string sexStr = valStr.Substring(valStr.IndexOf("code="), valStr.IndexOf("codeSystem=") - valStr.IndexOf("code=")).Replace("code=", "").Replace("\"", "").Trim();//性别 + if (sexStr.Trim() == "M") + ap.gender = "男"; + if (sexStr.Trim() == "F") + ap.gender = "女"; + + XmlNodeList xnList4 = xmlDoc.DocumentElement.GetElementsByTagName("birthTime"); + string birthday = xnList4[0].OuterXml;//出生日期 + birthday = birthday.Substring(birthday.IndexOf("value="), birthday.IndexOf("xmlns=") - birthday.IndexOf("value=")).Replace("value=", "").Replace("\"", "").Trim(); + if (birthday.Length > 0) + { + ap.birthDay = birthday; + int year = int.Parse(ap.birthDay.Substring(0, 4)); + ap.age = (DateTime.Now.Year - year).ToString(); + } + + XmlNodeList xnList5 = xmlDoc.DocumentElement.GetElementsByTagName("patientid"); + string patientId = xnList5[0].OuterXml;//患者id + patientId = patientId.Substring(patientId.IndexOf("extension="), patientId.IndexOf("xmlns=") - patientId.IndexOf("extension=")).Replace("extension=", "").Replace("\"", "").Trim(); + ap.patientid = patientId; + + //获取日期和时间 + XmlNodeList xnList3 = xmlDoc.DocumentElement.GetElementsByTagName("effectiveTime"); + string collStr = xnList3[0].FirstChild.OuterXml; + string collectTime = collStr.Substring(collStr.IndexOf("value="), collStr.IndexOf("xmlns=") - collStr.IndexOf("value=")).Replace("value=", "").Replace("\"", "").Trim();//采集时间 + if (collectTime.Length > 0) + { + ap.collectTime = collectTime.Insert(4, "-").Insert(7, "-").Insert(10, " ").Insert(13, ":").Insert(16, ":");//转换成日期时间格式 + } + foreach (XmlNode xnx in xnList) + { + // string sss = xnx.FirstChild.Name; + string OuterXml1 = xnx.FirstChild.OuterXml; + // string xxx = xnx.LastChild.Name; + string OuterXml2 = xnx.LastChild.OuterXml; + if (OuterXml1.Contains("MDC_ECG_HEART_RATE")) + { + string valueStr = OuterXml2.Substring(OuterXml2.IndexOf("value="), OuterXml2.IndexOf("unit=") - OuterXml2.IndexOf("value=")).Replace("value=", "").Replace("\"", "").Trim(); + ap.heartRate = valueStr; + } + + if (OuterXml1.Contains("MDC_ECG_TIME_PD_P") && !OuterXml1.Contains("MDC_ECG_TIME_PD_PR") && !OuterXml1.Contains("MDC_ECG_TIME_PD_PQ")) + { + string valueStr = OuterXml2.Substring(OuterXml2.IndexOf("value="), OuterXml2.IndexOf("unit=") - OuterXml2.IndexOf("value=")).Replace("value=", "").Replace("\"", "").Trim(); + ap.P = valueStr; + } + + if (OuterXml1.Contains("MDC_ECG_TIME_PD_QRS")) + { + string valueStr = OuterXml2.Substring(OuterXml2.IndexOf("value="), OuterXml2.IndexOf("unit=") - OuterXml2.IndexOf("value=")).Replace("value=", "").Replace("\"", "").Trim(); + ap.QRS = valueStr; + } + + if (OuterXml1.Contains("MDC_ECG_TIME_PD_RR")) + { + string valueStr = OuterXml2.Substring(OuterXml2.IndexOf("value="), OuterXml2.IndexOf("unit=") - OuterXml2.IndexOf("value=")).Replace("value=", "").Replace("\"", "").Trim(); + ap.RR = valueStr; + } + + if (OuterXml1.Contains("MDC_ECG_TIME_PD_PR")) + { + string valueStr = OuterXml2.Substring(OuterXml2.IndexOf("value="), OuterXml2.IndexOf("unit=") - OuterXml2.IndexOf("value=")).Replace("value=", "").Replace("\"", "").Trim(); + ap.PR = valueStr; + } + + if (OuterXml1.Contains("MDC_ECG_TIME_PD_PQ")) + { + string valueStr = OuterXml2.Substring(OuterXml2.IndexOf("value="), OuterXml2.IndexOf("unit=") - OuterXml2.IndexOf("value=")).Replace("value=", "").Replace("\"", "").Trim(); + ap.PQ = valueStr; + } + + if (OuterXml1.Contains("MDC_ECG_TIME_PD_QT") && !OuterXml1.Contains("MDC_ECG_TIME_PD_QTc")) + { + string valueStr = OuterXml2.Substring(OuterXml2.IndexOf("value="), OuterXml2.IndexOf("unit=") - OuterXml2.IndexOf("value=")).Replace("value=", "").Replace("\"", "").Trim(); + ap.QT = valueStr; + } + + if (OuterXml1.Contains("MDC_ECG_TIME_PD_QTc")) + { + string valueStr = OuterXml2.Substring(OuterXml2.IndexOf("value="), OuterXml2.IndexOf("unit=") - OuterXml2.IndexOf("value=")).Replace("value=", "").Replace("\"", "").Trim(); + ap.QTc = valueStr; + } + + if (OuterXml1.Contains("MDC_ECG_ANGLE_P_FRONT")) + { + string valueStr = OuterXml2.Substring(OuterXml2.IndexOf("value="), OuterXml2.IndexOf("unit=") - OuterXml2.IndexOf("value=")).Replace("value=", "").Replace("\"", "").Trim(); + ap.P_degrees = valueStr; + } + + if (OuterXml1.Contains("MDC_ECG_ANGLE_QRS_FRONT")) + { + string valueStr = OuterXml2.Substring(OuterXml2.IndexOf("value="), OuterXml2.IndexOf("unit=") - OuterXml2.IndexOf("value=")).Replace("value=", "").Replace("\"", "").Trim(); + ap.QRS_degrees = valueStr; + } + + if (OuterXml1.Contains("MDC_ECG_ANGLE_T_FRONT")) + { + string valueStr = OuterXml2.Substring(OuterXml2.IndexOf("value="), OuterXml2.IndexOf("unit=") - OuterXml2.IndexOf("value=")).Replace("value=", "").Replace("\"", "").Trim(); + ap.T_degrees = valueStr; + } + + if (OuterXml1.Contains("Biocare_RV5") && !OuterXml1.Contains("Biocare_RV5_PLUS_SV1")) + { + string valueStr = OuterXml2.Substring(OuterXml2.IndexOf("value="), OuterXml2.IndexOf("unit=") - OuterXml2.IndexOf("value=")).Replace("value=", "").Replace("\"", "").Trim(); + ap.RV5 = valueStr; + } + + if (OuterXml1.Contains("Biocare_SV1")) + { + string valueStr = OuterXml2.Substring(OuterXml2.IndexOf("value="), OuterXml2.IndexOf("unit=") - OuterXml2.IndexOf("value=")).Replace("value=", "").Replace("\"", "").Trim(); + ap.SV1 = valueStr; + } + + if (OuterXml1.Contains("Biocare_RV5_PLUS_SV1")) + { + string valueStr = OuterXml2.Substring(OuterXml2.IndexOf("value="), OuterXml2.IndexOf("unit=") - OuterXml2.IndexOf("value=")).Replace("value=", "").Replace("\"", "").Trim(); + ap.RV5PLUSSV1 = valueStr; + } + + if (OuterXml1.Contains("Biocare_PAPER_SPEED")) + { + string valueStr = OuterXml2.Substring(OuterXml2.IndexOf("value="), OuterXml2.IndexOf("unit=") - OuterXml2.IndexOf("value=")).Replace("value=", "").Replace("\"", "").Trim(); + ap.paperSpeed = valueStr + "mm/s"; + } + + if (OuterXml1.Contains("Biocare_GAIN")) + { + string valueStr = OuterXml2.Substring(OuterXml2.IndexOf("value="), OuterXml2.IndexOf("unit=") - OuterXml2.IndexOf("value=")).Replace("value=", "").Replace("\"", "").Trim(); + ap.Gain = valueStr + "mm/mV"; + } + } + return ap; + } + catch (Exception ex) { } + + return null; + } + + + /// + /// 根据HL7-ECG XML文件 生成心电图 + /// + /// HL7-ECG XML 文件的路径 + /// 心电图报告标题 + /// + public string createEcgBmpByHL7XMLFile(string path, string reportInfo) + { + analysisParas ap = getAnalysisParas(path); + FileInfo fi = new FileInfo(path); + XmlDocument xmlDoc = new XmlDocument(); + XmlReaderSettings settings = new XmlReaderSettings(); + settings.IgnoreComments = true;//忽略文档里面的注释 + XmlReader reader = XmlReader.Create(path, settings); + xmlDoc.Load(reader); + XmlNodeList xn = xmlDoc.ChildNodes; + XmlNodeList xnList = xmlDoc.DocumentElement.GetElementsByTagName("digits"); + Dictionary> EcgTable = new Dictionary>(); + int leadDataIndex = 0; + for (int i = 0; i < 12; i++) + { + string[] ecgDataArray = new string[xnList.Item(leadDataIndex + i).InnerText.Split(' ').Length]; + ecgDataArray = xnList.Item(leadDataIndex + i).InnerText.Split(' '); + List ecg_List = new List(); + for (int b = 0; b < ecgDataArray.Length; b++) + if (!string.IsNullOrEmpty(ecgDataArray[b])) + ecg_List.Add(float.Parse(ecgDataArray[b]) / 9); + EcgTable.Add(i, ecg_List); + } + EcgDataDraw_New EDDN = new EcgDataDraw_New(); + var btmp = new Bitmap(3319, 2357); + Graphics Ecg_Graphics = Graphics.FromImage(btmp); + List leadInfo = new List(); + for (int i = 0; i < 12; i++) + leadInfo.Add(i); + EDDN.InitEcgParameter(btmp, 12, EcgTable, 300, leadInfo);//初始化 + EDDN.Draw_EcgBackGroundGrid(500);//画背景网格 + EDDN.Draw_EcgWave(500, 0, 0);//画波形 + EDDN.Draw_analysisParas(ap);//画患者信息和分析参数 + EDDN.Draw_CalibrationVoltage_And_LeadName();//画定标电压和导联名称 + EDDN.Draw_ReportHeadInfo(reportInfo, "", ""); + //string bmpPath = fi.DirectoryName + @"\EcgDataFiles\" + reportInfo + ".jpg"; + // string RotateEcgDataFilesPath = fi.DirectoryName + @"\RotateEcgDataFiles\" + reportInfo+ ".jpg"; + //string xmlPath = fi.DirectoryName + @"\XmlDataFiles\" + reportInfo + ".xml"; + + string ecgBmpPath = fi.DirectoryName + @"\" + ap.patientName + "[" + Guid.NewGuid().ToString() + "].jpg"; + btmp.Save(ecgBmpPath, ImageFormat.Jpeg); + //btmp.RotateFlip(RotateFlipType.Rotate90FlipNone);//顺时针旋转90° + //btmp.Save(RotateEcgDataFilesPath, ImageFormat.Jpeg); + btmp.Dispose(); + reader.Close(); + // fi.CopyTo(xmlPath, true); + //string returnStr = FtpHelper.FileUpLoad(bmpPath, ConfigurationManager.AppSettings["path1"], reportInfo + ".jpg");//上传 png文件 + // textBox2.AppendText(bmpPath + "\r\n" + reportInfo + ".jpg" + "\r\n FTP:" + returnStr + "\r\n"); // FtpHelper.FileUpLoad(xmlPath, ConfigurationManager.AppSettings["path1"], reportInfo.Split('_')[0] + ".xml");//上传 xml文件 + //dataSubmit(reportInfo);//提交数据 + //SqliteOptions_sql.CreateInstance().SqliteAdd("INSERT INTO [dbo].[tb_Pecg] ([ID],[medicalSN],[patientName],[sex],[birthday],[createDate],[ecgFilePath]) VALUES ('" + Guid.NewGuid().ToString() + "','" + reportInfo.Split('_')[0] + "','" + reportInfo.Split('_')[1] + "','" + reportInfo.Split('_')[2] + "','" + birthday + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" + (reportInfo.Split('_')[0] + ".jpg") + "')"); + //fi.Delete(); + //textBox2.AppendText(label1.Text + "\r\n"); + //label1.Text = string.Empty; + return ecgBmpPath; + } + + + } +} diff --git a/1200gFtp/OssUnity.cs b/1200gFtp/OssUnity.cs new file mode 100644 index 0000000..3575bc3 --- /dev/null +++ b/1200gFtp/OssUnity.cs @@ -0,0 +1,188 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Security.Cryptography; +using System.Windows.Forms; +using Aliyun.OSS; +using Aliyun.OSS.Common; + +namespace _1200gFtp +{ + /// + /// 阿里云上传下载数据类 + /// + public class OssUnity + { + public readonly OssClient _client; + const string endpoint = "http://oss-cn-beijing.aliyuncs.com"; + //北京科麦迪账号下的 华东2 上海 oss + const string accessId = "LTAI5tA3YFzqR2qHSLYZP68T"; + const string accessKey = "efjTmIWXCGcJO4vmnHnNhKsuXbiVo5"; + + public OssUnity() + { + + _client = new OssClient(endpoint, accessId, accessKey); + } + + /// + /// Bucket数据容器,出错返回错误信息. + /// + /// Bucket名称 + /// 错误信息 + /// 是否执行成功 + public bool CreateBucket(string bucketName, out string msg) + { + bool reslut = true; + msg = string.Empty; + try + { + var buckets = _client.ListBuckets(); + if (buckets.All(b => b.Name != bucketName)) + { + _client.CreateBucket(bucketName); + } + } + catch (OssException ex) + { + reslut = false; + msg = ex.Message; + } + return reslut; + } + + /// + /// 上传文件到Bucket容器 + /// + /// Bucket容器 + /// Key值 + /// 文件路径 + /// 返回MD5值 + public string PutObject(String bucketName, String key, String path) + { + using (var fs = File.Open(path, FileMode.Open)) + { + var metadata = new ObjectMetadata { ContentLength = fs.Length }; + var result = _client.PutObject(bucketName, key, fs, metadata); + return result.ETag; + } + } + /// + /// 下载数据 + /// + /// 进度条 + /// 提示文本框 + /// 文件保存路径 + /// bucket名称 + /// KEY值 + /// + public bool DownloadData(ProgressBar pb, Label lbl, string saveFileName, string bucketName, string key) + { + bool result = false; + short ticks = 0; + try + { + if (pb != null) + { + //if (pb.InvokeRequired) + //{ + // pb.BeginInvoke((Action)(() => + // { + // pb.Maximum = 100; + // })); + //} + //else + pb.Maximum = 100; + } + var obj = _client.GetObject(bucketName, key); + using (var requestStream = obj.Content) + { + var buf = new byte[1024]; + using (var fs = File.Open(saveFileName, FileMode.OpenOrCreate)) + { + var len = 0; + while ((len = requestStream.Read(buf, 0, 1024)) != 0) + { + fs.Write(buf, 0, len); + float percent = fs.Length / (float)obj.Metadata.ContentLength; + var n = (int)Math.Ceiling(percent * 100); + Application.DoEvents(); + + if (pb != null) + { + pb.Value = n <= 100 ? n : 100; + //pb.Refresh(); + } + if (lbl != null) + { + lbl.Text = percent.ToString("00.00%"); + //lbl.Refresh(); + } + } + } + } + result = true; + } + catch (Exception ex) + { + ticks++; + if (ticks < 3) + { + DownloadData(pb, lbl, saveFileName, bucketName, key); + } + else + { + // Watching.Write(@"下载出错:", ex); + if (lbl != null) + lbl.Text = "下载出错,请稍后再试!"; + } + } + return result; + } + + /// + /// 判断OSS上的文件是否存在 + /// + /// BUCKET NAME + /// KEY + /// + public bool Exists(string bucketName, string key) + { + bool flag = true; + try + { + OssObject obj = _client.GetObject(bucketName, key); + obj.Dispose(); + } + catch (Exception) + { + flag = false; + } + return flag; + } + + /// + /// 下载oss上的文件 + /// + /// + /// + /// + public void GetObject(String bucketName, string key, string localFilePath) + { + var object1 = _client.GetObject(bucketName, key); + using (var requestStream = object1.Content) + { + var buf = new byte[1024]; + var fs = File.Open(localFilePath, FileMode.OpenOrCreate); + int len; + while ((len = requestStream.Read(buf, 0, 1024)) != 0) + { + fs.Write(buf, 0, len); + } + fs.Close(); + } + } + + } +} diff --git a/1200gFtp/PatientMd.cs b/1200gFtp/PatientMd.cs new file mode 100644 index 0000000..397f584 --- /dev/null +++ b/1200gFtp/PatientMd.cs @@ -0,0 +1,277 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace _1200gFtp +{ + public class PatientMd + { + public string REGISTDATE { get; set; }//东营体检系统的 登记日期 + public string companyName { get; set; } + public string highLevelOrgID { get; set; } + /// + /// 时长 + /// + public string ecgTimeLong { get; set; } + + /// + /// 年龄 + /// + public string age { get; set; } + /// + /// 主键 + /// + public string ID { get; set; } + /// + /// 患者ID + /// + public string PatientID { get; set; } + /// + /// 姓名 + /// + public string PatientName { get; set; } + /// + /// 性别 + /// + public string Gender { get; set; } + /// + /// 出生日期 + /// + public string Birthday { get; set; } + /// + /// 民族 + /// + public string Folk { get; set; } + /// + /// 身份证ID + /// + public string P_Id { get; set; } + /// + /// 地址 + /// + public string Address { get; set; } + /// + /// 签证机关 + /// + public string Agency { get; set; } + /// + /// 有效期的开始时间 + /// + public string ExpireStart { get; set; } + /// + /// 有效期的结束时间 + /// + public string ExpireEnd { get; set; } + /// + /// 工作单位 + /// + public string WorkUnits { get; set; } + /// + /// 联系电话 + /// + public string Phone { get; set; } + /// + /// 文化程度 + /// + public string Levelofeducation { get; set; } + /// + /// 婚姻状况 + /// + public string Marriage { get; set; } + /// + /// 常住类型 + /// + public string PermanentType { get; set; } + /// + /// 血型 + /// + public string BloodType { get; set; } + /// + /// 睡眠情况 + /// + public string SleepStatus { get; set; } + /// + /// 体育锻炼 + /// + public string PhysicalExercise { get; set; } + /// + /// 饮酒情况 + /// + public string Drinking { get; set; } + /// + /// 职业 + /// + public string Professional { get; set; } + /// + /// 身高 + /// + public string Height { get; set; } + /// + /// 腰围 + /// + public string Waistline { get; set; } + /// + /// 臀围 + /// + public string Hipline { get; set; } + /// + /// 体重 + /// + public string Weight { get; set; } + /// + /// 残疾情况 + /// + public string DisabilityStatus { get; set; } + /// + /// 药物过敏史 + /// + public string Allergy { get; set; } + /// + /// 暴露史 + /// + public string ExposureHistory { get; set; } + /// + /// 疾病史 + /// + public string DiseasesHistory { get; set; } + /// + /// 手术史 + /// + public string OperationHistory { get; set; } + /// + /// 外伤史 + /// + public string RtaumaHistory { get; set; } + /// + /// 输血史 + /// + public string TransfusionHistory { get; set; } + + /// + /// 年龄开始 + /// + public string AgeStart { get; set; } + /// + /// 年龄结束 + /// + public string AgeEnd { get; set; } + /// + /// 采集开始时间 + /// + public string CollectionStartDate { get; set; } + /// + /// 采集结束时间 + /// + public string ConllectionEndDate { get; set; } + + /// + /// 采集时间 + /// + public string WardshipId { get; set; } + /// + /// 申请ID + /// + public string AppId { get; set; } + + /// + /// 判读状态 + /// + public string Pdstatus { get; set; } + + /// + /// + /// + public string LEU { get; set; } + + + public string NIT { get; set; } + + + public string UBG { get; set; } + + + public string PRO { get; set; } + + + public string PH { get; set; } + + + public string BLD { get; set; } + + + public string KET { get; set; } + + + public string BIL { get; set; } + + + public string GLU { get; set; } + + + public string VC { get; set; } + + + public string SG { get; set; } + + + public string Mmol { get; set; } + + + public string Spo2 { get; set; } + + + public string DIA { get; set; } + + + public string SYS { get; set; } + + public string Temperature { get; set; } + + /// + /// 门诊号 + /// + public string mzh { get; set; } + /// + /// 病历号 + /// + public string blh { get; set; } + /// + /// 科室 + /// + public string keshi { get; set; } + /// + /// 病房病床 + /// + public string bfbc { get; set; } + + /// + /// 是否是心电患者 + /// + public string isEcg { get; set; } + /// + /// 是否是血压患者 + /// + public string isBp { get; set; } + + /// + /// 是否是单导心电贴患者 + /// + public string isSingleEcg { get; set; } + + /// + /// 是否是心电图患者 + /// + public string isXinDianTu { get; set; } + /// + /// 是否是 精神压力分析患者 + /// + public string isHrvBalance { get; set; } + /// + /// 体检编号 + /// + public string medicalSN { get; set; } + + } +} diff --git a/1200gFtp/Program.cs b/1200gFtp/Program.cs new file mode 100644 index 0000000..4b3ee5c --- /dev/null +++ b/1200gFtp/Program.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Windows.Forms; + +namespace _1200gFtp +{ + static class Program + { + /// + /// 应用程序的主入口点。 + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/1200gFtp/Properties/AssemblyInfo.cs b/1200gFtp/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..888346b --- /dev/null +++ b/1200gFtp/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("1200gFtp")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("1200gFtp")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +//将 ComVisible 设置为 false 将使此程序集中的类型 +//对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("09be6454-1cea-403f-81be-5a7170fd5d7f")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, +// 方法是按如下所示使用“*”: : +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/1200gFtp/Properties/Resources.Designer.cs b/1200gFtp/Properties/Resources.Designer.cs new file mode 100644 index 0000000..cab276c --- /dev/null +++ b/1200gFtp/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace 云心电ECG数据解析服务端.Properties { + using System; + + + /// + /// 一个强类型的资源类,用于查找本地化的字符串等。 + /// + // 此类是由 StronglyTypedResourceBuilder + // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 + // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen + // (以 /str 作为命令选项),或重新生成 VS 项目。 + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// 返回此类使用的缓存的 ResourceManager 实例。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("云心电ECG数据解析服务端.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// 重写当前线程的 CurrentUICulture 属性,对 + /// 使用此强类型资源类的所有资源查找执行重写。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/1200gFtp/Properties/Resources.resx b/1200gFtp/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/1200gFtp/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/1200gFtp/Properties/Settings.Designer.cs b/1200gFtp/Properties/Settings.Designer.cs new file mode 100644 index 0000000..a5b3330 --- /dev/null +++ b/1200gFtp/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace 云心电ECG数据解析服务端.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.9.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/1200gFtp/Properties/Settings.settings b/1200gFtp/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/1200gFtp/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/1200gFtp/SMS.cs b/1200gFtp/SMS.cs new file mode 100644 index 0000000..910e134 --- /dev/null +++ b/1200gFtp/SMS.cs @@ -0,0 +1,75 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net; +using System.Text; + +namespace _1200gFtp +{ + class SMS + { + public static string smsSend(string phone, string content) + { + string userid = "1699";//企业ID + string account = "XDKJ168"; //用户名 + string password = "qwe18601017090"; //密码 + StringBuilder sbTemp = new StringBuilder(); + //POST 传值 + sbTemp.Append("action=send&userid=" + userid + "&account=" + account + "&password=" + password + "&mobile=" + phone + "&content=" + content); + byte[] bTemp = System.Text.Encoding.GetEncoding("GBK").GetBytes(sbTemp.ToString()); + string postReturn = doPostRequest("http://www.uehyt.com/smsGBK.aspx", bTemp); + //Response.Write("Post response is: " + postReturn); //测试返回结果 + return postReturn; + } + + private static String doPostRequest(string url, byte[] bData) + { + System.Net.HttpWebRequest hwRequest; + System.Net.HttpWebResponse hwResponse; + + string strResult = string.Empty; + try + { + hwRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url); + hwRequest.Timeout = 5000; + hwRequest.Method = "POST"; + hwRequest.ContentType = "application/x-www-form-urlencoded"; + hwRequest.ContentLength = bData.Length; + + System.IO.Stream smWrite = hwRequest.GetRequestStream(); + smWrite.Write(bData, 0, bData.Length); + smWrite.Close(); + } + catch (System.Exception err) + { + WriteErrLog(err.ToString()); + return strResult; + } + + //get response + try + { + hwResponse = (HttpWebResponse)hwRequest.GetResponse(); + StreamReader srReader = new StreamReader(hwResponse.GetResponseStream(), Encoding.ASCII); + strResult = srReader.ReadToEnd(); + srReader.Close(); + hwResponse.Close(); + } + catch (System.Exception err) + { + WriteErrLog(err.ToString()); + } + + return strResult; + } + + private static void WriteErrLog(string strErr) + { + Console.WriteLine(strErr); + System.Diagnostics.Trace.WriteLine(strErr); + } + + + } +} diff --git a/1200gFtp/SqliteOptions.cs b/1200gFtp/SqliteOptions.cs new file mode 100644 index 0000000..c976af4 --- /dev/null +++ b/1200gFtp/SqliteOptions.cs @@ -0,0 +1,263 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.IO; +using System.Data; +using System.Windows.Forms; +using System.Data.SqlClient; +using System.Security.Cryptography; + +namespace _1200gFtp +{ + public class SqliteOptions_sql + { + public SqlConnection sqliteConn = null; + /// + /// 让此类创建一个单例类 + /// + public static SqliteOptions_sql _instance = null;//申明一个EcgDrawing对象,复制Null + private static readonly object lockHelper = new object(); + + public static SqliteOptions_sql CreateInstance() + { + if (_instance == null) + { + lock (lockHelper) + { + if (_instance == null) + _instance = new SqliteOptions_sql(); + } + } + return _instance; + } + + public SqliteOptions_sql() + { + GetSqliteConnection(); + } + + + /// + /// DES加密 + /// + /// 加密数据 + /// 8位字符的密钥字符串 + /// 8位字符的初始化向量字符串 + /// + public string DESEncrypt(string data, string key, string iv) + { + byte[] byKey = System.Text.ASCIIEncoding.ASCII.GetBytes(key); + byte[] byIV = System.Text.ASCIIEncoding.ASCII.GetBytes(iv); + + DESCryptoServiceProvider cryptoProvider = new DESCryptoServiceProvider(); + int i = cryptoProvider.KeySize; + MemoryStream ms = new MemoryStream(); + CryptoStream cst = new CryptoStream(ms, cryptoProvider.CreateEncryptor(byKey, byIV), CryptoStreamMode.Write); + + StreamWriter sw = new StreamWriter(cst); + sw.Write(data); + sw.Flush(); + cst.FlushFinalBlock(); + sw.Flush(); + return Convert.ToBase64String(ms.GetBuffer(), 0, (int)ms.Length); + } + + + + /// + /// DES解密 + /// + /// 解密数据 + /// 8位字符的密钥字符串(需要和加密时相同) + /// 8位字符的初始化向量字符串(需要和加密时相同) + /// + public string DESDecrypt(string data, string key, string iv) + { + byte[] byKey = System.Text.ASCIIEncoding.ASCII.GetBytes(key); + byte[] byIV = System.Text.ASCIIEncoding.ASCII.GetBytes(iv); + + byte[] byEnc; + try + { + byEnc = Convert.FromBase64String(data); + } + catch + { + return null; + } + + DESCryptoServiceProvider cryptoProvider = new DESCryptoServiceProvider(); + MemoryStream ms = new MemoryStream(byEnc); + CryptoStream cst = new CryptoStream(ms, cryptoProvider.CreateDecryptor(byKey, byIV), CryptoStreamMode.Read); + StreamReader sr = new StreamReader(cst); + return sr.ReadToEnd(); + } + + + /// + /// 获得sqlite数据库连接 + /// + /// + /// + public bool GetSqliteConnection() + { + try + { + //给数据库连接类赋值 + string ConnectionStr = File.ReadAllText(Application.StartupPath + @"\conn.dll"); + ConnectionStr = DESDecrypt(ConnectionStr, "51220151", "51220151"); + SqlConnection conn = new SqlConnection(ConnectionStr); + sqliteConn = conn; + } + catch { return false; } + return true; + } + + /// + /// 执行sqlite查询语句,并返回一个 DataTable + /// + /// + /// + public DataTable ExcuteSqlite(string sqliteStr) + { + SqlDataAdapter sqliteDp = new SqlDataAdapter(sqliteStr, sqliteConn); + DataSet sqliteds = new DataSet(); + try + { + //if (sqliteConn.State == ConnectionState.Open) + // sqliteConn.Close(); + sqliteDp.SelectCommand.CommandTimeout = 600000; + sqliteDp.Fill(sqliteds); + return sqliteds.Tables[0]; + } + catch { } + return new DataTable(); + } + + /// + /// Sqlite 添加数据的操作函数 + /// + /// + /// + public bool SqliteAdd(string sqliteSQL) + { + try + { + if (sqliteConn.State == ConnectionState.Closed) + sqliteConn.Open(); + SqlCommand sqliteCmd = new SqlCommand(sqliteSQL, sqliteConn); + sqliteCmd.ExecuteNonQuery(); + sqliteCmd.Dispose(); + sqliteConn.Close(); + } + catch { return false; } + return true; + } + + /// + /// Sqlite 删除数据的操作函数 + /// + /// + /// + public bool SqliteDelete(string sqliteSQL) + { + try + { + if (sqliteConn.State == ConnectionState.Closed) + sqliteConn.Open(); + SqlCommand sqliteCmd = new SqlCommand(sqliteSQL, sqliteConn); + sqliteCmd.CommandTimeout = 3600; + sqliteCmd.ExecuteNonQuery(); + sqliteCmd.Dispose(); + sqliteConn.Close(); + } + catch { return false; } + return true; + } + + /// + /// Sqlite 更新数据的操作函数 + /// + /// + /// + public bool SqliteUpdate(string sqliteSQL) + { + try + { + if (sqliteConn.State == ConnectionState.Closed) + sqliteConn.Open(); + SqlCommand sqliteCmd = new SqlCommand(sqliteSQL, sqliteConn); + sqliteCmd.ExecuteNonQuery(); + sqliteCmd.Dispose(); + sqliteConn.Close(); + } + catch { return false; } + return true; + } + + /// + /// 执行SQL语句函数 + /// + /// SQL语句 + /// SQL语句中的参数组 + /// 返回受影响记录条数 + public int ExecuteSql(string sqlcmd, params SqlParameter[] paras) + { + + SqlCommand cmd = new SqlCommand(sqlcmd, sqliteConn); + if (sqliteConn.State == ConnectionState.Closed) + { + sqliteConn.Open(); + } + + foreach (SqlParameter p in paras) + { + cmd.Parameters.Add(p); + } + + int cnt = cmd.ExecuteNonQuery(); + sqliteConn.Close(); + return cnt; + } + + + + + /// + /// Sqlite 执行数据库的多条语句, + /// + /// + /// + public bool SqliteExecuteNonQuery(string[] sqliteSQL) + { + + if (sqliteConn.State == ConnectionState.Closed) + { + sqliteConn.Open(); + } + SqlTransaction sqlTran = sqliteConn.BeginTransaction(); + try + { + foreach (string sql in sqliteSQL) + { + SqlCommand sqliteCmd = new SqlCommand(sql, sqliteConn, sqlTran); + sqliteCmd.ExecuteNonQuery(); + sqliteCmd.Dispose(); + } + sqlTran.Commit(); + } + catch + { + sqlTran.Rollback(); + return false; + } + finally + { + + sqliteConn.Close(); + } + return true; + } + + } +} diff --git a/1200gFtp/analysisParas.cs b/1200gFtp/analysisParas.cs new file mode 100644 index 0000000..7a7a0ef --- /dev/null +++ b/1200gFtp/analysisParas.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 云心电ECG数据解析服务端 +{ + public class analysisParas + { + + public string patientid { get; set; }//患者id + public string collectTime { get; set; }//采集时间 + public string birthDay { get; set; }//出生日期 + public string age { get; set; }//年龄 + public string patientName { get; set; }//姓名 + public string gender { get; set; }//性别 + public string heartRate { get; set; }//心率 + public string P { get; set; }//P波宽度 ms + public string QRS { get; set; }//QRS波宽度 ms + public string RR { get; set; }//RR波间期 ms + public string PR { get; set; }//PR间期 ms + public string PQ { get; set; }//PQ间期 ms + public string QT { get; set; }//QT间期 ms + public string QTc { get; set; }//QTC ms + public string P_degrees { get; set; }//电轴 度数 + public string QRS_degrees { get; set; }//电轴 度数 + public string T_degrees { get; set; }//电轴 度数 + public string RV5 { get; set; }//mv + public string SV1 { get; set; }//mv + public string RV5PLUSSV1 { get; set; }//mv + public string paperSpeed { get; set; }//走速 mm/s + public string Gain { get; set; }//增益 mm/mV + + public List LEAD_I { get; set; }// I导联数据 + public List LEAD_II { get; set; }// II导联数据 + public List LEAD_III { get; set; }// III导联数据 + public List LEAD_AVR { get; set; }// AVR导联数据 + public List LEAD_AVL { get; set; }// AVL导联数据 + public List LEAD_AVF { get; set; }// AVF导联数据 + public List LEAD_V1 { get; set; }// V1导联数据 + public List LEAD_V2 { get; set; }// V2导联数据 + public List LEAD_V3 { get; set; }// V3导联数据 + public List LEAD_V4 { get; set; }// V4导联数据 + public List LEAD_V5 { get; set; }// V5导联数据 + public List LEAD_V6 { get; set; }// V6导联数据 + } +} diff --git a/1200gFtp/apiList.cs b/1200gFtp/apiList.cs new file mode 100644 index 0000000..e5ab127 --- /dev/null +++ b/1200gFtp/apiList.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace _1200gFtp +{ + public class apiList + { + public static string loginUrl = ""; + public static string patientUrl = ""; + public static string blUrl = "";//病历Url + + + + //public static string submitXmlInfo= "http://localhost:20086/api/DiagnosticApply/SubmitDiagnosticApply";//张家口的新版HIS接口:提交 心电 xml信息给何冰冰 。 他申请判读 + public static string submitXmlInfo = "http://47.104.235.204:8015/api/DiagnosticApply/SubmitDiagnosticApply";//河北省的新版HIS接口:提交 心电 xml信息给何冰冰 。 他申请判读 + + public static string his03 = "http://his.hebjcws.com:7086/pm-s-report/ECG/HIS03"; + } +} diff --git a/1200gFtp/app.config b/1200gFtp/app.config new file mode 100644 index 0000000..85cfd9f --- /dev/null +++ b/1200gFtp/app.config @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/1200gFtp/baseModel.cs b/1200gFtp/baseModel.cs new file mode 100644 index 0000000..441e424 --- /dev/null +++ b/1200gFtp/baseModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace _1200gFtp +{ + public class baseModel + { + public bool successed { get; set; } + public string msg { get; set; } + public object data { get; set; } + } +} diff --git a/1200gFtp/commonOptions.cs b/1200gFtp/commonOptions.cs new file mode 100644 index 0000000..0d78423 --- /dev/null +++ b/1200gFtp/commonOptions.cs @@ -0,0 +1,636 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Drawing; +using System.Drawing.Imaging; +using System.IO; +using System.Linq; +using System.Net; + +using System.Security.Cryptography; +using System.Text; +using System.Threading.Tasks; + + +namespace _1200gFtp +{ + public class commonOptions + { + /// + /// 获取福乐云HIS系统的token + /// + /// + /// + /// + public static string getHisToken(string url1,string appkey, string appsecret) + { + Dictionary dic = new Dictionary(); + dic.Add("appkey", appkey); + dic.Add("appsecret", appsecret); + + string resultV = commonOptions.PostFile3(url1, dic); + FlyHisTokenMsgModel tm = JsonConvert.DeserializeObject(resultV); + return tm.data.access_token; + } + + /// + /// 获取福乐云HIS系统的患者基本信息 + /// + /// + /// + /// + public static FlyHisEcgDataModel GetHisEcgData(string url1, string Yiyuanid, string kaifangsj,string token) + { + Dictionary dic = new Dictionary(); + dic.Add("Yiyuanid", Yiyuanid); + dic.Add("kaifangsj", kaifangsj); + dic.Add("token", token); + string resultV = commonOptions.PostFile3(url1, dic); + FlyHisEcgDataModel tm = JsonConvert.DeserializeObject(resultV); + return tm; + } + + + + /// + /// post form-data 参数 + /// + /// + /// + /// + public static string PostFile3(string url, Dictionary items) + { + string boundary = DateTime.Now.Ticks.ToString("x"); + HttpWebRequest request = null; + //如果是发送HTTPS请求               + if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase)) + { + //处理HttpWebRequest访问https有安全证书的问题( 请求被中止: 未能创建 SSL/TLS 安全通道。) + ServicePointManager.ServerCertificateValidationCallback += (s, cert, chain, sslPolicyErrors) => true; + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls; + + //ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult); + request = WebRequest.Create(url) as HttpWebRequest; + request.ProtocolVersion = HttpVersion.Version10; + } + else + { + request = WebRequest.Create(url) as HttpWebRequest; + } + + request.ContentType = "multipart/form-data; boundary=" + boundary; + request.Method = "POST"; + // request.Headers.Add("Authorization", "Bearer " + token); + // 最后的结束符 + var endBoundary = Encoding.UTF8.GetBytes("\r\n--" + boundary + "--\r\n"); + + //文件数据 + string fileFormdataTemplate = + "--" + boundary + + "\r\nContent-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"" + + "\r\nContent-Type: application/octet-stream" + + "\r\n\r\n"; + + //文本数据 + string dataFormdataTemplate = + "\r\n--" + boundary + + "\r\nContent-Disposition: form-data; name=\"{0}\"" + + "\r\n\r\n{1}"; + //FileInfo fi = new FileInfo(filePath); + //string fileHeader = string.Format(fileFormdataTemplate, "file", fi.Name); + //var fileBytes = Encoding.UTF8.GetBytes(fileHeader); + + using (var postStream = new MemoryStream()) + { + ////写入文件格式串 + //postStream.Write(fileBytes, 0, fileBytes.Length); + + //#region 写入文件流 + //using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read)) + //{ + // byte[] buffer = new byte[1024]; + // int bytesRead = 0; + // while ((bytesRead = fs.Read(buffer, 0, buffer.Length)) != 0) + // { + // postStream.Write(buffer, 0, bytesRead); + // } + //} + //#endregion + + #region 写入其他表单参数 + foreach (KeyValuePair key in items) + { + var p = string.Format(dataFormdataTemplate, key.Key, key.Value); + var bp = Encoding.UTF8.GetBytes(p); + postStream.Write(bp, 0, bp.Length); + } + #endregion + + //写入结束边界 + postStream.Write(endBoundary, 0, endBoundary.Length); + + #region 写入流 + + request.ContentLength = postStream.Length; + postStream.Position = 0; + using (Stream ds = request.GetRequestStream()) + { + byte[] buffer = new byte[1024]; + int bytesRead = 0; + while ((bytesRead = postStream.Read(buffer, 0, buffer.Length)) != 0) + { + ds.Write(buffer, 0, bytesRead); + } + } + #endregion + + #region 获取返回值 + + string result = string.Empty; + using (HttpWebResponse rep = (HttpWebResponse)request.GetResponse()) + { + using (Stream ds = rep.GetResponseStream()) + { + using (StreamReader sr = new StreamReader(ds)) + { + result = sr.ReadToEnd(); + } + } + } + + return result; + + #endregion + } + } + + + + //public static string PostMoths8(string url, string appkey, string appsecret) + //{ + // string strURL = url; + // HttpWebRequest request; + // request = (HttpWebRequest)WebRequest.Create(strURL); + // request.Method = "POST"; + // request.ContentType = "application/json;charset=UTF-8"; + // string paraUrlCoded = param; + // byte[] payload; + // payload = Encoding.UTF8.GetBytes(paraUrlCoded); + // request.ContentLength = payload.Length; + // Stream writer = request.GetRequestStream(); + // writer.Write(payload, 0, payload.Length); + // writer.Close(); + // System.Net.HttpWebResponse response; + // response = (System.Net.HttpWebResponse)request.GetResponse(); + // System.IO.Stream s; + // s = response.GetResponseStream(); + // string StrDate = ""; + // string strValue = ""; + // StreamReader Reader = new StreamReader(s, Encoding.UTF8); + // while ((StrDate = Reader.ReadLine()) != null) + // { + // strValue += StrDate + "\r\n"; + // } + // return strValue; + //} + + + /// + /// 获取福乐云的token + /// + /// + /// + /// + public static string gettoken(string username, string pwd, string url1) + { + loginPara lp = new loginPara(); + lp.username = username; + lp.password = commonOptions.Encrypt(pwd);//非对称公钥加密 + string loginJson = JsonConvert.SerializeObject(lp); + string resultV = commonOptions.PostMoths(url1, loginJson); + tokenMsg tm = JsonConvert.DeserializeObject(resultV); + return tm.data; + } + + // 非对称公钥加密 使用公钥加密数据 + public static string Encrypt(string plainText) + { + string base64EncryptedData = string.Empty; + // 创建 RSA 密钥对 + using (var rsa = new RSACryptoServiceProvider()) + { + // 获取公钥 + string publicKey = rsa.ToXmlString(false); + // 加载公钥 + rsa.FromXmlString("gMIre8vicEqHjwhyrMUSMbwyR+STy9vGDyqmOd9xA4JI9/ghqAQAl5T9R8z87gwKMosPsEaRf4/1tg8taa/q2g0xwcZZ3dZlBzDSQ7k7I7t/Cv+m3YUZDp1U1TooSw8NzX3MQ36u1uiniWAUMvA0PT17dR6dxsQmMdDN4xSJO/0=AQAB"); + // 将待加密数据转换成字节数组 + byte[] dataToEncrypt = Encoding.UTF8.GetBytes(plainText); + // 使用公钥加密数据 + byte[] encryptedData = rsa.Encrypt(dataToEncrypt, false); + // 将加密后的数据转换为 Base64 编码的字符串 + base64EncryptedData = Convert.ToBase64String(encryptedData); + string aaa = "公钥:" + publicKey; + + } + return base64EncryptedData; + //byte[] encryptedData = Encoding.UTF8.GetBytes(plainText); + //using (RSA rsa = RSA.Create()) + //{ + // rsa.ImportParameters(publicKey); + // // return rsa.Encrypt(data, RSAEncryptionPadding.Pkcs1); + // return Encoding.UTF8.GetString(rsa.Encrypt(encryptedData, RSAEncryptionPadding.Pkcs1)); + //} + } + +//---------------------------------------------------------------------------------------------------------------------------- + + + + + + // 非对称公钥加密 使用公钥加密数据 + public static string Encrypt(string plainText, RSAParameters publicKey) + { + byte[] encryptedData = Encoding.UTF8.GetBytes(plainText); + using (RSA rsa = RSA.Create()) + { + rsa.ImportParameters(publicKey); + // return rsa.Encrypt(data, RSAEncryptionPadding.Pkcs1); + return Encoding.UTF8.GetString(rsa.Encrypt(encryptedData, RSAEncryptionPadding.Pkcs1)); + } + } + + + /// + /// DES加密 + /// + /// 加密数据 + /// 8位字符的密钥字符串 + /// 8位字符的初始化向量字符串 + /// + public static string DESEncrypt(string data, string key, string iv) + { + byte[] byKey = System.Text.ASCIIEncoding.ASCII.GetBytes(key); + byte[] byIV = System.Text.ASCIIEncoding.ASCII.GetBytes(iv); + + DESCryptoServiceProvider cryptoProvider = new DESCryptoServiceProvider(); + int i = cryptoProvider.KeySize; + MemoryStream ms = new MemoryStream(); + CryptoStream cst = new CryptoStream(ms, cryptoProvider.CreateEncryptor(byKey, byIV), CryptoStreamMode.Write); + + StreamWriter sw = new StreamWriter(cst); + sw.Write(data); + sw.Flush(); + cst.FlushFinalBlock(); + sw.Flush(); + return Convert.ToBase64String(ms.GetBuffer(), 0, (int)ms.Length); + } + + /// + /// DES解密 + /// + /// 解密数据 + /// 8位字符的密钥字符串(需要和加密时相同) + /// 8位字符的初始化向量字符串(需要和加密时相同) + /// + public static string DESDecrypt(string data, string key, string iv) + { + byte[] byKey = System.Text.ASCIIEncoding.ASCII.GetBytes(key); + byte[] byIV = System.Text.ASCIIEncoding.ASCII.GetBytes(iv); + + byte[] byEnc; + try + { + byEnc = Convert.FromBase64String(data); + } + catch + { + return null; + } + + DESCryptoServiceProvider cryptoProvider = new DESCryptoServiceProvider(); + MemoryStream ms = new MemoryStream(byEnc); + CryptoStream cst = new CryptoStream(ms, cryptoProvider.CreateDecryptor(byKey, byIV), CryptoStreamMode.Read); + StreamReader sr = new StreamReader(cst); + return sr.ReadToEnd(); + } + + public static string PostMoths(string url, string param) + { + string strURL = url; + HttpWebRequest request; + request = (HttpWebRequest)WebRequest.Create(strURL); + request.Method = "POST"; + request.ContentType = "application/json;charset=UTF-8"; + string paraUrlCoded = param; + byte[] payload; + payload = Encoding.UTF8.GetBytes(paraUrlCoded); + request.ContentLength = payload.Length; + Stream writer = request.GetRequestStream(); + writer.Write(payload, 0, payload.Length); + writer.Close(); + System.Net.HttpWebResponse response; + response = (System.Net.HttpWebResponse)request.GetResponse(); + System.IO.Stream s; + s = response.GetResponseStream(); + string StrDate = ""; + string strValue = ""; + StreamReader Reader = new StreamReader(s, Encoding.UTF8); + while ((StrDate = Reader.ReadLine()) != null) + { + strValue += StrDate + "\r\n"; + } + return strValue; + } + + + /// + /// + /// + /// + /// + /// + /// + public static string PostByParas(string url, string token, string jsonContent) + { + string result = ""; + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); + req.Method = "POST"; + req.ContentType = "application/json"; + req.Headers.Add("Authorization", "Bearer " + token); + byte[] data = Encoding.UTF8.GetBytes(jsonContent); + req.ContentLength = data.Length; + using (Stream reqStream = req.GetRequestStream()) + { + reqStream.Write(data, 0, data.Length); + reqStream.Close(); + } + HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); + Stream stream = resp.GetResponseStream(); + //获取响应内容 + using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) + { + result = reader.ReadToEnd(); + } + return result; + } + + + + + + + + /// + /// 海军给的 http 上传文件 好用版 + /// + /// + /// + /// + /// + /// + public static string PostFile2(string url, string filePath, Dictionary items, string token) + { + string boundary = DateTime.Now.Ticks.ToString("x"); + HttpWebRequest request = null; + //如果是发送HTTPS请求               + if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase)) + { + //处理HttpWebRequest访问https有安全证书的问题( 请求被中止: 未能创建 SSL/TLS 安全通道。) + ServicePointManager.ServerCertificateValidationCallback += (s, cert, chain, sslPolicyErrors) => true; + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls; + + //ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult); + request = WebRequest.Create(url) as HttpWebRequest; + request.ProtocolVersion = HttpVersion.Version10; + } + else + { + request = WebRequest.Create(url) as HttpWebRequest; + } + + request.ContentType = "multipart/form-data; boundary=" + boundary; + request.Method = "POST"; + request.Headers.Add("Authorization", "Bearer " + token); + // 最后的结束符 + var endBoundary = Encoding.UTF8.GetBytes("\r\n--" + boundary + "--\r\n"); + + //文件数据 + string fileFormdataTemplate = + "--" + boundary + + "\r\nContent-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"" + + "\r\nContent-Type: application/octet-stream" + + "\r\n\r\n"; + + //文本数据 + string dataFormdataTemplate = + "\r\n--" + boundary + + "\r\nContent-Disposition: form-data; name=\"{0}\"" + + "\r\n\r\n{1}"; + FileInfo fi = new FileInfo(filePath); + string fileHeader = string.Format(fileFormdataTemplate, "file", fi.Name); + var fileBytes = Encoding.UTF8.GetBytes(fileHeader); + + using (var postStream = new MemoryStream()) + { + //写入文件格式串 + postStream.Write(fileBytes, 0, fileBytes.Length); + + #region 写入文件流 + using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read)) + { + byte[] buffer = new byte[1024]; + int bytesRead = 0; + while ((bytesRead = fs.Read(buffer, 0, buffer.Length)) != 0) + { + postStream.Write(buffer, 0, bytesRead); + } + } + #endregion + + #region 写入其他表单参数 + foreach (KeyValuePair key in items) + { + var p = string.Format(dataFormdataTemplate, key.Key, key.Value); + var bp = Encoding.UTF8.GetBytes(p); + postStream.Write(bp, 0, bp.Length); + + //System.Diagnostics.Debug.WriteLine(p); + } + #endregion + + //写入结束边界 + postStream.Write(endBoundary, 0, endBoundary.Length); + + #region 写入流 + + request.ContentLength = postStream.Length; + postStream.Position = 0; + using (Stream ds = request.GetRequestStream()) + { + byte[] buffer = new byte[1024]; + int bytesRead = 0; + while ((bytesRead = postStream.Read(buffer, 0, buffer.Length)) != 0) + { + ds.Write(buffer, 0, bytesRead); + } + } + #endregion + + #region 获取返回值 + + string result = string.Empty; + using (HttpWebResponse rep = (HttpWebResponse)request.GetResponse()) + { + using (Stream ds = rep.GetResponseStream()) + { + using (StreamReader sr = new StreamReader(ds)) + { + result = sr.ReadToEnd(); + } + } + } + + return result; + + #endregion + } + } + + + + + + + + + /// + /// 指定Post地址使用Get 方式获取全部字符串 + /// + /// 请求后台地址 + /// + public static string PostByParas(string url, Dictionary dic) + { + string result = ""; + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); + req.Method = "POST"; + req.ContentType = "application/x-www-form-urlencoded"; + #region 添加Post 参数 + StringBuilder builder = new StringBuilder(); + int i = 0; + foreach (var item in dic) + { + if (i > 0) + builder.Append("&"); + builder.AppendFormat("{0}={1}", item.Key, item.Value); + i++; + } + byte[] data = Encoding.UTF8.GetBytes(builder.ToString()); + req.ContentLength = data.Length; + using (Stream reqStream = req.GetRequestStream()) + { + reqStream.Write(data, 0, data.Length); + reqStream.Close(); + } + #endregion + HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); + Stream stream = resp.GetResponseStream(); + //获取响应内容 + using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) + { + result = reader.ReadToEnd(); + } + return result; + } + + + + public static string HttpGet(string url) + { + //ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult); + Encoding encoding = Encoding.UTF8; + HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); + request.Method = "GET"; + request.Accept = "text/html, application/xhtml+xml, */*"; + request.ContentType = "application/json"; + + HttpWebResponse response = (HttpWebResponse)request.GetResponse(); + using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8)) + { + return reader.ReadToEnd(); + } + } + + + //public static Image CreateBarCode(string content) + //{ + // using (var barcode = new Barcode() + // { + // //true显示content,false反之 + // IncludeLabel = true, + + // //content的位置 + // Alignment = AlignmentPositions.CENTER, + + // //条形码的宽高 + // Width = 145, + // Height = 39, + + // //类型 + // RotateFlipType = RotateFlipType.RotateNoneFlipNone, + + // //颜色 + // BackColor = Color.White, + // ForeColor = Color.Black, + // }) + // { + // return barcode.Encode(TYPE.CODE128B, content); + // } + //} + + + /// + /// 格式化磁盘 + /// + /// 盘符名称:C:、D:、E:、F: + /// + public static bool FormatDisk(string DiskName) + { + ProcessStartInfo processStartInfo = new ProcessStartInfo("cmd.exe"); + processStartInfo.RedirectStandardInput = true; + processStartInfo.RedirectStandardOutput = true; + processStartInfo.UseShellExecute = false; + Process process = Process.Start(processStartInfo); + if (process != null) + { + process.StandardInput.WriteLine($"FORMAT {DiskName} /y /FS:FAT32 /V:BMECG /Q"); + process.StandardInput.Close(); + string outputString = process.StandardOutput.ReadToEnd(); + if (outputString.Contains("已完成")) + { + return true; + } + } + return false; + } + + + + + //public static void PdfToImages(string pdfFilePath, string outputFolder) + //{ + + // string imgpath = @"D:/PDFFF/"; + // var pathList = GetPdfAllPageImgs(pdfFilePath, imgpath, "11556699"); + + //} + + + + + + + +} +} diff --git a/1200gFtp/his03Model.cs b/1200gFtp/his03Model.cs new file mode 100644 index 0000000..9c5941f --- /dev/null +++ b/1200gFtp/his03Model.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace _1200gFtp +{ + public class his03Model + { + public int status { get; set; } + + public string posId { get; set; } + public string id { get; set; } + public string testDate { get; set; } + public string hisCode { get; set; } + public string name { get; set; } + public string identityCode { get; set; } + public string sex { get; set; } + + + + public int age { get; set; } + public string ageUnit { get; set; } + public string itemId { get; set; } + public string itemName { get; set; } + public string departmentId { get; set; } + public string doctorId { get; set; } + public string patientType { get; set; } + public string evidence { get; set; } + public string pdfUrl { get; set; } + + + + public string optName { get; set; } + public string auditName { get; set; } + public string bedNum { get; set; } + public string testNum { get; set; } + public string barCode { get; set; } + + + + public string specimenType { get; set; } + public string dicomUrl { get; set; } + public string conclusion { get; set; } + public string departmentName { get; set; } + public string doctorName { get; set; } + public string birthday { get; set; } + public string negaPosiTive { get; set; } + + } +} diff --git a/1200gFtp/loginPara.cs b/1200gFtp/loginPara.cs new file mode 100644 index 0000000..dca7da8 --- /dev/null +++ b/1200gFtp/loginPara.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace _1200gFtp +{ + public class loginPara + { + public string username { get; set; } + public string password { get; set; } + } +} diff --git a/1200gFtp/msgModel.cs b/1200gFtp/msgModel.cs new file mode 100644 index 0000000..9f9910a --- /dev/null +++ b/1200gFtp/msgModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace _1200gFtp +{ + public class msgModel + { + public string successed { get; set; } + public string msg { get; set; } + public string data { get; set; } + } +} diff --git a/1200gFtp/netOptions.cs b/1200gFtp/netOptions.cs new file mode 100644 index 0000000..b22aa92 --- /dev/null +++ b/1200gFtp/netOptions.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net; +using System.Text; + +namespace _1200gFtp +{ + public class netOptions + { + public static string HttpPost(string Url, string postDataStr) + { + 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; + } + public static string HttpPost(string Url, string postDataStr, string Method) + { + WebRequest request = WebRequest.Create(Url); + request.Method = Method; + 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; + } + + public static string PostWebRequest(string Url, string postDataStr, string Method, Dictionary headerDic) + { + string ret = string.Empty; + try + { + WebRequest request = WebRequest.Create(Url); + foreach (KeyValuePair kvp in headerDic) + request.Headers[kvp.Key] = kvp.Value; + request.Method = Method; + 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; + } + catch (Exception ex) + { + + } + return ret; + } + + + + /// + /// 获取url的返回值 + /// + /// + public static string GethttpInfo(string url) + { + string strBuff = ""; + Uri httpURL = new Uri(url); + ///HttpWebRequest类继承于WebRequest,并没有自己的构造函数,需通过WebRequest的Creat方法 建立,并进行强制的类型转换 + HttpWebRequest httpReq = (HttpWebRequest)WebRequest.Create(httpURL); + ///通过HttpWebRequest的GetResponse()方法建立HttpWebResponse,强制类型转换 + HttpWebResponse httpResp = (HttpWebResponse)httpReq.GetResponse(); + ///GetResponseStream()方法获取HTTP响应的数据流,并尝试取得URL中所指定的网页内容 + ///若成功取得网页的内容,则以System.IO.Stream形式返回,若失败则产生ProtoclViolationException错 误。在此正确的做法应将以下的代码放到一个try块中处理。这里简单处理 + Stream respStream = httpResp.GetResponseStream(); + ///返回的内容是Stream形式的,所以可以利用StreamReader类获取GetResponseStream的内容,并以 + //StreamReader类的Read方法依次读取网页源程序代码每一行的内容,直至行尾(读取的编码格式:UTF8) + StreamReader respStreamReader = new StreamReader(respStream, Encoding.UTF8); + strBuff = respStreamReader.ReadToEnd(); + return strBuff; + } + + + } +} diff --git a/1200gFtp/o13www.ixigua.com.ico b/1200gFtp/o13www.ixigua.com.ico new file mode 100644 index 0000000000000000000000000000000000000000..545c69bb3fdba70f92fd4c011483c368355237b7 GIT binary patch literal 4286 zcmb_fU5Hgx6h70fnL>n0(kTihf)Yb2`t>2L9wcV&Ir|QZ1p3ezYLiSR_+;u}iX{k> zKFmX;nNlJlL2o{U8WD(K&?Gq#4f9}_WLh)MJ!hYLR^PYx+2@{nX0CIsW>~Y&-h1u! zed}lcjOVrCcfkUWf4yUOd){2n^B#j>$Xf>CxcR}{oLN@vz^(sP>V~IO1o_dcR3_Rh zm8iX^=V~bk?0Dc~uB<(^LT=r73oDem+NM<433(N=J_w>WgP{6a5a^e{YjIEx=T(-+ zB^8ik4f6l-u)c?jfO8Ns4s6Lug7079|6yQnP)a{hsmSe0Rl(s#3!craqSVA)zNN ztDx2p$EX`N$1ILEIQ({a?%U4Wn4}!P2LAK^mV;6Wb2uAzKY&E2HRd|=lXxkPH0Hx{ z#8?a+a(GUuxUIRDQ)gH^s3X+8ei3#q(mwGlrp|rW$1!K>BGn^T>XE}y*y;5B)^Y(| z&kqE?>xbdVlzpq-xLGW?9`Y^x=N_&D;>%)&1~&*M+0G3Do-xsv zut&cWVy{^fCA)XWGBgy+o;_MNZPK!8mF1E5)o`$JcXjIOWfC@Dhcv_>JzM5r{AKvk z4_lu=ey7bema<|+B!>>g$@sXKpEwp78A;^CiJENPs%7O$8z0zcs6+N)$JDH~7ahac z{Vo8^Gy01W=fjx4h;PQzZ=vD&=D9x~nUa!NFK2Cku`jx>}2zIa8C~Ud>v~`<(NQbGjG!rUrnwgs~!i zt~L3xd?O+LfdjEbQ2}t8E_JqTi%rg~Pc|NT`-uNrxF0$g0OT0>>3%jG?0zB_D>?yw zvVVUpVK@z7VW?IU*|jU?+O*~~eA_p^>h-D;w-X;+o(8u+E!TR^O+V#D|M%^S#npZR zGV3NNkMrjfS+`Epf8g0Vo@!ewoa^Q+MvNbYoO7|KZayCDv;OGQl`A)|zq4l(*}U2K zp6x-0oyL=SZWj%4rNSdJcv1@)M0*`j$SoBYr=^X>GD zZR*z*==AjT#3hGsVh~hkL;pia#^2b>_C;vyk^}AHtTn#yF0!}{e&#s1dnohg3#@;z zQfYjXsV;NR@*Fs4_q@G7r}GCoE{=u#S`M5iN7gX8xjx2t#;wAe@V30~#(#Akb%1xX zir#_#HLiC;JMMc*%b1(E=k@D6EVhY36>ImR)@C((hrw5Hn8Z6Pd=I)AhaCTm6L~Zn zFLHz)-wvOb%lZMg=ZgNjzP*PhSqtRw2Yfe}u;JR~v9K}Yd>VhV<}dU=MQj(k`^I54 zYY_tz2dwLZoTEL5&u>UW9E$y%?$4MTfZ$!xSZ~d+-MIa~g*-Ig&Bn&}MVy=TN3o83 zX*qmBzU@8hY`5CldeFF^gy$3fhlu*%+sBX}P(yqh)yM(ub+jXpuORQD|4IbL6ZjCzg->Jhg2 zzipVdQPu(<sV0D-~`ybDU!mR)R literal 0 HcmV?d00001 diff --git a/1200gFtp/packages.config b/1200gFtp/packages.config new file mode 100644 index 0000000..dc4906e --- /dev/null +++ b/1200gFtp/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/1200gFtp/panduReturnModel.cs b/1200gFtp/panduReturnModel.cs new file mode 100644 index 0000000..e3ff4c8 --- /dev/null +++ b/1200gFtp/panduReturnModel.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace _1200gFtp +{ + public class panduReturnModel + { + public string applyId { get; set; }//申请id + public int applyStatus { get; set; }//申请状态 + public string auditorTime { get; set; }//审核时间 + public string auditorUserId { get; set; }//审核用户的用户ID + public string auditorUserName { get; set; }//审核用户的用户名 + public string crisis { get; set; }//危机值 + public string diagnosticPosId { get; set; }//诊断机构的机构id + public string patientBirthday { get; set; }//患者生日 + public string patientId { get; set; }//患者ID + public string patientName { get; set; }//患者姓名 + public string patientSex { get; set; }//患者性别 + public string positive { get; set; }//积极 + public string reportConclusion { get; set; }//诊断结论 + public string reportFeatures { get; set; }//特征说明 + public string reportPdf { get; set; }//报告地址 + public string reportTime { get; set; }//报告时间 + public string reportUserId { get; set; }//出报告的医生id + public string reportUserName { get; set; }//出报告的医生的用户名 + public string supplierId { get; set; }//供应商ID + + } +} diff --git a/1200gFtp/patientInfoFLY.cs b/1200gFtp/patientInfoFLY.cs new file mode 100644 index 0000000..0179acd --- /dev/null +++ b/1200gFtp/patientInfoFLY.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace _1200gFtp +{ + public class patientInfoFLY + { + public string patientName { get; set; } + public string idCard { get; set; } + public string sex { get; set; } + public string birthday { get; set; } + public string yearold { get; set; } + public string area { get; set; } + public string Items { get; set; } + public string appointmentTimes { get; set; } + public string symptom { get; set; } + public string hospitalCode { get; set; } + public string hospitalName { get; set; } + public string departmentCode { get; set; } + public string departmentName { get; set; } + public string resDoctorName { get; set; } + public string resDoctorCode { get; set; } + public string patientType { get; set; } + public int patientTypeCode { get; set; } + public string nation { get; set; } + public string appointmentId { get; set; } + public string wearTime { get; set; } + public int status { get; set; } + public string patientCode { get; set; } + } +} diff --git a/1200gFtp/patientInfoModel.cs b/1200gFtp/patientInfoModel.cs new file mode 100644 index 0000000..1c7abe4 --- /dev/null +++ b/1200gFtp/patientInfoModel.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace _1200gFtp +{ + public class patientInfoModel + { + public string ftpPath { get; set; } + public string patientName { get; set; } + public string patientSex { get; set; } + public int patientAge { get; set; } + public string startTime { get; set; } + public string endTime { get; set; } + public string dicomUrl { get; set; } + public bool isPanDu { get; set; } + + public string pdfUrl { get; set; } + public string testDate { get; set; } + public string evidence { get; set; } + public string conclusion { get; set; } + + } +} diff --git a/1200gFtp/returnPatientModel.cs b/1200gFtp/returnPatientModel.cs new file mode 100644 index 0000000..521a691 --- /dev/null +++ b/1200gFtp/returnPatientModel.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace _1200gFtp +{ + public class returnPatientModel + { + public string code { get; set; } + public string message { get; set; } + public string result { get; set; } + public string data { get; set; } + } +} diff --git a/1200gFtp/tokenMsg.cs b/1200gFtp/tokenMsg.cs new file mode 100644 index 0000000..9209657 --- /dev/null +++ b/1200gFtp/tokenMsg.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace _1200gFtp +{ + internal class tokenMsg + { + public string msg { get; set; } + public string code { get; set; } + public string data { get; set; } + } +} diff --git a/1200gFtp/云心电ECG数据解析服务端.csproj b/1200gFtp/云心电ECG数据解析服务端.csproj new file mode 100644 index 0000000..83d94c2 --- /dev/null +++ b/1200gFtp/云心电ECG数据解析服务端.csproj @@ -0,0 +1,138 @@ + + + + + Debug + AnyCPU + {09BE6454-1CEA-403F-81BE-5A7170FD5D7F} + WinExe + Properties + 云心电ECG数据解析服务端 + 云心电ECG数据解析服务端 + v4.8 + 512 + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + o13www.ixigua.com.ico + + + + False + bin\Debug\Aliyun.OSS.dll + + + ..\packages\Microsoft.Diagnostics.Tracing.EventSource.Redist.1.1.28\lib\net46\Microsoft.Diagnostics.Tracing.EventSource.dll + True + + + False + bin\Debug\Newtonsoft.Json.dll + + + ..\packages\RabbitMQ.Client.5.1.2\lib\net451\RabbitMQ.Client.dll + True + + + + + + + + + + + + + + + + + + + + + + + + + Form + + + Form1.cs + + + + + + + + + + + + + + + + + + + + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + \ No newline at end of file diff --git a/xml读取.txt b/xml读取.txt new file mode 100644 index 0000000..22ea407 --- /dev/null +++ b/xml读取.txt @@ -0,0 +1,139 @@ +调用: + ReadXMLByPath(@"C:\Users\PETER\Desktop\芯动心电网络管理系统\FTP数据\e30c180b-2512-4073-ae7a-d65be041f424.XML"); + + + + +string ReadXMLByPath(string path) + { + string caseName = ""; + string age = ""; + string sex = ""; + + 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; + 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]; + //检测当前节点的名称,节点的值是否与已知匹配 + 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")) + { + caseName = oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText; + } + if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.ToLower().Equals("sex")) + { + sex = oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText; + } + if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.ToLower().Equals("age")) + { + age = oCurrentNode.ChildNodes[n].ChildNodes[ii].InnerText; + } + if (oCurrentNode.ChildNodes[n].ChildNodes[ii].Name.ToLower().Equals("age")) + { + age = 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; + } + + + } + } + + + + + } + } + } + + + + + } + + } + catch { } + + return caseName + "," + sex + "," + age; + } \ No newline at end of file diff --git a/云心电ECG数据解析服务端.sln b/云心电ECG数据解析服务端.sln new file mode 100644 index 0000000..69d122d --- /dev/null +++ b/云心电ECG数据解析服务端.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.9.34723.18 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "云心电ECG数据解析服务端", "1200gFtp\云心电ECG数据解析服务端.csproj", "{09BE6454-1CEA-403F-81BE-5A7170FD5D7F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {09BE6454-1CEA-403F-81BE-5A7170FD5D7F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {09BE6454-1CEA-403F-81BE-5A7170FD5D7F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {09BE6454-1CEA-403F-81BE-5A7170FD5D7F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {09BE6454-1CEA-403F-81BE-5A7170FD5D7F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {FEA323F1-3B5C-4E60-BF47-2D7F6CBC4CDA} + EndGlobalSection +EndGlobal