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_PatientRTSDB : BaseDB, IT_Service_FirstAid_PatientRTS { public SqlSugarClient db = GetClient(); /// /// 新增GCS评分 /// /// /// public bool Add(T_Service_FirstAid_PatientRTS rts) { T_Service_FirstAid_PatientRTS model = new T_Service_FirstAid_PatientRTS(); model = db.Queryable().Where(i => i.PatientGUID == rts.PatientGUID && i.DeleteFlag == 0&&i.Flag==rts.Flag).First(); if (model == null) { return db.Insertable(rts).ExecuteCommand() == 1 ? true : false; } else { rts.GUID = model.GUID; rts.ID = model.ID; return db.Updateable(rts).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand()==1?true:false; } } /// /// 查看详情 /// /// /// public PatientRTSModel 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 PatientRTSModel() { GCS = a.GCS, SystolicPressureScore = a.SystolicPressureScore, BreathingScore = a.BreathingScore, TotalScore = a.TotalScore, RTSLevel = a.RTSLevel, ScoreTime = a.ScoreTime, CreateUser = b.FullName }).First(); } /// /// 根据患者标识,flag查看详情 /// /// /// /// public PatientRTSModel GetRTSByPaitentGuid(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 PatientRTSModel() { GCS = a.GCS, SystolicPressureScore = a.SystolicPressureScore, BreathingScore = a.BreathingScore, TotalScore = a.TotalScore, RTSLevel = a.RTSLevel, 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.RTSLevel, 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 GetPatientRTSList(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 FirstAid_PatientRTSListModel() { GCS = a.GCS, SystolicPressureScore = a.SystolicPressureScore, BreathingScore = a.BreathingScore, TotalScore = a.TotalScore, RTSLevel = a.RTSLevel, 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; } } }