StableVersion4.3/HL_FristAidPlatform_DataBase/Service/T_Service_FirstAid_Whereabo...

142 lines
5.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_FirstAid_WhereaboutsAndCountDB:BaseDB, IT_Service_FirstAid_WhereaboutsAndCount
{
public SqlSugarClient db = GetClient();
public List<WhereaboutsAndCountModel> GetWhereaboutsAndCountStatistics(string hospitalGuid, string startTime, string endTime)
{
List<WhereaboutsAndCountModel> list = new List<WhereaboutsAndCountModel>();
//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; 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, T_Service_FirstAid_PatientInfo>((a, b) => new JoinQueryInfos(
JoinType.Left, a.GUID == b.PatientGUID))
.Where((a, b) => a.HospitalGuid == hospitalGuid && a.DeleteFlag == 0)
.Where((a, b) => a.CreationDate >= SqlFunc.ToDate(startTime) && a.CreationDate <= SqlFunc.ToDate(endTime))
.Select((a,b) => new {
GUID=a.GUID,
Killip=b.Killip,
TriageDepartment =b.TriageDepartment
})
.ToList();
if (oneClass != null)
{
//分诊科室
WhereaboutsAndCountModel model1 = new WhereaboutsAndCountModel();
model1.Name = "急诊内科";
model1.Count = oneClass.Where(i => i.TriageDepartment == "1").Count()+"";
WhereaboutsAndCountModel model2 = new WhereaboutsAndCountModel();
model2.Name = "急诊外科";
model2.Count = oneClass.Where(i => i.TriageDepartment == "2").Count() + "";
WhereaboutsAndCountModel model3 = new WhereaboutsAndCountModel();
model3.Name = "卒中中心";
model3.Count = oneClass.Where(i => i.TriageDepartment == "3").Count() + "";
WhereaboutsAndCountModel model4 = new WhereaboutsAndCountModel();
model4.Name = "胸痛中心";
model4.Count = oneClass.Where(i => i.TriageDepartment == "4").Count() + "";
WhereaboutsAndCountModel model5 = new WhereaboutsAndCountModel();
model5.Name = "创伤中心";
model5.Count = oneClass.Where(i => i.TriageDepartment == "5").Count() + "";
WhereaboutsAndCountModel model6 = new WhereaboutsAndCountModel();
model6.Name = "发热门诊";
model6.Count = oneClass.Where(i => i.TriageDepartment == "6").Count() + "";
WhereaboutsAndCountModel model7 = new WhereaboutsAndCountModel();
model7.Name = "急诊肛肠科";
model7.Count = oneClass.Where(i => i.TriageDepartment == "7").Count() + "";
WhereaboutsAndCountModel model8 = new WhereaboutsAndCountModel();
model8.Name = "其他门诊";
model8.Count = oneClass.Where(i => i.TriageDepartment == "8").Count() + "";
WhereaboutsAndCountModel model9 = new WhereaboutsAndCountModel();
model9.Name = "急诊妇科";
model9.Count = oneClass.Where(i => i.TriageDepartment == "9").Count() + "";
WhereaboutsAndCountModel model10 = new WhereaboutsAndCountModel();
model10.Name = "急诊儿科";
model10.Count = oneClass.Where(i => i.TriageDepartment == "10").Count() + "";
//病情等级
WhereaboutsAndCountModel model11 = new WhereaboutsAndCountModel();
model11.Name = "Ⅰ级(急危病人)";
model11.Count = oneClass.Where(i => i.Killip == "1").Count() + "";
WhereaboutsAndCountModel model12 = new WhereaboutsAndCountModel();
model12.Name = "Ⅱ级(急重病人)";
model12.Count = oneClass.Where(i => i.Killip == "2").Count() + "";
WhereaboutsAndCountModel model13 = new WhereaboutsAndCountModel();
model13.Name = "Ⅲ级(急症病人)";
model13.Count = oneClass.Where(i => i.Killip == "3").Count() + "";
WhereaboutsAndCountModel model14 = new WhereaboutsAndCountModel();
model14.Name = "Ⅳ级(非急症病人)";
model14.Count = oneClass.Where(i => i.Killip == "4").Count() + "";
list.Add(model1);
list.Add(model2);
list.Add(model3);
list.Add(model4);
list.Add(model5);
list.Add(model6);
list.Add(model7);
list.Add(model8);
list.Add(model9);
list.Add(model10);
list.Add(model11);
list.Add(model12);
list.Add(model13);
list.Add(model14);
}
return list;
}
/// <summary>
/// 计算月份
/// </summary>
/// <param name="month"></param>
/// <returns></returns>
private string GetMonthZero(int month)
{
if (month < 10)
{
return "0" + month;
}
else
{
return month.ToString();
}
}
}
}