1030 lines
48 KiB
C#
1030 lines
48 KiB
C#
using DevExpress.XtraEditors;
|
||
using DevExpress.XtraEditors.Controls;
|
||
using HL_FristAidPlatform_Apoplexy.Properties;
|
||
using HL_FristAidPlatform_DTO;
|
||
using HL_FristAidPlatform_MultiSystemPublic;
|
||
using HL_FristAidPlatform_Public;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Data;
|
||
using System.Drawing;
|
||
using System.Windows.Forms;
|
||
|
||
namespace HL_FristAidPlatform_Apoplexy
|
||
{
|
||
/// <summary>
|
||
/// 时间轴
|
||
/// </summary>
|
||
public partial class Form_TimeAxis : XtraForm
|
||
{
|
||
#region 变量
|
||
|
||
/// <summary>
|
||
/// 当前病人编号
|
||
/// </summary>
|
||
public string Cur_PatientGuid;
|
||
|
||
/// <summary>
|
||
/// 当前病人时间节点记录源
|
||
/// </summary>
|
||
private DataTable Cur_PatientDT = new DataTable();
|
||
|
||
#endregion 变量
|
||
|
||
/// <summary>
|
||
/// 抢救时间轴
|
||
/// </summary>
|
||
/// <param name="_patientGuid">当前病人编号(GUID)</param>
|
||
public Form_TimeAxis(string _patientGuid)
|
||
{
|
||
InitializeComponent();
|
||
Cur_PatientGuid = _patientGuid;
|
||
}
|
||
|
||
#region 事件
|
||
|
||
/// <summary>
|
||
/// 窗体加载
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void Form_TimeAxis_Load(object sender, EventArgs e)
|
||
{
|
||
BindData();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 绑定数据
|
||
/// </summary>
|
||
private void BindData()
|
||
{
|
||
try
|
||
{
|
||
string Url = string.Format("api/service/T_Service_Apoplexy_PatientsTimeAxis/GetPatientDetailTime?PatientGuid={0}&isDisplayTimeAxis=0", Cur_PatientGuid);
|
||
Cur_PatientDT = DBHelpClass.GetJsonText(Url);
|
||
overwritePanelLoad(Cur_PatientDT);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
PublicClass.WriteErrorLog(this.Text, "绑定数据:\r\n" + ex);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 时间轴点击事件
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void SimpleButton_Click(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
#region 时间轴点击事件
|
||
|
||
//时间节点编号
|
||
long id = PublicClass.ToInt64(((Control)sender).Tag, 0);
|
||
string time = "";
|
||
|
||
string Url = string.Format("api/service/T_Service_Apoplexy_PatientsTimeAxis/GetPatientDetailTime?PatientGuid={0}&isDisplayTimeAxis=0", Cur_PatientGuid);
|
||
Cur_PatientDT = DBHelpClass.GetJsonText(Url);
|
||
if (Cur_PatientDT != null)
|
||
{
|
||
Form_SelectTime form = new Form_SelectTime(Cur_PatientDT.Select("ID='" + id + "'")[0]["RecordingTime"].ToString());
|
||
if (form.ShowDialog() == DialogResult.OK)
|
||
{
|
||
time = form.time;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
Form_SelectTime form = new Form_SelectTime("");
|
||
if (form.ShowDialog() == DialogResult.OK)
|
||
{
|
||
time = form.time;
|
||
}
|
||
}
|
||
|
||
if (id > 0 && !string.IsNullOrEmpty(time))
|
||
{
|
||
List<T_Service_Apoplexy_PatientsTimeAxisDTO> list = new List<T_Service_Apoplexy_PatientsTimeAxisDTO>();
|
||
T_Service_Apoplexy_PatientsTimeAxisDTO model = new T_Service_Apoplexy_PatientsTimeAxisDTO();
|
||
|
||
Url = "api/service/T_Service_Apoplexy_PatientsTimeAxis/UpdateRecordingTimeByPatientIDAndTimeAxisID";
|
||
model.RecordingTime = time;
|
||
model.PatientGuid = Cur_PatientGuid;
|
||
model.TimeAxisID = id;
|
||
model.NormalTime = PublicClass.DateTimeNow();//赋值但不更新
|
||
list.Add(model);
|
||
//初始化两个工厂
|
||
ClientFactory<T_Service_Apoplexy_PatientsTimeAxisDTO> httpClient = new HttpClientFactory<T_Service_Apoplexy_PatientsTimeAxisDTO>();
|
||
Client<T_Service_Apoplexy_PatientsTimeAxisDTO> client = httpClient.VisitFactory();
|
||
|
||
//访问
|
||
ListEntity<T_Service_Apoplexy_PatientsTimeAxisDTO> t = client.Post(Url, list);
|
||
if (t.Success)
|
||
{
|
||
//更改之后重新获取数据源
|
||
Url = string.Format("api/service/T_Service_Apoplexy_PatientsTimeAxis/GetPatientDetailTime?PatientGuid={0}&isDisplayTimeAxis=0", Cur_PatientGuid);
|
||
Cur_PatientDT = DBHelpClass.GetJsonText(Url);
|
||
overwritePanelLoad(Cur_PatientDT);
|
||
|
||
TSM_Refurbish_Click(sender, e);
|
||
}
|
||
}
|
||
|
||
#endregion 时间轴点击事件
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
PublicClass.WriteErrorLog(this.Text, "时间轴点击事件:\r\n" + ex);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 窗体关闭
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void Form_TimeAxis_FormClosed(object sender, FormClosedEventArgs e)
|
||
{
|
||
this.Dispose();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 刷新时间轴
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void TSM_Refurbish_Click(object sender, EventArgs e)
|
||
{
|
||
overwritePanel_MajorNode.Controls.Clear();
|
||
overwritePanel_Info.Controls.Clear();
|
||
Form_TimeAxis_Load(sender, e);
|
||
}
|
||
|
||
#endregion 事件
|
||
|
||
#region 绘制
|
||
|
||
#region 主时间节点
|
||
|
||
/// <summary>
|
||
/// 左侧主节点绘制-线
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void overwritePanel_MajorNode_Paint(object sender, PaintEventArgs e)
|
||
{
|
||
int xAdd = 17;//线对应图标X轴坐标增加的像素 即往右平移
|
||
int yAdd = 10;//线对应图标Y轴坐标增加的像素 即往下平移
|
||
|
||
#region 主时间轴
|
||
|
||
if (Cur_PatientDT != null && Cur_PatientDT.Rows.Count > 0)
|
||
{
|
||
DataRow[] dataRows = Cur_PatientDT.Select("ParentID='-1'", "LocationX Asc");
|
||
if (dataRows.Length >= 0)
|
||
{
|
||
int LocationX = PublicClass.ToInt32(dataRows[0]["LocationX"], 0);//时间节点X轴坐标 图标的
|
||
int LocationY = PublicClass.ToInt32(dataRows[0]["LocationY"], 0);//时间节点Y轴坐标 图标的
|
||
int LocationX2 = PublicClass.ToInt32(dataRows[dataRows.Length - 1]["LocationX"], 0);//时间节点X轴坐标 图标的
|
||
int LocationY2 = PublicClass.ToInt32(dataRows[dataRows.Length - 1]["LocationY"], 0);//时间节点Y轴坐标 图标的
|
||
e.Graphics.DrawLine(new Pen(Color.Gray), LocationX + xAdd, LocationY + yAdd, LocationX2 + xAdd, LocationY2);
|
||
}
|
||
}
|
||
|
||
#endregion 主时间轴
|
||
}
|
||
|
||
/// <summary>
|
||
/// 左侧主节点绘制-点
|
||
/// </summary>
|
||
/// <param name="Cur_PatientDT"></param>
|
||
private void MainTime(DataTable Cur_PatientDT)
|
||
{
|
||
try
|
||
{
|
||
#region 左侧主节点绘制-点
|
||
|
||
int xName = 5;//节点名称X轴坐标
|
||
int yName = 0;//节点名称Y轴坐标对比变量 相对节点坐标而言
|
||
int xAdd = 40;//参考时长、实际时长X轴坐标
|
||
int yAdd = 20;//参考时长、实际时长Y轴坐标对比变量
|
||
|
||
if (Cur_PatientDT != null && Cur_PatientDT.Rows.Count > 0)
|
||
{
|
||
DataRow[] dataRows = Cur_PatientDT.Select("ParentID='-1'");
|
||
|
||
string PatientServiceHospitalTime = ""; //患者到达医院时间
|
||
string PreliminaryDiagnosisTime = "";//到院至完成初步诊断
|
||
string ThrombolyticDoctorAdmissionsTime = "";//溶栓医生接诊患者时间
|
||
string FirstDoseAdministrationTime = "";//首剂给药时间
|
||
string InterventionalTherapyTalkTime = ""; //介入治疗开始谈话时间
|
||
string PatientLeavingCatheterRoomTime = ""; //患者离开导管室时间
|
||
DateTime compareDate = new DateTime();
|
||
DateTime compareDateExaminationTime = new DateTime();
|
||
|
||
//循环动态画时间轴
|
||
for (int i = 0; i < dataRows.Length; i++)
|
||
{
|
||
int actualMin = 0;//实际时长
|
||
int ColorFlag = 0;//颜色标记: 0:黑色(正常) 1:橙色 2:红色
|
||
|
||
TimeSpan timeSpan = new TimeSpan();
|
||
string id = PublicClass.ToString(dataRows[i]["ID"], "");//时间ID
|
||
int interval = PublicClass.ToInt32(dataRows[i]["Interval"], 0);//时间控制要求指标--间隔
|
||
string recordingTime = PublicClass.ToString(dataRows[i]["RecordingTime"], "");//实际发生时间
|
||
string normalTime = PublicClass.ToString(dataRows[i]["NormalTime"], "");//正常参考时间
|
||
string timeName = PublicClass.ToString(dataRows[i]["TimeName"], "");//时间节点名称
|
||
|
||
int LocationX = PublicClass.ToInt32(dataRows[i]["LocationX"], 0);//时间节点X轴坐标 图标的
|
||
int LocationY = PublicClass.ToInt32(dataRows[i]["LocationY"], 0);//时间节点Y轴坐标 图标的
|
||
|
||
#region 对各时间节点赋值
|
||
|
||
//患者到达医院时间赋值
|
||
if (id == PublicClassForDataBase.Config13)
|
||
{
|
||
PatientServiceHospitalTime = recordingTime;
|
||
}
|
||
//介入治疗开始谈话时间赋值
|
||
if (id == PublicClassForDataBase.Config31)
|
||
{
|
||
InterventionalTherapyTalkTime = recordingTime;
|
||
}
|
||
//患者离开导管室时间赋值
|
||
if (id == PublicClassForDataBase.Config37)
|
||
{
|
||
PatientLeavingCatheterRoomTime = recordingTime;
|
||
}
|
||
//溶栓医生接诊患者时间赋值
|
||
if (id == PublicClassForDataBase.Config26)
|
||
{
|
||
ThrombolyticDoctorAdmissionsTime = recordingTime;
|
||
}
|
||
//首剂给药时间赋值
|
||
if (id == PublicClassForDataBase.Config30)
|
||
{
|
||
FirstDoseAdministrationTime = recordingTime;
|
||
}
|
||
//介入治疗开始谈话时间赋值
|
||
if (id == PublicClassForDataBase.Config31)
|
||
{
|
||
InterventionalTherapyTalkTime = recordingTime;
|
||
}
|
||
//到院至完成初步诊断赋值
|
||
if (id == PublicClassForDataBase.Config2)
|
||
{
|
||
PreliminaryDiagnosisTime = recordingTime;
|
||
}
|
||
|
||
#endregion 对各时间节点赋值
|
||
|
||
//显示节点名称
|
||
LabelControl labelName = new LabelControl
|
||
{
|
||
Name = "labelName" + i.ToString(),
|
||
Text = timeName,
|
||
Location = new Point(xName, LocationY + yName),
|
||
Size = new Size(65, 30),
|
||
Visible = true,
|
||
AutoSizeMode = LabelAutoSizeMode.Vertical,
|
||
};
|
||
overwritePanel_MajorNode.Controls.Add(labelName);
|
||
|
||
#region 图标
|
||
|
||
//院前接诊
|
||
if (PublicClassForDataBase.Config1 == id)
|
||
{
|
||
ColorFlag = ShowImage(interval, timeSpan, i, id, LocationX, LocationY, PatientServiceHospitalTime, true, overwritePanel_MajorNode, out actualMin);//显示图标
|
||
}
|
||
|
||
//计算到院至完成初步诊断是否超时
|
||
if (PublicClassForDataBase.Config2 == id)
|
||
{
|
||
if (!string.IsNullOrEmpty(PatientServiceHospitalTime))
|
||
{
|
||
DateTime date = Convert.ToDateTime(PatientServiceHospitalTime).AddMinutes(interval);//计算正常时间 从患者到达医院时间加控制标准10分钟
|
||
UpdateNormalTime(date, Convert.ToDateTime(compareDate), int.Parse(PublicClassForDataBase.Config2));//更新正常时间
|
||
PublicClassForDataBase.UpdateTime(Cur_PatientGuid, PatientServiceHospitalTime, PublicClassForDataBase.Config2);
|
||
if (!string.IsNullOrEmpty(PatientServiceHospitalTime))
|
||
{
|
||
timeSpan = PublicClass.DiffMinutes(compareDate, Convert.ToDateTime(PatientServiceHospitalTime));
|
||
}
|
||
}
|
||
ColorFlag = ShowImage(interval, timeSpan, i, id, LocationX, LocationY, PatientServiceHospitalTime, true, overwritePanel_MajorNode, out actualMin);//显示图标
|
||
}
|
||
|
||
//完成初步诊断至完成治疗前检查是否超时
|
||
if (PublicClassForDataBase.Config3 == id)
|
||
{
|
||
if (!string.IsNullOrEmpty(PreliminaryDiagnosisTime))
|
||
{
|
||
DateTime date = Convert.ToDateTime(PreliminaryDiagnosisTime).AddMinutes(interval);
|
||
UpdateNormalTime(date, Convert.ToDateTime(compareDateExaminationTime), int.Parse(PublicClassForDataBase.Config3));
|
||
PublicClassForDataBase.UpdateTime(Cur_PatientGuid, PreliminaryDiagnosisTime, PublicClassForDataBase.Config3);
|
||
timeSpan = PublicClass.DiffMinutes(compareDateExaminationTime, Convert.ToDateTime(PreliminaryDiagnosisTime));
|
||
}
|
||
ColorFlag = ShowImage(interval, timeSpan, i, id, LocationX, LocationY, PreliminaryDiagnosisTime, true, overwritePanel_MajorNode, out actualMin);//显示图标
|
||
}
|
||
|
||
//完成治疗前检查至溶栓治疗开始
|
||
if (PublicClassForDataBase.Config4 == id)
|
||
{
|
||
if (!string.IsNullOrEmpty(FirstDoseAdministrationTime))
|
||
{
|
||
DateTime date = Convert.ToDateTime(ThrombolyticDoctorAdmissionsTime).AddMinutes(interval);
|
||
UpdateNormalTime(date, Convert.ToDateTime(FirstDoseAdministrationTime), int.Parse(PublicClassForDataBase.Config4));
|
||
PublicClassForDataBase.UpdateTime(Cur_PatientGuid, FirstDoseAdministrationTime, PublicClassForDataBase.Config4);
|
||
if (!string.IsNullOrEmpty(ThrombolyticDoctorAdmissionsTime) && !string.IsNullOrEmpty(FirstDoseAdministrationTime))
|
||
{
|
||
timeSpan = PublicClass.DiffMinutes(Convert.ToDateTime(FirstDoseAdministrationTime), Convert.ToDateTime(ThrombolyticDoctorAdmissionsTime));
|
||
}
|
||
}
|
||
ColorFlag = ShowImage(interval, timeSpan, i, id, LocationX, LocationY, FirstDoseAdministrationTime, true, overwritePanel_MajorNode, out actualMin);//显示图标
|
||
}
|
||
|
||
//完成治疗前检查至介入治疗开始
|
||
if (PublicClassForDataBase.Config5 == id)
|
||
{
|
||
if (!string.IsNullOrEmpty(PatientLeavingCatheterRoomTime))
|
||
{
|
||
DateTime date = Convert.ToDateTime(InterventionalTherapyTalkTime).AddMinutes(interval);
|
||
UpdateNormalTime(date, Convert.ToDateTime(PatientLeavingCatheterRoomTime), int.Parse(PublicClassForDataBase.Config5));
|
||
PublicClassForDataBase.UpdateTime(Cur_PatientGuid, PatientLeavingCatheterRoomTime, PublicClassForDataBase.Config5);
|
||
if (!string.IsNullOrEmpty(PatientLeavingCatheterRoomTime) && !string.IsNullOrEmpty(InterventionalTherapyTalkTime))
|
||
{
|
||
timeSpan = PublicClass.DiffMinutes(Convert.ToDateTime(PatientLeavingCatheterRoomTime), Convert.ToDateTime(InterventionalTherapyTalkTime));
|
||
}
|
||
}
|
||
ColorFlag = ShowImage(interval, timeSpan, i, id, LocationX, LocationY, PatientLeavingCatheterRoomTime, true, overwritePanel_MajorNode, out actualMin);//显示图标
|
||
}
|
||
|
||
#endregion 图标
|
||
|
||
#region 颜色
|
||
|
||
Color color = Color.Black;
|
||
if (ColorFlag == 1)
|
||
{
|
||
color = Color.LightSalmon;
|
||
}
|
||
else if (ColorFlag == 2)
|
||
{
|
||
color = Color.Red;
|
||
}
|
||
|
||
#endregion 颜色
|
||
|
||
#region 参考时长
|
||
|
||
if (interval > 0)
|
||
{
|
||
//参考时长Label显示
|
||
LabelControl referenceTimeLabel = new LabelControl
|
||
{
|
||
Name = "referenceTimeLabel" + i.ToString(),
|
||
Text = "参考时长:" + interval + " min",
|
||
Location = new Point(LocationX + xAdd, LocationY),
|
||
Size = new Size(100, 30),
|
||
Visible = true
|
||
};
|
||
overwritePanel_MajorNode.Controls.Add(referenceTimeLabel);
|
||
|
||
//实际时长Label显示
|
||
LabelControl actualTimeLabel = new LabelControl
|
||
{
|
||
Name = "actualTimeLabel" + i.ToString(),
|
||
Text = "实际时长:" + actualMin + " min",
|
||
Location = new Point(LocationX + xAdd, LocationY + yAdd),
|
||
Size = new Size(100, 30),
|
||
ForeColor = color,
|
||
Visible = true,
|
||
AutoSizeMode = LabelAutoSizeMode.Vertical,
|
||
};
|
||
overwritePanel_MajorNode.Controls.Add(actualTimeLabel);
|
||
}
|
||
|
||
#endregion 参考时长
|
||
}
|
||
}
|
||
|
||
#endregion 左侧主节点绘制-点
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
PublicClass.WriteErrorLog(this.Text, "左侧主节点绘制-点:\r\n" + ex);
|
||
}
|
||
}
|
||
|
||
#endregion 主时间节点
|
||
|
||
#region 详细时间节点
|
||
|
||
/// <summary>
|
||
/// 右侧详细节点绘制--线
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void overwritePanel_Info_Paint(object sender, PaintEventArgs e)
|
||
{
|
||
try
|
||
{
|
||
#region 右侧详细节点绘制--线
|
||
|
||
int xAdd = 10;//线对应图标X轴坐标增加的像素 即往右平移
|
||
int yAdd = 17;//线对应图标Y轴坐标增加的像素 即往下平移
|
||
|
||
if (Cur_PatientDT != null && Cur_PatientDT.Rows.Count > 0)
|
||
{
|
||
#region 院前接诊时间轴
|
||
|
||
DataRow[] DataRow1 = Cur_PatientDT.Select("ParentID='" + PublicClassForDataBase.Config1 + "'");
|
||
if (DataRow1.Length > 0)
|
||
{
|
||
int LocationX = PublicClass.ToInt32(DataRow1[0]["LocationX"], 0);//时间节点X轴坐标 图标的
|
||
int LocationY = PublicClass.ToInt32(DataRow1[0]["LocationY"], 0);//时间节点Y轴坐标 图标的
|
||
int LocationX2 = PublicClass.ToInt32(DataRow1[DataRow1.Length - 1]["LocationX"], 0);//时间节点X轴坐标 图标的
|
||
int LocationY2 = PublicClass.ToInt32(DataRow1[DataRow1.Length - 1]["LocationY"], 0);//时间节点Y轴坐标 图标的
|
||
|
||
e.Graphics.DrawLine(new Pen(Color.Gray), LocationX + xAdd, LocationY + yAdd, LocationX2 + xAdd, LocationY2 + yAdd);
|
||
}
|
||
|
||
#endregion 院前接诊时间轴
|
||
|
||
#region 到院至完成初步诊断
|
||
|
||
DataRow[] DataRow2 = Cur_PatientDT.Select("ParentID='" + PublicClassForDataBase.Config2 + "'");
|
||
if (DataRow2.Length > 0)
|
||
{
|
||
int LocationX = PublicClass.ToInt32(DataRow2[0]["LocationX"], 0);//时间节点X轴坐标 图标的
|
||
int LocationY = PublicClass.ToInt32(DataRow2[0]["LocationY"], 0);//时间节点Y轴坐标 图标的
|
||
int LocationX2 = PublicClass.ToInt32(DataRow2[DataRow2.Length - 1]["LocationX"], 0);//时间节点X轴坐标 图标的
|
||
int LocationY2 = PublicClass.ToInt32(DataRow2[DataRow2.Length - 1]["LocationY"], 0);//时间节点Y轴坐标 图标的
|
||
|
||
e.Graphics.DrawLine(new Pen(Color.Gray), LocationX + xAdd, LocationY + yAdd, LocationX2 + xAdd, LocationY2 + yAdd);
|
||
}
|
||
|
||
#endregion 到院至完成初步诊断
|
||
|
||
#region 完成初步诊断至完成治疗前检查
|
||
|
||
DataRow[] DataRow3 = Cur_PatientDT.Select("ParentID='" + PublicClassForDataBase.Config3 + "'");
|
||
if (DataRow3.Length > 0)
|
||
{
|
||
int LocationX = PublicClass.ToInt32(DataRow3[0]["LocationX"], 0);//时间节点X轴坐标 图标的
|
||
int LocationY = PublicClass.ToInt32(DataRow3[0]["LocationY"], 0);//时间节点Y轴坐标 图标的
|
||
int LocationX2 = PublicClass.ToInt32(DataRow3[DataRow3.Length - 1]["LocationX"], 0);//时间节点X轴坐标 图标的
|
||
int LocationY2 = PublicClass.ToInt32(DataRow3[DataRow3.Length - 1]["LocationY"], 0);//时间节点Y轴坐标 图标的
|
||
|
||
e.Graphics.DrawLine(new Pen(Color.Gray), LocationX + xAdd, LocationY + yAdd, LocationX2 + xAdd, LocationY2 + yAdd);
|
||
}
|
||
|
||
#endregion 完成初步诊断至完成治疗前检查
|
||
|
||
#region 完成治疗前检查至溶栓治疗开始
|
||
|
||
DataRow[] DataRow4 = Cur_PatientDT.Select("ParentID='" + PublicClassForDataBase.Config4 + "'");
|
||
if (DataRow4.Length > 0)
|
||
{
|
||
int LocationX = PublicClass.ToInt32(DataRow4[0]["LocationX"], 0);//时间节点X轴坐标 图标的
|
||
int LocationY = PublicClass.ToInt32(DataRow4[0]["LocationY"], 0);//时间节点Y轴坐标 图标的
|
||
int LocationX2 = PublicClass.ToInt32(DataRow4[DataRow4.Length - 1]["LocationX"], 0);//时间节点X轴坐标 图标的
|
||
int LocationY2 = PublicClass.ToInt32(DataRow4[DataRow4.Length - 1]["LocationY"], 0);//时间节点Y轴坐标 图标的
|
||
|
||
e.Graphics.DrawLine(new Pen(Color.Gray), LocationX + xAdd, LocationY + yAdd, LocationX2 + xAdd, LocationY2 + yAdd);
|
||
}
|
||
|
||
#endregion 完成治疗前检查至溶栓治疗开始
|
||
|
||
#region 完成治疗前检查至介入治疗开始
|
||
|
||
DataRow[] DataRow5 = Cur_PatientDT.Select("ParentID='" + PublicClassForDataBase.Config5 + "'");
|
||
if (DataRow5.Length > 0)
|
||
{
|
||
int LocationX = PublicClass.ToInt32(DataRow5[0]["LocationX"], 0);//时间节点X轴坐标 图标的
|
||
int LocationY = PublicClass.ToInt32(DataRow5[0]["LocationY"], 0);//时间节点Y轴坐标 图标的
|
||
int LocationX2 = PublicClass.ToInt32(DataRow5[DataRow5.Length - 1]["LocationX"], 0);//时间节点X轴坐标 图标的
|
||
int LocationY2 = PublicClass.ToInt32(DataRow5[DataRow5.Length - 1]["LocationY"], 0);//时间节点Y轴坐标 图标的
|
||
|
||
e.Graphics.DrawLine(new Pen(Color.Gray), LocationX + xAdd, LocationY + yAdd, LocationX2 + xAdd, LocationY2 + yAdd);
|
||
}
|
||
|
||
#endregion 完成治疗前检查至介入治疗开始
|
||
}
|
||
|
||
#endregion 右侧详细节点绘制--线
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
PublicClass.WriteErrorLog(this.Text, "右侧详细节点绘制--线:\r\n" + ex);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 右侧详细节点绘制--点
|
||
/// </summary>
|
||
/// <param name="PatientsTimeAxisDT">节点源</param>
|
||
private void overwritePanelLoad(DataTable PatientsTimeAxisDT)
|
||
{
|
||
//左侧主节点绘制-点
|
||
//MainTime(PatientsTimeAxisDT);
|
||
//院前接诊
|
||
DetailTime(PatientsTimeAxisDT, PublicClassForDataBase.Config1);
|
||
//到院至完成初步诊断
|
||
DetailTime(PatientsTimeAxisDT, PublicClassForDataBase.Config2);
|
||
//完成初步诊断至完成治疗前检查
|
||
DetailTime(PatientsTimeAxisDT, PublicClassForDataBase.Config3);
|
||
//完成治疗前检查至溶栓治疗开始
|
||
DetailTime(PatientsTimeAxisDT, PublicClassForDataBase.Config4);
|
||
//完成治疗前检查至介入治疗开始
|
||
DetailTime(PatientsTimeAxisDT, PublicClassForDataBase.Config5);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 绘制详细节点轴
|
||
/// </summary>
|
||
/// <param name="Cur_PatientDT">数据源</param>
|
||
/// <param name="TimeParentID">所属父级节点编号</param>
|
||
private void DetailTime(DataTable Cur_PatientDT, string TimeParentID)
|
||
{
|
||
int xName = 0;//节点名称X轴坐标对比变量 相对节点坐标而言
|
||
int xTime = 0;//实际时间X轴坐标对比变量 相对节点坐标而言
|
||
int yName = 0;//节点名称Y轴坐标对比变量 相对节点坐标而言
|
||
int yTime = 0;//实际时间Y轴坐标对比变量 相对节点坐标而言
|
||
|
||
if (Cur_PatientDT != null && Cur_PatientDT.Rows.Count > 0)
|
||
{
|
||
DataRow[] dataRows = Cur_PatientDT.Select("ParentID='" + TimeParentID + "'");
|
||
|
||
//循环动态画时间轴
|
||
for (int i = 0; i < dataRows.Length; i++)
|
||
{
|
||
int actualMin = 0;//实际时长
|
||
int ColorFlag = 0;//颜色标记: 0:黑色(正常) 1:橙色 2:红色
|
||
|
||
TimeSpan timeSpan = new TimeSpan();
|
||
string id = PublicClass.ToString(dataRows[i]["ID"], "");//时间编号节点编号
|
||
int interval = PublicClass.ToInt32(dataRows[i]["Interval"], 0);//时间控制要求指标--间隔
|
||
string contrastTimeAxisID = PublicClass.ToString(dataRows[i]["ContrastTimeAxisID"], "");//参考时间节点编号
|
||
string recordingTime = PublicClass.ToString(dataRows[i]["RecordingTime"], "");//实际发生时间
|
||
string timeName = PublicClass.ToString(dataRows[i]["TimeName"], "");//时间节点名称
|
||
|
||
int LocationX = PublicClass.ToInt32(dataRows[i]["LocationX"], 0);//时间节点X轴坐标 图标的
|
||
int LocationY = PublicClass.ToInt32(dataRows[i]["LocationY"], 0);//时间节点Y轴坐标 图标的
|
||
|
||
//参考间隔不为0 取参考节点值
|
||
if (interval > 0 && !string.IsNullOrEmpty(recordingTime))
|
||
{
|
||
DataRow[] dataRowsContrast = Cur_PatientDT.Select("ID='" + contrastTimeAxisID + "'");
|
||
if (dataRowsContrast.Length > 0)
|
||
{
|
||
DateTime ContrastTime = PublicClass.ToDateTime(dataRowsContrast[0]["RecordingTime"], PublicClass.DefaultTime);
|
||
timeSpan = PublicClass.DiffMinutes(ContrastTime, PublicClass.ToDateTime(recordingTime, PublicClass.DefaultTime));
|
||
}
|
||
}
|
||
//参考间隔为0 取上一个节点的值
|
||
else
|
||
{
|
||
if (i > 0)
|
||
{
|
||
if (!string.IsNullOrEmpty(dataRows[i - 1]["RecordingTime"] + ""))
|
||
{
|
||
timeSpan = PublicClass.DiffMinutes(PublicClass.ToDateTime(dataRows[i - 1]["RecordingTime"], PublicClass.DefaultTime), PublicClass.ToDateTime(recordingTime, PublicClass.DefaultTime));
|
||
}
|
||
}
|
||
}
|
||
|
||
if (interval > 0)
|
||
{
|
||
if (!string.IsNullOrEmpty(recordingTime))
|
||
{
|
||
DateTime date = Convert.ToDateTime(recordingTime).AddMinutes(interval);
|
||
UpdateNormalTime(date, Convert.ToDateTime(recordingTime), int.Parse(id));//更新参考时间
|
||
}
|
||
}
|
||
|
||
//显示图标
|
||
ColorFlag = ShowImage(interval, timeSpan, i, id, LocationX, LocationY, recordingTime, false, overwritePanel_Info, out actualMin);
|
||
|
||
#region 颜色
|
||
|
||
Color color = Color.Black;
|
||
if (ColorFlag == 1)
|
||
{
|
||
color = Color.LightSalmon;
|
||
}
|
||
else if (ColorFlag == 2)
|
||
{
|
||
color = Color.Red;
|
||
}
|
||
|
||
#endregion 颜色
|
||
|
||
#region 坐标
|
||
|
||
//X轴 第一个特殊处理
|
||
if (i == 0)
|
||
{
|
||
xName = LocationX - 20;//向左平移20个像素
|
||
xTime = LocationX - 20;//向左平移20个像素
|
||
}
|
||
else
|
||
{
|
||
xName = Convert.ToInt32(timeName.Length * 3.5);//每个字符12个像素 汉字
|
||
xTime = Convert.ToInt32(recordingTime.Length * 2);//每个字符6个像素 数字
|
||
}
|
||
|
||
//Y轴 奇数偶数判断 等于0为偶数,放图标底下
|
||
if (i % 2 == 0)
|
||
{
|
||
yName = 35;
|
||
yTime = 55;
|
||
}
|
||
else
|
||
{
|
||
yName = -30;
|
||
yTime = -15;
|
||
}
|
||
|
||
#endregion 坐标
|
||
|
||
//显示节点名称
|
||
LabelControl labelName = new LabelControl
|
||
{
|
||
Name = "labelName" + i.ToString(),
|
||
Text = timeName,
|
||
Location = new Point(LocationX - xName, LocationY + yName),
|
||
Size = new Size(20, 30),
|
||
Visible = true
|
||
};
|
||
overwritePanel_Info.Controls.Add(labelName);
|
||
|
||
//显示节点时间
|
||
LabelControl labelTime = new LabelControl
|
||
{
|
||
Name = "labelTime" + i.ToString(),
|
||
Text = recordingTime,
|
||
Location = new Point(LocationX - xTime, LocationY + yTime),
|
||
Size = new Size(20, 30),
|
||
ForeColor = color,
|
||
Visible = true
|
||
};
|
||
overwritePanel_Info.Controls.Add(labelTime);
|
||
}
|
||
}
|
||
}
|
||
|
||
#endregion 详细时间节点
|
||
|
||
/// <summary>
|
||
/// 根据实际时间和正常时间来显示图标
|
||
/// </summary>
|
||
/// <param name="interval">参考间隔</param>
|
||
/// <param name="timeSpan">两个节点间实际间隔</param>
|
||
/// <param name="number">第几个:用于绘制图标控件</param>
|
||
/// <param name="timeAxisID">节点编号</param>
|
||
/// <param name="x">X轴坐标</param>
|
||
/// <param name="y">Y轴坐标</param>
|
||
/// <param name="recordingTime">发生的时间:控制是否显示灰色图标</param>
|
||
/// <param name="isMainTime">是否主节点:true是,false否</param>
|
||
/// <param name="actualLength">实际时长</param>
|
||
/// <param name="overwritePanel">所属绘制控件:主、详</param>
|
||
/// <returns>返回的颜色标记: 0:黑色(正常) 1:橙色 2:红色</returns>
|
||
public int ShowImage(int interval, TimeSpan timeSpan, int number, string timeAxisID, int x, int y, string recordingTime, bool isMainTime, OverwritePanel overwritePanel, out int actualLength)
|
||
{
|
||
//返回的颜色标记: 0:黑色(正常) 1:橙色 2:红色
|
||
int ColorFlag = 0;
|
||
//赋予默认值
|
||
actualLength = 0;
|
||
|
||
#region 主节点
|
||
|
||
if (isMainTime)
|
||
{
|
||
//没有录入时间的节点数量
|
||
int NotHaveTimeNum = 0;
|
||
|
||
DataRow[] dataRows = Cur_PatientDT.Select("ParentID='" + timeAxisID + "'", "RecordingTime Asc");
|
||
for (int i = 0; i < dataRows.Length; i++)
|
||
{
|
||
if (PublicClass.ToDateTime(dataRows[i]["RecordingTime"], PublicClass.DefaultTime) == PublicClass.DefaultTime)
|
||
{
|
||
NotHaveTimeNum++;
|
||
}
|
||
}
|
||
|
||
//全部未录入--灰色
|
||
if (NotHaveTimeNum == dataRows.Length)
|
||
{
|
||
SimpleButton simpleButton = new SimpleButton
|
||
{
|
||
Name = "Timebutton" + number,
|
||
ButtonStyle = BorderStyles.NoBorder,
|
||
BackgroundImage = Resources.未填,
|
||
BackgroundImageLayout = ImageLayout.Center,
|
||
Location = new Point(x, y),
|
||
Tag = timeAxisID,
|
||
Size = new Size(35, 33)
|
||
};
|
||
simpleButton.Click += SimpleButton_Click;
|
||
overwritePanel.Controls.Add(simpleButton);
|
||
}
|
||
//部分录入--黄色
|
||
else if (NotHaveTimeNum < dataRows.Length && NotHaveTimeNum > 0)
|
||
{
|
||
SimpleButton simpleButton = new SimpleButton
|
||
{
|
||
Name = "Timebutton" + number,
|
||
ButtonStyle = BorderStyles.NoBorder,
|
||
BackgroundImage = Resources.部分填写,
|
||
BackgroundImageLayout = ImageLayout.Center,
|
||
Location = new Point(x, y),
|
||
Tag = timeAxisID,
|
||
Size = new Size(35, 33)
|
||
};
|
||
simpleButton.Click += SimpleButton_Click;
|
||
overwritePanel.Controls.Add(simpleButton);
|
||
|
||
ColorFlag = 1;
|
||
|
||
#region 计算已经耗时
|
||
|
||
DataRow[] dataRows1 = Cur_PatientDT.Select("ParentID='" + timeAxisID + "' And RecordingTime <> ''", "RecordingTime Asc");
|
||
if (dataRows1.Length > 0)
|
||
{
|
||
DateTime MinTime = PublicClass.ToDateTime(dataRows1[0]["RecordingTime"], PublicClass.DefaultTime);
|
||
DateTime MaxTime = PublicClass.ToDateTime(dataRows1[dataRows1.Length - 1]["RecordingTime"], PublicClass.DefaultTime);
|
||
actualLength = Convert.ToInt32(PublicClass.DiffMinutes(MinTime, MaxTime).TotalMinutes);
|
||
}
|
||
|
||
#endregion 计算已经耗时
|
||
}
|
||
//全部录完--异常:红色;正常:绿色
|
||
else if (NotHaveTimeNum == 0)
|
||
{
|
||
DateTime MinTime = PublicClass.ToDateTime(dataRows[0]["RecordingTime"], PublicClass.DefaultTime);
|
||
DateTime MaxTime = PublicClass.ToDateTime(dataRows[dataRows.Length - 1]["RecordingTime"], PublicClass.DefaultTime);
|
||
timeSpan = PublicClass.DiffMinutes(MinTime, MaxTime);
|
||
|
||
actualLength = Convert.ToInt32(timeSpan.TotalMinutes);
|
||
|
||
//【没有设置间隔参考】或者【参考间隔>=实际间隔】
|
||
if (interval == 0 || (interval > Convert.ToInt32(timeSpan.TotalMinutes)))
|
||
{
|
||
SimpleButton simpleButton = new SimpleButton
|
||
{
|
||
Name = "Timebutton" + number,
|
||
ButtonStyle = BorderStyles.NoBorder,
|
||
BackgroundImage = Resources.正常,
|
||
BackgroundImageLayout = ImageLayout.Center,
|
||
Location = new Point(x, y),
|
||
Tag = timeAxisID,
|
||
Size = new Size(35, 33)
|
||
};
|
||
simpleButton.Click += SimpleButton_Click;
|
||
overwritePanel.Controls.Add(simpleButton);
|
||
}
|
||
//【参考间隔<=实际间隔】
|
||
else if (interval <= Convert.ToInt32(timeSpan.TotalMinutes))
|
||
{
|
||
SimpleButton simpleButton = new SimpleButton
|
||
{
|
||
Name = "Timebutton" + number,
|
||
ButtonStyle = BorderStyles.NoBorder,
|
||
BackgroundImage = Resources.错误,
|
||
BackgroundImageLayout = ImageLayout.Center,
|
||
Location = new Point(x, y),
|
||
Tag = timeAxisID,
|
||
Size = new Size(35, 33)
|
||
};
|
||
simpleButton.Click += SimpleButton_Click;
|
||
overwritePanel.Controls.Add(simpleButton);
|
||
|
||
ColorFlag = 2;
|
||
}
|
||
}
|
||
}
|
||
|
||
#endregion 主节点
|
||
|
||
#region 细节点
|
||
|
||
else
|
||
{
|
||
//未录入:灰色
|
||
if (PublicClass.ToDateTime(recordingTime, PublicClass.DefaultTime) == PublicClass.DefaultTime)
|
||
{
|
||
SimpleButton simpleButton = new SimpleButton
|
||
{
|
||
Name = "Timebutton" + number,
|
||
ButtonStyle = BorderStyles.NoBorder,
|
||
BackgroundImage = Resources.未填28,
|
||
BackgroundImageLayout = ImageLayout.Center,
|
||
Location = new Point(x, y),
|
||
Tag = timeAxisID,
|
||
Size = new Size(35, 33)
|
||
};
|
||
simpleButton.Click += SimpleButton_Click;
|
||
overwritePanel.Controls.Add(simpleButton);
|
||
}
|
||
//录入--异常:红色;正常:绿色
|
||
else
|
||
{
|
||
//【没有设置间隔参考】或者
|
||
if (interval == 0)
|
||
{
|
||
//间隔时间超过系统参数设置的参考间隔
|
||
if (Convert.ToInt32(timeSpan.TotalMinutes) > PublicClass.ToInt32(PublicClassForDataBase.Config112, 0))
|
||
{
|
||
SimpleButton simpleButton = new SimpleButton
|
||
{
|
||
Name = "Timebutton" + number,
|
||
ButtonStyle = BorderStyles.NoBorder,
|
||
BackgroundImage = Resources.错误28,
|
||
BackgroundImageLayout = ImageLayout.Center,
|
||
Location = new Point(x, y),
|
||
Tag = timeAxisID,
|
||
Size = new Size(35, 33)
|
||
};
|
||
simpleButton.Click += SimpleButton_Click;
|
||
overwritePanel.Controls.Add(simpleButton);
|
||
|
||
ColorFlag = 2;
|
||
}
|
||
else
|
||
{
|
||
SimpleButton simpleButton = new SimpleButton
|
||
{
|
||
Name = "Timebutton" + number,
|
||
ButtonStyle = BorderStyles.NoBorder,
|
||
BackgroundImage = Resources.正常28,
|
||
BackgroundImageLayout = ImageLayout.Center,
|
||
Location = new Point(x, y),
|
||
Tag = timeAxisID,
|
||
Size = new Size(35, 33)
|
||
};
|
||
simpleButton.Click += SimpleButton_Click;
|
||
overwritePanel.Controls.Add(simpleButton);
|
||
}
|
||
}
|
||
//【有设置时间间隔】
|
||
else
|
||
{
|
||
//对比时间不早于参考时间
|
||
if (timeSpan.TotalMinutes > 0)
|
||
{
|
||
//【参考间隔>=实际间隔】
|
||
if (interval >= Convert.ToInt32(timeSpan.TotalMinutes))
|
||
{
|
||
SimpleButton simpleButton = new SimpleButton
|
||
{
|
||
Name = "Timebutton" + number,
|
||
ButtonStyle = BorderStyles.NoBorder,
|
||
BackgroundImage = Resources.正常28,
|
||
BackgroundImageLayout = ImageLayout.Center,
|
||
Location = new Point(x, y),
|
||
Tag = timeAxisID,
|
||
Size = new Size(35, 33)
|
||
};
|
||
simpleButton.Click += SimpleButton_Click;
|
||
overwritePanel.Controls.Add(simpleButton);
|
||
}
|
||
//【参考间隔<实际间隔】
|
||
else if (interval < Convert.ToInt32(timeSpan.TotalMinutes))
|
||
{
|
||
SimpleButton simpleButton = new SimpleButton
|
||
{
|
||
Name = "Timebutton" + number,
|
||
ButtonStyle = BorderStyles.NoBorder,
|
||
BackgroundImage = Resources.错误28,
|
||
BackgroundImageLayout = ImageLayout.Center,
|
||
Location = new Point(x, y),
|
||
Tag = timeAxisID,
|
||
Size = new Size(35, 33)
|
||
};
|
||
simpleButton.Click += SimpleButton_Click;
|
||
overwritePanel.Controls.Add(simpleButton);
|
||
|
||
ColorFlag = 2;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
SimpleButton simpleButton = new SimpleButton
|
||
{
|
||
Name = "Timebutton" + number,
|
||
ButtonStyle = BorderStyles.NoBorder,
|
||
BackgroundImage = Resources.错误28,
|
||
BackgroundImageLayout = ImageLayout.Center,
|
||
Location = new Point(x, y),
|
||
Tag = timeAxisID,
|
||
Size = new Size(35, 33)
|
||
};
|
||
simpleButton.Click += SimpleButton_Click;
|
||
overwritePanel.Controls.Add(simpleButton);
|
||
|
||
ColorFlag = 2;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
#endregion 细节点
|
||
|
||
return ColorFlag;
|
||
}
|
||
|
||
#endregion 绘制
|
||
|
||
#region 方法
|
||
|
||
/// <summary>
|
||
/// 冒泡比较时间
|
||
/// </summary>
|
||
/// <param name="time1"></param>
|
||
/// <param name="time2"></param>
|
||
/// <param name="time3"></param>
|
||
/// <param name="time4"></param>
|
||
/// <param name="time5"></param>
|
||
/// <returns></returns>
|
||
public DateTime CompareTime(DateTime time1, DateTime time2, DateTime time3, DateTime time4, DateTime time5)
|
||
{
|
||
List<DateTime> times = new List<DateTime>();
|
||
times.Add(time1);
|
||
times.Add(time2);
|
||
times.Add(time3);
|
||
times.Add(time4);
|
||
times.Add(time5);
|
||
DateTime dateTime;
|
||
for (int j = 0; j < times.Count - 1; j++)
|
||
{
|
||
for (int i = 0; i < times.Count - 1; i++)
|
||
{
|
||
if (times[i] < times[i + 1])
|
||
{
|
||
dateTime = times[i + 1];
|
||
times[i + 1] = times[i];
|
||
times[i] = dateTime;
|
||
}
|
||
}
|
||
}
|
||
return times[0];
|
||
}
|
||
|
||
/// <summary>
|
||
/// 更新正常时间
|
||
/// </summary>
|
||
/// <param name="date">参考时间</param>
|
||
/// <param name="recordingTime">操作记录时间</param>
|
||
/// <param name="timeAxidID"></param>
|
||
public void UpdateNormalTime(DateTime date, DateTime recordingTime, int timeAxidID)
|
||
{
|
||
try
|
||
{
|
||
#region 更新正常时间
|
||
|
||
string timeUrl = "api/service/T_Service_Apoplexy_PatientsTimeAxis/UpdateNormalTime";
|
||
ClientFactory<T_Service_Apoplexy_PatientsTimeAxisDTO> httpClient = new HttpClientFactory<T_Service_Apoplexy_PatientsTimeAxisDTO>();
|
||
Client<T_Service_Apoplexy_PatientsTimeAxisDTO> client = httpClient.VisitFactory();
|
||
List<T_Service_Apoplexy_PatientsTimeAxisDTO> listEntity = new List<T_Service_Apoplexy_PatientsTimeAxisDTO>();
|
||
T_Service_Apoplexy_PatientsTimeAxisDTO timeAxisDTO = new T_Service_Apoplexy_PatientsTimeAxisDTO();
|
||
timeAxisDTO.PatientGuid = Cur_PatientGuid;
|
||
timeAxisDTO.TimeAxisID = timeAxidID;
|
||
timeAxisDTO.PatientGuid = Cur_PatientGuid;
|
||
timeAxisDTO.NormalTime = date.ToString(PublicClass.TimeToString);
|
||
timeAxisDTO.RecordingTime = recordingTime.ToString(PublicClass.TimeToString);
|
||
listEntity.Add(timeAxisDTO);
|
||
ListEntity<T_Service_Apoplexy_PatientsTimeAxisDTO> t = client.Post(timeUrl, listEntity);
|
||
|
||
#endregion 更新正常时间
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
PublicClass.WriteErrorLog(this.Text, "更新正常时间:\r\n" + ex);
|
||
}
|
||
}
|
||
|
||
#endregion 方法
|
||
|
||
protected override void CreateHandle()
|
||
{
|
||
if (!IsHandleCreated)
|
||
{
|
||
try
|
||
{
|
||
base.CreateHandle();
|
||
}
|
||
catch { }
|
||
finally
|
||
{
|
||
if (!IsHandleCreated)
|
||
{
|
||
base.RecreateHandle();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
} |