From 8e7a6b281fcc77792c74fbc1a4347a57ff22f1e0 Mon Sep 17 00:00:00 2001 From: lxd <1004405501@qq.com> Date: Wed, 2 Apr 2025 23:01:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=80=E4=BA=9BBUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.config | 28 ++-- ExamRecord.cs | 2 + InfoForm.Designer.cs | 24 ++-- InfoForm.cs | 1 + RootObject.cs | 29 +++++ video.Designer.cs | 40 +++++- video.cs | 301 +++++++++++++++++++++++++++++++++---------- videoGather.csproj | 2 + 8 files changed, 333 insertions(+), 94 deletions(-) create mode 100644 RootObject.cs diff --git a/App.config b/App.config index 563ead2..7bdf230 100644 --- a/App.config +++ b/App.config @@ -6,8 +6,8 @@ - - + + @@ -18,26 +18,34 @@ - - + + - + + + + + + - - + + + + + - - - + + + diff --git a/ExamRecord.cs b/ExamRecord.cs index 5475f03..605eab0 100644 --- a/ExamRecord.cs +++ b/ExamRecord.cs @@ -23,5 +23,7 @@ namespace videoGather public string orgId { get; set; } public string orgName { get; set; } public string regId { get; set; } + + public string sfz { get; set; } } } diff --git a/InfoForm.Designer.cs b/InfoForm.Designer.cs index 7d786cb..58c1759 100644 --- a/InfoForm.Designer.cs +++ b/InfoForm.Designer.cs @@ -46,13 +46,13 @@ this.label8 = new System.Windows.Forms.Label(); this.datekaifangsj = new System.Windows.Forms.DateTimePicker(); this.label9 = new System.Windows.Forms.Label(); - this.textexamItemName = new System.Windows.Forms.TextBox(); this.textexamItemcode = new System.Windows.Forms.TextBox(); this.label10 = new System.Windows.Forms.Label(); this.button2 = new System.Windows.Forms.Button(); this.button3 = new System.Windows.Forms.Button(); this.button4 = new System.Windows.Forms.Button(); this.button5 = new System.Windows.Forms.Button(); + this.textexamItemName = new System.Windows.Forms.TextBox(); this.SuspendLayout(); // // button1 @@ -139,6 +139,7 @@ // this.label4.AutoSize = true; this.label4.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label4.ForeColor = System.Drawing.Color.Red; this.label4.Location = new System.Drawing.Point(535, 86); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(62, 21); @@ -237,15 +238,6 @@ this.label9.TabIndex = 18; this.label9.Text = "检查名称:"; // - // textexamItemName - // - this.textexamItemName.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.textexamItemName.ForeColor = System.Drawing.SystemColors.WindowText; - this.textexamItemName.Location = new System.Drawing.Point(603, 139); - this.textexamItemName.Name = "textexamItemName"; - this.textexamItemName.Size = new System.Drawing.Size(169, 29); - this.textexamItemName.TabIndex = 19; - // // textexamItemcode // this.textexamItemcode.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); @@ -317,18 +309,26 @@ this.button5.UseVisualStyleBackColor = true; this.button5.Click += new System.EventHandler(this.button5_Click); // + // textexamItemName + // + this.textexamItemName.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.textexamItemName.Location = new System.Drawing.Point(603, 139); + this.textexamItemName.Name = "textexamItemName"; + this.textexamItemName.Size = new System.Drawing.Size(169, 29); + this.textexamItemName.TabIndex = 26; + // // InfoForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(800, 680); + this.Controls.Add(this.textexamItemName); this.Controls.Add(this.button5); this.Controls.Add(this.button4); this.Controls.Add(this.button3); this.Controls.Add(this.button2); this.Controls.Add(this.textexamItemcode); this.Controls.Add(this.label10); - this.Controls.Add(this.textexamItemName); this.Controls.Add(this.label9); this.Controls.Add(this.datekaifangsj); this.Controls.Add(this.label8); @@ -377,12 +377,12 @@ private System.Windows.Forms.Label label8; private System.Windows.Forms.DateTimePicker datekaifangsj; private System.Windows.Forms.Label label9; - private System.Windows.Forms.TextBox textexamItemName; private System.Windows.Forms.TextBox textexamItemcode; private System.Windows.Forms.Label label10; private System.Windows.Forms.Button button2; private System.Windows.Forms.Button button3; private System.Windows.Forms.Button button4; private System.Windows.Forms.Button button5; + private System.Windows.Forms.TextBox textexamItemName; } } \ No newline at end of file diff --git a/InfoForm.cs b/InfoForm.cs index 502aedc..a63baa5 100644 --- a/InfoForm.cs +++ b/InfoForm.cs @@ -92,6 +92,7 @@ namespace videoGather if (string.IsNullOrEmpty(textjianchaid.Text.Trim()) || string.IsNullOrEmpty(txt_jianchabh.Text.Trim()) || string.IsNullOrEmpty(txtname.Text.Trim()) || + string.IsNullOrEmpty(textsfz.Text.Trim()) || string.IsNullOrEmpty(textexamItemName.Text.Trim()) || string.IsNullOrEmpty(textexamItemcode.Text.Trim())) { diff --git a/RootObject.cs b/RootObject.cs new file mode 100644 index 0000000..51939f7 --- /dev/null +++ b/RootObject.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace videoGather +{ + internal class RootObject + { + public int code { get; set; } + public Data data { get; set; } + public string msg { get; set; } + public class Data + { + public string jianchaid { get; set; } + public string name { get; set; } + public string jianchabh { get; set; } + public string birthdate { get; set; } + public string age { get; set; } + public string sex { get; set; } + public object yiyuanname { get; set; } + public object yiyuancode { get; set; } + public string kaifangsj { get; set; } + public string examItemName { get; set; } + public string examItemCode { get; set; } + } + } +} diff --git a/video.Designer.cs b/video.Designer.cs index ec2a460..fd9c122 100644 --- a/video.Designer.cs +++ b/video.Designer.cs @@ -34,6 +34,8 @@ namespace videoGather this.btn_Capture = new System.Windows.Forms.Button(); this.btn_Close = new System.Windows.Forms.Button(); this.gb_ButtonBox = new System.Windows.Forms.GroupBox(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.label7 = new System.Windows.Forms.Label(); this.button6 = new System.Windows.Forms.Button(); this.label3 = new System.Windows.Forms.Label(); this.btn_Connect = new System.Windows.Forms.Button(); @@ -116,6 +118,8 @@ namespace videoGather // // gb_ButtonBox // + this.gb_ButtonBox.Controls.Add(this.textBox1); + this.gb_ButtonBox.Controls.Add(this.label7); this.gb_ButtonBox.Controls.Add(this.button6); this.gb_ButtonBox.Controls.Add(this.label3); this.gb_ButtonBox.Controls.Add(this.btn_Connect); @@ -133,16 +137,34 @@ namespace videoGather this.gb_ButtonBox.Controls.Add(this.cb_CameraSelect); this.gb_ButtonBox.Dock = System.Windows.Forms.DockStyle.Top; this.gb_ButtonBox.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.gb_ButtonBox.Location = new System.Drawing.Point(3, 157); + this.gb_ButtonBox.Location = new System.Drawing.Point(3, 170); this.gb_ButtonBox.Margin = new System.Windows.Forms.Padding(2); this.gb_ButtonBox.Name = "gb_ButtonBox"; this.gb_ButtonBox.Padding = new System.Windows.Forms.Padding(2); - this.gb_ButtonBox.Size = new System.Drawing.Size(556, 204); + this.gb_ButtonBox.Size = new System.Drawing.Size(556, 235); this.gb_ButtonBox.TabIndex = 16; this.gb_ButtonBox.TabStop = false; this.gb_ButtonBox.Text = "功能区"; this.gb_ButtonBox.Enter += new System.EventHandler(this.gb_ButtonBox_Enter); // + // textBox1 + // + this.textBox1.Location = new System.Drawing.Point(123, 175); + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(183, 26); + this.textBox1.TabIndex = 31; + this.textBox1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBox1_KeyDown); + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(11, 180); + this.label7.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(119, 16); + this.label7.TabIndex = 32; + this.label7.Text = "检查编号扫码:"; + // // button6 // this.button6.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); @@ -161,7 +183,7 @@ namespace videoGather this.label3.AutoSize = true; this.label3.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label3.ForeColor = System.Drawing.Color.Red; - this.label3.Location = new System.Drawing.Point(2, 182); + this.label3.Location = new System.Drawing.Point(2, 213); this.label3.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(109, 16); @@ -279,6 +301,7 @@ namespace videoGather // // groupBox2 // + this.groupBox2.AutoSize = true; this.groupBox2.Controls.Add(this.button5); this.groupBox2.Controls.Add(this.txt_h); this.groupBox2.Controls.Add(this.lab_h); @@ -297,7 +320,7 @@ namespace videoGather this.groupBox2.Font = new System.Drawing.Font("宋体", 12F); this.groupBox2.Location = new System.Drawing.Point(3, 17); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(556, 140); + this.groupBox2.Size = new System.Drawing.Size(556, 153); this.groupBox2.TabIndex = 18; this.groupBox2.TabStop = false; this.groupBox2.Text = "病理"; @@ -452,11 +475,11 @@ namespace videoGather this.groupBox1.Controls.Add(this.dGVPatient); this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill; this.groupBox1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.groupBox1.Location = new System.Drawing.Point(3, 361); + this.groupBox1.Location = new System.Drawing.Point(3, 405); this.groupBox1.Margin = new System.Windows.Forms.Padding(2); this.groupBox1.Name = "groupBox1"; this.groupBox1.Padding = new System.Windows.Forms.Padding(2); - this.groupBox1.Size = new System.Drawing.Size(556, 630); + this.groupBox1.Size = new System.Drawing.Size(556, 586); this.groupBox1.TabIndex = 19; this.groupBox1.TabStop = false; this.groupBox1.Text = "患者信息"; @@ -477,7 +500,7 @@ namespace videoGather this.dGVPatient.ReadOnly = true; this.dGVPatient.RowTemplate.Height = 23; this.dGVPatient.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.dGVPatient.Size = new System.Drawing.Size(552, 607); + this.dGVPatient.Size = new System.Drawing.Size(552, 563); this.dGVPatient.TabIndex = 0; this.dGVPatient.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dGVPatient_CellDoubleClick); // @@ -577,6 +600,7 @@ namespace videoGather this.groupBox2.ResumeLayout(false); this.groupBox2.PerformLayout(); this.groupBox3.ResumeLayout(false); + this.groupBox3.PerformLayout(); this.groupBox1.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.dGVPatient)).EndInit(); this.gb_CameraPanel.ResumeLayout(false); @@ -628,6 +652,8 @@ namespace videoGather private System.Windows.Forms.Label label3; private System.Windows.Forms.Button button5; private System.Windows.Forms.Button button6; + private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.Label label7; } } diff --git a/video.cs b/video.cs index 56ebd5b..a13e589 100644 --- a/video.cs +++ b/video.cs @@ -24,8 +24,10 @@ using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Controls; +using System.Windows.Documents; using System.Windows.Forms; using System.Windows.Shapes; +using System.Xml.Linq; using static AForge.Imaging.Filters.HitAndMiss; using static System.Windows.Forms.VisualStyles.VisualStyleElement; @@ -88,6 +90,11 @@ namespace videoGather /// private string _url = string.Empty; + /// + /// 是否读取HIS信息 + /// + private string _ishisinfo = string.Empty; + private string _path = string.Empty; /// /// 当前类型 @@ -114,6 +121,14 @@ namespace videoGather /// 文件上传模式 /// private string _model = string.Empty; + /// + /// 体检患者信息地址 + /// + private string _InspectUrl = string.Empty; + /// + /// 是否开启体检编码扫码 + /// + private string _isInspect = string.Empty; //超声存放文件访问地址 ArrayList imagearray = new ArrayList(); /// @@ -140,6 +155,8 @@ namespace videoGather InitCamera(); InitCameraSelect(); //读取配置信息 + _isInspect = ConfigurationManager.AppSettings["isInspect"]; + _InspectUrl = ConfigurationManager.AppSettings["InspectUrl"]; _url = ConfigurationManager.AppSettings["URL"]; _path = ConfigurationManager.AppSettings["path"]; _type = ConfigurationManager.AppSettings["type"]; @@ -148,6 +165,7 @@ namespace videoGather _blprefix = ConfigurationManager.AppSettings["blprefix"]; _xywh = ConfigurationManager.AppSettings["xywh"]; _model = ConfigurationManager.AppSettings["model"]; + _ishisinfo = ConfigurationManager.AppSettings["ishisinfo"]; if (_type == "1") { @@ -170,7 +188,16 @@ namespace videoGather txt_h.Text = _xywh.Split(',')[3]; } this.btn_Capture.Enabled = false; - + if (_isInspect == "1") + { + label7.Visible = true; + textBox1.Visible = true; + } + else + { + label7.Visible = false; + textBox1.Visible = false; + } //秒表 timer_count = new System.Timers.Timer(); //实例化Timer类,设置间隔时间为1000毫秒; @@ -179,8 +206,52 @@ namespace videoGather timer_count.Interval = 1000; HookStart(); btn_Connect_Click(null, null); - GetHisInfo(); + if (_ishisinfo == "0") + { + button1.Visible = true; + GetHisInfo(); + } + else + { + button1.Visible = false; + } label4.Focus(); + // 添加对窗口大小改变事件的订阅 + this.Resize += new EventHandler(Form1_Resize); + } + + private void Form1_Resize(object sender, EventArgs e) + { + //// 检查视频捕获是否已初始化 + //if (videoCapture != null && videoCapture.IsRunning) + //{ + // // 停止并重新启动视频捕获,确保视频帧能够正确显示 + // videoCapture.SignalToStop(); + // videoCapture.WaitForStop(); + // videoCapture.Start(); + //} + + // 检查视频捕获是否已初始化 + if (videoCapture != null) + { + if (this.WindowState == FormWindowState.Minimized) + { + // 窗口最小化时停止视频捕获 + if (videoCapture.IsRunning) + { + videoCapture.SignalToStop(); + videoCapture.WaitForStop(); + } + } + else if (this.WindowState == FormWindowState.Maximized || this.WindowState == FormWindowState.Normal) + { + // 窗口最大化或恢复正常大小时重新启动视频捕获 + if (!videoCapture.IsRunning) + { + videoCapture.Start(); + } + } + } } /// /// 窗口关闭时 @@ -293,20 +364,37 @@ namespace videoGather /// private void btn_Capture_Click(object sender, EventArgs e) { - if (videoCapture == null) + try { - MessageBox.Show("设备未连接"); - return; + if (videoCapture == null) + { + MessageBox.Show("设备未连接"); + return; + } + imgMap = this.vsp_Panel.GetCurrentVideoFrame(); + if (imgMap == null) + { + return; + } + var saveName = $"{filePath}{$"{DateTime.Now.ToString("yyyyMMddhhmmssffff")}"}.jpg"; + imgMap.Save(saveName); + imagearray.Add(saveName); + // 使用 Invoke 方法确保在UI线程上更新标签的文本 + if (label1.InvokeRequired) + { + label1.Invoke(new Action(() => label1.Text = imagearray.Count.ToString())); + } + else + { + label1.Text = imagearray.Count.ToString(); + } + label1.Refresh(); } - imgMap = this.vsp_Panel.GetCurrentVideoFrame(); - if (imgMap == null) + catch (Exception ex) { - return; + MessageBox.Show(ex.Message+ex.StackTrace); } - var saveName = $"{filePath}{$"{DateTime.Now.ToString("yyyyMMddhhmmssffff")}"}.jpg"; - imgMap.Save(saveName); - imagearray.Add(saveName); - label1.Text = imagearray.Count.ToString(); + } /// /// 保存事件 @@ -525,6 +613,8 @@ namespace videoGather string result = ""; try { + // 忽略证书验证 + ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true; HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); req.Method = "POST"; req.ContentType = "application/json"; @@ -566,6 +656,8 @@ namespace videoGather string result = ""; try { + // 忽略证书验证 + ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true; HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); req.Method = "POST"; req.ContentType = "application/json"; @@ -605,6 +697,8 @@ namespace videoGather { try { + // 忽略证书验证 + ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true; HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); req.Method = "GET"; req.Timeout = 30000; @@ -654,6 +748,8 @@ namespace videoGather { try { + // 忽略证书验证 + ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true; HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); req.Method = "GET"; req.Timeout = 30000; @@ -698,51 +794,59 @@ namespace videoGather /// public void GetHisInfo() { - //存放绑定界面的患者数据 一个患者有多个检查 按照检查拆分 一个检查一条数据 - List hisInfos = new List(); - //获取福乐云HIS接口的token - string hisToken = getHisToken(ConfigurationManager.AppSettings["hisGetTokenUrl"], ConfigurationManager.AppSettings["hisAppkey"], ConfigurationManager.AppSettings["appsecret"]); - - //获取当天的患者信息 - FlyHisEcgDataModel FHEDM = GetHisEcgData(ConfigurationManager.AppSettings["hisGetDataUrl"], ConfigurationManager.AppSettings["inHisCode"], DateTime.Now.ToString("yyyy-MM-dd"), hisToken);// - if (FHEDM != null) + try { - foreach (patientInfo item in FHEDM.rows) - { - foreach (projectsInfo projectsInfo in item.projects) - { - if (projectsInfo.category == "US") - { - HisInfo info = new HisInfo(); - info.jianchaid = item.jianchaid; - info.name = item.name; - info.jianchabh = item.jianchabh; - info.sfz = item.sfz; - info.birthdate = item.birthdate; - info.age = item.age; - info.sex = item.sex; - info.yiyuanname = item.yiyuanname; - info.yiyuanid = item.yiyuanid; - info.yiyuancode = item.yiyuancode; - info.kaifangsj = item.kaifangsj; - info.departmentCode = item.departmentCode; - info.departmentName = item.departmentName; - info.resDoctorName = item.resDoctorName; - info.resDoctorCode = item.resDoctorCode; - info.nation = item.nation; - info.patientCode = item.patientCode; - info.visitType = item.visitType; - info.jianchamingcheng = projectsInfo.jianchamingcheng; - info.nhbm = projectsInfo.nhbm; - info.category = projectsInfo.category; - hisInfos.Add(info); - } + //存放绑定界面的患者数据 一个患者有多个检查 按照检查拆分 一个检查一条数据 + List hisInfos = new List(); + //获取福乐云HIS接口的token + string hisToken = getHisToken(ConfigurationManager.AppSettings["hisGetTokenUrl"], ConfigurationManager.AppSettings["hisAppkey"], ConfigurationManager.AppSettings["appsecret"]); + //获取当天的患者信息 + FlyHisEcgDataModel FHEDM = GetHisEcgData(ConfigurationManager.AppSettings["hisGetDataUrl"], ConfigurationManager.AppSettings["inHisCode"], DateTime.Now.ToString("yyyy-MM-dd"), hisToken);// + if (FHEDM != null) + { + foreach (patientInfo item in FHEDM.rows) + { + foreach (projectsInfo projectsInfo in item.projects) + { + if (projectsInfo.category == "US") + { + HisInfo info = new HisInfo(); + info.jianchaid = item.jianchaid; + info.name = item.name; + info.jianchabh = item.jianchabh; + info.sfz = item.sfz; + info.birthdate = item.birthdate; + info.age = item.age; + info.sex = item.sex; + info.yiyuanname = item.yiyuanname; + info.yiyuanid = item.yiyuanid; + info.yiyuancode = item.yiyuancode; + info.kaifangsj = item.kaifangsj; + info.departmentCode = item.departmentCode; + info.departmentName = item.departmentName; + info.resDoctorName = item.resDoctorName; + info.resDoctorCode = item.resDoctorCode; + info.nation = item.nation; + info.patientCode = item.patientCode; + info.visitType = item.visitType; + info.jianchamingcheng = projectsInfo.jianchamingcheng; + info.nhbm = projectsInfo.nhbm; + info.category = projectsInfo.category; + hisInfos.Add(info); + } + + } } + dGVPatient.DataSource = hisInfos; + rowhisinfo = null; } - dGVPatient.DataSource = hisInfos; - rowhisinfo = null; } + catch (Exception e) + { + MessageBox.Show("获取接口数据失败"); + } + } @@ -791,6 +895,8 @@ namespace videoGather /// public string PostFile3(string url, Dictionary items) { + // 忽略证书验证 + ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true; string boundary = DateTime.Now.Ticks.ToString("x"); HttpWebRequest request = null; //如果是发送HTTPS请求               @@ -1221,11 +1327,11 @@ namespace videoGather { string keyString = key.ToString(); // MessageBox.Show(keyString); - - if (keyString == strkey) - { - SaveImageDcm(); - } + //不是病理的 暂时不需要先注释了 + //if (keyString == strkey) + //{ + // SaveImageDcm(); + //} switch (keyString) { case "F6": @@ -1513,10 +1619,11 @@ namespace videoGather List Record = new List(); ExamRecord examRecord = new ExamRecord(); - examRecord.examId = rowhisinfo.jianchabh + "_" + GetRandomNumber(1, 100); + examRecord.examId = _isInspect == "1" ? rowhisinfo.jianchabh : rowhisinfo.jianchabh + "_" + GetRandomNumber(1, 100); + examRecord.sfz = rowhisinfo.sfz; examRecord.pname = rowhisinfo.name; examRecord.gender = rowhisinfo.sex; - examRecord.birthday = GetTimestampFromBirthdate(rowhisinfo.birthdate).ToString(); + examRecord.birthday = GetTimestampFromBirthdate(rowhisinfo.birthdate).ToString(); examRecord.deviceType = "US";//rowhisinfo.category examRecord.deviceName = "彩超"; examRecord.seDc = "1/1"; @@ -1578,7 +1685,7 @@ namespace videoGather // 将指定的出生日期转换为Unix时间戳(毫秒) public static long GetTimestampFromBirthdate(string birthdate) { - + // 尝试解析日期字符串 DateTime birthDateTime; if (DateTime.TryParseExact(birthdate, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out birthDateTime)) @@ -1597,17 +1704,17 @@ namespace videoGather } public static long GetTimestampFromdate(string birthdate) - { - + { + // 尝试解析日期字符串 DateTime birthDateTime; if (DateTime.TryParseExact(birthdate, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.None, out birthDateTime)) { - + // 将本地时间转换为UTC时间 DateTime birthDateTimeUtc = birthDateTime.ToUniversalTime(); // 计算时间戳 - return (long)birthDateTimeUtc.Subtract(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds; + return (long)birthDateTimeUtc.Subtract(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds; } else { @@ -1723,12 +1830,76 @@ namespace videoGather if (infoForm.ShowDialog() == DialogResult.OK) { //先赋空再绑定 - dGVPatient.DataSource=null; + dGVPatient.DataSource = null; hisInfos.Add(infoForm.info); dGVPatient.DataSource = hisInfos; rowhisinfo = null; } } + + private void textBox1_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + try + { + if (string.IsNullOrEmpty(textBox1.Text.Trim())) + { + MessageBox.Show("请输入体检编号"); + textBox1.Text = ""; + return; + } + string result = Get(_InspectUrl + "/admin-api/inspect/patient/getUSPatientInfo?medicalSn=" + textBox1.Text.Trim() + ""); + if (!string.IsNullOrEmpty(result)) + { + RootObject msgInfo = JsonConvert.DeserializeObject(result); + if (msgInfo != null) + { + if (msgInfo.data != null) + { + HisInfo info = new HisInfo(); + info.jianchaid = msgInfo.data.jianchaid; + info.name = msgInfo.data.name; + info.jianchabh = msgInfo.data.jianchabh; + info.birthdate = msgInfo.data.birthdate; + info.age = string.IsNullOrEmpty(msgInfo.data.age) ? 0 : int.Parse(msgInfo.data.age); + info.sex = msgInfo.data.sex; + info.yiyuanname = ConfigurationManager.AppSettings["yymc"]; + info.yiyuancode = ConfigurationManager.AppSettings["yycode"]; + info.kaifangsj = msgInfo.data.kaifangsj; + info.jianchamingcheng = msgInfo.data.examItemName; + info.nhbm = msgInfo.data.examItemCode; + + //先赋空再绑定 + dGVPatient.DataSource = null; + hisInfos.Add(info); + dGVPatient.DataSource = hisInfos; + textBox1.Text = ""; + rowhisinfo = null; + } + else + { + MessageBox.Show("未找到该患者信息"); + textBox1.Text = ""; + } + + } + } + else + { + MessageBox.Show("未找到该患者信息"); + textBox1.Text = ""; + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + textBox1.Text = ""; + return; + + } + } + } } } diff --git a/videoGather.csproj b/videoGather.csproj index d3673a3..b0081ab 100644 --- a/videoGather.csproj +++ b/videoGather.csproj @@ -46,6 +46,7 @@ 7.3 prompt true + true bin\x86\Release\ @@ -126,6 +127,7 @@ ProcessForm.cs +