AIMS/AIMSControls/OperationAanesthesia/frmAanesthesiaRecord.cs
2023-08-16 22:32:16 +08:00

2637 lines
112 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using AIMS.DocManager;
using AIMS.OperationFront.UI;
using AIMS.PublicUI.UI;
using AIMSBLL;
using AIMSExtension;
using AIMSModel;
using DevComponents.DotNetBar;
using DevComponents.Editors.DateTimeAdv;
using DocumentManagement;
using DrawGraph;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Printing;
using System.IO;
using System.Linq;
using System.Windows.Forms;
namespace AIMS.OperationAanesthesia
{
public partial class frmAanesthesiaRecord : Form
{
#region
public OperationRecord _record;
public TemplateManage templateManage;
public TemplateManage templateManage2;
public AIMSModel.OperationRoom NowRoom;
public int PatientId = 0;
public int ApplyId = 0;
public int RecoverId = 1;
private System.Windows.Forms.Timer timerGetTextCollectorData;
public AIMSExtension.EditState State;
public bool isReadOnly = false;
public frmAanesthesiaRecord()
{
InitializeComponent();
#region
txtInRoom.MouseDown += new MouseEventHandler(txtDateTime_MouseDown);
txtOutRoom.MouseDown += new MouseEventHandler(txtDateTime_MouseDown);
txtAnaesthesiaBegin.MouseDown += new MouseEventHandler(txtDateTime_MouseDown);
txtAnaesthesiaEnd.MouseDown += new MouseEventHandler(txtDateTime_MouseDown);
txtOperationBegin.MouseDown += new MouseEventHandler(txtDateTime_MouseDown);
txtOperationEnd.MouseDown += new MouseEventHandler(txtDateTime_MouseDown);
txtCG.MouseDown += new MouseEventHandler(txtDateTime_MouseDown);
txtBG.MouseDown += new MouseEventHandler(txtDateTime_MouseDown);
txtAnaesthesiaBegin.KeyUp += new KeyEventHandler(dateTimePicker_KeyUp);
txtAnaesthesiaEnd.KeyUp += new KeyEventHandler(dateTimePicker_KeyUp);
txtOperationBegin.KeyUp += new KeyEventHandler(dateTimePicker_KeyUp);
txtOperationEnd.KeyUp += new KeyEventHandler(dateTimePicker_KeyUp);
txtCG.KeyUp += new KeyEventHandler(dateTimePicker_KeyUp);
txtBG.KeyUp += new KeyEventHandler(dateTimePicker_KeyUp);
txtInRoom.LostFocus += new EventHandler(txtDateTime_LostFocus);
txtOutRoom.LostFocus += new EventHandler(txtDateTime_LostFocus);
txtAnaesthesiaBegin.LostFocus += new EventHandler(txtDateTime_LostFocus);
txtAnaesthesiaEnd.LostFocus += new EventHandler(txtDateTime_LostFocus);
txtOperationBegin.LostFocus += new EventHandler(txtDateTime_LostFocus);
txtOperationEnd.LostFocus += new EventHandler(txtDateTime_LostFocus);
txtCG.LostFocus += new EventHandler(txtDateTime_LostFocus);
txtBG.LostFocus += new EventHandler(txtDateTime_LostFocus);
this.picInRoom.BackgroundImage = global::AIMSControls.Properties.Resources.;
this.picAnesBegin.BackgroundImage = global::AIMSControls.Properties.Resources.;
this.picCG.BackgroundImage = global::AIMSControls.Properties.Resources.;
this.picOpeBegin.BackgroundImage = global::AIMSControls.Properties.Resources.;
this.picOpeEnd.BackgroundImage = global::AIMSControls.Properties.Resources.;
this.picBG.BackgroundImage = global::AIMSControls.Properties.Resources.;
this.picAnesEnd.BackgroundImage = global::AIMSControls.Properties.Resources.;
this.picOutRoom.BackgroundImage = global::AIMSControls.Properties.Resources.;
#endregion
panel8.MouseWheel += new System.Windows.Forms.MouseEventHandler(panel8_MouseWheel);
panel82.MouseWheel += new System.Windows.Forms.MouseEventHandler(panel82_MouseWheel);
}
private void frmAnasRecordBill2_Load(object sender, EventArgs e)
{
labOperatorName.Text = "(" + AIMSExtension.PublicMethod.OperatorNo + ")" + " " + AIMSExtension.PublicMethod.OperatorName;
if (NowRoom != null) lblRoom.Text = NowRoom.Name;
circularProgress1.Location = new Point((panel8.Width - circularProgress1.Width) / 2, (panel8.Height - circularProgress1.Height) / 2);
if (PublicMethod.OperatorNo == "admin" || PublicMethod.RoleName.Contains("麻醉收费记录"))
{
btnChage.Visible = true;
}
if (PublicMethod.OperatorNo == "admin" || PublicMethod.RoleName.Contains("数据中心"))
{
btnsjzx.Visible = true;
}
if (PublicMethod.OperatorNo == "admin" || PublicMethod.RoleName.Contains("大屏通知"))
{
btndptz.Visible = true;
}
//this.MaximizeBox = false;
//this.MinimizeBox = false;
LoadAnesRescue();
}
#endregion
#region
public List<MasterPane> mPanes = new List<MasterPane>();
public List<MasterPane> UpPanes = new List<MasterPane>();
int m_startPrintPage;// 打印的起始页码
int m_endPrintPage;//打印的终止页码
//int m_PageIndex;// 当前打印页码
int count = 0;
private void plPrint_Click(object sender, EventArgs e)
{
if (_record == null || _record.Id == 0) return;
plPrint.Select();
SelectWorkerValue.Hidden();
SelectDictValue.Hidden();
SelectDictText.Hidden();
if (_record.SAreaObj != null && _record.SAreaObj.Selected == true)
{
_record.SAreaObj.Clear();
}
if (_record.SelPhysioConfig != null)
{
_record.SelPhysioConfig.IsClick = false;
_record.SelPhysioConfig.onClick(e);
_record.SelPhysioConfig = null;
}
Panel panel = zgcAnaesRecord.Parent as Panel;
panel.VerticalScroll.Value = 0;
Panel panel2 = zgcAnaesRecord2.Parent as Panel;
panel2.VerticalScroll.Value = 0;
if (_record.StateName == "手术中")
{
if (txtOperationEnd.CustomFormat == " " && txtOutRoom.CustomFormat == " ")
{
txtOperationEnd.BackColor = Color.Red;
txtOutRoom.BackColor = Color.Red;
MessageBox.Show("手术还没有结束,请填写 手术结束时间和出室时间!", "系统提示");
return;
}
if (txtOperationEnd.CustomFormat == " ")
{
txtOperationEnd.BackColor = Color.Red;
MessageBox.Show("手术还没有结束,请填写手术结束时间!", "系统提示");
return;
}
if (txtOutRoom.CustomFormat == " ")
{
txtOutRoom.BackColor = Color.Red;
MessageBox.Show("手术还没有结束,请填写出室时间!", "系统提示");
return;
}
}
try
{
mPanes = new List<MasterPane>();
UpPanes = new List<MasterPane>();
while (_record.pageCount != 1)
{
btnUpPage_Click(null, null);
}
PrintDocPage(null, null);
count = 0;
int pylWidth = 3;
System.Drawing.Printing.PrintDocument pDoc = new System.Drawing.Printing.PrintDocument();
pDoc.DefaultPageSettings.Landscape = false;
pDoc.OriginAtMargins = true;
pDoc.DefaultPageSettings.PrinterResolution.Kind = PrinterResolutionKind.High;
pDoc.DefaultPageSettings.Margins = new Margins(pylWidth, 0, 0, 0);
pDoc.PrintPage -= new PrintPageEventHandler(pDoc_PrintPage);
pDoc.PrintPage += new PrintPageEventHandler(pDoc_PrintPage);
System.Windows.Forms.PrintDialog pDlg = new System.Windows.Forms.PrintDialog();
pDlg.Document = pDoc;
if (pDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
pDoc.Print();
}
ControlExtension.UPDocument(_record.PatientId.Value, _record.OperationApplyId.Value, _record.Id.Value, _record.RecoverId.Value, "40,50", "麻醉记录单");
PublicMethod.WriteLog("打印麻醉记录单", _record.PatientId.Value, 1, "麻醉");
count = 0;
}
catch (Exception exp)
{
PublicMethod.WriteLog(exp, "");
}
}
private void plPrintBrowse_Click(object sender, EventArgs e)
{
if (_record == null || _record.Id == 0) return;
plPrintBrowse.Select();
SelectWorkerValue.Hidden();
SelectDictValue.Hidden();
SelectDictText.Hidden();
if (_record.SAreaObj != null && _record.SAreaObj.Selected == true)
{
_record.SAreaObj.Clear();
}
if (_record.SelPhysioConfig != null)
{
_record.SelPhysioConfig.IsClick = false;
_record.SelPhysioConfig.onClick(e);
_record.SelPhysioConfig = null;
}
templateManage2.BindOperationRecordValueAll(templateManage2.OpeRecord);
templateManage2.Bind();
zgcAnaesRecord2.Refresh();
panel8.VerticalScroll.Value = 0;
panel82.VerticalScroll.Value = 0;
paneltop.Visible = false;
mPanes = new List<MasterPane>();
UpPanes = new List<MasterPane>();
PrintDocPage(null, null);
count = 0;
System.Drawing.Printing.PrintDocument pDoc = new System.Drawing.Printing.PrintDocument();
pDoc.DefaultPageSettings.Landscape = false;
if (templateManage.Typesetting == TypesettingEnum.Horizontal)
{
pDoc.DefaultPageSettings.Landscape = true;
}
pDoc.OriginAtMargins = true;
pDoc.DefaultPageSettings.PrinterResolution.Kind = PrinterResolutionKind.High;
pDoc.DefaultPageSettings.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0);
pDoc.PrintPage -= new PrintPageEventHandler(pDoc_PrintPage);
pDoc.PrintPage += new PrintPageEventHandler(pDoc_PrintPage);
PrintPreviewDialog pdg = new PrintPreviewDialog();
foreach (Control ctl in pdg.Controls)
{
if (ctl is ToolStrip)
{
ToolStrip toolbar = ctl as ToolStrip;
toolbar.Items.RemoveAt(0);
ToolStrip tb = ctl as ToolStrip;
ToolStripButton settingBtn4 = new ToolStripButton();
settingBtn4.ToolTipText = "打印全部正面";
settingBtn4.Text = "打印全部正面";
settingBtn4.Click += PageSetting_Click4;
tb.Items.Insert(0, settingBtn4);
ToolStripButton settingBtn3 = new ToolStripButton();
settingBtn3.ToolTipText = "打印反面";
settingBtn3.Text = "打印反面";
settingBtn3.Click += PageSetting_Click3;
tb.Items.Insert(0, settingBtn3);
ToolStripButton settingBtn2 = new ToolStripButton();
settingBtn2.ToolTipText = "打印正面";
settingBtn2.Text = "打印正面";
settingBtn2.Click += PageSetting_Click2;
tb.Items.Insert(0, settingBtn2);
ToolStripButton settingBtn = new ToolStripButton();
settingBtn.ToolTipText = "打印全部";
settingBtn.Text = "打印全部";
settingBtn.Click += PageSetting_Click;
tb.Items.Insert(0, settingBtn);
}
}
pdg.PrintPreviewControl.Columns = 2;
pdg.Width = zgcAnaesRecord.Width + 50;
pdg.ClientSize = new System.Drawing.Size(zgcAnaesRecord.Width, zgcAnaesRecord.Height);
Form f = (Form)pdg;
f.WindowState = FormWindowState.Maximized;
pdg.Document = pDoc;
pdg.PrintPreviewControl.Zoom = 1;
pdg.ShowDialog();
pdg.Focus();
}
private void PageSetting_Click(object sender, EventArgs e)
{
plPrint_Click(null, null);
}
private void PageSetting_Click2(object sender, EventArgs e)
{
mPanes = new List<MasterPane>();
UpPanes = new List<MasterPane>();
while (_record.pageCount != 1)
{
btnUpPage_Click(null, null);
}
PrintDocPane(null, zgcAnaesRecord, templateManage, true);
count = 0;
int pylWidth = 3;
System.Drawing.Printing.PrintDocument pDoc = new System.Drawing.Printing.PrintDocument();
pDoc.DefaultPageSettings.Landscape = false;
pDoc.OriginAtMargins = true;
pDoc.DefaultPageSettings.PrinterResolution.Kind = PrinterResolutionKind.High;
pDoc.DefaultPageSettings.Margins = new Margins(pylWidth, 0, 0, 0);
pDoc.PrintPage -= new PrintPageEventHandler(pDoc_PrintPage);
pDoc.PrintPage += new PrintPageEventHandler(pDoc_PrintPage);
System.Windows.Forms.PrintDialog pDlg = new System.Windows.Forms.PrintDialog();
pDlg.Document = pDoc;
if (pDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
pDoc.Print();
}
}
private void PageSetting_Click3(object sender, EventArgs e)
{
mPanes = new List<MasterPane>();
UpPanes = new List<MasterPane>();
while (_record.pageCount != 1)
{
btnUpPage_Click(null, null);
}
PrintDocPane(null, zgcAnaesRecord2, templateManage2, false);
count = 0;
int pylWidth = 3;
System.Drawing.Printing.PrintDocument pDoc = new System.Drawing.Printing.PrintDocument();
pDoc.DefaultPageSettings.Landscape = false;
pDoc.OriginAtMargins = true;
pDoc.DefaultPageSettings.PrinterResolution.Kind = PrinterResolutionKind.High;
pDoc.DefaultPageSettings.Margins = new Margins(pylWidth, 0, 0, 0);
pDoc.PrintPage -= new PrintPageEventHandler(pDoc_PrintPage);
pDoc.PrintPage += new PrintPageEventHandler(pDoc_PrintPage);
System.Windows.Forms.PrintDialog pDlg = new System.Windows.Forms.PrintDialog();
pDlg.Document = pDoc;
if (pDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
pDoc.Print();
}
}
private void PageSetting_Click4(object sender, EventArgs e)
{
mPanes = new List<MasterPane>();
UpPanes = new List<MasterPane>();
while (_record.pageCount != 1)
{
btnUpPage_Click(null, null);
}
for (int i = 1; i <= _record.pageCount; i++)
{
PrintDocPane(null, zgcAnaesRecord, templateManage, true);
btnNextPage_Click(null, null);
}
count = 0;
int pylWidth = 3;
System.Drawing.Printing.PrintDocument pDoc = new System.Drawing.Printing.PrintDocument();
pDoc.DefaultPageSettings.Landscape = false;
pDoc.OriginAtMargins = true;
pDoc.DefaultPageSettings.PrinterResolution.Kind = PrinterResolutionKind.High;
pDoc.DefaultPageSettings.Margins = new Margins(pylWidth, 0, 0, 0);
pDoc.PrintPage -= new PrintPageEventHandler(pDoc_PrintPage);
pDoc.PrintPage += new PrintPageEventHandler(pDoc_PrintPage);
System.Windows.Forms.PrintDialog pDlg = new System.Windows.Forms.PrintDialog();
pDlg.Document = pDoc;
if (pDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
pDoc.Print();
}
}
private void PrintDocPage(object sender, PrintPageEventArgs e)
{
if (_record.currentPage == 1)
{
PrintDocPane(e, zgcAnaesRecord, templateManage, true);
PrintDocPane(e, zgcAnaesRecord2, templateManage2, false);
}
else
{
for (int i = 1; i <= _record.pageCount; i++)
{
PrintDocPane(e, zgcAnaesRecord, templateManage, true);
if (i == 1)
{
PrintDocPane(e, zgcAnaesRecord2, templateManage2, false);
}
btnNextPage_Click(null, null);
if (i != 1)
{
MasterPane mPane = new MasterPane();
mPane.Border.IsVisible = false;
mPanes.Add(mPane);
}
}
}
}
private void PrintDocPane(PrintPageEventArgs e, ZedGraphControl zedGraph, TemplateManage template, bool InitChart)
{
foreach (AreaManageBase area in template.ManageList)
{
area.setPrint(false);
area.BindTempData();
}
int zedGraphMainWidth = zedGraph.Size.Width;
int zedGraphMainHeight = zedGraph.Size.Height;
int width = 825;
int height = Convert.ToInt32(width * 1.414) + 2;
zedGraph.Size = new Size(width, height);
zedGraph.Width = width;
zedGraph.Height = height;
if (InitChart == true)
foreach (PhysioDataConfig pp in _record.PhysioConfigList)
{
if (pp.ShowText == true)
{
pp.IsValid = false;
///重新设置曲线属性
pp.reSetCurveSpo2();
}
}
TipBox.Hidden();
MasterPane mPane = zedGraph.MasterPane; //this.MasterPane;
mPane.Border.IsVisible = false;
//当前窗体中的矩形区域大小
RectangleF saveRect = mPane.Rect;
if (InitChart == true)
template.initChart();
mPanes.Add(mPane.Clone());
if (e != null)
mPane.Draw(e.Graphics); //在打印文档中画出MasterPane内容
using (Graphics g = zedGraph.CreateGraphics())
{
mPane.ReSize(g, saveRect);
}
zedGraph.Size = new Size(zedGraphMainWidth, zedGraphMainHeight);
if (InitChart == true)
template.initChart();
UpPanes.Add(mPane.Clone());
if (InitChart == true)
foreach (PhysioDataConfig pp in _record.PhysioConfigList)
{
if (pp.ShowText == true)
{
pp.IsValid = true;
///重新设置曲线属性
pp.reSetCurveSpo2();
}
}
if (InitChart == false)
{
int LocationY = Convert.ToInt32(templateManage2.ZedControl.Height * 0.065);
templateManage2.LocationY = LocationY;
templateManage2.SetPYL();
foreach (AreaManageBase area in template.ManageList)
{
area.setPrint(true);
}
}
else
{
int LocationY = Convert.ToInt32(templateManage.ZedControl.Height * 0.04);
templateManage.LocationY = LocationY;
templateManage.SetPYL();
foreach (AreaManageBase area in template.ManageList)
{
area.setPrint(true);
}
}
}
private void pDoc_PrintPage(object sender, PrintPageEventArgs e)
{
System.Drawing.Printing.PrintDocument pDoc = sender as System.Drawing.Printing.PrintDocument;
m_startPrintPage = pDoc.PrinterSettings.FromPage;
m_endPrintPage = pDoc.PrinterSettings.ToPage;
int printCount = mPanes.Count;
if (mPanes.Count > 0 && count < printCount)
{
mPanes[count].Draw(e.Graphics);
count++;
if (count < printCount)
{
e.HasMorePages = true;
}
}
else
{
e.HasMorePages = false;
}
}
#endregion
#region
/// <summary>
/// 手术特殊事件时间点处理事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void txtDateTime_MouseDown(object sender, MouseEventArgs e)
{
if (PatientId == 0) return;
DateTimeInput tb = sender as DateTimeInput;
//if (_record != null && _record.OutRoomTime != null)
//{
// if ((tb.Name == "txtBG" || tb.Name == "txtCG") && tb.Text.Trim() == "")
// {
// return;
// }
//}
if (tb.Text.Trim() == "" && tb.CustomFormat == " ")
{
tb.BackColor = Color.White;
SetPic(sender);
}
else
{
tb.CustomFormat = "HH:mm";
tb.ButtonDropDown.Visible = true;
}
}
private void txtDateTime_LostFocus(object sender, EventArgs e)
{
if (PatientId == 0) return;
DateTimeInput tb = sender as DateTimeInput;
if (tb.CustomFormat == "HH:mm")
{
if (tb.Name == "txtInRoom" || tb.Name == "txtOutRoom")
{
tb.CustomFormat = "MM-dd HH:mm";
}
tb.ButtonDropDown.Visible = false;
}
if (tb.Text.Trim() != "" && tb.Value.ToString() != tb.Tag.ToString())
{
try
{
SetPic(sender, tb.Value);
tb.BackColor = Color.White;
}
catch (Exception)
{
tb.Focus();
tb.Value = DateTime.Parse(tb.Tag.ToString());
return;
}
}
else
{
if (tb.Tag != null && tb.Tag.ToString() != "")
tb.Value = DateTime.Parse(tb.Tag.ToString());
}
}
private void dateTimePicker_KeyUp(object sender, KeyEventArgs e)
{
if (PatientId == 0) return;
DateTimeInput dtpak = (DateTimeInput)sender;
if (e.KeyCode == Keys.Delete || e.KeyCode == Keys.Back)
{
if (dtpak.CustomFormat != " " && dtpak.Tag != null)
{
try
{
SetPic((DateTimeInput)sender);
}
catch (Exception)
{
//PublicMethod.ShowMessage("输入的时间格式不符合规范(HH:mm)");
return;
}
}
}
}
/// <summary>
/// 特殊事件触发时设置图片
/// </summary>
/// <param name="obj">显示时间的控件</param>
private void SetPic(Object obj)
{
DrawGraph.FactEvents Inevent = null;
DateTimeInput tb = obj as DateTimeInput;
DateTime nowtime = DateTime.Now;// getOpeMaxTime();
DateTime curTimeTemp = new DateTime(nowtime.Year, nowtime.Month, nowtime.Day, nowtime.Hour, nowtime.Minute, 0);
InsertOrUpdateEventTime(0, "txtInRoom", "入室", tb, curTimeTemp, ref Inevent);
curTimeTemp = curTimeTemp.AddSeconds(2);
InsertOrUpdateEventTime(0, "txtAnaesthesiaBegin", "麻醉开始", tb, curTimeTemp, ref Inevent);
curTimeTemp = curTimeTemp.AddSeconds(2);
InsertOrUpdateEventTime(0, "txtCG", cmbCGType.Text, tb, curTimeTemp, ref Inevent);
curTimeTemp = curTimeTemp.AddSeconds(2);
InsertOrUpdateEventTime(0, "txtBG", cmbBGType.Text, tb, curTimeTemp, ref Inevent);
curTimeTemp = curTimeTemp.AddSeconds(2);
InsertOrUpdateEventTime(0, "txtOperationBegin", "手术开始", tb, curTimeTemp, ref Inevent);
curTimeTemp = curTimeTemp.AddSeconds(2);
InsertOrUpdateEventTime(0, "txtOperationEnd", "手术结束", tb, curTimeTemp, ref Inevent);
curTimeTemp = curTimeTemp.AddSeconds(2);
InsertOrUpdateEventTime(0, "txtAnaesthesiaEnd", "麻醉完成", tb, curTimeTemp, ref Inevent);
curTimeTemp = curTimeTemp.AddSeconds(2);
InsertOrUpdateEventTime(0, "txtOutRoom", "出室", tb, curTimeTemp, ref Inevent);
if (Inevent != null)
{
_record.FactEventsList.Add(Inevent);
if (Inevent.EventName == "入室")
{
_record.pageCount = 0;
ReviewEvent();
}
else if (Inevent.EventName == "手术开始" || Inevent.EventName == "出室" || Inevent.EventBeginTime > _record.lastPageBegin)
{
ReviewEvent();
}
else
{
DrawEvent();
}
PublicMethod.WriteLog(Inevent.EventName, _record.PatientId.Value, 1, "麻醉");
}
}
/// <summary>
/// 特殊事件触发时设置图片
/// </summary>
/// <param name="obj">显示时间的控件</param>
private void SetPic(Object obj, DateTime curTimeTemp)
{
DrawGraph.FactEvents Inevent = null;
DateTimeInput tb = obj as DateTimeInput;
curTimeTemp = new DateTime(curTimeTemp.Year, curTimeTemp.Month, curTimeTemp.Day, curTimeTemp.Hour, curTimeTemp.Minute, 0);
//try
//{
// if (curTimeTemp.Date < _record.PlanOperationTime.AddDays(-3).Date)
// {
// tb.Focus();
// tb.Value = DateTime.Parse(tb.Tag.ToString());
// return;
// }
//}
//catch (Exception)
//{
//}
InsertOrUpdateEventTime(1, "txtInRoom", "入室", tb, curTimeTemp, ref Inevent);
curTimeTemp = curTimeTemp.AddSeconds(2);
InsertOrUpdateEventTime(1, "txtAnaesthesiaBegin", "麻醉开始", tb, curTimeTemp, ref Inevent);
curTimeTemp = curTimeTemp.AddSeconds(2);
InsertOrUpdateEventTime(1, "txtOperationBegin", "手术开始", tb, curTimeTemp, ref Inevent);
curTimeTemp = curTimeTemp.AddSeconds(2);
InsertOrUpdateEventTime(1, "txtCG", cmbCGType.Text, tb, curTimeTemp, ref Inevent);
curTimeTemp = curTimeTemp.AddSeconds(2);
InsertOrUpdateEventTime(1, "txtBG", cmbBGType.Text, tb, curTimeTemp, ref Inevent);
curTimeTemp = curTimeTemp.AddSeconds(2);
InsertOrUpdateEventTime(1, "txtOperationEnd", "手术结束", tb, curTimeTemp, ref Inevent);
curTimeTemp = curTimeTemp.AddSeconds(2);
InsertOrUpdateEventTime(1, "txtAnaesthesiaEnd", "麻醉完成", tb, curTimeTemp, ref Inevent);
curTimeTemp = curTimeTemp.AddSeconds(2);
InsertOrUpdateEventTime(1, "txtOutRoom", "出室", tb, curTimeTemp, ref Inevent);
if (Inevent != null)
{
if (Inevent.EventName == "入室")
{
_record.pageCount = 0;
ReviewEvent();
}
else if (Inevent.EventName == "出室" || Inevent.EventName == "手术开始" || Inevent.EventBeginTime > _record.lastPageBegin)
{
ReviewEvent();
}
else
{
DrawEvent();
}
PublicMethod.WriteLog("修改" + Inevent.EventName, _record.PatientId.Value, 1, "麻醉");
}
}
/// <summary>
/// 特殊事件触发时设置图片
/// </summary>
/// <param name="obj">显示时间的控件</param>
private void SetPic(DateTimeInput obj)
{
DrawGraph.FactEvents Inevent = null;
DateTimeInput tb = obj as DateTimeInput;
if (_record.StateName == "手术中" || tb.Name.Equals("txtCG") || tb.Name.Equals("txtBG"))
{
DeleteEventTime("txtAnaesthesiaBegin", "麻醉开始", tb, ref Inevent);
DeleteEventTime("txtOperationBegin", "手术开始", tb, ref Inevent);
DeleteEventTime("txtOperationEnd", "手术结束", tb, ref Inevent);
DeleteEventTime("txtAnaesthesiaEnd", "麻醉完成", tb, ref Inevent);
DeleteEventTime("txtCG", cmbCGType.Text, tb, ref Inevent);
DeleteEventTime("txtBG", cmbBGType.Text, tb, ref Inevent);
}
else
{
MessageBox.Show("选择的事件不可删除 只可修改!");
}
if (Inevent != null)
{
tb.ButtonDropDown.Visible = false;
_record.FactEventsList.Remove(Inevent);
DrawEvent();
PublicMethod.WriteLog("删除" + Inevent.EventName, _record.PatientId.Value, 1, "麻醉");
}
}
/// <summary>
/// 判断控件对应的事件 删除事件
/// </summary>
/// <param name="EventTxtName">事件对应的控件名称</param>
/// <param name="EventName">事件名称</param>
/// <param name="tb">控件</param>
private void DeleteEventTime(string EventTxtName, string EventName, DateTimeInput tb, ref DrawGraph.FactEvents Inevent)
{
if (tb.Name.Equals(EventTxtName))
{
List<DrawGraph.FactEvents> list = _record.FactEventsList.Where(c => c.EventName == EventName).ToList();
if (list.Count <= 0) return;
Inevent = list[0];
if (EventName == "入室" || EventName == "出室")
{
//PublicMethod.ShowMessage("该事件为主要事件 不可删除 只可修改!!");
tb.Value = Inevent.EventBeginTime.Value;
Inevent = null;
return;
}
BFactEvents.DeleteById(Inevent.Id.ToString());
Inevent.clearAddObj(zgcAnaesRecord);
tb.CustomFormat = " ";
tb.Value = DateTime.Now;
tb.Tag = null;
if (Inevent != null && Inevent.EventName == "麻醉开始")
{
_record.AnesthesiaBeginTime = null;
this.picAnesBegin.BackgroundImage = global::AIMSControls.Properties.Resources.;
BOperationRecord.Update("AnesthesiaBeginTime=null where Id=@id ", new AIMSModel.ParameterList("@id", _record.Id));
}
if (Inevent != null && Inevent.EventName == "手术开始")
{
_record.OperationBeginTime = null;
this.picOpeBegin.BackgroundImage = global::AIMSControls.Properties.Resources.;
BOperationRecord.Update(" OperationBeginTime=null where Id=@id ", new AIMSModel.ParameterList("@id", _record.Id));
}
if (Inevent != null && Inevent.EventName == "手术结束")
{
_record.OperationEndTime = null;
this.picOpeEnd.BackgroundImage = global::AIMSControls.Properties.Resources.;
BOperationRecord.Update(" OperationEndTime=null where Id=@id ", new AIMSModel.ParameterList("@id", _record.Id));
}
if (Inevent != null && Inevent.EventName == "麻醉完成")
{
_record.AnesthesiaEndTime = null;
this.picAnesEnd.BackgroundImage = global::AIMSControls.Properties.Resources.;
BOperationRecord.Update(" AnesthesiaEndTime=null where Id=@id ", new AIMSModel.ParameterList("@id", _record.Id));
}
if (Inevent != null && Inevent.EventName == cmbCGType.Text)
{
_record.InCGType = "";
_record.SpileInTime = null;
this.picCG.BackgroundImage = global::AIMSControls.Properties.Resources.;
BOperationRecord.Update(" SpileInTime=null where Id=@id ", new AIMSModel.ParameterList("@id", _record.Id));
UpdatePhysioDataResp();
}
if (Inevent != null && Inevent.EventName == cmbBGType.Text)
{
_record.InBGType = "";
_record.SpileOutTime = null;
this.picBG.BackgroundImage = global::AIMSControls.Properties.Resources.;
BOperationRecord.Update(" SpileOutTime=null where Id=@id ", new AIMSModel.ParameterList("@id", _record.Id));
UpdatePhysioDataResp();
}
}
}
/// <summary>
/// 判断控件对应的事件 插入事件
/// </summary>
/// <param name="state">0插入 1更新</param>
/// <param name="EventTxtName">事件对应的控件名称</param>
/// <param name="EventName">事件名称</param>
/// <param name="EventTime">事件对应的对象时间</param>
/// <param name="tb">控件</param>
/// <param name="curTimeTemp">事件时间</param>
/// <param name="Inevent">事件对象</param>
private void InsertOrUpdateEventTime(int state, string EventTxtName, string EventName, DateTimeInput tb, DateTime curTimeTemp, ref DrawGraph.FactEvents Inevent)
{
if (tb.Name.Equals(EventTxtName))
{
string messing = "";
bool timeistrue = true;
timeistrue = BOperationRecord.IfTimeisTrue(true, _record, EventName, curTimeTemp, ref messing);
if (_record.StateName != null && _record.StateName != "手术中")
{
if (messing != "")
{
MessageBox.Show(messing);
}
}
else
{ timeistrue = true; }
if (EventName == "出室" && _record.StateName == "手术中" && state == 0)
{
if (GetOpeState(ref messing) == false)
{
if (messing != "") MessageBox.Show(messing, "系统提示");
if (messing == "请与手术信息选择手术分级!" || messing == "请与手术信息选择手术切口!")
btnOperationInfo_Click(null, null);
return;
}
}
if (timeistrue == false)
{
if (tb.Tag != null) tb.Value = DateTime.Parse(tb.Tag.ToString());
return;
}
if (EventName == "出室" && curTimeTemp.ToString("yyyy-MM-dd HH:mm") == _record.lastPageBegin.ToString("yyyy-MM-dd HH:mm"))
{
curTimeTemp = _record.lastPageBegin;
}
if (state == 0)
{
Inevent = BFactEvents.Insert(PatientId, EventName, curTimeTemp, curTimeTemp, RecoverId);
}
else if (state == 2)
{
string eventName = "";
if (EventName == "插管" || EventName == "喉罩") eventName = "'3','9'";
if (EventName == "拔管" || EventName == "拔喉罩") eventName = "'4','10'";
BFactEvents.Delete(" EventId in (" + eventName + ") and PatientId=" + PatientId, null);
Inevent = BFactEvents.Insert(PatientId, EventName, curTimeTemp, curTimeTemp, RecoverId);
}
else
{
updateEventTime(EventName, curTimeTemp, ref Inevent);
}
tb.Value = curTimeTemp;
tb.Tag = curTimeTemp;
if (Inevent != null && Inevent.EventName == "入室" && _record.InRoomTime != Inevent.EventBeginTime)
{
_record.InRoomTime = Inevent.EventBeginTime;
this.picInRoom.BackgroundImage = global::AIMSControls.Properties.Resources._select;
BOperationRecord.Update("InRoomTime=@InRoom where Id=@id ", new AIMSModel.ParameterList("@InRoom", _record.InRoomTime.Value.ToString("yyyy-MM-dd HH:mm:ss"), "@id", _record.Id));
//try
//{
// if (State != AIMSExtension.EditState.BROWSE && _record.StateName == "手术中" && NowRoom != null && isReadOnly == false)
// {
// //没有IP判断
// DataTable dtPhysioData = BOperationRecord.getPhysioDataByIp(NowRoom.Ip, _record.Id.Value, _record.InRoomTime.Value, getOpeMaxTime(_record), 5);
// if (dtPhysioData.Rows.Count > 0)
// {
// foreach (var addPP in _record.PhysioConfigList)
// {
// addPP.clearAddObj(zgcAnaesRecord);
// }
// BOperationRecord.DeletePhysioDataByOpeID(_record.Id.Value);
// //同步未画点数据
// DrawFillPhysioData(dtPhysioData);
// }
// }
//}
//catch (Exception ex)
//{
// PublicMethod.WriteLog(ex);
//}
}
if (Inevent != null && Inevent.EventName == "麻醉开始" && _record.AnesthesiaBeginTime != Inevent.EventBeginTime)
{
_record.AnesthesiaBeginTime = Inevent.EventBeginTime;
this.picAnesBegin.BackgroundImage = global::AIMSControls.Properties.Resources._select;
BOperationRecord.Update("AnesthesiaBeginTime=@AnesthesiaBeginTime where Id=@id ", new AIMSModel.ParameterList("@AnesthesiaBeginTime", _record.AnesthesiaBeginTime.Value.ToString("yyyy-MM-dd HH:mm:ss"), "@id", _record.Id));
}
if (Inevent != null && Inevent.EventName == "手术开始" && _record.OperationBeginTime != Inevent.EventBeginTime)
{
_record.OperationBeginTime = Inevent.EventBeginTime;
this.picOpeBegin.BackgroundImage = global::AIMSControls.Properties.Resources._select;
BOperationRecord.Update("OperationBeginTime=@OperationBegin where Id=@id ", new AIMSModel.ParameterList("@OperationBegin", _record.OperationBeginTime.Value.ToString("yyyy-MM-dd HH:mm:ss"), "@id", _record.Id));
}
if (Inevent != null && Inevent.EventName == cmbCGType.Text && _record.SpileInTime != Inevent.EventBeginTime)
{
_record.InCGType = cmbCGType.Text;
_record.SpileInTime = Inevent.EventBeginTime;
this.picCG.BackgroundImage = global::AIMSControls.Properties.Resources._select;
BOperationRecord.Update(" SpileInTime=@SpileIn where Id=@id ", new AIMSModel.ParameterList("@SpileIn", _record.SpileInTime.Value.ToString("yyyy-MM-dd HH:mm:ss"), "@id", _record.Id));
UpdatePhysioDataResp();
}
if (Inevent != null && Inevent.EventName == cmbBGType.Text && _record.SpileOutTime != Inevent.EventBeginTime)
{
_record.InBGType = cmbBGType.Text;
_record.SpileOutTime = Inevent.EventBeginTime;
this.picBG.BackgroundImage = global::AIMSControls.Properties.Resources._select;
BOperationRecord.Update(" SpileOutTime=@SpileOut where Id=@id ", new AIMSModel.ParameterList("@SpileOut", _record.SpileOutTime.Value.ToString("yyyy-MM-dd HH:mm:ss"), "@id", _record.Id));
UpdatePhysioDataResp();
}
if (Inevent != null && Inevent.EventName == "手术结束" && _record.OperationEndTime != Inevent.EventBeginTime)
{
_record.OperationEndTime = Inevent.EventBeginTime;
this.picOpeEnd.BackgroundImage = global::AIMSControls.Properties.Resources._select;
BOperationRecord.Update("OperationEndTime=@OperationEnd where Id=@id ", new AIMSModel.ParameterList("@OperationEnd", _record.OperationEndTime.Value.ToString("yyyy-MM-dd HH:mm:ss"), "@id", _record.Id));
}
if (Inevent != null && Inevent.EventName == "麻醉完成" && _record.AnesthesiaEndTime != Inevent.EventBeginTime)
{
_record.AnesthesiaEndTime = Inevent.EventBeginTime;
this.picAnesEnd.BackgroundImage = global::AIMSControls.Properties.Resources._select;
BOperationRecord.Update("AnesthesiaEndTime=@AnesthesiaEndTime where Id=@id ", new AIMSModel.ParameterList("@AnesthesiaEndTime", _record.AnesthesiaEndTime.Value.ToString("yyyy-MM-dd HH:mm:ss"), "@id", _record.Id));
}
if (Inevent != null && Inevent.EventName == "出室" && _record.OutRoomTime != Inevent.EventBeginTime)
{
_record.OutRoomTime = Inevent.EventBeginTime;
this.picOutRoom.BackgroundImage = global::AIMSControls.Properties.Resources._select;
BOperationRecord.Update("OutRoomTime=@OutRoom where Id=@id ", new AIMSModel.ParameterList("@OutRoom", _record.OutRoomTime.Value.ToString("yyyy-MM-dd HH:mm:ss"), "@id", _record.Id));
}
}
}
/// <summary>
/// 修改事件时间
/// </summary>
/// <param name="eventName"></param>
/// <param name="dt"></param>
public void updateEventTime(string eventName, DateTime dt, ref DrawGraph.FactEvents elist)
{
List<DrawGraph.FactEvents> list = _record.FactEventsList.Where(c => c.EventName == eventName).ToList();
if (list.Count <= 0) return;
elist = list[0];
if (elist.EventBeginTime != dt)
{
elist.EventBeginTime = dt;
elist.EventEndTime = dt;
BFactEvents.Update("EventBeginTime=@EventBeginTime,EventEndTime=@EventEndTime where id=@id ", new AIMSModel.ParameterList("@EventBeginTime", elist.EventBeginTime, "@EventEndTime", elist.EventEndTime, "@id", elist.Id));
}
}
#endregion
#region
private void panel8_Scroll(object sender, ScrollEventArgs e)
{
if (templateManage != null)
templateManage.SetPYL();
paneltop.Location = new Point(0, paneltop.VerticalScroll.Value);
if (panel8.VerticalScroll.Value > 240)
{
paneltop.Width = panel8.Width - 50;
paneltop.Visible = true;
}
else
{
paneltop.Visible = false;
}
}
private void panel82_Scroll(object sender, ScrollEventArgs e)
{
if (templateManage2 != null)
templateManage2.SetPYL();
}
private void panel8_MouseWheel(object sender, MouseEventArgs e)
{
if (templateManage != null)
templateManage.SetPYL();
paneltop.Location = new Point(0, paneltop.VerticalScroll.Value);
if (panel8.VerticalScroll.Value > 240)
{
paneltop.Width = panel8.Width - 50;
paneltop.Visible = true;
}
else
{
paneltop.Visible = false;
}
}
private void panel82_MouseWheel(object sender, MouseEventArgs e)
{
if (templateManage2 != null)
templateManage2.SetPYL();
}
private void plRefresh_Click(object sender, EventArgs e)
{
if (PatientId == 0) return;
plRefresh.Select();
//刷新到当前页
ReviewEvent();
}
private void btnUpPage_Click(object sender, EventArgs e)
{
if (PatientId == 0) return;
if (_record.pageCount == 1) return;
btnUpPage.Select();
SetUpPageTime();
ReviewEvent();
}
private void btnNextPage_Click(object sender, EventArgs e)
{
if (PatientId == 0) return;
if (_record.pageCount == _record.currentPage) return;
btnNextPage.Select();
SetNextPageTime();
ReviewEvent();
}
private void btnUpFsPage_Click(object sender, EventArgs e)
{
while (_record.pageCount != 1)
{
btnUpPage_Click(null, null);
}
}
private void btnNextEndPage_Click(object sender, EventArgs e)
{
while (_record.currentPage != _record.pageCount)
{
btnNextPage_Click(null, null);
}
}
public void SetUpPageTime()
{
if (_record.PageBegin < _record.sharpBegin) return;
_record.lastPageBegin = _record.PageBegin;
_record.PageBegin = _record.PageBegin.AddMinutes(-240);
_record.pageCount--;
if (_record.pageCount < 1) _record.pageCount = 1;
if (_record.phListPack != null)
{
Panel pan3 = _record.phListPack.CControl as Panel;
if (pan3 != null)
{
pan3.Controls.Clear();
}
}
}
public void SetNextPageTime()
{
//当下一页的开始时间,小于当前最大时间
DateTime curTimeTemp = getOpeMaxTime(_record);
if (_record.lastPageBegin > curTimeTemp) return;
//先设置新页的开始时间
_record.PageBegin = _record.lastPageBegin;
_record.lastPageBegin = _record.PageBegin.AddMinutes(240);
_record.pageCount++;
if (_record.pageCount > _record.currentPage) _record.pageCount = _record.currentPage;
if (_record.phListPack != null)
{
Panel pan3 = _record.phListPack.CControl as Panel;
if (pan3 != null)
{
pan3.Controls.Clear();
}
}
}
public DateTime getOpeMaxTime(OperationRecord myOpeRecord)
{
try
{
DateTime dts = BOperationRecord.lastMaxOperationDate(myOpeRecord.PatientId.Value, myOpeRecord.RecoverId.Value);
DateTime nowDate = DateTime.Now;
TimeSpan tsp = nowDate - dts;
if (tsp.TotalHours <= 12 && tsp.TotalDays <= 1 && dts < nowDate)//&& IsReview == false
{
dts = nowDate;
}
if (dts.ToString("yyyy-MM-dd HH:mm") == myOpeRecord.PageBegin.AddMinutes(240).ToString("yyyy-MM-dd HH:mm"))
{
dts = myOpeRecord.PageBegin.AddMinutes(240);
}
if (myOpeRecord.OutRoomTime != null)
{
DateTime outRoomTime = DateTime.Parse(myOpeRecord.OutRoomTime.ToString());
if (DateTime.Compare(dts, outRoomTime) > 0)
{
dts = outRoomTime;
}
}
return dts;
}
catch (Exception)
{
return DateTime.Now;
}
}
#endregion
#region
private void btnSelectPatient_Click(object sender, EventArgs e)
{
OperationAanesthesia.frmSelectPatientNew2 frmSelectPatient = new frmSelectPatientNew2();
frmSelectPatient.isMainOpen = true;
frmSelectPatient.tempfrmAnasRecord = this;
frmSelectPatient.FormClosed += new FormClosedEventHandler(frmSelectPatient_FormClosed);
frmSelectPatient.ShowDialog();
}
void frmSelectPatient_FormClosed(object sender, FormClosedEventArgs e)
{
LoadAnesRescue();
}
//private System.Windows.Forms.Timer timerLoadAnesRescue;
public void LoadAnesRescue()
{
circularProgress1.IsRunning = true;
circularProgress1.Visible = true;
circularProgress1.AnimationSpeed = 0;
circularProgress2.IsRunning = true;
circularProgress2.Visible = true;
zgcAnaesRecord.Visible = false;
zgcAnaesRecord2.Visible = false;
TimerLoadAnesRescue_Tick(null, null);
//timerLoadAnesRescue = new System.Windows.Forms.Timer(components);
//timerLoadAnesRescue.Enabled = true;//调试时设置为FALSE
//timerLoadAnesRescue.Interval = 200;
//timerLoadAnesRescue.Tick -= TimerLoadAnesRescue_Tick;
//timerLoadAnesRescue.Tick += TimerLoadAnesRescue_Tick;
//timerLoadAnesRescue.Start();
}
private void TimerLoadAnesRescue_Tick(object sender, EventArgs e)
{
//timerLoadAnesRescue.Dispose();
try
{
if (PatientId > 0 && State == AIMSExtension.EditState.ADD)
{
try
{
_record = new OperationRecord();
_record.OperationApplyId = ApplyId;
_record.PatientId = PatientId;
_record.RecoverId = RecoverId;
HelperDB.DbHelperSQL.BeginTrans();
_record.Id = BOperationRecord.AddTitleTime(PatientId, ApplyId, RecoverId, 1, DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd HH:mm:00")), NowRoom.Id.Value);
SelectPatient.UpdateApplyState(PatientId, ApplyId); //修改状态
HelperDB.DbHelperSQL.CommitTrans();
ClearTimeText();
btnSelectPatient.Enabled = false;
btnCancelOperation.Enabled = true;
btnCancelIn.Enabled = true;
DrawAnasReordBill.IniDrawAnasReordBill5(_record, zgcAnaesRecord, zgcAnaesRecord2, ref templateManage, ref templateManage2);
_record.ComputerRect = Screen.GetWorkingArea(this);
PublicMethod.WriteLog("入手术间", _record.PatientId.Value, 1, "麻醉");
StartTimer();
}
catch
{
HelperDB.DbHelperSQL.RollbackTrans();
this.Close();
}
}
else if (PatientId > 0 && State == AIMSExtension.EditState.EDIT)
{
_record = new OperationRecord();
btnSelectPatient.Enabled = false; //清空记录点并重新加载
btnCancelOperation.Enabled = true;
btnCancelIn.Enabled = true;
ClearTimeText();
if (templateManage != null)
{
templateManage.ControlClear();
}
if (templateManage2 != null)
{
templateManage2.ControlClear();
}
DrawAnasReordBill.IniDrawAnasReordBill5(_record, zgcAnaesRecord, zgcAnaesRecord2, ref templateManage, ref templateManage2);
_record.ComputerRect = Screen.GetWorkingArea(this);
StartTimer();
}
else if (PatientId > 0 && State == AIMSExtension.EditState.BROWSE)
{
_record = new OperationRecord();
btnSelectPatient.Enabled = true;
btnCancelOperation.Enabled = false;
btnCancelIn.Enabled = false;
LastMonitorDataTime = null;
LastAnesMonitorDataTime = null;
ClearTimeText();
if (templateManage != null)
{
templateManage.ControlClear();
}
if (templateManage2 != null)
{
templateManage2.ControlClear();
}
DrawAnasReordBill.IniDrawAnasReordBill5(_record, zgcAnaesRecord, zgcAnaesRecord2, ref templateManage, ref templateManage2);
_record.ComputerRect = Screen.GetWorkingArea(this);
StartTimer();
}
ReviewEvent();
if (_record.MedicalRecord != null && _record.MedicalRecord != "")
{
btnOutputLiquids.Enabled = false;
btnDrug.Enabled = false;
btnAddEvents.Enabled = false;
button6.Enabled = false;
btnBloodGasAnalysis.Enabled = false;
txtInRoom.Enabled = false;
txtAnaesthesiaBegin.Enabled = false;
txtOperationBegin.Enabled = false;
txtOperationEnd.Enabled = false;
txtAnaesthesiaEnd.Enabled = false;
txtOutRoom.Enabled = false;
txtCG.Enabled = false;
txtBG.Enabled = false;
isReadOnly = true;
}
circularProgress1.IsRunning = false;
circularProgress1.Visible = false;
zgcAnaesRecord.Visible = true;
circularProgress2.IsRunning = false;
circularProgress2.Visible = false;
zgcAnaesRecord2.Visible = true;
}
catch (Exception ex)
{
PublicMethod.WriteLog(ex);
}
}
private void _record_SpeedyDrugsParam(List<FactDrug> factDrugs, DateTime clickTime)
{
if (PatientId != 0)
{
if (factDrugs != null && factDrugs.Count > 0)
{
frmFactSpeedyDrug frmFact = new frmFactSpeedyDrug();
frmFact._record = _record;
frmFact.factDrugs = factDrugs;
frmFact.ClickTime = clickTime;
frmFact.zgcAnaesRecord = zgcAnaesRecord;
frmFact.DrugTypeId = RecoverId; // 事件类型 1 麻醉单事件 2 麻醉恢复单
frmFact.DrugsParam += FrmFactDrug_DrugsParam;
frmFact.ShowDialog();
}
else
{
PublicUI.UI.frmFactDrugNew frmFactDrug = new PublicUI.UI.frmFactDrugNew();
frmFactDrug._record = _record;
frmFactDrug.zgcAnaesRecord = zgcAnaesRecord;
frmFactDrug.ClickTime = clickTime;
frmFactDrug.DrugTypeId = RecoverId; // 事件类型 1 麻醉单事件 2 麻醉恢复单
frmFactDrug.DrugsParam += FrmFactDrug_DrugsParam;
frmFactDrug.ShowDialog();
}
}
}
private void btnOperationInfo_Click(object sender, EventArgs e)
{
if (PatientId != 0)
{
AIMS.OperationAanesthesia.frmOperationInfoNew2 frmOperationInfo = new frmOperationInfoNew2();
frmOperationInfo._record = _record;
//frmOperationInfo.FormClosed += new FormClosedEventHandler(plRefresh_Click);
frmOperationInfo.ShowDialog();
}
else
{
MessageBox.Show("请选择患者");
}
}
private void btnDrug_Click(object sender, EventArgs e)
{
if (PatientId != 0)
{
PublicUI.UI.frmFactDrugNew frmFactDrug = new PublicUI.UI.frmFactDrugNew();
frmFactDrug._record = _record;
frmFactDrug.zgcAnaesRecord = zgcAnaesRecord;
frmFactDrug.DrugTypeId = RecoverId; // 事件类型 1 麻醉单事件 2 麻醉恢复单
frmFactDrug.DrugsParam += FrmFactDrug_DrugsParam;
frmFactDrug.ShowDialog();
}
else
{
MessageBox.Show("请选择患者");
}
}
private void FrmFactDrug_DrugsParam()
{
templateManage.Bind("DrugsManage");
templateManage.Bind("SapManage");
templateManage.Bind("RemarkManage");
zgcAnaesRecord.Refresh();
}
private void btnAddEvents_Click(object sender, EventArgs e)
{
if (PatientId != 0)
{
PublicUI.UI.frmFactEventsNew frmFactEventsNew = new PublicUI.UI.frmFactEventsNew();
frmFactEventsNew._record = _record;
frmFactEventsNew.zgcAnaesRecord = zgcAnaesRecord;
frmFactEventsNew.EventTypeId = RecoverId; // 事件类型 1 麻醉单事件 2 麻醉恢复单
frmFactEventsNew.EventParam += frmFactEventsNew_EventsParam;
frmFactEventsNew.ShowDialog();
}
else
{
MessageBox.Show("请选择患者");
}
}
private void frmFactEventsNew_EventsParam()
{
if (txtInRoom.Value != _record.InRoomTime)
{
_record.pageCount = 0;
ReviewEvent();
}
else
{
DrawEvent();
}
}
private void btnOutputLiquids_Click(object sender, EventArgs e)
{
if (PatientId != 0)
{
PublicUI.UI.frmFactOutputLiquidsNew frmFactOutputLiquids = new PublicUI.UI.frmFactOutputLiquidsNew();
frmFactOutputLiquids._record = _record;
frmFactOutputLiquids.zgcAnaesRecord = zgcAnaesRecord;
frmFactOutputLiquids.OutputLiquidTypeId = RecoverId; // 事件类型 1 麻醉单事件 2 麻醉恢复单
frmFactOutputLiquids.OutParam += FrmFactOutputLiquids_OutParam;
frmFactOutputLiquids.ShowDialog();
}
else
{
MessageBox.Show("请选择患者");
}
}
private void FrmFactOutputLiquids_OutParam()
{
templateManage.Bind("OutputManage");
templateManage.Bind("RemarkManage");
zgcAnaesRecord.Refresh();
}
private void button6_Click(object sender, EventArgs e)
{
frmAanesthesiaQuality frmAnaseDataQuality = new frmAanesthesiaQuality();
frmAnaseDataQuality._record = _record;
frmAnaseDataQuality.ShowDialog();
}
private void btnCancelOperation_Click(object sender, EventArgs e)
{
if (PatientId == 0)
{
MessageBox.Show("请选择患者!");
return;
}
frmStopOperation frmStop = new frmStopOperation();
frmStop.tsbCancel.Text = " 停止手术";
frmStop.ApplyIdList = new List<int>() { _record.OperationApplyId.Value };
DialogResult ddr = frmStop.ShowDialog();
if (ddr == System.Windows.Forms.DialogResult.OK)
{
try
{
HelperDB.DbHelperSQL.BeginTrans();
BOperationApply.UpdateApplyState(ApplyId, 11);
BOperationRecord.UpdateOpeState(PatientId, 1, 5, frmStop.txtContent.Text.Trim());
HelperDB.DbHelperSQL.CommitTrans();
this.Close();
}
catch
{
HelperDB.DbHelperSQL.RollbackTrans();
}
}
}
private void btnCancelIn_Click(object sender, EventArgs e)
{
if (PatientId == 0)
{
MessageBox.Show("请选择患者!");
return;
}
if (BOperationRecord.GetDataCount(_record.Id.Value, PatientId, RecoverId) > 0)
{
MessageBox.Show("清除数据在进行取消转入操作!");
return;
}
if (MessageBox.Show("确认要取消转入吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
try
{
HelperDB.DbHelperSQL.BeginTrans();
BOperationApply.UpdateApplyState(ApplyId, 5);
BOperationRecord.DeleteOperationRecordData(_record.Id.Value, PatientId, RecoverId);
HelperDB.DbHelperSQL.CommitTrans();
PublicMethod.WriteLog("取消转入", _record.PatientId.Value, 0, "麻醉");
DisposeTimer();
//ClearData();
this.Close();
}
catch
{
HelperDB.DbHelperSQL.RollbackTrans();
}
}
}
private void btnTemplate_Click(object sender, EventArgs e)
{
if (PatientId == 0)
{
MessageBox.Show("请选择患者!");
return;
}
PublicUI.UI.frmTemplate frmTemplateObj = new PublicUI.UI.frmTemplate();
frmTemplateObj._record = _record;
frmTemplateObj.InRoomTime = _record.InRoomTime.Value;
frmTemplateObj.PatientId = PatientId;
frmTemplateObj.TypeId = 1;
DialogResult ddr = frmTemplateObj.ShowDialog();
if (ddr == System.Windows.Forms.DialogResult.OK)
{
ReviewEvent();
}
}
private void tsbExePlan_Click(object sender, EventArgs e)
{
if (PatientId == 0)
{
MessageBox.Show("请先选择患者!");
return;
}
if (_record.Applydiagnose == null || _record.Applydiagnose == "")
{
MessageBox.Show("请选择诊断后再填写文书!", "系统提示");
ModifyApply_Click(null, null);
return;
}
PatientRecord patient = PatientRecord.GetPatientRecord(PatientId);
frmDocument frmDoc = new frmDocument(patient);
frmDoc.StartPosition = FormStartPosition.CenterScreen;
frmDoc.WindowState = FormWindowState.Maximized;
frmDoc.Show();
frmDoc.BringToFront();
}
void toolStripMenuItem2_Click(object sender, EventArgs e)
{
frmPhysiosSetting frm = new frmPhysiosSetting();
frm.ConfigParam += new frmPhysiosSetting.ConfigParamHandler(templateManage.frmInstance_ConfigParam);
frm._record = _record;
frm.FormClosed += ((s, er) =>
{
if (PatientId == 0) return;
//刷新到当前页
ReviewEvent();
});
frm.ShowDialog();
}
private void btnBloodGasAnalysis_Click(object sender, EventArgs e)
{
if (PatientId != 0)
{
frmBloodGasAnalysisNew frmFactBloodGasAnalysis = new frmBloodGasAnalysisNew();
frmFactBloodGasAnalysis._record = _record;
frmFactBloodGasAnalysis.zgcAnaesRecord = zgcAnaesRecord;
frmFactBloodGasAnalysis.FormClosed += ((s, er) =>
{
reDrawAnalysis();
});
frmFactBloodGasAnalysis.ShowDialog();
}
else
{
MessageBox.Show("请选择患者");
}
}
private void reDrawAnalysis()
{
try
{
//图表的对象
TextPackObj janCePack = templateManage.GetPackObjectOTag<TextPackObj>("PhysioDataManage_TextPackObj_12");
LinePackObj H5pack = templateManage.GetPackObjectOTag<LinePackObj>("IconManage_LinePackObj_6");
foreach (FactBloodGasAnalysis analysis in _record.FactBloodGasAnalysisList)
{
analysis.clearAddObj(zgcAnaesRecord);
if (analysis.RecordTime.Value >= _record.PageBegin && analysis.RecordTime.Value < _record.lastPageBegin)
{
analysis.setAnasArr(zgcAnaesRecord, H5pack.RealX, H5pack.RealEndX, _record.PageBegin, _record.PageBegin.AddMinutes(240));
analysis.drawText(janCePack.RealEndX, janCePack.RealY);
}
}
if (_record.FactBloodGasAnalysisList != null && _record.FactBloodGasAnalysisList.Count > 0)
zgcAnaesRecord.Refresh();
}
catch (Exception exp)
{
PublicMethod.WriteLog(exp, "");
}
}
#endregion
#region
public DateTime? LastMonitorDataTime = null;
public DateTime? LastAnesMonitorDataTime = null;
private void timerGetCollectorData_Tick()
{
if (State == AIMSExtension.EditState.BROWSE || _record.StateName != "手术中" || NowRoom == null || isReadOnly == true) return;
if (_record.OutRoomTime != null && DateTime.Now >= _record.OutRoomTime) return;
DateTime dtTime = DateTime.Now;
//InRoomTime.Value
double span = ((TimeSpan)(dtTime - _record.PageBegin)).TotalSeconds % 300;
if (span < 10 || span > 12)
return;
if (LastMonitorDataTime != null && LastMonitorDataTime.Value.ToString("yyyy-MM-dd HH:mm") == dtTime.ToString("yyyy-MM-dd HH:mm")) return;
if (LastMonitorDataTime != null && LastMonitorDataTime.Value > dtTime) return;
try
{
PublicMethod.StartCollectorDataProgram();
LastMonitorDataTime = dtTime;
DateTime InsertTime = Convert.ToDateTime(dtTime.ToString("yyyy-MM-dd HH:mm:00.000"));
int date = 0;
List<PhysioData> physioDatas = new List<PhysioData>();
foreach (PhysioDataConfig addPP in _record.PhysioConfigList)
{
string key = addPP.Name;
string value = addPP.Enname;
if (addPP.IsValid == false) continue;
if (value == null || value == "") continue;
int minMinutes = -5;
DataTable dtPhysioData = BOperationRecord.getPhysioDataByTimeName(NowRoom.Ip, value, InsertTime.AddMinutes(minMinutes), InsertTime.AddSeconds(1));
if (dtPhysioData != null && dtPhysioData.Rows.Count > 0)
{
foreach (DataRow dr in dtPhysioData.Rows)
{
//if (Double.Parse(dr["ParamValue"].ToString()) <= 1) continue;
//if (key.Contains("压") && Double.Parse(dr["ParamValue"].ToString()) <= 30) continue;
if (!isCgtime(addPP.Name, dtTime)) continue;
PhysioData pdTemp = PhysioDataConfig.newPhysioData(addPP, _record.Id.Value, dtTime, dr["ParamValue"].ToString());
physioDatas.Add(pdTemp);
continue;
}
}
}
if (LastAnesMonitorDataTime == null || dtTime > LastAnesMonitorDataTime.Value.AddMinutes(9))
{
foreach (PhysioDataConfig addPP in _record.PhysioAnesConfigList)
{
string key = addPP.Name;
string value = addPP.Enname;
if (addPP.IsValid == false) continue;
if (value == null || value == "") continue;
if (_record.AnesthesiaBeginTime != null && InsertTime < _record.AnesthesiaBeginTime) continue;
LastAnesMonitorDataTime = dtTime;
int minMinutes = -5;
DataTable dtPhysioData = BOperationRecord.getPhysioDataByTimeName(NowRoom.Ip, value, InsertTime.AddMinutes(minMinutes), InsertTime.AddSeconds(1));
if (dtPhysioData != null && dtPhysioData.Rows.Count > 0)
{
foreach (DataRow dr in dtPhysioData.Rows)
{
PhysioData pdTemp = PhysioDataConfig.newPhysioData(addPP, _record.Id.Value, dtTime, dr["ParamValue"].ToString());
physioDatas.Add(pdTemp);
continue;
}
}
}
}
//有有创清空无创
foreach (var pdTemp in physioDatas)
{
if (pdTemp.PhysioDataConfigId == 7)
{
foreach (var temp in physioDatas)
{
if (temp.PhysioDataConfigId == 5)
{
temp.Value = -1;
}
}
}
if (pdTemp.PhysioDataConfigId == 8)
{
foreach (var temp in physioDatas)
{
if (temp.PhysioDataConfigId == 6)
{
temp.Value = -1;
}
}
}
}
//有机械呼吸情况自主呼吸
foreach (var pdTemp in physioDatas)
{
if (pdTemp.PhysioDataConfigId == 12)
{
foreach (var temp in physioDatas)
{
if (temp.PhysioDataConfigId == 3)
{
temp.Value = -1;
}
}
}
}
foreach (var pdTemp in physioDatas)
{
if (pdTemp.Value < 0) continue;
List<PhysioDataConfig> addPP = _record.PhysioConfigList.Where(a => pdTemp.PhysioDataConfigId == a.Id).ToList();
if (addPP == null || addPP.Count == 0)
{
addPP = _record.PhysioAnesConfigList.Where(a => pdTemp.PhysioDataConfigId == a.Id).ToList();
}
if (addPP != null && addPP.Count > 0)
{
addPP[0].AddPointItem(pdTemp);
date++;
}
}
if (dtTime > _record.lastPageBegin && ((TimeSpan)(dtTime - _record.lastPageBegin)).TotalHours < 24 && date > 0)
{
_record.currentPage++;
btnNextPage_Click(null, null);
}
zgcAnaesRecord.Refresh();
}
catch (Exception ex)
{
PublicMethod.WriteLog(ex);
}
}
public string szy;//舒张压
public string ssy;//收缩压
private void timerGetTextCollectorData_Tick(object sender, EventArgs e)
{
try
{
if (((TimeSpan)(DateTime.Now - _record.lastPageBegin)).TotalHours > 24 || NowRoom == null) return;
timerGetCollectorData_Tick();
if (State != AIMSExtension.EditState.BROWSE)
{
ShowMonitorDataToRight();
}
}
catch (Exception)
{
//PublicMethod.WriteLog(ex);
}
}
private BackgroundWorker backgroundWorker1;
public void ShowMonitorDataToRight()
{
this.backgroundWorker1 = new BackgroundWorker();
this.backgroundWorker1.WorkerReportsProgress = true;
this.backgroundWorker1.WorkerSupportsCancellation = true;
this.backgroundWorker1.DoWork += new DoWorkEventHandler(this.backgroundWorker1_DoWork);
this.backgroundWorker1.RunWorkerCompleted += new RunWorkerCompletedEventHandler(this.backgroundWorker1_RunWorkerCompleted);
this.backgroundWorker1.RunWorkerAsync();
}
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
BackgroundWorker worker = sender as BackgroundWorker;
List<DeviceCacheData> lists = DeviceCacheData.Select(" IPAddress='" + NowRoom.Ip + "' and UpdateTime>='" + DateTime.Now.AddSeconds(-300) + "'");
e.Result = lists;
}
private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
List<DeviceCacheData> lists = e.Result as List<DeviceCacheData>;
if (lists != null && lists.Count > 0)
{
DeviceCacheData deviceCacheData = lists[0];
NowPhysioData nowPhysioData = JsonConvert.DeserializeObject<NowPhysioData>(deviceCacheData.JsonData);
label11.Text = "最后采集时间:" + deviceCacheData.UpdateTime;
if (nowPhysioData.HR != null && nowPhysioData.HR.ToString() != string.Empty && nowPhysioData.HR.ToString() != "NaN" && nowPhysioData.HR.ToString() != "NULL")
{
double value = Double.Parse(nowPhysioData.HR.ToString());
lblHR.Text = 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());
lblRESP.Text = value <= 0 ? "- -" : value.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());
lblSpo2.Text = 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());
lblPR.Text = 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());
szy = 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());
ssy = 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());
szy = 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());
ssy = value <= 0 ? "" : value.ToString();
}
string szyssy = ssy + "/" + szy;
if (szyssy != "/")
lblDia.Text = szyssy;
}
else
{
label11.Text = "当前无采集数据";
lblHR.Text = "--";
lblRESP.Text = "--";
lblSpo2.Text = "--";
lblPR.Text = "--";
lblDia.Text = "---/---";
lblHR.ForeColor = Color.Green;
lblRESP.ForeColor = Color.DarkOrange;
lblSpo2.ForeColor = Color.Cyan;
lblPR.ForeColor = Color.Green;
lblDia.ForeColor = Color.Red;
}
}
public bool isCgtime(string key, DateTime time)
{
bool b = false;
if (key == "机械通气")
{
if (_record.SpileInTime != null && _record.SpileOutTime != null)
{
if (time >= _record.SpileInTime && time < _record.SpileOutTime.Value.AddMinutes(-3))
b = true;
}
if (_record.SpileInTime != null && _record.SpileOutTime == null)
{
if (time > _record.SpileInTime)
b = true;
}
}
else if (key == "自主呼吸")
{
if (_record.SpileInTime != null && _record.SpileOutTime != null)
{
if (time < _record.SpileInTime || time >= _record.SpileOutTime)
b = true;
}
if (_record.SpileInTime != null && _record.SpileOutTime == null)
{
if (time < _record.SpileInTime)
b = true;
}
if (_record.SpileInTime == null && _record.SpileOutTime == null)
{
b = true;
}
}
else
{
b = true;
}
return b;
}
private void StartTimer()
{
if (timerGetTextCollectorData == null)
timerGetTextCollectorData = new System.Windows.Forms.Timer(components);
timerGetTextCollectorData.Enabled = true;//调试时设置为FALSE
timerGetTextCollectorData.Interval = 2000;
timerGetTextCollectorData.Tick -= new System.EventHandler(timerGetTextCollectorData_Tick);
timerGetTextCollectorData.Tick += new System.EventHandler(timerGetTextCollectorData_Tick);
timerGetTextCollectorData.Start();
PublicMethod.StartCollectorDataProgram();
}
private void DisposeTimer()
{
if (timerGetTextCollectorData != null)
{
LastMonitorDataTime = null;
LastAnesMonitorDataTime = null;
timerGetTextCollectorData.Enabled = false;
timerGetTextCollectorData.Stop();
}
}
#endregion
#region
private void zgcAnaesRecord_KeyUp(object sender, KeyEventArgs e)
{
if (templateManage != null)
{
ZedGraphControl send = sender as ZedGraphControl;
templateManage.zedControl_KeyUp(send, e);
}
}
private bool zgcAnaesRecord_MouseDownEvent(ZedGraphControl sender, MouseEventArgs e)
{
if (templateManage != null && isReadOnly == false)
{
SelectWorkerValue.Hidden();
SelectDictValue.Hidden();
templateManage.zedControl_MouseDownEvent(sender, e);
}
return default(bool);
}
private bool zgcAnaesRecord_MouseUpEvent(ZedGraphControl sender, MouseEventArgs e)
{
if (templateManage != null && isReadOnly == false)
{
templateManage.zedControl_MouseUpEvent(sender, e);
}
return default(bool);
}
private bool zgcAnaesRecord_MouseMoveEvent(ZedGraphControl sender, MouseEventArgs e)
{
if (templateManage != null)
{
templateManage.zedControl_MouseMoveEvent(sender, e);
}
return default(bool);
}
private void zgcAnaesRecord_MouseDoubleClick(object sender, MouseEventArgs e)
{
if (templateManage != null && isReadOnly == false)
{
ZedGraphControl send = sender as ZedGraphControl;
templateManage.zedControl_MouseDoubleClick(send, e);
}
}
private void zgcAnaesRecord_ContextMenuBuilder(ZedGraphControl sender, ContextMenuStrip menuStrip, Point mousePt, ZedGraphControl.ContextMenuObjectState objState)
{
//添加自定义的新菜单
ToolStripMenuItem clearSelectCouve = new ToolStripMenuItem();
clearSelectCouve.Text = "删除选择数据";
clearSelectCouve.Click += new EventHandler(clearSelectCouve_Click);
menuStrip.Items.Add(clearSelectCouve);
if (NowRoom != null)
{
ToolStripMenuItem getPhysioData = new ToolStripMenuItem();
getPhysioData.Text = "重新获取数据";
getPhysioData.Click += getPhysioData_Click;
menuStrip.Items.Add(getPhysioData);
}
ToolStripMenuItem ModifyApply = new ToolStripMenuItem();
ModifyApply.Text = "手术申请信息";
ModifyApply.Click += ModifyApply_Click;
menuStrip.Items.Add(ModifyApply);
ToolStripMenuItem mnuAddDrug = new ToolStripMenuItem();
mnuAddDrug.Name = "add_medicine";
mnuAddDrug.Tag = "add_medicine";
mnuAddDrug.Text = "手动添加数据";
mnuAddDrug.Click += ((s, er) =>
{
frmPhysioDataEdit frm = new frmPhysioDataEdit(_record);
frm.FormClosed += ((ss, err) =>
{
templateManage.Bind("MonitorManage");
zgcAnaesRecord.Refresh();
});
frm.ShowDialog();
});
menuStrip.Items.Add(mnuAddDrug);
if (NowRoom != null)
{
ToolStripMenuItem ModifyRoom = new ToolStripMenuItem();
ModifyRoom.Text = "更换患者术间";
ModifyRoom.Click += ModifyRoom_Click;
menuStrip.Items.Add(ModifyRoom);
}
if (PublicMethod.RoleId == 1 || PublicMethod.RoleId == 6 || PublicMethod.RoleId == 8 || PublicMethod.RoleId == 10)
{
ToolStripMenuItem btnSyatemPhysion = new ToolStripMenuItem();
btnSyatemPhysion.Name = "btnSyatemPhysion";
btnSyatemPhysion.Tag = "btnSyatemPhysion";
btnSyatemPhysion.Text = "查询修改痕迹";
btnSyatemPhysion.Click += new EventHandler(btnSyatemPhysion_Click);
menuStrip.Items.Add(btnSyatemPhysion);
}
}
private void btnSyatemPhysion_Click(object sender, EventArgs e)
{
if (PatientId == 0) return;
frmPhysioDataUpdateLog Log = new frmPhysioDataUpdateLog();
Log.OperationRecordId = _record.Id.Value;
Log.ShowDialog();
}
private void ModifyRoom_Click(object sender, EventArgs e)
{
frmSeleteRoom seleteRoom = new frmSeleteRoom();
seleteRoom.NowRoomId = NowRoom.Id.ToString();
seleteRoom.ShowDialog();
string RoomStr = seleteRoom.RoomId;
if (RoomStr != null && RoomStr != "")
{
_record.RoomId = int.Parse(RoomStr);
BOperationRecord.Update("RoomId=@RoomId where Id=@id ", new AIMSModel.ParameterList("@RoomId", _record.RoomId, "@id", _record.Id));
BOperationApply.UpdateApplyRoom(_record.OperationApplyId.Value, _record.RoomId.Value, _record.PlanOperationTime);
BOperationApply.UpdteOperationOrder(_record.PlanOperationTime, NowRoom.Id.Value);
NowRoom = AIMSBLL.BOperationRoom.SelectSingle(_record.RoomId);
lblRoom.Text = NowRoom.Name;
}
}
private void getPhysioData_Click(object sender, EventArgs e)
{
if (State != AIMSExtension.EditState.BROWSE && _record.StateName == "手术中" && NowRoom != null && isReadOnly == false)
{
//InRoomTime
//没有IP判断
DataTable dtPhysioData = BOperationRecord.getPhysioDataByIp(NowRoom.Ip, _record.Id.Value, _record.PageBegin, getOpeMaxTime(_record), 5);
//同步未画点数据
DrawFillPhysioData(dtPhysioData);
templateManage.Bind("MonitorManage");
zgcAnaesRecord.Refresh();
}
}
private void DrawFillPhysioData(DataTable dtPhysioData)
{
if (dtPhysioData.Rows.Count <= 0)
return;
if (dtPhysioData != null && dtPhysioData.Rows.Count > 0)
{
foreach (var addPP in _record.PhysioConfigList)
{
if (addPP.IsValid == false) continue;
foreach (DataRow dr in dtPhysioData.Rows)
{
if (Double.Parse(dr["ParamValue"].ToString()) <= 0) continue;
if (dr["ParameterName"] != null && dr["ParameterName"].ToString() != "" && dr["ParameterName"].ToString().Equals(addPP.Id.ToString()))
{
DateTime RecordTime = DateTime.Parse(dr["InsertTime"].ToString());
if (RecordTime < _record.InRoomTime) continue;
if (!isCgtime(addPP.Name, RecordTime)) continue;
PhysioData pdTemp = PhysioDataConfig.newPhysioData(addPP, _record.Id.Value, RecordTime, dr["ParamValue"].ToString());
addPP.AddPointItem(pdTemp);
}
}
}
foreach (var addPP in _record.PhysioAnesConfigList)
{
if (addPP.IsValid == false) continue;
foreach (DataRow dr in dtPhysioData.Rows)
{
if (dr["ParameterName"] != null && dr["ParameterName"].ToString() != "" && dr["ParameterName"].ToString().Equals(addPP.Id.ToString()))
{
DateTime RecordTime = DateTime.Parse(dr["InsertTime"].ToString());
if (RecordTime < _record.InRoomTime) continue;
PhysioData pdTemp = PhysioDataConfig.newPhysioData(addPP, _record.Id.Value, RecordTime, dr["ParamValue"].ToString());
addPP.AddPointItem(pdTemp);
}
}
}
}
}
private void UpdatePhysioDataResp()
{
BOperationRecord.UpdatePhysioDataRespByTime(_record);
string PhysioDataConfigIds = "3,12";
DataTable dtPhysioData = BOperationRecord.getByOpeIDIsPhysioData(_record.Id.Value, PhysioDataConfigIds);
List<string> Ids = PhysioDataConfigIds.Split(',').ToList();
if (dtPhysioData != null && dtPhysioData.Rows.Count > 0)
{
foreach (PhysioDataConfig addPP in _record.PhysioConfigList)
{
if (!Ids.Contains(addPP.Id.ToString())) continue;
addPP.clearAddObj(zgcAnaesRecord);
if (addPP.IsDefalultShow == false) continue;
for (int i = 0; i < dtPhysioData.Rows.Count; i++)
{
if (dtPhysioData.Rows[i]["Name"].ToString().Equals(addPP.Name.ToString()))
{
PhysioData pdTemp = PhysioDataConfig.newPhysioData(addPP, _record.Id.Value, DateTime.Parse(dtPhysioData.Rows[i]["RecordTime"].ToString()), dtPhysioData.Rows[i]["Value"].ToString());
addPP.AddPointItem(pdTemp, false);
}
}
}
}
}
private void clearSelectCouve_Click(Object sender, EventArgs e)
{
templateManage.ClearSelectCouve();
}
private void zgcAnaesRecord2_KeyUp(object sender, KeyEventArgs e)
{
if (templateManage2 != null)
{
ZedGraphControl send = sender as ZedGraphControl;
templateManage2.zedControl_KeyUp(send, e);
}
}
private bool zgcAnaesRecord2_MouseDownEvent(ZedGraphControl sender, MouseEventArgs e)
{
if (templateManage2 != null && isReadOnly == false)
{
SelectDictText.Hidden();
templateManage2.zedControl_MouseDownEvent(sender, e);
}
return default(bool);
}
private bool zgcAnaesRecord2_MouseUpEvent(ZedGraphControl sender, MouseEventArgs e)
{
if (templateManage2 != null && isReadOnly == false)
{
templateManage2.zedControl_MouseUpEvent(sender, e);
}
return default(bool);
}
private bool zgcAnaesRecord2_MouseMoveEvent(ZedGraphControl sender, MouseEventArgs e)
{
if (templateManage2 != null)
{
templateManage2.zedControl_MouseMoveEvent(sender, e);
}
return default(bool);
}
private void zgcAnaesRecord2_MouseDoubleClick(object sender, MouseEventArgs e)
{
if (templateManage2 != null && isReadOnly == false)
{
ZedGraphControl send = sender as ZedGraphControl;
templateManage2.zedControl_MouseDoubleClick(send, e);
}
}
private void zgcAnaesRecord2_ContextMenuBuilder(ZedGraphControl sender, ContextMenuStrip menuStrip, Point mousePt, ZedGraphControl.ContextMenuObjectState objState)
{
}
private void ModifyApply_Click(object sender, EventArgs e)
{
if (PatientId == 0) return;
frmOperationApplyDetail frm = new frmOperationApplyDetail();
frm.State = AIMSExtension.EditState.EDIT;
frm.EditApplyId = ApplyId;
frm.tsbExit.Visible = true;
frm.tsbCancel.Visible = false;
frm.FormClosed += (s, er) =>
{
ReviewEvent();
};
//frm.FormBorderStyle = FormBorderStyle.None; // 无边框
//frm.TopLevel = false;
//frm.Dock = DockStyle.Fill;
//panel8.Controls.Add(frm);
frm.Show();
frm.Focus();
frm.BringToFront();
}
#endregion
#region
private void ReviewEvent()
{
try
{
if (PatientId != 0)
{
templateManage.OpeRecord = BOperationRecord.getRecord(_record, PatientId, RecoverId);
_record.SpeedyDrugsParam -= _record_SpeedyDrugsParam;
_record.SpeedyDrugsParam += _record_SpeedyDrugsParam;
templateManage2.OpeRecord = templateManage.OpeRecord;
templateManage.BindOperationRecordValueAll(templateManage.OpeRecord);
templateManage2.BindOperationRecordValueAll(templateManage2.OpeRecord);
foreach (AreaManageBase area in templateManage2.ManageList)
{
area.MouseWheelParam += Area_MouseWheelParam;
}
templateManage.Bind();
templateManage2.Bind();
reDrawEvent();
reDrawAnalysis();
zgcAnaesRecord.Refresh();
zgcAnaesRecord2.Refresh();
}
}
catch (Exception ex)
{
PublicMethod.WriteLog(ex);
}
}
private void Area_MouseWheelParam(object sender, MouseEventArgs e)
{
//if (!(panel82.VerticalScroll.Visible == false || (panel82.VerticalScroll.Value == 0 && e.Delta > 0) || (panel82.VerticalScroll.Value == lastpanel82VerticalScrollValue && e.Delta < 0)))
//{
string value = e.Delta.ToString();
if (value.Contains("-"))
{
value = value.Replace("-", "");
panel82.VerticalScroll.Value += int.Parse(value);
}
else
{
if (panel82.VerticalScroll.Value - e.Delta < 0)
panel82.VerticalScroll.Value = 0;
else
panel82.VerticalScroll.Value -= e.Delta;
}
panel82.Refresh();
panel82.Invalidate();
panel82.Update();
//}
}
private void DrawEvent()
{
templateManage.Bind("IconManage");
templateManage.Bind("RemarkManage");
reDrawEvent();
zgcAnaesRecord.Refresh();
}
private void reDrawEvent()
{
ClearTimeText();
DrawPanelTopTime();
if (_record.InRoomTime != null)
{
txtInRoom.CustomFormat = "MM-dd HH:mm";
txtInRoom.ButtonDropDown.Visible = false;
txtInRoom.Tag = _record.InRoomTime.Value;
txtInRoom.Value = _record.InRoomTime.Value;
this.picInRoom.BackgroundImage = global::AIMSControls.Properties.Resources._select;
}
if (_record.AnesthesiaBeginTime != null)
{
txtAnaesthesiaBegin.CustomFormat = "HH:mm";
txtAnaesthesiaBegin.ButtonDropDown.Visible = false;
txtAnaesthesiaBegin.Tag = _record.AnesthesiaBeginTime.Value;
txtAnaesthesiaBegin.Value = _record.AnesthesiaBeginTime.Value;
this.picAnesBegin.BackgroundImage = global::AIMSControls.Properties.Resources._select;
}
if (_record.SpileInTime != null)
{
this.cmbCGType.SelectedIndexChanged -= new System.EventHandler(this.cmbCGType_SelectedIndexChanged);
cmbCGType.Text = _record.InCGType;
txtCG.CustomFormat = "MM-dd HH:mm";
txtCG.Tag = _record.SpileInTime.Value;
txtCG.Value = _record.SpileInTime.Value;
this.picCG.BackgroundImage = global::AIMSControls.Properties.Resources._select;
if (_record.SpileOutTime == null)
{
if (_record.InCGType == "插管") cmbBGType.Text = "拔管";
if (_record.InCGType == "喉罩") cmbBGType.Text = "拔喉罩";
}
this.cmbCGType.SelectedIndexChanged += new System.EventHandler(this.cmbCGType_SelectedIndexChanged);
}
if (_record.SpileOutTime != null)
{
this.cmbBGType.SelectedIndexChanged -= new System.EventHandler(this.cmbBGType_SelectedIndexChanged);
cmbBGType.Text = _record.InBGType;
txtBG.CustomFormat = "MM-dd HH:mm";
txtBG.Tag = _record.SpileOutTime.Value;
txtBG.Value = _record.SpileOutTime.Value;
this.picBG.BackgroundImage = global::AIMSControls.Properties.Resources._select;
this.cmbBGType.SelectedIndexChanged += new System.EventHandler(this.cmbBGType_SelectedIndexChanged);
}
if (_record.OperationBeginTime != null)
{
txtOperationBegin.CustomFormat = "HH:mm";
txtOperationBegin.ButtonDropDown.Visible = false;
txtOperationBegin.Tag = _record.OperationBeginTime.Value;
txtOperationBegin.Value = _record.OperationBeginTime.Value;
this.picOpeBegin.BackgroundImage = global::AIMSControls.Properties.Resources._select;
}
if (_record.OperationEndTime != null)
{
txtOperationEnd.CustomFormat = "HH:mm";
txtOperationEnd.ButtonDropDown.Visible = false;
txtOperationEnd.Tag = _record.OperationEndTime.Value;
txtOperationEnd.Value = _record.OperationEndTime.Value;
this.picOpeEnd.BackgroundImage = global::AIMSControls.Properties.Resources._select;
}
if (_record.AnesthesiaEndTime != null)
{
txtAnaesthesiaEnd.CustomFormat = "HH:mm";
txtAnaesthesiaEnd.ButtonDropDown.Visible = false;
txtAnaesthesiaEnd.Tag = _record.AnesthesiaEndTime.Value;
txtAnaesthesiaEnd.Value = _record.AnesthesiaEndTime.Value;
this.picAnesEnd.BackgroundImage = global::AIMSControls.Properties.Resources._select;
}
if (_record.OutRoomTime != null)
{
txtOutRoom.CustomFormat = "MM-dd HH:mm";
txtOutRoom.ButtonDropDown.Visible = false;
txtOutRoom.Tag = _record.OutRoomTime.Value;
txtOutRoom.Value = _record.OutRoomTime.Value;
this.picOutRoom.BackgroundImage = global::AIMSControls.Properties.Resources._select;
}
if (_record.OutRoomTime != null && _record.StateName == "手术中")
{
txtOutRoom.CustomFormat = "MM-dd HH:mm";
txtOutRoom.ButtonDropDown.Visible = false;
txtOutRoom.Tag = _record.OutRoomTime.Value;
txtOutRoom.Value = _record.OutRoomTime.Value;
EndOperationOutRoom();
}
}
public void DrawPanelTopTime()
{
paneltop.Controls.Clear();
int LoactionX = Convert.ToInt32(panel8.Width * 0.19);
int SpanX = (panel8.Width - LoactionX) / (240 / 15 + 2);
paneltop.BringToFront();
System.Windows.Forms.Label label = new System.Windows.Forms.Label();
label.AutoSize = true;
label.Font = new System.Drawing.Font("微软雅黑", 9.5F);
label.Location = new System.Drawing.Point(LoactionX - 100, 7);
label.Size = new System.Drawing.Size(39, 17);
label.TabIndex = 0;
label.Text = "时间min";
paneltop.Controls.Add(label);
for (int i = 0; i <= (240 / 15); i++)
{
DateTime tempTime = _record.PageBegin.AddMinutes(i * 15);
System.Windows.Forms.Label labeltemp = new System.Windows.Forms.Label();
labeltemp.AutoSize = true;
labeltemp.Font = new System.Drawing.Font("微软雅黑", 9.5F);
labeltemp.Location = new System.Drawing.Point(LoactionX + SpanX * i, 7);
labeltemp.Size = new System.Drawing.Size(39, 17);
labeltemp.TabIndex = 0;
labeltemp.Text = tempTime.ToString("HH:mm");
paneltop.Controls.Add(labeltemp);
}
}
private void ClearTimeText()
{
txtInRoom.CustomFormat = " ";
txtAnaesthesiaBegin.CustomFormat = " ";
txtOperationBegin.CustomFormat = " ";
txtOperationEnd.CustomFormat = " ";
txtAnaesthesiaEnd.CustomFormat = " ";
txtOutRoom.CustomFormat = " ";
txtCG.CustomFormat = " ";
txtBG.CustomFormat = " ";
txtInRoom.Tag = null;
txtAnaesthesiaBegin.Tag = null;
txtOperationBegin.Tag = null;
txtOperationEnd.Tag = null;
txtAnaesthesiaEnd.Tag = null;
txtOutRoom.Tag = null;
txtCG.Tag = null;
txtBG.Tag = null;
txtInRoom.Text = "";
txtAnaesthesiaBegin.Text = "";
txtOperationBegin.Text = "";
txtOperationEnd.Text = "";
txtAnaesthesiaEnd.Text = "";
txtOutRoom.Text = "";
txtCG.Text = "";
txtBG.Text = "";
this.picInRoom.BackgroundImage = global::AIMSControls.Properties.Resources.;
this.picAnesBegin.BackgroundImage = global::AIMSControls.Properties.Resources.;
this.picCG.BackgroundImage = global::AIMSControls.Properties.Resources.;
this.picOpeBegin.BackgroundImage = global::AIMSControls.Properties.Resources.;
this.picOpeEnd.BackgroundImage = global::AIMSControls.Properties.Resources.;
this.picBG.BackgroundImage = global::AIMSControls.Properties.Resources.;
this.picAnesEnd.BackgroundImage = global::AIMSControls.Properties.Resources.;
this.picOutRoom.BackgroundImage = global::AIMSControls.Properties.Resources.;
}
private bool GetOpeState(ref string message)
{
bool isTrue = true;
if (PublicMethod.HospitalName.Contains("秦皇岛"))
if (_record.AnesthesiaDoctor == null || _record.AnesthesiaDoctor.Trim() == "")
{
message = "请填写麻醉医生";
isTrue = false;
}
if (_record.AnesthesiaDoctor != null && _record.AnesthesiaDoctor.Trim() != "")
{
if (_record.AnaseDataQualityRecordList == null || _record.AnaseDataQualityRecordList.Count <= 0)
{
message = "请填写麻醉质量质控指标";
isTrue = false;
}
//if (_record.OpeRecordInfo.StewardNumber == null || _record.OpeRecordInfo.StewardNumber.ToString().Trim() == "")
//{
// message = "请与手术信息选择患者Steward评分";
// isTrue = false;
//}
//if (_record.OpeRecordInfo.Whereabouts == null || _record.OpeRecordInfo.Whereabouts.ToString().Trim() == "")
//{
// message = "请与手术信息选择患者去向!";
// isTrue = false;
//}
if (_record.ASALevel == null || _record.ASALevel == null)
{
message = "请添写ASA分级";
isTrue = false;
}
if (_record.OperationDoctor == null || _record.OperationDoctor.Trim() == "")
{
message = "请添加手术医师!";
isTrue = false;
}
if (_record.OperationType == null || _record.OperationType.Trim() == "")
{
message = "请选择择期急诊!";
isTrue = false;
}
if (PublicMethod.RoleName.Contains("术中填写手术等级切口等级"))
{
if (_record.OpeRecordInfo.OperationLevel == null || _record.OpeRecordInfo.OperationLevel.ToString().Trim() == "")
{
message = "请与手术信息选择手术分级!";
isTrue = false;
}
if (_record.OpeRecordInfo.OperationCut == null || _record.OpeRecordInfo.OperationCut.ToString().Trim() == "")
{
message = "请与手术信息选择手术切口!";
isTrue = false;
}
}
}
return isTrue;
}
private void EndOperationOutRoom()
{
if (_record == null || _record.StateName != "手术中") return;
try
{
//CloseOtherFrom();
//保存持续加药未结束药品
foreach (FactDrug temp in _record.FactDrugList)
{
if (temp.IsContinue == 1 && temp.DrugBeginTime == temp.DrugEndTime)
{
temp.DrugEndTime = _record.OutRoomTime.Value;
temp.OperatorNo = PublicMethod.OperatorNo;
temp.OperatorName = PublicMethod.OperatorName;
temp.OperateDate = DateTime.Now;
BFactDrug.Update(temp);
}
}
//保存持续事件未结束事件
foreach (FactEvents temp in _record.FactEventsList)
{
if (temp.IsContinue == 1 && temp.EventBeginTime == temp.EventEndTime)
{
temp.EventEndTime = _record.OutRoomTime;
temp.OperatorNo = PublicMethod.OperatorNo;
temp.OperatorName = PublicMethod.OperatorName;
temp.OperateDate = DateTime.Now;
BFactEvents.Update(temp);
}
}
_record.StateName = "手术结束";
BOperationApply.UpdateApplyState(ApplyId, 8);
BOperationRecord.UpdateState(PatientId, 1, 2);
//PublicMethod.WriteLog("结束转出手术: " + _record.Id);
//TipBox.Hidden(true);
State = AIMSExtension.EditState.BROWSE;
btnCancelOperation.Enabled = false;
btnCancelIn.Enabled = false;
btnSelectPatient.Enabled = true;
DisposeTimer();
ReviewEvent();
}
catch (Exception exp)
{
PublicMethod.WriteLog(exp, "");
}
}
public void ClearRecordDate()
{
panel8.VerticalScroll.Value = 0;
panel82.VerticalScroll.Value = 0;
paneltop.Visible = false;
//清空记录点并重新加载
ClearTimeText();
//关闭采集的服务
DisposeTimer();
label11.Text = "";
lblHR.Text = "--";
lblRESP.Text = "--";
lblSpo2.Text = "--";
lblPR.Text = "--";
lblDia.Text = "---/---";
lblHR.ForeColor = Color.Green;
lblRESP.ForeColor = Color.DarkOrange;
lblSpo2.ForeColor = Color.Cyan;
lblPR.ForeColor = Color.Green;
lblDia.ForeColor = Color.Red;
if (templateManage != null)
{
templateManage.ControlClear();
}
if (templateManage2 != null)
{
templateManage2.ControlClear();
}
if (_record.phListPack != null)
{
Panel pan3 = _record.phListPack.CControl as Panel;
if (pan3 != null)
{
pan3.Controls.Clear();
}
}
_record = null;
//this.Dispose();
}
#endregion
#region
private void btnyldj_Click(object sender, EventArgs e)
{
//FormUseDrugsReport formUseDrugsReport = new FormUseDrugsReport(1);
//if (_record != null) formUseDrugsReport._record = _record;
//formUseDrugsReport.Show();
}
private void btnzsk_Click(object sender, EventArgs e)
{
frmKnowledgeBase frm = new frmKnowledgeBase();
frm.Show();
}
private void btndptz_Click(object sender, EventArgs e)
{
frmNoticeLargeScreen fnc = new frmNoticeLargeScreen();
if (_record != null)
{
fnc.lblName.Text = _record.Name;
fnc.textBox2.Focus();
fnc.groupBox1.Visible = false;
}
fnc.ShowDialog();
}
private void btnxldlx_Click(object sender, EventArgs e)
{
frmHemodynamics frm = new frmHemodynamics();
frm.Show();
}
private void btnsbwh_Click(object sender, EventArgs e)
{
frmInstrumentRegistration frm = new frmInstrumentRegistration();
frm.Show();
}
private void btnsjzx_Click(object sender, EventArgs e)
{
if (_record != null)
{
EMRExtension.OpenEMRS(_record.PatientId.Value, _record.OperationApplyId.Value);
}
}
private void btnChage_Click(object sender, EventArgs e)
{
if (_record != null)
{
EMRExtension.OpenFeesRecord(_record, "麻醉");
}
}
private void frmAnasRecordBill2_VisibleChanged(object sender, EventArgs e)
{
if (this.Visible == false)
{
panel8.VerticalScroll.Value = 0;
panel82.VerticalScroll.Value = 0;
paneltop.Visible = false;
if (templateManage != null)
templateManage.SetPYL();
if (templateManage2 != null)
templateManage2.SetPYL();
if (_record != null && _record.StateName == "手术中" && State != AIMSExtension.EditState.BROWSE)
{
DisposeTimer();
}
}
else
{
if (_record != null && _record.StateName == "手术中" && State != AIMSExtension.EditState.BROWSE)
{
StartTimer();
}
}
}
private void superTabMain_SelectedTabChanged(object sender, SuperTabStripSelectedTabChangedEventArgs e)
{
if (_record.SelPhysioConfig != null)
{
_record.SelPhysioConfig.IsClick = false;
_record.SelPhysioConfig.onClick(e);
_record.SelPhysioConfig = null;
}
}
private void button10_Click(object sender, EventArgs e)
{
frmSafetyExamine frmSafety = new frmSafetyExamine();
frmSafety.PatientId = PatientId;
frmSafety.Show();
}
private void cmbCGType_SelectedIndexChanged(object sender, EventArgs e)
{
_record.InCGType = cmbCGType.Text;
if (txtCG.CustomFormat != " " && txtCG.Tag != null)
{
DrawGraph.FactEvents Inevent = null;
InsertOrUpdateEventTime(2, "txtCG", cmbCGType.Text, txtCG, txtCG.Value, ref Inevent);
ReviewEvent();
}
}
private void cmbBGType_SelectedIndexChanged(object sender, EventArgs e)
{
_record.InBGType = cmbBGType.Text;
if (txtBG.CustomFormat != " " && txtBG.Tag != null)
{
DrawGraph.FactEvents Inevent = null;
InsertOrUpdateEventTime(2, "txtBG", cmbBGType.Text, txtBG, txtBG.Value, ref Inevent);
ReviewEvent();
}
}
private void PanelSave_Click(object sender, EventArgs e)
{
PanelSave.Select();
if (_record != null)
{
BOperationRecord.Update(_record);
if (_record.OpeRecordInfo != null)
BOperationRecordInfo.Update(_record.OpeRecordInfo);
new frmMessageBox().Show();
ReviewEvent();
}
}
private void label11_Click(object sender, EventArgs e)
{
DialogResult dialog = MessageBox.Show("是否重启采集程序!", "系统提示", MessageBoxButtons.YesNo);
if (dialog == DialogResult.Yes)
{
PublicMethod.StartCollectorDataProgram(true);
}
}
#endregion
}
}