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
{
///
/// 院前患者PHI评分
///
public class T_Service_FirstAid_PatientPHIDB : BaseDB, IT_Service_FirstAid_PatientPHI
{
public SqlSugarClient db = GetClient();
///
/// 新增PHI评分
///
///
///
public bool Add(T_Service_FirstAid_PatientPHI phi)
{
T_Service_FirstAid_PatientPHI model = new T_Service_FirstAid_PatientPHI();
model = db.Queryable().Where(i => i.PatientGUID == phi.PatientGUID && i.DeleteFlag == 0&&i.Flag==phi.Flag).First();
if (model == null)
{
return db.Insertable(phi).ExecuteCommand() == 1 ? true : false;
}
else
{
phi.GUID = model.GUID;
phi.ID = model.ID;
return db.Updateable(phi).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand() == 1 ? true : false;
}
}
///
/// 查看详情
///
///
///
public PatientPHIModel 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 PatientPHIModel()
{
SystolicPressureScore = a.SystolicPressureScore,
PulseScore = a.PulseScore,
BreathingScore = a.BreathingScore,
SonsciousScore = a.SonsciousScore,
InjuryScore = a.InjuryScore,
TotalScore = a.TotalScore,
PHILevel = a.PHILevel,
ScoreTime = a.ScoreTime,
CreateUser = b.FullName
}).First();
}
///
/// 查看详情
///
///
///
public PatientPHIModel GetPHIByPatientGuid(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 PatientPHIModel()
{
SystolicPressureScore = a.SystolicPressureScore,
PulseScore = a.PulseScore,
BreathingScore = a.BreathingScore,
SonsciousScore = a.SonsciousScore,
InjuryScore = a.InjuryScore,
TotalScore = a.TotalScore,
PHILevel = a.PHILevel,
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.PHILevel,
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 GetPatientPHIList(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 PatientPHIListModel()
{
SystolicPressureScore = a.SystolicPressureScore,
PulseScore = a.PulseScore,
BreathingScore = a.BreathingScore,
SonsciousScore = a.SonsciousScore,
InjuryScore = a.InjuryScore,
TotalScore = a.TotalScore,
PHILevel = a.PHILevel,
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;
}
}
}