777 lines
		
	
	
		
			38 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			777 lines
		
	
	
		
			38 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using AIMSExtension;
 | |
| using HelperDB;
 | |
| using System;
 | |
| using System.Collections.Generic;
 | |
| using System.Data;
 | |
| using System.Linq;
 | |
| using System.Net;
 | |
| using System.Text;
 | |
| 
 | |
| namespace DrawGraph
 | |
| {
 | |
|     public class DBManage
 | |
|     {
 | |
|         public static DataTable GetDictDataTable(OperationRecord OpeRecord, string HelpCode, string _title, string PersonType, string SelPerson)
 | |
|         {
 | |
|             string strSql = "";
 | |
|             switch (_title)
 | |
|             {
 | |
|                 case "人员":
 | |
|                     if (PersonType == "0")
 | |
|                     {
 | |
|                         strSql = "SELECT top 20 p.Id,p.Name,p.No Code FROM Person p WHERE p.IsValid=1  AND p.PersonType ='医生' ";
 | |
|                         if (HelpCode != "") strSql += " AND (p.Name LIKE '%" + HelpCode + "%' OR p.HelpCode LIKE '%" + HelpCode + "%' OR p.No LIKE '%" + HelpCode + "%')";
 | |
|                         if (HelpCode == "" && OpeRecord.DepartmentId != null) strSql += " AND p.DepId='" + OpeRecord.DepartmentId + "' ";
 | |
|                         if (SelPerson != "") strSql += " AND p.Id not in (" + SelPerson + ") ";
 | |
|                         strSql += " ORDER BY p.HelpCode ASC ";
 | |
|                     }
 | |
|                     else if (PersonType == "1")
 | |
|                     {
 | |
|                         strSql = "SELECT top 20 p.Id,p.Name,p.No Code FROM Person p WHERE p.IsValid=1  AND p.PersonType  like '%护士%' AND (p.Name LIKE '%" + HelpCode + "%' OR p.HelpCode LIKE '%" + HelpCode + "%' OR p.No LIKE '%" + HelpCode + "%')";
 | |
|                         if (SelPerson != "") strSql += " AND p.Id not in (" + SelPerson + ") ";
 | |
|                         strSql += " order by PersonOrder asc";
 | |
|                     }
 | |
|                     else if (PersonType == "2")
 | |
|                     {
 | |
|                         strSql = "SELECT top 20 p.Id,p.Name,p.No Code FROM Person p WHERE p.IsValid=1  AND p.PersonType ='麻醉医生' AND (p.Name LIKE '%" + HelpCode + "%' OR p.HelpCode LIKE '%" + HelpCode + "%' OR p.No LIKE '%" + HelpCode + "%')";
 | |
|                         if (SelPerson != "") strSql += " AND p.Id not in (" + SelPerson + ") ";
 | |
|                         strSql += " order by PersonOrder asc";
 | |
|                     }
 | |
|                     else if (PersonType == "3")
 | |
|                     {
 | |
|                         strSql = "SELECT top 20 p.Id,p.Name,p.No Code FROM Person p WHERE p.IsValid=1  AND p.PersonType ='手术室护士' AND (p.Name LIKE '%" + HelpCode + "%' OR p.HelpCode LIKE '%" + HelpCode + "%' OR p.No LIKE '%" + HelpCode + "%')";
 | |
|                         if (SelPerson != "") strSql += " AND p.Id not in (" + SelPerson + ") ";
 | |
|                         strSql += " order by PersonOrder asc";
 | |
|                     }
 | |
|                     else if (PersonType == "4")
 | |
|                     {
 | |
|                         strSql = "SELECT top 20 p.Id,p.Name,p.No Code FROM Person p WHERE p.IsValid=1  AND p.PersonType ='麻醉护士' AND (p.Name LIKE '%" + HelpCode + "%' OR p.HelpCode LIKE '%" + HelpCode + "%' OR p.No LIKE '%" + HelpCode + "%')";
 | |
|                         if (SelPerson != "") strSql += " AND p.Id not in (" + SelPerson + ") ";
 | |
|                         strSql += " order by PersonOrder asc";
 | |
|                     } 
 | |
|                     break;
 | |
|                 case "手术":
 | |
|                     strSql = "SELECT top 20 p.Id,p.Name,p.IcdCode Code FROM Operation p WHERE p.IsValid=1  AND (p.Name LIKE '%" + HelpCode + "%' OR p.HelpCode LIKE '%" + HelpCode + "%' OR p.IcdCode LIKE '%" + HelpCode + "%')";
 | |
|                     if (SelPerson != "") strSql += " AND p.Id not in (" + SelPerson + ") ";
 | |
|                     strSql += " order by UseRate desc";
 | |
|                     break;
 | |
|                 case "诊断":
 | |
|                     strSql = "SELECT top 20 p.Id,p.Name,p.IcdCode Code FROM Disease p WHERE p.IsValid=1  AND (p.Name LIKE '%" + HelpCode + "%' OR p.HelpCode LIKE '%" + HelpCode + "%' OR p.IcdCode LIKE '%" + HelpCode + "%')";
 | |
|                     if (SelPerson != "") strSql += " AND p.Id not in (" + SelPerson + ") ";
 | |
|                     strSql += " order by UseRate desc";
 | |
|                     break;
 | |
|                 case "麻醉方式":
 | |
|                     strSql = "SELECT p.Id,p.Name,p.Explain Code FROM AnaesthesiaMethod p WHERE p.IsValid=1  AND (p.Name LIKE '%" + HelpCode + "%' OR p.HelpCode LIKE '%" + HelpCode + "%' )";
 | |
|                     if (SelPerson != "") strSql += " AND p.Id not in (" + SelPerson + ") ";
 | |
|                     strSql += " order by UseRate asc";
 | |
|                     break;
 | |
|                 case "手术体位":
 | |
|                     strSql = "SELECT top 30 p.Id,p.Name,p.Explain Code FROM OperationBodyPosition p WHERE p.IsValid=1  AND (p.Name LIKE '%" + HelpCode + "%' OR p.HelpCode LIKE '%" + HelpCode + "%' )";
 | |
|                     if (SelPerson != "") strSql += " AND p.Id not in (" + SelPerson + ") ";
 | |
|                     strSql += " order by PositionOrder asc";
 | |
|                     break;
 | |
|                 case "手术部位":
 | |
|                     strSql = "SELECT top 20 p.Id,p.Name,p.Explain Code FROM OperationPosition p WHERE p.IsValid=1  AND (p.Name LIKE '%" + HelpCode + "%' OR p.HelpCode LIKE '%" + HelpCode + "%' )";
 | |
|                     if (SelPerson != "") strSql += " AND p.Id not in (" + SelPerson + ") ";
 | |
|                     strSql += " order by PositionOrder asc";
 | |
|                     break;
 | |
|                 default:
 | |
|                     strSql = "SELECT top 30 p.Id,p.Name,p.Remark Code FROM BasicDictionary p WHERE p.IsValid=1 and ParentId in(select Id from BasicDictionary where Name='" + _title + "') AND (p.Name LIKE '%" + HelpCode + "%' OR p.HelpCode LIKE '%" + HelpCode + "%' )";
 | |
|                     //if (SelPerson != "" && ) strSql += " AND p.Id not in (" + SelPerson + ") ";
 | |
|                     strSql += " order by p.[Order]  asc";
 | |
|                     break;
 | |
| 
 | |
|             }
 | |
|             return HelperDB.DbHelperSQL.GetDataTable(strSql.ToString());
 | |
|         }
 | |
|         public static int SetOperationRecordValue(object operationRecord, string propertyName, string value, string Text)
 | |
|         {
 | |
|             int i = 0;
 | |
|             OperationRecord _operationRecord = operationRecord as OperationRecord;
 | |
|             if (_operationRecord == null) return i;
 | |
|             string[] items = propertyName.Split('.');
 | |
|             try
 | |
|             {
 | |
|                 if (items.Length < 1) return i;
 | |
|                 if (items.Length > 2)
 | |
|                 {
 | |
|                     if (items[1] == "InstrumentList")
 | |
|                     {
 | |
|                         i += UpdateInstrumentList(items[2] + "='" + value + "'  where Id= " + _operationRecord.InstrumentList.Id);
 | |
|                     }
 | |
|                     else if (items[1] == "OpeRecordInfo")
 | |
|                     {
 | |
|                         i += UpdateOperationRecordInfo(items[2] + "='" + value + "'  where Id= " + _operationRecord.OpeRecordInfo.Id);
 | |
|                     }
 | |
|                     else if (items[1] == "OpeRecoverInInfo")
 | |
|                     {
 | |
|                         i += UpdateOperationRecoverInInfo(items[2] + "='" + value + "'  where Id= " + _operationRecord.OpeRecoverInInfo.Id);
 | |
|                     }
 | |
|                     else if (items[1] == "OpeRecoverOutInfo")
 | |
|                     {
 | |
|                         i += UpdateOperationRecoverOutInfo(items[2] + "='" + value + "'  where Id= " + _operationRecord.OpeRecoverOutInfo.Id);
 | |
|                     }
 | |
|                     else if (items[1] == "AnalgesiaRecord")
 | |
|                     {
 | |
|                         i += UpdateAnalgesiaRecord(items[2] + "='" + value + "'  where Id= " + _operationRecord.AnalgesiaRecord.Id);
 | |
|                     }
 | |
|                 }
 | |
|                 else
 | |
|                 {
 | |
|                     if (items[1] == "OperationDoctor")
 | |
|                     {
 | |
|                         i += AddPerson(_operationRecord, _operationRecord.OperationDoctor, 1);
 | |
|                     }
 | |
|                     else if (items[1] == "Assistant1")
 | |
|                     {
 | |
|                         i += AddPerson(_operationRecord, _operationRecord.Assistant1, 2);
 | |
|                     }
 | |
|                     else if (items[1] == "Assistant2")
 | |
|                     {
 | |
|                         i += AddPerson(_operationRecord, _operationRecord.Assistant2, 3);
 | |
|                     }
 | |
|                     else if (items[1] == "Assistant3")
 | |
|                     {
 | |
|                         i += AddPerson(_operationRecord, _operationRecord.Assistant3, 4);
 | |
|                     }
 | |
|                     else if (items[1] == "AnesthesiaDoctor")
 | |
|                     {
 | |
|                         i += AddPerson(_operationRecord, _operationRecord.AnesthesiaDoctor, 5);
 | |
|                     }
 | |
|                     else if (items[1] == "InstrumentNurse")
 | |
|                     {
 | |
|                         i += AddPerson(_operationRecord, _operationRecord.InstrumentNurse, 6);
 | |
|                     }
 | |
|                     else if (items[1] == "TourNurse")
 | |
|                     {
 | |
|                         i += AddPerson(_operationRecord, _operationRecord.TourNurse, 7);
 | |
|                     }
 | |
|                     else if (items[1] == "OrtherDoctorId")
 | |
|                     {
 | |
|                         i += AddPerson(_operationRecord, _operationRecord.OrtherDoctorId, 11);
 | |
|                     }
 | |
|                     else if (items[1] == "Operation")
 | |
|                     {
 | |
|                         i += AddOperation(_operationRecord, _operationRecord.Operation);
 | |
|                     }
 | |
|                     else if (items[1] == "Diagnose")
 | |
|                     {
 | |
|                         i += AddDiagnose(_operationRecord, _operationRecord.Diagnose);
 | |
|                     }
 | |
|                     else if (items[1] == "Applyoperation")
 | |
|                     {
 | |
|                         i += AddApplyOperation(_operationRecord, _operationRecord.Applyoperation);
 | |
|                     }
 | |
|                     else if (items[1] == "Applydiagnose")
 | |
|                     {
 | |
|                         i += AddApplyDiagnose(_operationRecord, _operationRecord.Applydiagnose); 
 | |
|                     }
 | |
|                     else if (items[1] == "AnaesthesiaMethodId")
 | |
|                     {
 | |
|                         i += AddAnaesthesiaMethod(_operationRecord, _operationRecord.AnaesthesiaMethodId);
 | |
|                     }
 | |
|                     else if (items[1] == "OperationSiteId")
 | |
|                     {
 | |
|                         i += AddOperationSite(_operationRecord, _operationRecord.OperationSiteId);
 | |
|                     }
 | |
|                     else if (items[1] == "OperationPositionId")
 | |
|                     {
 | |
|                         i += AddOperationPosition(_operationRecord, _operationRecord.OperationPositionId);
 | |
|                     }
 | |
|                     else if (items[1] == "Height" || items[1] == "Weight" || items[1] == "Age")
 | |
|                     {
 | |
|                         i += UpdatePatient(items[1] + "='" + value + "'  where Id= " + _operationRecord.PatientId);
 | |
|                     }
 | |
|                     else if (items[1] == "BloodType" || items[1] == "RHBloodType")
 | |
|                     {
 | |
|                         i += UpdatePatient(items[1] + "='" + Text + "'  where Id= " + _operationRecord.PatientId);
 | |
|                     }
 | |
|                     else if (items[1] == "OperationType")
 | |
|                     {
 | |
|                         i += UpdateApply(items[1] + "='" + value + "'  where Id= " + _operationRecord.OperationApplyId);
 | |
|                     }
 | |
|                     else
 | |
|                     {
 | |
|                         i += Update(items[1] + "='" + value + "'  where Id= " + _operationRecord.Id);
 | |
|                     }
 | |
|                 }
 | |
|             }
 | |
|             catch (Exception)
 | |
|             {
 | |
|                 //PublicMethod.WriteLog(new Exception("回写数据出错:" + propertyName + " 值:" + value + " 错误:" + ex.Message));
 | |
|             }
 | |
|             return i;
 | |
|         }
 | |
| 
 | |
|         public static int Update(string sql)
 | |
|         {
 | |
|             string sqlStr = "update OperationRecord set " + sql;
 | |
|             return DBHelper.ExecNonQuery(sqlStr);
 | |
|         }
 | |
| 
 | |
|         public static int UpdatePatient(string sql)
 | |
|         {
 | |
|             string sqlStr = "update Oris_Patient set " + sql;
 | |
|             return DBHelper.ExecNonQuery(sqlStr);
 | |
|         }
 | |
|         public static int UpdateApply(string sql)
 | |
|         {
 | |
|             string sqlStr = "update OperationApply set " + sql;
 | |
|             return DBHelper.ExecNonQuery(sqlStr);
 | |
|         }
 | |
|         public static int UpdateInstrumentList(string sql)
 | |
|         {
 | |
|             string sqlStr = "update InstrumentList set " + sql;
 | |
|             return DBHelper.ExecNonQuery(sqlStr);
 | |
|         }
 | |
|         public static int UpdateOperationRecordInfo(string sql)
 | |
|         {
 | |
|             string sqlStr = "update OperationRecordInfo set " + sql;
 | |
|             return DBHelper.ExecNonQuery(sqlStr);
 | |
|         }
 | |
|         public static int UpdateOperationRecoverInInfo(string sql)
 | |
|         {
 | |
|             string sqlStr = "update OperationRecoveInInfo set " + sql;
 | |
|             return DBHelper.ExecNonQuery(sqlStr);
 | |
|         }
 | |
|         public static int UpdateOperationRecoverOutInfo(string sql)
 | |
|         {
 | |
|             string sqlStr = "update OperationRecoverOutInfo set " + sql;
 | |
|             return DBHelper.ExecNonQuery(sqlStr);
 | |
|         }
 | |
|         public static int UpdateAnalgesiaRecord(string sql)
 | |
|         {
 | |
|             string sqlStr = "update OperationRecordAnalgesia set " + sql;
 | |
|             return DBHelper.ExecNonQuery(sqlStr);
 | |
|         }
 | |
|         public static int AddPerson(OperationRecord _operationRecord, string Persons, int PersonDutyId)
 | |
|         {
 | |
|             int i = 0;
 | |
|             if (Persons.Trim() == "" || Persons == ",")
 | |
|             {
 | |
|                 DeletePerson(_operationRecord.PatientId.Value, PersonDutyId);
 | |
|                 i++;
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 DeletePerson(_operationRecord.PatientId.Value, PersonDutyId);
 | |
|                 i++;
 | |
|                 string[] Personstr = Persons.Split(',');
 | |
|                 foreach (string PersonId in Personstr)
 | |
|                 {
 | |
|                     StringBuilder strSql = new StringBuilder();
 | |
|                     strSql.Append("insert into [FactPersonDuty](");
 | |
|                     strSql.Append("PatientId,ApplyId,PersonDutyId,PersonId,OperatorNo,OperatorName,OperateDate");
 | |
|                     strSql.Append(")");
 | |
|                     strSql.Append(" values (");
 | |
|                     strSql.Append("" + _operationRecord.PatientId + ",");
 | |
|                     strSql.Append("" + _operationRecord.OperationApplyId + ",");
 | |
|                     strSql.Append("" + PersonDutyId + ",");
 | |
|                     strSql.Append("" + PersonId + ",");
 | |
|                     strSql.Append("'" + AIMSExtension.PublicMethod.OperatorNo + "',");
 | |
|                     strSql.Append("'" + AIMSExtension.PublicMethod.OperatorName + "',");
 | |
|                     strSql.Append("'" + DateTime.Now + "'");
 | |
|                     strSql.Append(")");
 | |
|                     i += HelperDB.DbHelperSQL.ExecNonQuery(strSql.ToString());
 | |
|                 }
 | |
|             }
 | |
|             return i;
 | |
|         }
 | |
|         public static int AddPerson(OperationRecord _operationRecord, List<int> Persons, int PersonDutyId)
 | |
|         {
 | |
|             int i = 0;
 | |
|             if (Persons == null || Persons.Count <= 0)
 | |
|             {
 | |
|                 DeletePerson(_operationRecord.PatientId.Value, PersonDutyId);
 | |
|                 i++;
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 DeletePerson(_operationRecord.PatientId.Value, PersonDutyId);
 | |
|                 i++;
 | |
|                 foreach (int PersonId in Persons)
 | |
|                 {
 | |
|                     StringBuilder strSql = new StringBuilder();
 | |
|                     strSql.Append("insert into [FactPersonDuty](");
 | |
|                     strSql.Append("PatientId,ApplyId,PersonDutyId,PersonId,OperatorNo,OperatorName,OperateDate");
 | |
|                     strSql.Append(")");
 | |
|                     strSql.Append(" values (");
 | |
|                     strSql.Append("" + _operationRecord.PatientId + ",");
 | |
|                     strSql.Append("" + _operationRecord.OperationApplyId + ",");
 | |
|                     strSql.Append("" + PersonDutyId + ",");
 | |
|                     strSql.Append("" + PersonId + ",");
 | |
|                     strSql.Append("'" + AIMSExtension.PublicMethod.OperatorNo + "',");
 | |
|                     strSql.Append("'" + AIMSExtension.PublicMethod.OperatorName + "',");
 | |
|                     strSql.Append("'" + DateTime.Now + "'");
 | |
|                     strSql.Append(")");
 | |
|                     i += HelperDB.DbHelperSQL.ExecNonQuery(strSql.ToString());
 | |
|                 }
 | |
|             }
 | |
|             return i;
 | |
|         }
 | |
| 
 | |
|         public static int AddOperation(OperationRecord _operationRecord, string Operation)
 | |
|         {
 | |
|             int i = 0;
 | |
|             if (Operation.Trim() == "" || Operation == ",")
 | |
|             {
 | |
|                 DeleteOperation(_operationRecord.PatientId.Value);
 | |
|                 i++;
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 DeleteOperation(_operationRecord.PatientId.Value);
 | |
|                 i++;
 | |
|                 string[] Operationstr = Operation.Split(',');
 | |
|                 foreach (string OperationId in Operationstr)
 | |
|                 {
 | |
|                     StringBuilder strSql = new StringBuilder();
 | |
|                     strSql.Append("insert into [FactOperationInfo](");
 | |
|                     strSql.Append("PatientId,ApplyId,OperationId,OperatorNo,OperatorName,OperateDate,OperationName,LeftRemark,RightRemark");
 | |
|                     strSql.Append(")");
 | |
|                     strSql.Append(" values (");
 | |
|                     strSql.Append("" + _operationRecord.PatientId + ",");
 | |
|                     strSql.Append("" + _operationRecord.OperationApplyId + ",");
 | |
|                     strSql.Append("" + OperationId + ",");
 | |
|                     strSql.Append("'" + AIMSExtension.PublicMethod.OperatorNo + "',");
 | |
|                     strSql.Append("'" + AIMSExtension.PublicMethod.OperatorName + "',");
 | |
|                     strSql.Append("'" + DateTime.Now + "',");
 | |
|                     strSql.Append("'',");//" + FactOperationInfoObj.OperationName + "
 | |
|                     strSql.Append("'',");//" + FactOperationInfoObj.LeftRemark + "
 | |
|                     strSql.Append("''");//" + FactOperationInfoObj.RightRemark + "
 | |
|                     strSql.Append(")");
 | |
|                     i += HelperDB.DbHelperSQL.ExecNonQuery(strSql.ToString());
 | |
|                 }
 | |
|             }
 | |
|             return i;
 | |
|         }
 | |
|         public static int AddOperation(OperationRecord _operationRecord, List<int> Operation)
 | |
|         {
 | |
|             int i = 0;
 | |
|             if (Operation == null || Operation.Count <= 0)
 | |
|             {
 | |
|                 DeleteOperation(_operationRecord.PatientId.Value);
 | |
|                 i++;
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 DeleteOperation(_operationRecord.PatientId.Value);
 | |
|                 i++;
 | |
|                 foreach (int OperationId in Operation)
 | |
|                 {
 | |
|                     StringBuilder strSql = new StringBuilder();
 | |
|                     strSql.Append("insert into [FactOperationInfo](");
 | |
|                     strSql.Append("PatientId,ApplyId,OperationId,OperatorNo,OperatorName,OperateDate,OperationName,LeftRemark,RightRemark");
 | |
|                     strSql.Append(")");
 | |
|                     strSql.Append(" values (");
 | |
|                     strSql.Append("" + _operationRecord.PatientId + ",");
 | |
|                     strSql.Append("" + _operationRecord.OperationApplyId + ",");
 | |
|                     strSql.Append("" + OperationId + ",");
 | |
|                     strSql.Append("'" + AIMSExtension.PublicMethod.OperatorNo + "',");
 | |
|                     strSql.Append("'" + AIMSExtension.PublicMethod.OperatorName + "',");
 | |
|                     strSql.Append("'" + DateTime.Now + "',");
 | |
|                     strSql.Append("'',");//" + FactOperationInfoObj.OperationName + "
 | |
|                     strSql.Append("'',");//" + FactOperationInfoObj.LeftRemark + "
 | |
|                     strSql.Append("''");//" + FactOperationInfoObj.RightRemark + "
 | |
|                     strSql.Append(")");
 | |
|                     i += HelperDB.DbHelperSQL.ExecNonQuery(strSql.ToString());
 | |
|                 }
 | |
|             }
 | |
|             return i;
 | |
|         }
 | |
|         public static int AddDiagnose(OperationRecord _operationRecord, string Diagnose)
 | |
|         {
 | |
|             int i = 0;
 | |
|             if (Diagnose.Trim() == "" || Diagnose == ",")
 | |
|             {
 | |
|                 DeleteDiagnose(_operationRecord.PatientId.Value);
 | |
|                 i++;
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 DeleteDiagnose(_operationRecord.PatientId.Value);
 | |
|                 i++;
 | |
|                 string[] Operationstr = Diagnose.Split(',');
 | |
|                 foreach (string DiagnoseId in Operationstr)
 | |
|                 {
 | |
|                     StringBuilder strSql = new StringBuilder();
 | |
|                     strSql.Append("insert into [FactDiagnoseInfo](");
 | |
|                     strSql.Append("PatientId,ApplyId,[DiagnoseId],OperatorNo,OperatorName,OperateDate ");
 | |
|                     strSql.Append(")");
 | |
|                     strSql.Append(" values (");
 | |
|                     strSql.Append("" + _operationRecord.PatientId + ",");
 | |
|                     strSql.Append("" + _operationRecord.OperationApplyId + ",");
 | |
|                     strSql.Append("" + DiagnoseId + ",");
 | |
|                     strSql.Append("'" + AIMSExtension.PublicMethod.OperatorNo + "',");
 | |
|                     strSql.Append("'" + AIMSExtension.PublicMethod.OperatorName + "',");
 | |
|                     strSql.Append("'" + DateTime.Now + "'");
 | |
|                     strSql.Append(")");
 | |
|                     i += HelperDB.DbHelperSQL.ExecNonQuery(strSql.ToString());
 | |
|                 }
 | |
|             }
 | |
|             return i;
 | |
|         }
 | |
|         public static int AddApplyOperation(OperationRecord _operationRecord, string Operation)
 | |
|         {
 | |
|             int i = 0;
 | |
|             if (Operation.Trim() == "" || Operation == ",")
 | |
|             {
 | |
|                 DeleteApplyOperation(_operationRecord.OperationApplyId.Value);
 | |
|                 i++;
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 DeleteApplyOperation(_operationRecord.OperationApplyId.Value);
 | |
|                 i++;
 | |
|                 string[] Operationstr = Operation.Split(',');
 | |
|                 foreach (string OperationId in Operationstr)
 | |
|                 {
 | |
|                     string Name = "";
 | |
|                     string sql = string.Format("select Name from Operation where Id = '{0}'", OperationId );
 | |
|                     object dt = DBHelper.ExecuteScalar(sql);
 | |
|                     if (dt != null) { Name  = dt.ToString(); }
 | |
|                     StringBuilder strSql = new StringBuilder();
 | |
|                     strSql.Append("insert into [ApplyOperationInfo](");
 | |
|                     strSql.Append("OperationApplyId,OperationId,OperatorNo,OperatorName,OperateDate,OperationName,LeftRemark,RightRemark");
 | |
|                     strSql.Append(")");
 | |
|                     strSql.Append(" values (");
 | |
|                     strSql.Append("" + _operationRecord.OperationApplyId + ",");
 | |
|                     strSql.Append("" + OperationId + ",");
 | |
|                     strSql.Append("'" + AIMSExtension.PublicMethod.OperatorNo + "',");
 | |
|                     strSql.Append("'" + AIMSExtension.PublicMethod.OperatorName + "',");
 | |
|                     strSql.Append("'" + DateTime.Now + "',");
 | |
|                     strSql.Append("'" + Name + "',");//" + FactOperationInfoObj.OperationName + "
 | |
|                     strSql.Append("'',");//" + FactOperationInfoObj.LeftRemark + "
 | |
|                     strSql.Append("''");//" + FactOperationInfoObj.RightRemark + "
 | |
|                     strSql.Append(")");
 | |
|                     i += HelperDB.DbHelperSQL.ExecNonQuery(strSql.ToString());
 | |
|                 }
 | |
|             }
 | |
|             return i;
 | |
|         }
 | |
|         public static int AddApplyDiagnose(OperationRecord _operationRecord, string Diagnose)
 | |
|         {
 | |
|             int i = 0;
 | |
|             if (Diagnose.Trim() == "" || Diagnose == ",")
 | |
|             {
 | |
|                 DeleteApplyDiagnose(_operationRecord.OperationApplyId.Value);
 | |
|                 i++;
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 DeleteApplyDiagnose(_operationRecord.OperationApplyId.Value);
 | |
|                 i++;
 | |
|                 string[] Diagnosestr = Diagnose.Split(',');
 | |
|                 foreach (string DiagnoseId in Diagnosestr)
 | |
|                 {
 | |
|                     StringBuilder strSql = new StringBuilder();
 | |
|                     strSql.Append("insert into [ApplyDiagnoseInfo](");
 | |
|                     strSql.Append("OperationApplyId,DiagnoseId,OperatorNo,OperatorName,OperateDate");
 | |
|                     strSql.Append(")");
 | |
|                     strSql.Append(" values (");
 | |
|                     strSql.Append("" + _operationRecord.OperationApplyId + ",");
 | |
|                     strSql.Append("" + DiagnoseId + ",");
 | |
|                     strSql.Append("'" + AIMSExtension.PublicMethod.OperatorNo + "',");
 | |
|                     strSql.Append("'" + AIMSExtension.PublicMethod.OperatorName + "',");
 | |
|                     strSql.Append("'" + DateTime.Now + "'");
 | |
|                     strSql.Append(")");
 | |
|                     i += HelperDB.DbHelperSQL.ExecNonQuery(strSql.ToString());
 | |
|                 }
 | |
|             }
 | |
|             return i;
 | |
|         }
 | |
|         public static int AddOperationSite(OperationRecord _operationRecord, string OperationSite)
 | |
|         {
 | |
|             int i = 0;
 | |
|             if (OperationSite.Trim() == "" || OperationSite == ",")
 | |
|             {
 | |
|                 DeleteOperationSite(_operationRecord.PatientId.Value);
 | |
|                 i++;
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 DeleteOperationSite(_operationRecord.PatientId.Value);
 | |
|                 i++;
 | |
|                 string[] Operationstr = OperationSite.Split(',');
 | |
|                 foreach (string OperationSiteId in Operationstr)
 | |
|                 {
 | |
|                     StringBuilder strSql = new StringBuilder();
 | |
|                     strSql.Append("insert into [FactOperationBodyPosition](");
 | |
|                     strSql.Append("PatientId,ApplyId,OperationBodyPositionId,OperatorNo,OperatorName,OperateDate");
 | |
|                     strSql.Append(")");
 | |
|                     strSql.Append(" values (");
 | |
|                     strSql.Append("" + _operationRecord.PatientId + ",");
 | |
|                     strSql.Append("" + _operationRecord.OperationApplyId + ",");
 | |
|                     strSql.Append("" + OperationSiteId + ",");
 | |
|                     strSql.Append("'" + AIMSExtension.PublicMethod.OperatorNo + "',");
 | |
|                     strSql.Append("'" + AIMSExtension.PublicMethod.OperatorName + "',");
 | |
|                     strSql.Append("'" + DateTime.Now + "'");
 | |
|                     strSql.Append(")");
 | |
|                     i += HelperDB.DbHelperSQL.ExecNonQuery(strSql.ToString());
 | |
|                 }
 | |
|             }
 | |
|             return i;
 | |
|         }
 | |
|         public static int AddOperationPosition(OperationRecord _operationRecord, string OperationPositionId)
 | |
|         {
 | |
|             int i = 0;
 | |
|             if (OperationPositionId.Trim() == "" || OperationPositionId == ",")
 | |
|             {
 | |
|                 DeleteOperationPosition(_operationRecord.PatientId.Value);
 | |
|                 i++;
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 DeleteOperationPosition(_operationRecord.PatientId.Value);
 | |
|                 i++;
 | |
|                 string[] Operationstr = OperationPositionId.Split(',');
 | |
|                 foreach (string OperationPosition in Operationstr)
 | |
|                 {
 | |
|                     StringBuilder strSql = new StringBuilder();
 | |
|                     strSql.Append("insert into [FactOperationPosition](");
 | |
|                     strSql.Append("PatientId,ApplyId,OperationPositionId,OperatorNo,OperatorName,OperateDate");
 | |
|                     strSql.Append(")");
 | |
|                     strSql.Append(" values (");
 | |
|                     strSql.Append("" + _operationRecord.PatientId + ",");
 | |
|                     strSql.Append("" + _operationRecord.OperationApplyId + ",");
 | |
|                     strSql.Append("" + OperationPosition + ",");
 | |
|                     strSql.Append("'" + AIMSExtension.PublicMethod.OperatorNo + "',");
 | |
|                     strSql.Append("'" + AIMSExtension.PublicMethod.OperatorName + "',");
 | |
|                     strSql.Append("'" + DateTime.Now + "'");
 | |
|                     strSql.Append(")");
 | |
|                     i += HelperDB.DbHelperSQL.ExecNonQuery(strSql.ToString());
 | |
|                 }
 | |
|             }
 | |
|             return i;
 | |
|         }
 | |
|         public static int AddOperationPosition(OperationRecord _operationRecord, List<int> OperationPositionIds)
 | |
|         {
 | |
|             int i = 0;
 | |
|             if (OperationPositionIds == null || OperationPositionIds.Count <= 0)
 | |
|             {
 | |
|                 DeleteOperationPosition(_operationRecord.PatientId.Value);
 | |
|                 i++;
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 DeleteOperationPosition(_operationRecord.PatientId.Value);
 | |
|                 i++;
 | |
|                 foreach (int OperationPosition in OperationPositionIds)
 | |
|                 {
 | |
|                     StringBuilder strSql = new StringBuilder();
 | |
|                     strSql.Append("insert into [FactOperationPosition](");
 | |
|                     strSql.Append("PatientId,ApplyId,OperationPositionId,OperatorNo,OperatorName,OperateDate");
 | |
|                     strSql.Append(")");
 | |
|                     strSql.Append(" values (");
 | |
|                     strSql.Append("" + _operationRecord.PatientId + ",");
 | |
|                     strSql.Append("" + _operationRecord.OperationApplyId + ",");
 | |
|                     strSql.Append("" + OperationPosition + ",");
 | |
|                     strSql.Append("'" + AIMSExtension.PublicMethod.OperatorNo + "',");
 | |
|                     strSql.Append("'" + AIMSExtension.PublicMethod.OperatorName + "',");
 | |
|                     strSql.Append("'" + DateTime.Now + "'");
 | |
|                     strSql.Append(")");
 | |
|                     i += HelperDB.DbHelperSQL.ExecNonQuery(strSql.ToString());
 | |
|                 }
 | |
|             }
 | |
|             return i;
 | |
|         }
 | |
|         public static int AddAnaesthesiaMethod(OperationRecord _operationRecord, string AnaesthesiaMethod)
 | |
|         {
 | |
|             int i = 0;
 | |
|             if (AnaesthesiaMethod.Trim() == "" || AnaesthesiaMethod == "+")
 | |
|             {
 | |
|                 DeleteAnaesthesiaMethod(_operationRecord.PatientId.Value);
 | |
|                 i++;
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 DeleteAnaesthesiaMethod(_operationRecord.PatientId.Value);
 | |
|                 i++;
 | |
|                 string[] Operationstr = AnaesthesiaMethod.Split('+');
 | |
|                 foreach (string AnaesthesiaMethodId in Operationstr)
 | |
|                 {
 | |
|                     StringBuilder strSql = new StringBuilder();
 | |
|                     strSql.Append("insert into [FactAnaesthesiaMethod](");
 | |
|                     strSql.Append("PatientId,ApplyId,AnaesthesiaMethodId,OperatorNo,OperatorName,OperateDate");
 | |
|                     strSql.Append(")");
 | |
|                     strSql.Append(" values (");
 | |
|                     strSql.Append("" + _operationRecord.PatientId + ",");
 | |
|                     strSql.Append("" + _operationRecord.OperationApplyId + ",");
 | |
|                     strSql.Append("" + AnaesthesiaMethodId + ",");
 | |
|                     strSql.Append("'" + AIMSExtension.PublicMethod.OperatorNo + "',");
 | |
|                     strSql.Append("'" + AIMSExtension.PublicMethod.OperatorName + "',");
 | |
|                     strSql.Append("'" + DateTime.Now + "'");
 | |
|                     strSql.Append(")");
 | |
|                     i += HelperDB.DbHelperSQL.ExecNonQuery(strSql.ToString());
 | |
|                 }
 | |
|             }
 | |
|             return i;
 | |
|         }
 | |
|         public static void DeletePerson(int PatientId, int PersonDutyId)
 | |
|         {
 | |
|             StringBuilder strSql = new StringBuilder();
 | |
|             strSql.Append("delete FactPersonDuty ");
 | |
|             strSql.Append(" where PatientId=" + PatientId + " and PersonDutyId=" + PersonDutyId + "");
 | |
|             HelperDB.DbHelperSQL.ExecNonQuery(strSql.ToString());
 | |
|         }
 | |
|         public static void DeleteApplyOperation(int OperationApplyId)
 | |
|         {
 | |
|             StringBuilder strSql = new StringBuilder();
 | |
|             strSql.Append("delete ApplyOperationInfo ");
 | |
|             strSql.Append(" where OperationApplyId=" + OperationApplyId + " ");
 | |
|             HelperDB.DbHelperSQL.ExecNonQuery(strSql.ToString());
 | |
|         }
 | |
|         public static void DeleteApplyDiagnose(int OperationApplyId)
 | |
|         {
 | |
|             StringBuilder strSql = new StringBuilder();
 | |
|             strSql.Append("delete ApplyDiagnoseInfo ");
 | |
|             strSql.Append(" where OperationApplyId=" + OperationApplyId + " ");
 | |
|             HelperDB.DbHelperSQL.ExecNonQuery(strSql.ToString());
 | |
|         }
 | |
|         public static void DeleteOperation(int PatientId)
 | |
|         {
 | |
|             StringBuilder strSql = new StringBuilder();
 | |
|             strSql.Append("delete FactOperationInfo ");
 | |
|             strSql.Append(" where PatientId=" + PatientId + " ");
 | |
|             HelperDB.DbHelperSQL.ExecNonQuery(strSql.ToString());
 | |
|         }
 | |
|         public static void DeleteDiagnose(int PatientId)
 | |
|         {
 | |
|             StringBuilder strSql = new StringBuilder();
 | |
|             strSql.Append("delete FactDiagnoseInfo ");
 | |
|             strSql.Append(" where PatientId=" + PatientId + " ");
 | |
|             HelperDB.DbHelperSQL.ExecNonQuery(strSql.ToString());
 | |
|         }
 | |
|         public static void DeleteOperationSite(int PatientId)
 | |
|         {
 | |
|             StringBuilder strSql = new StringBuilder();
 | |
|             strSql.Append("delete from FactOperationBodyPosition ");
 | |
|             strSql.Append(" where PatientId=" + PatientId + " ");
 | |
|             HelperDB.DbHelperSQL.ExecNonQuery(strSql.ToString());
 | |
|         }
 | |
|         public static void DeleteOperationPosition(int PatientId)
 | |
|         {
 | |
|             StringBuilder strSql = new StringBuilder();
 | |
|             strSql.Append("delete from FactOperationPosition ");
 | |
|             strSql.Append(" where PatientId=" + PatientId + " ");
 | |
|             HelperDB.DbHelperSQL.ExecNonQuery(strSql.ToString());
 | |
|         }
 | |
|         public static void DeleteAnaesthesiaMethod(int PatientId)
 | |
|         {
 | |
|             StringBuilder strSql = new StringBuilder();
 | |
|             strSql.Append("delete FactAnaesthesiaMethod ");
 | |
|             strSql.Append(" where PatientId=" + PatientId + " ");
 | |
|             HelperDB.DbHelperSQL.ExecNonQuery(strSql.ToString());
 | |
|         }
 | |
| 
 | |
|         public static string GetDictionaryValuesById(string Ids, string DictionaryName)
 | |
|         {
 | |
|             if (Ids == null || Ids.Trim() == "") return "";
 | |
|             string Explain = "";
 | |
|             try
 | |
|             {
 | |
|                 string sql = "";
 | |
|                 switch (DictionaryName)
 | |
|                 {
 | |
|                     case "手术":
 | |
|                         sql = "select dbo.GetOperation('" + Ids + "') value";
 | |
|                         break;
 | |
|                     case "CA人员":
 | |
|                         sql = "select dbo.GetPersons('" + Ids + "') value";
 | |
|                         break;
 | |
|                     case "人员":
 | |
|                         sql = "select dbo.GetPersons('" + Ids + "') value";
 | |
|                         break;
 | |
|                     case "诊断":
 | |
|                         sql = "select dbo.GetDisease('" + Ids + "') value";
 | |
|                         break;
 | |
|                     case "麻醉方式":
 | |
|                         sql = "select dbo.GetAnaesthesiaMethod('" + Ids + "') value";
 | |
|                         break;
 | |
|                     case "手术体位":
 | |
|                         sql = "select dbo.GetOperationBodyPosition('" + Ids + "') value";
 | |
|                         break;
 | |
|                     case "手术部位":
 | |
|                         sql = "select dbo.GetOperationPosition('" + Ids + "') value";
 | |
|                         break;
 | |
|                     default:
 | |
|                         sql = "select dbo.funBasicDictionary('" + Ids + "') value";
 | |
|                         break;
 | |
|                 }
 | |
|                 if (sql != "")
 | |
|                 {
 | |
|                     object dt = DBHelper.ExecuteScalar(sql);
 | |
|                     if (dt != null)
 | |
|                     {
 | |
|                         Explain = dt.ToString();
 | |
|                     }
 | |
|                 }
 | |
|             }
 | |
|             catch (Exception ex)
 | |
|             {
 | |
|                 PublicMethod.WriteLog(ex);
 | |
|                 Explain = "";
 | |
|             }
 | |
|             return Explain;
 | |
|         }
 | |
| 
 | |
|         public static string GetDictionaryValuesById(string Ids, string DictionaryName, string Tags)
 | |
|         {
 | |
|             if (Ids == null || Ids.Trim() == "") return "";
 | |
|             string Explain = "";
 | |
|             try
 | |
|             {
 | |
|                 string sql = "";
 | |
|                 switch (DictionaryName)
 | |
|                 {
 | |
|                     case "手术":
 | |
|                         sql = "select dbo.GetOperation('" + Ids + "') value";
 | |
|                         break;
 | |
|                     case "CA人员":
 | |
|                         sql = "select dbo.GetPersons('" + Ids + "') value";
 | |
|                         break;
 | |
|                     case "人员":
 | |
|                         sql = "select dbo.GetPersons('" + Ids + "') value";
 | |
|                         break;
 | |
|                     case "诊断":
 | |
|                         sql = "select dbo.GetDisease('" + Ids + "') value";
 | |
|                         break;
 | |
|                     case "麻醉方式":
 | |
|                         sql = "select dbo.GetAnaesthesiaMethod('" + Ids + "') value";
 | |
|                         break;
 | |
|                     case "手术体位":
 | |
|                         sql = "select dbo.GetOperationBodyPosition('" + Ids + "') value";
 | |
|                         break;
 | |
|                     case "手术部位":
 | |
|                         sql = "select dbo.GetOperationPosition('" + Ids + "') value";
 | |
|                         break;
 | |
|                     default:
 | |
|                         sql = "select dbo.funBasicDictionary('" + Ids + "') value";
 | |
|                         break;
 | |
|                 }
 | |
|                 if (sql != "")
 | |
|                 {
 | |
|                     object dt = DBHelper.ExecuteScalar(sql);
 | |
|                     if (dt != null)
 | |
|                     {
 | |
|                         string namestr = dt.ToString();
 | |
|                         List<string> list = namestr.Split(',').ToList();
 | |
|                         List<string> tags = Tags.Split('|').ToList();
 | |
|                         for (int i = 0; i < list.Count; i++)
 | |
|                         {
 | |
|                             list[i] = list[i] + tags[i];
 | |
|                         }
 | |
|                         Explain = string.Join(",", list);
 | |
|                     }
 | |
|                 }
 | |
|             }
 | |
|             catch (Exception ex)
 | |
|             {
 | |
|                 PublicMethod.WriteLog(ex);
 | |
|                 Explain = "";
 | |
|             }
 | |
|             return Explain;
 | |
|         }
 | |
|     }
 | |
| }
 |