StableVersion4.3/HL_FristAidPlatform_PreHosp.../Form_EmergencyMain.cs

652 lines
28 KiB
C#

using DevExpress.XtraEditors;
using DevExpress.XtraGrid.Views.Grid;
using HL_FristAidPlatform_DTO;
using HL_FristAidPlatform_DynamicElectrocardiogram;
using HL_FristAidPlatform_Print;
using HL_FristAidPlatform_Public;
using HL_FristAidPlatform_RealTimeVideo;
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
namespace HL_FristAidPlatform_PreHospitalEmergency
{
public partial class Form_EmergencyMain : XtraForm
{
#region 变量
/// <summary>
/// 当前操作患者编号
/// </summary>
private string Cur_PatientGuid;
/// <summary>
/// 保存信息后患者所属系统模块编号(修改和新增)
/// </summary>
public long Cur_PatientSystemModuleID = 0;
/// <summary>
/// 当前患者所属院区编号(GUID)
/// </summary>
private string Cur_HospitalGuid;
/// <summary>
/// 条码机打印名称
/// </summary>
private string BarCodePrinterName = string.Empty;
/// <summary>
/// 当前页
/// </summary>
public int curPage = 1;
/// <summary>
/// 每页大小
/// </summary>
public int pageSize = 100;
/// <summary>
/// 所有记录条数
/// </summary>
public int totalNumber = 0;
/// <summary>
/// 等待窗体
/// </summary>
private Loading loading = new Loading();
#endregion
#region 分页实现
public void ExportEvents(bool singlePage)//单页,所有
{
//导出GridControl代码写在这。
}
public void RefreshGridList()
{
FillGridListCtrlQuery(curPage);//自己实现FillGridListCtrlQuery函数。
}
/// <summary>
/// 绑定数据源
/// </summary>
/// <returns></returns>
private void FillGridListCtrlQuery(int curPage)
{
try
{
#region 绑定数据源
int systemModuleID = PublicClass.ToInt32(LUEdit_SelSystemModule.EditValue, -1);
int gender = PublicClass.ToInt32(LUEdit_SelGender.EditValue, -1);
int category = PublicClass.ToInt32(radioGroup_Category.SelectedIndex, -1);
int ageStart = PublicClass.ToInt32(txt_AgeStart.Text, 0);
int ageEnd = PublicClass.ToInt32(txt_AgeEnd.Text, 200);
string strParameter = string.Empty;
//没有所有院区权限 只获取当前院区数据
if (!PublicHelp.IsHaveAllDistrictRight(Information.User.ID))
{
strParameter += "&hospitalGuid=" + Information.Hospital.GUID;
}
if (!string.IsNullOrEmpty(txt_Key.Text.ToString().Trim()))
{
strParameter += "&keyWord=" + txt_Key.Text.ToString().Trim();
}
string startTime = date_RegisterTimeStart.TimeValue;
string endTime = date_RegisterTimeEnd.TimeValue;
string Url = string.Format("api/service/T_Service_Patient?pageIndex={0}&pageSize={1}&systemModuleID={2}&registerTimeStart={3}&registerTimeEnd={4}&gender={5}&category={6}&ageStart={7}&ageEnd={8}&emergencyState=0{9}", curPage, pageSize, systemModuleID, startTime, endTime, gender, category, ageStart, ageEnd, strParameter);
DataTable ResultDT = DBHelpClass.Get(Url);
grid_Patient.DataSource = ResultDT;//显示分页结果
grv_Patient.BestFitColumns();//列宽自适应
totalNumber = DBHelpClass.TotalNumber;
userControlForPage.RefreshPager(pageSize, totalNumber, curPage);//更新分页控件显示。
#endregion
}
catch (Exception ex)
{
PublicClass.WriteErrorLog(this.Text, "绑定数据源:\r\n" + ex);
}
}
private void MyPagerEvents(int curPage, int pageSize)
{
this.curPage = curPage;
this.pageSize = pageSize;
FillGridListCtrlQuery(curPage);
}
private void userControlForPage_exportEvents(bool singlePage)
{
userControlForPage.exportEvents += ExportEvents;
}
private void userControlForPage_myPagerEvents(int curPage, int pageSize)
{
userControlForPage.myPagerEvents += MyPagerEvents;
}
#endregion
public Form_EmergencyMain()
{
InitializeComponent();
}
/// <summary>
/// 窗体加载
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Form_NewPatient_Load(object sender, EventArgs e)
{
BindData();
BarCodePrinterName = IniFiles.Read("打印机配置", "条码打印机名称", PublicClass.SystemProfileConfigFile);
date_RegisterTimeStart.TimeValue = DateTime.Now.AddDays(-7).ToShortDateString() + " 00:00:00";
date_RegisterTimeEnd.TimeValue = DateTime.Now.ToShortDateString() + " 23:59:59";
RefreshGridList();
}
#region 查询
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_Select_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
loading.ShowMessage();
RefreshGridList();
loading.HideMessage();
}
/// <summary>
/// 本月
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void simpleButton_ThisMonth_Click(object sender, EventArgs e)
{
date_RegisterTimeStart.TimeValue = DateTime.Now.AddDays(1 - DateTime.Now.Day).Date.ToShortDateString() + " 00:00:00";
date_RegisterTimeEnd.TimeValue = DateTime.Now.AddDays(1 - DateTime.Now.Day).Date.AddMonths(1).AddSeconds(-1).ToShortDateString() + " 23:59:59";
RefreshGridList();
}
/// <summary>
/// 本周
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void simpleButton_ThisWeek_Click(object sender, EventArgs e)
{
date_RegisterTimeStart.TimeValue = DateTime.Now.AddDays(Convert.ToDouble((0 - Convert.ToInt16(DateTime.Now.DayOfWeek)))).ToShortDateString() + " 00:00:00";
date_RegisterTimeEnd.TimeValue = DateTime.Now.AddDays(Convert.ToDouble((6 - Convert.ToInt16(DateTime.Now.DayOfWeek)))).ToShortDateString() + " 23:59:59";
RefreshGridList();
}
/// <summary>
/// 今天
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void simpleButton_ToDay_Click(object sender, EventArgs e)
{
date_RegisterTimeStart.TimeValue = DateTime.Now.Date.ToShortDateString() + " 00:00:00";
date_RegisterTimeEnd.TimeValue = DateTime.Now.Date.ToShortDateString() + " 23:59:59";
RefreshGridList();
}
#endregion
/// <summary>
/// 新增
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_Insert_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
//Form_AddPatient frm = new Form_AddPatient("", 1);
//if (frm.ShowDialog() == DialogResult.OK)
//{
// //直接跳转到对应系统的急救综合界面
// ShowPatientMain(frm.Cur_PatientGuid, Information.Hospital.GUID, frm.Cur_PatientSystemModuleID);
//}
//simpleButton_ThisMonth_Click(null, null);
}
/// <summary>
/// 修改
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_Update_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
try
{
if (grv_Patient.DataRowCount > 0)
{
int selectRow = grv_Patient.GetSelectedRows()[0];
string PatientID = PublicClass.ToString(grv_Patient.GetRowCellValue(selectRow, "ID"), "0");
Cur_PatientGuid = PublicClass.ToString(grv_Patient.GetRowCellValue(selectRow, "GUID"), "");
Cur_HospitalGuid = PublicClass.ToString(grv_Patient.GetRowCellValue(selectRow, "HospitalGuid"), "");
if (!string.IsNullOrEmpty(Cur_PatientGuid))
{
//Form_AddPatient frm = new Form_AddPatient(Cur_PatientGuid, 1);
//if (frm.ShowDialog() == DialogResult.OK)
//{
// //直接跳转到对应系统的急救综合界面
// ShowPatientMain(Cur_PatientGuid, Cur_HospitalGuid, frm.Cur_PatientSystemModuleID);
//}
btn_Select_ItemClick(null, null);
//定位
PublicClass.LocationForGridView(grv_Patient, PatientID.ToString(), 0);
}
}
}
catch (Exception ex)
{
PublicClass.WriteErrorLog(this.Text, "修改:\r\n" + ex);
}
}
/// <summary>
/// 打开对应各系统中的急救综合界面
/// 用于双击打开和新增自动弹出
/// </summary>
/// <param name="patientGuid">患者编号(GUID)</param>
/// <param name="hospitalGuid">患者所属院区编号(GUID)</param>
/// <param name="patientSystemModuleID">所属系统模块</param>
private void ShowPatientMain(string patientGuid, string hospitalGuid, long patientSystemModuleID)
{
try
{
//胸痛中心系统
if (patientSystemModuleID.ToString() == PublicClassForDataBase.Config10001)
{
Form form = PublicHelp.GetReflection("HL_FristAidPlatform_ChestPain", "Form_ChestPain_PatientMain", 0, patientGuid, hospitalGuid, Enumerate.PatientMainState., false, "", "", "", 0);
form.ShowDialog();
}
//卒中中心系统
else if (patientSystemModuleID.ToString() == PublicClassForDataBase.Config10002)
{
Form form = PublicHelp.GetReflection("HL_FristAidPlatform_Apoplexy", "Form_PatientMain", 0, patientGuid, hospitalGuid, Enumerate.PatientMainState., false);
form.ShowDialog();
}
//创伤救治中心系统
else if (patientSystemModuleID.ToString() == PublicClassForDataBase.Config10003)
{
}
//危重孕产妇救治中心系统
else if (patientSystemModuleID.ToString() == PublicClassForDataBase.Config10004)
{
}
//危重新生儿救治中心系统
else if (patientSystemModuleID.ToString() == PublicClassForDataBase.Config10005)
{
}
}
catch (Exception ex)
{
PublicClass.WriteErrorLog(this.Text, "打开对应各系统中的急救综合界面:\r\n" + ex);
}
}
/// <summary>
/// 退出
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_Exit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
Close();
}
/// <summary>
/// 删除
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_Delete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
try
{
if (grv_Patient.DataRowCount > 0)
{
int selectRow = grv_Patient.GetSelectedRows()[0];
string guid = grv_Patient.GetRowCellValue(selectRow, "GUID").ToString();
if (XtraMessageBox.Show(string.Format("确定要删除患者【{0}】的信息么?", grv_Patient.GetRowCellValue(selectRow, "Name").ToString()), "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
List<T_Service_PatientDTO> list = new List<T_Service_PatientDTO>();
T_Service_PatientDTO model = new T_Service_PatientDTO();
model.GUID = guid;
model.DeleteFlag = 1;
#region 赋值不更新
model.CreationDate = PublicClass.DateTimeNow();
model.RegisterTime = PublicClass.DateTimeNow();
model.EditTime = PublicClass.DateTimeNow();
#endregion
list.Add(model);
string Url = "api/service/T_Service_Patient/Delete";
//初始化两个工厂
ClientFactory<T_Service_PatientDTO> httpClient = new HttpClientFactory<T_Service_PatientDTO>();
Client<T_Service_PatientDTO> client = httpClient.VisitFactory();
//访问
ListEntity<T_Service_PatientDTO> t = client.Post(Url, list);
if (t.Success)
{
XtraMessageBox.Show("已删除!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
//绑定列表
RefreshGridList();
}
else
{
XtraMessageBox.Show("删除失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
catch (Exception ex)
{
PublicClass.WriteErrorLog(this.Text, "删除:\r\n" + ex);
}
}
#region 绑定数据
/// <summary>
/// 绑定数据
/// </summary>
private void BindData()
{
BindGender();
BindSystemModule();
}
/// <summary>
/// 绑定性别
/// </summary>
private void BindGender()
{
try
{
DataTable GenderDT = DBHelpClass.Get("/api/base/T_Base_Gender/GetList");
PublicClass.SetLookUpList(ref LUEdit_SelGender, GenderDT, 1, 2, true, "全部");
}
catch (Exception ex)
{
PublicClass.WriteErrorLog(this.Text, "绑定性别:\r\n" + ex);
}
}
/// <summary>
/// 绑定所属系统模块
/// </summary>
private void BindSystemModule()
{
try
{
DataTable ResultDT = DBHelpClass.Get("/api/admin/T_SYS_SystemModule/GetIsHaveTimeAxisList?isHaveTimeAxis=0");
PublicClass.SetLookUpList(ref LUEdit_SelSystemModule, ResultDT, 0, 2, true, "全部");
}
catch (Exception ex)
{
PublicClass.WriteErrorLog(this.Text, "绑定所属系统模块:\r\n" + ex);
}
}
#endregion
/// <summary>
/// 打印条码
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_PrintBarCode_Click(object sender, EventArgs e)
{
try
{
#region 打印条码
if (grv_Patient.DataRowCount > 0)
{
if (!string.IsNullOrEmpty(Cur_PatientGuid))
{
#region 定义条码表
DataTable PrintBarCodeDT = new DataTable();
PrintBarCodeDT.Columns.Add("BarCode");//0.条码=病人编号#时间节点编号
PrintBarCodeDT.Columns.Add("PrintNumber");//1.打印张数
PrintBarCodeDT.Columns.Add("PatientID");//2.患者编号
PrintBarCodeDT.Columns.Add("PatientName");//3.患者姓名
PrintBarCodeDT.Columns.Add("PatientGender");//4.患者性别
PrintBarCodeDT.Columns.Add("PatientAge");//5.患者年龄
PrintBarCodeDT.Columns.Add("SystemModule");//6.模块名称
PrintBarCodeDT.Columns.Add("TimeAxisID");//7.时间节点编号
PrintBarCodeDT.Columns.Add("TimeAxisName");//8.时间节点名称
PrintBarCodeDT.Columns.Add("Registertime");//9.登记时间
PrintBarCodeDT.Columns.Add("DiseaseTime");//10.发病时间
#endregion
int selectRow = grv_Patient.GetSelectedRows()[0];
string PatientID = PublicClass.ToString(grv_Patient.GetRowCellValue(selectRow, "ID"), "0");
string Name = PublicClass.ToString(grv_Patient.GetRowCellValue(selectRow, "Name"), "");
string Gender = PublicClass.ToString(grv_Patient.GetRowCellValue(selectRow, "GenderName"), "");
string Age = PublicClass.ToString(grv_Patient.GetRowCellValue(selectRow, "Age"), "");
string SystemModule = PublicClass.ToString(grv_Patient.GetRowCellValue(selectRow, "SystemModule"), "");
int SystemModuleID = PublicClass.ToInt32(grv_Patient.GetRowCellValue(selectRow, "SystemModuleID"), -1);
string Registertime = PublicClass.ToString(grv_Patient.GetRowCellValue(selectRow, "RegisterTime"), "");//登记时间
string DiseaseTime = PublicClass.ToString(grv_Patient.GetRowCellValue(selectRow, "DiseaseTime"), "");//发病时间
string Url = string.Format("api/base/T_Base_TimeAxis/GetTimeAxisByIsPrintBarCode?isPrintBarCode=0&systemModuleID={0}", SystemModuleID);
DataTable BarCodeDT = DBHelpClass.Get(Url);
if (BarCodeDT != null && BarCodeDT.Rows.Count > 0)
{
foreach (DataRow row in BarCodeDT.Rows)
{
//循环打印
PrintBarCodeDT.Rows.Clear();
int PrintBarCodeNumber = PublicClass.ToInt32(row["PrintBarCodeNumber"], 1);
DataRow dr = PrintBarCodeDT.NewRow();
dr["BarCode"] = PatientID + PublicClassForDataBase.Config100 + row["ID"];
dr["PrintNumber"] = PrintBarCodeNumber;
dr["PatientID"] = PatientID;
dr["PatientName"] = Name;
dr["PatientGender"] = Gender;
dr["PatientAge"] = Age;
dr["SystemModule"] = row["SystemModule"];
dr["TimeAxisID"] = row["ID"];
dr["TimeAxisName"] = row["TimeName"];
dr["Registertime"] = Registertime;
dr["DiseaseTime"] = DiseaseTime;
PrintBarCodeDT.Rows.Add(dr);
#region 按设置的打印张数开始打印
for (int i = 0; i < PrintBarCodeNumber; i++)
{
HL_FristAidPlatform_Print.PrintByGridpp print = new HL_FristAidPlatform_Print.PrintByGridpp();
print.PrintReport(PrintBarCodeDT, BarCodePrinterName, "TimeAxisTxm.grf", ckb_IsPrintPreview.Checked);
}
#endregion
}
}
else
{
XtraMessageBox.Show("目前系统设置中没有需要打印时间节点条码或数据获取失败!请联系管理员。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
else
{
XtraMessageBox.Show("请先在右侧选择患者信息后再打印标签!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
#endregion
}
catch (Exception ex)
{
PublicClass.WriteErrorLog(this.Text, "打印条码:\r\n" + ex);
}
}
/// <summary>
/// 单击赋值
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void grid_Patient_MouseClick(object sender, MouseEventArgs e)
{
if (grv_Patient.DataRowCount > 0)
{
int selectRow = grv_Patient.GetSelectedRows()[0];
long SystemModuleID = PublicClass.ToInt64(grv_Patient.GetRowCellValue(selectRow, "SystemModuleID").ToString(), 0);
Cur_PatientGuid = PublicClass.ToString(grv_Patient.GetRowCellValue(selectRow, "GUID").ToString(), "");
}
}
/// <summary>
/// 当在设备上发放心电设备时在系统获取病人信息
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_GetInfo_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
Form_CheckInECGPatient frm = new Form_CheckInECGPatient();
if (frm.ShowDialog() == DialogResult.OK)
{
btn_Select_ItemClick(null, null);
}
}
/// <summary>
/// 颜色绘制
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void grv_Patient_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
{
GridView View = sender as GridView;
if (e.Column.FieldName == "EmergencyStateCase")
{
string cellValue = PublicClass.ToString(e.CellValue, "");
if (!string.IsNullOrEmpty(cellValue))
{
if (cellValue == Enumerate.EmergencyState..ToString())
{
e.Appearance.ForeColor = Color.Red;
}
if (cellValue == Enumerate.EmergencyState..ToString())
{
e.Appearance.ForeColor = Color.Green;//字体颜色
//e.Appearance.BackColor = Color.Green;//背景色
#region 背景渐变色
//e.Appearance.BackColor = Color.Red;
//e.Appearance.BackColor2 = Color.FromArgb(255, 255, 255);
#endregion
}
}
}
}
/// <summary>
/// 双击跳转
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void grid_Patient_MouseDoubleClick(object sender, MouseEventArgs e)
{
try
{
if (grv_Patient.DataRowCount > 0)
{
int selectRow = grv_Patient.GetSelectedRows()[0];
long SystemModuleID = PublicClass.ToInt64(grv_Patient.GetRowCellValue(selectRow, "SystemModuleID"), 0);
Cur_PatientGuid = PublicClass.ToString(grv_Patient.GetRowCellValue(selectRow, "GUID"), "");
Cur_HospitalGuid = PublicClass.ToString(grv_Patient.GetRowCellValue(selectRow, "HospitalGuid"), "");
if (!string.IsNullOrEmpty(Cur_PatientGuid))
{
//直接跳转到对应系统的急救综合界面
ShowPatientMain(Cur_PatientGuid, Cur_HospitalGuid, SystemModuleID);
}
}
}
catch (Exception ex)
{
PublicClass.WriteErrorLog(this.Text, "双击跳转:\r\n" + ex);
}
}
/// <summary>
/// 列表操作
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void repositoryItemButtonEdit_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
{
if (grv_Patient.DataRowCount > 0)
{
int selectRow = grv_Patient.GetSelectedRows()[0];
//所属模块编号
long SystemModuleID = PublicClass.ToInt64(grv_Patient.GetRowCellValue(selectRow, "SystemModuleID"), 0);
//患者编号
string PatientGuid = PublicClass.ToString(grv_Patient.GetRowCellValue(selectRow, "GUID"), "");
//患者姓名
string PatientName = PublicClass.ToString(grv_Patient.GetRowCellValue(selectRow, "Name"), "");
//患者年龄
string PatientAge = PublicClass.ToString(grv_Patient.GetRowCellValue(selectRow, "Age"), "");
//患者性别
string PatientGenderName = PublicClass.ToString(grv_Patient.GetRowCellValue(selectRow, "GenderName"), "");
//所属医院编号
string HospitalGuid = PublicClass.ToString(grv_Patient.GetRowCellValue(selectRow, "HospitalGuid"), "");
//心电合同号
string WardshipId = PublicClass.ToString(grv_Patient.GetRowCellValue(selectRow, "WardshipId"), "");
if (!string.IsNullOrEmpty(PatientGuid))
{
switch (e.Button.Caption)
{
case "查看病例":
loading.ShowMessage();
//直接跳转到对应系统的急救综合界面
ShowPatientMain(Cur_PatientGuid, Cur_HospitalGuid, SystemModuleID);
loading.HideMessage();
break;
case "动态监护":
if (!string.IsNullOrEmpty(WardshipId))
{
loading.ShowMessage("请稍候", "正在加载【" + PatientName + "】的心电监测...");
Form_DynamicElectrocardiogramDetailed form = new Form_DynamicElectrocardiogramDetailed(PatientName, PatientAge, PatientGenderName, WardshipId);
form.WindowState = FormWindowState.Maximized;
form.Show();
}
else
{
XtraMessageBox.Show("当前患者没有实现动态监护仪,请核实!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
loading.HideMessage();
break;
case "实时视频":
loading.ShowMessage("请稍候", "正在加载【" + PatientName + "】的车载视频...");
Form_RealTimeVideo form_RealTimeVideo = new Form_RealTimeVideo(PatientGuid);
form_RealTimeVideo.WindowState = FormWindowState.Maximized;
form_RealTimeVideo.Show();
loading.HideMessage();
break;
default:
break;
}
}
}
}
private void Form_EmergencyMain_FormClosed(object sender, FormClosedEventArgs e)
{
this.Dispose();
}
}
}