using DevExpress.XtraEditors;
using HL_FristAidPlatform_DTO;
using HL_FristAidPlatform_Public;
using System;
using System.Collections.Generic;
using System.Data;
using System.Windows.Forms;
namespace HL_FristAidPlatform_ChestPain
{
public partial class Form_ChestPain_Pathography : XtraForm
{
#region 变量
///
/// 当前病人编号(GUID)
///
private string Cur_PatientGuid;
///
/// 从存储过程中调取的数据源 便于首次生成和后期更新
///
private DataTable Cur_QualityControlDT = new DataTable();
///
/// 当前修改的记录信息
///
private DataTable Cur_DetailDT = new DataTable();
#endregion 变量
///
/// 胸痛患者病志
///
/// 患者编号
public Form_ChestPain_Pathography(string _patientGuid)
{
InitializeComponent();
Cur_PatientGuid = _patientGuid;
}
///
/// 窗体加载
///
///
///
private void Form_ChestPain_Pathography_Load(object sender, EventArgs e)
{
BindData();
}
///
/// 窗体快捷键注册
///
///
///
private void Form_ChestPain_Pathography_KeyDown(object sender, KeyEventArgs e)
{
//同时按下 Ctrl+S 时执行保存方法
if (e.KeyCode == Keys.S && e.Control)
{
barButton_Save_ItemClick(null, null);
}
}
///
/// 绑定数据
///
private void BindData()
{
try
{
string ContentStr = string.Empty;
string Url = string.Format("api/service/T_Service_Pathography/GetByPatientGuid?patientGuid={0}", Cur_PatientGuid);
Cur_DetailDT = DBHelpClass.Get(Url);
//没有在病例表中进行数据存储
if (Cur_DetailDT != null && Cur_DetailDT.Rows.Count > 0)
{
ContentStr = Cur_DetailDT.Rows[0]["Content"].ToString();
ContentStr = ContentStr.Replace("rn", "\r\n");
}
else
{
Url = string.Format("api/service/T_Service_ChestPain_PatientsTimeAxis/GetChestPainQualityControl?patientGuid={0}", Cur_PatientGuid);
Cur_QualityControlDT = DBHelpClass.GetJsonText(Url);
ContentStr = InitializePathography(Cur_QualityControlDT);
}
richEdit_Content.Text = ContentStr;
}
catch (Exception ex)
{
PublicClass.WriteErrorLog(this.Text, "绑定数据:\r\n" + ex);
}
}
///
/// 初始化病志信息
///
/// 数据源
///
private string InitializePathography(DataTable DataDT)
{
string ContentStr = string.Empty;
//判断是否有数据
if (DataDT != null && DataDT.Rows.Count > 0)
{
#region 初始化病志信息
//日期
string RegisterTime = PublicClass.DateTimeToString(DataDT.Rows[0]["RegisterTime"], "", "yyyy-MM-dd HH:mm");
//姓名
string Name = PublicClass.ToString(DataDT.Rows[0]["Name"], "");
//性别
string GenderName = PublicClass.ToString(DataDT.Rows[0]["GenderName"], "");
//年龄
string Age = PublicClass.ToString(DataDT.Rows[0]["Age"], "");
//年龄单位
string Age_Unit = PublicClass.ToString(DataDT.Rows[0]["Age_Unit"], "");
//发病时间
string FB_Time = PublicClass.DateTimeToString(DataDT.Rows[0]["FB_Time"], "", "HH:mm");
//诊断
string Diagnosis = string.Empty;
#region 诊断
int CP_Diagnosis_Code = PublicClass.ToInt32(DataDT.Rows[0]["CP_Diagnosis_Code"], 0);
switch (CP_Diagnosis_Code)
{
case 1:
Diagnosis = "STEMI";
break;
case 2:
Diagnosis = "NSTEMI";
break;
case 3:
Diagnosis = "UA";
break;
case 4:
Diagnosis = "主动脉夹层";
break;
case 5:
Diagnosis = "肺动脉栓塞";
break;
case 6:
Diagnosis = "非ACS心源性胸痛";
break;
case 7:
Diagnosis = "其它非心源性胸痛";
break;
case 8:
Diagnosis = "待查";
break;
default:
Diagnosis = "";
break;
}
#endregion
//来院方式
string LYFS = PublicClass.ToString(DataDT.Rows[0]["LYFS"], "");
//到达医院大门时间
string Arrived_Hospital_Time = PublicClass.DateTimeToString(DataDT.Rows[0]["Arrived_Hospital_Time"], "", "HH:mm");
//是否远程传输心电图
string Remote_ECG_Transmission = PublicClass.ToString(DataDT.Rows[0]["Remote_ECG_Transmission"], "") == "1" ? "是" : "否";
//绕行模式
string GreenChannel = string.Empty;
#region 绕行模式
int IsGreenChannel = PublicClass.ToInt32(DataDT.Rows[0]["IsGreenChannel"], 0);
switch (IsGreenChannel)
{
case (int)Enumerate.CircumferenceMode.未绕行:
GreenChannel = Enumerate.CircumferenceMode.未绕行.ToString();
break;
case (int)Enumerate.CircumferenceMode.单绕:
GreenChannel = Enumerate.CircumferenceMode.单绕.ToString();
break;
case (int)Enumerate.CircumferenceMode.双绕:
GreenChannel = Enumerate.CircumferenceMode.双绕.ToString();
break;
case (int)Enumerate.CircumferenceMode.三绕:
GreenChannel = Enumerate.CircumferenceMode.三绕.ToString();
break;
default:
GreenChannel = "";
break;
}
#endregion 绕行模式
//是否溶栓 0:无溶栓 1:院前溶栓 2:院内溶栓 3:院前溶栓+院内溶栓
int Thrombolysis = PublicClass.ToInt32(DataDT.Rows[0]["Thrombolysis"], 0);
//是否介入治疗 0:否 1:是
int Interventional_Therapy = PublicClass.ToInt32(DataDT.Rows[0]["Interventional_Therapy"], 0);
//首次医疗接触时间
string FMC_Time = PublicClass.DateTimeToString(DataDT.Rows[0]["FMC_Time"], "", "HH:mm");
//首份心电图完成时间
string ECG_Time = PublicClass.DateTimeToString(DataDT.Rows[0]["ECG_Time"], "", "HH:mm");
//心电图确诊时间
string ECG_Diagnose_Time = PublicClass.DateTimeToString(DataDT.Rows[0]["ECG_Diagnose_Time"], "", "HH:mm");
//肌钙蛋白抽血完成时间
string Blood_Time = PublicClass.DateTimeToString(DataDT.Rows[0]["Blood_Time"], "", "HH:mm");
//肌钙蛋白获得报告时间
string Report_Time = PublicClass.DateTimeToString(DataDT.Rows[0]["Report_Time"], "", "HH:mm");
//通知会诊时间
string Notice_IMCD_Time = PublicClass.DateTimeToString(DataDT.Rows[0]["Notice_IMCD_Time"], "", "HH:mm");
//会诊时间
string Consultation_Time = PublicClass.DateTimeToString(DataDT.Rows[0]["Consultation_Time"], "", "HH:mm");
//溶栓开始知情同意时间
string Throm_Start_Agree_Time = PublicClass.DateTimeToString(DataDT.Rows[0]["Throm_Start_Agree_Time"], "", "HH:mm");
//溶栓签署知情同意时间
string Throm_Sign_Agree_Time = PublicClass.DateTimeToString(DataDT.Rows[0]["Throm_Sign_Agree_Time"], "", "HH:mm");
//介入开始知情同意时间
string Start_Agree_Time = PublicClass.DateTimeToString(DataDT.Rows[0]["Start_Agree_Time"], "", "HH:mm");
//介入签署知情同意时间
string Sign_Agree_Time = PublicClass.DateTimeToString(DataDT.Rows[0]["Sign_Agree_Time"], "", "HH:mm");
//启动导管室时间
string Start_Conduit_Time = PublicClass.DateTimeToString(DataDT.Rows[0]["Start_Conduit_Time"], "", "HH:mm");
//导管室激活时间
string Activate_Conduit_Time = PublicClass.DateTimeToString(DataDT.Rows[0]["Activate_Conduit_Time"], "", "HH:mm");
//导丝通过时间
string Balloon_expansion_Time = PublicClass.DateTimeToString(DataDT.Rows[0]["Balloon_expansion_Time"], "", "HH:mm");
//发病时间-首次医疗接触时间
int S2FMC = PublicClass.ToInt32(DataDT.Rows[0]["S2FMC"], 0);
//首次医疗接触时间间隔-首份心电图时间
int FMC2ECG = PublicClass.ToInt32(DataDT.Rows[0]["FMC2ECG"], 0);
//首份心电图时间-首份心电图确诊时间
int ECG2QZ = PublicClass.ToInt32(DataDT.Rows[0]["ECG2QZ"], 0);
//肌钙蛋白抽血时间-获取报告时间
int CX2BG = PublicClass.ToInt32(DataDT.Rows[0]["CX2BG"], 0);
//通知心内科会诊-会诊时间
int TZHZ2HZ = PublicClass.ToInt32(DataDT.Rows[0]["TZHZ2HZ"], 0);
//溶栓开始知情同意时间-溶栓签署知情同意时间
int RSKSZQTY2QS = PublicClass.ToInt32(DataDT.Rows[0]["RSZQTY2QS"], 0);
//介入开始知情同意时间-介入签署知情同意时间
int JRKSZQTY2QS = PublicClass.ToInt32(DataDT.Rows[0]["JRZQTY2QS"], 0);
//启动导管室时间-导管室激活时间
int QDDGS2DGSJH = PublicClass.ToInt32(DataDT.Rows[0]["QDDGS2DGSJH"], 0);
//到达医院大门时间-导丝通过时间
int D2W = PublicClass.ToInt32(DataDT.Rows[0]["D2W"], 0);
#region 治疗方案++知情同意
//治疗方案
string TreatmentOptions = string.Empty;
//知情同意时间和签署知情同意时间
string Start_Agree_Str = string.Empty;
//0:无溶栓 1:院前溶栓 2:院内溶栓 3:院前溶栓+院内溶栓
if (Thrombolysis > 0)
{
Start_Agree_Str = $"溶栓开始知情同意时间({Throm_Start_Agree_Time})-溶栓签署知情同意时间({Throm_Sign_Agree_Time});耗时{RSKSZQTY2QS}分钟";
switch (Thrombolysis)
{
case 1:
TreatmentOptions = "院前溶栓";
break;
case 2:
TreatmentOptions = "院内溶栓";
break;
case 3:
TreatmentOptions = "院前溶栓+院内溶栓";
break;
default:
break;
}
}
//是否介入治疗 0:否 1:是
if (Interventional_Therapy == 1)
{
if (!string.IsNullOrEmpty(Start_Agree_Str))
{
Start_Agree_Str += $"\r\n介入开始知情同意时间({Start_Agree_Time})-介入签署知情同意时间({Sign_Agree_Time});耗时{JRKSZQTY2QS}分钟";
}
else
{
Start_Agree_Str += $"介入开始知情同意时间({Start_Agree_Time})-介入签署知情同意时间({Sign_Agree_Time});耗时{JRKSZQTY2QS}分钟";
}
TreatmentOptions += TreatmentOptions == "" ? "介入治疗" : "+介入治疗";
}
#endregion 治疗方案++知情同意
#region 达标项与未达标项
//达标项
string StandardItem = string.Empty;
//不达标项
string NotStandardItem = string.Empty;
//首次医疗接触时间间隔-首份心电图时间
if (FMC2ECG >= 0 && FMC2ECG <= 10)
{
StandardItem = "首份心电图时间";
}
else
{
NotStandardItem = "首份心电图时间";
}
//首份心电图时间-首份心电图确诊时间
if (ECG2QZ >= 0 && ECG2QZ <= 10)
{
StandardItem += "\r\n心电图确诊时间";
}
else
{
NotStandardItem += "\r\n心电图确诊时间";
}
//肌钙蛋白抽血时间-获取报告时间
if (CX2BG >= 0 && CX2BG <= 20)
{
StandardItem += "\r\n肌钙蛋白检测时间";
}
else
{
NotStandardItem += "\r\n肌钙蛋白检测时间";
}
//到达医院大门时间-导丝通过时间
if (QDDGS2DGSJH >= 0 && QDDGS2DGSJH <= 30)
{
StandardItem += "\r\n导管室激活时间";
}
else
{
NotStandardItem += "\r\n导管室激活时间";
}
#endregion 达标项与未达标项
ContentStr = $"患者姓名:{Name},{GenderName},{Age}{Age_Unit}\r\n" +
$"建档日期:{RegisterTime}\r\n" +
$"诊断:{Diagnosis}\r\n" +
$"治疗方案:{TreatmentOptions}\r\n" +
$"绕行模式:{GreenChannel}\r\n" +
$"来院方式:{LYFS}\r\n" +
$"【质控指标】\r\n" +
$"是否远程传输心电图:{Remote_ECG_Transmission}\r\n" +
$"发病时间({FB_Time})-首次医疗接触时间({FMC_Time});耗时{S2FMC}分钟\r\n" +
$"首次医疗接触时间({FMC_Time})-首份心电图完成时间({ECG_Time});耗时{FMC2ECG}分钟\r\n" +
$"首份心电图完成时间({ECG_Time})-心电图诊断时间({ECG_Diagnose_Time});耗时{ECG2QZ}分钟\r\n" +
$"抽血完成时间({Blood_Time})-获得报告时间({Report_Time});耗时{CX2BG}分钟\r\n" +
$"通知心内科会诊时间({Notice_IMCD_Time})-会诊时间({Consultation_Time});耗时{TZHZ2HZ}分钟\r\n" + Start_Agree_Str + "\r\n" +
$"启动导管室时间({Start_Conduit_Time})-导管室激活时间({Activate_Conduit_Time});耗时{QDDGS2DGSJH}分钟\r\n" +
$"到达医院大门时间({Arrived_Hospital_Time})-导丝通过时间({Balloon_expansion_Time});耗时{D2W}分钟\r\n" +
$"【达标项】\r\n{StandardItem}\r\n" +
$"【未达标项】\r\n{NotStandardItem}";
#endregion 初始化病志信息
}
return ContentStr;
}
///
/// 保存按钮
///
///
///
private void barButton_Save_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
string Content = richEdit_Content.Text;
if (string.IsNullOrEmpty(Content))
{
if (XtraMessageBox.Show("当前患者病志信息为空,是否继续保存?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
{
return;
}
}
if (Save())
{
XtraMessageBox.Show("患者病志信息保存成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
BindData();//重新绑定,避免重复新增
}
}
///
/// 退出按钮
///
///
///
private void barButton_Exit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
Close();
}
///
/// 保存病志
///
///
private bool Save()
{
try
{
string Url = string.Empty;
#region 保存病志
List list_Model = new List();
T_Service_PathographyDTO model = new T_Service_PathographyDTO();
//存在则修改 否则新增
if (Cur_DetailDT != null && Cur_DetailDT.Rows.Count > 0)
{
Url = "api/service/T_Service_Pathography/UpdateNotNullColumns";
model.ID = PublicClass.ToInt64(Cur_DetailDT.Rows[0]["ID"], 0); ;
model.GUID = Cur_DetailDT.Rows[0]["GUID"].ToString();
model.DeleteFlag = PublicClass.ToInt32(Cur_DetailDT.Rows[0]["DeleteFlag"], -1);
model.CreatorID = PublicClass.ToInt64(Cur_DetailDT.Rows[0]["CreatorID"], 0);
model.CreationDate = Cur_DetailDT.Rows[0]["CreationDate"].ToString();
model.EditorID = Information.User.ID;
model.Editor = Information.User.FullName;
model.EditTime = PublicClass.DateTimeNow();
}
else
{
Url = "api/service/T_Service_Pathography/AddNotNullColumns";
model.ID = 0;
model.GUID = Guid.NewGuid().ToString();
model.DeleteFlag = 0;
model.CreatorID = Information.User.ID;
model.Creator = Information.User.FullName;
model.CreationDate = PublicClass.DateTimeNow();
}
model.PatientGuid = Cur_PatientGuid;
model.Content = richEdit_Content.Text;
list_Model.Add(model);
//初始化两个工厂
ClientFactory httpClient = new HttpClientFactory();
Client client = httpClient.VisitFactory();
#endregion
var result = client.Post(Url, list_Model);
//访问
return result.Success;
}
catch (Exception ex)
{
PublicClass.WriteErrorLog(this.Text, "保存患者病志信息:\r\n" + ex);
return false;
}
}
///
/// 刷新
///
///
///
private void barButton_Refresh_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
if (!string.IsNullOrEmpty(richEdit_Content.Text.Trim()))
{
if (XtraMessageBox.Show("当前患者病志信息不为空,是否继续更新?\r\n继续更新将覆盖您当前的所有更改!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
{
return;
}
}
if (Cur_QualityControlDT.Rows.Count <= 0)
{
string Url = string.Format("api/service/T_Service_ChestPain_PatientsTimeAxis/GetChestPainQualityControl?patientGuid={0}", Cur_PatientGuid);
Cur_QualityControlDT = DBHelpClass.GetJsonText(Url);
}
//生成病志
richEdit_Content.Text = InitializePathography(Cur_QualityControlDT);
}
///
/// 收藏
///
///
///
private void barButton_Enshrine_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
//病志没有存储到表中
if (Cur_DetailDT != null && Cur_DetailDT.Rows.Count > 0)
{
//病志内容框不为空
string Content = richEdit_Content.Text.Trim();
if (!string.IsNullOrEmpty(Content))
{
//收藏前进行保存
if (Save())
{
BindData();//重新绑定,避免重复新增
string dynamicGuid = PublicClass.ToString(Cur_DetailDT.Rows[0]["GUID"], "");
if (!string.IsNullOrEmpty(dynamicGuid))
{
if (Save_Enshrine(dynamicGuid))
{
XtraMessageBox.Show("收藏患者病志信息成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
XtraMessageBox.Show("收藏失败,请稍后重试或联系管理员!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
XtraMessageBox.Show("收藏失败,请先保存患者病志信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
}
///
/// 保存收藏
///
/// 需要收藏的动态编号
///
private bool Save_Enshrine(string dynamicGuid)
{
try
{
string Url = $"api/service/T_Service_Enshrine/GetModelByDynamicGuid?userId={Information.User.ID}&type=1&dynamicGuid={dynamicGuid}";
DataTable EnshrineDT = DBHelpClass.Get(Url);
#region 保存收藏
List list_Model = new List();
T_Service_EnshrineDTO model = new T_Service_EnshrineDTO();
//存在则修改 否则新增
if (EnshrineDT != null && EnshrineDT.Rows.Count > 0)
{
Url = "api/service/T_Service_Enshrine/UpdateNotNullColumns";
model.ID = PublicClass.ToInt64(EnshrineDT.Rows[0]["ID"], 0); ;
model.GUID = EnshrineDT.Rows[0]["GUID"].ToString();
model.DeleteFlag = PublicClass.ToInt32(EnshrineDT.Rows[0]["DeleteFlag"], -1);
model.CreatorID = PublicClass.ToInt64(EnshrineDT.Rows[0]["CreatorID"], 0);
model.EditorID = Information.User.ID;
model.Editor = Information.User.FullName;
model.EditTime = PublicClass.DateTimeNow();
}
else
{
Url = "api/service/T_Service_Enshrine/AddNotNullColumns";
model.ID = 0;
model.GUID = Guid.NewGuid().ToString();
model.DeleteFlag = 0;
model.CreatorID = Information.User.ID;
model.Creator = Information.User.FullName;
model.CreationDate = PublicClass.DateTimeNow();
}
model.UserID = Information.User.ID;
model.Type = 1;
model.DynamicGuid = dynamicGuid;
list_Model.Add(model);
//初始化两个工厂
ClientFactory httpClient = new HttpClientFactory();
Client client = httpClient.VisitFactory();
#endregion
bool IsTrue = client.Post(Url, list_Model).Success;
//访问
return IsTrue;
}
catch (Exception ex)
{
PublicClass.WriteErrorLog(this.Text, "保存收藏:\r\n" + ex);
return false;
}
}
}
}