using DevExpress.XtraEditors; using DevExpress.XtraGrid.Views.Grid; using HL_FristAidPlatform_DTO; using HL_FristAidPlatform_Public; using System; using System.Collections.Generic; using System.Data; using System.Drawing; using System.Windows.Forms; namespace HL_FristAidPlatform_FollowUp { public partial class Form_FollowUpDetail : XtraForm { /// /// 当前患者信息 /// public DataTable Cur_PatientDT; /// /// 当前患者编号(GUID) /// public string Cur_PatientID; /// /// 当前随访计划编号(GUID) /// public string Cur_FollUpID; public Form_FollowUpDetail(string _Cur_PatientID) { InitializeComponent(); Cur_PatientID = _Cur_PatientID; } /// /// 窗体加载 /// /// /// private void Form_FollowUpDetail_Load(object sender, EventArgs e) { BindData(); BindList(); } /// /// 绑定随访计划列表 /// private void BindList() { try { DataTable data = DBHelpClass.Get("api/service/T_Service_FollowUp/?pageIndex=1&pageSize=20&pGuid=" + Cur_PatientID + ""); gridControl_FollowUpVisit.DataSource = data; gridView_FollowUpVisit.OptionsBehavior.Editable = false; } catch (Exception ex) { PublicClass.WriteErrorLog(this.Text, "绑定随访计划列表:\r\n" + ex); } } /// /// 查询绑定 /// private void BindData() { BindDoctorList(); BindPatientInfo(); } /// /// 绑定随访医生列表 /// private void BindDoctorList() { try { DataTable dataTableDoctor = DBHelpClass.Get("api/admin/T_SYS_User/GetModelByWhere?where=PositionID in(1,2)"); PublicClass.SetLookUpList(ref lookUpEdit_FollowUpDoctor, dataTableDoctor, 0, 4, false); lookUpEdit_FollowUpDoctor.EditValue = Information.User.ID.ToString(); } catch (Exception ex) { PublicClass.WriteErrorLog(this.Text, "绑定随访医生列表:\r\n" + ex); } } /// /// 绑定患者信息 /// private void BindPatientInfo() { try { Cur_PatientDT = DBHelpClass.GetDataRow("api/service/T_Service_Patient/" + Cur_PatientID + ""); label_name.Text = Cur_PatientDT.Rows[0]["Name"].ToString(); label_sex.Text = Cur_PatientDT.Rows[0]["GenderString"].ToString(); label_age.Text = Cur_PatientDT.Rows[0]["Age"].ToString(); } catch (Exception ex) { PublicClass.WriteErrorLog(this.Text, "绑定患者信息:\r\n" + ex); } } /// /// 保存 /// /// /// private void simpleButton_save_Click(object sender, EventArgs e) { 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(); //dataTable = DBHelpClass.Get("api/service/T_Service_FollowUp/GetByPatientGuid?patientGuid=" + Cur_PatientID + ""); if (!string.IsNullOrEmpty(Cur_FollUpID)) { dataTable = DBHelpClass.GetDataRow("api/service/T_Service_FollowUp/" + Cur_FollUpID + ""); if (dataTable.Rows.Count > 0) { Url = "api/service/T_Service_FollowUp/Update"; PrehospitalDTO.ID = Int64.Parse(dataTable.Rows[0]["ID"].ToString()); PrehospitalDTO.GUID = dataTable.Rows[0]["GUID"].ToString(); } } else { Url = "api/service/T_Service_FollowUp"; PrehospitalDTO.GUID = Guid.NewGuid().ToString(); } PrehospitalDTO.PatientGuid = Cur_PatientID; PrehospitalDTO.FollowUpDate = Convert.ToDateTime(dateEdit_FollowUpDate.TimeValue).ToString(); PrehospitalDTO.FollowUpType = comboBox_FollowUpType.Text; PrehospitalDTO.AdmittingDiagnosis = comboBox_AdmittingDiagnosis.Text; PrehospitalDTO.DischargeDiagnosis = comboBox_DischargeDiagnosis.Text; PrehospitalDTO.HospitalOutcome = comboBox_HospitalOutcome.Text; PrehospitalDTO.DrugRegimen = comboBox_DrugRegimen.Text; PrehospitalDTO.FollowUpStatus = "1"; string healthPrescription = ""; string rehabilitationProgram = ""; for (int i = 0; i < checkedListBox_HealthPrescription.CheckedIndices.Count; i++) { healthPrescription += checkedListBox_HealthPrescription.CheckedIndices[i].ToString() + "#"; } for (int i = 0; i < checkedListBox_RehabilitationProgram.CheckedIndices.Count; i++) { rehabilitationProgram += checkedListBox_RehabilitationProgram.CheckedIndices[i].ToString() + "#"; } //string SyndromeNumber = string.Empty; //string Syndrome = string.Empty; //PublicClass.GetCheckedListBoxItemValues(checkedListBox_HealthPrescription, "#", out healthPrescription, out rehabilitationProgram); //dto.SyndromeNumber = SyndromeNumber; //dto.Syndrome = Syndrome; PrehospitalDTO.HealthPrescription = healthPrescription.Length==0? healthPrescription:healthPrescription.Remove(healthPrescription.Length - 1); PrehospitalDTO.RehabilitationProgram = rehabilitationProgram.Length==0? rehabilitationProgram:rehabilitationProgram.Remove(rehabilitationProgram.Length - 1); PrehospitalDTO.InspectionResult = textEdit_InspectionResult.Text; PrehospitalDTO.CheckResult = textEdit_CheckResult.Text; PrehospitalDTO.FollowUpResult = comboBox_FollowUpResult.Text; PrehospitalDTO.FollowUpDoctor = lookUpEdit_FollowUpDoctor.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); } } /// /// 绑定详情 /// /// /// public void BindDataPrehospital(string _patientID, ListEntity entity) { try { #region 绑定详情 DataTable dataTable = new DataTable(); if (string.IsNullOrEmpty(_patientID)) { dataTable = DBHelpClass.JsonToDataRow(entity.DataString); } if (entity == null) { dataTable = DBHelpClass.GetDataRow("api/service/T_Service_FollowUp/" + _patientID + ""); } if (dataTable != null) { if (dataTable.Rows.Count > 0) { dateEdit_FollowUpDate.TimeValue = PublicClass.ToString(dataTable.Rows[0]["FollowUpDate"], ""); comboBox_FollowUpType.Text = dataTable.Rows[0]["FollowUpType"] + ""; comboBox_AdmittingDiagnosis.Text = dataTable.Rows[0]["AdmittingDiagnosis"] + ""; comboBox_DischargeDiagnosis.Text = dataTable.Rows[0]["DischargeDiagnosis"] + ""; comboBox_HospitalOutcome.Text = dataTable.Rows[0]["HospitalOutcome"] + ""; comboBox_DrugRegimen.Text = dataTable.Rows[0]["DrugRegimen"] + ""; string healthPrescriptionText = dataTable.Rows[0]["HealthPrescription"] + ""; string[] listHealthPrescriptionText = { }; listHealthPrescriptionText = healthPrescriptionText.Split('#'); for (int i = 0; i < listHealthPrescriptionText.Length; i++) { checkedListBox_HealthPrescription.SetItemCheckState(int.Parse(listHealthPrescriptionText[i]), CheckState.Checked); } string rehabilitationProgramText = dataTable.Rows[0]["RehabilitationProgram"] + ""; string[] listrehabilitationProgramText = { }; listrehabilitationProgramText = rehabilitationProgramText.Split('#'); for (int i = 0; i < listrehabilitationProgramText.Length; i++) { checkedListBox_RehabilitationProgram.SetItemCheckState(int.Parse(listrehabilitationProgramText[i]), CheckState.Checked); } textEdit_InspectionResult.Text = dataTable.Rows[0]["InspectionResult"] + ""; textEdit_CheckResult.Text = dataTable.Rows[0]["CheckResult"] + ""; comboBox_FollowUpResult.Text = dataTable.Rows[0]["FollowUpResult"] + ""; lookUpEdit_FollowUpDoctor.Text = dataTable.Rows[0]["FollowUpDoctor"] + ""; } } #endregion } catch (Exception ex) { PublicClass.WriteErrorLog(this.Text, "绑定详情:\r\n" + ex); } } /// /// 单击绑定详情 /// /// /// private void gridView_FollowUpVisit_RowClick(object sender, RowClickEventArgs e) { try { DataRow dataRow = gridView_FollowUpVisit.GetDataRow(e.RowHandle); Cur_FollUpID = dataRow["GUID"].ToString(); BindDataPrehospital(Cur_FollUpID, null); } catch (Exception ex) { PublicClass.WriteErrorLog(this.Text, "单击绑定详情:\r\n" + ex); } } /// /// 新增 /// /// /// private void simpleButton_Add_Click(object sender, EventArgs e) { dateEdit_FollowUpDate.TimeValue = ""; comboBox_FollowUpType.Text = ""; comboBox_AdmittingDiagnosis.Text = ""; comboBox_DischargeDiagnosis.Text = ""; comboBox_HospitalOutcome.Text = ""; comboBox_DrugRegimen.Text = ""; checkedListBox_HealthPrescription.Text = ""; checkedListBox_RehabilitationProgram.Text = ""; textEdit_InspectionResult.Text = ""; textEdit_CheckResult.Text = ""; comboBox_FollowUpResult.Text = ""; lookUpEdit_FollowUpDoctor.Text = ""; } private void gridView_FollowUpVisit_RowCellStyle(object sender, RowCellStyleEventArgs e) { GridView View = sender as GridView; //随访状态 if (e.Column.FieldName == "FollowUpStatus") { int value = PublicClass.ToInt32(e.CellValue, 0); switch (value) { case 0: e.Appearance.BackColor = Color.Red; e.Appearance.BackColor2 = Color.FromArgb(255, 255, 255); break; case 1: e.Appearance.BackColor = Color.Green; e.Appearance.BackColor2 = Color.FromArgb(255, 255, 255); break; default: break; } } } /// /// 自定义显示 /// /// /// private void gridView_FollowUpVisit_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e) { GridView View = sender as GridView; //随访状态 if (e.Column.FieldName == "FollowUpStatus") { int value = PublicClass.ToInt32(e.Value, 0); switch (value) { case 0: e.DisplayText = "未随访"; break; case 1: e.DisplayText = "已随访"; break; default: break; } } } } }