StableVersion4.3/HL_FristAidPlatform_Apoplexy/Screen/UserControl/UC_FamilyHistory.cs

227 lines
8.7 KiB
C#

using DevExpress.XtraEditors;
using HL_FristAidPlatform_DTO;
using HL_FristAidPlatform_Public;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HL_FristAidPlatform_Apoplexy
{
public partial class UC_FamilyHistory : UserControl
{
public string patientGuid;
public string flag;
public UC_FamilyHistory(string _patientGuid, string _flag)
{
InitializeComponent();
patientGuid = _patientGuid;
flag = _flag;
}
private void UC_FamilyHistory_Load(object sender, EventArgs e)
{
GetScreenFamilyHistory();
}
/// <summary>
/// 获取家族史
/// </summary>
public void GetScreenFamilyHistory()
{
ScreenFamilyHistoryDTO dto = new ScreenFamilyHistoryDTO();
string url = string.Format("api/service/T_Service_ApoplexyScreen/GetScreenFamilyHistory?patientGuid={0}&flag={1}", patientGuid, flag);
dto = DBHelpClass.GetDateModel<ScreenFamilyHistoryDTO>(url);
if (dto != null)
{
txt_FamilyHistoryScreener.Text = dto.Screener;
radio_Apoplexia.EditValue = dto.Apoplexia;
if (dto.Apoplexia == "1")
{
if (!string.IsNullOrEmpty(dto.ApoplexiaR))
{
PublicClass.SetItemChecked(check_ApoplexiaR, dto.ApoplexiaR, ';');
txt_ApoplexiaN.Text = dto.ApoplexiaN;
}
}
radio_CoronaryDisease.EditValue = dto.CoronaryDisease;
if (dto.CoronaryDisease == "1")
{
if (!string.IsNullOrEmpty(dto.CoronaryDiseaseR))
{
PublicClass.SetItemChecked(check_CoronaryDiseaseR, dto.CoronaryDiseaseR, ';');
txt_CoronaryDiseaseN.Text = dto.CoronaryDiseaseN;
}
}
radio_Hypertension.EditValue = dto.Hypertension;
if (dto.Hypertension == "1")
{
if (!string.IsNullOrEmpty(dto.HypertensionN))
{
PublicClass.SetItemChecked(check_HypertensionR, dto.HypertensionR, ';');
txt_HypertensionN.Text = dto.HypertensionN;
}
}
radio_DiabetesMellitus.EditValue = dto.DiabetesMellitus;
if (dto.DiabetesMellitus == "1")
{
if (!string.IsNullOrEmpty(dto.DiabetesMellitusN))
{
PublicClass.SetItemChecked(check_DiabetesMellitusR, dto.DiabetesMellitusR, ';');
txt_DiabetesMellitusN.Text = dto.DiabetesMellitusN;
}
}
}
}
/// <summary>
/// 保存家族史
/// </summary>
public void SaveScreenFamilyHistory()
{
try
{
string value = "";
string text = "";
ScreenFamilyHistoryDTO dto = new ScreenFamilyHistoryDTO();
List<ScreenFamilyHistoryDTO> list = new List<ScreenFamilyHistoryDTO>();
dto.Flag = flag;
dto.PatientGUID = patientGuid;
dto.Screener = txt_FamilyHistoryScreener.Text;
dto.Apoplexia = GetEditValue(radio_Apoplexia);
if (dto.Apoplexia == "1")
{
PublicClass.GetCheckedListBoxItemValues(check_ApoplexiaR, ";", out value, out text);
if (!string.IsNullOrEmpty(value))
{ dto.ApoplexiaR += ";" + value + ";"; }
else { dto.ApoplexiaR = ""; }
dto.ApoplexiaN = txt_ApoplexiaN.Text.Trim();
}
dto.CoronaryDisease = GetEditValue(radio_CoronaryDisease);
if (dto.CoronaryDisease == "1")
{
PublicClass.GetCheckedListBoxItemValues(check_CoronaryDiseaseR, ";", out value, out text);
if (!string.IsNullOrEmpty(value))
{ dto.CoronaryDiseaseR += ";" + value + ";"; }
else { dto.CoronaryDiseaseR = ""; }
dto.CoronaryDiseaseN = txt_CoronaryDiseaseN.Text.Trim();
}
dto.Hypertension = GetEditValue(radio_Hypertension);
if (dto.Hypertension == "1")
{
PublicClass.GetCheckedListBoxItemValues(check_HypertensionR, ";", out value, out text);
if (!string.IsNullOrEmpty(value))
{ dto.HypertensionR += ";" + value + ";"; }
else { dto.HypertensionR = ""; }
dto.HypertensionN = txt_HypertensionN.Text.Trim();
}
dto.DiabetesMellitus = GetEditValue(radio_DiabetesMellitus);
if (dto.DiabetesMellitus == "1")
{
PublicClass.GetCheckedListBoxItemValues(check_DiabetesMellitusR, ";", out value, out text);
if (!string.IsNullOrEmpty(value))
{ dto.DiabetesMellitusR += ";" + value + ";"; }
else { dto.DiabetesMellitusR = ""; }
dto.DiabetesMellitusN = txt_DiabetesMellitusN.Text.Trim();
}
dto.CreateID = Information.User.ID;
list.Add(dto);
string Url = "api/service/T_Service_ApoplexyScreen/SaveScreenFamilyHistory";
//初始化两个工厂
ClientFactory<ScreenFamilyHistoryDTO> httpClient = new HttpClientFactory<ScreenFamilyHistoryDTO>();
Client<ScreenFamilyHistoryDTO> client = httpClient.VisitFactory();
//访问
ListEntity<ScreenFamilyHistoryDTO> t = client.Post(Url, list);
if (t.Success)
{
if (!string.IsNullOrEmpty(t.DataString))
{
if (t.DataString.Contains("Success"))
{
JObject jo = (JObject)JsonConvert.DeserializeObject(t.DataString);
string msg = jo["Msg"].ToString();
if (!string.IsNullOrEmpty(msg))
{
XtraMessageBox.Show(msg);
GetScreenFamilyHistory();
}
}
else
{
string msg1 = t.DataString.Replace("/", "").Replace(@"\", "").Replace("\"", "");
XtraMessageBox.Show(msg1);
}
}
else
{
XtraMessageBox.Show("保存失败");
}
}
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 获取单选组件value
/// </summary>
/// <param name="radio"></param>
/// <returns></returns>
public string GetEditValue(RadioGroup radio)
{
string value = "";
if (radio.SelectedIndex > -1 && radio.EditValue.ToString() != null)
value = radio.EditValue.ToString();
return value;
}
private void radio_Apoplexia_SelectedIndexChanged(object sender, EventArgs e)
{
if (radio_Apoplexia.SelectedIndex == 2)
{ panel_Apoplexia.Visible = true; }
else { panel_Apoplexia.Visible = false; }
}
private void radio_CoronaryDisease_SelectedIndexChanged(object sender, EventArgs e)
{
if (radio_CoronaryDisease.SelectedIndex == 2)
{ panel_CoronaryDisease.Visible = true; }
else { panel_CoronaryDisease.Visible = false; }
}
private void radio_Hypertension_SelectedIndexChanged(object sender, EventArgs e)
{
if (radio_Hypertension.SelectedIndex == 2)
{ panel_Hypertension.Visible = true; }
else { panel_Hypertension.Visible = false; }
}
private void radio_DiabetesMellitus_SelectedIndexChanged(object sender, EventArgs e)
{
if (radio_DiabetesMellitus.SelectedIndex == 2)
{ panel_DiabetesMellitus.Visible = true; }
else { panel_DiabetesMellitus.Visible = false; }
}
}
}