163 lines
12 KiB
C#
163 lines
12 KiB
C#
using AIMSModel;
|
|
using DrawGraph;
|
|
using System;
|
|
using System.Data;
|
|
using System.Text;
|
|
|
|
namespace AIMSDAL
|
|
{
|
|
internal partial class DOperationRecord
|
|
{
|
|
public static int AddTitleTime(int PatientId, int ApplyId, int RecoverId, string TableColumnName, DateTime Time, int RoomId)
|
|
{
|
|
string strSql = "INSERT INTO OperationRecord(PatientId,OperationApplyId,RecoverId," + TableColumnName + ",OperatorNo,OperatorName,OperateDate,RoomId)" +
|
|
"VALUES (" + PatientId + "," + ApplyId + "," + RecoverId + ",'" + Time + "','" + AIMSExtension.PublicMethod.OperatorNo + "','"
|
|
+ AIMSExtension.PublicMethod.OperatorName + "','" + AIMSExtension.PublicMethod.SystemDate() + "','" + RoomId + "');select @@identity ";
|
|
return Convert.ToInt32(HelperDB.DbHelperSQL.ExecNonQuery(strSql));
|
|
;
|
|
}
|
|
|
|
public static void UpdateTitleTime(int PatientId, string TableColumnName, DateTime Time)
|
|
{
|
|
string strSql = "Update OperationRecord Set " + TableColumnName + "='" + Time.ToString("yyyy-MM-dd HH:mm:ss") +
|
|
"',OperatorNo='" + AIMSExtension.PublicMethod.OperatorNo +
|
|
"',OperatorName='" + AIMSExtension.PublicMethod.OperatorName + "' WHERE PatientId=" + PatientId + "";
|
|
HelperDB.DbHelperSQL.ExecNonQuery(strSql);
|
|
}
|
|
|
|
public static TitleTime GetTitleTime(int PatientId, int RecoverId)
|
|
{
|
|
TitleTime TitleTimeObj = new TitleTime();
|
|
string strSql = "SELECT OperationApplyId, InRoomTime, OutRoomTime, OperationBeginTime,OperationEndTime " +
|
|
"FROM OperationRecord WHERE PatientId='" + PatientId + "' and RecoverId='" + RecoverId + "'";
|
|
|
|
DataTable dt = HelperDB.DbHelperSQL.GetDataTable(strSql);
|
|
|
|
if (dt.Rows.Count > 0)
|
|
{
|
|
if (dt.Rows[0]["OperationApplyId"].ToString() != "")
|
|
{
|
|
TitleTimeObj.OperationApplyId = int.Parse(dt.Rows[0]["OperationApplyId"].ToString());
|
|
}
|
|
|
|
if (dt.Rows[0]["InRoomTime"].ToString() != "")
|
|
{
|
|
TitleTimeObj.InRoomTime = DateTime.Parse(DateTime.Parse(dt.Rows[0]["InRoomTime"].ToString()).ToString("yyyy-MM-dd HH:mm:ss"));
|
|
}
|
|
|
|
if (dt.Rows[0]["OutRoomTime"].ToString() != "")
|
|
{
|
|
TitleTimeObj.OutRoomTime = DateTime.Parse(dt.Rows[0]["OutRoomTime"].ToString());
|
|
}
|
|
if (dt.Rows[0]["OperationBeginTime"].ToString() != "")
|
|
{
|
|
TitleTimeObj.OperationBeginTime = DateTime.Parse(dt.Rows[0]["OperationBeginTime"].ToString());
|
|
}
|
|
if (dt.Rows[0]["OperationEndTime"].ToString() != "")
|
|
{
|
|
TitleTimeObj.OperationEndTime = DateTime.Parse(dt.Rows[0]["OperationEndTime"].ToString());
|
|
}
|
|
|
|
}
|
|
return TitleTimeObj;
|
|
}
|
|
|
|
|
|
public static DataTable GetOperationDoingMainInfo(int PatientId, int TypeId)
|
|
{
|
|
string strSql = "SELECT od.Id,od.PatientId, od.ApplyId,(SELECT TOP 1 fe.EventBeginTime FROM FactEvents fe LEFT JOIN Events e ON e.Id =fe.EventId WHERE e.Name='入室' and PatientId=" + PatientId + " and EventTypeId=" + TypeId + " ) as InRoomTime,"
|
|
+ "(SELECT TOP 1 fe.EventBeginTime FROM FactEvents fe LEFT JOIN Events e ON e.Id =fe.EventId WHERE e.Name='出室' and PatientId=" + PatientId + " and EventTypeId=" + TypeId + " ) as OutRoomTime, "
|
|
+ "(SELECT TOP 1 fe.EventBeginTime FROM FactEvents fe LEFT JOIN Events e ON e.Id =fe.EventId WHERE e.Name='手术开始' and PatientId=" + PatientId + " and EventTypeId=" + TypeId + " ) as OperationBeginTime, "
|
|
+ "(SELECT TOP 1 fe.EventBeginTime FROM FactEvents fe LEFT JOIN Events e ON e.Id =fe.EventId WHERE e.Name='手术结束' and PatientId=" + PatientId + " and EventTypeId=" + TypeId + " ) as OperationEndTime, " +
|
|
" od.DiagnoseInfoName, od.OperationInfoName,od.AnaesthesiaMethodName, od.OperationCutTypeName," +
|
|
"od.OperationBodyPositionName, od.OperationPositionName, od.OperationDoctor,od.Assistant, od.AnesthesiaDoctor, od.Nurse,od.Nurse2," +
|
|
"od.OperatorNo,od.OperatorName,od.OperateDate,od.State,OperationDoctorId ,[AssistantId] ,[AnesthesiaDoctorId] ,[InstrumentNurseId],[TourNurseId],DiagnoseInfoId,OperationInfoId,AnaesthesiaMethodId,OrtherDoctor,OrtherDoctorId,OperationPositionId,OperationBodyPositionId,ASALevel,SpecialCase,Fasting,BloodType FROM V_OperationDoing od WHERE od.PatientId=" + PatientId + " and od.RecoverId='" + TypeId + "'";
|
|
return HelperDB.DbHelperSQL.GetDataTable(strSql);
|
|
}
|
|
|
|
public static void UpdateState(int PatientId, int TypeId, int State)
|
|
{
|
|
string strSql = "UPDATE OperationRecord SET " + (State == 1 ? " OutRoomTime=null, " : "") + " [State] = " + State +
|
|
",OperatorNo = '" + AIMSExtension.PublicMethod.OperatorNo +
|
|
"',OperatorName = '" + AIMSExtension.PublicMethod.OperatorName +
|
|
"',OperateDate = '" + AIMSExtension.PublicMethod.SystemDate() +
|
|
"' WHERE PatientId=" + PatientId + " and RecoverId='" + TypeId + "'";
|
|
HelperDB.DbHelperSQL.ExecNonQuery(strSql.ToString());
|
|
}
|
|
|
|
public static void DeleteOperationRecordData(int RecorId, int PatientId, int TypeId)
|
|
{
|
|
HelperDB.DbHelperSQL.ExecNonQuery("DELETE FROM FactAnaesthesiaMethod WHERE PatientId=" + PatientId + "");
|
|
HelperDB.DbHelperSQL.ExecNonQuery("DELETE FROM FactBloodGasAnalysis WHERE OperationRecordId=" + RecorId + "");
|
|
HelperDB.DbHelperSQL.ExecNonQuery("DELETE FROM FactDiagnoseInfo WHERE PatientId=" + PatientId + "");
|
|
HelperDB.DbHelperSQL.ExecNonQuery("DELETE FROM FactDrug WHERE DrugTypeId=" + TypeId + " and PatientId=" + PatientId + "");
|
|
HelperDB.DbHelperSQL.ExecNonQuery("DELETE FROM FactEvents WHERE EventTypeId=" + TypeId + " and PatientId=" + PatientId + "");
|
|
HelperDB.DbHelperSQL.ExecNonQuery("DELETE FROM FactOperationBodyPosition WHERE PatientId=" + PatientId + "");
|
|
HelperDB.DbHelperSQL.ExecNonQuery("DELETE FROM FactOperationCutType WHERE PatientId=" + PatientId + "");
|
|
HelperDB.DbHelperSQL.ExecNonQuery("DELETE FROM FactOperationInfo WHERE PatientId=" + PatientId + "");
|
|
HelperDB.DbHelperSQL.ExecNonQuery("DELETE FROM FactOperationPosition WHERE PatientId=" + PatientId + "");
|
|
HelperDB.DbHelperSQL.ExecNonQuery("DELETE FROM FactOutputLiquids WHERE OutputLiquidsTypeId=" + TypeId + " and PatientId=" + PatientId + "");
|
|
HelperDB.DbHelperSQL.ExecNonQuery("DELETE FROM FactPersonDuty WHERE PatientId=" + PatientId + " and PersonDutyId=" + TypeId + "");
|
|
HelperDB.DbHelperSQL.ExecNonQuery("DELETE FROM OperationRecordInfo WHERE OperationRecordId=" + RecorId);
|
|
HelperDB.DbHelperSQL.ExecNonQuery("DELETE FROM PhysioData WHERE PatientId =" + RecorId);
|
|
HelperDB.DbHelperSQL.ExecNonQuery("DELETE FROM OperationRecord WHERE id=" + RecorId);
|
|
}
|
|
public static void DeleteOperationRecorvreData(int PatientId, int TypeId)
|
|
{
|
|
HelperDB.DbHelperSQL.ExecNonQuery("DELETE FROM FactDrug WHERE DrugTypeId=" + TypeId + " and PatientId=" + PatientId + "");
|
|
HelperDB.DbHelperSQL.ExecNonQuery("DELETE FROM FactEvents WHERE EventTypeId=" + TypeId + " and PatientId=" + PatientId + "");
|
|
HelperDB.DbHelperSQL.ExecNonQuery("DELETE FROM FactOutputLiquids WHERE OutputLiquidsTypeId=" + TypeId + " and PatientId=" + PatientId + "");
|
|
HelperDB.DbHelperSQL.ExecNonQuery("DELETE FROM FactPersonDuty WHERE PatientId=" + PatientId + " and PersonDutyId=" + TypeId + "");
|
|
HelperDB.DbHelperSQL.ExecNonQuery("DELETE FROM OperationRecord WHERE PatientId=" + PatientId + " and RecoverId=" + TypeId + "");
|
|
}
|
|
public static void DeleteEvent(int PatientId, int EventId)
|
|
{
|
|
HelperDB.DbHelperSQL.ExecNonQuery("DELETE FROM FactEvents WHERE EventTypeId=1 and EventId =" + EventId + " and PatientId=" + PatientId + "");
|
|
}
|
|
|
|
public static 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 static 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 static 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 static 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());
|
|
}
|
|
}
|
|
}
|