586 lines
32 KiB
C#
586 lines
32 KiB
C#
using HL_FristAidPlatform_Help;
|
|
using HL_FristAidPlatform_Help.Model;
|
|
using HL_FristAidPlatform_IDataBase;
|
|
using HL_FristAidPlatform_Models;
|
|
using SqlSugar;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace HL_FristAidPlatform_DataBase
|
|
{
|
|
public class T_Service_Trauma_BaseInfoDB : BaseDB, IT_Service_Trauma_BaseInfo
|
|
{
|
|
public SqlSugarClient db = GetClient();
|
|
|
|
/// <summary>
|
|
/// 保存创伤患者
|
|
/// </summary>
|
|
/// <param name="patient"></param>
|
|
/// <param name="info"></param>
|
|
/// <returns></returns>
|
|
public bool SaveTraumaPatientInfo(T_Service_Patient patient, T_Service_Trauma_BaseInfo info)
|
|
{
|
|
try
|
|
{
|
|
db.Ado.BeginTran();
|
|
db.Insertable(patient).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand();
|
|
db.Insertable(info).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand();
|
|
if (info.ComeHosptialWay == "1" || info.ComeHosptialWay == "2")
|
|
{
|
|
T_Service_Trauma_FirstAidInfo firstAidInfo = new T_Service_Trauma_FirstAidInfo();
|
|
firstAidInfo.GUID = Guid.NewGuid().ToString();
|
|
firstAidInfo.PatientGuid = patient.GUID;
|
|
db.Insertable(firstAidInfo).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand();
|
|
T_Service_Trauma_Rescue rescue = new T_Service_Trauma_Rescue();
|
|
rescue.GUID = Guid.NewGuid().ToString();
|
|
rescue.PatientGuid = patient.GUID;
|
|
db.Insertable(rescue).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand();
|
|
}
|
|
if (info.ComeHosptialWay == "3" || info.ComeHosptialWay == "4" || info.ComeHosptialWay == "5")
|
|
{
|
|
T_Service_Trauma_Rescue rescue = new T_Service_Trauma_Rescue();
|
|
rescue.GUID = Guid.NewGuid().ToString();
|
|
rescue.PatientGuid = patient.GUID;
|
|
db.Insertable(rescue).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand();
|
|
|
|
T_Service_Trauma_ReceiveInfo receiveInfo = new T_Service_Trauma_ReceiveInfo();
|
|
receiveInfo.GUID = Guid.NewGuid().ToString();
|
|
receiveInfo.PatientGuid = patient.GUID;
|
|
db.Insertable(receiveInfo).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand();
|
|
}
|
|
db.Ado.CommitTran();
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Ado.RollbackTran();
|
|
Help.WriteErrorLog("保存创伤患者(SaveTraumaPatientInfo)", ex.ToString());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public bool SaveTraumaPatientInfoForTriage(T_Service_Trauma_BaseInfo info)
|
|
{
|
|
try
|
|
{
|
|
db.Ado.BeginTran();
|
|
db.Insertable(info).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand();
|
|
if (info.ComeHosptialWay == "1" || info.ComeHosptialWay == "2")
|
|
{
|
|
T_Service_Trauma_FirstAidInfo firstAidInfo = new T_Service_Trauma_FirstAidInfo();
|
|
firstAidInfo.GUID = Guid.NewGuid().ToString();
|
|
firstAidInfo.PatientGuid = info.PatientGuid;
|
|
db.Insertable(firstAidInfo).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand();
|
|
T_Service_Trauma_Rescue rescue = new T_Service_Trauma_Rescue();
|
|
rescue.GUID = Guid.NewGuid().ToString();
|
|
rescue.PatientGuid = info.PatientGuid;
|
|
db.Insertable(rescue).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand();
|
|
}
|
|
if (info.ComeHosptialWay == "3" || info.ComeHosptialWay == "4" || info.ComeHosptialWay == "5")
|
|
{
|
|
T_Service_Trauma_Rescue rescue = new T_Service_Trauma_Rescue();
|
|
rescue.GUID = Guid.NewGuid().ToString();
|
|
rescue.PatientGuid = info.PatientGuid;
|
|
db.Insertable(rescue).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand();
|
|
|
|
T_Service_Trauma_ReceiveInfo receiveInfo = new T_Service_Trauma_ReceiveInfo();
|
|
receiveInfo.GUID = Guid.NewGuid().ToString();
|
|
receiveInfo.PatientGuid = info.PatientGuid;
|
|
db.Insertable(receiveInfo).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand();
|
|
}
|
|
db.Ado.CommitTran();
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Ado.RollbackTran();
|
|
Help.WriteErrorLog("保存创伤患者(SaveTraumaPatientInfoForTriage)", ex.ToString());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 创伤患者列表
|
|
/// </summary>
|
|
/// <param name="hospitalGuid"></param>
|
|
/// <param name="name"></param>
|
|
/// <param name="gender"></param>
|
|
/// <param name="illness"></param>
|
|
/// <param name="startTime"></param>
|
|
/// <param name="endTime"></param>
|
|
/// <param name="pageIndex"></param>
|
|
/// <param name="pageSize"></param>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
public TableModel<TraumaPatientListModel> GetTraumaPatientList(string hospitalGuid, long systemId, string name, int gender, string illness, string startTime, string endTime, int pageIndex, int pageSize, string GreenWay, string eventID)
|
|
{
|
|
int totalNumber = 0;
|
|
TableModel<TraumaPatientListModel> t = new TableModel<TraumaPatientListModel>();
|
|
|
|
List<TraumaPatientListModel> list = new List<TraumaPatientListModel>();
|
|
list = db.Queryable<T_Service_Patient, T_Service_Trauma_BaseInfo, T_Base_AccidentInfo>
|
|
((a, b, c) => new JoinQueryInfos(JoinType.Left, a.GUID == b.PatientGuid, JoinType.Left, b.EventID == c.ID + ""))
|
|
.Where((a, b, c) => a.HospitalGuid == hospitalGuid && a.DeleteFlag == 0 && a.SystemModuleID == systemId)
|
|
.WhereIF(!SqlFunc.IsNullOrEmpty(name), (a, b, c) => a.Name.Contains(name))
|
|
.WhereIF(gender > -1, (a, b, c) => a.Gender == gender)
|
|
.WhereIF(!SqlFunc.IsNullOrEmpty(illness) && illness != "-1", (a, b, c) => b.IllnessLevel == illness)
|
|
.WhereIF(!SqlFunc.IsNullOrEmpty(startTime), (a, b, c) => a.CreationDate >= Convert.ToDateTime(startTime))
|
|
.WhereIF(!SqlFunc.IsNullOrEmpty(endTime), (a, b, c) => a.CreationDate <= Convert.ToDateTime(endTime).AddDays(1))
|
|
.WhereIF(!SqlFunc.IsNullOrEmpty(GreenWay), (a, b, c) => a.IsGreenWay == GreenWay)
|
|
.WhereIF(!SqlFunc.IsNullOrEmpty(eventID), (a, b, c) => b.EventID == eventID)
|
|
.OrderBy((a) => a.CreationDate, OrderByType.Desc)
|
|
.OrderBy((a) => a.ID, OrderByType.Asc)
|
|
.Select((a, b, c) => new TraumaPatientListModel
|
|
{
|
|
ID = a.ID,
|
|
GUID = a.GUID,
|
|
Name = a.Name,
|
|
Gender = a.Gender,
|
|
Age = a.Age,
|
|
CreationDate = a.CreationDate,
|
|
MPDS = b.MPDS,
|
|
MPDSContent = b.MPDSContent,
|
|
MPDSType = b.MPDSType,
|
|
IllnessLevel = b.IllnessLevel,
|
|
ComeHosptialWay = b.ComeHosptialWay,
|
|
ZXLYComeHosptialWay = b.ZXLYComeHosptialWay,
|
|
HosptialName = b.HosptialName,
|
|
FollowingDoctor = b.FollowingDoctor,
|
|
FollowingNurse = b.FollowingNurse,
|
|
IsGreenWay = a.IsGreenWay,
|
|
EventName = b.EventName,
|
|
EventIDName = c.ParentName,
|
|
EmergencyState = a.EmergencyState
|
|
}).ToPageList(pageIndex, pageSize, ref totalNumber);
|
|
|
|
t.Code = 0;
|
|
t.PageCount = list.Count;
|
|
t.TotalNumber = totalNumber;
|
|
t.Data = list;
|
|
t.Msg = "成功";
|
|
return t;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取创伤患者基本信息
|
|
/// </summary>
|
|
/// <param name="guid"></param>
|
|
/// <returns></returns>
|
|
public TraumaPatientIBasenfoModel GetTraumaPatientBaseInfo(string guid)
|
|
{
|
|
return db.Queryable<T_Service_Patient, T_Service_Trauma_BaseInfo, T_Service_Trauma_ReceiveInfo, T_Base_Province, T_Base_City, T_Base_County>
|
|
((a, b, c, e, f, g) => new JoinQueryInfos(
|
|
JoinType.Left, a.GUID == b.PatientGuid,
|
|
JoinType.Left, a.GUID == c.PatientGuid,
|
|
JoinType.Left, a.Province == e.ProvinceName,
|
|
JoinType.Left, a.City == f.CityName,
|
|
JoinType.Left, a.Area == g.CountyName))
|
|
.Where((a, b, c, e, f, g) => a.GUID == guid && a.DeleteFlag == 0)
|
|
.Select((a, b, c, e, f, g) => new TraumaPatientIBasenfoModel()
|
|
{
|
|
ID = a.ID,
|
|
GUID = a.GUID,
|
|
Name = a.Name,
|
|
Age = a.Age,
|
|
Gender = a.Gender,
|
|
Category = a.Category,
|
|
IdentityCard = a.IdentityCard,
|
|
EmergencyContact = a.EmergencyContact,
|
|
EmergencyContactPhone = a.EmergencyContactPhone,
|
|
Province = a.Province,
|
|
City = a.City,
|
|
Area = a.Area,
|
|
Address = a.Address,
|
|
IllnessLevel = b.IllnessLevel,
|
|
MPDSType = b.MPDSType,
|
|
MPDS = b.MPDS,
|
|
MPDSContent = b.MPDSContent,
|
|
ComeHosptialWay = b.ComeHosptialWay,
|
|
ZXLYComeHosptialWay = b.ZXLYComeHosptialWay,
|
|
HosptialName = b.HosptialName,
|
|
FollowingDoctor = b.FollowingDoctor,
|
|
FollowingNurse = b.FollowingNurse,
|
|
CardNumber = b.CardNumber,
|
|
CardType = b.CardType,
|
|
AttackAddress = b.AttackAddress,
|
|
ReceiveDepartment = c.ReceiveDepartment,
|
|
OutpatientID = c.OutpatientID,
|
|
AttendingDoctor = c.AttendingDoctor,
|
|
AttendingNurse = c.AttendingNurse,
|
|
//InpatientID = c.InpatientID,
|
|
OtherComeHosptialWay = b.OtherComeHosptialWay,
|
|
AmbulanceType = b.AmbulanceType,
|
|
ArriveEmergencyTime = c.ArriveEmergencyTime,
|
|
ArriveOutpatientTime = c.ArriveOutpatientTime,
|
|
CallTraumaTeam = b.CallTraumaTeam,
|
|
EarlyWarning = b.EarlyWarning,
|
|
ProvinceCode = SqlFunc.Subqueryable<T_Base_Province>().Where(s => s.ProvinceName == a.Province).Select(s => s.ProvinceCode),
|
|
CityCode = SqlFunc.Subqueryable<T_Base_City>().InnerJoin<T_Base_Province>((city, Province) => city.ProvinceCode == Province.ProvinceCode && Province.ProvinceName == a.Province && city.CityName == a.City).Select(city => city.CityCode),
|
|
AreaCode = SqlFunc.Subqueryable<T_Base_County>().InnerJoin<T_Base_City>((county, city) => county.CityCode == city.CityCode && city.CityName == a.City && county.CountyName == a.Area).Select(county => county.CountyCode),
|
|
Credentials_Type = a.Credentials_Type,
|
|
EventID = b.EventID,
|
|
EventName = b.EventName,
|
|
EmergencyState = a.EmergencyState
|
|
}).First();
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="guid"></param>
|
|
/// <returns></returns>
|
|
public T_Service_Trauma_BaseInfo GetPatientGUID(string guid)
|
|
{
|
|
return db.Queryable<T_Service_Trauma_BaseInfo>().Where(i => i.PatientGuid == guid).First();
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存创伤患者基本信息
|
|
/// </summary>
|
|
/// <param name="patient"></param>
|
|
/// <param name="info"></param>
|
|
/// <returns></returns>
|
|
public bool SaveTraumaPatientBaseInfo(T_Service_Patient patient, T_Service_Trauma_BaseInfo info, T_Service_Trauma_ReceiveInfo receiveInfo)
|
|
{
|
|
try
|
|
{
|
|
db.Ado.BeginTran();
|
|
db.Updateable(patient).UpdateColumns(it => new { it.Name, it.Age, it.Gender, it.Category, it.EmergencyContact, it.EmergencyContactPhone, it.Province, it.City, it.Area, it.Address, it.IdentityCard, it.Credentials_Type }).ExecuteCommand();
|
|
|
|
|
|
db.Updateable(info).UpdateColumns(it => new { it.ComeHosptialWay, it.FollowingDoctor, it.FollowingNurse, it.HosptialName, it.IllnessLevel, it.MPDS, it.MPDSType, it.OtherComeHosptialWay, it.CardNumber, it.CardType, it.AttackAddress, it.MPDSContent, it.AmbulanceType, it.ZXLYComeHosptialWay, it.EarlyWarning, it.CallTraumaTeam, it.EventID }).ExecuteCommand();
|
|
if (!SqlFunc.IsNullOrEmpty(receiveInfo.GUID))
|
|
{
|
|
db.Updateable(receiveInfo).UpdateColumns(it => new { it.ReceiveDepartment, it.AttendingDoctor, it.AttendingNurse, it.OutpatientID, it.ArriveEmergencyTime, it.ArriveOutpatientTime }).ExecuteCommand();
|
|
}
|
|
else
|
|
{
|
|
receiveInfo.GUID = Guid.NewGuid().ToString();
|
|
db.Insertable(receiveInfo).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand();
|
|
}
|
|
db.Ado.CommitTran();
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Ado.RollbackTran();
|
|
Help.WriteErrorLog("保存创伤患者基本信息(SaveTraumaPatientBaseInfo)", ex.ToString());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取未评分患者列表
|
|
/// </summary>
|
|
/// <param name="hospitalGuid"></param>
|
|
/// <param name="starTime"></param>
|
|
/// <param name="endTime"></param>
|
|
/// <param name="systemId"></param>
|
|
/// <param name="type">0 TI评分 1 GCS评分 2 ISS评分</param>
|
|
/// <param name="pageIndex"></param>
|
|
/// <param name="pageSize"></param>
|
|
/// <returns></returns>
|
|
public TableModel<UNGradStaisicsModel> GetUNGradStaisicsList(string hospitalGuid, string starTime, string endTime, long systemId, int type, int pageIndex, int pageSize)
|
|
{
|
|
if (!string.IsNullOrEmpty(starTime))
|
|
starTime = starTime + "-01";
|
|
if (!string.IsNullOrEmpty(endTime))
|
|
endTime = endTime + "-01";
|
|
int totalNumber = 0;
|
|
List<UNGradStaisicsModel> list = new List<UNGradStaisicsModel>();
|
|
if (type == 0)
|
|
{
|
|
list = db.Queryable<T_Service_Patient, T_Service_Trauma_BaseInfo, T_Service_Trauma_OutCome, T_Service_Trauma_TIScore>
|
|
((a, b, c, d) => new JoinQueryInfos(JoinType.Inner, a.GUID == b.PatientGuid,
|
|
JoinType.Inner, a.GUID == c.PatientGuid,
|
|
JoinType.Left, a.GUID == d.PatientGuid))
|
|
.Where((a, b, c, d) => a.HospitalGuid == hospitalGuid && a.SystemModuleID == systemId && a.DeleteFlag == 0)
|
|
.Where((a, b, c, d) => SqlFunc.IsNullOrEmpty(d.TISum))
|
|
.Where((a, b, c, d) => SqlFunc.IsNullOrEmpty(SqlFunc.Subqueryable<T_Service_Trauma_ISSAIS>().Where(s => s.PatientGuid == a.GUID).OrderByDesc(s => s.CreationDate).Select(s => s.AIS)))
|
|
.WhereIF(!SqlFunc.IsNullOrEmpty(starTime), (a, b, c, d) => a.CreationDate >= SqlFunc.ToDate(starTime))
|
|
.WhereIF(!SqlFunc.IsNullOrEmpty(endTime), (a, b, c, d) => a.CreationDate <= SqlFunc.ToDate(endTime).AddMonths(1))
|
|
.Select((a, b, c, d) => new UNGradStaisicsModel()
|
|
{
|
|
GUID = a.GUID,
|
|
Name = a.Name,
|
|
Age = a.Age,
|
|
Gender = a.Gender,
|
|
MPDSType = b.MPDSType,
|
|
ComeHosptialWay = b.ComeHosptialWay,
|
|
IllnessLevel = b.IllnessLevel,
|
|
Whereabouts = c.Whereabouts,
|
|
Grave = SqlFunc.Subqueryable<T_Service_Trauma_ISSAIS>().Where(s => s.PatientGuid == a.GUID).OrderByDesc(s => s.CreationDate).Select(s => s.Grave)
|
|
}).ToPageList(pageIndex, pageSize, ref totalNumber);
|
|
}
|
|
if (type == 1)
|
|
{
|
|
list = db.Queryable<T_Service_Patient, T_Service_Trauma_BaseInfo, T_Service_Trauma_OutCome, T_Service_PatientGCS>
|
|
((a, b, c, d) => new JoinQueryInfos(JoinType.Inner, a.GUID == b.PatientGuid,
|
|
JoinType.Inner, a.GUID == c.PatientGuid,
|
|
JoinType.Inner, a.GUID == d.PatientGUID))
|
|
.Where((a, b, c, d) => a.HospitalGuid == hospitalGuid && a.SystemModuleID == systemId && a.DeleteFlag == 0)
|
|
.Where((a, b, c, d) => SqlFunc.IsNullOrEmpty(d.TotalScore))
|
|
.Where((a, b, c, d) => SqlFunc.IsNullOrEmpty(SqlFunc.Subqueryable<T_Service_Trauma_ISSAIS>().Where(s => s.PatientGuid == a.GUID).OrderByDesc(s => s.CreationDate).Select(s => s.AIS)))
|
|
.WhereIF(!SqlFunc.IsNullOrEmpty(starTime), (a, b, c, d) => a.CreationDate >= SqlFunc.ToDate(starTime))
|
|
.WhereIF(!SqlFunc.IsNullOrEmpty(endTime), (a, b, c, d) => a.CreationDate <= SqlFunc.ToDate(endTime).AddMonths(1))
|
|
.Select((a, b, c, d) => new UNGradStaisicsModel()
|
|
{
|
|
GUID = a.GUID,
|
|
Name = a.Name,
|
|
Age = a.Age,
|
|
Gender = a.Gender,
|
|
MPDSType = b.MPDSType,
|
|
ComeHosptialWay = b.ComeHosptialWay,
|
|
IllnessLevel = b.IllnessLevel,
|
|
Whereabouts = c.Whereabouts,
|
|
Grave = SqlFunc.Subqueryable<T_Service_Trauma_ISSAIS>().Where(s => s.PatientGuid == a.GUID).OrderByDesc(s => s.CreationDate).Select(s => s.Grave)
|
|
}).ToPageList(pageIndex, pageSize, ref totalNumber);
|
|
}
|
|
if (type == 2)
|
|
{
|
|
list = db.Queryable<T_Service_Patient, T_Service_Trauma_BaseInfo, T_Service_Trauma_OutCome>
|
|
((a, b, c) => new JoinQueryInfos(JoinType.Inner, a.GUID == b.PatientGuid,
|
|
JoinType.Inner, a.GUID == c.PatientGuid))
|
|
.Where((a, b, c) => SqlFunc.IsNullOrEmpty(SqlFunc.Subqueryable<T_Service_Trauma_ISSAIS>().Where(s => s.PatientGuid == a.GUID).OrderByDesc(s => s.CreationDate).Select(s => s.AIS)))
|
|
.Where((a, b, c) => a.HospitalGuid == hospitalGuid && a.SystemModuleID == systemId && a.DeleteFlag == 0)
|
|
.WhereIF(!SqlFunc.IsNullOrEmpty(starTime), (a, b, c) => a.CreationDate >= SqlFunc.ToDate(starTime))
|
|
.WhereIF(!SqlFunc.IsNullOrEmpty(endTime), (a, b, c) => a.CreationDate <= SqlFunc.ToDate(endTime).AddMonths(1))
|
|
.Select((a, b, c) => new UNGradStaisicsModel()
|
|
{
|
|
GUID = a.GUID,
|
|
Name = a.Name,
|
|
Age = a.Age,
|
|
Gender = a.Gender,
|
|
MPDSType = b.MPDSType,
|
|
ComeHosptialWay = b.ComeHosptialWay,
|
|
IllnessLevel = b.IllnessLevel,
|
|
Whereabouts = c.Whereabouts,
|
|
Grave = SqlFunc.Subqueryable<T_Service_Trauma_ISSAIS>().Where(s => s.PatientGuid == a.GUID).OrderByDesc(s => s.CreationDate).Select(s => s.Grave)
|
|
}).ToPageList(pageIndex, pageSize, ref totalNumber);
|
|
}
|
|
|
|
TableModel<UNGradStaisicsModel> t = new TableModel<UNGradStaisicsModel>();
|
|
t.Code = 0;
|
|
t.PageCount = list.Count;
|
|
t.TotalNumber = totalNumber;
|
|
t.Data = list;
|
|
t.Msg = "成功";
|
|
return t;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 质控信息列表
|
|
/// </summary>
|
|
/// <param name="hospitalGuid"></param>
|
|
/// <param name="starTime"></param>
|
|
/// <param name="endTime"></param>
|
|
/// <param name="systemId"></param>
|
|
/// <param name="type">0 >=90 1 </param>
|
|
/// <returns></returns>
|
|
public TableModel<IntegrityStatisicsInfoModel> GetIntegrityStatisicsList(string hospitalGuid, string starTime, string endTime, long systemId, int type, int pageIndex, int pageSize)
|
|
{
|
|
int totalNumber = 0;
|
|
List<IntegrityStatisicsInfoModel> lst = new List<IntegrityStatisicsInfoModel>();
|
|
lst = db.Queryable<T_Service_Patient, T_Service_Trauma_OutCome>((a, b) => new JoinQueryInfos(JoinType.Left, a.GUID == b.PatientGuid))
|
|
.Where((a, b) => a.HospitalGuid == hospitalGuid && a.SystemModuleID == systemId && a.DeleteFlag == 0)
|
|
.WhereIF(!SqlFunc.IsNullOrEmpty(starTime), (a, b) => a.CreationDate >= SqlFunc.ToDate(starTime))
|
|
.WhereIF(!SqlFunc.IsNullOrEmpty(endTime), (a, b) => a.CreationDate <= SqlFunc.ToDate(endTime).AddDays(1))
|
|
.WhereIF(type == 0, (a, b) => SqlFunc.ToInt64(b.CompletionRate) >= 90)
|
|
.WhereIF(type == 1, (a, b) => SqlFunc.ToInt64(b.CompletionRate) >= 50 && SqlFunc.ToInt64(b.CompletionRate) < 90)
|
|
.WhereIF(type == 2, (a, b) => SqlFunc.ToInt64(b.CompletionRate) < 50 || SqlFunc.IsNullOrEmpty(b.CompletionRate))
|
|
.Select((a, b) => new IntegrityStatisicsInfoModel()
|
|
{
|
|
GUID = a.GUID,
|
|
Name = a.Name,
|
|
Gender = a.Gender,
|
|
Age = a.Age,
|
|
CompletionRate = b.CompletionRate,
|
|
DataReporter = b.DataReporter
|
|
}).ToPageList(pageIndex, pageSize, ref totalNumber);
|
|
|
|
TableModel<IntegrityStatisicsInfoModel> t = new TableModel<IntegrityStatisicsInfoModel>();
|
|
t.Code = 0;
|
|
t.PageCount = lst.Count;
|
|
t.TotalNumber = totalNumber;
|
|
t.Data = lst;
|
|
t.Msg = "成功";
|
|
return t;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 转诊信息列表
|
|
/// </summary>
|
|
/// <param name="hospitalGuid"></param>
|
|
/// <param name="starTime"></param>
|
|
/// <param name="endTime"></param>
|
|
/// <param name="systemId"></param>
|
|
/// <param name="type"></param>
|
|
/// <param name="pageIndex"></param>
|
|
/// <param name="pageSize"></param>
|
|
/// <returns></returns>
|
|
public TableModel<ReferralStatisicsInfoModel> GetReferralStatisicsList(string hospitalGuid, string starTime, string endTime, long systemId, int type, int pageIndex, int pageSize)
|
|
{
|
|
int totalNumber = 0;
|
|
List<ReferralStatisicsInfoModel> lst = new List<ReferralStatisicsInfoModel>();
|
|
lst = db.Queryable<T_Service_Patient, T_Service_Trauma_BaseInfo, T_Service_Trauma_OutCome>((a, b, c) => new JoinQueryInfos(JoinType.Left, a.GUID == b.PatientGuid, JoinType.Left, a.GUID == c.PatientGuid))
|
|
.Where((a, b, c) => a.HospitalGuid == hospitalGuid && a.SystemModuleID == systemId && a.DeleteFlag == 0)
|
|
.WhereIF(!SqlFunc.IsNullOrEmpty(starTime), (a, b, c) => a.CreationDate >= SqlFunc.ToDate(starTime))
|
|
.WhereIF(!SqlFunc.IsNullOrEmpty(endTime), (a, b, c) => a.CreationDate <= SqlFunc.ToDate(endTime).AddDays(1))
|
|
.WhereIF(type == 0, (a, b, c) => b.ComeHosptialWay == "2")
|
|
.WhereIF(type == 1, (a, b, c) => c.Whereabouts == "3")
|
|
.Select((a, b, c) => new ReferralStatisicsInfoModel()
|
|
{
|
|
GUID = a.GUID,
|
|
Name = a.Name,
|
|
Gender = a.Gender,
|
|
Age = a.Age,
|
|
CreationDate = SqlFunc.ToDate(a.CreationDate).ToString("yyyy-MM-dd HH:mm"),
|
|
MPDSType = b.MPDSType,
|
|
MPDSContent = b.MPDSContent
|
|
}).ToPageList(pageIndex, pageSize, ref totalNumber);
|
|
|
|
TableModel<ReferralStatisicsInfoModel> t = new TableModel<ReferralStatisicsInfoModel>();
|
|
t.Code = 0;
|
|
t.PageCount = lst.Count;
|
|
t.TotalNumber = totalNumber;
|
|
t.Data = lst;
|
|
t.Msg = "成功";
|
|
return t;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 门/急诊停留时间、输血准备时间列表查询
|
|
/// </summary>
|
|
/// <param name="hospitalGuid"></param>
|
|
/// <param name="starTime"></param>
|
|
/// <param name="endTime"></param>
|
|
/// <param name="systemId"></param>
|
|
/// <param name="type">0 停留时间 1 准备时间</param>
|
|
/// <param name="section">0 <=30min 1 >30min</param>
|
|
/// <param name="pageIndex"></param>
|
|
/// <param name="pageSize"></param>
|
|
/// <returns></returns>
|
|
public TableModel<ResidenceTimeModel> GetResidenceTimeList(string hospitalGuid, string starTime, string endTime, long systemId, int type, int section, int pageIndex, int pageSize)
|
|
{
|
|
DateTime dt = Convert.ToDateTime(starTime + "-01");
|
|
DateTime dt1 = Convert.ToDateTime(endTime + "-01").AddMonths(1);
|
|
int totalNumber = 0;
|
|
List<ResidenceTimeModel> lst = new List<ResidenceTimeModel>();
|
|
if (type == 0)
|
|
{
|
|
lst = db.Queryable<T_Service_Patient, T_Service_Trauma_ReceiveInfo, T_Service_Trauma_OutCome>((a, b, c) => new JoinQueryInfos(JoinType.Left, a.GUID == b.PatientGuid, JoinType.Left, a.GUID == c.PatientGuid))
|
|
.Where((a, b) => a.HospitalGuid == hospitalGuid && a.SystemModuleID == systemId && a.DeleteFlag == 0)
|
|
.WhereIF(!SqlFunc.IsNullOrEmpty(starTime), (a, b, c) => a.CreationDate >= dt)
|
|
.WhereIF(!SqlFunc.IsNullOrEmpty(endTime), (a, b, c) => a.CreationDate <= dt1)
|
|
.WhereIF(section == 0, (a, b, c) => SqlFunc.IsNullOrEmpty(b.ResidenceTime) || (!SqlFunc.IsNullOrEmpty(b.ResidenceTime) && SqlFunc.ToInt64(b.ResidenceTime) <= 30))
|
|
.WhereIF(section == 1, (a, b, c) => !SqlFunc.IsNullOrEmpty(b.ResidenceTime) && SqlFunc.ToInt64(b.ResidenceTime) > 30)
|
|
.OrderBy((a, b, c) => a.CreationDate, OrderByType.Desc)
|
|
.Select((a, b, c) => new ResidenceTimeModel()
|
|
{
|
|
GUID = a.GUID,
|
|
Name = a.Name,
|
|
Gender = a.Gender,
|
|
Age = a.Age,
|
|
CreationDate = SqlFunc.ToDate(a.CreationDate).ToString("yyyy-MM-dd HH:mm"),
|
|
TimeOne = b.ReceiveDepartment == "1" ? Convert.ToDateTime(b.ArriveEmergencyTime).ToString("yyyy-MM-dd HH:mm") : Convert.ToDateTime(b.ArriveOutpatientTime).ToString("yyyy-MM-dd HH:mm"),
|
|
TimeTwo = c.LeaveTime == null ? "" : SqlFunc.ToDate(c.LeaveTime).ToString("yyyy-MM-dd HH:mm"),
|
|
Interval = b.ResidenceTime
|
|
}).ToPageList(pageIndex, pageSize, ref totalNumber);
|
|
}
|
|
if (type == 1)
|
|
{
|
|
lst = db.Queryable<T_Service_Patient, T_Service_Trauma_Rescue>((a, b) => new JoinQueryInfos(JoinType.Left, a.GUID == b.PatientGuid))
|
|
.Where((a, b) => a.HospitalGuid == hospitalGuid && a.SystemModuleID == systemId && a.DeleteFlag == 0)
|
|
.WhereIF(!SqlFunc.IsNullOrEmpty(starTime), (a, b) => a.CreationDate >= dt)
|
|
.WhereIF(!SqlFunc.IsNullOrEmpty(endTime), (a, b) => a.CreationDate <= dt1)
|
|
.WhereIF(section == 0, (a, b) => SqlFunc.IsNullOrEmpty(b.BloodTransfusionInterval) || (!SqlFunc.IsNullOrEmpty(b.BloodTransfusionInterval) && SqlFunc.ToInt64(b.BloodTransfusionInterval) <= 30))
|
|
.WhereIF(section == 1, (a, b) => !SqlFunc.IsNullOrEmpty(b.BloodTransfusionInterval) && SqlFunc.ToInt64(b.BloodTransfusionInterval) > 30)
|
|
.OrderBy((a, b) => a.CreationDate, OrderByType.Desc)
|
|
.Select((a, b) => new ResidenceTimeModel()
|
|
{
|
|
GUID = a.GUID,
|
|
Name = a.Name,
|
|
Gender = a.Gender,
|
|
Age = a.Age,
|
|
CreationDate = SqlFunc.ToDate(a.CreationDate).ToString("yyyy-MM-dd HH:mm"),
|
|
TimeOne = b.ApplyBloodTransfusionTime,
|
|
TimeTwo = b.ImplementBloodTransfusionTime,
|
|
Interval = b.BloodTransfusionInterval
|
|
}).ToPageList(pageIndex, pageSize, ref totalNumber);
|
|
}
|
|
TableModel<ResidenceTimeModel> t = new TableModel<ResidenceTimeModel>();
|
|
t.Code = 0;
|
|
t.PageCount = lst.Count;
|
|
t.TotalNumber = totalNumber;
|
|
t.Data = lst;
|
|
t.Msg = "成功";
|
|
return t;
|
|
}
|
|
|
|
public int UpdateNotNullColumns(T_Service_Trauma_BaseInfo model)
|
|
{
|
|
return db.Updateable(model).Where(it => it.PatientGuid == model.PatientGuid).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
|
|
}
|
|
|
|
public bool SaveGroupInjury(GroupInjuryModel model)
|
|
{
|
|
try
|
|
{
|
|
db.Ado.BeginTran();
|
|
|
|
for (int i = 0; i < model.count; i++)
|
|
{
|
|
T_Service_Patient patient = new T_Service_Patient();
|
|
patient.GUID = Guid.NewGuid().ToString();
|
|
patient.Name = model.EventName + "_" + (i + 1) + "号患者";
|
|
patient.CreationDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
|
|
patient.RegisterTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
|
|
patient.CreatorID = model.CreatorID;
|
|
patient.SystemModuleID = long.Parse(model.SystemModuleID + "");
|
|
patient.HospitalGuid = model.HospitalGuid;
|
|
|
|
T_Service_Trauma_BaseInfo info = new T_Service_Trauma_BaseInfo();
|
|
info.GUID = Guid.NewGuid().ToString();
|
|
info.PatientGuid = patient.GUID;
|
|
info.CreationDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
|
|
info.AttackAddress = model.AttackAddress;
|
|
info.EventID = model.EventID;
|
|
info.EventName = model.EventName;
|
|
|
|
T_Service_Trauma_FirstAidInfo firstAidInfo = new T_Service_Trauma_FirstAidInfo();
|
|
firstAidInfo.GUID = Guid.NewGuid().ToString();
|
|
firstAidInfo.PatientGuid = patient.GUID;
|
|
|
|
T_Service_Trauma_Rescue rescue = new T_Service_Trauma_Rescue();
|
|
rescue.GUID = Guid.NewGuid().ToString();
|
|
rescue.PatientGuid = patient.GUID;
|
|
|
|
db.Insertable(patient).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand();
|
|
db.Insertable(info).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand();
|
|
|
|
db.Insertable(firstAidInfo).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand();
|
|
db.Insertable(rescue).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand();
|
|
|
|
}
|
|
db.Ado.CommitTran();
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Ado.RollbackTran();
|
|
Help.WriteErrorLog("批量创建创伤患者(SaveTraumaPatientInfo)", ex.ToString());
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|