AIMS/AIMS/OperationDoing/AnasRecoverBill/frmAnasRecoverBill.cs

1625 lines
67 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.OperationDoing.AnasRecordBill;
using AIMS.OperationFront.UI;
using AIMS.PublicUI.UI;
using AIMSBLL;
using AIMSExtension;
using AIMSModel;
using DevComponents.Editors.DateTimeAdv;
using DrawGraph;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Printing;
using System.Linq;
using System.Reflection;
using System.Windows.Forms;
namespace AIMS.OperationDoing.AnasRecoverBill.UI
{
public partial class frmAnasRecoverBill : Form
{
#region
public OperationRecord _record;
public TemplateManage templateManage;
public AIMSModel.OperationRoom NowRoom;
public int PatientId = 0;
public int ApplyId = 0;
public int RecoverId = 2;
private System.Windows.Forms.Timer timerGetTextCollectorData;
public AIMSExtension.EditState State;
public bool isReadOnly = false;
public frmAnasRecoverBill()
{
InitializeComponent();
#region
txtInRoom.MouseDown += new MouseEventHandler(txtDateTime_MouseDown);
txtOutRoom.MouseDown += new MouseEventHandler(txtDateTime_MouseDown);
txtAnaesthesiaEnd.MouseDown += new MouseEventHandler(txtDateTime_MouseDown);
txtBG.MouseDown += new MouseEventHandler(txtDateTime_MouseDown);
txtAnaesthesiaEnd.KeyUp += new KeyEventHandler(dateTimePicker_KeyUp);
txtBG.KeyUp += new KeyEventHandler(dateTimePicker_KeyUp);
txtInRoom.LostFocus += new EventHandler(txtDateTime_LostFocus);
txtOutRoom.LostFocus += new EventHandler(txtDateTime_LostFocus);
txtAnaesthesiaEnd.LostFocus += new EventHandler(txtDateTime_LostFocus);
txtBG.LostFocus += new EventHandler(txtDateTime_LostFocus);
this.picInRoom.BackgroundImage = global::AIMS.Properties.Resources.;
this.picBG.BackgroundImage = global::AIMS.Properties.Resources.;
this.picAnesEnd.BackgroundImage = global::AIMS.Properties.Resources.;
this.picOutRoom.BackgroundImage = global::AIMS.Properties.Resources.;
#endregion
}
private void frmAnasRecordBillNew_Load(object sender, EventArgs e)
{
if (PublicMethod.OperatorNo == "admin")
{
btnChage.Visible = true;
}
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);
LoadAnesRescue();
}
#endregion
#region
public List<MasterPane> mPanes = new List<MasterPane>();
public List<MasterPane> UpPanes = new List<MasterPane>();
public int printWidth = 800;
public int printHeight = 1160;
int count = 0;
private void pDoc_PrintPage(object sender, PrintPageEventArgs e)
{
Font f = new Font("宋体", 10, FontStyle.Regular);
decimal Chinese_OneWidth = Convert.ToDecimal(e.Graphics.MeasureString("测", f).Width);
int pageWidth = Convert.ToInt32(Math.Round(e.PageSettings.PrintableArea.Width, 0)) - 1;//打印机可打印区域的宽度
int onePageHeight = Convert.ToInt32(Math.Round(e.PageSettings.PrintableArea.Height, 0)) - 1;//打印机可打印区域的高度
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;
}
}
private void plPrintBrowse_Click(object sender, EventArgs e)
{
int pylWidth = 3;
System.Drawing.Printing.PrintDocument pDoc = new System.Drawing.Printing.PrintDocument();
pDoc.DefaultPageSettings.Landscape = false;
pDoc.OriginAtMargins = true;
pDoc.DefaultPageSettings.Margins = new Margins(pylWidth, 0, 0, 0);//8, 0);
pDoc.DefaultPageSettings.PrinterResolution.Kind = PrinterResolutionKind.High;
pDoc.PrintPage -= new PrintPageEventHandler(PrintDocPage);
pDoc.PrintPage += new PrintPageEventHandler(PrintDocPage);
PrintPreviewDialog pdg = new PrintPreviewDialog();
pdg.Width = zgcAnaesRecord.Width;
Form f = (Form)pdg;
f.WindowState = FormWindowState.Maximized;
pdg.Document = pDoc;
pdg.PrintPreviewControl.Zoom = 1;
pdg.ShowDialog(this);
pdg.Focus();
pdg.BringToFront();
}
private void PrintDocPage(object sender, PrintPageEventArgs e)
{
if (_record == null) return;
int zgcAnaesRecordWidth = zgcAnaesRecord.Size.Width;
int zgcAnaesRecordHeight = zgcAnaesRecord.Size.Height;
printHeight = Convert.ToInt32(printWidth * 1.414) + 2;
zgcAnaesRecord.Size = new Size(printWidth, printHeight);
foreach (PhysioDataConfig pp in _record.addPhysioList)
{
if (pp.showStyle == "显示数值")
{
pp.IsValid = false;
///重新设置曲线属性
pp.reSetCurveSpo2();
}
}
TipBox.Hidden();
MasterPane mPane = zgcAnaesRecord.MasterPane; //this.MasterPane;
mPane.Border.IsVisible = false;
//GraphPane cPane = mPane.PaneList[0]; //graphPane;
//cPane.Border.IsVisible = false;
//当前窗体中的矩形区域大小
RectangleF saveRect = mPane.Rect;
templateManage.initChart();
mPanes.Add(mPane.Clone());
if (e != null)
mPane.Draw(e.Graphics); //在打印文档中画出MasterPane内容
using (Graphics g = zgcAnaesRecord.CreateGraphics())
{
mPane.ReSize(g, saveRect);
}
zgcAnaesRecord.Size = new Size(zgcAnaesRecordWidth, zgcAnaesRecordHeight);
templateManage.initChart();
UpPanes.Add(mPane.Clone());
foreach (PhysioDataConfig pp in _record.addPhysioList)
{
if (pp.showStyle == "显示数值")
{
pp.IsValid = true;
///重新设置曲线属性
pp.reSetCurveSpo2();
}
}
}
private void plPrint_Click(object sender, EventArgs e)
{
if (_record == null || _record.Id == 0) return;
if (txtOutRoom.Focused)
{
zgcAnaesRecord.Focus();
}
if (_record.StateName == "麻醉恢复中")
{
if (txtOutRoom.CustomFormat == " ")
{
txtOutRoom.BackColor = Color.Red;
MessageBox.Show("恢复还没有结束,请填写出室时间!", "系统提示");
return;
}
}
try
{
mPanes = new List<MasterPane>();
UpPanes = new List<MasterPane>();
int printrcount = 0;
while (_record.pageCount != 1)
{
btnUpPage_Click(null, null);
}
while (_record.currentPage != _record.pageCount)
{
PrintDocPage(null, null);
printrcount++;
btnNextPage_Click(null, null);
if (printrcount > 10) break;
}
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();
}
count = 0;
}
catch (Exception exp)
{
PublicMethod.WriteLog(exp, "");
}
}
#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, "txtBG", "拔管", 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.EventBeginTime > _record.lastPageBegin)
{
ReviewEvent();
}
else
{
DrawEvent();
}
}
}
/// <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, "txtBG", "拔管", 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.EventBeginTime > _record.lastPageBegin)
{
ReviewEvent();
}
else
{
DrawEvent();
}
}
}
/// <summary>
/// 特殊事件触发时设置图片
/// </summary>
/// <param name="obj">显示时间的控件</param>
private void SetPic(DateTimeInput obj)
{
DrawGraph.FactEvents Inevent = null;
DateTimeInput tb = obj as DateTimeInput;
if (_record.StateName == "麻醉恢复中")
{
DeleteEventTime("txtAnaesthesiaEnd", "麻醉完成", tb, ref Inevent);
DeleteEventTime("txtBG", "拔管", tb, ref Inevent);
}
else
{
MessageBox.Show("选择的事件不可删除 只可修改!");
}
if (Inevent != null)
{
tb.ButtonDropDown.Visible = false;
_record.FactEventsList.Remove(Inevent);
DrawEvent();
}
}
/// <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.AnesthesiaEndTime = null;
this.picAnesEnd.BackgroundImage = global::AIMS.Properties.Resources.;
}
if (Inevent != null && Inevent.EventName == "拔管")
{
_record.SpileOutTime = null;
this.picBG.BackgroundImage = global::AIMS.Properties.Resources.;
}
if (Inevent != null)
{
BOperationRecord.Update("OperationBeginTime=@OperationBegin,OperationEndTime=@OperationEnd,OutRoomTime=@OutRoom where Id=@id", new AIMSModel.ParameterList("@OperationBegin", _record.OperationBeginTime.HasValue ? (object)_record.OperationBeginTime.Value : (object)DBNull.Value, "@OperationEnd", _record.OperationEndTime.HasValue ? (object)_record.OperationEndTime.Value : (object)DBNull.Value, "@OutRoom", _record.OutRoomTime.HasValue ? (object)_record.OutRoomTime.Value : (object)DBNull.Value, "@id", _record.Id));
}
}
}
/// <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(false, _record, EventName, curTimeTemp, ref messing);
if (_record.State != null)
{
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 == "请填写恢复不良事件!")
// btnAdverseFactEvents_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 != 1)
{
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::AIMS.Properties.Resources._select;
}
if (Inevent != null && Inevent.EventName == "拔管" && _record.SpileOutTime != Inevent.EventBeginTime)
{
_record.SpileOutTime = Inevent.EventBeginTime;
this.picBG.BackgroundImage = global::AIMS.Properties.Resources._select;
}
if (Inevent != null && Inevent.EventName == "麻醉完成" && _record.AnesthesiaEndTime != Inevent.EventBeginTime)
{
_record.AnesthesiaEndTime = Inevent.EventBeginTime;
this.picAnesEnd.BackgroundImage = global::AIMS.Properties.Resources._select;
}
if (Inevent != null && Inevent.EventName == "出室" && _record.OutRoomTime != Inevent.EventBeginTime)
{
_record.OutRoomTime = Inevent.EventBeginTime;
this.picOutRoom.BackgroundImage = global::AIMS.Properties.Resources._select;
}
if (Inevent != null)
{
BOperationRecord.Update("InRoomTime=@InRoom,OperationBeginTime=@OperationBegin,OperationEndTime=@OperationEnd,OutRoomTime=@OutRoom where Id=@id ", new AIMSModel.ParameterList("@InRoom", _record.InRoomTime.HasValue ? (object)_record.InRoomTime.Value : (object)DateTime.Now, "@OperationBegin", _record.OperationBeginTime.HasValue ? (object)_record.OperationBeginTime.Value : (object)DBNull.Value, "@OperationEnd", _record.OperationEndTime.HasValue ? (object)_record.OperationEndTime.Value : (object)DBNull.Value, "@OutRoom", _record.OutRoomTime.HasValue ? (object)_record.OutRoomTime.Value : (object)DBNull.Value, "@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)
{
templateManage.SetPYL();
}
private void plRefresh_Click(object sender, EventArgs e)
{
if (PatientId == 0) return;
//刷新到当前页
ReviewEvent();
}
private void btnUpPage_Click(object sender, EventArgs e)
{
if (PatientId == 0) return;
if (_record.pageCount == 1) return;
SetUpPageTime();
ReviewEvent();
}
private void btnNextPage_Click(object sender, EventArgs e)
{
if (PatientId == 0) return;
if (_record.pageCount == _record.currentPage) return;
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;
}
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;
}
#endregion
#region
private void btnSelectPatient_Click(object sender, EventArgs e)
{
OperationDoing.AnasRecordBill.UI.frmRecoverPatient frmSelectPatient = new AnasRecordBill.UI.frmRecoverPatient();
//frmSelectPatient.isMainOpen = true;
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;
zgcAnaesRecord.Visible = false;
timerLoadAnesRescue = new System.Windows.Forms.Timer(components);
timerLoadAnesRescue.Enabled = true;//调试时设置为FALSE
timerLoadAnesRescue.Interval = 300;
timerLoadAnesRescue.Tick -= TimerLoadAnesRescue_Tick;
timerLoadAnesRescue.Tick += TimerLoadAnesRescue_Tick;
timerLoadAnesRescue.Start();
}
private void TimerLoadAnesRescue_Tick(object sender, EventArgs e)
{
try
{
timerLoadAnesRescue.Dispose();
if (PatientId > 0 && State == AIMSExtension.EditState.ADD)
{
try
{
HelperDB.DbHelperSQL.BeginTrans();
_record = new OperationRecord();
_record.OperationApplyId = ApplyId;
_record.PatientId = PatientId;
_record.RecoverId = RecoverId;
_record.Id = BOperationRecord.AddTitleTime(PatientId, ApplyId, RecoverId,3, DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd HH:mm:00")), NowRoom.Id.Value);
HelperDB.DbHelperSQL.CommitTrans();
//_record.currentPage = 1;
ClearTimeText();
btnSelectPatient.Enabled = false;
DrawAnasReordBill.IniDrawAnasReordBill3(_record, zgcAnaesRecord, ref templateManage); //初始化麻醉记录单界
StartTimer();
}
catch
{
HelperDB.DbHelperSQL.RollbackTrans();
}
}
else if (PatientId > 0 && State == AIMSExtension.EditState.EDIT)
{
_record = new OperationRecord();
btnSelectPatient.Enabled = false; //清空记录点并重新加载
ClearTimeText();
if (templateManage != null)
{
templateManage.ControlClear();
}
DrawAnasReordBill.IniDrawAnasReordBill3(_record, zgcAnaesRecord, ref templateManage); //初始化麻醉记录单界面
StartTimer();
}
else if (PatientId > 0 && State == AIMSExtension.EditState.BROWSE)
{
_record = new OperationRecord();
btnSelectPatient.Enabled = true;
btnCancelOperation.Enabled = false;
btnCancelIn.Enabled = false;
ClearTimeText();
if (templateManage != null)
{
templateManage.ControlClear();
}
DrawAnasReordBill.IniDrawAnasReordBill3(_record, zgcAnaesRecord, ref templateManage); //初始化麻醉记录单界面
DisposeTimer();
}
plRefresh_Click(null, null);
if (_record.MedicalRecord != null && _record.MedicalRecord != "")
{
btnOperationInfo.Enabled = false;
btnOutputLiquids.Enabled = false;
btnDrug.Enabled = false;
btnAddEvents.Enabled = false;
txtInRoom.Enabled = false;
txtAnaesthesiaEnd.Enabled = false;
txtOutRoom.Enabled = false;
txtBG.Enabled = false;
isReadOnly = true;
}
}
catch (Exception ex)
{
throw ex;
}
circularProgress1.IsRunning = false;
circularProgress1.Visible = false;
zgcAnaesRecord.Visible = true;
}
private void btnOperationInfo_Click(object sender, EventArgs e)
{
if (PatientId != 0)
{
frmOpeRecoverInInfo frmOperationInfo = new frmOpeRecoverInInfo();
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.FormClosed += new FormClosedEventHandler(frmFactEventsNew_FormClosed);
frmFactDrug.ShowDialog();
}
else
{
MessageBox.Show("请选择患者");
}
}
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 += ReferEventDrugs;
frmFactEventsNew.ShowDialog();
}
else
{
MessageBox.Show("请选择患者");
}
}
private void btnOutputLiquids_Click(object sender, EventArgs e)
{
if (PatientId != 0)
{
PublicUI.UI.frmFactOutputLiquidsNew frmFactOutputLiquids = new PublicUI.UI.frmFactOutputLiquidsNew();
frmFactOutputLiquids._record = _record;
frmFactOutputLiquids.OutputLiquidTypeId = RecoverId; // 事件类型 1 麻醉单事件 2 麻醉恢复单
frmFactOutputLiquids.FormClosed += new FormClosedEventHandler(frmFactEventsNew_FormClosed);
frmFactOutputLiquids.ShowDialog();
}
else
{
MessageBox.Show("请选择患者");
}
}
private void button6_Click(object sender, EventArgs e)
{
frmAnaseDataQualityRecord frmAnaseDataQuality = new frmAnaseDataQualityRecord();
frmAnaseDataQuality._record = _record;
frmAnaseDataQuality.ShowDialog();
}
void frmFactEventsNew_FormClosed(object sender, FormClosedEventArgs e)
{
plRefresh_Click(null, null);
}
private void btnCancelOperation_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, 8);
//BOperationRecord.DeleteOperationRecordData(PatientId, RecoverId);
BOperationRecord.UpdateState(PatientId, 1, 5);
HelperDB.DbHelperSQL.CommitTrans();
//ClearData();
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, 8);
BOperationRecord.DeleteOperationRecorvreData(_record.Id.Value, PatientId, RecoverId);
HelperDB.DbHelperSQL.CommitTrans();
DisposeTimer();
//ClearData();
this.Close();
}
catch
{
HelperDB.DbHelperSQL.RollbackTrans();
}
}
}
private void btnTemplate_Click(object sender, EventArgs e)
{
if (PatientId != 0)
{
frmOpeRecoverOutInfo frmOperationInfo = new frmOpeRecoverOutInfo();
frmOperationInfo._record = _record;
frmOperationInfo.FormClosed += new FormClosedEventHandler(plRefresh_Click);
frmOperationInfo.ShowDialog();
}
else
{
MessageBox.Show("请选择患者");
}
}
private void tsbExePlan_Click(object sender, EventArgs e)
{
if (PatientId == 0)
{
MessageBox.Show("请先选择患者!");
return;
}
PatientRecord patient = PatientRecord.GetPatientRecord(PatientId);
frmDocument frmDocument = new frmDocument(patient);
frmDocument.StartPosition = FormStartPosition.CenterScreen;
frmDocument.WindowState = FormWindowState.Maximized;
frmDocument.ShowDialog();
}
void toolStripMenuItem2_Click(object sender, EventArgs e)
{
frmPhysiosSetting frm = new frmPhysiosSetting();
frm.ConfigParam += new frmPhysiosSetting.ConfigParamHandler(templateManage.frmInstance_ConfigParam);
frm._record = _record;
frm.ShowDialog();
}
private void reDrawAnalysis()
{
try
{
//图表的对象
TextPackObj janCePack = templateManage.GetPackObjectOTag<TextPackObj>("PhysioDataManage_TextPackObj_17");
LinePackObj H5pack = templateManage.GetPackObjectOTag<LinePackObj>("IconManage_LinePackObj_5");
RectangleFramePackObj IconPpack = templateManage.GetPackObjectOTag<RectangleFramePackObj>("IconManage_RectangleFramePackObj_2");
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, IconPpack.RealY, _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;
private void timerGetCollectorData_Tick(bool isOpen)
{
if (State == AIMSExtension.EditState.BROWSE || _record.StateName != "麻醉恢复中" || NowRoom == null || isReadOnly == true) return;
//if (!PublicMethod.RoleId.Operator.RoleRef.Name.Contains("麻醉") && PublicMethod.Operator.Id != _record.OperatorId
// && _record.OperatorId != 1 && PublicMethod.Operator.Name != "系统管理员") return;
if (_record.OutRoomTime != null && DateTime.Now >= _record.OutRoomTime) return;
DateTime dtTime = DateTime.Now;
double span = ((TimeSpan)(dtTime - _record.InRoomTime.Value)).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
{
//bool isNowRoom = isOpeRoom();
//if (isNowRoom == false)
//{
// return;
//}
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.addPhysioList)
{
string key = addPP.Name;
string value = addPP.Enname;
if (addPP.IsValid == false) continue;
//if (addPP.StopCollect == true) continue;
if (key == "机控呼吸") 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)
{
try
{
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 = new PhysioData();
pdTemp.RecordTime = dtTime;
pdTemp.Value = Double.Parse(dr["ParamValue"].ToString());
pdTemp.YAisx = addPP.YAisx;
pdTemp.PhysioDataConfigId = addPP.Id;
pdTemp.PatientId = _record.Id.Value;
physioDatas.Add(pdTemp);
continue;
}
catch (Exception)
{
continue;
}
}
}
}
//有有创清空无创
foreach (var pdTemp in physioDatas)
{
if (pdTemp.PhysioDataConfigId == 7)
{
foreach (var temp in physioDatas)
{
if (temp.PhysioDataConfigId == 5)
{
temp.Value = 0;
}
}
}
if (pdTemp.PhysioDataConfigId == 8)
{
foreach (var temp in physioDatas)
{
if (temp.PhysioDataConfigId == 6)
{
temp.Value = 0;
}
}
}
}
foreach (var pdTemp in physioDatas)
{
if (pdTemp.Value < 1) continue;
PhysioDataConfig addPP = _record.addPhysioList.Where(a => pdTemp.PhysioDataConfigId == a.Id).ToList()[0];
addPP.AddOrDelItem(pdTemp, 5);
date++;
}
if (dtTime > _record.lastPageBegin && ((TimeSpan)(dtTime - _record.lastPageBegin)).TotalHours < 24 && date > 0)
{
_record.currentPage++;
btnNextPage_Click(null, null);
}
}
catch (Exception)
{
//getPhysioData_Click(null, null);
}
}
public string szy;//舒张压
public string ssy;//收缩压
public DateTime? LastRespMonitorDataTime;
private void timerGetTextCollectorData_Tick(object sender, EventArgs e)
{
try
{
if (((TimeSpan)(DateTime.Now - _record.lastPageBegin)).TotalHours > 24 || NowRoom == null) return;
timerGetCollectorData_Tick(false);
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);
foreach (PropertyInfo p in nowPhysioData.GetType().GetProperties())
{
bool iswar = false;
foreach (PhysioDataConfig keyValuePair in _record.addPhysioList)
{
if (keyValuePair.Enname.ToUpper() == p.Name.ToUpper())
{
try
{
object paramValue = p.GetValue(nowPhysioData, null);
if (paramValue != null && paramValue.ToString() != string.Empty && paramValue.ToString() != "NaN" && paramValue.ToString() != "NULL")
{
double value = Double.Parse(paramValue.ToString());
value = Convert.ToInt32(value);
if (value < keyValuePair.WarningLowLimit || value > keyValuePair.WarningHighLimit)
{
iswar = true;
}
if (keyValuePair.Name == "心率")
{
lblHR.Text = value <= 0 ? "- -" : value.ToString();
if (iswar == true) lblHR.ForeColor = Color.Red; else lblHR.ForeColor = Color.Green;
}
if (keyValuePair.Name == "自主呼吸")
{
lblRESP.Text = value <= 0 ? "- -" : value.ToString();
if (iswar == true) lblRESP.ForeColor = Color.Red; else lblRESP.ForeColor = Color.Green;
}
if (keyValuePair.Name == "氧饱和度")
{
lblSpo2.Text = value <= 0 ? "- -" : value.ToString();
if (iswar == true) lblSpo2.ForeColor = Color.Red; else lblSpo2.ForeColor = Color.Green;
}
if (keyValuePair.Name == "脉率")
{
lblPR.Text = value <= 0 ? "- -" : value.ToString();
if (iswar == true) lblPR.ForeColor = Color.Red; else lblPR.ForeColor = Color.Green;
}
if (keyValuePair.Name == "无创舒张压")
{
szy = value <= 0 ? "" : value.ToString();
if (iswar == true) lblDia.ForeColor = Color.Red; else lblDia.ForeColor = Color.Green;
}
if (keyValuePair.Name == "无创收缩压")
{
ssy = value <= 0 ? "" : value.ToString();
if (iswar == true) lblDia.ForeColor = Color.Red; else lblDia.ForeColor = Color.Green;
}
if (keyValuePair.Name == "有创舒张压")
{
szy = value <= 0 ? "" : value.ToString();
if (iswar == true) lblDia.ForeColor = Color.Red; else lblDia.ForeColor = Color.Green;
}
if (keyValuePair.Name == "有创收缩压")
{
ssy = value <= 0 ? "" : value.ToString();
if (iswar == true) lblDia.ForeColor = Color.Red; else lblDia.ForeColor = Color.Green;
}
break;
}
}
catch (Exception)
{
//PublicMethod.WriteLog(ex);
}
}
}
}
string szyssy = ssy + "/" + szy;
lblDia.Text = szyssy == "/" ? "--/--" : szyssy;
}
else
{
lblHR.Text = "- -";
lblRESP.Text = "- -";
lblSpo2.Text = "- -";
lblPR.Text = "- -";
lblDia.Text = "--/--";
lblHR.ForeColor = Color.Green;
lblRESP.ForeColor = Color.Green;
lblSpo2.ForeColor = Color.Green;
lblPR.ForeColor = Color.Green;
lblDia.ForeColor = Color.Green;
}
}
public bool isCgtime(string key, DateTime time)
{
bool b = false;
try
{
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;
}
}
else
{
b = false;
}
}
catch (Exception ex)
{
PublicMethod.WriteLog(ex);
}
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();
}
private void DisposeTimer()
{
if (timerGetTextCollectorData != null)
{
timerGetTextCollectorData.Enabled = false;
timerGetTextCollectorData.Stop();
}
}
public void StarttimerGetTextCollectorData()
{
if (timerGetTextCollectorData == null) return;
timerGetTextCollectorData.Start();
}
#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);
}
}
//public ucStripMenuItem menuItem = new ucStripMenuItem();
private void zgcAnaesRecord_ContextMenuBuilder(ZedGraphControl sender, ContextMenuStrip menuStrip, Point mousePt, ZedGraphControl.ContextMenuObjectState objState)
{
//if (PatientId == 0) return;
//menuStrip.Width = 1;
//menuItem.Visible = true;
//menuItem.Location = mousePt;
//menuItem.BringToFront();
//if (menuItem.isAdd == false)
//{
// menuItem.isAdd = true;
// zgcAnaesRecord.Controls.Add(menuItem);
//}
//添加自定义的新菜单
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 btnSyatemPhysion = new ToolStripMenuItem();
btnSyatemPhysion.Name = "btnSyatemPhysion";
btnSyatemPhysion.Tag = "btnSyatemPhysion";
btnSyatemPhysion.Text = "修改痕迹";
btnSyatemPhysion.Click += new EventHandler(btnSyatemPhysion_Click);
menuStrip.Items.Add(btnSyatemPhysion);
}
/// <summary>
/// 生命体征修改痕迹
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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 getPhysioData_Click(object sender, EventArgs e)
{
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);
//同步未画点数据
DrawFillPhysioData(dtPhysioData);
templateManage.Bind("PhysioDataManage");
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.addPhysioList)
{
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()))
{
PhysioData pdTemp = new PhysioData();
pdTemp.RecordTime = DateTime.Parse(dr["InsertTime"].ToString());
pdTemp.Value = Double.Parse(dr["ParamValue"].ToString());
pdTemp.YAisx = addPP.YAisx;
pdTemp.PhysioDataConfigId = addPP.Id;
pdTemp.PatientId = _record.Id.Value;
addPP.AddItemByTime(pdTemp);
}
}
}
}
}
private void clearSelectCouve_Click(Object sender, EventArgs e)
{
templateManage.ClearSelectCouve();
}
#endregion
#region
private void ReviewEvent()
{
if (PatientId != 0)
{
templateManage.OpeRecord = BOperationRecord.getRecord(_record, PatientId, RecoverId);
templateManage.BindOperationRecordValueAll(templateManage.OpeRecord);
reDrawEvent();
templateManage.Bind();
reDrawAnalysis();
zgcAnaesRecord.Refresh();
}
}
private void DrawEvent()
{
reDrawEvent();
templateManage.Bind("IconManage");
templateManage.Bind("RemarkManage");
zgcAnaesRecord.Refresh();
}
private void reDrawEvent()
{
ClearTimeText();
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::AIMS.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::AIMS.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::AIMS.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 ReferEventDrugs()
{
//if (IsReadOnly == false)
//BOperationRecord.Update(_record);
if (txtInRoom.Value != _record.InRoomTime)
{
_record.pageCount = 0;
ReviewEvent();
}
else
{
plRefresh_Click(null, null);
}
}
private void ClearTimeText()
{
txtInRoom.CustomFormat = " ";
txtAnaesthesiaEnd.CustomFormat = " ";
txtOutRoom.CustomFormat = " ";
txtBG.CustomFormat = " ";
txtInRoom.Tag = null;
txtAnaesthesiaEnd.Tag = null;
txtOutRoom.Tag = null;
txtBG.Tag = null;
txtInRoom.Text = "";
txtAnaesthesiaEnd.Text = "";
txtOutRoom.Text = "";
txtBG.Text = "";
this.picInRoom.BackgroundImage = global::AIMS.Properties.Resources.;
this.picBG.BackgroundImage = global::AIMS.Properties.Resources.;
this.picAnesEnd.BackgroundImage = global::AIMS.Properties.Resources.;
this.picOutRoom.BackgroundImage = global::AIMS.Properties.Resources.;
}
public DateTime getOpeMaxTime(OperationRecord myOpeRecord)
{
try
{
DateTime dts = BOperationRecord.lastMaxOperationDate(myOpeRecord.Id.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;
}
}
private bool GetOpeState(ref string message)
{
bool isTrue = true;
string anaesName = DBManage.GetDictionaryValuesById(_record.AnaesthesiaMethodId, "麻醉方式");
if (_record.AnaesthesiaMethodId == null || _record.AnaesthesiaMethodId.ToString().Trim() == "")
{
message = "请添加麻醉方式!";
isTrue = false;
}
if (anaesName.Contains("全身麻醉"))
{
if (_record.OperationDoctor == null || _record.OperationDoctor.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, 9);
BOperationRecord.UpdateState(PatientId, RecoverId, 4);
//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, "");
}
}
#endregion
#region
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 btnsbwh_Click(object sender, EventArgs e)
{
frmInstrumentRegistration frm = new frmInstrumentRegistration();
frm.Show();
}
private void btnsjzx_Click(object sender, EventArgs e)
{
MessageBox.Show("未连接到服务器 请联系管理员或稍后再试!", "系统提示");
}
private void btnChage_Click(object sender, EventArgs e)
{
frmChargRecordPrint frmchargRecord = new frmChargRecordPrint(_record);
frmchargRecord.TemplateType = "麻醉";
frmchargRecord.Show();
frmchargRecord.BringToFront();
}
#endregion
}
}