StableVersion4.3/HL_FristAidPlatform_FollowUp/FollowUpInfo/UC_FollowUpInfo.cs

390 lines
15 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_FollowUp
{
/// <summary>
/// 基本信息
/// </summary>
public partial class UC_FollowUpInfo : UserControl
{
/// <summary>
///
/// </summary>
public string registerId;
/// <summary>
///
/// </summary>
public string month;
/// <summary>
/// 委托事件定义
/// </summary>
/// <param name="isfollow">随访值</param>
//public delegate void IsFollowDelegate(string isfollow);
/// <summary>
/// 事件
/// </summary>
//public event IsFollowDelegate EventMethos;
/// <summary>
///
/// </summary>
/// <param name="_registerId"></param>
/// <param name="_month"></param>
public UC_FollowUpInfo(string _registerId, string _month)
{
InitializeComponent();
registerId = _registerId;
month = _month;
}
private void UC_FollowUpInfo_Load(object sender, EventArgs e)
{
GetInfo(registerId, month);
}
/// <summary>
/// 获取基本信息
/// </summary>
/// <param name="registerId"></param>
/// <param name="month"></param>
public void GetInfo(string registerId, string month)
{
FollowUpInfoDTO dto = new FollowUpInfoDTO();
string url = string.Format("api/service/T_Service_ChestPain_FollowUpInfo/GetFollowUpInfo?registerId={0}&month={1}", registerId, month);
dto = DBHelpClass.GetDateModel<FollowUpInfoDTO>(url);
if (dto != null)
{
radio_isFollowUp.EditValue = dto.isFollowUp;
if (dto.isFollowUp == "1")
{
radio_way.EditValue = dto.way;
if (!string.IsNullOrEmpty(dto.actualEvaluationDate))
time_actualEvaluationDate.TimeValue = dto.actualEvaluationDate;
radio_followUpStatus.EditValue = dto.followUpStatus;
if (dto.followUpStatus == "1")
{
radio_currentState.EditValue = dto.currentState;
radio_isRecoveryPlan.EditValue = dto.isRecoveryPlan;
radio_isHeartCarePlan.EditValue = dto.isHeartCarePlan;
if (radio_isRecoveryPlan.EditValue.ToString() == "1" && !string.IsNullOrEmpty(dto.recoveryPlanDate))
time_recoveryPlanDate.TimeValue = dto.recoveryPlanDate;
if (!string.IsNullOrEmpty(dto.adverseEvents))
{
string[] adverse = dto.adverseEvents.ToString().Split(new char[] { '|' });
for (int i = 0; i < adverse.Length; i++)
{
for (int j = 0; j < check_adverseEvents.Items.Count; j++)
{
if (check_adverseEvents.Items[j].Value.ToString().Trim().Contains(adverse[i]))
{
check_adverseEvents.SetItemChecked(j, true);
}
}
}
if (dto.adverseEvents.Contains("5"))
{
panel_bleedingSite.Visible = true;
radio_bleedingSite.EditValue = dto.bleedingSite;
}
if (dto.adverseEvents.Contains("6"))
{
panel_implementDate.Visible = true;
time_implementDate.TimeValue = dto.implementDate;
}
}
}
if (dto.followUpStatus == "2")
{
time_deathDate.TimeValue = dto.deathDate;
radio_deathCause.EditValue = dto.deathCause;
if (dto.deathCause == "1")
{
radio_cardiovascularDeath.EditValue = dto.cardiovascularDeath;
if (radio_cardiovascularDeath.EditValue.ToString() == "99")
{
txt_cardiovascularDeathDesc.Text = dto.cardiovascularDeathDesc;
}
}
if (dto.deathCause == "2")
radio_nonCardiovascularDeath.EditValue = dto.nonCardiovascularDeath;
if (dto.deathCause == "3")
txt_unexplainedDeath.Text = dto.unexplainedDeath;
}
}
}
}
private void radio_isFollowUp_SelectedIndexChanged(object sender, EventArgs e)
{
if (radio_isFollowUp.EditValue.ToString() == "0")
{
panel_Content.Visible = false;
}
else
{
panel_Content.Visible = true;
}
}
private void radio_followUpStatus_SelectedIndexChanged(object sender, EventArgs e)
{
if (radio_followUpStatus.EditValue.ToString() == "1")
{
panel_deathCause.Visible = false;
panel_OtherInfo.Visible = true;
labelControl7.Visible = false;
time_deathDate.Visible = false;
labelControl33.Visible = false;
}
if (radio_followUpStatus.EditValue.ToString() == "2")
{
panel_deathCause.Visible = true;
panel_OtherInfo.Visible = false;
labelControl7.Visible = true;
time_deathDate.Visible = true;
labelControl33.Visible = true;
}
if (radio_followUpStatus.EditValue.ToString() == "3")
{
panel_deathCause.Visible = false;
panel_OtherInfo.Visible = false;
labelControl7.Visible = false;
time_deathDate.Visible = false;
labelControl33.Visible = false;
}
}
private void radio_deathCause_SelectedIndexChanged(object sender, EventArgs e)
{
if (radio_deathCause.EditValue.ToString() == "1")
{
panel_cardiovascularDeath.Visible = true;
panel_nonCardiovascularDeath.Visible = false;
panel_unexplainedDeath.Visible = false;
}
if (radio_deathCause.EditValue.ToString() == "2")
{
panel_cardiovascularDeath.Visible = false;
panel_nonCardiovascularDeath.Visible = true;
panel_unexplainedDeath.Visible = false;
}
if (radio_deathCause.EditValue.ToString() == "3")
{
panel_cardiovascularDeath.Visible = false;
panel_nonCardiovascularDeath.Visible = false;
panel_unexplainedDeath.Visible = true;
}
}
private void radio_cardiovascularDeath_SelectedIndexChanged(object sender, EventArgs e)
{
if (radio_cardiovascularDeath.EditValue.ToString() == "99")
{
panel_cardiovascularDeathDesc.Visible = true;
}
else
{
panel_cardiovascularDeathDesc.Visible = false;
}
}
private void radio_isRecoveryPlan_SelectedIndexChanged(object sender, EventArgs e)
{
if (radio_isRecoveryPlan.EditValue.ToString() == "1")
{
labelControl1.Visible = true;
time_recoveryPlanDate.Visible = true;
}
else
{
labelControl1.Visible = false;
time_recoveryPlanDate.Visible = false;
}
}
/// <summary>
/// 保存基本信息
/// </summary>
public void SaveFollowUpInfo(string status)
{
try
{
List<FollowUpInfoDTO> list = new List<FollowUpInfoDTO>();
FollowUpInfoDTO dto = new FollowUpInfoDTO();
dto.registerId = registerId;
dto.month = month;
dto.status = status;
dto.isFollowUp = radio_isFollowUp.EditValue != null ? radio_isFollowUp.EditValue.ToString() : "";
if (dto.isFollowUp == "1")
{
dto.way = radio_way.EditValue != null ? radio_way.EditValue.ToString() : "";
if (!string.IsNullOrEmpty(time_actualEvaluationDate.TimeValue.ToString()))
dto.actualEvaluationDate =Convert.ToDateTime( time_actualEvaluationDate.TimeValue).ToString("yyyy-MM-dd");
dto.followUpStatus = radio_followUpStatus.EditValue != null ? radio_followUpStatus.EditValue.ToString() : "";
if (dto.followUpStatus == "1")
{
dto.isRecoveryPlan = radio_isRecoveryPlan.EditValue != null ? radio_isRecoveryPlan.EditValue.ToString() : "";
if (dto.isRecoveryPlan == "1" && !string.IsNullOrEmpty(time_recoveryPlanDate.TimeValue.ToString()))
dto.recoveryPlanDate = Convert.ToDateTime(time_recoveryPlanDate.TimeValue).ToString("yyyy-MM-dd");
dto.isHeartCarePlan = radio_isHeartCarePlan.EditValue != null ? radio_isHeartCarePlan.EditValue.ToString() : "";
for (int i = 0; i < check_adverseEvents.Items.Count; i++)
{
if (check_adverseEvents.Items[i].CheckState == CheckState.Checked)
{
dto.adverseEvents += check_adverseEvents.Items[i].Value.ToString() + "|";
}
}
if (!string.IsNullOrEmpty(dto.adverseEvents))
{
dto.adverseEvents = dto.adverseEvents.TrimEnd('|');
if (dto.adverseEvents.Contains("5"))
{
dto.bleedingSite = radio_bleedingSite.EditValue != null ? radio_bleedingSite.EditValue.ToString() : "";
}
if (dto.adverseEvents.Contains("6"))
{
if (!string.IsNullOrEmpty(time_implementDate.TimeValue))
dto.implementDate = Convert.ToDateTime(time_implementDate.TimeValue).ToString("yyyy-MM-dd");
}
}
dto.currentState = radio_currentState.EditValue != null ? radio_currentState.EditValue.ToString() : "";
}
if (dto.followUpStatus == "2")
{
if (!string.IsNullOrEmpty(time_deathDate.TimeValue.ToString()))
dto.deathDate = Convert.ToDateTime(time_deathDate.TimeValue).ToString("yyyy-MM-dd");
dto.deathCause = radio_deathCause.EditValue != null ? radio_deathCause.EditValue.ToString() : "";
if (dto.deathCause == "1")
{
dto.cardiovascularDeath = radio_cardiovascularDeath.EditValue.ToString();
if (dto.cardiovascularDeath == "99")
{
dto.cardiovascularDeathDesc = txt_cardiovascularDeathDesc.Text;
}
}
if (dto.deathCause == "2") dto.nonCardiovascularDeath = radio_nonCardiovascularDeath.EditValue != null ? radio_nonCardiovascularDeath.EditValue.ToString() : "";
if (dto.deathCause == "3") dto.unexplainedDeath = txt_unexplainedDeath.Text;
}
}
dto.month = month;
list.Add(dto);
string Url = string.Empty;
Url = "api/service/T_Service_ChestPain_FollowUpInfo/SaveFollowUpInfo";
//初始化两个工厂
ClientFactory<FollowUpInfoDTO> httpClient = new HttpClientFactory<FollowUpInfoDTO>();
Client<FollowUpInfoDTO> client = httpClient.VisitFactory();
//访问
ListEntity<FollowUpInfoDTO> t = client.Post(Url, list);
if (t.Success)
{
JObject jo = (JObject)JsonConvert.DeserializeObject(t.DataString);
string msg = jo["Msg"].ToString();
if (!string.IsNullOrEmpty(msg))
{
XtraMessageBox.Show(msg);
}
}
else
{
// MessageBox.Show("保存失败");
}
}
catch (Exception ex)
{
throw ex;
}
}
private void check_adverseEvents_SelectedIndexChanged(object sender, EventArgs e)
{
if (check_adverseEvents.SelectedIndex == 6)
{
for (int i = 0; i < check_adverseEvents.Items.Count; i++)
{
if (check_adverseEvents.Items[i].Value.ToString() == "99")
{
}
else
{
check_adverseEvents.Items[i].CheckState = CheckState.Unchecked;
panel_bleedingSite.Visible = false;
panel_implementDate.Visible = false;
}
}
}
else
{
for (int i = 0; i < check_adverseEvents.Items.Count; i++)
{
if (check_adverseEvents.Items[i].Value.ToString() == "99")
{
check_adverseEvents.Items[i].CheckState = CheckState.Unchecked;
}
}
}
}
private void check_adverseEvents_MouseClick(object sender, MouseEventArgs e)
{
if (check_adverseEvents.SelectedIndex == 0)
{
if (check_adverseEvents.Items[0].CheckState == CheckState.Checked)
{
panel_bleedingSite.Visible = false;
}
else
{
panel_bleedingSite.Visible = true;
}
}
else if (check_adverseEvents.SelectedIndex == 2)
{
if (check_adverseEvents.Items[2].CheckState == CheckState.Checked)
{
panel_implementDate.Visible = false;
}
else
{
panel_implementDate.Visible = true;
}
}
}
}
}