StableVersion4.3/HL_FristAidPlatform_DataBase/Service/T_Service_ChestPain_Statist...

680 lines
38 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using HL_FristAidPlatform_Help;
using HL_FristAidPlatform_IDataBase;
using HL_FristAidPlatform_Models;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
namespace HL_FristAidPlatform_DataBase
{
/// <summary>
/// 胸痛患者转归
/// </summary>
public class T_Service_ChestPain_StatisticsDB : BaseDB, IT_Service_ChestPain_Statistics
{
public SqlSugarClient db = GetClient();
/// <summary>
/// 胸痛患者急救环节耗时统计
/// 仅统计STEMI患者进行了【急诊PCI】、NSTEMI患者进行了【紧急介入治疗】治疗方式
/// </summary>
/// <param name="systemModuleID">所属模块ID</param>
/// <param name="startTime">开始时间(建档)</param>
/// <param name="endTime">结束时间(建档)</param>
/// <param name="hospitalGuid">所属院区GUID</param>
/// <returns></returns>
public string GetTimeConsuming(long systemModuleID, string startTime, string endTime, string hospitalGuid)
{
try
{
string StrWhere = string.Empty;
#region 所属院区
if (!string.IsNullOrEmpty(hospitalGuid.Trim()))
{
StrWhere += " AND a.HospitalGuid = '" + hospitalGuid + "'";
}
#endregion
//STEMI患者直接PCI+NSTEMI患者紧急介入治疗
string SqlStr = string.Format(@"
SELECT SUBSTRING(CONVERT(varchar(10), a.CreationDate,120),0,8) as MonthValue,a.[GUID],
CASE ISNULL(b.CW_Coming_Way_Code,'') WHEN '' THEN '0' ELSE b.CW_Coming_Way_Code END AS HospitalMode,
c.STEMI_Is_Bypass_Emergency AS Is_Bypass_Emergency,
dbo.Fun_GetRecordingTimeDiff(a.GUID,(SELECT Config FROM T_Base_Config WHERE ID =1002),(SELECT Config FROM T_Base_Config WHERE ID =1007),2,1) AS TimeConsuming_120,
dbo.Fun_GetRecordingTimeDiff(a.GUID,(SELECT Config FROM T_Base_Config WHERE ID =1007),(SELECT Config FROM T_Base_Config WHERE ID =1023),2,1) AS TimeConsuming_JZK,
dbo.Fun_GetRecordingTimeDiff(a.GUID,(SELECT Config FROM T_Base_Config WHERE ID =1023),(SELECT Config FROM T_Base_Config WHERE ID =1028),2,1) AS TimeConsuming_JRK,
dbo.Fun_GetRecordingTimeDiff(a.GUID,(SELECT Config FROM T_Base_Config WHERE ID =1003),(SELECT Config FROM T_Base_Config WHERE ID =1028),2,1) AS TimeConsuming_ZSJ
FROM T_Service_Patient a
LEFT JOIN T_Service_ChestPain_FirstAIDInfo b ON b.PatientGuid = a.[GUID]
LEFT JOIN T_Service_ChestPain_TreatmentInfo c ON c.PatientGuid = a.[GUID]
WHERE a.RegisterTime BETWEEN '{0}' AND '{1}' AND c.STEMI_Measures=1 AND
a.SystemModuleID='{2}' AND c.CP_Diagnosis_Code=1 AND a.DeleteFlag=0 AND b.DeleteFlag=0 {3}
UNION ALL
SELECT SUBSTRING(CONVERT(varchar(10), a.CreationDate,120),0,8) as MonthValue,a.[GUID],
CASE ISNULL(b.CW_Coming_Way_Code,'') WHEN '' THEN '0' ELSE b.CW_Coming_Way_Code END AS HospitalMode,
c.NSTEMI_Is_Bypass_Emergency AS Is_Bypass_Emergency,
dbo.Fun_GetRecordingTimeDiff(a.GUID,(SELECT Config FROM T_Base_Config WHERE ID =1002),(SELECT Config FROM T_Base_Config WHERE ID =1007),2,1) AS TimeConsuming_120,
dbo.Fun_GetRecordingTimeDiff(a.GUID,(SELECT Config FROM T_Base_Config WHERE ID =1007),(SELECT Config FROM T_Base_Config WHERE ID =1023),2,1) AS TimeConsuming_JZK,
dbo.Fun_GetRecordingTimeDiff(a.GUID,(SELECT Config FROM T_Base_Config WHERE ID =1023),(SELECT Config FROM T_Base_Config WHERE ID =1028),2,1) AS TimeConsuming_JRK,
dbo.Fun_GetRecordingTimeDiff(a.GUID,(SELECT Config FROM T_Base_Config WHERE ID =1003),(SELECT Config FROM T_Base_Config WHERE ID =1028),2,1) AS TimeConsuming_ZSJ
FROM T_Service_Patient a
LEFT JOIN T_Service_ChestPain_FirstAIDInfo b ON b.PatientGuid = a.[GUID]
LEFT JOIN T_Service_ChestPain_TreatmentInfo c ON c.PatientGuid = a.[GUID]
WHERE a.RegisterTime BETWEEN '{0}' AND '{1}' AND c.NSTEMI_Invasive_Strategy=1 AND
a.SystemModuleID='{2}' AND c.CP_Diagnosis_Code=2 AND a.DeleteFlag=0 AND b.DeleteFlag=0 {3}", startTime, endTime, systemModuleID, StrWhere);
DataTable dt = db.Ado.GetDataTable(SqlStr);
string JsonStr = Help.DataTableToJsonStr(dt);
return JsonStr;
}
catch (Exception ex)
{
Help.Info(ex.Message);
return ex.Message;
}
}
/// <summary>
/// 急救环节耗时统计 FirstAidTimeStatistics
/// </summary>
/// <param name="hosptialGuid"></param>
/// <param name="startTime"></param>
/// <param name="endTime"></param>
/// <returns></returns>
public List<CheatPainFirstAidTimeStatisticsModel> GetFirstAidTimeStatistics(string hosptialGuid, string startTime, string endTime)
{
List<CheatPainFirstAidTimeStatisticsModel> Datalist = new List<CheatPainFirstAidTimeStatisticsModel>();
List<string> listMonth = GetMonthList(startTime + "-01", endTime + "-01");
var listClass = db.Queryable<T_Service_Patient, T_Service_ChestPain_TreatmentInfo, T_Service_ChestPain_FirstAIDInfo>((a, b, c) => new JoinQueryInfos(
JoinType.Left, a.GUID == b.PatientGuid, //左连接 左链接 左联
JoinType.Left, a.GUID == c.PatientGuid))//&& c.CW_Coming_Way_Code == "1"
.Where((a, b, c) => a.HospitalGuid == hosptialGuid && a.SystemModuleID == 2 && (b.CP_Diagnosis_Code == "1" || b.CP_Diagnosis_Code == "2") && (b.STEMI_Measures == "1" || b.NSTEMI_Invasive_Strategy == "1") && a.DeleteFlag == 0)
.WhereIF(!SqlFunc.IsNullOrEmpty(startTime), (a, b, c) => Convert.ToDateTime(a.CreationDate) >= SqlFunc.ToDate(startTime + "-01"))
.WhereIF(!SqlFunc.IsNullOrEmpty(endTime), (a, b, c) => Convert.ToDateTime(a.CreationDate) < SqlFunc.ToDate(endTime + "-01").AddMonths(1))
.Select((a, b, c) => new
{
RegisterTime = a.RegisterTime,
Diff120 = SqlFunc.IF(!SqlFunc.IsNullOrEmpty(SqlFunc.Subqueryable<T_Service_ChestPain_PatientsTimeAxis>().Where(s => s.PatientGuid == a.GUID && s.TimeAxisID == 39).Select(s => s.RecordingTime)) && !SqlFunc.IsNullOrEmpty(SqlFunc.Subqueryable<T_Service_ChestPain_PatientsTimeAxis>().Where(s => s.PatientGuid == a.GUID && s.TimeAxisID == 45).Select(s => s.RecordingTime))).Return(SqlFunc.SqlServer_DateDiff("mi", SqlFunc.ToDate(SqlFunc.Subqueryable<T_Service_ChestPain_PatientsTimeAxis>().Where(s => s.PatientGuid == a.GUID && s.TimeAxisID == 39).Select(s => s.RecordingTime)), SqlFunc.ToDate(SqlFunc.Subqueryable<T_Service_ChestPain_PatientsTimeAxis>().Where(s => s.PatientGuid == a.GUID && s.TimeAxisID == 45).Select(s => s.RecordingTime)))).End("0"),
DiffEmergencyDepartment = SqlFunc.IF(!SqlFunc.IsNullOrEmpty(SqlFunc.Subqueryable<T_Service_ChestPain_PatientsTimeAxis>().Where(s => s.PatientGuid == a.GUID && s.TimeAxisID == 45).Select(s => s.RecordingTime)) && !SqlFunc.IsNullOrEmpty(SqlFunc.Subqueryable<T_Service_ChestPain_PatientsTimeAxis>().Where(s => s.PatientGuid == a.GUID && s.TimeAxisID == 47).Select(s => s.RecordingTime))).Return(SqlFunc.SqlServer_DateDiff("mi", SqlFunc.ToDate(SqlFunc.Subqueryable<T_Service_ChestPain_PatientsTimeAxis>().Where(s => s.PatientGuid == a.GUID && s.TimeAxisID == 45).Select(s => s.RecordingTime)), SqlFunc.ToDate(SqlFunc.Subqueryable<T_Service_ChestPain_PatientsTimeAxis>().Where(s => s.PatientGuid == a.GUID && s.TimeAxisID == 47).Select(s => s.RecordingTime)))).End("0"),
DiffInterventionalRoom = SqlFunc.IF(!SqlFunc.IsNullOrEmpty(SqlFunc.Subqueryable<T_Service_ChestPain_PatientsTimeAxis>().Where(s => s.PatientGuid == a.GUID && s.TimeAxisID == 47).Select(s => s.RecordingTime)) && !SqlFunc.IsNullOrEmpty(SqlFunc.Subqueryable<T_Service_ChestPain_PatientsTimeAxis>().Where(s => s.PatientGuid == a.GUID && s.TimeAxisID == 62).Select(s => s.RecordingTime))).Return(SqlFunc.SqlServer_DateDiff("mi", SqlFunc.ToDate(SqlFunc.Subqueryable<T_Service_ChestPain_PatientsTimeAxis>().Where(s => s.PatientGuid == a.GUID && s.TimeAxisID == 47).Select(s => s.RecordingTime)), SqlFunc.ToDate(SqlFunc.Subqueryable<T_Service_ChestPain_PatientsTimeAxis>().Where(s => s.PatientGuid == a.GUID && s.TimeAxisID == 62).Select(s => s.RecordingTime)))).End("0"),
DiffFirstAidProcess = SqlFunc.IF(!SqlFunc.IsNullOrEmpty(SqlFunc.Subqueryable<T_Service_ChestPain_PatientsTimeAxis>().Where(s => s.PatientGuid == a.GUID && s.TimeAxisID == 67).Select(s => s.RecordingTime)) && !SqlFunc.IsNullOrEmpty(SqlFunc.Subqueryable<T_Service_ChestPain_PatientsTimeAxis>().Where(s => s.PatientGuid == a.GUID && s.TimeAxisID == 62).Select(s => s.RecordingTime))).Return(SqlFunc.SqlServer_DateDiff("mi", SqlFunc.ToDate(SqlFunc.Subqueryable<T_Service_ChestPain_PatientsTimeAxis>().Where(s => s.PatientGuid == a.GUID && s.TimeAxisID == 67).Select(s => s.RecordingTime)), SqlFunc.ToDate(SqlFunc.Subqueryable<T_Service_ChestPain_PatientsTimeAxis>().Where(s => s.PatientGuid == a.GUID && s.TimeAxisID == 62).Select(s => s.RecordingTime)))).End("0"),
}).ToList();
if (listClass != null && listClass.Count > 0)
{
if (listMonth.Count > 0)
{
for (int i = 0; i < listMonth.Count; i++)
{
CheatPainFirstAidTimeStatisticsModel model = new CheatPainFirstAidTimeStatisticsModel();
CheatPainFirstAidTimeStatisticsDataModel model120 = new CheatPainFirstAidTimeStatisticsDataModel();
CheatPainFirstAidTimeStatisticsDataModel modelEmergencyDepartment = new CheatPainFirstAidTimeStatisticsDataModel();
CheatPainFirstAidTimeStatisticsDataModel modelInterventionalRoom = new CheatPainFirstAidTimeStatisticsDataModel();
CheatPainFirstAidTimeStatisticsDataModel modelFirstAidProcess = new CheatPainFirstAidTimeStatisticsDataModel();
model.Month = listMonth[i] + "";
model.Avg120 = "0.00";
model.AvgEmergencyDepartment = "0.00";
model.AvgInterventionalRoom = "0.00";
model.AvgFirstAidProcess = "0.00";
model120.MonthValue = listMonth[i] + "";
model120.MaxValue = "0";
model120.MinValue = "0";
model120.AvgValue = "0.00";
model120.SumCount = "0";
modelEmergencyDepartment.MonthValue = listMonth[i] + "";
modelEmergencyDepartment.MaxValue = "0";
modelEmergencyDepartment.MinValue = "0";
modelEmergencyDepartment.AvgValue = "0.00";
modelEmergencyDepartment.SumCount = "0";
modelInterventionalRoom.MonthValue = listMonth[i] + "";
modelInterventionalRoom.MaxValue = "0";
modelInterventionalRoom.MinValue = "0";
modelInterventionalRoom.AvgValue = "0.00";
modelInterventionalRoom.SumCount = "0";
modelFirstAidProcess.MonthValue = listMonth[i] + "";
modelFirstAidProcess.MaxValue = "0";
modelFirstAidProcess.MinValue = "0";
modelFirstAidProcess.AvgValue = "0.00";
modelFirstAidProcess.SumCount = "0";
DateTime start = Convert.ToDateTime(listMonth[i] + "-01");
DateTime end = Convert.ToDateTime(listMonth[i] + "-01").AddMonths(1);
var tempListClass = listClass.Where(j => Convert.ToDateTime(j.RegisterTime) >= start && Convert.ToDateTime(j.RegisterTime) <= end).ToList();
int max = 0;
int min = 0;
string avg = "";
if (tempListClass != null && tempListClass.Count > 0)
{
max = tempListClass.Max(j => int.Parse(j.Diff120));
min = tempListClass.Min(j => int.Parse(j.Diff120));
avg = tempListClass.Average(j => int.Parse(j.Diff120)).ToString("#0.00") + "";
model120.MonthValue= listMonth[i] + "";
model120.MaxValue = string.IsNullOrEmpty(max + "") ? "0" : max + "";
model120.MinValue = string.IsNullOrEmpty(min + "") ? "0" : min + "";
model120.AvgValue = string.IsNullOrEmpty(avg + "") ? "0.00" : avg + "";
model120.SumCount = string.IsNullOrEmpty(tempListClass.Count + "") ? "0" : tempListClass.Count + "";
model.Avg120 = string.IsNullOrEmpty(avg + "") ? "0.00" : avg + "";
max = 0;
min = 0;
avg = "";
max = tempListClass.Max(j => int.Parse(j.DiffEmergencyDepartment));
min = tempListClass.Min(j => int.Parse(j.DiffEmergencyDepartment));
avg = tempListClass.Average(j => int.Parse(j.DiffEmergencyDepartment)).ToString("#0.00") + "";
modelEmergencyDepartment.MonthValue = listMonth[i] + "";
modelEmergencyDepartment.MaxValue = string.IsNullOrEmpty(max + "") ? "0" : max + "";
modelEmergencyDepartment.MinValue = string.IsNullOrEmpty(min + "") ? "0" : min + "";
modelEmergencyDepartment.AvgValue = string.IsNullOrEmpty(avg + "") ? "0.00" : avg + "";
modelEmergencyDepartment.SumCount = string.IsNullOrEmpty(tempListClass.Count + "") ? "0" : tempListClass.Count + "";
model.AvgEmergencyDepartment = string.IsNullOrEmpty(avg + "") ? "0.00" : avg + "";
max = 0;
min = 0;
avg = "";
max = tempListClass.Max(j => int.Parse(j.DiffInterventionalRoom));
min = tempListClass.Min(j => int.Parse(j.DiffInterventionalRoom));
avg = tempListClass.Average(j => int.Parse(j.DiffInterventionalRoom)).ToString("#0.00") + "";
modelInterventionalRoom.MonthValue = listMonth[i] + "";
modelInterventionalRoom.MaxValue = string.IsNullOrEmpty(max + "") ? "0" : max + "";
modelInterventionalRoom.MinValue = string.IsNullOrEmpty(min + "") ? "0" : min + "";
modelInterventionalRoom.AvgValue = string.IsNullOrEmpty(avg + "") ? "0.00" : avg + "";
modelInterventionalRoom.SumCount = string.IsNullOrEmpty(tempListClass.Count + "") ? "0" : tempListClass.Count + "";
model.AvgInterventionalRoom = string.IsNullOrEmpty(avg + "") ? "0.00" : avg + "";
max = 0;
min = 0;
avg = "";
max = tempListClass.Max(j => int.Parse(j.DiffFirstAidProcess));
min = tempListClass.Min(j => int.Parse(j.DiffFirstAidProcess));
avg = tempListClass.Average(j => int.Parse(j.DiffFirstAidProcess)).ToString("#0.00") + "";
modelFirstAidProcess.MonthValue = listMonth[i] + "";
modelFirstAidProcess.MaxValue = string.IsNullOrEmpty(max + "") ? "0" : max + "";
modelFirstAidProcess.MinValue = string.IsNullOrEmpty(min + "") ? "0" : min + "";
modelFirstAidProcess.AvgValue = string.IsNullOrEmpty(avg + "") ? "0.00" : avg + "";
modelFirstAidProcess.SumCount = string.IsNullOrEmpty(tempListClass.Count + "") ? "0" : tempListClass.Count + "";
model.AvgFirstAidProcess = string.IsNullOrEmpty(avg + "") ? "0.00" : avg + "";
}
model.Data120 = model120;
model.DataEmergencyDepartment = modelEmergencyDepartment;
model.DataInterventionalRoom = modelInterventionalRoom;
model.DataFirstAidProcess = modelFirstAidProcess;
Datalist.Add(model);
}
}
}
return Datalist;
}
/// <summary>
/// 患者趋势图和分布图统计
/// </summary>
/// <param name="systemModuleID">所属模块ID</param>
/// <param name="startTime">开始时间(建档)</param>
/// <param name="endTime">结束时间(建档)</param>
/// <param name="hospitalGuid">所属院区GUID</param>
/// <returns></returns>
public string GetPatientDiagnosis(long systemModuleID, string startTime, string endTime, string hospitalGuid)
{
try
{
string StrWhere = string.Empty;
#region 所属院区
if (!string.IsNullOrEmpty(hospitalGuid.Trim()))
{
StrWhere += " AND a.HospitalGuid = '" + hospitalGuid + "'";
}
#endregion
// AND b.DeleteFlag=0
string SqlStr = string.Format(@"SELECT a.Name,CONVERT(varchar(7),a.RegisterTime, 120) AS RegisterTime,CONVERT(varchar(100),a.RegisterTime, 23) AS RegisterTime_ForDay,CASE b.CP_Diagnosis_Code WHEN '1' THEN 'STEMI' WHEN '2' THEN 'NSTEMI' WHEN '3' THEN 'UA' WHEN '4' THEN '主动脉夹层' WHEN '5' THEN '肺动脉栓塞' WHEN '6' THEN '非ACS心源性胸痛' WHEN '7' THEN '其它非心源性胸痛' WHEN '8' THEN '待查' ELSE '' END AS Diagnosis
FROM T_Service_Patient a
LEFT JOIN T_Service_ChestPain_TreatmentInfo b ON a.GUID=b.PatientGuid
WHERE a.RegisterTime BETWEEN '{0}' AND '{1}' AND
a.SystemModuleID='{2}' AND a.DeleteFlag=0 {3} order by a.RegisterTime", startTime, endTime, systemModuleID, StrWhere);
DataTable dt = db.Ado.GetDataTable(SqlStr);
string JsonStr = Help.DataTableToJsonStr(dt);
return JsonStr;
}
catch (Exception ex)
{
Help.Info(ex.Message);
return ex.Message;
}
}
/// <summary>
/// 胸痛首页获取患者数量
/// </summary>
/// <param name="hospitalGuid"></param>
/// <returns></returns>
public ChestPainPatientNumModel GetChestPainPatientNum(string hospitalGuid)
{
ChestPainPatientNumModel model = new ChestPainPatientNumModel();
var oneClass = db.Queryable<T_Service_Patient>()
.Where(i => i.HospitalGuid == hospitalGuid && i.SystemModuleID == 2 && i.DeleteFlag == 0)
.Select(i => new { i.GUID, i.CreationDate })
.ToList();
if (oneClass != null)
{
DateTime dt = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"));
model.ToDayCount = oneClass.Where(i => i.CreationDate >= dt && i.CreationDate <= dt.AddDays(1)).Count();
//星期一为第一天
int weeknow = Convert.ToInt32(dt.DayOfWeek);
//因为是以星期一为第一天所以要判断weeknow等于0时要向前推6天。
weeknow = (weeknow == 0 ? (7 - 1) : (weeknow - 1));
int daydiff = (-1) * weeknow;
//本周第一天
DateTime FirstDay = dt.AddDays(daydiff);
#region 获取本周最后一天
//星期天为最后一天
int lastWeekDay = Convert.ToInt32(dt.DayOfWeek);
lastWeekDay = lastWeekDay == 0 ? (7 - lastWeekDay) : lastWeekDay;
int lastWeekDiff = (7 - lastWeekDay);
//本周最后一天
DateTime LastDay = dt.AddDays(lastWeekDiff);
#endregion
model.WeekCount = oneClass.Where(i => i.CreationDate >= FirstDay && i.CreationDate < LastDay.AddDays(1)).Count();
DateTime startMonth = dt.AddDays(1 - dt.Day);
DateTime endMonth = startMonth.AddMonths(1);
model.MonthCount = oneClass.Where(i => i.CreationDate >= startMonth && i.CreationDate < endMonth).Count();
DateTime sixstartMonth = dt.AddDays(1 - dt.Day).AddMonths(-5);
DateTime sixendMonth = dt.AddDays(1 - dt.Day).AddMonths(1);
model.SixMonthCount = oneClass.Where(i => i.CreationDate >= sixstartMonth && i.CreationDate < sixendMonth).Count();
model.TotalCount = oneClass.Count();
}
return model;
}
/// <summary>
/// 近6个月胸痛病种分布图
/// </summary>
/// <param name="hospitalGuid"></param>
/// <returns></returns>
public List<KeyNumber> GetChestPainPatientTrendChart(string hospitalGuid)
{
List<KeyNumber> list = new List<KeyNumber>();
DateTime dt = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"));
DateTime sixstartMonth = dt.AddDays(1 - dt.Day).AddMonths(-5);
DateTime sixendMonth = dt.AddDays(1 - dt.Day).AddMonths(1);
/// <summary>
/// 初步诊断
/// 1:STEMI
/// 2:NSTEMI
/// 3:UA
/// 4:主动脉夹层
/// 5:肺动脉栓塞
/// 6:非ACS心源性胸痛
/// 7:其它非心源性胸痛
/// 8:待查
/// 9未诊断
/// </summary>
//public string CP_Diagnosis_Code { get; set; }
var oneClass = db.Queryable<T_Service_Patient, T_Service_ChestPain_TreatmentInfo>((a, b) => new JoinQueryInfos(
JoinType.Left, a.GUID == b.PatientGuid)) //左连接 左链接 左联
.Where((a, b) => a.HospitalGuid == hospitalGuid && a.SystemModuleID == 2 && a.DeleteFlag == 0)
.Where((a, b) => a.CreationDate >= sixstartMonth)
.Where((a, b) => a.CreationDate < sixendMonth)
.Select((a, b) => new { a.GUID, a.CreationDate, b.CP_Diagnosis_Code })
.ToList();
KeyNumber KeyNumber1 = new KeyNumber();
KeyNumber KeyNumber2 = new KeyNumber();
KeyNumber KeyNumber3 = new KeyNumber();
KeyNumber KeyNumber4 = new KeyNumber();
KeyNumber KeyNumber5 = new KeyNumber();
KeyNumber KeyNumber6 = new KeyNumber();
KeyNumber KeyNumber7 = new KeyNumber();
KeyNumber KeyNumber8 = new KeyNumber();
KeyNumber KeyNumber9 = new KeyNumber();
KeyNumber1.key = "STEMI";
KeyNumber2.key = "NSTEMI";
KeyNumber3.key = "UA";
KeyNumber4.key = "主动脉夹层";
KeyNumber5.key = "肺动脉栓塞";
KeyNumber6.key = "非ACS心源性胸痛";
KeyNumber7.key = "其它非心源性胸痛";
KeyNumber8.key = "待查";
KeyNumber9.key = "未诊断";
KeyNumber1.value = oneClass.Where(it => !SqlFunc.IsNullOrEmpty(it.CP_Diagnosis_Code) && it.CP_Diagnosis_Code == "1").Count();
KeyNumber2.value = oneClass.Where(it => !SqlFunc.IsNullOrEmpty(it.CP_Diagnosis_Code) && it.CP_Diagnosis_Code == "2").Count();
KeyNumber3.value = oneClass.Where(it => !SqlFunc.IsNullOrEmpty(it.CP_Diagnosis_Code) && it.CP_Diagnosis_Code == "3").Count();
KeyNumber4.value = oneClass.Where(it => !SqlFunc.IsNullOrEmpty(it.CP_Diagnosis_Code) && it.CP_Diagnosis_Code == "4").Count();
KeyNumber5.value = oneClass.Where(it => !SqlFunc.IsNullOrEmpty(it.CP_Diagnosis_Code) && it.CP_Diagnosis_Code == "5").Count();
KeyNumber6.value = oneClass.Where(it => !SqlFunc.IsNullOrEmpty(it.CP_Diagnosis_Code) && it.CP_Diagnosis_Code == "6").Count();
KeyNumber7.value = oneClass.Where(it => !SqlFunc.IsNullOrEmpty(it.CP_Diagnosis_Code) && it.CP_Diagnosis_Code == "7").Count();
KeyNumber8.value = oneClass.Where(it => !SqlFunc.IsNullOrEmpty(it.CP_Diagnosis_Code) && it.CP_Diagnosis_Code == "8").Count();
KeyNumber9.value = oneClass.Where(it => SqlFunc.IsNullOrEmpty(it.CP_Diagnosis_Code)).Count();
list.Add(KeyNumber1);
list.Add(KeyNumber2);
list.Add(KeyNumber3);
list.Add(KeyNumber4);
list.Add(KeyNumber5);
list.Add(KeyNumber6);
list.Add(KeyNumber7);
list.Add(KeyNumber8);
list.Add(KeyNumber9);
return list;
}
/// <summary>
/// 近6个月胸痛病种分布图
/// </summary>
/// <param name="hospitalGuid"></param>
/// <returns></returns>
public List<MonthKeyValue> GetChestPainPatientHistogram(string hospitalGuid)
{
List<MonthKeyValue> listModel = new List<MonthKeyValue>();
//获取月份
DateTime dt = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"));
List<string> monthList = GetMonthList(dt.AddMonths(-5).ToString(), dt.ToString());
DateTime sixstartMonth = dt.AddDays(1 - dt.Day).AddMonths(-5);
DateTime sixendMonth = dt.AddDays(1 - dt.Day).AddMonths(1);
var listmodel = db.Queryable<T_Service_Patient, T_Service_ChestPain_TreatmentInfo>((a, b) => new JoinQueryInfos(
JoinType.Left, a.GUID == b.PatientGuid)) //左连接 左链接 左联
.Where((a, b) => a.HospitalGuid == hospitalGuid && a.SystemModuleID == 2 && a.DeleteFlag == 0)
.Where((a, b) => a.CreationDate >= sixstartMonth)
.Where((a, b) => a.CreationDate < sixendMonth)
.Select((a, b) => new { a.GUID, a.CreationDate, b.CP_Diagnosis_Code })
.ToList();
for (int i = 0; i < monthList.Count(); i++)
{
MonthKeyValue monthKeyValue = new MonthKeyValue();
monthKeyValue.Month = monthList[i];
DateTime start = Convert.ToDateTime(monthList[i] + "-01");
DateTime end = Convert.ToDateTime(monthList[i] + "-01").AddMonths(1);
var oneClass = listmodel.Where(it => it.CreationDate >= start && it.CreationDate < end).ToList();
List<KeyNumber> list = new List<KeyNumber>();
KeyNumber KeyNumber1 = new KeyNumber();
KeyNumber KeyNumber2 = new KeyNumber();
KeyNumber KeyNumber3 = new KeyNumber();
KeyNumber KeyNumber4 = new KeyNumber();
KeyNumber KeyNumber5 = new KeyNumber();
KeyNumber KeyNumber6 = new KeyNumber();
KeyNumber KeyNumber7 = new KeyNumber();
KeyNumber KeyNumber8 = new KeyNumber();
KeyNumber KeyNumber9 = new KeyNumber();
KeyNumber1.key = "STEMI";
KeyNumber2.key = "NSTEMI";
KeyNumber3.key = "UA";
KeyNumber4.key = "主动脉夹层";
KeyNumber5.key = "肺动脉栓塞";
KeyNumber6.key = "非ACS心源性胸痛";
KeyNumber7.key = "其它非心源性胸痛";
KeyNumber8.key = "待查";
KeyNumber9.key = "未诊断";
if (oneClass != null && oneClass.Count > 0)
{
KeyNumber1.value = oneClass.Where(it => !SqlFunc.IsNullOrEmpty(it.CP_Diagnosis_Code) && it.CP_Diagnosis_Code == "1").Count();
KeyNumber2.value = oneClass.Where(it => !SqlFunc.IsNullOrEmpty(it.CP_Diagnosis_Code) && it.CP_Diagnosis_Code == "2").Count();
KeyNumber3.value = oneClass.Where(it => !SqlFunc.IsNullOrEmpty(it.CP_Diagnosis_Code) && it.CP_Diagnosis_Code == "3").Count();
KeyNumber4.value = oneClass.Where(it => !SqlFunc.IsNullOrEmpty(it.CP_Diagnosis_Code) && it.CP_Diagnosis_Code == "4").Count();
KeyNumber5.value = oneClass.Where(it => !SqlFunc.IsNullOrEmpty(it.CP_Diagnosis_Code) && it.CP_Diagnosis_Code == "5").Count();
KeyNumber6.value = oneClass.Where(it => !SqlFunc.IsNullOrEmpty(it.CP_Diagnosis_Code) && it.CP_Diagnosis_Code == "6").Count();
KeyNumber7.value = oneClass.Where(it => !SqlFunc.IsNullOrEmpty(it.CP_Diagnosis_Code) && it.CP_Diagnosis_Code == "7").Count();
KeyNumber8.value = oneClass.Where(it => !SqlFunc.IsNullOrEmpty(it.CP_Diagnosis_Code) && it.CP_Diagnosis_Code == "8").Count();
KeyNumber9.value = oneClass.Where(it => SqlFunc.IsNullOrEmpty(it.CP_Diagnosis_Code)).Count();
}
list.Add(KeyNumber1);
list.Add(KeyNumber2);
list.Add(KeyNumber3);
list.Add(KeyNumber4);
list.Add(KeyNumber5);
list.Add(KeyNumber6);
list.Add(KeyNumber7);
list.Add(KeyNumber8);
list.Add(KeyNumber9);
monthKeyValue.list = list;
listModel.Add(monthKeyValue);
}
return listModel;
}
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;
}
public string GetMonthZero(int month)
{
if (month < 10)
{
return "0" + month;
}
else
{
return month.ToString();
}
}
/// <summary>
/// 获取标准版报表
/// </summary>
/// <param name="hospitalGuid">所属院区编号,为空查询所有</param>
/// <param name="startDate">开始时间</param>
/// <param name="endDate">结束时间</param>
/// <param name="dataType">数据类型 -1:全部 1:已上传</param>
/// <param name="reportType">报表类型 1:月报表</param>
/// <param name="startTimeAxisID">起始时间节点编号</param>
/// <param name="endTimeAxisID">结束时间节点编号</param>
/// <param name="diffFlag">获取差异标记 1:天,2:分,3:秒</param>
/// <param name="reportName">报表名称 比如5.16,5.17</param>
/// <returns></returns>
public string GetReportStandard(string hospitalGuid, string startDate, string endDate, string dataType, string reportType, string startTimeAxisID, string endTimeAxisID, string diffFlag, string reportName)
{
try
{
DataSet dataSet = db.Ado.GetDataSetAll("EXEC Pro_ChestPain_Report_Standard @HospitalGuid,@StartDate,@EndDate,@DataType,@ReportType,@StartTimeAxisID,@EndTimeAxisID,@DiffFlag,@ReportName",
new
{
HospitalGuid = hospitalGuid,
StartDate = startDate,
EndDate = endDate,
DataType = dataType,
ReportType = reportType,
StartTimeAxisID = startTimeAxisID,
EndTimeAxisID = endTimeAxisID,
DiffFlag = diffFlag,
ReportName = reportName
});
string JsonStr = Help.DataSetToJsonStr(dataSet);
return JsonStr;
}
catch (Exception ex)
{
Help.Info(ex.Message);
return ex.Message;
}
}
/// <summary>
/// 获取基层版报表
/// </summary>
/// <param name="hospitalGuid">所属院区编号,为空查询所有</param>
/// <param name="startDate">开始时间</param>
/// <param name="endDate">结束时间</param>
/// <param name="dataType">数据类型 -1:全部 1:已上传</param>
/// <param name="reportType">报表类型 1:月报表</param>
/// <param name="startTimeAxisID">起始时间节点编号</param>
/// <param name="endTimeAxisID">结束时间节点编号</param>
/// <param name="diffFlag">获取差异标记 1:天,2:分,3:秒</param>
/// <param name="reportName">报表名称 比如5.16,5.17</param>
/// <returns></returns>
public string GetReportBasic(string hospitalGuid, string startDate, string endDate, string dataType, string reportType, string startTimeAxisID, string endTimeAxisID, string diffFlag, string reportName)
{
try
{
DataSet dataSet = db.Ado.GetDataSetAll("EXEC Pro_ChestPain_Report_Basic @HospitalGuid,@StartDate,@EndDate,@DataType,@ReportType,@StartTimeAxisID,@EndTimeAxisID,@DiffFlag,@ReportName",
new
{
HospitalGuid = hospitalGuid,
StartDate = startDate,
EndDate = endDate,
DataType = dataType,
ReportType = reportType,
StartTimeAxisID = startTimeAxisID,
EndTimeAxisID = endTimeAxisID,
DiffFlag = diffFlag,
ReportName = reportName
});
string JsonStr = Help.DataSetToJsonStr(dataSet);
return JsonStr;
}
catch (Exception ex)
{
Help.Error(ex.Message);
return ex.Message;
}
}
public List<MonthKeyValue> GetChestPainPatientDistributionHistogram(string hospitalGuid, string startTime, string endTime)
{
List<MonthKeyValue> listModel = new List<MonthKeyValue>();
//获取月份
DateTime dt = Convert.ToDateTime(startTime);
DateTime dt1 = Convert.ToDateTime(endTime);
List<string> monthList = GetMonthList(startTime, endTime);
var listmodel = db.Queryable<T_Service_Patient, T_Service_ChestPain_TreatmentInfo>((a, b) => new JoinQueryInfos(
JoinType.Left, a.GUID == b.PatientGuid)) //左连接 左链接 左联
.Where((a, b) => a.HospitalGuid == hospitalGuid && a.SystemModuleID == 2 && a.DeleteFlag == 0)
.Where((a, b) => a.CreationDate >= dt)
.Where((a, b) => a.CreationDate < dt1)
.Select((a, b) => new { a.GUID, a.CreationDate, b.CP_Diagnosis_Code })
.ToList();
for (int i = 0; i < monthList.Count(); i++)
{
MonthKeyValue monthKeyValue = new MonthKeyValue();
monthKeyValue.Month = monthList[i];
DateTime start = Convert.ToDateTime(monthList[i] + "-01");
DateTime end = Convert.ToDateTime(monthList[i] + "-01").AddMonths(1);
var oneClass = listmodel.Where(it => it.CreationDate >= start && it.CreationDate < end).ToList();
List<KeyNumber> list = new List<KeyNumber>();
KeyNumber KeyNumber1 = new KeyNumber();
KeyNumber KeyNumber2 = new KeyNumber();
KeyNumber KeyNumber3 = new KeyNumber();
KeyNumber KeyNumber4 = new KeyNumber();
KeyNumber KeyNumber5 = new KeyNumber();
KeyNumber KeyNumber6 = new KeyNumber();
KeyNumber KeyNumber7 = new KeyNumber();
KeyNumber KeyNumber8 = new KeyNumber();
KeyNumber KeyNumber9 = new KeyNumber();
KeyNumber1.key = "STEMI";
KeyNumber2.key = "NSTEMI";
KeyNumber3.key = "UA";
KeyNumber4.key = "主动脉夹层";
KeyNumber5.key = "肺动脉栓塞";
KeyNumber6.key = "非ACS心源性胸痛";
KeyNumber7.key = "其它非心源性胸痛";
KeyNumber8.key = "待查";
KeyNumber9.key = "未诊断";
if (oneClass != null && oneClass.Count > 0)
{
KeyNumber1.value = oneClass.Where(it => !SqlFunc.IsNullOrEmpty(it.CP_Diagnosis_Code) && it.CP_Diagnosis_Code == "1").Count();
KeyNumber2.value = oneClass.Where(it => !SqlFunc.IsNullOrEmpty(it.CP_Diagnosis_Code) && it.CP_Diagnosis_Code == "2").Count();
KeyNumber3.value = oneClass.Where(it => !SqlFunc.IsNullOrEmpty(it.CP_Diagnosis_Code) && it.CP_Diagnosis_Code == "3").Count();
KeyNumber4.value = oneClass.Where(it => !SqlFunc.IsNullOrEmpty(it.CP_Diagnosis_Code) && it.CP_Diagnosis_Code == "4").Count();
KeyNumber5.value = oneClass.Where(it => !SqlFunc.IsNullOrEmpty(it.CP_Diagnosis_Code) && it.CP_Diagnosis_Code == "5").Count();
KeyNumber6.value = oneClass.Where(it => !SqlFunc.IsNullOrEmpty(it.CP_Diagnosis_Code) && it.CP_Diagnosis_Code == "6").Count();
KeyNumber7.value = oneClass.Where(it => !SqlFunc.IsNullOrEmpty(it.CP_Diagnosis_Code) && it.CP_Diagnosis_Code == "7").Count();
KeyNumber8.value = oneClass.Where(it => !SqlFunc.IsNullOrEmpty(it.CP_Diagnosis_Code) && it.CP_Diagnosis_Code == "8").Count();
KeyNumber9.value = oneClass.Where(it => SqlFunc.IsNullOrEmpty(it.CP_Diagnosis_Code)).Count();
}
list.Add(KeyNumber1);
list.Add(KeyNumber2);
list.Add(KeyNumber3);
list.Add(KeyNumber4);
list.Add(KeyNumber5);
list.Add(KeyNumber6);
list.Add(KeyNumber7);
list.Add(KeyNumber8);
list.Add(KeyNumber9);
monthKeyValue.list = list;
listModel.Add(monthKeyValue);
}
return listModel;
}
}
}