222 lines
8.7 KiB
C#
222 lines
8.7 KiB
C#
using HL_FristAidPlatform_Help;
|
|
using HL_FristAidPlatform_IDataBase.Service;
|
|
using HL_FristAidPlatform_Models;
|
|
using SqlSugar;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace HL_FristAidPlatform_DataBase
|
|
{
|
|
public class T_Service_Chest_UpwardReferralDB: BaseDB, IT_Service_Chest_UpwardReferral
|
|
{
|
|
public SqlSugarClient db = GetClient();
|
|
|
|
public T_Service_Chest_UpwardReferral Add(T_Service_Chest_UpwardReferral model)
|
|
{
|
|
T_Service_Patient patient = new T_Service_Patient();
|
|
patient.GUID = model.PatientGuid;
|
|
patient.IsForward = "1";
|
|
db.Updateable(patient).UpdateColumns(it => new { it.IsForward }).Where(it => it.GUID == patient.GUID).ExecuteCommand();
|
|
|
|
return db.Insertable(model).ExecuteReturnEntity();
|
|
}
|
|
|
|
public ChestPatientReferralModel GetByPatientGuid(string patientGuid, string hospitalGuid)
|
|
{
|
|
|
|
ChestPatientReferralModel model = new ChestPatientReferralModel();
|
|
model = db.Queryable<T_Service_Patient, T_Service_ChestPain_FirstAIDInfo, T_Service_ChestPain_OutComeInfo, T_Service_Chest_UpwardReferral, T_Base_Hospital>
|
|
((a, b, c, d, e) => new JoinQueryInfos(
|
|
JoinType.Left, a.GUID == b.PatientGuid,
|
|
JoinType.Left, a.GUID == c.PatientGuid,
|
|
JoinType.Left, a.GUID == d.PatientGuid,
|
|
JoinType.Left, a.HospitalGuid == e.GUID))
|
|
.Where((a, b, c, d, e) => a.GUID == patientGuid && a.HospitalGuid == hospitalGuid && a.DeleteFlag == 0)
|
|
.Select((a, b, c, d, e) => new ChestPatientReferralModel()
|
|
{
|
|
HospitalGuid = a.HospitalGuid,
|
|
PatientGuid = a.GUID,
|
|
Name = a.Name,
|
|
Gender = a.Gender,
|
|
Age = a.Age,
|
|
Phone = a.MobilePhone,
|
|
Inpatient_ID = b.Inpatient_ID,
|
|
Medical_Insurance_Type = b.Medical_Insurance_Type,
|
|
LeaveTime = d.LeaveTime != "" ? d.LeaveTime : SqlFunc.ToDate(c.Hand_Time).ToString("yyyy-MM-dd"),
|
|
LeaveHospital = d.TransferHospital != "" ? d.TransferHospital : e.Name,
|
|
IllnessExplain = d.IllnessExplain,
|
|
TransferNotice = d.TransferNotice,
|
|
ReceiveHospital = d.ReceiveHospital,
|
|
AppointHospital = d.AppointHospital,
|
|
PatientSignature = d.PatientSignature,
|
|
ReferringDoctorSignature = d.ReferringDoctorSignature,
|
|
TransferWay = d.TransferWay
|
|
}).First();
|
|
return model;
|
|
}
|
|
public T_Service_Chest_UpwardReferral GetByPatientGuid1(string PatientGuid)
|
|
{
|
|
return db.Queryable<T_Service_Chest_UpwardReferral>().Where(it => it.PatientGuid == PatientGuid && it.DeleteFlag == 0).First();
|
|
}
|
|
|
|
public string GetHospitalParentGUID(string receiveHospital)
|
|
{
|
|
return db.Queryable<T_Base_Hospital>().Where(it => it.Name== receiveHospital).Select(it => it.GUID).First();
|
|
}
|
|
|
|
public int Update(T_Service_Chest_UpwardReferral model)
|
|
{
|
|
return db.Updateable(model).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
|
|
}
|
|
/// <summary>
|
|
/// 以下用于上级医院新增数据
|
|
/// </summary>
|
|
/// <param name="guid"></param>
|
|
/// <returns></returns>
|
|
public T_Service_Patient Get(string guid)
|
|
{
|
|
return db.Queryable<T_Service_Patient>().Where(it => it.GUID == guid).First();
|
|
}
|
|
|
|
public T_Service_ChestPain_FirstAIDInfo GetModelOfPatient(string patientGUID)
|
|
{
|
|
return db.Queryable<T_Service_ChestPain_FirstAIDInfo>().First(it => it.PatientGuid == patientGUID);
|
|
}
|
|
|
|
public T_Service_ChestPain_TreatmentInfo GetTreatmentByPatientGUID(string patientGUID)
|
|
{
|
|
return db.Queryable<T_Service_ChestPain_TreatmentInfo>().First(it => it.PatientGuid == patientGUID);
|
|
}
|
|
|
|
public T_Service_ChestPain_OutComeInfo GetOutComeByPatientGUID(string patientGUID)
|
|
{
|
|
return db.Queryable<T_Service_ChestPain_OutComeInfo>().First(it => it.PatientGuid == patientGUID);
|
|
}
|
|
public List<T_Service_ChestPain_ECG> GetECGByPatientGUID(string patientGUID)
|
|
{
|
|
return db.Queryable<T_Service_ChestPain_ECG>().Where(it => it.PatientGuid == patientGUID && it.DeleteFlag == 0).ToList();
|
|
}
|
|
public List<T_Service_ChestPain_CTNT> GetCTNTByPatientGUID(string patientGUID)
|
|
{
|
|
return db.Queryable<T_Service_ChestPain_CTNT>().Where(it => it.PatientGuid == patientGUID && it.DeleteFlag == 0).ToList();
|
|
}
|
|
|
|
public string GetNetHospitalParentGUID(string hospitalname)
|
|
{
|
|
return db.Queryable<T_Base_Network_Hospital>().Where(it => it.HospitalName == hospitalname).Select(it => it.HospitalGuid).First();
|
|
}
|
|
|
|
public void InsertChestData(T_Service_Patient upwardPatient, T_Service_ChestPain_FirstAIDInfo upt_Service_ChestPain_FirstAIDInfo, T_Service_ChestPain_TreatmentInfo upt_Service_ChestPain_Treatment, T_Service_ChestPain_OutComeInfo upt_Service_ChestPain_OutCome, List<T_Service_ChestPain_ECG> uplistECG, List<T_Service_ChestPain_CTNT> uplistCTNT)
|
|
{
|
|
try
|
|
{
|
|
db.Ado.BeginTran();
|
|
|
|
if (SqlFunc.IsNullOrEmpty(upwardPatient.GUID))
|
|
{
|
|
upwardPatient.GUID = Guid.NewGuid().ToString();
|
|
db.Insertable(upwardPatient).IgnoreColumns(it => new { it.ID }).ExecuteCommand();
|
|
}
|
|
else
|
|
{
|
|
db.Insertable(upwardPatient).IgnoreColumns(it => new { it.ID }).ExecuteCommand();
|
|
}
|
|
|
|
if (SqlFunc.IsNullOrEmpty(upt_Service_ChestPain_FirstAIDInfo.GUID))
|
|
{
|
|
upt_Service_ChestPain_FirstAIDInfo.GUID = Guid.NewGuid().ToString();
|
|
db.Insertable(upt_Service_ChestPain_FirstAIDInfo).IgnoreColumns(it => new { it.ID }).ExecuteCommand();
|
|
}
|
|
else
|
|
{
|
|
db.Insertable(upt_Service_ChestPain_FirstAIDInfo).IgnoreColumns(it => new { it.ID }).ExecuteCommand();
|
|
}
|
|
|
|
if (SqlFunc.IsNullOrEmpty(upt_Service_ChestPain_Treatment.GUID))
|
|
{
|
|
upt_Service_ChestPain_Treatment.GUID = Guid.NewGuid().ToString();
|
|
db.Insertable(upt_Service_ChestPain_Treatment).IgnoreColumns(it => new { it.ID }).ExecuteCommand();
|
|
}
|
|
else
|
|
{
|
|
db.Insertable(upt_Service_ChestPain_Treatment).IgnoreColumns(it => new { it.ID }).ExecuteCommand();
|
|
}
|
|
|
|
if (SqlFunc.IsNullOrEmpty(upt_Service_ChestPain_OutCome.GUID))
|
|
{
|
|
upt_Service_ChestPain_OutCome.GUID = Guid.NewGuid().ToString();
|
|
db.Insertable(upt_Service_ChestPain_OutCome).IgnoreColumns(it => new { it.ID }).ExecuteCommand();
|
|
}
|
|
else
|
|
{
|
|
db.Insertable(upt_Service_ChestPain_OutCome).IgnoreColumns(it => new { it.ID }).ExecuteCommand();
|
|
}
|
|
|
|
for (int i = 0; i < uplistECG.Count; i++)
|
|
{
|
|
if (SqlFunc.IsNullOrEmpty(uplistECG[i].GUID))
|
|
{
|
|
uplistECG[i].GUID = Guid.NewGuid().ToString();
|
|
db.Insertable(uplistECG[i]).IgnoreColumns(it => new { it.ID }).ExecuteCommand();
|
|
}
|
|
else
|
|
{
|
|
db.Insertable(uplistECG[i]).IgnoreColumns(it => new { it.ID }).ExecuteCommand();
|
|
}
|
|
}
|
|
|
|
for (int i = 0; i < uplistCTNT.Count; i++)
|
|
{
|
|
if (SqlFunc.IsNullOrEmpty(uplistCTNT[i].GUID))
|
|
{
|
|
uplistCTNT[i].GUID = Guid.NewGuid().ToString();
|
|
db.Insertable(uplistCTNT[i]).IgnoreColumns(it => new { it.ID }).ExecuteCommand();
|
|
}
|
|
else
|
|
{
|
|
db.Insertable(uplistCTNT[i]).IgnoreColumns(it => new { it.ID }).ExecuteCommand();
|
|
}
|
|
}
|
|
|
|
db.Ado.CommitTran();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
db.Ado.RollbackTran();
|
|
Help.WriteErrorLog("上转数据报错日志:", ex.ToString());
|
|
|
|
throw;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
}
|