311 lines
14 KiB
C#
311 lines
14 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.ComponentModel;
|
||
using System.Data;
|
||
using System.Drawing;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Windows.Forms;
|
||
using System.Drawing.Drawing2D;
|
||
using AIMSModel;
|
||
using AIMSBLL;
|
||
using AIMSExtension;
|
||
using DCSoftDotfuscate;
|
||
using DrawGraph;
|
||
using System.Reflection;
|
||
using Newtonsoft.Json;
|
||
using AIMS.OperationAanesthesia;
|
||
|
||
namespace AIMS.OperationAfter.UI
|
||
{
|
||
public partial class frmPhysiologyLargeScreen : Form
|
||
{
|
||
public frmPhysiologyLargeScreen()
|
||
{
|
||
InitializeComponent();
|
||
}
|
||
|
||
private void frmPhysiologyLargeScreen_Load(object sender, EventArgs e)
|
||
{
|
||
Initial();
|
||
}
|
||
/// <summary>
|
||
/// 初始化数据
|
||
/// </summary>
|
||
private void Initial()
|
||
{
|
||
List<OperationRoom> rooms = BOperationRoom.GetOperationRooms("IsValid=1 and Site='手术室'");
|
||
SetTabPages(rooms);
|
||
DataTable dt = SelectPatient.GetTodayDoOpePatientDataTable
|
||
(DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")));
|
||
FullUCControlData(dt);
|
||
timer1.Enabled = true;
|
||
timer1.Start();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据手术间数量设置有多少个TabPages,每个TabPages显示10个手术间
|
||
/// </summary>
|
||
private void SetTabPages(List<OperationRoom> list)
|
||
{
|
||
tabControl.TabPages.Clear();
|
||
if (list.Count > 0 && list.Count <= 10)
|
||
{
|
||
tabControl.TabPages.Add(" 1间—10间 ");
|
||
FullControlToTabPages(0, list.Skip(0).Take(10).ToList());
|
||
}
|
||
else if (list.Count > 10 && list.Count <= 20)
|
||
{
|
||
tabControl.TabPages.Add(" 1间—10间 ");
|
||
FullControlToTabPages(0, list.Skip(0).Take(10).ToList());
|
||
tabControl.TabPages.Add(" 11间—20间 ");
|
||
FullControlToTabPages(1, list.Skip(10).Take(10).ToList());
|
||
}
|
||
else if (list.Count > 20 && list.Count <= 30)
|
||
{
|
||
tabControl.TabPages.Add(" 1间—10间 ");
|
||
FullControlToTabPages(0, list.Skip(0).Take(10).ToList());
|
||
tabControl.TabPages.Add(" 11间—20间 ");
|
||
FullControlToTabPages(1, list.Skip(10).Take(10).ToList());
|
||
tabControl.TabPages.Add(" 21间—30间 ");
|
||
FullControlToTabPages(2, list.Skip(20).Take(10).ToList());
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 将信息卡填充到tabPages
|
||
/// </summary>
|
||
/// <param name="tabPagesIndex"></param>
|
||
/// <param name="roomlist"></param>
|
||
private void FullControlToTabPages(int tabPagesIndex, List<OperationRoom> roomlist)
|
||
{
|
||
int i = 0, j = 0;
|
||
foreach (OperationRoom room in roomlist)
|
||
{
|
||
AIMS.OremrUserControl.UCPatientPhysiology uc = new AIMS.OremrUserControl.UCPatientPhysiology();
|
||
uc.OperationRoom = room.Name;
|
||
uc.OperationRoomIp = room.Ip;
|
||
uc.lblRoom.Tag = room.Id;
|
||
uc.panel2.Visible = false;
|
||
uc.Location = new Point(j * (this.Width / 5) + 5, i * (uc.Height + 20) + 5);
|
||
tabControl.TabPages[tabPagesIndex].Controls.Add(uc);
|
||
j++;
|
||
if (j == 5)
|
||
{
|
||
i++;
|
||
j = 0;
|
||
}
|
||
}
|
||
}
|
||
|
||
private void PlRefresh_Click(object sender, EventArgs e)
|
||
{
|
||
System.Windows.Forms.Panel plRefresh = sender as System.Windows.Forms.Panel;
|
||
OperationRecord apply = BOperationRecord.SelectSingle(Convert.ToInt32(plRefresh.Tag));
|
||
frmAanesthesiaRecord frmAnasRecord = new frmAanesthesiaRecord();
|
||
frmAnasRecord.PatientId = apply.PatientId.Value;
|
||
frmAnasRecord.ApplyId = apply.OperationApplyId.Value;
|
||
frmAnasRecord.State = AIMSExtension.EditState.BROWSE;
|
||
frmAnasRecord.Show();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 将数据填充到信息卡
|
||
/// </summary>
|
||
/// <param name="dt"></param>
|
||
private void FullUCControlData(DataTable dt)
|
||
{
|
||
for (int i = 0; i < tabControl.TabPages.Count; i++)
|
||
{
|
||
foreach (Control ctl in tabControl.TabPages[i].Controls)
|
||
{
|
||
if (ctl is AIMS.OremrUserControl.UCPatientPhysiology)
|
||
{
|
||
AIMS.OremrUserControl.UCPatientPhysiology uc = ctl as AIMS.OremrUserControl.UCPatientPhysiology;
|
||
foreach (DataRow dr in dt.Rows)
|
||
{
|
||
if (dr["OperationRoomId"].ToString() == uc.lblRoom.Tag.ToString())
|
||
{
|
||
uc.panel2.Visible = true;
|
||
uc.Tag = dr["Id"].ToString();
|
||
uc.plRefresh.Tag = dr["Id"].ToString();
|
||
uc.PatientName = dr["PatientName"].ToString()+" "+ dr["Sex"].ToString()+" "+ dr["Age"].ToString();
|
||
uc.OperationName = dr["ApplyOperationInfoName"].ToString();
|
||
uc.AnaesthesiaMethod = dr["AnaesthesiaMethodName"].ToString();
|
||
uc.OperationDoctor = dr["OperationDoctor"].ToString();
|
||
uc.AnaesthesiaDoctor = dr["AnesthesiaDoctor"].ToString();
|
||
uc.OperationTime = dr["InRoomTime"].ToString();
|
||
uc.plRefresh.Click -= PlRefresh_Click;
|
||
uc.plRefresh.Click += PlRefresh_Click;
|
||
FullPatientPhysiology(uc, Convert.ToInt32(uc.Tag));
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 刷新控件及生命体征数据
|
||
/// </summary>
|
||
private void RefreshPatientPhysiology()
|
||
{
|
||
DataTable dt = SelectPatient.GetTodayDoOpePatientDataTable
|
||
(DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")));
|
||
for (int i = 0; i < tabControl.TabPages.Count; i++)
|
||
{
|
||
foreach (Control ctl in tabControl.TabPages[i].Controls)
|
||
{
|
||
if (ctl is AIMS.OremrUserControl.UCPatientPhysiology)
|
||
{
|
||
bool key = false;
|
||
AIMS.OremrUserControl.UCPatientPhysiology uc = ctl as AIMS.OremrUserControl.UCPatientPhysiology;
|
||
if (uc.Tag == null) continue;
|
||
foreach (DataRow dr in dt.Rows)
|
||
{
|
||
if (uc.lblRoom.Tag.ToString() == dr["OperationRoomId"].ToString())
|
||
{
|
||
key = true;
|
||
uc.panel2.Visible = true;
|
||
uc.Tag = dr["Id"].ToString();
|
||
uc.plRefresh.Tag = dr["Id"].ToString();
|
||
uc.PatientName = dr["PatientName"].ToString() + " " + dr["Sex"].ToString() + " " + dr["Age"].ToString();
|
||
uc.OperationName = dr["ApplyOperationInfoName"].ToString();
|
||
uc.AnaesthesiaMethod = dr["AnaesthesiaMethodName"].ToString();
|
||
uc.OperationDoctor = dr["OperationDoctor"].ToString();
|
||
uc.AnaesthesiaDoctor = dr["AnesthesiaDoctor"].ToString();
|
||
uc.OperationTime = dr["InRoomTime"].ToString();
|
||
uc.plRefresh.Click -= PlRefresh_Click;
|
||
uc.plRefresh.Click += PlRefresh_Click;
|
||
//刷新生命体征数据
|
||
FullPatientPhysiology(uc, Convert.ToInt32(uc.Tag));
|
||
break;
|
||
}
|
||
}
|
||
if (!key)
|
||
{
|
||
uc.panel2.Visible = false;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 为控件填充生命体征数据
|
||
/// </summary>
|
||
/// <param name="uc">控件</param>
|
||
/// <param name="operationRecordId">手术编号</param>
|
||
private void FullPatientPhysiology(AIMS.OremrUserControl.UCPatientPhysiology uc, int operationRecordId)
|
||
{
|
||
List<DeviceCacheData> lists = DeviceCacheData.Select(" IPAddress='" + uc.OperationRoomIp + "' and UpdateTime>='" + DateTime.Now.AddSeconds(-300) + "'");
|
||
string hr = string.Empty;
|
||
string spo2 = string.Empty;
|
||
string br = string.Empty;
|
||
string pr = string.Empty;
|
||
string etco2 = string.Empty;
|
||
string dia = string.Empty;
|
||
string sys = string.Empty;
|
||
if (lists != null && lists.Count > 0)
|
||
{
|
||
DeviceCacheData deviceCacheData = lists[0];
|
||
NowPhysioData nowPhysioData = JsonConvert.DeserializeObject<NowPhysioData>(deviceCacheData.JsonData);
|
||
|
||
if (nowPhysioData.HR != null && nowPhysioData.HR.ToString() != string.Empty && nowPhysioData.HR.ToString() != "NaN" && nowPhysioData.HR.ToString() != "NULL")
|
||
{
|
||
double value = Double.Parse(nowPhysioData.HR.ToString());
|
||
hr = value <= 0 ? "--" : value.ToString();
|
||
}
|
||
if (nowPhysioData.Resp != null && nowPhysioData.Resp.ToString() != string.Empty && nowPhysioData.Resp.ToString() != "NaN" && nowPhysioData.Resp.ToString() != "NULL")
|
||
{
|
||
double value = Double.Parse(nowPhysioData.Resp.ToString());
|
||
}
|
||
if (nowPhysioData.SPO2 != null && nowPhysioData.SPO2.ToString() != string.Empty && nowPhysioData.SPO2.ToString() != "NaN" && nowPhysioData.SPO2.ToString() != "NULL")
|
||
{
|
||
double value = Double.Parse(nowPhysioData.SPO2.ToString());
|
||
spo2 = value <= 0 ? "--" : value.ToString();
|
||
}
|
||
if (nowPhysioData.PR != null && nowPhysioData.PR.ToString() != string.Empty && nowPhysioData.PR.ToString() != "NaN" && nowPhysioData.PR.ToString() != "NULL")
|
||
{
|
||
double value = Double.Parse(nowPhysioData.PR.ToString());
|
||
pr = value <= 0 ? "--" : value.ToString();
|
||
}
|
||
if (nowPhysioData.Etco2 != null && nowPhysioData.Etco2.ToString() != string.Empty && nowPhysioData.Etco2.ToString() != "NaN" && nowPhysioData.Etco2.ToString() != "NULL")
|
||
{
|
||
double value = Double.Parse(nowPhysioData.Etco2.ToString());
|
||
etco2 = value <= 0 ? "" : value.ToString();
|
||
}
|
||
if (nowPhysioData.Dia != null && nowPhysioData.Dia.ToString() != string.Empty && nowPhysioData.Dia.ToString() != "NaN" && nowPhysioData.Dia.ToString() != "NULL")
|
||
{
|
||
double value = Double.Parse(nowPhysioData.Dia.ToString());
|
||
dia = value <= 0 ? "" : value.ToString();
|
||
}
|
||
if (nowPhysioData.Sys != null && nowPhysioData.Sys.ToString() != string.Empty && nowPhysioData.Sys.ToString() != "NaN" && nowPhysioData.Sys.ToString() != "NULL")
|
||
{
|
||
double value = Double.Parse(nowPhysioData.Sys.ToString());
|
||
sys = value <= 0 ? "" : value.ToString();
|
||
}
|
||
if (nowPhysioData.Dia_H != null && nowPhysioData.Dia_H.ToString() != string.Empty && nowPhysioData.Dia_H.ToString() != "NaN" && nowPhysioData.Dia_H.ToString() != "NULL")
|
||
{
|
||
double value = Double.Parse(nowPhysioData.Dia_H.ToString());
|
||
dia = value <= 0 ? "" : value.ToString();
|
||
}
|
||
if (nowPhysioData.Sys_H != null && nowPhysioData.Sys_H.ToString() != string.Empty && nowPhysioData.Sys_H.ToString() != "NaN" && nowPhysioData.Sys_H.ToString() != "NULL")
|
||
{
|
||
double value = Double.Parse(nowPhysioData.Sys_H.ToString());
|
||
sys = value <= 0 ? "" : value.ToString();
|
||
}
|
||
}
|
||
if (hr.Length > 0)
|
||
{
|
||
uc.HR = hr;
|
||
}
|
||
else
|
||
{
|
||
uc.HR = "--";
|
||
}
|
||
if (spo2.Length > 0)
|
||
{
|
||
uc.SpO2 = spo2;
|
||
}
|
||
else
|
||
{
|
||
uc.SpO2 = "--";
|
||
}
|
||
if (br.Length > 0)
|
||
{
|
||
uc.BR = br;
|
||
}
|
||
else
|
||
{
|
||
uc.BR = "--";
|
||
}
|
||
if (etco2.Length > 0)
|
||
{
|
||
uc.T = etco2;
|
||
}
|
||
else
|
||
{
|
||
uc.T = "--";
|
||
}
|
||
if (dia.Length > 0 && sys.Length > 0)
|
||
{
|
||
uc.SYS = dia + "/" + sys;
|
||
}
|
||
else
|
||
{
|
||
uc.SYS = "---/--";
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 更新生命体征
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void timer1_Tick(object sender, EventArgs e)
|
||
{
|
||
RefreshPatientPhysiology();
|
||
}
|
||
|
||
}
|
||
}
|