268 lines
20 KiB
C#
268 lines
20 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Data;
|
|
using AIMSModel;
|
|
using DrawGraph;
|
|
using AIMSDAL;
|
|
using AIMSExtension;
|
|
|
|
namespace AIMSBLL
|
|
{
|
|
public class SelectPatient
|
|
{
|
|
public static DataTable GetSelectPatientDataTable(DateTime BeginDate, string Room)
|
|
{
|
|
string strSql = "SELECT of1.ApplyId Id, of1.PatientId, of1.ApplyId, of1.ApplyDepName, of1.OperationType, of1.MdrecNo, of1.PatientName, " +
|
|
"of1.ApplyOperationInfoName, of1.OperationDoctor, " +
|
|
"of1.AnesthesiaDoctor,of1.OperationRoomId , of1.State ,of1.Sex,Age,of1.PlanOperationTime,of1.InstrumentNurse,of1.TourNurse,of1.ApplyDiagnoseInfoName,of1.OperationRoom ,of1.Contagion,of1.OrderOperationTime " +
|
|
"FROM V_OperationFront of1 WHERE of1.State in('已审核','预排程','已排程','已访视') and of1.OrderOperationTime>='" + BeginDate + "' AND of1.OrderOperationTime<'" + BeginDate.AddDays(1) + "'";
|
|
if (Room != "" && Room != "-1") strSql += " and of1.OperationRoomId='" + Room + "'";
|
|
strSql += " order by OperationRoomId,PlanOrder";
|
|
return HelperDB.DbHelperSQL.GetDataTable(strSql.ToString());
|
|
}
|
|
|
|
public static DataTable GetSelectPatientDataTable(string PatientName)
|
|
{
|
|
string strSql = "SELECT of1.ApplyId Id, of1.PatientId, of1.ApplyId, of1.ApplyDepName, of1.OperationType, of1.MdrecNo, of1.PatientName, " +
|
|
"of1.ApplyOperationInfoName, of1.OperationDoctor, " +
|
|
"of1.AnesthesiaDoctor,of1.OperationRoomId , of1.State ,of1.Sex,Age,of1.PlanOperationTime,of1.InstrumentNurse,of1.TourNurse,of1.ApplyDiagnoseInfoName,of1.OperationRoom ,of1.Contagion,of1.OrderOperationTime " +
|
|
"FROM V_OperationFront of1 WHERE of1.State in('已审核','预排程','已排程','已访视') and ( of1.MdrecNo like '%" + PatientName + "%' or of1.PatientName like '%" + PatientName + "%')";
|
|
return HelperDB.DbHelperSQL.GetDataTable(strSql.ToString());
|
|
}
|
|
|
|
public static DataTable GetRelieveLockingPatientDataTable(DateTime BeginDate, string Room)
|
|
{
|
|
string strSql = "SELECT of2.Id,of1.PatientId, of1.ApplyId, of1.ApplyDepName, of1.OperationType, of1.MdrecNo, of1.PatientName, of2.OperationInfoNames ApplyOperationInfoName, of2.OperationDoctor, of2.AnesthesiaDoctor,of2.OperationRoomId,of2.State ,of1.Sex,Age,of2.InRoomTime PlanOperationTime,of2.Nurse InstrumentNurse,of2.Nurse2 TourNurse,of2.DiagnoseInfoName ApplyDiagnoseInfoName ,of2.OperationRoom ,of1.Contagion,of1.OrderOperationTime,of2.AnaesthesiaMethodName,of2.InRoomTime FROM V_OperationDoing of2 left join[dbo].[V_OperationFront] of1 on of1.PatientId = of2.PatientId WHERE of2.State in( '手术中','手术结束','停止手术') and of2.InRoomTime >= '" + BeginDate + "' AND of2.InRoomTime<'" + BeginDate.AddDays(1) + "' and RecoverId=1";
|
|
if (Room != "" && Room != "-1") strSql += " and of1.OperationRoomId='" + Room + "'";
|
|
strSql += " order by [StateId],of2.InRoomTime ";
|
|
return HelperDB.DbHelperSQL.GetDataTable(strSql.ToString());
|
|
}
|
|
public static DataTable GetRelieveLockingPatientDataTable(string PatientName)
|
|
{
|
|
string strSql = "SELECT of2.Id,of1.PatientId, of1.ApplyId, of1.ApplyDepName, of1.OperationType, of1.MdrecNo, of1.PatientName, of2.OperationInfoNames ApplyOperationInfoName, of2.OperationDoctor, of2.AnesthesiaDoctor,of2.OperationRoomId,of2.State ,of1.Sex,Age,of2.InRoomTime PlanOperationTime,of2.Nurse InstrumentNurse,of2.Nurse2 TourNurse,of2.DiagnoseInfoName ApplyDiagnoseInfoName ,of2.OperationRoom ,of1.Contagion,of1.OrderOperationTime,of2.AnaesthesiaMethodName,of2.InRoomTime FROM V_OperationDoing of2 left join[dbo].[V_OperationFront] of1 on of1.PatientId = of2.PatientId WHERE of2.State in( '手术中','手术结束','停止手术') and RecoverId=1 and ( of1.MdrecNo like '%" + PatientName + "%' or of1.PatientName like '%" + PatientName + "%')";
|
|
strSql += " order by [StateId] asc";
|
|
return HelperDB.DbHelperSQL.GetDataTable(strSql.ToString());
|
|
}
|
|
public static DataTable GetTodayDoOpePatientDataTable(DateTime BeginDate, string Room = "")
|
|
{
|
|
string strSql = "SELECT of2.Id,of1.PatientId, of1.ApplyId, of1.ApplyDepName, of1.OperationType, of1.MdrecNo, of1.PatientName, of2.OperationInfoNames ApplyOperationInfoName, of2.OperationDoctor, of2.AnesthesiaDoctor,of2.OperationRoomId,of2.State ,of1.Sex,Age,of2.InRoomTime PlanOperationTime,of2.Nurse InstrumentNurse,of2.Nurse2 TourNurse,of2.DiagnoseInfoName ApplyDiagnoseInfoName ,of2.OperationRoom ,of1.Contagion,of1.OrderOperationTime,of2.AnaesthesiaMethodName,of2.InRoomTime FROM V_OperationDoing of2 left join[dbo].[V_OperationFront] of1 on of1.PatientId = of2.PatientId WHERE of2.State in( '手术中' ) and of2.InRoomTime >= '" + BeginDate + "' AND of2.InRoomTime<'" + BeginDate.AddDays(1) + "' and RecoverId=1 ";
|
|
if (Room != "" && Room != "-1") strSql += " and of1.OperationRoomId='" + Room + "'";
|
|
strSql += " order by [StateId] asc";
|
|
return HelperDB.DbHelperSQL.GetDataTable(strSql.ToString());
|
|
}
|
|
public static DataTable GetRecoverPatientDataTable(DateTime BeginDate)
|
|
{
|
|
string strSql = "SELECT of2.Id,of1.PatientId, of1.ApplyId, of1.ApplyDepName, of1.OperationType, of1.MdrecNo, of1.PatientName, of2.OperationInfoNames ApplyOperationInfoName, of2.OperationDoctor, of2.AnesthesiaDoctor,of2.OperationRoomId,of2.State ,of1.Sex,Age,of2.OutRoomTime ,of2.Nurse InstrumentNurse,of2.Nurse2 TourNurse,of2.DiagnoseInfoName ApplyDiagnoseInfoName ,of2.OperationRoom,of2.Whereabouts,of2.AnaesthesiaMethodName FROM V_OperationDoing of2 left join[dbo].[V_OperationFront] of1 on of1.PatientId = of2.PatientId WHERE of1.State in( '手术结束') and (of2.Pulse='PACU' OR of2.Pulse='恢复室') and of2.OutRoomTime >= '" + BeginDate + "' AND of2.OutRoomTime<'" + BeginDate.AddDays(1) + "' and RecoverId=1 and of2.Id not in (select iD from OperationRecord where RecoverId<>1)";
|
|
return HelperDB.DbHelperSQL.GetDataTable(strSql.ToString());
|
|
}
|
|
public static DataTable GetRecoverPatientOutDataTable(DateTime BeginDate, DateTime EndDate)
|
|
{
|
|
string strSql = "SELECT of2.Id,of1.PatientId, of1.ApplyId, of1.ApplyDepName, of1.OperationType, of1.MdrecNo, of1.PatientName, of2.OperationInfoNames ApplyOperationInfoName, of2.OperationDoctor, of2.AnesthesiaDoctor,of2.OperationRoomId,of2.State ,of1.Sex,Age,of2.OutRoomTime ,of2.Nurse InstrumentNurse,of2.Nurse2 TourNurse,of2.DiagnoseInfoName ApplyDiagnoseInfoName ,of2.OperationRoom,of2.AnaesthesiaMethodName FROM V_OperationDoing of2 left join[dbo].[V_OperationFront] of1 on of1.PatientId = of2.PatientId WHERE of1.State in( '麻醉复苏结束') and of2.OutRoomTime >= '" + BeginDate + "' AND of2.OutRoomTime<'" + EndDate + "' and RecoverId=2 order by OutRoomTime desc ";
|
|
return HelperDB.DbHelperSQL.GetDataTable(strSql.ToString());
|
|
}
|
|
public static DataTable GetSelectPatientDataTable(DateTime BeginDate, DateTime EndDate, bool isLoginPerson, string person, bool isEnOpe)
|
|
{
|
|
if (isEnOpe == false)
|
|
{
|
|
string strSql = "SELECT of1.PatientId, of1.ApplyId, of1.ApplyDepName, of1.OperationType, of1.MdrecNo, of1.PatientName, " +
|
|
"of1.ApplyOperationInfoName, of1.OperationDoctor, of1.State ," +
|
|
"of1.AnesthesiaDoctor,of1.OperationRoomId,of1.InstrumentNurse,of1.TourNurse,of1.OperationRoom,of1.PlanOrder " +
|
|
"FROM V_OperationFront of1 WHERE of1.OrderOperationTime>='" + BeginDate + "' AND of1.OrderOperationTime<'" + EndDate + "' ";
|
|
if (isLoginPerson == true)
|
|
{
|
|
strSql += " and (AnesthesiaDoctor like '%" + person + "%' or InstrumentNurse like '%" + person + "%' or TourNurse like '%" + person + "%')";
|
|
}
|
|
return HelperDB.DbHelperSQL.GetDataTable(strSql.ToString());
|
|
}
|
|
else
|
|
{
|
|
string strSql = "SELECT of1.PatientId, of1.ApplyId, of1.ApplyDepName, of1.OperationType, of1.MdrecNo, of1.PatientName, " +
|
|
"of1.ApplyOperationInfoName, of1.OperationDoctor, of1.State ," +
|
|
"of1.AnesthesiaDoctor,of1.OperationRoomId,of1.InstrumentNurse,of1.TourNurse,of1.OperationRoom,of1.PlanOrder,InRoomTime " +
|
|
"FROM [V_OperationRecordALL] of1 WHERE of1.OrderOperationTime>='" + BeginDate + "' AND of1.OrderOperationTime<'" + EndDate + "' and SZstate =2 ";
|
|
if (isLoginPerson == true)
|
|
{
|
|
strSql += " and (AnesthesiaDoctor like '%" + person + "%' or InstrumentNurse like '%" + person + "%' or TourNurse like '%" + person + "%')";
|
|
}
|
|
strSql += " order by convert(nvarchar(10),InRoomTime,120) desc,OperationRoomId asc,PlanOrder asc";
|
|
return HelperDB.DbHelperSQL.GetDataTable(strSql.ToString());
|
|
}
|
|
}
|
|
|
|
public static DataTable GetSelectPatientChart()
|
|
{
|
|
string strSql = "select * from (select CONVERT(nvarchar(7), InRoomTime,120) dat, SUM(ROUND((DATEDIFF(minute, InRoomTime, OutRoomTime)) / CONVERT(FLOAT, 60), 1)) AS DiffDate from OperationRecord where State=2 group by CONVERT(nvarchar(7),InRoomTime , 120) ) a order by dat Asc ";
|
|
return HelperDB.DbHelperSQL.GetDataTable(strSql.ToString());
|
|
}
|
|
public static DataTable GetSelectPatientChart2(DateTime dateTime)
|
|
{
|
|
string strSql = @"SELECT DeptName dat,COUNT(*) con FROM(SELECT dp.Name DeptName FROM OperationRecord red left join OperationApply oa on oa.Id=red.OperationApplyId
|
|
left join Department dp on dp.Id=oa.ApplyDepId WHERE CONVERT(nvarchar(7), InRoomTime, 120)='" + dateTime.ToString("yyyy-MM") + "' And red.[State] = 2 ) temp GROUP BY DeptName ";
|
|
return HelperDB.DbHelperSQL.GetDataTable(strSql.ToString());
|
|
}
|
|
|
|
public static DataTable GetRecoverLockingPatientDataTable(DateTime BeginDate)
|
|
{
|
|
string strSql = "SELECT of2.Id,of1.PatientId, of1.ApplyId, of1.ApplyDepName, of1.OperationType, of1.MdrecNo, of1.PatientName, of2.OperationInfoNames ApplyOperationInfoName, of2.OperationDoctor, of2.AnesthesiaDoctor,of2.OperationRoomId,of2.State ,of1.Sex,Age,of2.InRoomTime,of2.Nurse InstrumentNurse,of2.Nurse2 TourNurse,of2.DiagnoseInfoName ApplyDiagnoseInfoName ,of2.OperationRoom,(select OutRoomTime from OperationRecord where OperationRecord.RecoverId=1 and OperationRecord.PatientId=of2.PatientId) OutRoomTime,of2.AnaesthesiaMethodName FROM V_OperationDoing of2 left join[dbo].[V_OperationFront] of1 on of1.PatientId = of2.PatientId WHERE of2.State in( '麻醉复苏中') and of2.InRoomTime >= '" + BeginDate + "' AND of2.InRoomTime<'" + BeginDate.AddDays(1) + "' and RecoverId=2 ";
|
|
strSql += " order by [StateId] asc";
|
|
return HelperDB.DbHelperSQL.GetDataTable(strSql.ToString());
|
|
}
|
|
|
|
|
|
public static void UpdateApplyState(int PatientId, int ApplyId)
|
|
{
|
|
try
|
|
{
|
|
HelperDB.DbHelperSQL.BeginTrans();
|
|
BOperationApply.UpdateApplyState(ApplyId, 6); //修改状态为手术中
|
|
|
|
//手术诊断
|
|
List<int> ApplyDiagnoseIdList = BApplyDiagnoseInfo.GetApplyDiagnoseIdList(ApplyId);
|
|
for (int i = 0; i < ApplyDiagnoseIdList.Count; i++)
|
|
{
|
|
FactDiagnoseInfo FactDiagnoseInfoObj = new FactDiagnoseInfo();
|
|
FactDiagnoseInfoObj.PatientId = PatientId;
|
|
FactDiagnoseInfoObj.ApplyId = ApplyId;
|
|
FactDiagnoseInfoObj.DiagnoseId = ApplyDiagnoseIdList[i];
|
|
FactDiagnoseInfoObj.OperatorNo = AIMSExtension.PublicMethod.OperatorNo;
|
|
FactDiagnoseInfoObj.OperatorName = AIMSExtension.PublicMethod.OperatorName;
|
|
FactDiagnoseInfoObj.OperateDate = AIMSExtension.PublicMethod.SystemDate();
|
|
BFactDiagnoseInfo.Add(FactDiagnoseInfoObj);
|
|
}
|
|
//实施手术
|
|
List<ApplyOperationInfo> ApplyOperationInfoList = BApplyOperationInfo.GetApplyOperationIdList(ApplyId);
|
|
for (int i = 0; i < ApplyOperationInfoList.Count; i++)
|
|
{
|
|
FactOperationInfo FactOperationInfoObj = new FactOperationInfo();
|
|
FactOperationInfoObj.PatientId = PatientId;
|
|
FactOperationInfoObj.ApplyId = ApplyId;
|
|
FactOperationInfoObj.OperationId = ApplyOperationInfoList[i].OperationId.Value;
|
|
FactOperationInfoObj.OperationName = ApplyOperationInfoList[i].OperationName;
|
|
FactOperationInfoObj.LeftRemark = ApplyOperationInfoList[i].LeftRemark;
|
|
FactOperationInfoObj.RightRemark = ApplyOperationInfoList[i].RightRemark;
|
|
FactOperationInfoObj.OperatorNo = AIMSExtension.PublicMethod.OperatorNo;
|
|
FactOperationInfoObj.OperatorName = AIMSExtension.PublicMethod.OperatorName;
|
|
FactOperationInfoObj.OperateDate = AIMSExtension.PublicMethod.SystemDate();
|
|
BFactOperationInfo.Add(FactOperationInfoObj);
|
|
}
|
|
////实施麻醉
|
|
//List<int> ApplyAnaesthesiaMethodList = BApplyAnaesthesiaMethod.GetApplyAnaesthesiaMethodList(ApplyId);
|
|
//for (int i = 0; i < ApplyAnaesthesiaMethodList.Count; i++)
|
|
//{
|
|
// FactAnaesthesiaMethod FactAnaesthesiaMethodObj = new FactAnaesthesiaMethod();
|
|
// FactAnaesthesiaMethodObj.PatientId = PatientId;
|
|
// FactAnaesthesiaMethodObj.ApplyId = ApplyId;
|
|
// FactAnaesthesiaMethodObj.AnaesthesiaMethodId = ApplyAnaesthesiaMethodList[i];
|
|
// FactAnaesthesiaMethodObj.OperatorNo = AIMSExtension.PublicMethod.OperatorNo;
|
|
// FactAnaesthesiaMethodObj.OperatorName = AIMSExtension.PublicMethod.OperatorName;
|
|
// FactAnaesthesiaMethodObj.OperateDate = AIMSExtension.PublicMethod.SystemDate();
|
|
// BFactAnaesthesiaMethod.Add(FactAnaesthesiaMethodObj);
|
|
//}
|
|
|
|
//手术部位
|
|
List<int> ApplyOperationPositionList = BApplyOperationPosition.GetApplyOperationPositionIdList(ApplyId);
|
|
for (int i = 0; i < ApplyOperationPositionList.Count; i++)
|
|
{
|
|
FactOperationPosition FactOperationPositionObj = new FactOperationPosition();
|
|
FactOperationPositionObj.PatientId = PatientId;
|
|
FactOperationPositionObj.ApplyId = ApplyId;
|
|
FactOperationPositionObj.OperationPositionId = ApplyOperationPositionList[i];
|
|
FactOperationPositionObj.OperatorNo = AIMSExtension.PublicMethod.OperatorNo;
|
|
FactOperationPositionObj.OperatorName = AIMSExtension.PublicMethod.OperatorName;
|
|
FactOperationPositionObj.OperateDate = AIMSExtension.PublicMethod.SystemDate();
|
|
BFactOperationPosition.Add(FactOperationPositionObj);
|
|
}
|
|
|
|
//手术切口
|
|
List<int> ApplyOperationCutTypeList = BApplyOperationCutType.GetApplyOperationCutTypeIdList(ApplyId);
|
|
for (int i = 0; i < ApplyOperationCutTypeList.Count; i++)
|
|
{
|
|
FactOperationCutType FactOperationCutTypeObj = new FactOperationCutType();
|
|
FactOperationCutTypeObj.PatientId = PatientId;
|
|
FactOperationCutTypeObj.ApplyId = ApplyId;
|
|
FactOperationCutTypeObj.OperationCutTypeId = ApplyOperationCutTypeList[i];
|
|
FactOperationCutTypeObj.OperatorNo = AIMSExtension.PublicMethod.OperatorNo;
|
|
FactOperationCutTypeObj.OperatorName = AIMSExtension.PublicMethod.OperatorName;
|
|
FactOperationCutTypeObj.OperateDate = AIMSExtension.PublicMethod.SystemDate();
|
|
BFactOperationCutType.Add(FactOperationCutTypeObj);
|
|
}
|
|
//医生信息
|
|
|
|
DataTable dt = BApplyPersonDuty.GetPersonDataTable(ApplyId);
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
{
|
|
if (int.Parse(dt.Rows[i]["PersonDutyId"].ToString()) != 2)
|
|
{
|
|
FactPersonDuty FactPersonDutyObj = new FactPersonDuty();
|
|
FactPersonDutyObj.PatientId = PatientId;
|
|
FactPersonDutyObj.ApplyId = ApplyId;
|
|
FactPersonDutyObj.PersonDutyId = int.Parse(dt.Rows[i]["PersonDutyId"].ToString());
|
|
FactPersonDutyObj.PersonId = int.Parse(dt.Rows[i]["PersonId"].ToString());
|
|
FactPersonDutyObj.OperatorNo = AIMSExtension.PublicMethod.OperatorNo;
|
|
FactPersonDutyObj.OperatorName = AIMSExtension.PublicMethod.OperatorName;
|
|
FactPersonDutyObj.OperateDate = AIMSExtension.PublicMethod.SystemDate();
|
|
BFactPersonDuty.Add(FactPersonDutyObj);
|
|
}
|
|
}
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
{
|
|
if (int.Parse(dt.Rows[i]["PersonDutyId"].ToString()) == 2)
|
|
{
|
|
FactPersonDuty FactPersonDutyObj = new FactPersonDuty();
|
|
FactPersonDutyObj.PatientId = PatientId;
|
|
FactPersonDutyObj.ApplyId = ApplyId;
|
|
FactPersonDutyObj.PersonDutyId = 1;
|
|
FactPersonDutyObj.PersonId = int.Parse(dt.Rows[i]["PersonId"].ToString());
|
|
FactPersonDutyObj.OperatorNo = AIMSExtension.PublicMethod.OperatorNo;
|
|
FactPersonDutyObj.OperatorName = AIMSExtension.PublicMethod.OperatorName;
|
|
FactPersonDutyObj.OperateDate = AIMSExtension.PublicMethod.SystemDate();
|
|
BFactPersonDuty.Add(FactPersonDutyObj);
|
|
}
|
|
}
|
|
|
|
if (PublicMethod.GetHospitalName().Contains("金州"))
|
|
{
|
|
FactPersonDuty FactPersonDutyObj = new FactPersonDuty();
|
|
FactPersonDutyObj.PatientId = PatientId;
|
|
FactPersonDutyObj.ApplyId = ApplyId;
|
|
FactPersonDutyObj.PersonDutyId = 11;
|
|
FactPersonDutyObj.PersonId = 6805;
|
|
FactPersonDutyObj.OperatorNo = AIMSExtension.PublicMethod.OperatorNo;
|
|
FactPersonDutyObj.OperatorName = AIMSExtension.PublicMethod.OperatorName;
|
|
FactPersonDutyObj.OperateDate = AIMSExtension.PublicMethod.SystemDate();
|
|
BFactPersonDuty.Add(FactPersonDutyObj);
|
|
}
|
|
//增加入室事件
|
|
Events EventsObj = BEvents.GetModelByName("入室");
|
|
|
|
if (EventsObj.Name != null)
|
|
{
|
|
FactEvents FactEventsObj = new FactEvents();
|
|
FactEventsObj.EventId = EventsObj.Id;
|
|
FactEventsObj.EventTypeId = 1;
|
|
FactEventsObj.EventBeginTime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd HH:mm:00"));
|
|
FactEventsObj.EventEndTime = FactEventsObj.EventBeginTime;
|
|
FactEventsObj.IsContinue = 0;
|
|
FactEventsObj.PatientId = PatientId;
|
|
FactEventsObj.OperatorNo = AIMSExtension.PublicMethod.OperatorNo;
|
|
FactEventsObj.OperatorName = AIMSExtension.PublicMethod.OperatorName;
|
|
FactEventsObj.OperateDate = AIMSExtension.PublicMethod.SystemDate();
|
|
|
|
BFactEvents.Add(FactEventsObj);
|
|
}
|
|
|
|
|
|
|
|
HelperDB.DbHelperSQL.CommitTrans();
|
|
|
|
}
|
|
catch
|
|
{
|
|
HelperDB.DbHelperSQL.RollbackTrans();
|
|
}
|
|
}
|
|
}
|
|
}
|