248 lines
11 KiB
C#
248 lines
11 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;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace HL_FristAidPlatform_DataBase
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// 创伤患者质控
|
|||
|
/// </summary>
|
|||
|
public class T_Service_Trauma_QualityControlDB : BaseDB, IT_Service_Trauma_QualityControl
|
|||
|
{
|
|||
|
public SqlSugarClient db = GetClient();
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 获取创伤患者质控信息
|
|||
|
/// </summary>
|
|||
|
/// <param name="guid"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public QualityControlModel GetQualityControlByPatientGuid(string guid, long systemModelId)
|
|||
|
{
|
|||
|
QualityControlModel model = new QualityControlModel();
|
|||
|
model = db.Queryable<T_Service_Patient, T_Service_Trauma_BaseInfo, T_Service_Trauma_ReceiveInfo, T_Service_Trauma_Rescue, T_Service_Trauma_OutCome, T_Service_Trauma_FirstAidInfo, T_Service_PatientGCS, T_Service_Trauma_TIScore>((a, b, c, d, e, f, gcs, ti) =>
|
|||
|
new JoinQueryInfos(JoinType.Left, a.GUID == b.PatientGuid,
|
|||
|
JoinType.Left, a.GUID == c.PatientGuid,
|
|||
|
JoinType.Left, a.GUID == d.PatientGuid,
|
|||
|
JoinType.Left, a.GUID == e.PatientGuid,
|
|||
|
JoinType.Left, a.GUID == f.PatientGuid,
|
|||
|
JoinType.Left, a.GUID == gcs.PatientGUID,
|
|||
|
JoinType.Left, a.GUID == ti.PatientGuid))
|
|||
|
.Where((a, b, c, d, e, f, gcs, ti) => a.GUID == guid && a.SystemModuleID == systemModelId)
|
|||
|
.Select((a, b, c, d, e, f, gcs, ti) => new QualityControlModel()
|
|||
|
{
|
|||
|
PatientGuid = a.GUID,
|
|||
|
ComeHosptialWay = b.ComeHosptialWay,
|
|||
|
Name = a.Name,
|
|||
|
Age = a.Age,
|
|||
|
Gender = a.Gender,
|
|||
|
CallTraumaTeam = b.CallTraumaTeam,
|
|||
|
EarlyWarning = b.EarlyWarning,
|
|||
|
InpatientID = c.InpatientID,
|
|||
|
OutpatientID = c.OutpatientID,
|
|||
|
ReceiveDepartment = c.ReceiveDepartment,
|
|||
|
ArriveEmergencyTime = c.ArriveEmergencyTime,
|
|||
|
ArriveEmergencyDeath = c.ArriveEmergencyDeath,
|
|||
|
BloodTransfusion = d.BloodTransfusion,
|
|||
|
ArtificialAirway = d.ArtificialAirway,
|
|||
|
EmergencyOperation = d.EmergencyOperation,
|
|||
|
FastCT = d.FastCT,
|
|||
|
FastCTEndTime = d.FastCTEndTime,
|
|||
|
ChestX = d.ChestX,
|
|||
|
ChestXEndTime = d.ChestXEndTime,
|
|||
|
Pelvis = d.Pelvis,
|
|||
|
PelvisEndTime = d.PelvisEndTime,
|
|||
|
FAST = d.FAST,
|
|||
|
FASTEndTime = d.FASTEndTime,
|
|||
|
OtherX = d.OtherX,
|
|||
|
OtherXEndTime = d.OtherXEndTime,
|
|||
|
OtherXType = d.OtherXType,
|
|||
|
Whereabouts = e.Whereabouts,
|
|||
|
SituationRemarks = e.SituationRemarks,
|
|||
|
ResidenceTime = c.ResidenceTime,
|
|||
|
TreatmentOutcome = e.TreatmentOutcome,
|
|||
|
HandoverTime = e.HandoverTime,
|
|||
|
ReceivingHospital = e.ReceivingHospital,
|
|||
|
OutComeTime = e.OutComeTime,
|
|||
|
ExactWereabouts = e.ExactWereabouts,
|
|||
|
HospitalizationStartTime = c.HospitalizationStartTime,
|
|||
|
HospitalizationEndTime = c.HospitalizationEndTime,
|
|||
|
Death = c.Death,
|
|||
|
DeathTime = c.DeathTime,
|
|||
|
ArriveICU = c.ArriveICU,
|
|||
|
ObservationTime = c.ObservationTime,
|
|||
|
ObservationDead = c.ObservationDead,
|
|||
|
DataReporter = e.DataReporter,
|
|||
|
ArriveOutpatientTime = c.ArriveOutpatientTime,
|
|||
|
ArriveOutpatientDeath = c.ArriveOutpatientDeath,
|
|||
|
CompletionRate = e.CompletionRate,
|
|||
|
ApplyBloodTransfusionTime = d.ApplyBloodTransfusionTime,
|
|||
|
ImplementBloodTransfusionTime = d.ImplementBloodTransfusionTime,
|
|||
|
ProposeAirwayTime = d.ProposeAirwayTime,
|
|||
|
StartOperationTime = d.StartOperationTime,
|
|||
|
EmergencyLeaveTime = c.EmergencyLeaveTime,
|
|||
|
DeathDesc = e.DeathDesc,
|
|||
|
KeepInDesc = e.DeathDesc,
|
|||
|
ProposeOperationTime = d.ProposeOperationTime,
|
|||
|
SuccessAirwayTime = d.SuccessAirwayTime,
|
|||
|
TreatmentOtherContent = e.TreatmentOtherContent,
|
|||
|
LeaveScene = f.LeaveScene,
|
|||
|
HospitalizationDays = c.HospitalizationDays,
|
|||
|
GCSScore = gcs.TotalScore == 0 ? "" : gcs.TotalScore.ToString(),
|
|||
|
TIScore = ti.TISum,
|
|||
|
HospitalizationID = c.HospitalizationID,
|
|||
|
ArriveHospital = f.ArriveHospital
|
|||
|
}).First();
|
|||
|
if (model != null)
|
|||
|
{
|
|||
|
model.ICUList = new List<ICUListModel>();
|
|||
|
model.ICUList = db.Queryable<T_Service_Trauma_ICUList>().Where(i => i.PatientGuid == guid)
|
|||
|
.OrderBy(i => new { i.ArriveICUTime, i.LeaveICUTime, i.ICUDays }, OrderByType.Asc)
|
|||
|
.Select(i => new ICUListModel
|
|||
|
{
|
|||
|
ArriveICUTime = i.ArriveICUTime,
|
|||
|
LeaveICUTime = i.LeaveICUTime,
|
|||
|
ICUDays = i.ICUDays
|
|||
|
}).ToList();
|
|||
|
}
|
|||
|
var ISSClass = db.Queryable<T_Service_Trauma_ISSAIS>().Where(i => i.PatientGuid == guid).OrderBy(i => i.CreationDate, OrderByType.Desc).Take(1).First();
|
|||
|
if (ISSClass != null)
|
|||
|
{
|
|||
|
model.ISS_AISScore = ISSClass.ISS + "/" + ISSClass.AIS;
|
|||
|
model.Grave = ISSClass.Grave;
|
|||
|
}
|
|||
|
return model;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 创伤患者质控信息保存
|
|||
|
/// </summary>
|
|||
|
/// <param name="patient"></param>
|
|||
|
/// <param name="baseInfo"></param>
|
|||
|
/// <param name="receiveInfo"></param>
|
|||
|
/// <param name="rescue"></param>
|
|||
|
/// <param name="outCome"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public bool SaveQualityControl(T_Service_Patient patient, T_Service_Trauma_ReceiveInfo receiveInfo, T_Service_Trauma_Rescue rescue, T_Service_Trauma_OutCome outCome, List<T_Service_Trauma_ICUList> lst, T_Service_Trauma_FirstAidInfo first)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
db.Ado.BeginTran();
|
|||
|
db.Updateable(patient).UpdateColumns(it => new { it.Name, it.Age, it.Gender ,it.EmergencyState}).ExecuteCommand();
|
|||
|
|
|||
|
if (SqlFunc.IsNullOrEmpty(receiveInfo.GUID))
|
|||
|
{
|
|||
|
receiveInfo.GUID = Guid.NewGuid().ToString();
|
|||
|
db.Insertable(receiveInfo).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
db.Updateable(receiveInfo).UpdateColumns(it => new
|
|||
|
{
|
|||
|
it.OutpatientID,
|
|||
|
it.InpatientID,
|
|||
|
it.ReceiveDepartment,
|
|||
|
it.ArriveEmergencyTime,
|
|||
|
it.ArriveEmergencyDeath,
|
|||
|
it.DeathTime,
|
|||
|
it.HospitalizationStartTime,
|
|||
|
it.HospitalizationEndTime,
|
|||
|
it.Death,
|
|||
|
it.ArriveICU,
|
|||
|
it.ObservationTime,
|
|||
|
it.ObservationDead,
|
|||
|
it.ResidenceTime,
|
|||
|
it.EmergencyLeaveTime,
|
|||
|
it.ArriveOutpatientDeath,
|
|||
|
it.ArriveOutpatientTime,
|
|||
|
it.HospitalizationDays,
|
|||
|
it.HospitalizationID
|
|||
|
}).ExecuteCommand();
|
|||
|
}
|
|||
|
if (SqlFunc.IsNullOrEmpty(rescue.GUID))
|
|||
|
{
|
|||
|
rescue.GUID = Guid.NewGuid().ToString();
|
|||
|
db.Insertable(rescue).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
db.Updateable(rescue).UpdateColumns(it => new
|
|||
|
{
|
|||
|
it.FastCT,
|
|||
|
it.FastCTEndTime,
|
|||
|
it.ChestX,
|
|||
|
it.ChestXEndTime,
|
|||
|
it.Pelvis,
|
|||
|
it.PelvisEndTime,
|
|||
|
it.FAST,
|
|||
|
it.FASTEndTime,
|
|||
|
it.BloodTransfusion,
|
|||
|
it.ApplyBloodTransfusionTime,
|
|||
|
it.ImplementBloodTransfusionTime,
|
|||
|
it.ArtificialAirway,
|
|||
|
it.ProposeAirwayTime,
|
|||
|
it.SuccessAirwayTime,
|
|||
|
it.EmergencyOperation,
|
|||
|
it.ProposeOperationTime,
|
|||
|
it.StartOperationTime,
|
|||
|
it.OtherX,
|
|||
|
it.OtherXEndTime,
|
|||
|
it.OtherXType,
|
|||
|
it.BloodTransfusionInterval,
|
|||
|
it.ArtificialAirwayInterval,
|
|||
|
it.EmergencyOperationInterval,
|
|||
|
it.FastCTInterval,
|
|||
|
it.ChestXInterval,
|
|||
|
it.PelvisInterval,
|
|||
|
it.FASTInterval,
|
|||
|
it.OtherXInterval
|
|||
|
}).ExecuteCommand();
|
|||
|
}
|
|||
|
if (SqlFunc.IsNullOrEmpty(outCome.GUID))
|
|||
|
{
|
|||
|
outCome.GUID = Guid.NewGuid().ToString();
|
|||
|
db.Insertable(outCome).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
db.Updateable(outCome).UpdateColumns(it => new { it.Whereabouts, it.OutComeTime, it.HandoverTime, it.DataReporter, it.CompletionRate, it.SituationRemarks, it.TreatmentOutcome, it.TreatmentOtherContent, it.DeathDesc, it.KeepInDesc, it.ExactWereabouts, it.ReceivingHospital }).ExecuteCommand();
|
|||
|
}
|
|||
|
if (lst.Count > 0)
|
|||
|
{
|
|||
|
db.Deleteable<T_Service_Trauma_ICUList>().In(it => it.PatientGuid, patient.GUID).ExecuteCommand();
|
|||
|
for (int i = 0; i < lst.Count; i++)
|
|||
|
{
|
|||
|
db.Insertable(lst[i]).ExecuteCommand();
|
|||
|
}
|
|||
|
}
|
|||
|
if (SqlFunc.IsNullOrEmpty(first.GUID))
|
|||
|
{
|
|||
|
first.GUID = Guid.NewGuid().ToString();
|
|||
|
db.Insertable(first).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
db.Updateable(first).UpdateColumns(it => new { it.LeaveScene,it.ArriveHospital }).ExecuteCommand();
|
|||
|
}
|
|||
|
db.Ado.CommitTran();
|
|||
|
return true;
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
db.Ado.RollbackTran();
|
|||
|
Help.WriteErrorLog("创伤患者质控信息保存(SaveQualityControl)", ex.ToString());
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
}
|