StableVersion4.3/HL_FristAidPlatform_DataBase/Service/T_Service_FirstAid_Apoplexy...

273 lines
13 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;
namespace HL_FristAidPlatform_DataBase
{
public class T_Service_FirstAid_ApoplexyHighRiskScreeningDB : BaseDB, IT_Service_FirstAid_ApoplexyHighRiskScreening
{
public SqlSugarClient db = GetClient();
/// <summary>
/// 增加一条数据
/// </summary>
public bool Add(T_Service_FirstAid_ApoplexyHighRiskScreening model)
{
return db.Insertable(model).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand() == 0 ? false : true;
}
public T_Service_ApoplexyScreenInfo GetByPhone(string phone)
{
DateTime dt1 = DateTime.Now.AddDays(1);
DateTime dt2 = dt1.AddYears(-1);
return db.Queryable<T_Service_ApoplexyScreenInfo>().Where(i => i.ContactNmber == phone && i.CreateTime >= dt2 && i.CreateTime <= dt1).First();
}
public T_Service_ApoplexyScreenInfo GetByIDCard(string idcard)
{
DateTime dt1 = DateTime.Now.AddDays(1);
DateTime dt2 = dt1.AddYears(-1);
return db.Queryable<T_Service_ApoplexyScreenInfo>().Where(i => i.IDCard == idcard && i.CreateTime >= dt2 && i.CreateTime <= dt1).First();
}
/// <summary>
/// 卒中高危人群列表查询
/// </summary>
/// <param name="name">姓名</param>
/// <param name="idCard">身份证</param>
/// <param name="highRisk">-1 全部 0不是高危人群 1是高危人群</param>
/// <param name="gender">-1 全部 0男 1女</param>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <returns></returns>
public TableModel<T_Service_FirstAid_ApoplexyHighRiskScreening> GetList(string hospitalGuid, string name, string idCard, int highRisk, int gender, string ShareUserName, string ShareUserDepartment, int pageIndex, int pageSize)
{
int total = 0;
var date = db.Queryable<T_Service_FirstAid_ApoplexyHighRiskScreening, T_Service_ApoplexyScreenInfo>((a, b) => new JoinQueryInfos(JoinType.Inner, b.GUID == a.PatientGUID))
.Where((a, b) => b.HospitalGUID == hospitalGuid)
.WhereIF(!SqlFunc.IsNullOrEmpty(name), (a, b) => b.Name.Contains(name))
.WhereIF(!SqlFunc.IsNullOrEmpty(idCard), (a, b) => b.IDCard.Contains(idCard))
.WhereIF(highRisk > -1, i => i.HighRisk == highRisk)
.WhereIF(gender > -1, (a, b) => b.Gender == gender)
.WhereIF(!SqlFunc.IsNullOrEmpty(ShareUserName), i => i.ShareUserName.Contains(ShareUserName))
.WhereIF(!SqlFunc.IsNullOrEmpty(ShareUserDepartment), i => i.ShareUserDepartment == ShareUserDepartment)
.OrderBy(i => i.CreateTime, OrderByType.Desc).ToPageList(pageIndex, pageSize, ref total);
TableModel<T_Service_FirstAid_ApoplexyHighRiskScreening> t = new TableModel<T_Service_FirstAid_ApoplexyHighRiskScreening>();
t.Code = 0;
t.PageCount = date.Count;
t.TotalNumber = total;
t.Data = date;
t.Msg = "成功";
return t;
}
/// <summary>
/// 卒中高危筛查月度统计
/// </summary>
/// <param name="hospitalGuid"></param>
/// <param name="userId"></param>
/// <param name="time1"></param>
/// <param name="time2"></param>
/// <returns></returns>
public List<ApoplexyHighRiskScreeningCensus> GetApoplexyHighRiskScreeningCensus(string hospitalGuid, long userId, string time1, string time2)
{
List<ApoplexyHighRiskScreeningCensus> list = new List<ApoplexyHighRiskScreeningCensus>();
return list;
}
public NotificationModel GetByPatientGuid(string GUID)
{
var model = db.Queryable<T_Service_ApoplexyScreenInfo, T_Service_FirstAid_ApoplexyHighRiskScreening>((a, b) => new JoinQueryInfos(JoinType.Inner, a.GUID == b.PatientGUID))
.Where((a, b) => a.GUID == GUID)
.OrderBy(a => a.CreateTime, OrderByType.Desc)
.Select((a, b) => new NotificationModel
{
PatientGUID = b.PatientGUID,
Name = a.Name,
Gender = a.Gender,
IDCard = a.IDCard,
ContactNmber = a.ContactNmber,
CAddress = a.CProvince + a.CCity + a.CArea + a.CAdress,
ParticipantSignature = b.ParticipantSignature,
ParticipantSignatureTime = b.ParticipantSignatureTime,
ProjectStaffSign = b.ProjectStaffSign,
ProjectStaffSignTime = b.ProjectStaffSignTime,
InformedConsentImg = b.InformedConsentImg,
FileAddress = b.FileAddress,
Hypertension = b.Hypertension,
BoolFat = b.BoolFat,
Diabetes = b.Diabetes,
HeartDisease = b.HeartDisease,
Smoke = b.Smoke,
AmountOfExercise = b.AmountOfExercise,
RelativeHistory = b.RelativeHistory,
Obese = b.Obese,
TIA = b.TIA,
Apoplexy = b.Apoplexy,
HighRisk = b.HighRisk,
Remarks = b.Remarks,
ShareUserID = b.ShareUserID,
ShareUserName = b.ShareUserName,
ShareUserDepartment = b.ShareUserDepartment,
CreateTime = b.CreateTime,
Height = b.Height,
Weight = b.Weight,
BMI = b.BMI,
InitialScreenNum = b.InitialScreenNum,
Source = b.Source,
Category = b.Category,
})
.First();
return model;
}
public TableModel<T_Service_FirstAid_ApoplexyHighRiskScreening> GetWorkloadStatistics(string startTime, string endTime)
{
var date = db.Queryable<T_Service_FirstAid_ApoplexyHighRiskScreening>().IgnoreColumns(i => new { i.FileAddress, i.InformedConsentImg, i.ProjectStaffSign, i.ParticipantSignature }).Where(it => SqlFunc.Between(it.CreateTime, startTime, endTime)).ToList();
TableModel<T_Service_FirstAid_ApoplexyHighRiskScreening> t = new TableModel<T_Service_FirstAid_ApoplexyHighRiskScreening>();
t.Code = 0;
t.PageCount = date.Count;
t.TotalNumber = date.Count;
t.Data = date;
t.Msg = "成功";
return t;
}
public bool Update(T_Service_FirstAid_ApoplexyHighRiskScreening model)
{
return db.Updateable(model).IgnoreColumns(ignoreAllNullColumns: true).Where(it => it.PatientGUID == model.PatientGUID).ExecuteCommand() == 0 ? false : true;
}
/// <summary>
/// 修改知情同意书接口
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool UpdateNotification(T_Service_FirstAid_ApoplexyHighRiskScreening model)
{
return db.Updateable(model).UpdateColumns(it => new { it.FileAddress, it.InformedConsentImg, it.ParticipantSignature, it.ParticipantSignatureTime, it.ProjectStaffSign, it.ProjectStaffSignTime }).Where(it => it.PatientGUID == model.PatientGUID).ExecuteCommand() == 0 ? false : true;
}
/// <summary>
/// PrintDataApoplexyHighRiskScreeningModel 打印卒中筛查表接口 ----新
/// </summary>
/// <param name="GUID"></param>
/// <returns></returns>
public PrintDataApoplexyHighRiskScreeningModel GetPrintDataByPatientGuid(string GUID)
{
var model = db.Queryable<T_Service_ApoplexyScreenInfo, T_Service_ApoplexyScreenPhysicalFitness, T_Service_FirstAid_ApoplexyHighRiskScreening>((a, b, c) => new JoinQueryInfos(JoinType.Inner, a.GUID == b.PatientGUID, JoinType.Inner, a.GUID == c.PatientGUID))
.Where((a, b, c) => a.GUID == GUID && b.Flag == "1")
.OrderBy(a => a.CreateTime, OrderByType.Desc)
.Select((a, b, c) => new PrintDataApoplexyHighRiskScreeningModel
{
Name = a.Name,
Age = a.Age,
Gender = a.Gender,
IDCard = a.IDCard,
Phone = a.ContactNmber,
CreateTime = a.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"),
Height = b.Height,
Weight = b.Weight,
BMI = b.BMI,
Hypertension = c.Hypertension,
BoolFat = c.BoolFat,
Diabetes = c.Diabetes,
HeartDisease = c.HeartDisease,
Smoke = c.Smoke,
AmountOfExercise = c.AmountOfExercise,
RelativeHistory = c.RelativeHistory,
Obese = c.Obese,
TIA = c.TIA,
Apoplexy = c.Apoplexy,
HighRisk = c.HighRisk,
Remarks = c.Remarks,
}).First();
return model;
}
/// <summary>
/// 根据患者GUID查询数据
/// </summary>
/// <param name="patientGuid"></param>
/// <returns></returns>
public T_Service_FirstAid_ApoplexyHighRiskScreening GetApoplexyHighRiskScreeningByPatientGuid(string patientGuid)
{
return db.Queryable<T_Service_FirstAid_ApoplexyHighRiskScreening>().Where(it => it.PatientGUID == patientGuid).First();
}
//T_Service_FirstAid_ApoplexyInitialScreeningModel
/// <summary>
/// 查询初筛表内容
/// </summary>
/// <param name="patientGuid"></param>
/// <returns></returns>
public T_Service_FirstAid_ApoplexyInitialScreeningModel GetApoplexyInitialScreeningByPatientGuid(string patientGuid)
{
return db.Queryable<T_Service_FirstAid_ApoplexyHighRiskScreening>()
.Where(it => it.PatientGUID == patientGuid)
.Select(it => new T_Service_FirstAid_ApoplexyInitialScreeningModel
{
GUID = it.GUID,
PatientGUID = it.PatientGUID,
Hypertension = it.Hypertension,
BoolFat = it.BoolFat,
Diabetes = it.Diabetes,
HeartDisease = it.HeartDisease,
Smoke = it.Smoke,
AmountOfExercise = it.AmountOfExercise,
RelativeHistory = it.RelativeHistory,
Obese = it.Obese,
TIA = it.TIA,
Apoplexy = it.Apoplexy,
HighRisk = it.HighRisk,
Remarks = it.Remarks,
ShareUserID = it.ShareUserID,
ShareUserName = it.ShareUserName,
ShareUserDepartment = it.ShareUserDepartment,
CreateTime = it.CreateTime,
Height = it.Height,
Weight = it.Weight,
BMI = it.BMI,
InitialScreenNum = it.InitialScreenNum,
Source = it.Source,
Category = it.Category
}).First();
}
public T_Service_FirstAid_ApoplexyHighRiskScreeningBaseInfo GetBaseByPatientGuid(string GUID)
{
return db.Queryable<T_Service_ApoplexyScreenInfo, T_Service_FirstAid_ApoplexyHighRiskScreening>((a, b) => new JoinQueryInfos(JoinType.Inner, a.GUID == b.PatientGUID))
.Where((a, b) => a.GUID == GUID)
.Select((a, b) => new T_Service_FirstAid_ApoplexyHighRiskScreeningBaseInfo
{
Name = a.Name,
Gender = a.Gender,
Age = a.Age,
ContactNmber = a.ContactNmber,
IDCard = a.IDCard,
HighRisk = b.HighRisk,
Remarks = b.Remarks,
Height = b.Height,
Weight = b.Weight,
BMI = b.BMI,
InitialScreenNum = b.InitialScreenNum,
Source = b.Source,
Category = b.Category,
ShareUserID = b.ShareUserID,
ShareUserName = b.ShareUserName,
ShareUserDepartment = b.ShareUserDepartment,
CreateTime = a.CreateTime,
}).First();
}
}
}