314 lines
13 KiB
C#
314 lines
13 KiB
C#
|
using HL_FristAidPlatform_Models;
|
|||
|
using SqlSugar;
|
|||
|
using System;
|
|||
|
using HL_FristAidPlatform_Help;
|
|||
|
using HL_FristAidPlatform_IDataBase;
|
|||
|
using System.Collections.Generic;
|
|||
|
|
|||
|
namespace HL_FristAidPlatform_DataBase
|
|||
|
{
|
|||
|
public class T_Service_Apoplexy_FAHBaseDB : BaseDB, IT_Service_Apoplexy_FAHBase
|
|||
|
{
|
|||
|
public SqlSugarClient db = GetClient();
|
|||
|
|
|||
|
#region 新增
|
|||
|
/// <summary>
|
|||
|
/// 新增
|
|||
|
/// </summary>
|
|||
|
/// <param name="model"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public T_Service_Apoplexy_FAHBase Add(T_Service_Apoplexy_FAHBase model)
|
|||
|
{
|
|||
|
return db.Insertable(model).IgnoreColumns(it => new { it.ID }).ExecuteReturnEntity();
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 新增 仅更新赋值的字段
|
|||
|
/// </summary>
|
|||
|
/// <param name="model"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public int AddNotNullColumns(T_Service_Apoplexy_FAHBase model)
|
|||
|
{
|
|||
|
return db.Insertable(model).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand();
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 更新
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 更新
|
|||
|
/// </summary>
|
|||
|
/// <param name="model"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public int Update(T_Service_Apoplexy_FAHBase model)
|
|||
|
{
|
|||
|
return db.Updateable(model).ExecuteCommand();
|
|||
|
}
|
|||
|
|
|||
|
//根据guid获取患者基础信息
|
|||
|
public T_Service_Apoplexy_FAHBase GetByPatientGuid(string PatientGuid)
|
|||
|
{
|
|||
|
return db.Queryable<T_Service_Apoplexy_FAHBase>().First(it => it.GUID == PatientGuid);
|
|||
|
}
|
|||
|
|
|||
|
public int LogicDelete(T_Service_Apoplexy_FAHBase model)
|
|||
|
{
|
|||
|
return db.Updateable(model).UpdateColumns(it => new { it.DeleteFlag }).Where(it => it.GUID == model.PatientGUID).ExecuteCommand();
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 仅更新赋值的字段
|
|||
|
/// </summary>
|
|||
|
/// <param name="model">实体类</param>
|
|||
|
/// <returns></returns>
|
|||
|
public int UpdateNotNullColumns(T_Service_Apoplexy_FAHBase model)
|
|||
|
{
|
|||
|
return db.Updateable(model).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 查询
|
|||
|
public TableModel<T_Service_Apoplexy_FAHBaseModel> GetPageList(int pageIndex, int pageSize, string hospitalGuid, string systemModuleID, string starttime, string endtime, string ageStart, string ageEnd, string name)
|
|||
|
{
|
|||
|
int TotalNumber = 0;
|
|||
|
TableModel<T_Service_Apoplexy_FAHBaseModel> t = new TableModel<T_Service_Apoplexy_FAHBaseModel>();
|
|||
|
|
|||
|
var listMode = db.Queryable<T_Service_Apoplexy_FAHBase>()
|
|||
|
.Where(a => a.ID > 0 && a.DeleteFlag == 0 && a.SystemModuleID == systemModuleID && a.HospitalGuid == hospitalGuid)
|
|||
|
.WhereIF(!SqlFunc.IsNullOrEmpty(starttime) && !SqlFunc.IsNullOrEmpty(endtime), a => SqlFunc.Between(a.CreationDate, Convert.ToDateTime(starttime), Convert.ToDateTime(endtime)))
|
|||
|
.WhereIF(!SqlFunc.IsNullOrEmpty(ageStart) && !SqlFunc.IsNullOrEmpty(ageEnd), a => SqlFunc.Between(int.Parse(a.Age), Convert.ToInt16(ageStart), Convert.ToInt16(ageEnd)))
|
|||
|
.WhereIF(!SqlFunc.IsNullOrEmpty(name), a => a.Name.Contains(name))
|
|||
|
.Select(a => new T_Service_Apoplexy_FAHBaseModel
|
|||
|
{
|
|||
|
ID = a.ID,
|
|||
|
GUID = a.GUID,
|
|||
|
SystemModuleID = a.SystemModuleID,
|
|||
|
BedNum = a.BedNum,
|
|||
|
Name = a.Name,
|
|||
|
Sex = a.Sex,
|
|||
|
PatientNum = a.PatientNum,
|
|||
|
GroupDif = a.GroupDif,
|
|||
|
Age = a.Age,
|
|||
|
Height = a.Height,
|
|||
|
Weight = a.Weight,
|
|||
|
AdmissionDate = a.AdmissionDate,
|
|||
|
DischargeDate = a.DischargeDate,
|
|||
|
PatientPhone = a.PatientPhone,
|
|||
|
EmergencyContactPhone = a.EmergencyContactPhone,
|
|||
|
IDCard = a.IDCard,
|
|||
|
Address = a.Address,
|
|||
|
MaritalStatus = a.MaritalStatus,
|
|||
|
ComingWay = a.ComingWay,
|
|||
|
MedicalType = a.MedicalType,
|
|||
|
InhospitalWay = a.InhospitalWay,
|
|||
|
ChargeDoctor = a.ChargeDoctor,
|
|||
|
Treated = a.Treated,
|
|||
|
AdmissionDiagnosis = a.AdmissionDiagnosis,
|
|||
|
AdmissionDiagnosisOther = a.AdmissionDiagnosisOther,
|
|||
|
PatientComplaint = a.PatientComplaint,
|
|||
|
HospitalGuid = a.HospitalGuid,
|
|||
|
DeleteFlag = a.DeleteFlag,
|
|||
|
CreationDate = a.CreationDate,
|
|||
|
CreatorID = a.CreatorID,
|
|||
|
FNextDay = SqlFunc.Subqueryable<T_Service_Apoplexy_FollowUpBase>().Where(s => s.PatientGuid == a.GUID && s.NextTime > DateTime.Now).OrderBy(s => s.NextTime).Select(s => s.NextTime),
|
|||
|
Proportion= SqlFunc.Subqueryable<T_Service_Apoplexy_FollowUpInfo>().Where(s => s.FGUID == (SqlFunc.Subqueryable<T_Service_Apoplexy_FollowUpBase>().Where(s => s.PatientGuid == a.GUID && s.NextTime > DateTime.Now).OrderBy(s => s.NextTime).Select(s => s.GUID))).Select(s => s.Proportion)
|
|||
|
}).OrderBy(a => a.CreationDate, OrderByType.Desc).ToPageList(pageIndex, pageSize, ref TotalNumber);
|
|||
|
|
|||
|
t.Code = 0;
|
|||
|
t.PageCount = listMode.Count;
|
|||
|
t.TotalNumber = TotalNumber;
|
|||
|
t.Data = listMode;
|
|||
|
t.Msg = "成功";
|
|||
|
return t;
|
|||
|
}
|
|||
|
|
|||
|
public List<KeyValue> GetPageList(string hospitalGuid)
|
|||
|
{
|
|||
|
List<KeyValue> t = new List<KeyValue>();
|
|||
|
|
|||
|
var listMode = db.Queryable<T_Service_Apoplexy_FAHBase>()
|
|||
|
.Where(a => a.ID > 0 && a.DeleteFlag == 0 && a.SystemModuleID == "3" && a.HospitalGuid == hospitalGuid)
|
|||
|
.Select(a => new
|
|||
|
{
|
|||
|
key = a.Name,
|
|||
|
value = SqlFunc.Subqueryable<T_Service_Apoplexy_FollowUpBase>().Where(s => s.PatientGuid == a.GUID && s.NextTime > DateTime.Now).OrderBy(s => s.NextTime).Select(s => s.NextTime),
|
|||
|
}).ToList();
|
|||
|
|
|||
|
for (int i = 0; i < listMode.Count; i++)
|
|||
|
{
|
|||
|
KeyValue tempkeyvalue = new KeyValue();
|
|||
|
if (!string.IsNullOrEmpty(listMode[i].value + "")&& (listMode[i].value+"")!="0001/1/1 0:00:00")
|
|||
|
{
|
|||
|
var dValue = Convert.ToDateTime(listMode[i].value+"").Subtract(Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")));
|
|||
|
if (!string.IsNullOrEmpty(dValue.TotalDays + "") && int.Parse(dValue.TotalDays + "") >= 0 && int.Parse(dValue.TotalDays + "") <= 7)
|
|||
|
{
|
|||
|
tempkeyvalue.key = listMode[i].key;
|
|||
|
tempkeyvalue.value = dValue.TotalDays + "";
|
|||
|
t.Add(tempkeyvalue);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
return t;
|
|||
|
}
|
|||
|
/// <summary>
|
|||
|
/// 根据患者GUID查询界面数据
|
|||
|
/// </summary>
|
|||
|
/// <param name="patientGuid"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public T_Service_Apoplexy_FAHBase GetFAHBaseByPatientGuid(string patientGuid)
|
|||
|
{
|
|||
|
return db.Queryable<T_Service_Apoplexy_FAHBase>().Where(a => a.GUID == patientGuid && a.DeleteFlag == 0).First();
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 根据guid获取患者基础信息
|
|||
|
/// </summary>
|
|||
|
/// <param name="PatientGuid"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public TableModel<T_Service_Apoplexy_FAHBase> GetByPatientGuid1(string PatientGuid)
|
|||
|
{
|
|||
|
TableModel<T_Service_Apoplexy_FAHBase> t = new TableModel<T_Service_Apoplexy_FAHBase>();
|
|||
|
List<T_Service_Apoplexy_FAHBase> list = new List<T_Service_Apoplexy_FAHBase>();
|
|||
|
var listModel = db.Queryable<T_Service_Apoplexy_FAHBase>()
|
|||
|
.Where(a => a.ID > 0 && a.DeleteFlag == 0 && a.GUID == PatientGuid)
|
|||
|
.Select(a => new T_Service_Apoplexy_FAHBase
|
|||
|
{
|
|||
|
ID = a.ID,
|
|||
|
GUID = a.GUID,
|
|||
|
SystemModuleID = a.SystemModuleID,
|
|||
|
BedNum = a.BedNum,
|
|||
|
Name = a.Name,
|
|||
|
Sex = a.Sex,
|
|||
|
PatientNum = a.PatientNum,
|
|||
|
GroupDif = a.GroupDif,
|
|||
|
Age = a.Age,
|
|||
|
Height = a.Height,
|
|||
|
Weight = a.Weight,
|
|||
|
AdmissionDate = a.AdmissionDate,
|
|||
|
DischargeDate = a.DischargeDate,
|
|||
|
PatientPhone = a.PatientPhone,
|
|||
|
EmergencyContactPhone = a.EmergencyContactPhone,
|
|||
|
IDCard = a.IDCard,
|
|||
|
Address = a.Address,
|
|||
|
MaritalStatus = a.MaritalStatus,
|
|||
|
ComingWay = a.ComingWay,
|
|||
|
MedicalType = a.MedicalType,
|
|||
|
InhospitalWay = a.InhospitalWay,
|
|||
|
ChargeDoctor = a.ChargeDoctor,
|
|||
|
Treated = a.Treated,
|
|||
|
AdmissionDiagnosis = a.AdmissionDiagnosis,
|
|||
|
AdmissionDiagnosisOther = a.AdmissionDiagnosisOther,
|
|||
|
PatientComplaint = a.PatientComplaint,
|
|||
|
HospitalGuid = a.HospitalGuid,
|
|||
|
DeleteFlag = a.DeleteFlag,
|
|||
|
CreationDate = a.CreationDate,
|
|||
|
CreatorID = a.CreatorID
|
|||
|
}).ToList();
|
|||
|
list = listModel;
|
|||
|
t.Code = 0;
|
|||
|
t.PageCount = list.Count;
|
|||
|
t.TotalNumber = list.Count;
|
|||
|
t.Data = list;
|
|||
|
t.Msg = "成功";
|
|||
|
return t;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 获取未创建健康档案的卒中患者
|
|||
|
/// </summary>
|
|||
|
/// <param name="pageIndex"></param>
|
|||
|
/// <param name="pageSize"></param>
|
|||
|
/// <param name="hospitalGuid"></param>
|
|||
|
/// <param name="systemModuleID"></param>
|
|||
|
/// <param name="starttime"></param>
|
|||
|
/// <param name="endtime"></param>
|
|||
|
/// <param name="ageStart"></param>
|
|||
|
/// <param name="ageEnd"></param>
|
|||
|
/// <param name="name"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public TableModel<T_Service_Patient> GetApoplexyPageList(int pageIndex, int pageSize, string hospitalGuid,string Name)
|
|||
|
{
|
|||
|
int TotalNumber = 0;
|
|||
|
TableModel<T_Service_Patient> t = new TableModel<T_Service_Patient>();
|
|||
|
var listMode = db.Queryable<T_Service_Patient, T_Service_Apoplexy_FAHBase>((a, b) => new JoinQueryInfos(
|
|||
|
JoinType.Left, a.GUID == b.PatientGUID))
|
|||
|
.Where((a, b) => a.ID > 0 && a.DeleteFlag == 0 && a.SystemModuleID == 3 && a.HospitalGuid == hospitalGuid)// && b.PatientGUID == null
|
|||
|
.WhereIF(!string.IsNullOrEmpty(Name), (a, b) => a.Name.Contains(Name))
|
|||
|
.Select(a => new T_Service_Patient
|
|||
|
{
|
|||
|
Height = a.Height,
|
|||
|
Weight = a.Weight,
|
|||
|
MaritalStatus = a.MaritalStatus,
|
|||
|
ID = a.ID,
|
|||
|
Gender = a.Gender,
|
|||
|
HospitalizationTime = a.HospitalizationTime,
|
|||
|
Address = a.Address,
|
|||
|
EmergencyContactPhone = a.EmergencyContactPhone,
|
|||
|
MobilePhone = a.MobilePhone,
|
|||
|
GUID = a.GUID,
|
|||
|
Age = a.Age,
|
|||
|
acZLType = a.acZLType,
|
|||
|
AdmissionNumber = a.AdmissionNumber,
|
|||
|
Name = a.Name,
|
|||
|
IsGreenWay = a.IsGreenWay,
|
|||
|
CreationDate = a.CreationDate,
|
|||
|
}).OrderBy(a => new { a.CreationDate },OrderByType.Desc).ToPageList(pageIndex, pageSize, ref TotalNumber);
|
|||
|
t.Code = 0;
|
|||
|
t.PageCount = listMode.Count;
|
|||
|
t.TotalNumber = TotalNumber;
|
|||
|
t.Data = listMode;
|
|||
|
t.Msg = "成功";
|
|||
|
return t;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 省市县查询
|
|||
|
/// </summary>
|
|||
|
/// <param name="id"></param>
|
|||
|
/// <param name="guid"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public TableModel<T_Service_Apoplexy_FAHBase> GetProvince(string guid)
|
|||
|
{
|
|||
|
var oneClass = db.Queryable<T_Service_Apoplexy_FAHBase, T_Base_Province, T_Base_City, T_Base_County>((a, b, c, d) => new object[]{
|
|||
|
JoinType.Inner, a.Province == b.ProvinceName,
|
|||
|
JoinType.Inner, a.City == c.CityName,
|
|||
|
JoinType.Inner, a.Area == d.CountyName,
|
|||
|
})
|
|||
|
.Where((a, b, c, d) => a.SystemModuleID == "3" && a.GUID == guid && a.ID > 0 && b.ProvinceCode == c.ProvinceCode && c.CityCode == d.CityCode)
|
|||
|
.Select((a, b, c, d) => new T_Service_Apoplexy_FAHBase
|
|||
|
{
|
|||
|
Province = b.ProvinceCode,
|
|||
|
City = c.CityCode,
|
|||
|
Area = d.CountyCode,
|
|||
|
}).ToList();
|
|||
|
TableModel<T_Service_Apoplexy_FAHBase> t = new TableModel<T_Service_Apoplexy_FAHBase>();
|
|||
|
t.Code = 0;
|
|||
|
t.PageCount = oneClass.Count;
|
|||
|
t.TotalNumber = oneClass.Count;
|
|||
|
t.Data = oneClass;
|
|||
|
t.Msg = "成功";
|
|||
|
return t;
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 删除
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 逻辑删除
|
|||
|
/// </summary>
|
|||
|
/// <param name="patient"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public int DeleteFlag(T_Service_Apoplexy_FAHBase followuppatient)
|
|||
|
{
|
|||
|
return db.Updateable(followuppatient).UpdateColumns(it => new { it.DeleteFlag }).ExecuteCommand();
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|