126 lines
5.4 KiB
C#
126 lines
5.4 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_DownwardReferralDB : BaseDB, IT_Service_DownwardReferral
|
|
{
|
|
public SqlSugarClient db = GetClient();
|
|
|
|
/// <summary>
|
|
/// 胸痛患者转诊信息
|
|
/// </summary>
|
|
/// <param name="patientGuid"></param>
|
|
/// <param name="hospitalGuid"></param>
|
|
public ChestPatientReferralModel GetPatientReferralOfChest(string patientGuid)
|
|
{
|
|
ChestPatientReferralModel model = new ChestPatientReferralModel();
|
|
model = db.Queryable<T_Service_Patient, T_Service_ChestPain_FirstAIDInfo, T_Service_ChestPain_OutComeInfo, T_Service_DownwardReferral, 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.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") ,
|
|
IllnessExplain = d.IllnessExplain,
|
|
HospitalSummary = d.HospitalSummary,
|
|
TreatmentPlan = d.TreatmentPlan,
|
|
SendHospital = d.SendHospital != "" ? d.SendHospital: c.Hospital_Name ,
|
|
DesignatedHospital = d.DesignatedHospital,
|
|
PatientSignature = d.PatientSignature,
|
|
ReferringDoctorSignature = d.ReferringDoctorSignature,
|
|
LeaveHospital = e.Name,
|
|
}).First();
|
|
return model;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 创伤患者转诊信息
|
|
/// </summary>
|
|
/// <param name="patientGuid"></param>
|
|
/// <param name="hospitalGuid"></param>
|
|
public TraumaPatientReferralModel GetPatientReferralOfTrauma(string patientGuid)
|
|
{
|
|
TraumaPatientReferralModel model = new TraumaPatientReferralModel();
|
|
model = db.Queryable<T_Service_Patient, T_Service_Trauma_BaseInfo, T_Service_DownwardReferral, T_Base_Hospital,T_Service_Trauma_ReceiveInfo >
|
|
((a, b, c, d,e) => new JoinQueryInfos(
|
|
JoinType.Left, a.GUID == b.PatientGuid,
|
|
JoinType.Left, a.GUID == c.PatientGuid,
|
|
JoinType.Left, a.HospitalGuid == d.GUID,
|
|
JoinType.Left,a.GUID==e.PatientGuid))
|
|
.Where((a, b, c, d,e) => a.GUID == patientGuid && a.DeleteFlag == 0)
|
|
.Select((a, b, c, d,e) => new TraumaPatientReferralModel()
|
|
{
|
|
HospitalGuid = a.HospitalGuid,
|
|
PatientGuid = a.GUID,
|
|
Name = a.Name,
|
|
Gender = a.Gender,
|
|
Age = a.Age,
|
|
Phone = a.EmergencyContactPhone,
|
|
OutpatientID = e.OutpatientID,
|
|
MPDSType = b.MPDSType,
|
|
MPDSContent=b.MPDSContent,
|
|
LeaveTime = c.LeaveTime,
|
|
IllnessExplain = c.IllnessExplain,
|
|
HospitalSummary = c.HospitalSummary,
|
|
TreatmentPlan = c.TreatmentPlan,
|
|
SendHospital = c.SendHospital,
|
|
DesignatedHospital = c.DesignatedHospital,
|
|
PatientSignature = c.PatientSignature,
|
|
ReferringDoctorSignature = c.ReferringDoctorSignature,
|
|
LeaveHospital = d.Name,
|
|
}).First();
|
|
return model;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存下转转诊信息
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public bool SavePatientReferralInfo(T_Service_DownwardReferral model)
|
|
{
|
|
if (SqlFunc.IsNullOrEmpty(model.GUID))
|
|
{
|
|
model.GUID = Guid.NewGuid().ToString();
|
|
return db.Insertable(model).IgnoreColumns(ignoreNullColumn: true).ExecuteCommand() == 1 ? true : false;
|
|
}
|
|
else
|
|
{
|
|
return db.Updateable(model).IgnoreColumns(it => new { it.ID }).ExecuteCommand() == 1 ? true : false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="patientGuid"></param>
|
|
/// <returns></returns>
|
|
public T_Service_DownwardReferral GetInfoByGUID(string patientGuid)
|
|
{
|
|
return db.Queryable<T_Service_DownwardReferral>().Where(i => i.PatientGuid == patientGuid && i.DeleteFlag == 0).First();
|
|
}
|
|
}
|
|
}
|