StableVersion4.3/HL_FristAidPlatform_DataBase/Service/T_Service_FirstAid_PatientR...

136 lines
5.5 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;
using System.Linq;
namespace HL_FristAidPlatform_DataBase
{
public class T_Service_FirstAid_PatientRTSDB : BaseDB, IT_Service_FirstAid_PatientRTS
{
public SqlSugarClient db = GetClient();
/// <summary>
/// 新增GCS评分
/// </summary>
/// <param name="phi"></param>
/// <returns></returns>
public bool Add(T_Service_FirstAid_PatientRTS rts)
{
T_Service_FirstAid_PatientRTS model = new T_Service_FirstAid_PatientRTS();
model = db.Queryable<T_Service_FirstAid_PatientRTS>().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;
}
}
/// <summary>
/// 查看详情
/// </summary>
/// <param name="guid"></param>
/// <returns></returns>
public PatientRTSModel Get(string guid)
{
return db.Queryable<T_Service_FirstAid_PatientRTS, T_SYS_User>((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();
}
/// <summary>
/// 根据患者标识flag查看详情
/// </summary>
/// <param name="guid"></param>
/// <param name="flag"></param>
/// <returns></returns>
public PatientRTSModel GetRTSByPaitentGuid(string patientGuid,int flag)
{
return db.Queryable<T_Service_FirstAid_PatientRTS, 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 PatientRTSModel()
{
GCS = a.GCS,
SystolicPressureScore = a.SystolicPressureScore,
BreathingScore = a.BreathingScore,
TotalScore = a.TotalScore,
RTSLevel = a.RTSLevel,
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_PatientRTS, 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.RTSLevel,
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<FirstAid_PatientRTSListModel> GetPatientRTSList(string patientGuid)
{
List<FirstAid_PatientRTSListModel> list = new List<FirstAid_PatientRTSListModel>();
list = db.Queryable<T_Service_FirstAid_PatientRTS, 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 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<FirstAid_PatientRTSListModel> t = new TableModel<FirstAid_PatientRTSListModel>();
t.Code = 0;
t.PageCount = list.Count();
t.TotalNumber = list.Count();
t.Data = list;
t.Msg = "成功";
return t;
}
}
}