155 lines
7.1 KiB
C#
155 lines
7.1 KiB
C#
|
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
|
|||
|
{
|
|||
|
public class T_Service_CriticalPregnant_BasicInfoDB : BaseDB, IT_Service_CriticalPregnant_BasicInfo
|
|||
|
{
|
|||
|
public SqlSugarClient db = GetClient();
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 根据患者GUID查询得到一个对象实体
|
|||
|
/// </summary>
|
|||
|
public T_Service_CriticalPregnant_BasicInfo GetByPatientGUID(string patientGUID)
|
|||
|
{
|
|||
|
return db.Queryable<T_Service_CriticalPregnant_BasicInfo>().Where(it => it.PatientGuid == patientGUID && it.DeleteFlag == 0).First();
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 增加一条数据
|
|||
|
/// </summary>
|
|||
|
/// <param name="model"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public T_Service_CriticalPregnant_BasicInfo AddBasicInfo(T_Service_CriticalPregnant_BasicInfo model)
|
|||
|
{
|
|||
|
return db.Insertable(model).ExecuteReturnEntity();
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 更新一条数据
|
|||
|
/// </summary>
|
|||
|
public int UpdateBasicInfo(T_Service_CriticalPregnant_BasicInfo model)
|
|||
|
{
|
|||
|
return db.Updateable(model).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 增加一条数据
|
|||
|
/// </summary>
|
|||
|
/// <param name="model"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public T_Service_CriticalPregnan_Time AddTime(T_Service_CriticalPregnan_Time model)
|
|||
|
{
|
|||
|
return db.Insertable(model).ExecuteReturnEntity();
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 更新一条数据
|
|||
|
/// </summary>
|
|||
|
public int UpdateTime(T_Service_CriticalPregnan_Time model)
|
|||
|
{
|
|||
|
return db.Updateable(model).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
|
|||
|
}
|
|||
|
|
|||
|
public T_Service_CriticalPregnan_Time GetTimeByPatientGUID(string patientGUID)
|
|||
|
{
|
|||
|
return db.Queryable<T_Service_CriticalPregnan_Time>().Where(it => it.PatientGuid == patientGUID && it.DeleteFlag == 0).First();
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 高危孕产妇患者列表
|
|||
|
/// </summary>
|
|||
|
/// <param name="startTime"></param>
|
|||
|
/// <param name="endTime"></param>
|
|||
|
/// <param name="name"></param>
|
|||
|
/// <param name="ageOne"></param>
|
|||
|
/// <param name="ageTwo"></param>
|
|||
|
/// <param name="comehospitalway"></param>
|
|||
|
/// <param name="grade"></param>
|
|||
|
/// <param name="state"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public TableModel<CriticalPregnantModel> GetCriticalPregnantsList(string hospitalGuid, long systemModelId, string startTime, string endTime, string name, int ageOne, int ageTwo, string comehospitalway, string grade, int state, int pageIndex, int pageSize)
|
|||
|
{
|
|||
|
int totalNumber = 0;
|
|||
|
TableModel<CriticalPregnantModel> t = new TableModel<CriticalPregnantModel>();
|
|||
|
List<CriticalPregnantModel> list = new List<CriticalPregnantModel>();
|
|||
|
list = db.Queryable<T_Service_Patient, T_Service_CriticalPregnant_BasicInfo,T_Service_CriticalPregnant_StandardScore>((a, b,c) => new JoinQueryInfos(JoinType.Left, a.GUID == b.PatientGuid,JoinType.Left,a.GUID==c.PatientGUID))
|
|||
|
.Where((a, b) => a.HospitalGuid == hospitalGuid && a.SystemModuleID == systemModelId && a.DeleteFlag == 0)
|
|||
|
.WhereIF(!SqlFunc.IsNullOrEmpty(startTime), (a, b,c) => a.CreationDate >= SqlFunc.ToDate(startTime))
|
|||
|
.WhereIF(!SqlFunc.IsNullOrEmpty(endTime), (a, b, c) => a.CreationDate <= SqlFunc.ToDate(endTime).AddDays(1))
|
|||
|
.WhereIF(!SqlFunc.IsNullOrEmpty(name), (a, b, c) => a.Name.Contains(name))
|
|||
|
.WhereIF(ageOne > 0, (a, b, c) => a.Age >= ageOne)
|
|||
|
.WhereIF(ageTwo > 0, (a, b, c) => a.Age <= ageTwo)
|
|||
|
.WhereIF(!SqlFunc.IsNullOrEmpty(comehospitalway), (a, b, c) => b.ComeHospitalWay == comehospitalway)
|
|||
|
.WhereIF(!SqlFunc.IsNullOrEmpty(grade), (a, b, c) => c.Grade ==int.Parse(grade))
|
|||
|
.WhereIF(state > -1, (a, b, c) => a.EmergencyState == state)
|
|||
|
.OrderBy((a, b, c) => a.CreationDate, OrderByType.Desc)
|
|||
|
.Select((a, b, c) => new CriticalPregnantModel()
|
|||
|
{
|
|||
|
GUID = a.GUID,
|
|||
|
Name = a.Name,
|
|||
|
Age = a.Age,
|
|||
|
EmergencyState = a.EmergencyState,
|
|||
|
CreationDate = a.CreationDate,
|
|||
|
ComeHospitalWay = b.ComeHospitalWay,
|
|||
|
Grade = SqlFunc.Subqueryable<T_Service_CriticalPregnant_StandardScore>().Where(s => s.PatientGUID == c.PatientGUID).Select(s => s.Grade),
|
|||
|
Attack_Time = b.Attack_Time,
|
|||
|
ABOBloodType = b.ABOBloodType,
|
|||
|
RhBloodType = b.RhBloodType,
|
|||
|
GestationalWeeks = b.GestationalWeeks,
|
|||
|
ExpectedDateOfConfinement = b.ExpectedDateOfConfinement
|
|||
|
}).ToPageList(pageIndex, pageSize, ref totalNumber);
|
|||
|
t.Code = 0;
|
|||
|
t.PageCount = list.Count;
|
|||
|
t.TotalNumber = totalNumber;
|
|||
|
t.Data = list;
|
|||
|
t.Msg = "成功";
|
|||
|
return t;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 获取病例个数统计
|
|||
|
/// </summary>
|
|||
|
/// <param name="hospitalGuid"></param>
|
|||
|
/// <param name="systemModelId"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public CaseDataModel GetCaseDataModel(string hospitalGuid, long systemModelId)
|
|||
|
{
|
|||
|
CaseDataModel model = new CaseDataModel();
|
|||
|
var oneClass = db.Queryable<T_Service_Patient>()
|
|||
|
.Where(i => i.HospitalGuid == hospitalGuid && i.SystemModuleID == systemModelId && i.DeleteFlag == 0)
|
|||
|
.Select(i => new { i.GUID, i.CreationDate })
|
|||
|
.ToList();
|
|||
|
if (oneClass != null)
|
|||
|
{
|
|||
|
DateTime dt = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"));
|
|||
|
model.ToDayCount = oneClass.Where(i => i.CreationDate >= dt && i.CreationDate <= dt.AddDays(1)).Count();
|
|||
|
|
|||
|
DateTime startQuarter = dt.AddMonths(0 - (dt.Month - 1) % 3).AddDays(1 - dt.Day);
|
|||
|
DateTime endQuarter = startQuarter.AddMonths(3).AddDays(-1);
|
|||
|
model.QuarterCount = oneClass.Where(i => i.CreationDate >= startQuarter && i.CreationDate <= endQuarter).Count();
|
|||
|
|
|||
|
DateTime startMonth = dt.AddDays(1 - dt.Day);
|
|||
|
DateTime endMonth = startMonth.AddMonths(1).AddDays(-1);
|
|||
|
model.MonthCount = oneClass.Where(i => i.CreationDate >= startMonth && i.CreationDate <= endMonth).Count();
|
|||
|
|
|||
|
DateTime startYear = new DateTime(dt.Year, 1, 1);
|
|||
|
DateTime endYear = new DateTime(dt.Year, 12, 31);
|
|||
|
model.YearCount = oneClass.Where(i => i.CreationDate >= startYear && i.CreationDate <= endYear).Count();
|
|||
|
model.TotalCount = oneClass.Count();
|
|||
|
|
|||
|
model.TotalCount = oneClass.Count();
|
|||
|
}
|
|||
|
|
|||
|
return model;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|