using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using HL_FristAidPlatform_Help; using HL_FristAidPlatform_Help.Model; using HL_FristAidPlatform_IDataBase; using HL_FristAidPlatform_IDataBase.Service; using HL_FristAidPlatform_Models; using SqlSugar; namespace HL_FristAidPlatform_DataBase.Service { /// /// 发病6小时内符合条件患者前循环大血管闭塞性脑梗死患者血管内治疗率 /// public class T_Service_Apoplexy_IntravascularTreatmentRateDB : BaseDB ,IT_Service_Apoplexy_IntravascularTreatmentRate { public SqlSugarClient db = GetClient(); public string GetMonthZero(int month) { if (month < 10) { return "0" + month; } else { return month.ToString(); } } public List GetMonthList(string startTime, string endTime) { DateTime st = Convert.ToDateTime(startTime); DateTime et = Convert.ToDateTime(endTime); //保留 年 月 份 int Month = (et.Year - st.Year) * 12 + (et.Month - st.Month); List monthList = new List(); for (int i = 0; i < Month + 1; i++) { monthList.Add(st.AddMonths(i).Year + "-" + GetMonthZero(st.AddMonths(i).Month)); } return monthList; } /// /// T_Service_Patient 患者基本信息表 /// T_Service_Apoplexy_PatientOutcome 出院表 /// T_Service_Apoplexy_XGZL 血管内治疗表 /// public OcclusiveCerebralInfarctionModel GetTreatmentRateModel(string hospitalGuid, string startTime, string endTime) { List monthList = GetMonthList(startTime, endTime); OcclusiveCerebralInfarctionModel occlusiveCerebralInfarction = new OcclusiveCerebralInfarctionModel(); int sumCount = 0; int sumCount1 = 0; string StartTime = startTime; string EndTime = Convert.ToDateTime(endTime).AddDays(1) + ""; Console.Write(EndTime); var oneClass = db.Queryable((a, b, c, d) => new JoinQueryInfos( JoinType.Left, a.GUID == b.PatientGuid, JoinType.Left, a.GUID == c.PatientGuid, JoinType.Left, a.GUID == d.PatientGuid)) .Where((a, b, c, d) => a.HospitalGuid == hospitalGuid && a.SystemModuleID == 3 && a.DeleteFlag == 0) .Where((a, b, c, d) => !SqlFunc.IsNullOrEmpty(b.NGSJZFaBingTime) && !SqlFunc.IsNullOrEmpty(a.CreationDate) && SqlFunc.SqlServer_DateDiff("mm", Convert.ToDateTime(b.NGSJZFaBingTime), Convert.ToDateTime(a.CreationDate)) < 360) .Where((a, b, c, d) => a.CreationDate >= SqlFunc.ToDate(StartTime)) .Where((a, b, c, d) => a.CreationDate < SqlFunc.ToDate(EndTime)) .Where((a, b, c, d) => c.Diagnosis == 1 && b.VascularOcclusion == "1") .Select((a, b, c, d) => new QueryTreatmentRateModel { GUID = a.GUID, CreationDate = a.CreationDate, //NGSJZDaoYuanTime = b.NGSJZDaoYuanTime, //NGSJZFaBingTime = b.NGSJZFaBingTime, //Diagnosis = c.Diagnosis, acZLType = a.acZLType }).ToList(); if(oneClass != null&&oneClass.Count>0) { sumCount = oneClass.Count(); sumCount1 = oneClass.Where(a =>(!string.IsNullOrEmpty(a.acZLType)&&a.acZLType.Contains("02"))).Count(); } if (sumCount > 0) { float a1 = (float)sumCount1 / sumCount * 100; string s1 = a1.ToString("F2");//保留两位小数 occlusiveCerebralInfarction.TreatmentRate = s1; } occlusiveCerebralInfarction.Count = sumCount; occlusiveCerebralInfarction.TreatmentNumber = sumCount1; occlusiveCerebralInfarction.NotTreatmentNumber = sumCount - sumCount1; return occlusiveCerebralInfarction; } /// /// 发病6小时内符合条件患者前循环大血管闭塞性脑梗死患者血管内治疗率的患者列表 type = 0 未治疗的 type = 1 经过治疗的 /// /// /// /// /// /// /// /// /// public TableModel GetQueryTreatmentRateModelList(string hospitalGuid, string startTime, string endTime, int type, int pageIndex, int pageSize) { int totalNumber = 0; TableModel t = new TableModel(); List list = new List(); string StartTime = startTime; string EndTime = Convert.ToDateTime(endTime).AddDays(1) + ""; list = db.Queryable((a, b, c, d) => new JoinQueryInfos( JoinType.Left, a.GUID == b.PatientGuid, JoinType.Left, a.GUID == c.PatientGuid, JoinType.Left, a.GUID == d.PatientGuid)) .Where((a, b, c, d) => a.HospitalGuid == hospitalGuid && a.SystemModuleID == 3 && a.DeleteFlag == 0) .Where((a, b, c, d) => !SqlFunc.IsNullOrEmpty(b.NGSJZFaBingTime) && !SqlFunc.IsNullOrEmpty(a.CreationDate) && SqlFunc.SqlServer_DateDiff("mm", Convert.ToDateTime(b.NGSJZFaBingTime), Convert.ToDateTime(a.CreationDate)) < 360) .Where((a, b, c, d) => a.CreationDate >= SqlFunc.ToDate(StartTime)) .Where((a, b, c, d) => a.CreationDate < SqlFunc.ToDate(EndTime)) .Where((a, b, c, d) => c.Diagnosis == 1 && b.VascularOcclusion == "1") .WhereIF(type == 1, (a, b, c, d) => (!string.IsNullOrEmpty(a.acZLType) && a.acZLType.Contains("02"))) .WhereIF(type == 0, (a, b, c, d) => (!string.IsNullOrEmpty(a.acZLType) && !a.acZLType.Contains("02"))) .Select((a, b, c, d) => new QueryTreatmentRateModel { GUID = a.GUID, Name = a.Name, Gender = a.Gender, Age = a.Age, CreationDate = a.CreationDate, //Diagnosis = c.Diagnosis, acZLType = a.acZLType }).ToPageList(pageIndex, pageSize, ref totalNumber); t.Code = 0; t.PageCount = list.Count; t.TotalNumber = totalNumber; t.Data = list; t.Msg = "成功"; return t; } } }