149 lines
7.1 KiB
C#
149 lines
7.1 KiB
C#
|
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
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// 发病6小时内符合条件患者前循环大血管闭塞性脑梗死患者血管内治疗率
|
|||
|
/// </summary>
|
|||
|
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<string> 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<string> monthList = new List<string>();
|
|||
|
for (int i = 0; i < Month + 1; i++)
|
|||
|
{
|
|||
|
monthList.Add(st.AddMonths(i).Year + "-" + GetMonthZero(st.AddMonths(i).Month));
|
|||
|
}
|
|||
|
|
|||
|
return monthList;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// T_Service_Patient 患者基本信息表
|
|||
|
/// T_Service_Apoplexy_PatientOutcome 出院表
|
|||
|
/// T_Service_Apoplexy_XGZL 血管内治疗表
|
|||
|
/// </summary>
|
|||
|
public OcclusiveCerebralInfarctionModel GetTreatmentRateModel(string hospitalGuid, string startTime, string endTime)
|
|||
|
{
|
|||
|
List<string> 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<T_Service_Patient, T_Service_Apoplexy_Prehospital, T_Service_Apoplexy_PatientOutcome, T_Service_Apoplexy_XGZL>((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;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 发病6小时内符合条件患者前循环大血管闭塞性脑梗死患者血管内治疗率的患者列表 type = 0 未治疗的 type = 1 经过治疗的
|
|||
|
/// </summary>
|
|||
|
/// <param name="hospitalGuid"></param>
|
|||
|
/// <param name="startTime"></param>
|
|||
|
/// <param name="endTime"></param>
|
|||
|
/// <param name="type"></param>
|
|||
|
/// <param name="flag"></param>
|
|||
|
/// <param name="pageIndex"></param>
|
|||
|
/// <param name="pageSize"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public TableModel<QueryTreatmentRateModel> GetQueryTreatmentRateModelList(string hospitalGuid, string startTime, string endTime, int type, int pageIndex, int pageSize)
|
|||
|
{
|
|||
|
int totalNumber = 0;
|
|||
|
TableModel<QueryTreatmentRateModel> t = new TableModel<QueryTreatmentRateModel>();
|
|||
|
List<QueryTreatmentRateModel> list = new List<QueryTreatmentRateModel>();
|
|||
|
string StartTime = startTime;
|
|||
|
string EndTime = Convert.ToDateTime(endTime).AddDays(1) + "";
|
|||
|
|
|||
|
list = db.Queryable<T_Service_Patient, T_Service_Apoplexy_Prehospital, T_Service_Apoplexy_PatientOutcome, T_Service_Apoplexy_XGZL>((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;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|