using HL_FristAidPlatform_Help;
using HL_FristAidPlatform_IDataBase;
using HL_FristAidPlatform_Models;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
namespace HL_FristAidPlatform_DataBase
{
public class T_Service_FirstAid_PatientMEWSDB : BaseDB, IT_Service_FirstAid_PatientMEWS
{
public SqlSugarClient db = GetClient();
///
/// 新增MEWS评分
///
///
///
public bool Add(T_Service_FirstAid_PatientMEWS mews)
{
T_Service_FirstAid_PatientMEWS model = new T_Service_FirstAid_PatientMEWS();
model = db.Queryable().Where(i => i.PatientGUID == mews.PatientGUID && i.DeleteFlag == 0 && i.Flag == mews.Flag).First();
if (model == null)
{
return db.Insertable(mews).ExecuteCommand() == 1 ? true : false;
}
else
{
mews.GUID = model.GUID;
mews.ID = model.ID;
return db.Updateable(mews).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand() == 1 ? true : false;
}
}
///
/// 查看评分详情
///
///
///
public PatientMEWSModel Get(string guid)
{
return db.Queryable((a, b) => new JoinQueryInfos(JoinType.Inner, a.CreateUser == b.ID))
.Where((a, b) => a.GUID == guid)
.Select((a, b) => new PatientMEWSModel()
{
HeartRateScore = a.HeartRateScore,
SystolicPressureScore = a.SystolicPressureScore,
BreathingScore = a.BreathingScore,
TemperatureScore = a.TemperatureScore,
SonsciousScore = a.SonsciousScore,
TotalScore = a.TotalScore,
MEWSLevel = a.MEWSLevel,
ScoreTime = a.ScoreTime,
CreateUser = b.FullName
}).First();
}
///
/// 根据患者GUID,Flag 查看评分详情
///
///
///
public PatientMEWSModel GetMEWSByPatientGuid(string patientGuid, int flag)
{
return db.Queryable((a, b) => new JoinQueryInfos(JoinType.Inner, a.CreateUser == b.ID))
.Where((a, b) => a.PatientGUID == patientGuid && a.Flag == flag)
.Select((a, b) => new PatientMEWSModel()
{
HeartRateScore = a.HeartRateScore,
SystolicPressureScore = a.SystolicPressureScore,
BreathingScore = a.BreathingScore,
TemperatureScore = a.TemperatureScore,
SonsciousScore = a.SonsciousScore,
TotalScore = a.TotalScore,
MEWSLevel = a.MEWSLevel,
ScoreTime = a.ScoreTime,
CreateUser = b.FullName
}).First();
}
///
/// 查看所有评分列表
///
///
///
public TableModel GetList(string patientGuid)
{
List list = new List();
list = db.Queryable((a, b) => new JoinQueryInfos(JoinType.Inner, a.CreateUser == b.ID))
.Where((a, b) => a.PatientGUID == patientGuid && a.Flag == 0).OrderBy((a, b) => a.ScoreTime, OrderByType.Desc)
.Select((a, b) => new PatientScoreModel()
{
GUID = a.GUID,
Level = a.MEWSLevel,
TotalScore = a.TotalScore.ToString(),
ScoreTime = a.ScoreTime,
ScoreName = b.FullName
}).ToList();
TableModel t = new TableModel();
t.Code = 0;
t.PageCount = list.Count();
t.TotalNumber = list.Count();
t.Data = list;
t.Msg = "成功";
return t;
}
///
/// 查看所有评分列表
///
///
///
public TableModel GetPatientMEWSList(string patientGuid)
{
List list = new List();
list = db.Queryable((a, b) => new JoinQueryInfos(JoinType.Inner, a.CreateUser == b.ID))
.Where((a, b) => a.PatientGUID == patientGuid && a.Flag == 0).OrderBy((a, b) => a.ScoreTime, OrderByType.Desc)
.Select((a, b) => new PatientMEWSListModel()
{
HeartRateScore = a.HeartRateScore,
SystolicPressureScore = a.SystolicPressureScore,
BreathingScore = a.BreathingScore,
TemperatureScore = a.TemperatureScore,
SonsciousScore = a.SonsciousScore,
ScoreTime = a.ScoreTime,
CreateUser = b.FullName
}).ToList();
TableModel t = new TableModel();
t.Code = 0;
t.PageCount = list.Count();
t.TotalNumber = list.Count();
t.Data = list;
t.Msg = "成功";
return t;
}
}
}