using System; using System.Collections.Generic; using System.Data; using System.Windows.Forms; using DevExpress.XtraEditors; using HL_FristAidPlatform_DTO; using HL_FristAidPlatform_Public; namespace HL_FristAidPlatform_FollowUp { public partial class Form_FollowUpTemplate_ChestPain : XtraForm { /// /// 当前页 /// private int curPage = 1; /// /// 所有记录条数 /// public int totalNumber = 0; /// /// 每页大小 /// private int pageSize = 100; private string pGuid; #region 分页 private void FillGridListCtrlQuery(int curPage) { string Url = string.Empty; string strParameter = ""; //没有所有院区权限 只获取当前院区数据 if (!PublicHelp.IsHaveAllDistrictRight(Information.User.ID)) { strParameter = Information.Hospital.GUID; } Url = string.Format("api/service/T_Service_FollowUpTemplate?pageIndex={0}&pageSize={1}",curPage, pageSize); DataTable patientDT = DBHelpClass.Get(Url); gridControl1.DataSource = patientDT; int totalNumber = DBHelpClass.TotalNumber; userControlForPage.RefreshPager(1, totalNumber, curPage);//更新分页控件显示。 } private void userControlForPage_exportEvents(bool singlePage) { userControlForPage.exportEvents += ExportEvents; } private void userControlForPage_myPagerEvents(int curPage, int pageSize) { userControlForPage.myPagerEvents += MyPagerEvents; } private void MyPagerEvents(int curPage, int pageSize) { this.curPage = curPage; this.pageSize = pageSize; FillGridListCtrlQuery(curPage); } public void ExportEvents(bool singlePage)//单页,所有 { //导出GridControl代码写在这。 } #endregion public Form_FollowUpTemplate_ChestPain(string patientGuid) { InitializeComponent(); pGuid = patientGuid; } /// /// 创建随访计划 /// /// /// private void Form_FollowUpTemplate_Load(object sender, EventArgs e) { FillGridListCtrlQuery(1); } public void GetOrUpdate(string Cur_FollUpTemplateID) { List patientDTOs = new List(); T_Service_FollowUpTemplateDTO PrehospitalDTO = new T_Service_FollowUpTemplateDTO(); string Url = string.Empty; ClientFactory httpClient = new HttpClientFactory(); Client client = httpClient.VisitFactory(); DataTable dataTable = new DataTable(); //dataTable = DBHelpClass.Get("api/service/T_Service_FollowUp/GetByPatientGuid?patientGuid=" + Cur_PatientID + ""); if (!string.IsNullOrEmpty(Cur_FollUpTemplateID)) { dataTable = DBHelpClass.GetDataRow("api/service/T_Service_FollowUpTemplate/" + Cur_FollUpTemplateID + ""); if (dataTable.Rows.Count > 0) { Url = "api/service/T_Service_FollowUpTemplate/Update"; PrehospitalDTO.ID = int.Parse(dataTable.Rows[0]["ID"].ToString()); PrehospitalDTO.GUID = dataTable.Rows[0]["GUID"]+""; } } else { Url = "api/service/T_Service_FollowUpTemplate"; PrehospitalDTO.GUID = Guid.NewGuid().ToString(); } PrehospitalDTO.Name = textEdit_Name.Text; PrehospitalDTO.Type = cmb_Classify.Text; PrehospitalDTO.CreateTime = PublicClass.DateTimeNow(); PrehospitalDTO.DeleteFlag = checkBox_DeleteFlag.Checked == true ? 0 : 1; PrehospitalDTO.Note = memoEdit_Note.Text; patientDTOs.Add(PrehospitalDTO); //访问 ListEntity t = client.Post(Url, patientDTOs); if (t.Success) { XtraMessageBox.Show("保存系统信息成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { XtraMessageBox.Show("保存失败,请稍后重试!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } /// /// 绑定 /// /// /// public void Bind(string Guid) { DataTable dataTable = new DataTable(); if (!string.IsNullOrEmpty(Guid)) { dataTable = DBHelpClass.GetDataRow("api/service/T_Service_FollowUpTemplate/" + Guid + ""); } if (dataTable != null) { if (dataTable.Rows.Count > 0) { textEdit_Name.Text = dataTable.Rows[0]["Name"] + ""; checkBox_DeleteFlag.Checked = dataTable.Rows[0]["DeleteFlag"].ToString() == "0" ? true : false; cmb_Classify.Text= dataTable.Rows[0]["Type"] + ""; memoEdit_Note.Text= dataTable.Rows[0]["Note"] + ""; } } } private void gridControl1_MouseDoubleClick(object sender, MouseEventArgs e) { if (gridView1.DataRowCount > 0) { int selectRow = gridView1.GetSelectedRows()[0]; //long PatientID = PublicClass.ToInt64(gridView1.GetRowCellValue(selectRow, "id").ToString(), 0); string GUID = gridView1.GetRowCellValue(selectRow, "GUID").ToString(); if (!string.IsNullOrEmpty(GUID)) { Bind(GUID); string Url = string.Format("api/service/T_Service_FollowUpTemplateChild?pageIndex={0}&pageSize={1}&patientGuid={2}", curPage, pageSize, GUID); DataTable patientDT = DBHelpClass.Get(Url); gridControl2.DataSource = patientDT; } } } /// /// 保存 /// /// /// private void btn_Save_Click(object sender, EventArgs e) { int selectRow = gridView1.GetSelectedRows()[0]; string GUID = gridView1.GetRowCellValue(selectRow, "GUID").ToString(); GetOrUpdate(GUID); } private void button_Query_Click(object sender, EventArgs e) { string Url = string.Format("api/service/T_Service_FollowUpTemplate?pageIndex={0}&pageSize={1}", curPage, pageSize); DataTable patientDT = DBHelpClass.Get(Url); gridControl1.DataSource = patientDT; int totalNumber = DBHelpClass.TotalNumber; userControlForPage.RefreshPager(1, totalNumber, curPage);//更新分页控件显示。 } private void simpleButton_apply_Click(object sender, EventArgs e) { bool flag = false; if (gridView1.DataRowCount > 0) { int selectRow = gridView1.GetSelectedRows()[0]; string templateGuid = gridView1.GetRowCellValue(selectRow, "GUID").ToString(); string templateType = gridView1.GetRowCellValue(selectRow, "Type").ToString().Trim(); string Url = string.Format("api/service/T_Service_FollowUpTemplateChild?pageIndex={0}&pageSize={1}&patientGuid={2}", curPage, pageSize, templateGuid); DataTable patientDT = DBHelpClass.Get(Url); string date = ""; string leave_Time = ""; switch (templateType) { case "卒中中心患者随访": DataTable DetailDT = DBHelpClass.Get(string.Format("api/service/T_Service_EMR_PatientOutcome/GetByPatientGuidAndReportType?patientGuid={0}&reportType={1}", pGuid, 9)); leave_Time = PublicClass.ToString(DetailDT.Rows[0]["DischargeDate"], ""); foreach (DataRow item in patientDT.Rows) { if (item["Unit"].ToString().Trim() == "天") { date = Convert.ToDateTime(leave_Time).AddDays(Convert.ToInt32(item["Interval"])).ToShortDateString(); } else if (item["Unit"].ToString().Trim() == "月") { date = Convert.ToDateTime(leave_Time).AddDays(Convert.ToInt32(item["Interval"]) * 30).ToShortDateString(); } if (!string.IsNullOrEmpty(date)) { flag = SaveData(date); } } break; case "胸痛中心患者随访": DataTable Cur_OutComeInfoDT = DBHelpClass.Get(string.Format("api/service/T_Service_ChestPain_OutComeInfo/GetByPatientGuid?patientGuid={0}", pGuid)); leave_Time = PublicClass.ToString(Cur_OutComeInfoDT.Rows[0]["Leave_Time"], ""); foreach (DataRow item in patientDT.Rows) { if (item["Unit"].ToString().Trim() == "天") { if (!string.IsNullOrEmpty(leave_Time)) { date = Convert.ToDateTime(leave_Time).AddDays(Convert.ToInt32(item["Interval"])).ToShortDateString(); } } else if (item["Unit"].ToString().Trim() == "月") { if (!string.IsNullOrEmpty(leave_Time)) { date = Convert.ToDateTime(leave_Time).AddDays(Convert.ToInt32(item["Interval"]) * 30).ToShortDateString(); } } if (!string.IsNullOrEmpty(date)) { flag = SaveData_ChestPain(date); } } break; } if (flag) { XtraMessageBox.Show("保存系统信息成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { XtraMessageBox.Show("保存失败,请稍后重试!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } /// /// 卒中随访数据保存 /// /// /// private bool SaveData(string dateTime) { try { #region 保存 List patientDTOs = new List(); T_Service_FollowUpDTO PrehospitalDTO = new T_Service_FollowUpDTO(); string Url = string.Empty; ClientFactory httpClient = new HttpClientFactory(); Client client = httpClient.VisitFactory(); DataTable dataTable = new DataTable(); Url = "api/service/T_Service_FollowUp"; PrehospitalDTO.GUID = Guid.NewGuid().ToString(); PrehospitalDTO.PatientGuid = pGuid; PrehospitalDTO.FollowUpDate = dateTime; PrehospitalDTO.FollowUpType = ""; PrehospitalDTO.AdmittingDiagnosis = ""; PrehospitalDTO.DischargeDiagnosis = ""; PrehospitalDTO.HospitalOutcome = ""; PrehospitalDTO.DrugRegimen = ""; PrehospitalDTO.HealthPrescription = ""; PrehospitalDTO.RehabilitationProgram = ""; PrehospitalDTO.InspectionResult = ""; PrehospitalDTO.CheckResult = ""; PrehospitalDTO.FollowUpResult = ""; PrehospitalDTO.FollowUpDoctor = ""; PrehospitalDTO.FollowUpStatus = "0"; patientDTOs.Add(PrehospitalDTO); //访问 ListEntity t = client.Post(Url, patientDTOs); return t.Success; #endregion } catch (Exception ex) { PublicClass.WriteErrorLog(this.Text, "保存:\r\n" + ex); return false; } } /// /// 胸痛随访数据保存 /// /// /// private bool SaveData_ChestPain(string dateTime) { try { #region 保存 List patientDTOs = new List(); T_Service_FollowUp_ChestPainDTO PrehospitalDTO = new T_Service_FollowUp_ChestPainDTO(); string Url = string.Empty; ClientFactory httpClient = new HttpClientFactory(); Client client = httpClient.VisitFactory(); DataTable dataTable = new DataTable(); Url = "api/service/T_Service_FollowUp_ChestPain"; PrehospitalDTO.GUID = Guid.NewGuid().ToString(); PrehospitalDTO.PatientGuid = pGuid; PrehospitalDTO.FollowUpDate =Convert.ToDateTime(dateTime); PrehospitalDTO.FollowUpStatus = "0"; PrehospitalDTO.Note = ""; PrehospitalDTO.DeleteFlag = 0; patientDTOs.Add(PrehospitalDTO); //访问 ListEntity t = client.Post(Url, patientDTOs); return t.Success; #endregion } catch (Exception ex) { PublicClass.WriteErrorLog(this.Text, "保存:\r\n" + ex); return false; } } private void simpleButton_save_Click(object sender, EventArgs e) { try { #region 保存 int selectRowChild = gridView2.GetSelectedRows()[0]; string ChildGuid = gridView2.GetRowCellValue(selectRowChild, "GUID").ToString(); string ParentGUID = gridView2.GetRowCellValue(selectRowChild, "ParentGUID").ToString(); List patientDTOs = new List(); T_Service_FollowUpTemplateChildDTO PrehospitalDTO = new T_Service_FollowUpTemplateChildDTO(); string Url = string.Empty; ClientFactory httpClient = new HttpClientFactory(); Client client = httpClient.VisitFactory(); DataTable dataTable = new DataTable(); if (!string.IsNullOrEmpty(ChildGuid)) { dataTable = DBHelpClass.GetDataRow("api/service/T_Service_FollowUpTemplateChild/" + ChildGuid + ""); if (dataTable.Rows.Count > 0) { Url = "api/service/T_Service_FollowUpTemplateChild/Update"; PrehospitalDTO.ID = int.Parse(dataTable.Rows[0]["ID"].ToString()); PrehospitalDTO.GUID = dataTable.Rows[0]["GUID"].ToString(); } } PrehospitalDTO.ParentGUID = ParentGUID; PrehospitalDTO.Interval =Convert.ToInt32(textEdit_Interval.Text); PrehospitalDTO.Unit = comboBox_Unit.Text; PrehospitalDTO.Cycle = Convert.ToInt32(textEdit_Cycle.Text); PrehospitalDTO.Note = textEdit_Note.Text; patientDTOs.Add(PrehospitalDTO); //访问 ListEntity t = client.Post(Url, patientDTOs); if (t.Success) { XtraMessageBox.Show("保存系统信息成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { XtraMessageBox.Show("保存失败,请稍后重试!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } #endregion } catch (Exception ex) { PublicClass.WriteErrorLog(this.Text, "保存:\r\n" + ex); } } private void gridControl2_MouseDoubleClick(object sender, MouseEventArgs e) { int selectRow = gridView2.GetSelectedRows()[0]; string templateGuid = gridView2.GetRowCellValue(selectRow, "GUID").ToString(); DataTable dataTable = new DataTable(); if (!string.IsNullOrEmpty(templateGuid)) { dataTable = DBHelpClass.GetDataRow("api/service/T_Service_FollowUpTemplateChild/" + templateGuid + ""); } if (dataTable != null) { if (dataTable.Rows.Count > 0) { textEdit_Interval.Text = dataTable.Rows[0]["Interval"] + ""; checkBox_DeleteFlagChild.Checked = dataTable.Rows[0]["DeleteFlag"].ToString() == "0" ? true : false; textEdit_Cycle.Text = dataTable.Rows[0]["Cycle"] + ""; textEdit_Note.Text = dataTable.Rows[0]["Note"] + ""; comboBox_Unit.Text= dataTable.Rows[0]["Unit"].ToString(); } } } private void simpleButton_New_Click(object sender, EventArgs e) { try { #region 保存 int selectRowChild = gridView1.GetSelectedRows()[0]; string ParentGUID = gridView1.GetRowCellValue(selectRowChild, "GUID").ToString(); List patientDTOs = new List(); T_Service_FollowUpTemplateChildDTO PrehospitalDTO = new T_Service_FollowUpTemplateChildDTO(); string Url = string.Empty; ClientFactory httpClient = new HttpClientFactory(); Client client = httpClient.VisitFactory(); DataTable dataTable = new DataTable(); Url = "api/service/T_Service_FollowUpTemplateChild"; PrehospitalDTO.GUID = Guid.NewGuid().ToString(); PrehospitalDTO.ParentGUID = ParentGUID; PrehospitalDTO.Interval = Convert.ToInt32(textEdit_Interval.Text); PrehospitalDTO.Unit = comboBox_Unit.Text; PrehospitalDTO.Cycle = Convert.ToInt32(textEdit_Cycle.Text); PrehospitalDTO.Note = textEdit_Note.Text; patientDTOs.Add(PrehospitalDTO); //访问 ListEntity t = client.Post(Url, patientDTOs); if (t.Success) { XtraMessageBox.Show("保存系统信息成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { XtraMessageBox.Show("保存失败,请稍后重试!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } #endregion } catch (Exception ex) { PublicClass.WriteErrorLog(this.Text, "保存:\r\n" + ex); } } } }