StableVersion4.3/HL_FristAidPlatform_DataBase/Service/T_Service_FirstAid_PatientP...

147 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
{
/// <summary>
/// 院前患者PHI评分
/// </summary>
public class T_Service_FirstAid_PatientPHIDB : BaseDB, IT_Service_FirstAid_PatientPHI
{
public SqlSugarClient db = GetClient();
/// <summary>
/// 新增PHI评分
/// </summary>
/// <param name="phi"></param>
/// <returns></returns>
public bool Add(T_Service_FirstAid_PatientPHI phi)
{
T_Service_FirstAid_PatientPHI model = new T_Service_FirstAid_PatientPHI();
model = db.Queryable<T_Service_FirstAid_PatientPHI>().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;
}
}
/// <summary>
/// 查看详情
/// </summary>
/// <param name="guid"></param>
/// <returns></returns>
public PatientPHIModel Get(string guid)
{
return db.Queryable<T_Service_FirstAid_PatientPHI, T_SYS_User>((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();
}
/// <summary>
/// 查看详情
/// </summary>
/// <param name="guid"></param>
/// <returns></returns>
public PatientPHIModel GetPHIByPatientGuid(string patientGuid, int flag)
{
return db.Queryable<T_Service_FirstAid_PatientPHI, 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 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();
}
/// <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_PatientPHI, 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.PHILevel,
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<PatientPHIListModel> GetPatientPHIList(string patientGuid)
{
List<PatientPHIListModel> list = new List<PatientPHIListModel>();
list = db.Queryable<T_Service_FirstAid_PatientPHI, 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 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<PatientPHIListModel> t = new TableModel<PatientPHIListModel>();
t.Code = 0;
t.PageCount = list.Count();
t.TotalNumber = list.Count();
t.Data = list;
t.Msg = "成功";
return t;
}
}
}