using HL_FristAidPlatform_DataBase; 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_Bussiness { public class T_Service_CriticalPregnant_BasicInfoBLL { private IT_Service_CriticalPregnant_BasicInfo IService = new T_Service_CriticalPregnant_BasicInfoDB(); private IT_Service_Patient patientService = new T_Service_PatientDB(); IT_Base_Config IConfig = new T_Base_ConfigDB(); /// /// 新增或修改 /// /// /// public MessageModel AddORUpdateBasicInfo(Patient_CriticalPregnant model) { //先查询有没有该患者数据 T_Service_CriticalPregnant_BasicInfo BasicInfo = new T_Service_CriticalPregnant_BasicInfo(); T_Service_Patient patient = new T_Service_Patient(); T_Service_CriticalPregnan_Time Time = new T_Service_CriticalPregnan_Time(); //patient.GUID = model.GUID; patient.Name = model.Name; patient.Age = model.Age; patient.Category = model.Category; patient.Gender = model.Gender; patient.Birthday = model.Birthday; patient.Credentials_Type = model.Credentials_Type; patient.HospitalGuid = model.HospitalGuid; patient.SystemModuleID = model.SystemModuleID; patient.Editor = model.Editor; patient.EditorID = model.EditorID; //patient.EditTime = model.EditTime; patient.CreatorID = model.CreatorID; patient.Creator = model.Creator; patient.IdentityCard = model.IdentityCard; patient.MobilePhone = model.MobilePhone; patient.WristStrapID = model.WristStrapID; patient.MaritalStatus = model.MaritalStatus; patient.Profession = model.Profession; patient.IllnessLevel = model.IllnessLevel; patient.Height = model.Height; patient.Weight = model.Weight; patient.OutpatientNumber = model.OutpatientNumber; patient.AdmissionNumber = model.AdmissionNumber; patient.Nation = model.Nation; patient.Education = model.Education; patient.EmergencyContact = model.EmergencyContact; patient.EmergencyContactPhone = model.EmergencyContactPhone; patient.Province = model.Province; patient.City = model.City; patient.Area = model.Area; patient.Attack_Address = model.Attack_Address; BasicInfo.NativePlaceProvince = model.NativePlaceProvince; BasicInfo.NativePlaceCity = model.NativePlaceCity; BasicInfo.NativePlaceArea = model.NativePlaceArea; BasicInfo.ABOBloodType = model.ABOBloodType; BasicInfo.RhBloodType = model.RhBloodType; BasicInfo.ComeHospitalWay = model.ComeHospitalWay; BasicInfo.Attack_Time = model.Attack_Time; BasicInfo.GestationalWeeks = model.GestationalWeeks; BasicInfo.ExpectedDateOfConfinement = model.ExpectedDateOfConfinement; BasicInfo.BedNumber = model.BedNumber; BasicInfo.HusbandName = model.HusbandName; BasicInfo.Pathography = model.Pathography; BasicInfo.Grade = model.Grade; BasicInfo.NonsecondaryMenstruation = model.NonsecondaryMenstruation; Time.Departure = model.Departure; Time.OutPatient = model.OutPatient; Time.VisitTime = model.VisitTime; Time.ArriveTime = model.ArriveTime; Time.LeaveTime = model.LeaveTime; Time.AttendingDoctor = model.AttendingDoctor; Time.AttendingTime = model.AttendingTime; Time.InRescueRoomTime = model.InRescueRoomTime; Time.OutRescueRoomTime = model.OutRescueRoomTime; Time.TransferTime = model.TransferTime; Time.TransferReason = model.TransferReason; Time.TransferDepartment = model.TransferDepartment; Time.CreationDate = Convert.ToDateTime(model.CreationDate); Time.CreatorID = model.CreatorID; Time.DeleteFlag = model.DeleteFlag; //患者存在则修改 if (!SqlFunc.IsNullOrEmpty(model.GUID)) { var oneClass = patientService.Get(model.GUID); if (oneClass == null) { return new MessageModel { Success = false, Msg = "该患者不存在" }; } patient.GUID = oneClass.GUID; patient.RegisterTime = oneClass.RegisterTime; patientService.UpdateByModel(patient); //高危孕产妇基本信息存在则修改 var getBasicInfo = IService.GetByPatientGUID(oneClass.GUID); if (getBasicInfo != null) { BasicInfo.GUID = getBasicInfo.GUID; IService.UpdateBasicInfo(BasicInfo); } var getTime = IService.GetTimeByPatientGUID(oneClass.GUID); if (getTime != null) { Time.GUID = getTime.GUID; IService.UpdateTime(Time); return new MessageModel { Success = true, Msg = "修改成功" }; } else { return new MessageModel { Success = false, Msg = "修改失败" }; } } else { patient.GUID = Guid.NewGuid().ToString(); patient.DeleteFlag = 0; patient.RegisterTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); patient.CreationDate = patient.RegisterTime; patientService.Add(patient); BasicInfo.GUID = Guid.NewGuid().ToString(); BasicInfo.PatientGuid = patient.GUID; BasicInfo.DeleteFlag = 0; IService.AddBasicInfo(BasicInfo); Time.GUID = Guid.NewGuid().ToString(); Time.PatientGuid = patient.GUID; IService.AddTime(Time); return new MessageModel { Success = true, Msg = "新增成功" }; } } /// /// 根据患者GUID和Flag查询数据 /// /// /// /// public Patient_CriticalPregnant GetByPatientGUID(string patientGUID) { Patient_CriticalPregnant patient = new Patient_CriticalPregnant(); var oneClass = patientService.Get(patientGUID); if (oneClass != null) { patient.GUID = oneClass.GUID; patient.Name = oneClass.Name; patient.Age = oneClass.Age; patient.Category = oneClass.Category; patient.Gender = oneClass.Gender; patient.Birthday = oneClass.Birthday; patient.Credentials_Type = oneClass.Credentials_Type; patient.HospitalGuid = oneClass.HospitalGuid; patient.SystemModuleID = oneClass.SystemModuleID; patient.Editor = oneClass.Editor; patient.EditorID = oneClass.EditorID; //patient.EditTime = model.EditTime; patient.CreatorID = oneClass.CreatorID; patient.Creator = oneClass.Creator; patient.IdentityCard = oneClass.IdentityCard; patient.MobilePhone = oneClass.MobilePhone; patient.WristStrapID = oneClass.WristStrapID; patient.MaritalStatus = oneClass.MaritalStatus; patient.Profession = oneClass.Profession; patient.IllnessLevel = oneClass.IllnessLevel; patient.Height = oneClass.Height; patient.Weight = oneClass.Weight; patient.OutpatientNumber = oneClass.OutpatientNumber; patient.AdmissionNumber = oneClass.AdmissionNumber; patient.RegisterTime = oneClass.RegisterTime; patient.CreationDate = oneClass.CreationDate; patient.Nation = oneClass.Nation; patient.Education = oneClass.Education; patient.EmergencyContact = oneClass.EmergencyContact; patient.EmergencyContactPhone = oneClass.EmergencyContactPhone; patient.Province = oneClass.Province; patient.City = oneClass.City; patient.Area = oneClass.Area; patient.Attack_Address = oneClass.Attack_Address; var Basic = IService.GetByPatientGUID(oneClass.GUID); if (Basic != null) { patient.NativePlaceProvince = Basic.NativePlaceProvince; patient.NativePlaceCity = Basic.NativePlaceCity; patient.NativePlaceArea = Basic.NativePlaceArea; patient.ABOBloodType = Basic.ABOBloodType; patient.RhBloodType = Basic.RhBloodType; patient.ComeHospitalWay = Basic.ComeHospitalWay; patient.PatientGuid = Basic.PatientGuid; patient.ComeHospitalWay = Basic.ComeHospitalWay; patient.Attack_Time = Basic.Attack_Time; patient.GestationalWeeks = Basic.GestationalWeeks; patient.ExpectedDateOfConfinement = Basic.ExpectedDateOfConfinement; patient.BedNumber = Basic.BedNumber; patient.HusbandName = Basic.HusbandName; patient.Pathography = Basic.Pathography; patient.Grade = Basic.Grade; patient.NonsecondaryMenstruation = Basic.NonsecondaryMenstruation; } var getTime = IService.GetTimeByPatientGUID(oneClass.GUID); if (getTime != null) { patient.Departure = getTime.Departure; patient.OutPatient = getTime.OutPatient; patient.VisitTime = getTime.VisitTime; patient.ArriveTime = getTime.ArriveTime; patient.LeaveTime = getTime.LeaveTime; patient.AttendingDoctor = getTime.AttendingDoctor; patient.AttendingTime = getTime.AttendingTime; patient.InRescueRoomTime = getTime.InRescueRoomTime; patient.OutRescueRoomTime = getTime.OutRescueRoomTime; patient.TransferTime = getTime.TransferTime; patient.TransferReason = getTime.TransferReason; patient.TransferDepartment = getTime.TransferDepartment; patient.CreationDate = Convert.ToDateTime(getTime.CreationDate); patient.CreatorID = getTime.CreatorID; patient.DeleteFlag = getTime.DeleteFlag; } } return patient; } /// /// 高危孕产妇患者列表 /// /// /// /// /// /// /// /// /// /// public TableModel GetCriticalPregnantsList(string hospitalGuid, string startTime, string endTime, string name, int ageOne, int ageTwo, string comehospitalway, string grade, int state, int pageIndex, int pageSize) { T_Base_Config Config10003 = IConfig.Get(10004); return IService.GetCriticalPregnantsList(hospitalGuid, long.Parse(Config10003.Config.ToString()), startTime, endTime, name, ageOne, ageTwo, comehospitalway, grade, state, pageIndex, pageSize); } } }