医疗文书未排程列表 点击主复制药品 剂量也复制 在空白行之上 添加多个子药往后新增行 刷新手术间台次逻辑 药品判断相同新增通路 考虑模板 通路 版本号 是否限制用药 自备药品 是否皮试
		
			
				
	
	
		
			189 lines
		
	
	
		
			10 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			189 lines
		
	
	
		
			10 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System;
 | |
| using System.Data;
 | |
| using System.Data.SqlClient;
 | |
| using System.Collections;
 | |
| using System.Collections.Generic;
 | |
| using AIMSModel;
 | |
| using AIMSObjectQuery;
 | |
| using System.Reflection;
 | |
| using System.Text;
 | |
| 
 | |
| namespace AIMSDAL
 | |
| {
 | |
|     internal partial class DOperationTemplate
 | |
|     {
 | |
|         public static bool Exists(string TemplateName, int TypeId)
 | |
|         {
 | |
|             bool Temp = false;
 | |
|             StringBuilder strSql = new StringBuilder();
 | |
|             strSql.Append("select * from OperationTemplate where TemplateName='" + TemplateName + "' and TypeId = '" + TypeId + "'");
 | |
| 
 | |
|             DataTable dt = HelperDB.DbHelperSQL.GetDataTable(strSql.ToString());
 | |
|             if (dt.Rows.Count > 0)
 | |
|             {
 | |
|                 Temp = true;
 | |
|             }
 | |
|             return Temp;
 | |
|         }
 | |
| 
 | |
|         public static void Add(OperationTemplate OperationTemplateObj)
 | |
|         {
 | |
|             StringBuilder strSql = new StringBuilder();
 | |
|             strSql.Append("insert into [OperationTemplate](");
 | |
|             strSql.Append("TemplateName,TypeId,ItemKindName,InRoomTime,ItemId,BeginTime,EndTime,Value,DosageUnit,DrugChannel,GiveDrugType,OperatorNo,OperatorName,OperateDate, IsPublic, Spare1, Spare2, Spare3, Spare4, Spare5, Spare6, Spare7, Spare8, Spare9, Spare10");
 | |
|             strSql.Append(")");
 | |
|             strSql.Append(" values (");
 | |
|             strSql.Append("'" + OperationTemplateObj.TemplateName + "',");
 | |
|             strSql.Append("" + OperationTemplateObj.TypeId + ",");
 | |
|             strSql.Append("'" + OperationTemplateObj.ItemKindName + "',");
 | |
|             strSql.Append("'" + OperationTemplateObj.InRoomTime + "',");
 | |
|             strSql.Append("" + OperationTemplateObj.ItemId + ",");
 | |
|             strSql.Append("'" + OperationTemplateObj.BeginTime + "',");
 | |
|             strSql.Append("'" + OperationTemplateObj.EndTime + "',");
 | |
|             strSql.Append("'" + OperationTemplateObj.Value + "',");
 | |
|             strSql.Append("'" + OperationTemplateObj.DosageUnit + "',");
 | |
|             strSql.Append("'" + OperationTemplateObj.DrugChannel + "',");
 | |
|             strSql.Append("'" + OperationTemplateObj.GiveDrugType + "',");
 | |
|             strSql.Append("'" + OperationTemplateObj.OperatorNo + "',");
 | |
|             strSql.Append("'" + OperationTemplateObj.OperatorName + "',");
 | |
|             strSql.Append("'" + OperationTemplateObj.OperateDate + "',");
 | |
|             strSql.Append("'" + OperationTemplateObj.IsPublic  + "',");
 | |
|             strSql.Append("'" + OperationTemplateObj.Spare1 + "',");
 | |
|             strSql.Append("'" + OperationTemplateObj.Spare2 + "',");
 | |
|             strSql.Append("'" + OperationTemplateObj.Spare3 + "',");
 | |
|             strSql.Append("'" + OperationTemplateObj.Spare4 + "',");
 | |
|             strSql.Append("'" + OperationTemplateObj.Spare5 + "',");
 | |
|             strSql.Append("'" + OperationTemplateObj.Spare6 + "',");
 | |
|             strSql.Append("'" + OperationTemplateObj.Spare7 + "',");
 | |
|             strSql.Append("'" + OperationTemplateObj.Spare8 + "',");
 | |
|             strSql.Append("'" + OperationTemplateObj.Spare9 + "',"); 
 | |
|             strSql.Append("'" + OperationTemplateObj.Spare10 + "'");
 | |
|             strSql.Append(")");
 | |
|             HelperDB.DbHelperSQL.ExecNonQuery(strSql.ToString());
 | |
|         } 
 | |
|         public static void Delete(string TemplateName, int TypeId)
 | |
|         {
 | |
|             StringBuilder strSql = new StringBuilder();
 | |
|             strSql.Append("delete OperationTemplate ");
 | |
|             strSql.Append(" where TemplateName='" + TemplateName + "' and TypeId=" + TypeId + "");
 | |
|             HelperDB.DbHelperSQL.ExecNonQuery(strSql.ToString());
 | |
|         }
 | |
| 
 | |
|         public static OperationTemplate GetModel(int Id)
 | |
|         {
 | |
|             OperationTemplate OperationTemplateObj = new OperationTemplate();
 | |
|             StringBuilder strSql = new StringBuilder();
 | |
|             strSql.Append("select  ");
 | |
|             strSql.Append("Id,TemplateName,TypeId,ItemKindName,InRoomTime,ItemId,BeginTime,EndTime,Value,DosageUnit,DrugChannel,GiveDrugType,OperatorNo,OperatorName,OperateDate, IsPublic, Spare1, Spare2, Spare3, Spare4, Spare5 , Spare6, Spare7, Spare8, Spare9 ,Spare10");
 | |
|             strSql.Append(" from OperationTemplate ");
 | |
|             strSql.Append(" where Id=" + Id + "");
 | |
|             DataSet ds = HelperDB.DbHelperSQL.GetDataSet(strSql.ToString());
 | |
|             if (ds.Tables[0].Rows.Count > 0)
 | |
|             {
 | |
|                 if (ds.Tables[0].Rows[0]["Id"].ToString() != "")
 | |
|                 {
 | |
|                     OperationTemplateObj.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
 | |
|                 }
 | |
|                 OperationTemplateObj.TemplateName = ds.Tables[0].Rows[0]["TemplateName"].ToString();
 | |
|                 if (ds.Tables[0].Rows[0]["TypeId"].ToString() != "")
 | |
|                 {
 | |
|                     OperationTemplateObj.TypeId = int.Parse(ds.Tables[0].Rows[0]["TypeId"].ToString());
 | |
|                 }
 | |
|                 OperationTemplateObj.ItemKindName = ds.Tables[0].Rows[0]["ItemKindName"].ToString();
 | |
| 
 | |
|                 if (ds.Tables[0].Rows[0]["InRoomTime"].ToString() != "")
 | |
|                 {
 | |
|                     OperationTemplateObj.InRoomTime = DateTime.Parse(ds.Tables[0].Rows[0]["InRoomTime"].ToString());
 | |
|                 }
 | |
|                 if (ds.Tables[0].Rows[0]["ItemId"].ToString() != "")
 | |
|                 {
 | |
|                     OperationTemplateObj.ItemId = int.Parse(ds.Tables[0].Rows[0]["ItemId"].ToString());
 | |
|                 }
 | |
|                 if (ds.Tables[0].Rows[0]["BeginTime"].ToString() != "")
 | |
|                 {
 | |
|                     OperationTemplateObj.BeginTime = DateTime.Parse(ds.Tables[0].Rows[0]["BeginTime"].ToString());
 | |
|                 }
 | |
|                 if (ds.Tables[0].Rows[0]["EndTime"].ToString() != "")
 | |
|                 {
 | |
|                     OperationTemplateObj.EndTime = DateTime.Parse(ds.Tables[0].Rows[0]["EndTime"].ToString());
 | |
|                 }
 | |
|                 if (ds.Tables[0].Rows[0]["Value"].ToString() != "")
 | |
|                 {
 | |
|                     OperationTemplateObj.Value = decimal.Parse(ds.Tables[0].Rows[0]["Value"].ToString());
 | |
|                 }
 | |
|                 OperationTemplateObj.DosageUnit = ds.Tables[0].Rows[0]["DosageUnit"].ToString();
 | |
|                 OperationTemplateObj.DrugChannel = ds.Tables[0].Rows[0]["DrugChannel"].ToString();
 | |
|                 OperationTemplateObj.GiveDrugType = ds.Tables[0].Rows[0]["GiveDrugType"].ToString();
 | |
|                 OperationTemplateObj.OperatorNo = ds.Tables[0].Rows[0]["OperatorNo"].ToString();
 | |
|                 OperationTemplateObj.OperatorName = ds.Tables[0].Rows[0]["OperatorName"].ToString();
 | |
|                 if (ds.Tables[0].Rows[0]["OperateDate"].ToString() != "")
 | |
|                 {
 | |
|                     OperationTemplateObj.OperateDate = DateTime.Parse(ds.Tables[0].Rows[0]["OperateDate"].ToString());
 | |
|                 }
 | |
|                 if (ds.Tables[0].Rows[0]["IsPublic"].ToString() != "")
 | |
|                 {
 | |
|                     OperationTemplateObj.IsPublic = int.Parse(ds.Tables[0].Rows[0]["IsPublic"].ToString());
 | |
|                 }
 | |
|                 OperationTemplateObj.Spare1 = ds.Tables[0].Rows[0]["Spare1"].ToString();
 | |
|                 OperationTemplateObj.Spare2 = ds.Tables[0].Rows[0]["Spare2"].ToString();
 | |
|                 OperationTemplateObj.Spare3 = ds.Tables[0].Rows[0]["Spare3"].ToString();
 | |
|                 OperationTemplateObj.Spare4 = ds.Tables[0].Rows[0]["Spare4"].ToString();
 | |
|                 OperationTemplateObj.Spare5 = ds.Tables[0].Rows[0]["Spare5"].ToString();
 | |
|                 OperationTemplateObj.Spare6 = ds.Tables[0].Rows[0]["Spare6"].ToString();
 | |
|                 OperationTemplateObj.Spare7 = ds.Tables[0].Rows[0]["Spare7"].ToString();
 | |
|                 OperationTemplateObj.Spare8 = ds.Tables[0].Rows[0]["Spare8"].ToString();
 | |
|                 OperationTemplateObj.Spare9 = ds.Tables[0].Rows[0]["Spare9"].ToString();
 | |
|                 OperationTemplateObj.Spare10 = ds.Tables[0].Rows[0]["Spare10"].ToString();
 | |
| 
 | |
|             }
 | |
|             return OperationTemplateObj;
 | |
|         }
 | |
| 
 | |
|         public static DataTable GetDataTable(int TypeId, string OpNo)
 | |
|         {
 | |
|             string strSql = "SELECT DISTINCT TemplateName,OperatorNo FROM OperationTemplate ot WHERE TypeId=" + TypeId + " and (isPublic=1 or [OperatorNo]='" + OpNo + "')";
 | |
|             return HelperDB.DbHelperSQL.GetDataTable(strSql.ToString());
 | |
| 
 | |
|         }
 | |
| 
 | |
|         public static void ClearData(int PatientId, int TypeId)
 | |
|         {
 | |
|             try
 | |
|             {
 | |
|                 HelperDB.DbHelperSQL.BeginTrans();
 | |
| 
 | |
|                 HelperDB.DbHelperSQL.ExecNonQuery("DELETE FROM FactDrug WHERE PatientId=" + PatientId + " AND  DrugTypeId=" + TypeId + " ");
 | |
|                 HelperDB.DbHelperSQL.ExecNonQuery("DELETE FROM FactEvents  WHERE EventId not in (" + GetInRoomEventId() + ")  and  PatientId=" + PatientId + " AND EventTypeId=" + TypeId + "");
 | |
|                 HelperDB.DbHelperSQL.ExecNonQuery("DELETE FROM FactOutputLiquids WHERE PatientId= " + PatientId + " AND OutputLiquidsTypeId=" + TypeId + "");
 | |
|                 HelperDB.DbHelperSQL.ExecNonQuery("DELETE FROM PhysioData WHERE PatientId=" + PatientId + " AND PhysioDataType=" + TypeId + "");
 | |
|                 HelperDB.DbHelperSQL.ExecNonQuery("DELETE FROM FactBloodGasAnalysis WHERE PatientId=" + PatientId + " AND TypeId=" + TypeId + "");
 | |
|                 HelperDB.DbHelperSQL.CommitTrans();
 | |
|             }
 | |
|             catch
 | |
|             {
 | |
|                 HelperDB.DbHelperSQL.RollbackTrans();
 | |
|             }
 | |
|         }
 | |
|         private static int GetInRoomEventId()
 | |
|         {
 | |
|             string strSql = "SELECT Id FROM Events WHERE NAME='入室' ";
 | |
|             DataTable dt = HelperDB.DbHelperSQL.GetDataTable(strSql);
 | |
| 
 | |
|             if (dt.Rows.Count > 0)
 | |
|             {
 | |
|                 return int.Parse(dt.Rows[0]["Id"].ToString());
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 return 0;
 | |
|             }
 | |
| 
 | |
|         }
 | |
|         public static DataTable GetDataTable(string TemplateName, int TypeId)
 | |
|         {
 | |
|             string strSql = "SELECT  TemplateName, ItemKindName,InRoomTime, ItemId, BeginTime, EndTime, [Value], DosageUnit,DrugChannel,GiveDrugType,[OperatorNo],[OperatorName] ,[OperateDate] ,[Ispublic],[Spare1],[Spare2],[Spare3] ,[Spare4],[Spare5],[Spare6],[Spare7],[Spare8] ,[Spare9],[Spare10]  FROM OperationTemplate ot WHERE TypeId=" + TypeId + " and  TemplateName='" + TemplateName + "'";
 | |
|             return HelperDB.DbHelperSQL.GetDataTable(strSql.ToString());
 | |
|         }
 | |
|     }
 | |
| }
 |