StableVersion4.3/HL_FristAidPlatform_DataBase/Service/T_Service_FollowUp_ChestPai...

120 lines
5.7 KiB
C#

using HL_FristAidPlatform_Help;
using HL_FristAidPlatform_IDataBase;
using HL_FristAidPlatform_Models;
using SqlSugar;
using System;
using System.Collections.Generic;
namespace HL_FristAidPlatform_DataBase
{
//T_Service_FollowUp_ChestPain
public class T_Service_FollowUp_ChestPainDB : BaseDB, IT_Service_FollowUp_ChestPain
{
public SqlSugarClient db = GetClient();
/// <summary>
/// 增加一条数据
/// </summary>
public bool Add(T_Service_FollowUp_ChestPain model)
{
return db.Insertable(model).ExecuteCommand() == 0 ? false : true;
}
/// <summary>
/// 更新一条数据
/// </summary>
public bool Update(T_Service_FollowUp_ChestPain model)
{
return db.Updateable(model).ExecuteCommand() == 0 ? false : true;
}
/// <summary>
/// 删除一条数据
/// </summary>
public bool Delete(long ID)
{
return db.Deleteable<T_Service_FollowUp_ChestPain>(it => it.ID == ID).ExecuteCommand() == 0 ? false : true; ;
}
/// <summary>
/// 获得数据列表
/// </summary>
public TableModel<T_Service_FollowUp_ChestPain> GetPageList(int pageIndex, int pageSize)
{
int total = 0;
List<T_Service_FollowUp_ChestPain> data = db.Queryable<T_Service_FollowUp_ChestPain>().Where(it => it.DeleteFlag == 0).ToPageList(pageIndex, pageSize, ref total);
TableModel<T_Service_FollowUp_ChestPain> t = new TableModel<T_Service_FollowUp_ChestPain>();
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_ChestPain> GetPageList(int pageIndex, int pageSize, string pGuid)
{
List<T_Service_FollowUp_ChestPain> data = db.Queryable<T_Service_FollowUp_ChestPain>().Where(FollowUp => FollowUp.PatientGuid == pGuid && FollowUp.DeleteFlag == 0).OrderBy(FollowUp => FollowUp.FollowUpDate, OrderByType.Asc).ToPageList(pageIndex, pageSize);
TableModel<T_Service_FollowUp_ChestPain> t = new TableModel<T_Service_FollowUp_ChestPain>();
t.Code = 0;
t.PageCount = data.Count;
t.TotalNumber = data.Count;
t.Data = data;
t.Msg = "成功";
return t;
}
public TableModel<T_Service_FollowUp_ChestPain_Patient> GetModelByFollowUp(string key, string startTime, string endTime, int state, int pageIndex, int pageSize, long SystemModuleID, string hospitalGuid)
{
int TotalNumber = 0;
List<T_Service_FollowUp_ChestPain_Patient> data = new List<T_Service_FollowUp_ChestPain_Patient>();
data = db.Queryable<T_Service_Patient, T_Service_FollowUp_ChestPain, 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, FollowUp.Note, FollowUp.IsChestPain, FollowUp.FollowUpDoctor, FollowUp.FollowUpType, FollowUp.FollowUpResult })
.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,
Note = FollowUp.Note,
IsChestPain = FollowUp.IsChestPain,
FollowUpDoctor = FollowUp.FollowUpDoctor,
FollowUpType = FollowUp.FollowUpType,
FollowUpResult = FollowUp.FollowUpResult
}).ToPageList(pageIndex, pageSize, ref TotalNumber);
TableModel<T_Service_FollowUp_ChestPain_Patient> t = new TableModel<T_Service_FollowUp_ChestPain_Patient>();
t.Code = 0;
t.PageCount = data.Count;
t.TotalNumber = TotalNumber;
t.Data = data;
t.Msg = "成功";
return t;
}
/// <summary>
/// 获得前几行数据
/// </summary>
public T_Service_FollowUp_ChestPain Get(string ID)
{
return db.Queryable<T_Service_FollowUp_ChestPain>().First(it => it.ID.ToString() == ID);
}
}
}