AIMS/AIMS/OperationDoing/AnasRecordBill/DAL/FillAnasRecordBillDataDB.cs
2022-08-23 21:12:59 +08:00

55 lines
3.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
namespace AIMS.OperationDoing.AnasRecordBill.DAL
{
public class FillAnasRecordBillDataDB
{
public DataTable FillDrugData(int PatientId, int DrugTypeId)
{
string strSql = " SELECT fd.Id,d.Id as DrugsId, d.Name AS DrugName ,fd.IsContinue,fd.Dosage,fd.DosageUnit,fd.DrugBeginTime, fd.DrugEndTime,fd.DrugChannel,fd.GiveDrugType,fd.Remark,d.DrugKind,[Density],[DensityUnit],[Velocity],[VelocityUnit],[BloodType] ,fd.[OperatorNo],fd.[OperatorName],fd.[OperateDate],fd.ParentId FROM FactDrug fd " +
"LEFT JOIN Drugs d ON d.Id = fd.DrugId " +
"WHERE fd.PatientId=" + PatientId + " AND fd.DrugTypeId=" + DrugTypeId + " ";
return HelperDB.DbHelperSQL.GetDataTable(strSql.ToString());
}
public DataTable FillOutFluid(int PatientId, int DrugTypeId)
{
string strSql = "SELECT fol.Id, fol.OutputLiquidsId,ol.Name AS OutputLiquidsName, fol.BeginTime, fol.EndTime, fol.Dosage, fol.DosageUnit,fol.Remark " +
"FROM FactOutputLiquids fol " +
"LEFT JOIN OutputLiquids ol ON ol.Id = fol.OutputLiquidsId " +
"WHERE fol.PatientId=" + PatientId + " AND fol.OutputLiquidsTypeId=" + DrugTypeId + " ";
return HelperDB.DbHelperSQL.GetDataTable(strSql.ToString());
}
public DateTime GetMaxTime(int PatientId, int TypeId)
{
string strSql = "SELECT ISNULL(MAX(A.MaxTime),GETDATE()) MaxTime FROM ( " +
"SELECT fd.DrugEndTime AS MaxTime FROM FactDrug fd WHERE fd.DrugTypeId=" + TypeId + " and fd.PatientId=" + PatientId + " " +
"UNION ALL " +
"SELECT fe.EventEndTime AS MaxTime FROM FactEvents fe LEFT JOIN Events e ON e.Id =fe.EventId WHERE fe.EventTypeId=" + TypeId + " and fe.PatientId=" + PatientId + " " +
"UNION ALL " +
"SELECT fol.EndTime AS MaxTime FROM FactOutputLiquids fol WHERE fol.OutputLiquidsTypeId=" + TypeId + " and fol.PatientId=" + PatientId + " )A ";
DataTable dt = HelperDB.DbHelperSQL.GetDataTable(strSql);
return DateTime.Parse(dt.Rows[0]["MaxTime"].ToString());
}
public int GetDataCount(int RecorId,int PatientId, int TypeId)
{
string strSql = "SELECT SUM(A.RowCounts) AS RowCounts FROM ( " +
"SELECT COUNT(*) AS RowCounts FROM FactDrug fd WHERE fd.DrugTypeId =" + TypeId + " and fd.PatientId=" + PatientId + " UNION ALL " +
"SELECT COUNT(*) AS RowCounts FROM FactEvents fe WHERE fe.EventTypeId=" + TypeId + " and fe.PatientId=" + PatientId + " and EventId<>7 UNION ALL " +
"SELECT COUNT(*) AS RowCounts FROM FactOutputLiquids fol WHERE OutputLiquidsTypeId=" + TypeId + " and fol.PatientId=" + PatientId + " UNION ALL " +
"SELECT COUNT(*) AS RowCounts FROM FactBloodGasAnalysis fol WHERE OperationRecordId=" + RecorId + " )A ";
DataTable dt = HelperDB.DbHelperSQL.GetDataTable(strSql);
return int.Parse(dt.Rows[0]["RowCounts"].ToString());
}
}
}