StableVersion4.3/HL_FristAidPlatform_Frame/Main/Form_ScanTime.cs

199 lines
9.9 KiB
C#

using DevExpress.XtraEditors;
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_Frame
{
/// <summary>
/// 快速扫码记录时间
/// </summary>
public partial class Form_ScanTime : XtraForm
{
public Form_ScanTime()
{
InitializeComponent();
}
private void Form_ScanTime_Load(object sender, EventArgs e)
{
txt_TxmCode.Focus();
}
/// <summary>
/// 扫码成功
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void txt_TxmCode_KeyDown(object sender, KeyEventArgs e)
{
try
{
if (e.KeyCode == Keys.Enter)
{
string TxmCodeStr = txt_TxmCode.EditValue as string;
if (!string.IsNullOrEmpty(TxmCodeStr.Trim()))
{
if (TxmCodeStr.Contains(PublicClassForDataBase.Config100))
{
string Url = string.Empty;
int i = TxmCodeStr.IndexOf(PublicClassForDataBase.Config100);
long PatientID = Convert.ToInt64(TxmCodeStr.Substring(0, i));
long TimeAxisID = Convert.ToInt64(TxmCodeStr.Substring(i + 1, TxmCodeStr.Length - i - 1));
//根据病人ID获取病人GUID
Url = "api/service/T_Service_Patient/{0}";
DataTable DetailDT = DBHelpClass.GetDataRow(string.Format(Url, PatientID));
if (DetailDT != null && DetailDT.Rows.Count > 0)
{
//患者编号(GUID)
string PatientGuid = PublicClass.ToString(DetailDT.Rows[0]["GUID"], "");
//患者姓名
string PatientName = DetailDT.Rows[0]["Name"].ToString();
//患者所属系统模块
string SystemModuleID = PublicClass.ToString(DetailDT.Rows[0]["SystemModuleID"], "");
//时间节点名称
string TimeAxisName = string.Empty;
//获取时间节点名称
DataTable TimeAxisDetailDT = DBHelpClass.GetDataRow(string.Format("api/base/T_Base_TimeAxis/{0}", TimeAxisID));
if (TimeAxisDetailDT != null && TimeAxisDetailDT.Rows.Count > 0)
{
TimeAxisName = TimeAxisDetailDT.Rows[0]["TimeName"].ToString();
}
//存在病人
if (string.IsNullOrEmpty(PatientGuid))
{
#region 对应更改各模块病人
//胸痛中心系统
if (SystemModuleID == PublicClassForDataBase.Config10001)
{
if (Update_ChestPain_PatientsTimeAxis(PatientGuid, TimeAxisID))
{
labelControl_Message.ForeColor = Color.Green;
labelControl_Message.Text = string.Format("【胸痛】患者【{0}】的【{1}】时间记录成功!", PatientName, TimeAxisName);
}
else
{
labelControl_Message.ForeColor = Color.Red;
labelControl_Message.Text = string.Format("【胸痛】患者【{0}】的【{1}】时间记录失败!请重新操作!", PatientName, TimeAxisName);
}
}
//卒中中心系统
else if (SystemModuleID == PublicClassForDataBase.Config10002)
{
if (Update_Apoplexy_PatientsTimeAxis(PatientGuid, TimeAxisID))
{
labelControl_Message.ForeColor = Color.Green;
labelControl_Message.Text = string.Format("【卒中】患者【{0}】的【{1}】时间记录成功!", PatientName, TimeAxisName);
}
else
{
labelControl_Message.ForeColor = Color.Red;
labelControl_Message.Text = string.Format("【卒中】患者【{0}】的【{1}】时间记录失败!请重新操作!", PatientName, TimeAxisName);
}
}
//创伤救治中心系统
else if (SystemModuleID == PublicClassForDataBase.Config10003)
{
}
//危重孕产妇救治中心系统
else if (SystemModuleID == PublicClassForDataBase.Config10004)
{
}
//危重新生儿救治中心系统
else if (SystemModuleID == PublicClassForDataBase.Config10005)
{
}
#endregion
}
}
else
{
labelControl_Message.ForeColor = Color.Red;
labelControl_Message.Text = string.Format("没有获取到病人ID为【{0}】的患者信息,请联系技术人员!", PatientID);
}
}
}
}
}
catch (Exception ex)
{
PublicClass.WriteErrorLog("开始接诊扫码", "扫码成功:\r\n" + ex);
}
}
/// <summary>
/// 更新胸痛病人时间节点
/// </summary>
/// <param name="_patientGuid">病人编号(GUID)</param>
/// <param name="_timeAxisID">时间节点编号</param>
private bool Update_ChestPain_PatientsTimeAxis(string _patientGuid, long _timeAxisID)
{
try
{
List<T_Service_ChestPain_PatientsTimeAxisDTO> list = new List<T_Service_ChestPain_PatientsTimeAxisDTO>();
T_Service_ChestPain_PatientsTimeAxisDTO model = new T_Service_ChestPain_PatientsTimeAxisDTO();
string Url = "/api/service/T_Service_ChestPain_PatientsTimeAxis/UpdateRecordingTimeByPatientIDAndTimeAxisID";
model.RecordingTime = PublicClass.DateTimeNow();
model.PatientGuid = _patientGuid;
model.TimeAxisID = _timeAxisID;
model.NormalTime = PublicClass.DateTimeNow();//赋值但不更新
list.Add(model);
//初始化两个工厂
ClientFactory<T_Service_ChestPain_PatientsTimeAxisDTO> httpClient = new HttpClientFactory<T_Service_ChestPain_PatientsTimeAxisDTO>();
Client<T_Service_ChestPain_PatientsTimeAxisDTO> client = httpClient.VisitFactory();
//访问
ListEntity<T_Service_ChestPain_PatientsTimeAxisDTO> t = client.Post(Url, list);
return t.Success;
}
catch (Exception ex)
{
PublicClass.WriteErrorLog("开始接诊扫码", "更新胸痛病人时间节点:\r\n" + ex);
return false;
}
}
/// <summary>
/// 更新卒中病人时间节点
/// </summary>
/// <param name="_patientGuid">病人编号(GUID)</param>
/// <param name="_timeAxisID">时间节点编号</param>
private bool Update_Apoplexy_PatientsTimeAxis(string _patientGuid, long _timeAxisID)
{
try
{
List<T_Service_Apoplexy_PatientsTimeAxisDTO> list = new List<T_Service_Apoplexy_PatientsTimeAxisDTO>();
T_Service_Apoplexy_PatientsTimeAxisDTO model = new T_Service_Apoplexy_PatientsTimeAxisDTO();
string Url = "/api/service/T_Service_Apoplexy_PatientsTimeAxis/UpdateRecordingTimeByPatientIDAndTimeAxisID";
model.RecordingTime = PublicClass.DateTimeNow();
model.PatientGuid = _patientGuid;
model.TimeAxisID = _timeAxisID;
model.NormalTime = PublicClass.DateTimeNow();//赋值但不更新
list.Add(model);
//初始化两个工厂
ClientFactory<T_Service_Apoplexy_PatientsTimeAxisDTO> httpClient = new HttpClientFactory<T_Service_Apoplexy_PatientsTimeAxisDTO>();
Client<T_Service_Apoplexy_PatientsTimeAxisDTO> client = httpClient.VisitFactory();
//访问
ListEntity<T_Service_Apoplexy_PatientsTimeAxisDTO> t = client.Post(Url, list);
return t.Success;
}
catch (Exception ex)
{
PublicClass.WriteErrorLog("开始接诊扫码", "更新卒中病人时间节点:\r\n" + ex);
return false;
}
}
}
}