AIMS/BeginScreen/PublicMethod.cs

278 lines
14 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Text;
using System.IO;
namespace BeginScreen
{
public static class PublicMethod
{
public static DateTime ServerTime()
{
string sqlStr = "select getdate() as SysDate";
DataTable dt = DBHelper.GetDataTable(sqlStr);
return DateTime.Parse(DateTime.Parse(dt.Rows[0]["SysDate"].ToString()).ToString("yyyy-MM-dd HH:mm:ss"));
}
/// <summary>
/// 根据时间查询排程公告
/// </summary>
/// <param name="dtBegin"></param>
/// <param name="dtEnd"></param>
/// <returns></returns>
public static DataTable GetPlanNoticeNew(DateTime dtBegin, DateTime dtEnd, string OpeTime, string DeptId)
{
string strSql = "select * from (select ApplyId ,OperationRoom,ApplyDepName,SickBed,PatientName,'等待手术' [State],SQState,SZState,ApplyOperationInfoName OperationInfo,OperationBeginTime,ApplyOperationDoctor OperationDoctor,applyAnesthesiaDoctor AnesthesiaDoctor,TourNurse,InstrumentNurse from [dbo].[V_OperationRecordALL] where sqstate <6 and ((OrderOperationTime >='" + dtBegin.ToString() + "' and OrderOperationTime<='" + dtEnd.ToString() + "')) union select ApplyId ,OperationRoom,ApplyDepName,SickBed,PatientName,'手术进行中'[State],SQState,SZState,OperationInfoName OperationInfo,OperationBeginTime,OperationDoctor OperationDoctor,AnesthesiaDoctor,TourNurse,InstrumentNurse from [V_OperationRecordALL] where SZstate in(1) and ((InRoomTime >='" + dtBegin.ToString() + "' and InRoomTime<='" + dtEnd.ToString() + "')) and OutRoomTime is null union select ApplyId ,OperationRoom,ApplyDepName,SickBed,PatientName,'手术结束'[State],SQState,SZState,OperationInfoName OperationInfo,OperationBeginTime,OperationDoctor OperationDoctor,AnesthesiaDoctor,TourNurse,InstrumentNurse from [V_OperationRecordALL] where datediff(minute,CONVERT(DATETIME,outRoomTime,120),GETDATE())<" + OpeTime + ") as a order by a.ApplyDepName collate Chinese_PRC_CS_AS_KS_WS,a.SQState desc,a.SZState desc";
return DBHelper.GetDataTable(strSql);
}
public static DataTable GetPlanNoticeNew1(DateTime dtBegin, DateTime dtEnd, string OpeTime, string DeptId)
{
string strSql = "select * from (select ApplyId ,OperationRoom,ApplyDepName,SickBed,PatientName,'等待手术' [State],SQState,SZState from [dbo].[V_OperationRecordALL] where sqstate <6 and ((OrderOperationTime >='" + dtBegin.ToString() + "' and OrderOperationTime<='" + dtEnd.ToString() + "')) union select ApplyId ,OperationRoom,ApplyDepName,SickBed,PatientName,'手术进行中'[State],SQState,SZState from [V_OperationRecordALL] where SZstate in(1) and ((InRoomTime >='" + dtBegin.ToString() + "' and InRoomTime<='" + dtEnd.ToString() + "')) and OutRoomTime is null union select ApplyId ,OperationRoom,ApplyDepName,SickBed,PatientName,'手术结束'[State],SQState,SZState from [V_OperationRecordALL] where datediff(minute,CONVERT(DATETIME,outRoomTime,120),GETDATE())<" + OpeTime + ") as a order by a.ApplyDepName collate Chinese_PRC_CS_AS_KS_WS,a.SQState desc,a.SZState desc";
return DBHelper.GetDataTable(strSql);
}
public static DataTable SelectPlanedOpeByRoom(string whereSql)
{
try
{
string sql = "select ApplyDepName 科室, OperationRoom.Name as 术间, PlanOrder as 台次,case CONVERT(VARCHAR(16), PlanOrder ) when 1 then '10:00' else '接台' end as 时间,PatientName as 姓名,Sex as 性别,Age as 年龄, MdrecNo as 住院号,SickBed as 床号,ApplyDiagnoseInfoName as 术前诊断,ApplyOperationInfoName as 拟施手术,OperationDoctor as 手术者,Assistant1 as 一助,Assistant2 as 二助,Assistant3 as 三助,AnaesthesiaMethodName as 拟施麻醉,AnesthesiaDoctor as 麻醉医生,InstrumentNurse as 洗手,TourNurse as 巡回 from [dbo].[V_OperationFront] left join OperationRoom on OperationRoom.Id = OperationRoomId where " + whereSql + " Order By ApplyDepName,OperationRoom.Id,PlanOrder" ;
return DBHelper.GetDataTable(sql);
}
catch (Exception)
{
return null;
}
}
public static string getMessige(string DeptId)
{
string strSql = "select top 1 Contents from NoticeContent where datediff(second,CONVERT(DATETIME,OperatorTime,120),GETDATE())<ReleaseTime order by ID desc ";// and OperatorId='" + DeptId + "'
DataTable dt = DBHelper.GetDataTable(strSql);
string messige = "";
if (dt.Rows.Count > 0)
{
messige = dt.Rows[0][0].ToString();
}
return messige;
}
/// <summary>
/// 公告显示
/// </summary>
/// <returns></returns>
public static DataRow getMessigeData(string DeptId)
{
string strSql = "select top 1 * from NoticeContent where datediff(second,CONVERT(DATETIME,OperatorTime,120),GETDATE())<ReleaseTime and OperatorId='" + DeptId + "' order by ID desc ";
DataTable dt = DBHelper.GetDataTable(strSql);
if (dt.Rows.Count > 0)
{
return dt.Rows[0];
}
else
{
return null;
}
}
public static string GetOpeStatus(DataRow dts)
{
//--0.【等待手术】 “已排程”“待访视”“已访视”
//--1.【术前准备】 点击“手术转入”
//--2.【手术进行中】 点击“手术开始”
//--3.【术后恢复】 点击“手术结束”
//--4.【离开手术室】 从点击手术结束
//--5.【转入复苏室】 麻醉恢复记录单点击“转入”
//--6.【离开手术室】 点击“转出”恢复室
string OperationRecordId = dts["OperationRecordId"].ToString();
string OpeStatus = dts["Szstate"].ToString();
string InRoomTime = dts["InRoomTime"].ToString();
string OperationBeginTime = dts["OperationBeginTime"].ToString();
string OperationEndTime = dts["OperationEndTime"].ToString();
string OutRoomTime = dts["OutRoomTime"].ToString();
string Temp = "";
if ((dts["SQstate"].ToString() == "2" && OperationRecordId == "") || (dts["SQstate"].ToString() == "1" && OperationRecordId == "" && dts["PlanOperationTime"].ToString() != "" && dts["SQOperationRoomId"].ToString() != "" && dts["APassApply"].ToString() != "0"))
{
Temp = "等待手术";
}
if (OpeStatus == "0" && InRoomTime != "" && OperationBeginTime == "" && OperationEndTime == "" && OutRoomTime == "")
{
Temp = "手术准备";
}
if (OpeStatus == "0" && InRoomTime != "" && OperationBeginTime != "" && OperationEndTime == "" && OutRoomTime == "")
{
Temp = "手术进行中";
}
if (OpeStatus == "0" && InRoomTime != "" && OperationBeginTime != "" && OperationEndTime != "" && OutRoomTime == "")
{
if (DateTime.Now < Convert.ToDateTime(OperationEndTime))
{
Temp = "手术进行中";
}
else
{
Temp = "术后恢复";
}
}
if (InRoomTime != "" && OperationBeginTime != "" && OperationEndTime != "" && OutRoomTime != "")
{
if (DateTime.Now < Convert.ToDateTime(OutRoomTime))
Temp = "术后恢复";
else
if (dts["Whereabouts"].ToString() == "病房")
{
Temp = "手术结束安返病房";
}
else if (dts["Whereabouts"].ToString() == "恢复室")
{
Temp = "手术结束转恢复室";
}
else
{
Temp = "手术结束";
}
}
if (OpeStatus == "4" && InRoomTime != "" && OutRoomTime == "")
{
Temp = "转入复苏室";
}
if (OpeStatus == "5" && InRoomTime != "" && OutRoomTime != "")
{
Temp = "离开复苏室";
}
return Temp;
}
/// <summary>
/// 将异常打印到LOG文件
/// </summary>
/// <param name="ex">异常</param>
/// <param name="LogAddress">日志文件地址</param>
public static void WriteLog(Exception ex, string LogAddress = "")
{
try
{
//如果日志文件为空则默认在Debug目录下新建 YYYY-mm-dd_Log.log文件
if (LogAddress == "")
{
LogAddress = Environment.CurrentDirectory + '\\' +
DateTime.Now.Year + '-' +
DateTime.Now.Month + '-' +
DateTime.Now.Day + "_Log.log";
}
//把异常信息输出到文件
StreamWriter sw = new StreamWriter(LogAddress, true);
sw.WriteLine("当前时间:" + DateTime.Now.ToString());
sw.WriteLine("异常信息:" + ex.Message);
sw.WriteLine("异常对象:" + ex.Source);
sw.WriteLine("调用堆栈:\n" + ex.StackTrace.Trim());
sw.WriteLine("触发方法:" + ex.TargetSite);
sw.WriteLine();
sw.Close();
}
catch (Exception)
{
return;
}
}
/// <summary>
/// 查询患者信息
/// </summary>
/// <param name="dtBegin"></param>
/// <param name="dtEnd"></param>
/// <returns></returns>
public static DataTable GetCurrentRoomPatientsInfo(int OperationRoom, string bdate)
{
// string strSql = string.Format(@" select * from (select a.OperationDoctor,
// a.Assistant1,
// a.Assistant2,
// a.Assistant3,
// a.AnesthesiaDoctor,
// a.AnesthesiaDoctorSucceed,
// a.InstrumentNurse,
// a.TourNurse,
// a.TourNurseSucceed
// from OperationRecord a
// where a.OperationRoomId ={0} and State = 0 and a.InRoomTime > '{1}') a", OperationRoom, bdate);
string strSql = string.Format(@" select * from (select [SQOperationDoctorId],[SZOperationDoctorId],
a.[SQAssistant1Id],[SZAssistant1Id],
[SQAssistant2Id],[SZAssistant2Id],
[SQAssistant3Id],[SZAssistant3Id],
[SQAnesthesiaDoctorId],[SZAnesthesiaDoctorId],
[SQInstrumentNurseId],[SZInstrumentNurseId],
[SQTourNurseId],[SZTourNurseId]
from [V_OperationRecordS] a where a.SZOperationRoomId ={0} and State = 0 and a.InRoomTime > '{1}') a", OperationRoom, bdate);
return DBHelper.GetDataTable(strSql);
}
/// <summary>
/// 根据时间查询排程公告
/// </summary>
/// <param name="dtBegin"></param>
/// <param name="dtEnd"></param>
/// <returns></returns>
public static DataTable GetOperationRoomPlan(DateTime dtBegin, DateTime dtEnd, string OpeTime, string RoomName)
{
string strSql = "select PatientName,a.Bed,sex,Age,ApplyDepartmentName,DepartmentName,SQOperation,SZOperation,a.SQDiagnose,a.SZDiagnose from (select * from V_OperationInformation where SZstate in(0) and ((InRoomTime >='" + dtBegin.ToString() + "' and InRoomTime<='" + dtEnd.ToString() + "'))) as a where a.SqOperationRoom = '" + RoomName + "' order by SqOperationRoomId asc,InRoomTime desc";
return DBHelper.GetDataTable(strSql);
}
/// <summary>
/// 查询患者信息
/// </summary>
/// <param name="dtBegin"></param>
/// <param name="dtEnd"></param>
/// <returns></returns>
public static DataTable GetCurrentRoomPatientsInfo(string sql)
{
// string strSql = string.Format(@" select
// '{0}' as 角色,w.Name,w.ElectronicSignature,bd.Name,d.Name,r.Name from Workers w
// left join BasicDictionary bd on w.JobTitleId = bd.Id
// left join Roles r on r.Id = w.RoleId
// left join Departments d on d.Id = w.DepartmentId where w.Id = {1}", RoleName, ID);
return DBHelper.GetDataTable(sql);
}
/// <summary>
/// 查询手术室信息
/// </summary>
/// <param name="dtBegin"></param>
/// <param name="dtEnd"></param>
/// <returns></returns>
public static DataTable GetRoomInfo(string Name)
{
string swl = "select Id,Name from OperationRoom where Name = '" + Name + "'";
return DBHelper.GetDataTable(swl);
}
/// <summary>
/// 查询科室
/// </summary>
/// <returns></returns>
public static DataTable GetDepartments()
{
string sql = "SELECT Id,Name,Name+'('+HelpCode+')' as NameHCode FROM Department where IsValid=1";
return DBHelper.GetDataTable(sql);
}
/// <summary>
/// 查询术者组人员
/// </summary>
/// <returns></returns>
public static DataTable GetWorkers()
{
string sql = "select top 20 Id,Name,Name+'('+No+')'+'('+HelpCode+')' as NameHCode FROM Person where IsValid = 1";
return DBHelper.GetDataTable(sql);
}
}
}