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

575 lines
24 KiB
C#

using AIMS.OremrUserControl;
using AIMSBLL;
using AIMSExtension;
using AIMSModel;
using DrawGraph;
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Net;
using System.Windows.Forms;
namespace AIMS.OperationAanesthesia
{
public partial class frmSelectPatientNew3 : Form
{
public int SelPatientId;
public int SelApplyId;
public bool isMainOpen = false;
public AIMS.OperationAanesthesia.frmAanesthesiaPainlessRecord tempfrmAnasRecord;
public frmSelectPatientNew3()
{
InitializeComponent();
}
private string[] Day = new string[] { "周日", "周一", "周二", "周三", "周四", "周五", "周六" };
private void frmSelectPatientNew3_Load(object sender, EventArgs e)
{
ControlExtension.GetOperationSiteRoom(labelSite, CboOperationSite, cboRoom, "内镜室");
string week = Day[Convert.ToInt32(DateTime.Now.DayOfWeek.ToString("d"))].ToString();
cboRoom.Text = "";
if (week == "周一")
dtpSelectPatientTime.Value = DateTime.Now.AddDays(-3);
else
dtpSelectPatientTime.Value = DateTime.Now.AddDays(-1);
dtpSelectPatientTime2.Value = DateTime.Now;
FillDgv();
this.dtpSelectPatientTime.ValueChanged += new System.EventHandler(this.dtpSelectPatientTime_ValueChanged);
this.dtpSelectPatientTime2.ValueChanged += new System.EventHandler(this.dtpSelectPatientTime_ValueChanged);
this.cboRoom.SelectedIndexChanged += new System.EventHandler(this.cboRoom_SelectedIndexChanged);
this.CboOperationSite.SelectedIndexChanged += new System.EventHandler(this.CboOperationSite_SelectedIndexChanged);
}
private void btnNext_Click(object sender, EventArgs e)
{
dtpSelectPatientTime.Value = dtpSelectPatientTime.Value.AddDays(1);
}
private void btnFrontDay_Click(object sender, EventArgs e)
{
dtpSelectPatientTime.Value = dtpSelectPatientTime.Value.AddDays(-1);
}
private void dtpSelectPatientTime_ValueChanged(object sender, EventArgs e)
{
FillDgv();
}
private int FillDgv()
{
int count = 0;
panel3.Controls.Clear();
panel2.Visible = false;
DataTable dt = new DataTable();
if (txtquery.Text.Trim() != "")
dt = SelectPatient.GetSelectPatientDataTable(txtquery.Text);
else
dt = SelectPatient.GetSelectPatientDataTable(DateTime.Parse(dtpSelectPatientTime.Value.ToString("yyyy-MM-dd").ToString()), cboRoom.SelectedValue.ToString(), DateTime.Parse(dtpSelectPatientTime2.Value.ToString("yyyy-MM-dd 23:59:59").ToString()));
DataTable dt2 = new DataTable();
if (txtquery.Text.Trim() != "")
dt2 = SelectPatient.GetRelieveLockingPatientDataTable(txtquery.Text);
else
dt2 = SelectPatient.GetRelieveLockingPatientDataTable(DateTime.Parse(dtpSelectPatientTime.Value.ToString("yyyy-MM-dd").ToString()), cboRoom.SelectedValue.ToString(), DateTime.Parse(dtpSelectPatientTime2.Value.ToString("yyyy-MM-dd 23:59:59").ToString()));
if (CboOperationSite.Visible == true && CboOperationSite.SelectedIndex > 0)
{
dt = AIMSExtension.PublicMethod.GetNewDataTable(dt, " OperationSite ='" + CboOperationSite.SelectedValue + "' ", "");
dt2 = AIMSExtension.PublicMethod.GetNewDataTable(dt2, " OperationSite ='" + CboOperationSite.SelectedValue + "' ", "");
}
//List<string> list = new List<string>();
//for (int i = 0; i < ControlExtension.SiteRooms.Count; i++)
//{
// foreach (DataRow dr in dt.Rows)
// {
// if (dr["OperationRoom"].ToString() == ControlExtension.SiteRooms[i].Name && !list.Contains(ControlExtension.SiteRooms[i].Name))
// {
// list.Add(ControlExtension.SiteRooms[i].Name);
// }
// }
// foreach (DataRow dr in dt2.Rows)
// {
// if (dr["OperationRoom"].ToString() == ControlExtension.SiteRooms[i].Name && !list.Contains(ControlExtension.SiteRooms[i].Name))
// {
// list.Add(ControlExtension.SiteRooms[i].Name);
// }
// }
//}
//if (cboRoom.Text != "")
//{
int numi = 0, j = 0;
foreach (DataRow dr in dt2.Rows)
{
//if (dr["OperationRoom"].ToString() != cboRoom.Text) continue;
ucPatientCard uc = new ucPatientCard(dr);
uc.InRoom += Uc_InRoom;
uc.QxRoom += Uc_QxRoom;
uc.Clicks += Uc_Clicks;
uc.Location = new Point((uc.Width + 9) * j, (uc.Height + 10) * numi + 30);
panel3.Controls.Add(uc);
j++;
if (j == 5)
{
numi++;
j = 0;
}
count++;
}
foreach (DataRow dr in dt.Rows)
{
//if (dr["OperationRoom"].ToString() != cboRoom.Text) continue;
ucPatientCard uc = new ucPatientCard(dr);
uc.InRoom += Uc_InRoom;
uc.QxRoom += Uc_QxRoom;
uc.Clicks += Uc_Clicks;
uc.Location = new Point((uc.Width + 9) * j, (uc.Height + 10) * numi + 30);
panel3.Controls.Add(uc);
j++;
if (j == 5)
{
numi++;
j = 0;
}
count++;
}
//}
//else
//{
// for (int i = 0; i < list.Count; i++)
// {
// int j = 0;
// int Pointx = 0;
// foreach (DataRow dr in dt.Rows)
// {
// if (dr["OperationRoom"].ToString() != list[i]) continue;
// ucPatientCard uc = new ucPatientCard(dr);
// uc.InRoom += Uc_InRoom;
// uc.QxRoom += Uc_QxRoom;
// uc.Clicks += Uc_Clicks;
// uc.Location = new Point((uc.Width + 9) * i, (uc.Height + 10) * j + 30);
// panel3.Controls.Add(uc);
// j++; Pointx = (uc.Width + 9) * i;
// }
// foreach (DataRow dr in dt2.Rows)
// {
// if (dr["OperationRoom"].ToString() != list[i]) continue;
// ucPatientCard uc = new ucPatientCard(dr);
// uc.InRoom += Uc_InRoom;
// uc.QxRoom += Uc_QxRoom;
// uc.Clicks += Uc_Clicks;
// uc.Location = new Point((uc.Width + 9) * i, (uc.Height + 10) * j + 30);
// panel3.Controls.Add(uc);
// j++;
// Pointx = (uc.Width + 9) * i;
// }
// if (Pointx > 0)
// {
// DevComponents.DotNetBar.Controls.Line line1 = new DevComponents.DotNetBar.Controls.Line();
// line1.Location = new System.Drawing.Point(Pointx - 10, 0);
// line1.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDotDot;
// line1.Size = new System.Drawing.Size(10, panel3.Height);
// line1.ForeColor = Color.DarkGray;
// line1.VerticalLine = true;
// panel3.Controls.Add(line1);
// }
// }
//}
return count;
}
public ucPatientCard SelUc;
private void Uc_Clicks(ucPatientCard uc, int PatientId, int applyId, DataRow dr)
{
SelPatientId = PatientId;
SelApplyId = applyId;
txtType.Text = dr["OperationType"].ToString();
txtNo.Text = dr["MdrecNo"].ToString();
txtname.Text = dr["PatientName"].ToString();
txtsex.Text = dr["sex"].ToString();
txtage.Text = dr["age"].ToString();
txtss.Text = dr["ApplyOperationInfoName"].ToString();
txtmzys.Text = dr["AnesthesiaDoctor"].ToString();
txttime.Text = dr["OrderOperationTime"].ToString();
txtdept.Text = dr["ApplyDepName"].ToString();
txtzdys.Text = dr["OperationDoctor"].ToString();
txths.Text = dr["InstrumentNurse"].ToString() + " " + dr["TourNurse"].ToString();
txtzd.Text = dr["ApplyDiagnoseInfoName"].ToString();
txtRoom.Text = dr["OperationRoom"].ToString();
txtRoom.Tag = dr["OperationRoomId"].ToString();
if (!txtType.Text.Contains("急")) txtType.ForeColor = Color.DarkGreen;
else txtType.ForeColor = Color.Red;
txtState.Text = dr["State"].ToString();
if (txtState.Text == "手术中" || txtState.Text == "手术结束" || txtState.Text == "停止手术")
{
label5.Text = "手术开始时间";
label23.Text = "术中诊断";
label25.Text = "实施手术";
}
else
{
label5.Text = "申请预约时间";
label23.Text = "术前诊断";
label25.Text = "拟施手术";
}
buttonX1.Text = uc.buttonX1.Text;
panel2.Visible = true;
SelUc = uc;
}
private void Uc_InRoom(ucPatientCard uc, int PatientId, int applyId)
{
string RoomStr = uc.Tag.ToString();
if (RoomStr == "")
{
frmSeleteRoom seleteRoom = new frmSeleteRoom();
seleteRoom.ShowDialog();
if (seleteRoom.RoomId != null)
{
RoomStr = seleteRoom.RoomId.ToString();
if (RoomStr != null && RoomStr != "")
{
OperationApply opeapply = BOperationApply.SelectSingle(applyId, RecursiveType.None, 0);
opeapply.State = 4;
opeapply.OperationRoomId = int.Parse(seleteRoom.RoomId);
opeapply.PlanOperationTime = dtpSelectPatientTime.Value;
opeapply.PlanOrder = BOperationApply.GetMaxPlanOrder(opeapply.PlanOperationTime.Value, opeapply.OperationRoomId.Value) + 1;
BOperationApply.Update(opeapply);
}
}
}
if (RoomStr == "") return;
SatrtOperation(uc, PatientId, applyId, int.Parse(RoomStr));
}
private void SatrtOperation(ucPatientCard uc, int PatientId, int applyId, int RoomId)
{
try
{
string State = uc.buttonX1.Text;
if (State == "转入术间")
{
OperationApply operA = BOperationApply.SelectSingle(applyId);
if (operA.State == 11)
{
MessageBox.Show("当前手术已停止 ,请确认后重新选择!", "系统提示");
FillDgv();
return;
}
if (operA.State == 6)
{
MessageBox.Show("当前手术已开始 ,请确认后重新选择!", "系统提示");
FillDgv();
return;
}
frmAanesthesiaPainlessRecord frmAnasRecord = null;
if (tempfrmAnasRecord != null && tempfrmAnasRecord._record != null)
{
frmAnasRecord = tempfrmAnasRecord;
frmAnasRecord.ClearRecordDate();
}
else
{
frmAnasRecord = new frmAanesthesiaPainlessRecord();
}
frmAnasRecord.PatientId = PatientId;
frmAnasRecord.ApplyId = applyId;
frmAnasRecord.NowRoom = AIMSBLL.BOperationRoom.SelectSingle(RoomId);
frmAnasRecord.State = AIMSExtension.EditState.ADD;
SelectPatient.UpdateApplyState(PatientId, applyId); //修改状态
uc.label2.Text = "手术中";
uc.label2.ForeColor = Color.Red;
uc.buttonX1.Text = "继续手术";
uc.buttonX2.Text = "取消手术";
uc.buttonX1.Visible = true;
uc.buttonX2.Visible = true;
uc.panelExMain.Style.BackColor1.Color = Color.OldLace;
if (isMainOpen == false)
{
frmAnasRecord.ShowDialog();
FillDgv();
}
else
{
this.Close();
}
}
else
{
frmAanesthesiaPainlessRecord frmAnasRecord = null;
if (tempfrmAnasRecord != null && tempfrmAnasRecord._record != null)
{
frmAnasRecord = tempfrmAnasRecord;
frmAnasRecord.ClearRecordDate();
}
else
{
frmAnasRecord = new frmAanesthesiaPainlessRecord();
}
frmAnasRecord.PatientId = PatientId;
frmAnasRecord.ApplyId = applyId;
frmAnasRecord.NowRoom = AIMSBLL.BOperationRoom.SelectSingle(RoomId);
if (State == "继续手术")
{
frmAnasRecord.State = AIMSExtension.EditState.EDIT;
}
else
{
frmAnasRecord.State = AIMSExtension.EditState.BROWSE;
}
if (isMainOpen == false)
{
frmAnasRecord.ShowDialog();
FillDgv();
}
else
{
this.Close();
}
}
}
catch (Exception ex)
{
AIMSExtension.PublicMethod.WriteLog(ex);
}
}
public OperationRoom GetOperationRoom(List<OperationRoom> list)
{
try
{
//得到计算机名
string strPcName = Dns.GetHostName();
//得到本机IP地址数组
IPHostEntry ipEntry = Dns.GetHostEntry(strPcName);
//遍历数组
foreach (OperationRoom room in list)
{
foreach (var IPadd in ipEntry.AddressList)
{
//判断当前字符串是否为正确IP地址
if (PublicMethod.IsRightIP(IPadd.ToString()))
{
if (room.Ip == IPadd.ToString() || room.Ip2 == IPadd.ToString() || room.Ip3 == IPadd.ToString())
{
return room;
}
}
}
}
return null;
}
catch (Exception)
{
return null;
}
}
private void Uc_QxRoom(ucPatientCard uc, int RecorId, int PatientId, int applyId)
{
try
{
if (uc.buttonX2.Text == "取消手术")
{
if (BOperationRecord.GetDataCount(RecorId, PatientId, 1) > 0)
{
MessageBox.Show("清除数据在进行取消转入操作!");
return;
}
if (MessageBox.Show("确认要取消手术吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
try
{
HelperDB.DbHelperSQL.BeginTrans();
BOperationApply.UpdateApplyState(applyId, 4);
BOperationRecord.DeleteOperationRecordData(RecorId, PatientId, 1);
HelperDB.DbHelperSQL.CommitTrans();
if (isMainOpen == false)
{
FillDgv();
}
else
{
this.Close();
}
}
catch
{
HelperDB.DbHelperSQL.RollbackTrans();
}
}
}
else
{
if (MessageBox.Show("确认要返回手术吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
try
{
HelperDB.DbHelperSQL.BeginTrans();
BOperationApply.UpdateApplyState(applyId, 6);
BOperationRecord.UpdateOpeState(PatientId, 1, 1, "");
BOperationRecord.DeleteEvent(PatientId, 8);
HelperDB.DbHelperSQL.CommitTrans();
frmAanesthesiaPainlessRecord frmAnasRecord = null;
if (tempfrmAnasRecord != null && tempfrmAnasRecord._record != null)
{
frmAnasRecord = tempfrmAnasRecord;
frmAnasRecord.ClearRecordDate();
}
else
{
frmAnasRecord = new frmAanesthesiaPainlessRecord();
}
frmAnasRecord.PatientId = PatientId;
frmAnasRecord.ApplyId = applyId;
frmAnasRecord.NowRoom = AIMSBLL.BOperationRoom.SelectSingle(int.Parse(uc.Tag.ToString()));
frmAnasRecord.State = AIMSExtension.EditState.EDIT;
frmAnasRecord._record = new OperationRecord();
frmAnasRecord._record.Id = PatientId;
if (isMainOpen == false)
{
frmAnasRecord.ShowDialog();
FillDgv();
}
else
{
//if (frmAnasRecord._record != null)
// frmAnasRecord.ClearRecordDate();
this.Close();
}
}
catch
{
HelperDB.DbHelperSQL.RollbackTrans();
}
}
}
}
catch (Exception ex)
{
AIMSExtension.PublicMethod.WriteLog(ex);
}
}
private void cboRoom_SelectedIndexChanged(object sender, EventArgs e)
{
if (cboRoom.SelectedIndex > 0)
{
PublicMethod.SelectRoom = Convert.ToInt32(cboRoom.SelectedValue);
}
else
{
PublicMethod.SelectRoom = -1;
}
FillDgv();
}
private void buttonX1_Click(object sender, EventArgs e)
{
string RoomStr = txtRoom.Tag.ToString();
if (RoomStr == "")
{
frmSeleteRoom seleteRoom = new frmSeleteRoom();
seleteRoom.ShowDialog();
if (seleteRoom.RoomId != null)
{
RoomStr = seleteRoom.RoomId.ToString();
if (RoomStr != null && RoomStr != "")
{
OperationApply opeapply = BOperationApply.SelectSingle(SelApplyId, RecursiveType.None, 0);
opeapply.State = 4;
opeapply.OperationRoomId = int.Parse(seleteRoom.RoomId);
opeapply.PlanOperationTime = dtpSelectPatientTime.Value;
opeapply.PlanOrder = BOperationApply.GetMaxPlanOrder(opeapply.PlanOperationTime.Value, opeapply.OperationRoomId.Value) + 1;
BOperationApply.Update(opeapply);
}
}
}
if (RoomStr == "") return;
SatrtOperation(SelUc, SelPatientId, SelApplyId, (int.Parse(RoomStr)));
}
private void buttonX3_Click(object sender, EventArgs e)
{
AIMS.OperationFront.UI.frmOperationApplyDetail frmOperationApplyDetail = new AIMS.OperationFront.UI.frmOperationApplyDetail();
frmOperationApplyDetail.State = AIMSExtension.EditState.ADD;
frmOperationApplyDetail.ShowDialog();
}
private void btnQuery_Click(object sender, EventArgs e)
{
int count = FillDgv();
if (txtquery.Text.Trim() != "" && count == 0)
{
DialogResult result = MessageBox.Show("未找到'" + txtquery.Text.Trim() + "' 手术申请信息 是否从HIS同步数据?", "系统提示", MessageBoxButtons.YesNo);
if (result == DialogResult.Yes)
{
OpeApplyAnalyze opeApplyAnalyze = new OpeApplyAnalyze();
opeApplyAnalyze.Analyze(txtquery.Text.Trim());
FillDgv();
}
}
}
private void buttonX2_Click(object sender, EventArgs e)
{
string RoomStr = txtRoom.Tag.ToString();
if (RoomStr != "")
{
frmSeleteRoom seleteRoom = new frmSeleteRoom();
seleteRoom.NowRoomId = RoomStr;
seleteRoom.ShowDialog();
RoomStr = seleteRoom.RoomId;
if (RoomStr != null && RoomStr != "")
{
txtRoom.Text = seleteRoom.RoomName;
txtRoom.Tag = int.Parse(RoomStr);
BOperationRecord.Update("RoomId=@RoomId where OperationApplyId=@id ", new AIMSModel.ParameterList("@RoomId", int.Parse(RoomStr), "@id", SelApplyId));
BOperationApply.UpdateApplyRoom(SelApplyId, int.Parse(RoomStr), DateTime.Parse(txttime.Text));
BOperationApply.UpdteOperationOrder(DateTime.Parse(txttime.Text), int.Parse(RoomStr));
FillDgv();
panel2.Visible = true;
MessageBox.Show("手术间切换成功!");
}
}
}
private void CboOperationSite_SelectedIndexChanged(object sender, EventArgs e)
{
this.cboRoom.SelectedIndexChanged -= new System.EventHandler(this.cboRoom_SelectedIndexChanged);
ControlExtension.SetOperationSiteRoom(CboOperationSite, cboRoom);
cboRoom.Text = "";
FillDgv();
this.cboRoom.SelectedIndexChanged += new System.EventHandler(this.cboRoom_SelectedIndexChanged);
}
private void buttonX4_Click(object sender, EventArgs e)
{
if (txtquery.Text.Trim() != "")
{
OpeApplyAnalyze opeApplyAnalyze = new OpeApplyAnalyze();
opeApplyAnalyze.Analyze(txtquery.Text.Trim());
FillDgv();
}
}
}
}