StableVersion4.3/HL_FristAidPlatform_DataBase/Service/T_Service_ApoplexyPastHisto...

79 lines
3.3 KiB
C#
Raw Normal View History

2024-03-11 09:47:34 +08:00
using HL_FristAidPlatform_Help;
using HL_FristAidPlatform_IDataBase;
using HL_FristAidPlatform_Models;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HL_FristAidPlatform_DataBase
{
/// <summary>
/// 卒中筛查既往病史及控制情况
/// </summary>
public class T_Service_ApoplexyPastHistoryDB : BaseDB, IT_Service_ApoplexyPastHistory
{
public SqlSugarClient db = GetClient();
/// <summary>
/// 保存既往病史及控制情况
/// </summary>
/// <param name="pastHistory"></param>
/// <returns></returns>
public bool SaveScreenPastHistory(T_Service_ApoplexyPastHistory pastHistory)
{
try
{
db.Ado.BeginTran();
var oneClass = db.Queryable<T_Service_ApoplexyPastHistory>().Where(i => i.PatientGUID == pastHistory.PatientGUID && i.DeleteFlag == 0).First();
if (oneClass != null)
{
if (oneClass.FillinStatus == "0")
{
T_Service_ApoplexyScreenInfo screenInfo = new T_Service_ApoplexyScreenInfo();
screenInfo = db.Queryable<T_Service_ApoplexyScreenInfo>().Where(i => i.GUID == pastHistory.PatientGUID).First();
screenInfo.RescreeningStatus = screenInfo.RescreeningStatus + 1;
db.Updateable(screenInfo).UpdateColumns(it => new { it.RescreeningStatus }).ExecuteCommand();
}
pastHistory.GUID = oneClass.GUID;
db.Updateable(pastHistory).IgnoreColumns(i => new { i.ID, i.CreateID, i.CreateTime }).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand() ;
}
else
{
pastHistory.GUID = Guid.NewGuid().ToString();
pastHistory.CreateTime = DateTime.Now;
db.Insertable(pastHistory).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand() ;
T_Service_ApoplexyScreenInfo screenInfo = new T_Service_ApoplexyScreenInfo();
screenInfo = db.Queryable<T_Service_ApoplexyScreenInfo>().Where(i => i.GUID == pastHistory.PatientGUID).First();
screenInfo.RescreeningStatus = screenInfo.RescreeningStatus + 1;
db.Updateable(screenInfo).UpdateColumns(it => new { it.RescreeningStatus }).ExecuteCommand();
}
db.Ado.CommitTran();
return true;
}
catch (Exception ex)
{
db.Ado.RollbackTran();
Help.WriteErrorLog("卒中高危筛查保存既往病史及控制情况(SaveScreenPastHistory)", ex.ToString());
return false;
}
}
/// <summary>
/// 获取查既往病史及控制情况
/// </summary>
/// <param name="guid"></param>
/// <returns></returns>
public T_Service_ApoplexyPastHistory GetScreenPastHistory(string patientGuid)
{
return db.Queryable<T_Service_ApoplexyPastHistory>().Where(i => i.PatientGUID == patientGuid && i.DeleteFlag == 0).First();
}
}
}