197 lines
9.2 KiB
C#
197 lines
9.2 KiB
C#
|
using HL_FristAidPlatform_Help;
|
|||
|
using HL_FristAidPlatform_IDataBase;
|
|||
|
using HL_FristAidPlatform_Models;
|
|||
|
using SqlSugar;
|
|||
|
using System.Collections.Generic;
|
|||
|
namespace HL_FristAidPlatform_DataBase
|
|||
|
{
|
|||
|
//T_Service_FollowUp
|
|||
|
public class T_Service_FollowUpDB : BaseDB, IT_Service_FollowUp
|
|||
|
{
|
|||
|
public SqlSugarClient db = GetClient();
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 增加一条数据
|
|||
|
/// </summary>
|
|||
|
public bool Add(T_Service_FollowUp model)
|
|||
|
{
|
|||
|
return db.Insertable(model).ExecuteCommand() == 0 ? false : true;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 更新一条数据
|
|||
|
/// </summary>
|
|||
|
public bool Update(T_Service_FollowUp model)
|
|||
|
{
|
|||
|
return db.Updateable(model).ExecuteCommand() == 0 ? false : true;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 删除一条数据
|
|||
|
/// </summary>
|
|||
|
public bool Delete(long ID)
|
|||
|
{
|
|||
|
return db.Deleteable<T_Service_FollowUp>(it => it.ID == ID).ExecuteCommand() == 0 ? false : true; ;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 获得数据列表
|
|||
|
/// </summary>
|
|||
|
public TableModel<T_Service_FollowUp> GetPageList(int pageIndex, int pageSize)
|
|||
|
{
|
|||
|
int total = 0;
|
|||
|
List<T_Service_FollowUp> data = db.Queryable<T_Service_FollowUp>().Where(it => it.DeleteFlag == 0).ToPageList(pageIndex, pageSize, ref total);
|
|||
|
TableModel<T_Service_FollowUp> t = new TableModel<T_Service_FollowUp>();
|
|||
|
t.Code = 0;
|
|||
|
t.PageCount = data.Count;
|
|||
|
t.TotalNumber = total;
|
|||
|
t.Data = data;
|
|||
|
t.Msg = "成功";
|
|||
|
return t;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 根据病人ID获取随访记录
|
|||
|
/// </summary>
|
|||
|
/// <param name="pageIndex"></param>
|
|||
|
/// <param name="pageSize"></param>
|
|||
|
/// <param name="pGuid"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public TableModel<T_Service_FollowUp> GetPageList(int pageIndex, int pageSize, string pGuid)
|
|||
|
{
|
|||
|
int TotalNumber = 0;
|
|||
|
List<T_Service_FollowUp> data = db.Queryable<T_Service_FollowUp>().Where(FollowUp => FollowUp.PatientGuid == pGuid && FollowUp.DeleteFlag == 0).OrderBy(FollowUp => FollowUp.FollowUpDate, OrderByType.Asc).ToPageList(pageIndex, pageSize, ref TotalNumber);
|
|||
|
TableModel<T_Service_FollowUp> t = new TableModel<T_Service_FollowUp>();
|
|||
|
|
|||
|
t.Code = 0;
|
|||
|
t.PageCount = data.Count;
|
|||
|
t.TotalNumber = TotalNumber;
|
|||
|
t.Data = data;
|
|||
|
t.Msg = "成功";
|
|||
|
return t;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 获得前几行数据
|
|||
|
/// </summary>
|
|||
|
public T_Service_FollowUp Get(string ID)
|
|||
|
{
|
|||
|
return db.Queryable<T_Service_FollowUp>().First(it => it.ID.ToString() == ID);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
public TableModel<T_Service_FollowUp_ChestPain_Patient> GetModelByFollowUp(string key, string startTime, string endTime, int state, int pageIndex, int pageSize, long SystemModuleID, string hospitalGuid)
|
|||
|
{
|
|||
|
|
|||
|
List<T_Service_FollowUp_ChestPain_Patient> data = new List<T_Service_FollowUp_ChestPain_Patient>();
|
|||
|
string where = " ";
|
|||
|
if (string.IsNullOrEmpty(key))
|
|||
|
{
|
|||
|
where += " AND ((([Patient].[Name] like '%'" + key + "'%') " +
|
|||
|
" OR ([Patient].[IdentityCard] like '%'" + key + "'%') ) " +
|
|||
|
" OR ([Patient].EmergencyContactPhone] like '%'" + key + "'%')) ";
|
|||
|
}
|
|||
|
if (string.IsNullOrEmpty(startTime))
|
|||
|
{
|
|||
|
where += " AND( [Patient].[RegisterTime] >= CAST('" + startTime + "' AS DATETIME)) ";
|
|||
|
}
|
|||
|
if (string.IsNullOrEmpty(endTime))
|
|||
|
{
|
|||
|
where += " AND( [Patient].[RegisterTime] <= CAST('" + endTime + "' AS DATETIME)) ";
|
|||
|
}
|
|||
|
if (state >= 0)
|
|||
|
{
|
|||
|
where += " AND( [Patient].[EmergencyState] = " + state + ") ";
|
|||
|
}
|
|||
|
if (SystemModuleID >= 0)
|
|||
|
{
|
|||
|
where += " AND( [Patient].[SystemModuleID]= " + SystemModuleID + " ) ";
|
|||
|
}
|
|||
|
if (string.IsNullOrEmpty(hospitalGuid))
|
|||
|
{
|
|||
|
where += " AND( [Patient].[HospitalGuid] = '" + hospitalGuid + "' ) ";
|
|||
|
}
|
|||
|
string sql = @" SELECT * FROM
|
|||
|
(SELECT [Patient].[ID] AS[ID] , [Patient].[GUID] AS [GUID] , [Patient].[Name] AS[Name] ,
|
|||
|
[Patient].[Age] AS[Age] , [Gender].[GenderName] AS[GenderString] , [Patient].[IdentityCard] AS[IdentityCard] ,
|
|||
|
[Patient].[MobilePhone] AS[MobilePhone], MIN([FollowUp].[FollowUpDate]) AS[FollowUpDate] ,
|
|||
|
[FollowUp]. [FollowUpStatus] [FollowUpStatus] , FollowUp.[FollowUpType] AS[FollowUpType] ,
|
|||
|
ROW_NUMBER() OVER(ORDER BY GetDate()) AS RowIndex
|
|||
|
FROM[T_Service_Patient] Patient
|
|||
|
Inner JOIN[T_Service_FollowUp_Apoplexy] FollowUp
|
|||
|
ON [Patient].[GUID] = [FollowUp].[PatientGuid]
|
|||
|
Left JOIN[T_Base_Gender] Gender
|
|||
|
ON [Patient].[Gender] = [Gender].[GenderCode]
|
|||
|
WHERE FollowUp.FollowUpDate =(SELECT TOP 1 FollowUpDate FROM T_Service_FollowUp_Apoplexy
|
|||
|
WHERE [PatientGuid] = FollowUp.[PatientGuid] ORDER BY ABS(DATEDIFF(second, getdate(), FollowUpDate)))
|
|||
|
AND [Patient].[DeleteFlag] = 0
|
|||
|
" + where + " GROUP BY[FollowUpDate],[Patient].[ID],[Patient].[GUID],[Patient].[Name],[Patient].[Age],[Gender].[GenderName], [Patient].[IdentityCard],[Patient].[MobilePhone],[FollowUp].[FollowUpStatus],[FollowUp].[FollowUpType] ) " +
|
|||
|
" T WHERE RowIndex BETWEEN " + pageIndex + " AND " + pageSize + " ";
|
|||
|
|
|||
|
|
|||
|
data = db.Ado.SqlQuery<T_Service_FollowUp_ChestPain_Patient>(sql);
|
|||
|
var total = data.Count;
|
|||
|
#region MyRegion
|
|||
|
//data = db.Queryable<T_Service_Patient, T_Service_FollowUp, T_Base_Gender>((Patient, FollowUp, Gender) => new object[]
|
|||
|
//{
|
|||
|
// JoinType.Inner, Patient.GUID == FollowUp.PatientGuid,
|
|||
|
// JoinType.Left,Patient.Gender==Gender.GenderCode
|
|||
|
//})
|
|||
|
//.WhereIF(!string.IsNullOrEmpty(key), Patient => Patient.Name.Contains(key) || Patient.IdentityCard.Contains(key) || Patient.EmergencyContactPhone.Contains(key))
|
|||
|
//.WhereIF(!string.IsNullOrEmpty(startTime), Patient => Patient.RegisterTime >= Convert.ToDateTime(startTime))
|
|||
|
//.WhereIF(!string.IsNullOrEmpty(endTime), Patient => Patient.RegisterTime <= Convert.ToDateTime(endTime))
|
|||
|
//.WhereIF(!string.IsNullOrEmpty(hospitalGuid), Patient => Patient.HospitalGuid == hospitalGuid)
|
|||
|
//.Where(Patient => Patient.DeleteFlag == 0 && Patient.EmergencyState == state && Patient.SystemModuleID == SystemModuleID).GroupBy((Patient, FollowUp, Gender) => new { Patient.ID, Patient.GUID, Patient.Name, Patient.Age, Gender.GenderName, Patient.IdentityCard, Patient.MobilePhone, FollowUp.FollowUpStatus })
|
|||
|
//.Select((Patient, FollowUp, Gender) => new T_Service_FollowUp_ChestPain_Patient
|
|||
|
//{
|
|||
|
// ID = Patient.ID,
|
|||
|
// GUID = Patient.GUID,
|
|||
|
// Name = Patient.Name,
|
|||
|
// Age = Patient.Age,
|
|||
|
// GenderString = Gender.GenderName,
|
|||
|
// IdentityCard = Patient.IdentityCard,
|
|||
|
// MobilePhone = Patient.MobilePhone,
|
|||
|
// FollowUpDate = SqlFunc.AggregateMin(FollowUp.FollowUpDate),
|
|||
|
// FollowUpStatus = FollowUp.FollowUpStatus
|
|||
|
//}).ToPageList(pageIndex, pageSize, ref TotalNumber);
|
|||
|
#endregion
|
|||
|
|
|||
|
TableModel<T_Service_FollowUp_ChestPain_Patient> t = new TableModel<T_Service_FollowUp_ChestPain_Patient>();
|
|||
|
t.Code = 0;
|
|||
|
t.PageCount = data.Count;
|
|||
|
t.TotalNumber = total;
|
|||
|
t.Data = data;
|
|||
|
t.Msg = "成功";
|
|||
|
return t;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 获得患者随访记录数据列表
|
|||
|
/// </summary>
|
|||
|
public TableModel<T_Service_FollowUp> GetPatientFollowList(string pGuid)
|
|||
|
{
|
|||
|
int TotalNumber = 0;
|
|||
|
TableModel<T_Service_FollowUp> t = new TableModel<T_Service_FollowUp>();
|
|||
|
var listFollowData = db.Queryable<T_Service_FollowUp>()
|
|||
|
.Where(it => it.PatientGuid == pGuid && it.DeleteFlag == 0).ToPageList(1, 100, ref TotalNumber);
|
|||
|
t.Code = 0;
|
|||
|
t.PageCount = listFollowData.Count;
|
|||
|
t.TotalNumber = TotalNumber;
|
|||
|
t.Data = listFollowData;
|
|||
|
t.Msg = "成功";
|
|||
|
return t;
|
|||
|
}
|
|||
|
|
|||
|
///<summary>
|
|||
|
///修改卒中患者详情
|
|||
|
/// </summary>
|
|||
|
/// <param name="model"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public bool UpdateFollowUp(int id)
|
|||
|
{
|
|||
|
return db.Updateable<T_Service_FollowUp>().SetColumns(it => it.FollowUpStatus == "1").Where(it => it.ID == id).ExecuteCommand() == 0 ? false : true;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|