140 lines
5.8 KiB
C#
140 lines
5.8 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;
|
|||
|
|
|||
|
namespace HL_FristAidPlatform_DataBase
|
|||
|
{
|
|||
|
public class T_Service_FirstAid_PatientMEWSDB : BaseDB, IT_Service_FirstAid_PatientMEWS
|
|||
|
{
|
|||
|
public SqlSugarClient db = GetClient();
|
|||
|
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 新增MEWS评分
|
|||
|
/// </summary>
|
|||
|
/// <param name="phi"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public bool Add(T_Service_FirstAid_PatientMEWS mews)
|
|||
|
{
|
|||
|
T_Service_FirstAid_PatientMEWS model = new T_Service_FirstAid_PatientMEWS();
|
|||
|
model = db.Queryable<T_Service_FirstAid_PatientMEWS>().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;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 查看评分详情
|
|||
|
/// </summary>
|
|||
|
/// <param name="patientGuid"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public PatientMEWSModel Get(string guid)
|
|||
|
{
|
|||
|
return db.Queryable<T_Service_FirstAid_PatientMEWS, T_SYS_User>((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();
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 根据患者GUID,Flag 查看评分详情
|
|||
|
/// </summary>
|
|||
|
/// <param name="patientGuid"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public PatientMEWSModel GetMEWSByPatientGuid(string patientGuid, int flag)
|
|||
|
{
|
|||
|
return db.Queryable<T_Service_FirstAid_PatientMEWS, T_SYS_User>((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();
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 查看所有评分列表
|
|||
|
/// </summary>
|
|||
|
/// <param name="patientGuid"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public TableModel<PatientScoreModel> GetList(string patientGuid)
|
|||
|
{
|
|||
|
List<PatientScoreModel> list = new List<PatientScoreModel>();
|
|||
|
list = db.Queryable<T_Service_FirstAid_PatientMEWS, T_SYS_User>((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<PatientScoreModel> t = new TableModel<PatientScoreModel>();
|
|||
|
t.Code = 0;
|
|||
|
t.PageCount = list.Count();
|
|||
|
t.TotalNumber = list.Count();
|
|||
|
t.Data = list;
|
|||
|
t.Msg = "成功";
|
|||
|
return t;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 查看所有评分列表
|
|||
|
/// </summary>
|
|||
|
/// <param name="patientGuid"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public TableModel<PatientMEWSListModel> GetPatientMEWSList(string patientGuid)
|
|||
|
{
|
|||
|
List<PatientMEWSListModel> list = new List<PatientMEWSListModel>();
|
|||
|
list = db.Queryable<T_Service_FirstAid_PatientMEWS, T_SYS_User>((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<PatientMEWSListModel> t = new TableModel<PatientMEWSListModel>();
|
|||
|
t.Code = 0;
|
|||
|
t.PageCount = list.Count();
|
|||
|
t.TotalNumber = list.Count();
|
|||
|
t.Data = list;
|
|||
|
t.Msg = "成功";
|
|||
|
return t;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|