StableVersion4.3/HL_FristAidPlatform_Bussiness/Service/T_Service_Apoplexy_FAHBaseB...

372 lines
16 KiB
C#

using HL_FristAidPlatform_DataBase;
using HL_FristAidPlatform_Help;
using HL_FristAidPlatform_IDataBase;
using HL_FristAidPlatform_IDataBase.Service;
using HL_FristAidPlatform_Models;
using HL_FristAidPlatform_Models.Sercice;
using System;
using System.Collections.Generic;
using System.Transactions;
namespace HL_FristAidPlatform_Bussiness
{
public class T_Service_Apoplexy_FAHBaseBLL
{
//健康档案相关
private IT_Service_Apoplexy_FAHBase IService = new T_Service_Apoplexy_FAHBaseDB();
private IT_Service_Apoplexy_FollowUpAndHealthInfo FService = new T_Service_Apoplexy_FollowUpAndHealthInfoDB();
//卒中系统相关
private IT_Service_Patient patientService = new T_Service_PatientDB();
private IT_Service_Apoplexy_Prehospital prehospitalService = new T_Service_Apoplexy_PrehospitalDB();
private IT_Service_Apoplexy_EmergencyRoom emergencyRoomService = new T_Service_Apoplexy_EmergencyRoomDB();
private IT_Service_Apoplexy_ZYYW zyywService = new T_Service_Apoplexy_ZYYWDB();
private IT_Service_Apoplexy_PatientOutcome outcomeService = new T_Service_Apoplexy_PatientOutcomeDB();
public TableModel<T_Service_Apoplexy_FAHBaseModel> GetPageList(int pageIndex, int pageSize, string hospitalGuid, string systemModuleID, string starttime, string endtime, string ageStart, string ageEnd,string name)
{
return IService.GetPageList(pageIndex, pageSize, hospitalGuid, systemModuleID, starttime, endtime, ageStart, ageEnd,name);
}
/// <summary>
/// 根据患者GUID查询界面数据
/// </summary>
/// <param name="patientGuid"></param>
/// <returns></returns>
public T_Service_Apoplexy_FAHBase GetFAHBaseByPatientGuid(string patientGuid)
{
return IService.GetFAHBaseByPatientGuid(patientGuid);
}
public List<KeyValue> GetPageList(string hospitalGuid)
{
return IService.GetPageList(hospitalGuid);
}
//新增
public T_Service_Apoplexy_FAHBase Add(T_Service_Apoplexy_FAHBase model)
{
return IService.Add(model);
}
//新增或者更新
public MessageModel<T_Service_Apoplexy_FAHBase> AddORUpdate(T_Service_Apoplexy_FAHBase model)
{
T_Service_Patient tsp = patientService.Get(model.PatientGUID);
T_Service_Apoplexy_Prehospital tsp1 = prehospitalService.GetByPatientGuid(model.PatientGUID);
T_Service_Apoplexy_EmergencyRoom tsp2 = emergencyRoomService.GetByPatientGuid1(model.PatientGUID);
T_Service_Apoplexy_ZYYW tsp3 = zyywService.GetOfPatientGuid(model.PatientGUID);
T_Service_Apoplexy_PatientOutcome tsp4 = outcomeService.GetByPatientGuid(model.PatientGUID);
if (!string.IsNullOrEmpty(model.PatientGUID+""))
{
model.Name = tsp.Name;
model.Sex = tsp.Gender + "";
model.Age = tsp.Age + "";
model.PatientNum = tsp.AdmissionNumber;
model.PatientPhone = tsp.MobilePhone;
model.EmergencyContactPhone = tsp.EmergencyContactPhone;
model.IDCard = tsp.IdentityCard;
model.Province = tsp.Province;
model.City = tsp.City;
model.Area = tsp.Area;
model.Address = tsp.Address;
model.MaritalStatus = tsp.MaritalStatus;
if (!string.IsNullOrEmpty(tsp.HospitalizationTime))
{
model.AdmissionDate = Convert.ToDateTime(tsp.HospitalizationTime);
}
//model.ComingWay = tsp.ComeHosptialWay;
model.Treated = tsp.acZLType;
//院前表
if (tsp1 != null)
{
model.PatientComplaint = tsp1.DiseaseRecord;
model.AdmissionDiagnosis = tsp1.PrimaryDiagnosis;
model.Height = tsp1.HEHeight + "";
model.Weight = tsp1.HEWeight + "";
model.ComingWay = tsp1.BCLyType;
model.InhospitalWay = tsp1.BCRyType;
}
//转归
if (tsp4 != null)
{
if(!string.IsNullOrEmpty(tsp4.CYTime+""))
model.DischargeDate = Convert.ToDateTime(tsp4.CYTime);
}
}
//先查询有没有该患者数据
T_Service_Apoplexy_FAHBase fahbase = new T_Service_Apoplexy_FAHBase();
fahbase = IService.GetByPatientGuid(model.GUID);
if (fahbase != null) //有执行修改操作
{
model.GUID = fahbase.GUID;
if (IService.Update(model) > 0)
{
return new MessageModel<T_Service_Apoplexy_FAHBase> { Success = true, Msg = "修改成功" };
}
else
{
return new MessageModel<T_Service_Apoplexy_FAHBase> { Success = false, Msg = "修改失败" };
}
}
else
{ //没有执行新增操作
if(string.IsNullOrEmpty(model.GUID))
model.GUID = Guid.NewGuid().ToString();
if (Add(model) != null)
{
T_Service_Apoplexy_FollowUpAndHealthInfo followUpAndHealthInfo= new T_Service_Apoplexy_FollowUpAndHealthInfo();
followUpAndHealthInfo.GUID = Guid.NewGuid().ToString();
followUpAndHealthInfo.PatientGuid = model.GUID;
followUpAndHealthInfo.DeleteFlag = 0;
if (!string.IsNullOrEmpty(model.PatientGUID + ""))
{
if (tsp1 != null)
{
followUpAndHealthInfo.Temperature = tsp1.Temperature;
followUpAndHealthInfo.SBP = tsp1.HESsy;
followUpAndHealthInfo.DBP = tsp1.HESzy;
followUpAndHealthInfo.Pulse = tsp1.HEBPulse;
followUpAndHealthInfo.Breathe = tsp1.Breathing + "";
}
//意识
//followUpAndHealthInfo.Consciousness = tsp1.Glasgow;
if (tsp2 != null)
{
if (tsp2.Hypertension == "是")
{
followUpAndHealthInfo.PastMedicalHistory = ";01;";
}
//Diabetes
if (tsp2.Diabetes == "是")
{
if (string.IsNullOrEmpty(followUpAndHealthInfo.PastMedicalHistory + ""))
{
followUpAndHealthInfo.PastMedicalHistory = ";02;";
}
else
{
followUpAndHealthInfo.PastMedicalHistory += "02;";
}
}
//Hyperlipidemia
if (tsp2.Hyperlipidemia == "是")
{
if (string.IsNullOrEmpty(followUpAndHealthInfo.PastMedicalHistory + ""))
{
followUpAndHealthInfo.PastMedicalHistory = ";04;";
}
else
{
followUpAndHealthInfo.PastMedicalHistory += "04;";
}
}
//HemorrhagicDisorders
if (tsp2.Hyperlipidemia == "是")
{
if (string.IsNullOrEmpty(followUpAndHealthInfo.PastMedicalHistory + ""))
{
followUpAndHealthInfo.PastMedicalHistory = ";05;";
}
else
{
followUpAndHealthInfo.PastMedicalHistory += "05;";
}
}
if (tsp2.Diagnose == "是")
{
if (string.IsNullOrEmpty(followUpAndHealthInfo.PastMedicalHistory + ""))
{
followUpAndHealthInfo.PastMedicalHistory = ";06;";
}
else
{
followUpAndHealthInfo.PastMedicalHistory += "06;";
}
}
//AtrialFibrillation 房颤
if (tsp2.AtrialFibrillation == "是")
{
if (string.IsNullOrEmpty(followUpAndHealthInfo.PastMedicalHistory + ""))
{
followUpAndHealthInfo.PastMedicalHistory = ";07;";
}
else
{
followUpAndHealthInfo.PastMedicalHistory += "07;";
}
}
}
if (tsp3 != null)
{
if (!string.IsNullOrEmpty(tsp3.YYKangNing) && int.Parse(tsp3.YYKangNing) == 1)
{
followUpAndHealthInfo.DrugUseIn = ";01;";
}
//YYJiangYa
if (!string.IsNullOrEmpty(tsp3.YYJiangYa) && int.Parse(tsp3.YYJiangYa) == 1)
{
if (string.IsNullOrEmpty(followUpAndHealthInfo.DrugUseIn + ""))
{
followUpAndHealthInfo.DrugUseIn = ";02;";
}
else
{
followUpAndHealthInfo.DrugUseIn += "02;";
}
}
//YYTiaoZhi
if (!string.IsNullOrEmpty(tsp3.YYTiaoZhi) && int.Parse(tsp3.YYTiaoZhi) == 1)
{
if (string.IsNullOrEmpty(followUpAndHealthInfo.DrugUseIn + ""))
{
followUpAndHealthInfo.DrugUseIn = ";03;";
}
else
{
followUpAndHealthInfo.DrugUseIn += "03;";
}
}
//YYJiangTang
if (!string.IsNullOrEmpty(tsp3.YYJiangTang) && int.Parse(tsp3.YYJiangTang) == 1)
{
if (string.IsNullOrEmpty(followUpAndHealthInfo.DrugUseIn + ""))
{
followUpAndHealthInfo.DrugUseIn = ";04;";
}
else
{
followUpAndHealthInfo.DrugUseIn += "04;";
}
}
}
//出院
if (tsp4 != null)
{
followUpAndHealthInfo.GCSScore2 = tsp4.ZWMPGCYGCS;
followUpAndHealthInfo.NIHSSScore2 = tsp4.CYNIHSS;
}
}
FService.Add(followUpAndHealthInfo);
return new MessageModel<T_Service_Apoplexy_FAHBase> { Success = true, Msg = "新增成功" + model.GUID };
}
else
{
return new MessageModel<T_Service_Apoplexy_FAHBase> { Success = false, Msg = "新增失败" };
}
}
}
//根据患者Guid查询
public T_Service_Apoplexy_FAHBase GetByPatientGuid(string PatientGuid)
{
return IService.GetByPatientGuid(PatientGuid);
}
public MessageModel<T_Service_Apoplexy_FAHBase> LogicDelete(T_Service_Apoplexy_FAHBase model)
{
//return IService.LogicDelete(model);
if (IService.LogicDelete(model) > 0)
{
return new MessageModel<T_Service_Apoplexy_FAHBase> { Success = true, Msg = "删除成功" };
}
else
{
return new MessageModel<T_Service_Apoplexy_FAHBase> { Success = false, Msg = "删除失败" };
}
}
//根据患者Guid获取tablemodel类型数据
public TableModel<T_Service_Apoplexy_FAHBase> GetByPatientGuid1( string PatientGuid)
{
return IService.GetByPatientGuid1(PatientGuid);
}
public MessageModel<bool> UpdateNotNullColumns(T_Service_Apoplexy_FAHBase model)
{
//先查询有没有该患者数据
T_Service_Apoplexy_FAHBase fahbase = new T_Service_Apoplexy_FAHBase();
fahbase = IService.GetByPatientGuid(model.GUID);
if (fahbase != null) //有执行修改操作
{
model.GUID = fahbase.GUID;
if (IService.Update(model) > 0)
{
return new MessageModel<bool> { Success = true, Msg = "修改成功" };
}
else
{
return new MessageModel<bool> { Success = false, Msg = "修改失败" };
}
}
else
{ //没有执行新增操作
if (string.IsNullOrEmpty(model.GUID + ""))
{
model.GUID = Guid.NewGuid().ToString();
}
if (Add(model) != null)
{
return new MessageModel<bool> { Success = true, Msg = "新增成功"};
}
else
{
return new MessageModel<bool> { Success = false, Msg = "新增失败" };
}
}
//if (IService.UpdateNotNullColumns(model) > 0)
//{
// return new MessageModel<bool> { Success = true, Msg = "修改成功" };
//}
//else
//{
// return new MessageModel<bool> { Success = false, Msg = "修改失败" };
//}
}
/// <summary>
/// 获取未创建健康档案的卒中患者列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="hospitalGuid"></param>
/// <returns></returns>
public TableModel<T_Service_Patient> GetApoplexyPageList(int pageIndex, int pageSize, string hospitalGuid, string Name)
{
return IService.GetApoplexyPageList(pageIndex, pageSize, hospitalGuid, Name);
}
/// <summary>
/// GUID获取患者地址Model类
/// </summary>
/// <param name="guid">GUID</param>
/// <returns></returns>
public TableModel<T_Service_Apoplexy_FAHBase> GetProvince(string guid)
{
return IService.GetProvince(guid);
}
}
}