StableVersion4.3/HL_FristAidPlatform_DataBase/Service/T_Service_FirstAid_PatientG...

125 lines
4.3 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
{
/// <summary>
/// 院前患者GCS评分
/// </summary>
public class T_Service_FirstAid_PatientGCSDB:BaseDB, IT_Service_FirstAid_PatientGCS
{
public SqlSugarClient db = GetClient();
/// <summary>
/// 新增GCS评分
/// </summary>
/// <param name="phi"></param>
/// <returns></returns>
public bool Add(T_Service_PatientGCS cgs)
{
int i = db.Insertable(cgs).ExecuteCommand();
if (i > 0)
{
return true;
}
else
{
return false;
}
}
/// <summary>
/// 查看详情
/// </summary>
/// <param name="guid"></param>
/// <returns></returns>
public PatientGCSModel Get(string guid)
{
return db.Queryable<T_Service_PatientGCS,T_SYS_User>((a,b)=>new JoinQueryInfos(JoinType.Left,a.CreateUser==b.ID))
.Where((a, b) => a.GUID==guid)
.Select((a, b) => new PatientGCSModel()
{
EyesOpenScore=a.EyesOpenScore,
VerbalResponseScore=a.VerbalResponseScore,
LimbExerciseScore=a.LimbExerciseScore,
TotalScore=a.TotalScore,
GCSLevel=a.GCSLevel,
ScoreTime=a.ScoreTime,
CreateUser=b.FullName,
}).First();
}
/// <summary>
/// 查看所有评分列表
/// </summary>
/// <param name="patientGuid"></param>
/// <returns></returns>
public TableModel<PatientGCSListModel> GetPatientCGSList(string patientGuid)
{
List<PatientGCSListModel> list = new List<PatientGCSListModel>();
list = db.Queryable<T_Service_PatientGCS, T_SYS_User>((a, b) => new JoinQueryInfos(JoinType.Inner, a.CreateUser == b.ID))
.Where((a, b) => a.PatientGUID == patientGuid)
.OrderBy((a,b)=>a.ScoreTime,OrderByType.Desc)
.Select((a, b) => new PatientGCSListModel()
{
EyesOpenScore = a.EyesOpenScore,
VerbalResponseScore = a.VerbalResponseScore,
LimbExerciseScore=a.LimbExerciseScore,
TotalScore = a.TotalScore,
GCSLevel=a.GCSLevel,
ScoreTime = a.ScoreTime,
CreateUser = b.FullName
}).ToList();
TableModel<PatientGCSListModel> t = new TableModel<PatientGCSListModel>();
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<PatientScoreModel> GetList(string patientGuid)
{
List<PatientScoreModel> list = new List<PatientScoreModel>();
list = db.Queryable<T_Service_PatientGCS, T_SYS_User>((a, b) => new JoinQueryInfos(JoinType.Inner, a.CreateUser == b.ID))
.Where((a, b) => a.PatientGUID == patientGuid)
.OrderBy((a, b) => a.ScoreTime, OrderByType.Desc)
.Select((a, b) => new PatientScoreModel()
{
GUID = a.GUID,
Level = a.GCSLevel,
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;
}
public T_Service_PatientGCS GetPatientGCS(string guid, int flag)
{
return db.Queryable<T_Service_PatientGCS>().Where(i => i.PatientGUID == guid && i.Flag == flag).First();
}
}
}