using System; using AIMSDAL; using AIMSModel; using AIMSObjectQuery; using System.Collections; using System.Collections.Generic; using System.Data; using HelperDB; using AIMSExtension; using System.Data.SqlClient; using System.Reflection; using System.Windows.Forms; using DrawGraph; namespace AIMSBLL { public partial class BOperationRecord { public static OperationRecord getRecord(OperationRecord _record, int PatientId, int RecoverId) { if (_record == null) _record = new OperationRecord(); if (PatientId == -1) { return _record; } TitleTime titleTime = BOperationRecord.GetTitleTime(PatientId, RecoverId); _record.PatientId = PatientId; _record.OperationApplyId = titleTime.OperationApplyId; _record.InRoomTime = titleTime.InRoomTime; _record.OperationBeginTime = titleTime.OperationBeginTime; _record.OperationEndTime = titleTime.OperationEndTime; _record.OutRoomTime = titleTime.OutRoomTime; _record.SpareFive = ""; if (titleTime.OutRoomTime != null && titleTime.InRoomTime != null) _record.SpareFive = Convert.ToInt32(((TimeSpan)(titleTime.OutRoomTime - titleTime.InRoomTime)).TotalMinutes).ToString() + "分钟"; DataTable OperationFrontdt = BOperationApply.GetOperationFrontDataTableByPatientId(PatientId); if (OperationFrontdt.Rows.Count > 0) { _record.DepartmentId = int.Parse(OperationFrontdt.Rows[0]["DepartmentId"].ToString()); _record.ApplyDepartmentName = OperationFrontdt.Rows[0]["ApplyDepName"].ToString() + " " + OperationFrontdt.Rows[0]["SickBed"].ToString(); _record.ApplyDepName = OperationFrontdt.Rows[0]["ApplyDepName"].ToString(); _record.EndemicArea = OperationFrontdt.Rows[0]["Illdistrict"].ToString(); _record.Bed = OperationFrontdt.Rows[0]["SickBed"].ToString(); _record.InHospitalNo = OperationFrontdt.Rows[0]["MdrecNo"].ToString(); _record.MedicalHistoryNo = OperationFrontdt.Rows[0]["ArchivesNo"].ToString(); _record.Name = OperationFrontdt.Rows[0]["PatientName"].ToString(); _record.Sex = OperationFrontdt.Rows[0]["Sex"].ToString(); _record.Age = AIMSExtension.PublicMethod.GetAge(DateTime.Parse(OperationFrontdt.Rows[0]["BirthDay"].ToString())); if (OperationFrontdt.Rows[0]["Height"].ToString() != "") _record.Height = double.Parse(OperationFrontdt.Rows[0]["Height"].ToString()).ToString(); if (OperationFrontdt.Rows[0]["Weight"].ToString() != "") _record.Weight = double.Parse(OperationFrontdt.Rows[0]["Weight"].ToString()).ToString(); _record.Applydiagnose = OperationFrontdt.Rows[0]["ApplyDiagnoseInfoId"].ToString(); _record.Applyoperation = OperationFrontdt.Rows[0]["ApplyOperationInfoId"].ToString(); _record.OperationPriority = OperationFrontdt.Rows[0]["OperationType"].ToString(); _record.OperationRoomId = int.Parse(OperationFrontdt.Rows[0]["OperationRoomId"].ToString().Trim()); _record.MedicalRecord = OperationFrontdt.Rows[0]["MedicalRecord"].ToString(); } DataTable OperationDoingdt = BOperationRecord.GetOperationDoingDataTableByPatientId(PatientId, RecoverId); if (OperationDoingdt.Rows.Count > 0) { _record.Id = int.Parse(OperationDoingdt.Rows[0]["Id"].ToString().Trim()); _record.State = OperationDoingdt.Rows[0]["State"].ToString().Trim(); _record.Operation = OperationDoingdt.Rows[0]["OperationInfoId"].ToString().Trim(); _record.Diagnose = OperationDoingdt.Rows[0]["DiagnoseInfoId"].ToString().Trim(); _record.AnaesthesiaMethodId = OperationDoingdt.Rows[0]["AnaesthesiaMethodId"].ToString().Trim(); _record.OperationSiteId = OperationDoingdt.Rows[0]["OperationBodyPositionId"].ToString().Trim(); _record.OperationPositionId = OperationDoingdt.Rows[0]["OperationPositionId"].ToString().Trim(); _record.OperationDoctor = OperationDoingdt.Rows[0]["OperationDoctorId"].ToString().Trim(); _record.Assistant1 = OperationDoingdt.Rows[0]["AssistantId"].ToString().Trim(); _record.AnesthesiaDoctor = OperationDoingdt.Rows[0]["AnesthesiaDoctorId"].ToString().Trim(); _record.InstrumentNurse = OperationDoingdt.Rows[0]["InstrumentNurseId"].ToString().Trim(); _record.TourNurse = OperationDoingdt.Rows[0]["TourNurseId"].ToString().Trim(); _record.AnesthesiaDoctorAssistant = OperationDoingdt.Rows[0]["OrtherDoctorId"].ToString().Trim(); _record.ASALevel = OperationDoingdt.Rows[0]["ASALevel"].ToString().Trim(); _record.SpecialCase = OperationDoingdt.Rows[0]["SpecialCase"].ToString().Trim(); if (_record.SpecialCase == null || _record.SpecialCase == "") _record.SpecialCase = "无"; if (OperationDoingdt.Rows[0]["Fasting"].ToString() != "") _record.Fasting = int.Parse(OperationDoingdt.Rows[0]["Fasting"].ToString()); _record.BloodType = OperationDoingdt.Rows[0]["BloodType"].ToString().Trim(); } FillEventsDataAll(PatientId, RecoverId, _record); FillDrugDataAll(PatientId, RecoverId, _record); DrawOutFluid(PatientId, RecoverId, _record); GetAnaseDataQualityRecord(_record); _record.OpeRecordInfo = BOperationRecordInfo.SelectSingle("OperationRecordId=" + _record.Id, null); if (_record.OpeRecordInfo == null) _record.OpeRecordInfo = new OperationRecordInfo(); _record.SpareSix = ""; if (_record.OpeRecordInfo.AnesthesiaSucceed != null && _record.OpeRecordInfo.AnesthesiaSucceed != "") { _record.SpareSix += "麻醉接台:" + _record.OpeRecordInfo.AnesthesiaSucceed + " "; if (_record.OpeRecordInfo.AnesthesiaSucceedTime != null) _record.SpareSix += "时间:" + _record.OpeRecordInfo.AnesthesiaSucceedTime.Value.ToString("yyyy-MM-dd HH:mm") + " "; } if (_record.OpeRecordInfo.InstrumentNurseSucceed != null && _record.OpeRecordInfo.InstrumentNurseSucceed != "") { _record.SpareSix += "巡回接台:" + _record.OpeRecordInfo.InstrumentNurseSucceed + " "; if (_record.OpeRecordInfo.InstrumentNurseSucceedTime != null) _record.SpareSix += "时间:" + _record.OpeRecordInfo.InstrumentNurseSucceedTime.Value.ToString("yyyy-MM-dd HH:mm") + " "; } if (_record.OpeRecordInfo.TourNurseSucceed != null && _record.OpeRecordInfo.TourNurseSucceed != "") { _record.SpareSix += "器械接台:" + _record.OpeRecordInfo.TourNurseSucceed + " "; if (_record.OpeRecordInfo.TourNurseSucceedTime != null) _record.SpareSix += "时间:" + _record.OpeRecordInfo.TourNurseSucceedTime.Value.ToString("yyyy-MM-dd HH:mm") + " "; } if (_record.OpeRecordInfo.Experts != null && _record.OpeRecordInfo.Experts != "") { _record.SpareSix += "外请专家:" + _record.OpeRecordInfo.Experts + " "; } if (_record.OpeRecordInfo.RuleAnesthesiaDoctor != null && _record.OpeRecordInfo.RuleAnesthesiaDoctor != "") { _record.SpareSix += "规培麻醉医生:" + _record.OpeRecordInfo.RuleAnesthesiaDoctor + " "; } if (_record.OpeRecordInfo.RuleNurse != null && _record.OpeRecordInfo.RuleNurse != "") { _record.SpareSix += "规培护士:" + _record.OpeRecordInfo.RuleNurse + " "; } _record.OpeRecoverInInfo = BOperationRecoverInInfo.SelectSingle("PatientId=" + _record.PatientId, null); if (_record.OpeRecoverInInfo == null) _record.OpeRecoverInInfo = new OperationRecoverInInfo(); _record.OpeRecoverOutInfo = BOperationRecoverOutInfo.SelectSingle("PatientId=" + _record.PatientId, null); if (_record.OpeRecoverOutInfo == null) _record.OpeRecoverOutInfo = new OperationRecoverOutInfo(); _record.FactBloodGasAnalysisList = BFactBloodGasAnalysis.Select("OperationRecordId=" + _record.Id, null); foreach (var item in _record.FactBloodGasAnalysisList) { item.FactBloodGasAnalysisDataList = BFactBloodGasAnalysisData.Select("RecordId=" + item.Id, null); } int x = 0; double allDrugDose = 0, allOutDose = 0; _record.SpareTwo = ""; _record.SpareThree = ""; _record.SpareFour = ""; foreach (var item in _record.FactDrugList) { string dose = ""; if (dose.Trim() != "") dose += " "; dose += ((double)item.Dosage).ToString(); if (item.DosageUnit != null) { dose += item.DosageUnit; } _record.SpareFour += string.Format("({0}){1} {2} {3}{4}{5} ", x + 1, (item.DrugBeginTime == item.DrugEndTime) ? item.DrugBeginTime.ToShortTimeString() : item.DrugBeginTime.ToShortTimeString() + "->" + item.DrugEndTime.ToShortTimeString(), item.DrugName.Trim(), dose, "", item.DrugChannel == null ? "" : " " + item.DrugChannel.ToString()); if (item.Dosage != 0) { Double val = Convert.ToDouble(item.Dosage); allDrugDose += val; } x++; } _record.SpareTwo = allDrugDose.ToString(); foreach (var item in _record.FactOutputLiquidsList) { string dose = ""; if (dose.Trim() != "") dose += " "; dose += ((double)item.Dosage).ToString(); if (item.DosageUnit != null) { dose += item.DosageUnit; } _record.SpareFour += string.Format("({0}){1} {2} {3} ", x + 1, (item.BeginTime == item.EndTime) ? item.BeginTime.ToShortTimeString() : item.BeginTime.ToShortTimeString() + "->" + item.EndTime.ToShortTimeString(), item.OutputLiquidsName.Trim(), dose); if (item.DosageUnit.Trim() == "mL" || item.DosageUnit.Trim() == "ml" || item.DosageUnit.Trim() == "ML") { if (item.Dosage != 0) { Double val = Convert.ToDouble(item.Dosage); allOutDose += val; } } x++; } _record.SpareThree = allOutDose.ToString(); _record.InstrumentList = BOperationRecordInstrumentList.SelectSingle(" OperationRecordId=" + Convert.ToInt32(_record.Id), null); if (_record.InstrumentList != null) { _record.InstrumentList.ApplianceRecordList = BApplianceRecord.GetApplianceRecordById(Convert.ToInt32(_record.Id), Convert.ToInt32(_record.InstrumentList.Id)); } return _record; } public static void FillDrugDataAll(int PatientId, int TypeId, OperationRecord _record) { //药品 _record.FactDrugList.Clear(); DataTable DrugAllData = BOperationRecord.FillDrugData(PatientId, TypeId); for (int i = 0; i < DrugAllData.Rows.Count; i++) { FactDrug FactDrug = new FactDrug(); FactDrug.Id = int.Parse(DrugAllData.Rows[i]["Id"].ToString()); ; FactDrug.DrugTypeId = TypeId; FactDrug.PatientId = PatientId; FactDrug.ParentId = int.Parse(DrugAllData.Rows[i]["ParentId"].ToString()); ; FactDrug.DrugId = int.Parse(DrugAllData.Rows[i]["DrugsId"].ToString()); FactDrug.DrugName = DrugAllData.Rows[i]["DrugName"].ToString(); FactDrug.DrugBeginTime = DateTime.Parse(DateTime.Parse(DrugAllData.Rows[i]["DrugBeginTime"].ToString()).ToString("yyyy-MM-dd HH:mm:ss")); FactDrug.DrugEndTime = DateTime.Parse(DateTime.Parse(DrugAllData.Rows[i]["DrugEndTime"].ToString()).ToString("yyyy-MM-dd HH:mm:ss")); if (DrugAllData.Rows[i]["Dosage"].ToString() != "") FactDrug.Dosage = decimal.Parse(DrugAllData.Rows[i]["Dosage"].ToString()); FactDrug.DosageUnit = DrugAllData.Rows[i]["DosageUnit"].ToString(); FactDrug.DrugChannel = DrugAllData.Rows[i]["DrugChannel"].ToString(); FactDrug.GiveDrugType = DrugAllData.Rows[i]["GiveDrugType"].ToString(); FactDrug.Remark = DrugAllData.Rows[i]["Remark"].ToString(); FactDrug.DrugKind = DrugAllData.Rows[i]["DrugKind"].ToString(); FactDrug.IsContinue = int.Parse(DrugAllData.Rows[i]["IsContinue"].ToString()); if (DrugAllData.Rows[i]["Density"].ToString() != "") FactDrug.Density = decimal.Parse(DrugAllData.Rows[i]["Density"].ToString()); FactDrug.DensityUnit = DrugAllData.Rows[i]["DensityUnit"].ToString(); if (DrugAllData.Rows[i]["Velocity"].ToString() != "") FactDrug.Velocity = decimal.Parse(DrugAllData.Rows[i]["Velocity"].ToString()); FactDrug.VelocityUnit = DrugAllData.Rows[i]["VelocityUnit"].ToString(); FactDrug.BloodType = DrugAllData.Rows[i]["BloodType"].ToString(); FactDrug.OperatorNo = DrugAllData.Rows[i]["OperatorNo"].ToString(); FactDrug.OperatorName = DrugAllData.Rows[i]["OperatorName"].ToString(); FactDrug.OperateDate = DateTime.Parse(DrugAllData.Rows[i]["OperateDate"].ToString()); _record.FactDrugList.Add(FactDrug); } } public static void FillEventsDataAll(int PatientId, int TypeId, OperationRecord _record) { //事件 _record.FactEventsList.Clear(); DataTable dt = BFactEvents.GetDataTable(PatientId, TypeId); for (int i = 0; i < dt.Rows.Count; i++) { FactEvents FactEventsObj = new FactEvents(); FactEventsObj.Id = int.Parse(dt.Rows[i]["Id"].ToString()); if (dt.Rows[i]["Remark"].ToString() == "") { FactEventsObj.EventName = dt.Rows[i]["EventName"].ToString(); } else { FactEventsObj.EventName = dt.Rows[i]["EventName"].ToString() + " " + dt.Rows[i]["Remark"].ToString(); } FactEventsObj.EventBeginTime = DateTime.Parse(DateTime.Parse(dt.Rows[i]["EventBeginTime"].ToString()).ToString("yyyy-MM-dd HH:mm:ss")); FactEventsObj.EventEndTime = DateTime.Parse(DateTime.Parse(dt.Rows[i]["EventEndTime"].ToString()).ToString("yyyy-MM-dd HH:mm:ss")); FactEventsObj.OperatorNo = dt.Rows[i]["OperatorNo"].ToString(); FactEventsObj.OperatorName = dt.Rows[i]["OperatorName"].ToString(); FactEventsObj.OperateDate = DateTime.Parse(dt.Rows[i]["OperateDate"].ToString()); _record.FactEventsList.Add(FactEventsObj); if (FactEventsObj.EventName == "手术开始") { _record.OperationBeginTime = FactEventsObj.EventBeginTime; } if (FactEventsObj.EventName == "手术结束") { _record.OperationEndTime = FactEventsObj.EventBeginTime; } if (FactEventsObj.EventName == "麻醉开始") { _record.AnesthesiaBeginTime = FactEventsObj.EventBeginTime; } if (FactEventsObj.EventName == "麻醉完成") { _record.AnesthesiaEndTime = FactEventsObj.EventBeginTime; } if (FactEventsObj.EventName == "插管") { _record.InCGType = FactEventsObj.EventName; _record.InCGTime = FactEventsObj.EventBeginTime; } if (FactEventsObj.EventName == "喉罩") { _record.InCGType = FactEventsObj.EventName; _record.InCGTime = FactEventsObj.EventBeginTime; } if (FactEventsObj.EventName == "拔管") { _record.OutCGTime = FactEventsObj.EventBeginTime; } } } public static void DrawOutFluid(int PatientId, int TypeId, OperationRecord _record) { //出量 _record.FactOutputLiquidsList.Clear(); DataTable OutputLiquidsDistinct = BOperationRecord.FillOutFluid(PatientId, TypeId); for (int i = 0; i < OutputLiquidsDistinct.Rows.Count; i++) { FactOutputLiquids OutputLiquidsObj = new FactOutputLiquids(); OutputLiquidsObj.OutputLiquidsTypeId = TypeId; OutputLiquidsObj.PatientId = PatientId; OutputLiquidsObj.Id = int.Parse(OutputLiquidsDistinct.Rows[i]["Id"].ToString()); OutputLiquidsObj.OutputLiquidsId = int.Parse(OutputLiquidsDistinct.Rows[i]["OutputLiquidsId"].ToString()); OutputLiquidsObj.OutputLiquidsName = OutputLiquidsDistinct.Rows[i]["OutputLiquidsName"].ToString(); OutputLiquidsObj.DosageUnit = OutputLiquidsDistinct.Rows[i]["DosageUnit"].ToString(); OutputLiquidsObj.BeginTime = DateTime.Parse(DateTime.Parse(OutputLiquidsDistinct.Rows[i]["BeginTime"].ToString()).ToString("yyyy-MM-dd HH:mm:ss")); OutputLiquidsObj.EndTime = DateTime.Parse(DateTime.Parse(OutputLiquidsDistinct.Rows[i]["EndTime"].ToString()).ToString("yyyy-MM-dd HH:mm:ss")); OutputLiquidsObj.Dosage = decimal.Parse(OutputLiquidsDistinct.Rows[i]["Dosage"].ToString()); OutputLiquidsObj.DosageUnit = OutputLiquidsDistinct.Rows[i]["DosageUnit"].ToString(); OutputLiquidsObj.Remark = OutputLiquidsDistinct.Rows[i]["Remark"].ToString(); _record.FactOutputLiquidsList.Add(OutputLiquidsObj); } } public static void GetAnaseDataQualityRecord(OperationRecord _record) { //出量 _record.AnaseDataQualityRecordList.Clear(); _record.AnaseDataQualityRecordList = BAnaseDataQualityRecord.Select("OperationRecordId=" + _record.Id, null); } /// /// 判断添加的事件 是否正确 /// /// true :术中 false:恢复 /// 手术对象 /// 事件名称 /// 事件时间 /// 返回提示消息 /// public static bool IfTimeisTrue(bool OpeState, OperationRecord _record, string EventName, DateTime curTimeTemp, ref string messing) { //if (curTimeTemp > PublicMethod.ServerTime()) //{ // messing = EventName + "时间不可以大于当前时间 !"; // return false; //} TimeSpan ifinroom = curTimeTemp - _record.InRoomTime.Value; if (EventName != "入室" && _record.InRoomTime == null) { messing = "请填写入室时间 !"; return false; } else if (EventName != "入室" && (ifinroom.TotalHours > 48 || ifinroom.TotalDays < -48)) { messing = EventName + "时间不能大于入室时间48小时 !"; return false; } else if (EventName != "入室" && EventName != "麻醉开始" && _record.InRoomTime > curTimeTemp)// && OpeState == true { //TimeSpan tsp = DateTime.Now - _record.InRoomTime.Value; //if (tsp.TotalHours > 12 || tsp.TotalDays > 1) // messing = "";// "请在“事件记录”添加" + EventName + "时间!"; //else messing = EventName + "时间不能小于入室时间(" + _record.InRoomTime + ") !"; return false; } if (_record.OutRoomTime != null && EventName != "出室" && EventName != "麻醉结束" && _record.OutRoomTime < curTimeTemp && OpeState == true) { messing = EventName + "时间不能大于出室时间(" + _record.OutRoomTime + ") !"; return false; } //if (EventName == "麻醉开始" && _record.OperationBeginTime != null && curTimeTemp > _record.OperationBeginTime && OpeState == true) //{ // messing = "麻醉开始时间不能大于手术开始时间(" + _record.OperationBeginTime + ") !"; // return false; //} //if (EventName == "手术开始" && _record.AnesthesiaBeginTime == null && OpeState == true) //{ // messing = "请先填写麻醉开始时间!"; // return false; //} //if (EventName == "手术开始" && curTimeTemp < _record.AnesthesiaBeginTime && OpeState == true) //{ // messing = "手术开始时间必须晚于麻醉开始时间(" + _record.AnesthesiaBeginTime + ") !"; // return false; //} else if (EventName == "手术开始" && _record.OperationEndTime != null && curTimeTemp > _record.OperationEndTime && OpeState == true) { messing = "手术开始时间不能大于手术结束时间(" + _record.OperationBeginTime + ") !"; return false; } if (EventName == "手术结束" && _record.OperationBeginTime == null && OpeState == true) { messing = "请先填写手术开始时间!"; return false; } else if (EventName == "手术结束" && curTimeTemp < _record.OperationBeginTime && OpeState == true) { messing = "手术结束时间必须晚于手术开始时间(" + _record.OperationBeginTime + ") !"; return false; } if (EventName == "出室" && _record.OperationEndTime == null && OpeState == true) { messing = "请先填写手术结束时间!"; return false; } else if (EventName == "出室" && curTimeTemp < _record.OperationEndTime && OpeState == true) { messing = "出室时间必须晚于手术结束时间(" + _record.OperationEndTime + ") !"; return false; } return true; } public static DataTable getOperationRecorePhysioData(int operationId) { string sqlStr = "exec [dbo].[usp_GetOperationRecorePhysioData] " + operationId; return DBHelper.GetDataTable(sqlStr); } public static int AddTitleTime(int PatientId, int ApplyId, int RecoverId, string TableColumnName, DateTime Time, int RoomId) { return DOperationRecord.AddTitleTime(PatientId, ApplyId, RecoverId, TableColumnName, Time, RoomId); } public static TitleTime GetTitleTime(int PatientId, int RecoverId) { return DOperationRecord.GetTitleTime(PatientId, RecoverId); } public static void UpdateState(int PatientId, int TypeId, int State) { DOperationRecord.UpdateState(PatientId, TypeId, State); } public static void DeleteOperationRecordData(int RecorId, int PatientId, int TypeId) { DOperationRecord.DeleteOperationRecordData(RecorId, PatientId, TypeId); } public static void DeleteOperationRecorvreData(int PatientId, int TypeId) { DOperationRecord.DeleteOperationRecorvreData(PatientId, TypeId); } public static void DeleteEvent(int PatientId, int eventId) { DOperationRecord.DeleteEvent(PatientId, eventId); } public static DataTable GetOperationDoingDataTableByPatientId(int PatientId, int TypeId) { return DOperationRecord.GetOperationDoingMainInfo(PatientId, TypeId); } public static bool ValidInput(int PatientId, int TypeId) { bool result = false; DataTable dt = DOperationRecord.GetOperationDoingMainInfo(PatientId, TypeId); if (dt.Rows[0]["InRoomTime"].ToString().Length < 1) { MessageBox.Show("入室不能为空!"); } else if (dt.Rows[0]["OutRoomTime"].ToString().Length < 1) { MessageBox.Show("出室不能为空!"); } else if (dt.Rows[0]["OperationBeginTime"].ToString().Length < 1) { MessageBox.Show("手术开始时间不能为空!"); } else if (dt.Rows[0]["OperationEndTime"].ToString().Length < 1) { MessageBox.Show("手术结束时间不能为空!"); } else if (dt.Rows[0]["DiagnoseInfoName"].ToString().Length < 1) { MessageBox.Show("术后诊断不能为空!"); } else if (dt.Rows[0]["OperationInfoName"].ToString().Length < 1) { MessageBox.Show("实施手术不能为空!"); } else if (dt.Rows[0]["AnaesthesiaMethodName"].ToString().Length < 1) { MessageBox.Show("麻醉方式不能为空!"); } else if (dt.Rows[0]["OperationDoctor"].ToString().Length < 1) { MessageBox.Show("手术医生不能为空!"); } else if (dt.Rows[0]["AnesthesiaDoctor"].ToString().Length < 1) { MessageBox.Show("麻醉医生不能为空!"); } else { result = true; } return result; } /// /// 得到手术的最大时间点 /// /// /// public static DateTime lastMaxOperationDate(int PatientId) { string sqlStr = "select top 1 * from (SELECT s.PatientId , s.EventEndTime etime FROM FactEvents s WHERE s.PatientId = " + PatientId + " union all SELECT s.PatientId , s.DrugEndTime FROM[dbo].[FactDrug] s WHERE s.PatientId = " + PatientId + " ) a order by a.etime desc"; DataTable dt = DBHelper.GetDataTable(sqlStr); return DateTime.Parse(dt.Rows[0][1].ToString()); } public static DataTable getPhysioDataByTimeName(string IP, string name, DateTime starttime, DateTime endtime) { DataTable dt = new DataTable(); string sqlStr = " exec [usp_GetPhysioDataByName] '" + IP + "','" + name + "','" + starttime + "','" + endtime + "'";// dt = DATADBHelper.GetDataTable(sqlStr); return dt; } public static DataTable getPhysioDataByIp(string IP, int operationId, DateTime starttime, DateTime endtime, int collectInterval) { DataTable dt = new DataTable(); string sqlStr = " exec [usp_GetPhysioDataByIp] '" + IP + "','" + starttime + "','" + endtime + "'," + collectInterval; dt = DATADBHelper.GetDataTable(sqlStr); foreach (DataRow item in dt.Rows) { if (item[0].ToString() == "7") { foreach (DataRow item1 in dt.Rows) { if (item1[0].ToString() == "5" && item1[1].ToString() == item[1].ToString()) { item1[2] = "0"; } } } if (item[0].ToString() == "8") { foreach (DataRow item1 in dt.Rows) { if (item1[0].ToString() == "6" && item1[1].ToString() == item[1].ToString()) { item1[2] = "0"; } } } } return dt; } public static int Update(string oql, ParameterList parameters) { using (SqlConnection conn = new SqlConnection(Connection.ConnectionString)) { conn.Open(); using (SqlCommand cmd = conn.CreateCommand()) { //解析过滤部份Sql语句 string updateString = oql;// SyntaxAnalyzer.ParseSql(oql, new OperationRecordMap()); cmd.CommandText = "update OperationRecord set " + updateString; cmd.Parameters.Clear(); //添加参数 if (parameters != null) { foreach (string key in parameters.Keys) { cmd.Parameters.Add(new SqlParameter(key, parameters[key])); } } return cmd.ExecuteNonQuery(); } } } public static DateTime GetMaxTime(int PatientId, int Type) { return DOperationRecord.GetMaxTime(PatientId, Type); } public static int GetDataCount(int RecorId, int PatientId, int Type) { return DOperationRecord.GetDataCount(RecorId, PatientId, Type); } public static DataTable FillDrugData(int PatientId, int DrugTypeId) { return DOperationRecord.FillDrugData(PatientId, DrugTypeId); } public static DataTable FillOutFluid(int PatientId, int DrugTypeId) { return DOperationRecord.FillOutFluid(PatientId, DrugTypeId); } } }