98 lines
4.9 KiB
C#
98 lines
4.9 KiB
C#
|
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_DataBase
|
|||
|
{
|
|||
|
public class T_Service_IllnessLevelDB : BaseDB, IT_Service_IllnessLevel
|
|||
|
{
|
|||
|
public SqlSugarClient db = GetClient();
|
|||
|
|
|||
|
public IllnessLevelModel GetIllnessLevelStatistics(string hospitalGuid, long systemModuleID, string startTime, string endTime, int flag)
|
|||
|
{
|
|||
|
IllnessLevelModel model = new IllnessLevelModel();
|
|||
|
List<IllnessLevelMonthvalue> list = new List<IllnessLevelMonthvalue>();
|
|||
|
|
|||
|
int Month = (Convert.ToDateTime(endTime).Year - Convert.ToDateTime(startTime).Year) * 12 + (Convert.ToDateTime(endTime).Month - Convert.ToDateTime(startTime).Month);
|
|||
|
List<DateTime> monthList = new List<DateTime>();
|
|||
|
for (int i = 0; i < Month + 1; i++)
|
|||
|
{
|
|||
|
string res = Convert.ToDateTime(startTime).AddMonths(i).Year + "-" + GetMonthZero(Convert.ToDateTime(startTime).AddMonths(i).Month) + "-01";
|
|||
|
DateTime dt = Convert.ToDateTime(res);
|
|||
|
monthList.Add(dt.AddDays(1 - dt.Day));
|
|||
|
}
|
|||
|
|
|||
|
//病情程度统计
|
|||
|
var oneClass = db.Queryable<T_Service_Patient>()
|
|||
|
.Where(a => a.HospitalGuid == hospitalGuid && a.SystemModuleID == systemModuleID && a.DeleteFlag == 0)
|
|||
|
.Where(a => a.CreationDate >= SqlFunc.ToDate(startTime) && a.CreationDate <= SqlFunc.ToDate(Convert.ToDateTime(endTime).AddMonths(1)))
|
|||
|
.Select(a => new
|
|||
|
{
|
|||
|
CreationDate = a.CreationDate,
|
|||
|
GUID = a.GUID,
|
|||
|
SystemModuleID = a.SystemModuleID,
|
|||
|
IllnessLevel = a.IllnessLevel
|
|||
|
})
|
|||
|
.ToList();
|
|||
|
|
|||
|
if (oneClass != null)
|
|||
|
{
|
|||
|
//濒危
|
|||
|
model.Endangered = oneClass.Where(j => j.IllnessLevel == "1").Count();
|
|||
|
//危重
|
|||
|
model.Critical = oneClass.Where(j => j.IllnessLevel == "2").Count();
|
|||
|
//急症
|
|||
|
model.Emergencycase = oneClass.Where(j => j.IllnessLevel == "3").Count();
|
|||
|
//非急症
|
|||
|
model.NoEmergencycase = oneClass.Where(j => j.IllnessLevel == "4").Count();
|
|||
|
//已死亡
|
|||
|
model.Dead = oneClass.Where(j => j.IllnessLevel == "5").Count();
|
|||
|
|
|||
|
for (int i = 0; i < monthList.Count; i++)
|
|||
|
{
|
|||
|
IllnessLevelMonthvalue MonthKeyValue = new IllnessLevelMonthvalue();
|
|||
|
MonthKeyValue.Month = monthList[i].ToString("yyyy-MM");
|
|||
|
|
|||
|
int temponeClass1 = oneClass.Where(j => j.CreationDate >= SqlFunc.ToDate(monthList[i].ToString()) && j.CreationDate <= Convert.ToDateTime(SqlFunc.ToDate(monthList[i].ToString() + "-01").AddMonths(1))).Where(j => j.IllnessLevel == "1").Count();
|
|||
|
int temponeClass2 = oneClass.Where(j => j.CreationDate >= SqlFunc.ToDate(monthList[i].ToString()) && j.CreationDate <= Convert.ToDateTime(SqlFunc.ToDate(monthList[i].ToString() + "-01").AddMonths(1))).Where(j => j.IllnessLevel == "2").Count();
|
|||
|
int temponeClass3 = oneClass.Where(j => j.CreationDate >= SqlFunc.ToDate(monthList[i].ToString()) && j.CreationDate <= Convert.ToDateTime(SqlFunc.ToDate(monthList[i].ToString() + "-01").AddMonths(1))).Where(j => j.IllnessLevel == "3").Count();
|
|||
|
int temponeClass4 = oneClass.Where(j => j.CreationDate >= SqlFunc.ToDate(monthList[i].ToString()) && j.CreationDate <= Convert.ToDateTime(SqlFunc.ToDate(monthList[i].ToString() + "-01").AddMonths(1))).Where(j => j.IllnessLevel == "4").Count();
|
|||
|
int temponeClass5 = oneClass.Where(j => j.CreationDate >= SqlFunc.ToDate(monthList[i].ToString()) && j.CreationDate <= Convert.ToDateTime(SqlFunc.ToDate(monthList[i].ToString() + "-01").AddMonths(1))).Where(j => j.IllnessLevel == "5").Count();
|
|||
|
|
|||
|
MonthKeyValue.Endangered = temponeClass1;
|
|||
|
MonthKeyValue.Critical = temponeClass2;
|
|||
|
MonthKeyValue.Emergencycase = temponeClass3;
|
|||
|
MonthKeyValue.NoEmergencycase = temponeClass4;
|
|||
|
MonthKeyValue.Dead = temponeClass5;
|
|||
|
|
|||
|
list.Add(MonthKeyValue);
|
|||
|
}
|
|||
|
model.monthvalue = list;
|
|||
|
}
|
|||
|
return model;
|
|||
|
}
|
|||
|
/// <summary>
|
|||
|
/// 计算月份
|
|||
|
/// </summary>
|
|||
|
/// <param name="month"></param>
|
|||
|
/// <returns></returns>
|
|||
|
private string GetMonthZero(int month)
|
|||
|
{
|
|||
|
if (month < 10)
|
|||
|
{
|
|||
|
return "0" + month;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
return month.ToString();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|