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

502 lines
22 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_Info : UserControl
{
public string patientGuid;
public string flag;
public int type = 1;
public DateTime dt;
public string interveneName;
public string screenName;
public UC_Info(string _patientGuid, string _flag)
{
InitializeComponent();
patientGuid = _patientGuid;
flag = _flag;
}
private void UC_Info_Load(object sender, EventArgs e)
{
DataTable BindDT = DBHelpClass.Get("/api/base/T_Base_Nation/GetList");
PublicClass.SetLookUpList(lookUp_Nation, BindDT, "Value", "NationName", true, "请选择"); //职业
PublicClass.SetLookUpList(lookUp_Profession, Enumerate.PublicDictionaryType., true, "请选择");
if (flag == "2")
{
tablePanel2.Visible = true;
}
BindProvince();
GetScreenInfo();
}
#region 省市县
/// <summary>
/// 绑定省
/// </summary>
private void BindProvince()
{
try
{
string Url = string.Format("/api/base/T_Base_Province/GetList?systemModuleId={0}", PublicClassForDataBase.Config10001);
DataTable BindDT = DBHelpClass.Get(Url);
PublicClass.SetLookUpList(lookUp_CRProvince, BindDT, "ProvinceCode", "ProvinceName", false, "");
PublicClass.SetLookUpList(lookUp_CProvince, BindDT, "ProvinceCode", "ProvinceName", false, "");
}
catch (Exception ex)
{
PublicClass.WriteErrorLog(this.Text, "绑定省:\r\n" + ex);
}
}
private void lookUp_CRProvince_EditValueChanged(object sender, EventArgs e)
{
string ProvinceCode = PublicClass.ToString(lookUp_CRProvince.EditValue, "");
if (ProvinceCode != "" && ProvinceCode != "-1")
{
string Url = string.Format("/api/base/T_Base_City/GetList?provinceCode={0}", ProvinceCode);
DataTable BindDT = DBHelpClass.Get(Url);
PublicClass.SetLookUpList(lookUp_CRCity, BindDT, "CityCode", "CityName", false, "");
}
}
private void lookUp_CRCity_EditValueChanged(object sender, EventArgs e)
{
string CityCode = PublicClass.ToString(lookUp_CRCity.EditValue, "");
if (CityCode != "" && CityCode != "-1")
{
string Url = string.Format("/api/base/T_Base_County/GetList?cityCode={0}", CityCode);
DataTable BindDT = DBHelpClass.Get(Url);
PublicClass.SetLookUpList(lookUp_CRArea, BindDT, "CountyCode", "CountyName", false, "");
}
}
private void lookUp_CProvince_EditValueChanged(object sender, EventArgs e)
{
string ProvinceCode = PublicClass.ToString(lookUp_CProvince.EditValue, "");
if (ProvinceCode != "" && ProvinceCode != "-1")
{
string Url = string.Format("/api/base/T_Base_City/GetList?provinceCode={0}", ProvinceCode);
DataTable BindDT = DBHelpClass.Get(Url);
PublicClass.SetLookUpList(lookUp_CCity, BindDT, "CityCode", "CityName", false, "");
}
}
private void lookUp_CCity_EditValueChanged(object sender, EventArgs e)
{
string CityCode = PublicClass.ToString(lookUp_CCity.EditValue, "");
if (CityCode != "" && CityCode != "-1")
{
string Url = string.Format("/api/base/T_Base_County/GetList?cityCode={0}", CityCode);
DataTable BindDT = DBHelpClass.Get(Url);
PublicClass.SetLookUpList(lookUp_CArea, BindDT, "CountyCode", "CountyName", false, "");
}
}
#endregion
/// <summary>
/// 获取基本信息
/// </summary>
public void GetScreenInfo()
{
ScreenInfoDTO dto = new ScreenInfoDTO();
string url = string.Format("api/service/T_Service_ApoplexyScreen/GetScreenInfo?guid={0}", patientGuid);
dto = DBHelpClass.GetDateModel<ScreenInfoDTO>(url);
if (dto != null)
{
interveneName = dto.InterveneName;
screenName = dto.ScreenName;
txt_Screener.Text = dto.ScreenName;
txt_Name.Text = dto.Name;
radio_Gender.SelectedIndex = dto.Gender > 0 ? dto.Gender - 1 : -1;
lookUp_Nation.EditValue = dto.Nation;
txt_IDCard.Text = dto.IDCard;
com_VisitType.SelectedIndex = string.IsNullOrEmpty(dto.VisitType) == true ? 0 : int.Parse(dto.VisitType);
com_MaritalStatus.SelectedIndex = string.IsNullOrEmpty(dto.MaritalStatus) == true ? 0 : int.Parse(dto.MaritalStatus);
com_EducationLevel.SelectedIndex = string.IsNullOrEmpty(dto.EducationLevel) == true ? 0 : int.Parse(dto.EducationLevel);
radio_IsRetire.EditValue = dto.IsRetire;
lookUp_Profession.EditValue = dto.EducationLevel;
cmb_AverageIncome.SelectedIndex = string.IsNullOrEmpty(dto.AverageIncome) == true ? 0 : int.Parse(dto.AverageIncome);
cmb_MedicalType.SelectedIndex = string.IsNullOrEmpty(dto.MedicalType) == true ? 0 : int.Parse(dto.MedicalType);
cmb_Residence.SelectedIndex = string.IsNullOrEmpty(dto.Residence) == true ? 0 : int.Parse(dto.Residence);
lookUp_Profession.EditValue = dto.Profession;
lookUp_CRProvince.Text = dto.CRProvince;
lookUp_CRCity.Text = dto.CRCity;
lookUp_CRArea.Text = dto.CRArea;
txt_CRAdress.Text = dto.CRAdress;
txt_CRZipCode.Text = dto.CRZipCode;
lookUp_CProvince.Text = dto.CProvince;
lookUp_CCity.Text = dto.CCity;
lookUp_CArea.Text = dto.CArea;
txt_CAdress.Text = dto.CAdress;
txt_CZipCode.Text = dto.CZipCode;
txt_ContactNmber.Text = dto.ContactNmber;
txt_WeChat.Text = dto.WeChat;
txt_Email.Text = dto.Email;
txt_ContactName.Text = dto.ContactName;
cmb_Relation.SelectedIndex = string.IsNullOrEmpty(dto.Relation) == true ? 0 : int.Parse(dto.Relation);
txt_RelationOther.Text = dto.RelationOther;
txt_ContactPhone.Text = dto.ContactPhone;
if (flag == "2")
{
radio_Investigation.EditValue = dto.Investigation;
radio_IsSelf.EditValue = dto.IsSelf;
if (dto.IsSelf == "0")
radio_Relationship.EditValue = dto.Relationship;
if (dto.Relationship == "5")
txt_RelationshipOther.Text = dto.RelationshipOther;
radio_IsFollowUp.EditValue = dto.IsFollowUp;
if (dto.IsFollowUp == "1")
radio_Reasons.EditValue = dto.Reasons;
if (dto.Reasons == "3")
txt_ReasonsOther.Text = dto.ReasonsOther;
}
radio_IsDie.EditValue = dto.IsDie;
radio_CauseOfDeath.EditValue = dto.CauseOfDeath;
radio_PlaceOfDeath.EditValue = dto.PlaceOfDeath;
radio_time1.Text = dto.CreateTime.AddYears(-2).Year + "年12月31日(含当日)以前";
radio_time2.Text = dto.CreateTime.AddYears(-1).Year + "年1月1日至" + dto.CreateTime.AddYears(-1).Year + "年12月31日之间";
radio_Medica.EditValue = dto.Medica;
radio_time3.Text = dto.CreateTime.Year + "年1月1日之后";
if (dto.DeathRegion == "1") radio_time1.Checked = true;
if (dto.DeathRegion == "2") radio_time2.Checked = true;
if (dto.DeathRegion == "3") radio_time3.Checked = true;
time_DeathTime.TimeValue = SetTimeValue(dto.DeathTime);
radio_SpecificType.EditValue = dto.SpecificType;
radio_IsBeInHospital.EditValue = dto.IsBeInHospital;
cmb_HospitalLevel.SelectedIndex = string.IsNullOrEmpty(dto.HospitalLevel) == true ? 0 : int.Parse(dto.HospitalLevel);
cmb_Diagnose.SelectedIndex = string.IsNullOrEmpty(dto.Diagnose) == true ? 0 : int.Parse(dto.Diagnose);
dt = dto.CreateTime;
}
}
/// <summary>
/// 保存基本信息
/// </summary>
public void SaveScreenInfo(int type)
{
try
{
ScreenInfoDTO dto = new ScreenInfoDTO();
List<ScreenInfoDTO> list = new List<ScreenInfoDTO>();
dto.Flag = flag;
dto.ButtonFlag = type;
if (flag == "1")
{
dto.InterveneName = interveneName;
dto.ScreenName = txt_Screener.Text;
}
if (flag == "2")
{
dto.ScreenName = screenName;
dto.InterveneName = txt_Screener.Text;
}
dto.GUID = patientGuid;
dto.VisitType = com_VisitType.SelectedIndex > 0 ? com_VisitType.SelectedIndex.ToString() : "";
dto.Gender = radio_Gender.SelectedIndex > -1 ? int.Parse(radio_Gender.EditValue.ToString()) : 0;
dto.Nation = lookUp_Nation.EditValue != null ? lookUp_Nation.EditValue.ToString() : "";
dto.IDCard = txt_IDCard.Text.Trim();
dto.MaritalStatus = com_MaritalStatus.SelectedIndex > 0 ? com_MaritalStatus.SelectedIndex.ToString() : "";
dto.EducationLevel = com_EducationLevel.SelectedIndex > 0 ? com_EducationLevel.SelectedIndex.ToString() : "";
dto.Residence = cmb_Residence.SelectedIndex > 0 ? cmb_Residence.SelectedIndex.ToString() : "";
dto.IsRetire = GetEditValue(radio_IsRetire);
dto.Profession = lookUp_Profession.Text != "" ? lookUp_Profession.EditValue.ToString() : "";
dto.AverageIncome = cmb_AverageIncome.SelectedIndex > 0 ? cmb_AverageIncome.SelectedIndex.ToString() : "";
dto.MedicalType = cmb_MedicalType.SelectedIndex > 0 ? cmb_MedicalType.SelectedIndex.ToString() : "";
dto.CRProvince = lookUp_CRProvince.Text != "请选择" ? lookUp_CRProvince.Text : "";
dto.CRCity = lookUp_CRCity.Text != "请选择" ? lookUp_CRCity.Text : "";
dto.CRArea = lookUp_CRArea.Text != "请选择" ? lookUp_CRArea.Text : "";
dto.CRAdress = txt_CRAdress.Text;
dto.CRZipCode = txt_CRZipCode.Text;
dto.CProvince = lookUp_CProvince.Text != "请选择" ? lookUp_CProvince.Text : "";
dto.CCity = lookUp_CCity.Text != "请选择" ? lookUp_CCity.Text : "";
dto.CArea = lookUp_CArea.Text != "请选择" ? lookUp_CArea.Text : "";
dto.CAdress = txt_CAdress.Text;
dto.CZipCode = txt_CZipCode.Text;
dto.ContactNmber = txt_ContactNmber.Text;
dto.WeChat = txt_WeChat.Text;
dto.Email = txt_Email.Text;
dto.ContactName = txt_ContactName.Text;
dto.Relation = cmb_Relation.SelectedIndex > 0 ? cmb_Relation.SelectedIndex.ToString() : "";
if (dto.Relation == "5")
dto.RelationOther = txt_RelationOther.Text;
dto.ContactPhone = txt_ContactPhone.Text;
if (flag == "2")
{
dto.Investigation = GetEditValue(radio_Investigation);
dto.IsSelf = GetEditValue(radio_IsSelf);
if (dto.IsSelf == "0")
dto.Relationship = GetEditValue(radio_Relationship);
if (dto.Relationship == "5")
dto.RelationshipOther = txt_RelationshipOther.Text;
dto.IsFollowUp = GetEditValue(radio_IsFollowUp);
if (dto.IsFollowUp == "1")
dto.Reasons = GetEditValue(radio_Reasons);
if (dto.Reasons == "3")
dto.ReasonsOther = txt_ReasonsOther.Text;
}
dto.IsDie = GetEditValue(radio_IsDie);
if (dto.IsDie == "1")
{
dto.CauseOfDeath = GetEditValue(radio_CauseOfDeath);
if (dto.CauseOfDeath == "1")
dto.SpecificType = GetEditValue(radio_SpecificType);
dto.IsBeInHospital = GetEditValue(radio_IsBeInHospital);
dto.PlaceOfDeath = GetEditValue(radio_PlaceOfDeath);
dto.HospitalLevel = cmb_HospitalLevel.SelectedIndex > -1 ? cmb_HospitalLevel.SelectedIndex.ToString() : "";
dto.Diagnose = cmb_Diagnose.SelectedIndex > -1 ? cmb_Diagnose.SelectedIndex.ToString() : "";
dto.Medica = GetEditValue(radio_Medica);
if (radio_time1.Checked == true) dto.DeathRegion = "1";
if (radio_time2.Checked == true) dto.DeathRegion = "2";
if (radio_time3.Checked == true) dto.DeathRegion = "3";
if (dto.DeathRegion == "3")
dto.DeathTime = GetTimeValue(time_DeathTime);
}
if (dt == null)
{ dto.CreateTime = DateTime.Now; }
else { dto.CreateTime = dt; }
list.Add(dto);
string Url = "api/service/T_Service_ApoplexyScreen/SaveScreenInfo";
//初始化两个工厂
ClientFactory<ScreenInfoDTO> httpClient = new HttpClientFactory<ScreenInfoDTO>();
Client<ScreenInfoDTO> client = httpClient.VisitFactory();
//访问
ListEntity<ScreenInfoDTO> 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);
}
}
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;
}
/// <summary>
/// 获取时间组件value
/// </summary>
/// <param name="time"></param>
/// <returns></returns>
public string GetTimeValue(TimeControl time)
{
string value = "";
if (!string.IsNullOrEmpty(time.TimeValue))
value = Convert.ToDateTime(time.TimeValue).ToString("yyyy-MM-dd");
return value;
}
/// <summary>
/// 设置组件TimeValue
/// </summary>
/// <param name="time"></param>
/// <returns></returns>
public string SetTimeValue(string time)
{
string value = "";
if (!string.IsNullOrEmpty(time))
value = time;
return value;
}
private void radio_IsRetire_SelectedIndexChanged(object sender, EventArgs e)
{
if (radio_IsRetire.SelectedIndex == 1) { lbl_Profession.Visible = false; lookUp_Profession.Visible = false; } else { lbl_Profession.Visible = true; lookUp_Profession.Visible = true; }
}
private void radio_IsDie_SelectedIndexChanged(object sender, EventArgs e)
{
if (radio_IsDie.SelectedIndex == 1) { panel_death.Visible = true; }
else
{
panel_death.Visible = false;
radio_CauseOfDeath.SelectedIndex = -1;
radio_time3.Checked = false;
}
}
private void radio_time3_CheckedChanged(object sender, EventArgs e)
{
if (radio_time3.Checked == true) { panel_deathTime.Visible = true; } else { panel_deathTime.Visible = false; }
}
private void radio_CauseOfDeath_SelectedIndexChanged(object sender, EventArgs e)
{
if (radio_CauseOfDeath.SelectedIndex == 0) { panel_apoplexy.Visible = true; } else { panel_apoplexy.Visible = false; radio_IsBeInHospital.SelectedIndex = -1; }
}
private void radio_IsBeInHospital_SelectedIndexChanged(object sender, EventArgs e)
{
if (radio_IsBeInHospital.SelectedIndex == 1) { panel_beInHospital.Visible = true; } else { panel_beInHospital.Visible = false; }
}
private void lookUp_CRProvince_EditValueChanged_1(object sender, EventArgs e)
{
string ProvinceCode = PublicClass.ToString(lookUp_CRProvince.EditValue, "");
if (ProvinceCode != "" && ProvinceCode != "-1")
{
string Url = string.Format("/api/base/T_Base_City/GetList?provinceCode={0}", ProvinceCode);
DataTable BindDT = DBHelpClass.Get(Url);
PublicClass.SetLookUpList(lookUp_CRCity, BindDT, "CityCode", "CityName", false, "");
}
}
private void lookUp_CRCity_EditValueChanged_1(object sender, EventArgs e)
{
string CityCode = PublicClass.ToString(lookUp_CRCity.EditValue, "");
if (CityCode != "" && CityCode != "-1")
{
string Url = string.Format("/api/base/T_Base_County/GetList?cityCode={0}", CityCode);
DataTable BindDT = DBHelpClass.Get(Url);
PublicClass.SetLookUpList(lookUp_CRArea, BindDT, "CountyCode", "CountyName", false, "");
}
}
private void lookUp_CProvince_EditValueChanged_1(object sender, EventArgs e)
{
string ProvinceCode = PublicClass.ToString(lookUp_CProvince.EditValue, "");
if (ProvinceCode != "" && ProvinceCode != "-1")
{
string Url = string.Format("/api/base/T_Base_City/GetList?provinceCode={0}", ProvinceCode);
DataTable BindDT = DBHelpClass.Get(Url);
PublicClass.SetLookUpList(lookUp_CCity, BindDT, "CityCode", "CityName", false, "");
}
}
private void lookUp_CCity_EditValueChanged_1(object sender, EventArgs e)
{
string CityCode = PublicClass.ToString(lookUp_CCity.EditValue, "");
if (CityCode != "" && CityCode != "-1")
{
string Url = string.Format("/api/base/T_Base_County/GetList?cityCode={0}", CityCode);
DataTable BindDT = DBHelpClass.Get(Url);
PublicClass.SetLookUpList(lookUp_CArea, BindDT, "CountyCode", "CountyName", false, "");
}
}
private void cmb_Relation_SelectedIndexChanged(object sender, EventArgs e)
{
if (cmb_Relation.Text == "其他")
{
lbl_RelationOther.Visible = true;
txt_RelationOther.Visible = true;
}
else
{
lbl_RelationOther.Visible = false;
txt_RelationOther.Visible = false;
}
}
private void radio_IsSelf_SelectedIndexChanged(object sender, EventArgs e)
{
if (radio_IsSelf.SelectedIndex == 0)
{
panel_Relationship.Visible = true;
}
else
{
radio_Relationship.SelectedIndex = -1;
panel_Relationship.Visible = false;
}
}
private void radio_Relationship_SelectedIndexChanged(object sender, EventArgs e)
{
if (radio_Relationship.SelectedIndex == 4)
{
lbl_RelationshipOther.Visible = true;
txt_RelationshipOther.Visible = true;
}
else
{
lbl_RelationshipOther.Visible = false;
txt_RelationshipOther.Visible = false;
txt_RelationshipOther.Text = "";
}
}
private void radio_IsFollowUp_SelectedIndexChanged(object sender, EventArgs e)
{
if (radio_IsFollowUp.SelectedIndex == 1)
{
panel_Reasons.Visible = true;
}
else
{
radio_Reasons.SelectedIndex = -1;
panel_Reasons.Visible = false;
}
}
private void radio_Reasons_SelectedIndexChanged(object sender, EventArgs e)
{
if (radio_Reasons.SelectedIndex == 2)
{
lbl_ReasonsOther.Visible = true;
txt_ReasonsOther.Visible = true;
}
else
{
lbl_ReasonsOther.Visible = false;
txt_ReasonsOther.Visible = false;
txt_ReasonsOther.Text = "";
}
}
}
}