using DevExpress.Utils; using DevExpress.XtraEditors; using DevExpress.XtraEditors.Controls; using DevExpress.XtraEditors.Repository; using DevExpress.XtraGrid.Views.Grid; using DevExpress.XtraGrid.Views.Grid.ViewInfo; using HL_FristAidPlatform_DTO; using HL_FristAidPlatform_Print; using HL_FristAidPlatform_Public; using System; using System.Collections.Generic; using System.Data; using System.Drawing; using System.Windows.Forms; namespace HL_FristAidPlatform_EmergencyTriage { public partial class Form_EmergencyMain : XtraForm { #region 变量 /// /// 当前操作派车单编号 /// private string Cur_Guid; /// /// 保存信息后患者所属系统模块编号(修改和新增) /// public long Cur_PatientSystemModuleID = 0; /// /// 当前患者所属院区编号(GUID) /// private string Cur_HospitalGuid; /// /// 条码机打印名称 /// private string BarCodePrinterName = string.Empty; /// /// 当前页 /// public int curPage = 1; /// /// 每页大小 /// public int pageSize = 100; /// /// 所有记录条数 /// public int totalNumber = 0; private DataTable ResultCall = null; public int accidentType = -1; public int transport = -1; DateTime dt = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")); /// /// 等待窗体 /// private Loading loading = new Loading(); #endregion public Form_EmergencyMain() { InitializeComponent(); } /// /// 窗体加载 /// /// /// private void Form_NewPatient_Load(object sender, EventArgs e) { BindAmbulance(); date_RegisterTimeStart.TimeValue = DateTime.Now.AddDays(-7).ToString(); date_RegisterTimeEnd.TimeValue = DateTime.Now.ToString(); FillGridListCtrlQuery(curPage); } #region 菜单按钮/控件点击事件 /// /// 查询 /// /// /// private void btn_Select_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { } /// /// 本月 /// /// /// 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"; } /// /// 本周 /// /// /// 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"; } /// /// 今天 /// /// /// 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"; } /// /// 新增 /// /// /// //private void btn_Insert_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) //{ // Form_EditPatient frm = new Form_EditPatient("", "", "", "", "", "", "", "", "", "", "", "", "",0); // if (frm.ShowDialog() == DialogResult.OK) // { // //直接跳转到对应系统的急救综合界面 // ShowPatientMain(frm.Cur_Guid, Information.Hospital.GUID, frm.Cur_PatientSystemModuleID); // } // simpleButton_ThisMonth_Click(null, null); //} /// /// 修改 /// /// /// private void btn_Update_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { try { if (gridView_TaxiHospital.DataRowCount > 0) { int selectRow = gridView_TaxiHospital.GetSelectedRows()[0]; string PatientID = PublicClass.ToString(gridView_TaxiHospital.GetRowCellValue(selectRow, "ID"), "0"); Cur_Guid = PublicClass.ToString(gridView_TaxiHospital.GetRowCellValue(selectRow, "GUID"), ""); Cur_HospitalGuid = PublicClass.ToString(gridView_TaxiHospital.GetRowCellValue(selectRow, "HospitalGuid"), ""); if (!string.IsNullOrEmpty(Cur_Guid)) { //HL_FristAidPlatform_Public.Form_AddPatient frm = new HL_FristAidPlatform_Public.Form_AddPatient(Cur_Guid, 1); //if (frm.ShowDialog() == DialogResult.OK) //{ // //直接跳转到对应系统的急救综合界面 // ShowPatientMain(Cur_Guid, Cur_HospitalGuid, frm.Cur_PatientSystemModuleID); //} btn_Select_ItemClick(null, null); //定位 PublicClass.LocationForGridView(gridView_TaxiHospital, PatientID.ToString(), 0); } } } catch (Exception ex) { PublicClass.WriteErrorLog(this.Text, "修改:\r\n" + ex); } } /// /// 删除 /// /// /// private void btn_Delete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { try { if (gridView_TaxiHospital.DataRowCount > 0) { int selectRow = gridView_TaxiHospital.GetSelectedRows()[0]; string PatientGuid = gridView_TaxiHospital.GetRowCellValue(selectRow, "GUID").ToString(); string PatientName = gridView_TaxiHospital.GetRowCellValue(selectRow, "Name").ToString(); DeletePatient(PatientGuid, PatientName); } } catch (Exception ex) { PublicClass.WriteErrorLog(this.Text, "删除:\r\n" + ex); } } /// /// 删除患者信息 /// /// 患者编号 /// 患者姓名 /// private void DeletePatient(string PatientGuid, string PatientName) { try { if (XtraMessageBox.Show(string.Format("确定要删除患者【{0}】的信息么?", PatientName), "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { string Url = "api/service/T_Service_Patient/Delete"; List list = new List(); T_Service_PatientDTO model = new T_Service_PatientDTO(); model.GUID = PatientGuid; model.DeleteFlag = 1; #region 赋值不更新 model.CreationDate = PublicClass.DateTimeNow(); model.RegisterTime = PublicClass.DateTimeNow(); model.EditTime = PublicClass.DateTimeNow(); #endregion list.Add(model); //初始化两个工厂 ClientFactory httpClient = new HttpClientFactory(); Client client = httpClient.VisitFactory(); //访问 ListEntity t = client.Post(Url, list); if (t.Success) { XtraMessageBox.Show(string.Format("患者【{0}】的信息已删除!", PatientName), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); //绑定列表 } else { XtraMessageBox.Show("删除患者信息失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch (Exception ex) { PublicClass.WriteErrorLog(this.Text, "删除:\r\n" + ex); } } /// /// 退出 /// /// /// private void btn_Exit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { Close(); } /// /// 双击跳转 /// /// /// private void grid_Patient_MouseDoubleClick(object sender, MouseEventArgs e) { try { if (gridView_TaxiHospital.DataRowCount > 0) { int selectRow = gridView_TaxiHospital.GetSelectedRows()[0]; long SystemModuleID = PublicClass.ToInt64(gridView_TaxiHospital.GetRowCellValue(selectRow, "SystemModuleID"), 0); Cur_Guid = PublicClass.ToString(gridView_TaxiHospital.GetRowCellValue(selectRow, "GUID"), ""); Cur_HospitalGuid = PublicClass.ToString(gridView_TaxiHospital.GetRowCellValue(selectRow, "HospitalGuid"), ""); if (!string.IsNullOrEmpty(Cur_Guid)) { //直接跳转到对应系统的急救综合界面 ShowPatientMain(Cur_Guid, Cur_HospitalGuid, SystemModuleID); } } } catch (Exception ex) { PublicClass.WriteErrorLog(this.Text, "双击跳转:\r\n" + ex); } } /// /// 打开对应各系统中的急救综合界面 /// /// 患者编号(GUID) /// 患者所属院区编号(GUID) /// 所属系统模块 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); form.Show(); } //卒中中心系统 else if (patientSystemModuleID.ToString() == PublicClassForDataBase.Config10002) { Form form = PublicHelp.GetReflection("HL_FristAidPlatform_Apoplexy", "Form_PatientMain", 0, patientGuid, hospitalGuid, Enumerate.PatientMainState.急救信息, false); form.Show(); } //创伤救治中心系统 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); } } #endregion public void BindAmbulance() { string url = string.Format("/api/base/T_Base_Ambulance/GetListForState?state={0}&hospitalGuid={1}", 0, Information.Hospital.GUID); DataTable dt = DBHelpClass.Get(url); PublicClass.SetLookUpList(lookUpEdit1, dt, "GUID", "PlateNumber", true, "请选择"); } /// /// 绑定数据源 /// /// private void FillGridListCtrlQuery(int curPage) { try { string ambulanceGuid = lookUpEdit1.EditValue.ToString() == "-1" ? "" : lookUpEdit1.EditValue.ToString(); string url = string.Format("api/service/T_Service_FirstAid_AlarmTaskInfo/GetAlarmTaskInfoFinishList?hospitalGuid={0}&time1={1}&time2={2}&accidentType={3}&ambulanceGuid={4}&transport={5}&pageIndex={6}&pageSize={7}", Information.Hospital.GUID, date_RegisterTimeStart.TimeValue, date_RegisterTimeEnd.TimeValue, accidentType, ambulanceGuid, transport, curPage, pageSize); ResultCall = DBHelpClass.Get(url); gridControl_TaxiHospital.DataSource = ResultCall;//显示分页结果 gridView_TaxiHospital.Appearance.EvenRow.BackColor = Color.FromArgb(245, 245, 245); gridView_TaxiHospital.Appearance.OddRow.BackColor = Color.FromArgb(255, 255, 255); gridView_TaxiHospital.OptionsView.EnableAppearanceEvenRow = true; gridView_TaxiHospital.OptionsView.EnableAppearanceOddRow = true; totalNumber = DBHelpClass.TotalNumber; userControlForPage.RefreshPager(pageSize, totalNumber, curPage);//更新分页控件显示。 } 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 gridView_TaxiHospital_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e) { GridView View = sender as GridView; if (e.Column.FieldName == "MajorEvents") { int majorEvents = PublicClass.ToInt32(e.Value, 0); switch (majorEvents) { case 0: e.DisplayText = "非重大事故"; break; case 1: e.DisplayText = "重大事故"; break; default: break; } } if (e.Column.FieldName == "Gender") { int gender = PublicClass.ToInt32(e.Value, 0); switch (gender) { case 0: e.DisplayText = "未知"; break; case 1: e.DisplayText = "男"; break; case 2: e.DisplayText = "女"; break; default: break; } } } /// /// 动态按钮事件 /// /// /// private void RiButtonEdit_ButtonClick(object sender, ButtonPressedEventArgs e) { int selectRow = gridView_TaxiHospital.GetSelectedRows()[0]; string guid = PublicClass.ToString(gridView_TaxiHospital.GetRowCellValue(selectRow, "TaskGUID").ToString(), ""); string name = PublicClass.ToString(gridView_TaxiHospital.GetRowCellValue(selectRow, "Name").ToString(), ""); string age = PublicClass.ToString(gridView_TaxiHospital.GetRowCellValue(selectRow, "Age").ToString(), ""); string gender = PublicClass.ToString(gridView_TaxiHospital.GetRowCellValue(selectRow, "Gender").ToString(), ""); string phone = "";//PublicClass.ToString(gridView_TaxiHospital.GetRowCellValue(selectRow, "Phone").ToString(), ""); switch (e.Button.Caption) { case "分诊"://string taskGuid, string _name, string _age, string _gender, string _phone Form_PreTriage frm = new Form_PreTriage(guid, name, age, gender, phone); frm.Owner = this; frm.Show(); break; case "录入病历": Form_EMR main = new Form_EMR(guid, name, age, gender, phone); main.StartPosition = FormStartPosition.CenterScreen; main.Owner = this; main.Show(); break; } } private void Form_EmergencyMain_FormClosed(object sender, FormClosedEventArgs e) { this.Dispose(); } private void simpleButton1_Click(object sender, EventArgs e) { FillGridListCtrlQuery(curPage); } private void radioButton5_CheckedChanged(object sender, EventArgs e) { if (radioButton5.Checked == true) accidentType = 0; } private void radioButton4_CheckedChanged(object sender, EventArgs e) { if (radioButton4.Checked == true) accidentType = 1; } private void radioButton2_CheckedChanged(object sender, EventArgs e) { if (radioButton2.Checked == true) transport = 1; } private void radioButton3_CheckedChanged(object sender, EventArgs e) { if (radioButton3.Checked == true) transport = 0; } private void radioButton1_CheckedChanged(object sender, EventArgs e) { if (radioButton1.Checked == true) accidentType = -1; } private void radioButton6_CheckedChanged(object sender, EventArgs e) { if (radioButton6.Checked == true) transport = -1; } private void simpleButton2_Click(object sender, EventArgs e) { date_RegisterTimeStart.TimeValue = DateTime.Now.ToString(); date_RegisterTimeEnd.TimeValue = DateTime.Now.ToString(); FillGridListCtrlQuery(curPage); } private void simpleButton3_Click(object sender, EventArgs e) { DateTime startWeek = dt.AddDays(1 - Convert.ToInt32(dt.DayOfWeek.ToString("d"))); DateTime endWeek = startWeek.AddDays(6); date_RegisterTimeStart.TimeValue = startWeek.ToString(); date_RegisterTimeEnd.TimeValue = endWeek.ToString(); FillGridListCtrlQuery(curPage); } private void simpleButton4_Click(object sender, EventArgs e) { DateTime startMonth = dt.AddDays(1 - dt.Day); DateTime endMonth = startMonth.AddMonths(1).AddDays(-1); date_RegisterTimeStart.TimeValue = startMonth.ToString(); date_RegisterTimeEnd.TimeValue = endMonth.ToString(); FillGridListCtrlQuery(curPage); } private void simpleButton5_Click(object sender, EventArgs e) { DateTime startYear = new DateTime(dt.Year, 1, 1); DateTime endYear = new DateTime(dt.Year, 12, 31); date_RegisterTimeStart.TimeValue = startYear.ToString(); date_RegisterTimeEnd.TimeValue = endYear.ToString(); FillGridListCtrlQuery(curPage); } private void simpleButton6_Click(object sender, EventArgs e) { date_RegisterTimeStart.TimeValue = ""; date_RegisterTimeEnd.TimeValue = ""; FillGridListCtrlQuery(curPage); } private void userControlForPage_myPagerEvents(int curPage, int pageSize) { userControlForPage.myPagerEvents += MyPagerEvents; } private void gridView_TaxiHospital_CustomRowCellEdit(object sender, CustomRowCellEditEventArgs e) { try { RepositoryItemButtonEdit riButtonEdit = new RepositoryItemButtonEdit(); riButtonEdit.Buttons.Clear(); if (e.Column.Name == "gridColumn_operate") { riButtonEdit.TextEditStyle = TextEditStyles.HideTextEditor; EditorButton bt1 = new EditorButton(); bt1.Kind = ButtonPredefines.Glyph; bt1.Appearance.ForeColor = Color.FromArgb(45, 140, 240); bt1.Caption = "分诊"; bt1.Appearance.TextOptions.HAlignment = HorzAlignment.Center; riButtonEdit.Buttons.Add(bt1); EditorButton bt2 = new EditorButton(); bt2.Kind = ButtonPredefines.Glyph; bt2.Appearance.ForeColor = Color.FromArgb(45, 140, 240); bt2.Caption = "录入病历"; bt2.Appearance.TextOptions.HAlignment = HorzAlignment.Center; riButtonEdit.Buttons.Add(bt2); } riButtonEdit.ButtonClick += RiButtonEdit_ButtonClick; e.RepositoryItem = riButtonEdit; } catch (Exception) { throw; } } } }