using HL_FristAidPlatform_Help; using HL_FristAidPlatform_IDataBase; using HL_FristAidPlatform_Models; using SqlSugar; using System.Collections.Generic; namespace HL_FristAidPlatform_DataBase { //T_Service_Apoplexy_RSZL 静脉溶栓 public class T_Service_Apoplexy_RSZLDB : BaseDB, IT_Service_Apoplexy_RSZL { public SqlSugarClient db = GetClient(); /// /// 增加一条数据 /// /// /// public T_Service_Apoplexy_RSZL Add(T_Service_Apoplexy_RSZL model) { return db.Insertable(model).ExecuteReturnEntity(); } /// /// 更新一条数据 /// public int Update(T_Service_Apoplexy_RSZL model) { return db.Updateable(model).Where(it => it.PatientGuid == model.PatientGuid).ExecuteCommand(); } /// /// 删除一条数据 /// public bool Delete(long ID) { return db.Deleteable(it => it.ID == ID).ExecuteCommand() == 0 ? false : true; ; } /// /// 获得前几行数据 /// public T_Service_Apoplexy_RSZL Get(string PatientGuid) { return db.Queryable().First(it => it.PatientGuid == PatientGuid); } public T_Service_Apoplexy_RSZL GetByPatientGuid(string PatientGuid) { return db.Queryable().First(it => it.PatientGuid == PatientGuid); } /// /// 根据患者GUID获取患者溶栓治疗信息 /// /// /// public RSZLModel GetRSZLByPatientGuid(string PatientGuid) { RSZLModel model = new RSZLModel(); var oneClass = db.Queryable().First(it => it.PatientGuid == PatientGuid); if (oneClass != null) { System.Reflection.PropertyInfo[] cfgItemProperties = oneClass.GetType().GetProperties(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public); foreach (System.Reflection.PropertyInfo item in cfgItemProperties) { string name = item.Name; object value = item.GetValue(oneClass, null); //string 或 值属性,且value 不为 null if ((item.PropertyType.IsValueType || item.PropertyType.Name.StartsWith("String")) && value != null && !string.IsNullOrEmpty(value.ToString())) { #region System.Reflection.PropertyInfo[] list2 = model.GetType().GetProperties(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public); foreach (System.Reflection.PropertyInfo i2 in list2) { //两者 PropertyType.Name 要相等 if (item.Name == i2.Name && item.PropertyType.Name == i2.PropertyType.Name) { i2.SetValue(model, value, null); } } #endregion } } model.InformedConsent = oneClass.InformedConsent; model.ThrombolysisDoctorImageFiles = oneClass.ThrombolysisDoctorImageFiles; } var twoClass = db.Queryable().Where(i => i.GUID == PatientGuid && i.DeleteFlag == 0).Select(i => new { i.TimeOfOnset, i.ArrivalHospitalTime }).First(); if (twoClass != null) { model.TimeOfOnset = twoClass.TimeOfOnset; model.ArrivalHospitalTime = twoClass.ArrivalHospitalTime; } var threeClass = db.Queryable().Where(i => i.PatientGuid == PatientGuid && i.DeleteFlag == 0).Select(i => new { i.CTExaminationCompletionTime }).First(); if (threeClass != null) model.CTExaminationCompletionTime = threeClass.CTExaminationCompletionTime; return model; } /// /// 获得数据列表 /// public TableModel GetPageList(int pageIndex, int pageSize) { int total = 0; List data = db.Queryable().Where(it => it.DeleteFlag == 0).ToPageList(pageIndex, pageSize, ref total); TableModel t = new TableModel(); t.Code = 0; t.PageCount = data.Count; t.TotalNumber = total; t.Data = data; t.Msg = "成功"; return t; } } }