808 lines
43 KiB
C#
808 lines
43 KiB
C#
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;
|
||
using System.Text;
|
||
|
||
namespace AIMSBLL
|
||
{
|
||
public partial class BOperationRecord
|
||
{
|
||
public static int AddTitleTime(int PatientId, int ApplyId, int RecoverId, int State, DateTime Time, int RoomId)
|
||
{
|
||
return DOperationRecord.AddTitleTime(PatientId, ApplyId, RecoverId, State, Time, RoomId);
|
||
}
|
||
public static int AddTitleTime2(int PatientId, int ApplyId, int RecoverId, int State, int RoomId)
|
||
{
|
||
return DOperationRecord.AddTitleTime2(PatientId, ApplyId, RecoverId, State, RoomId);
|
||
}
|
||
public static OperationRecord getRecord(OperationRecord _record, int PatientId, int RecoverId)
|
||
{
|
||
if (_record == null) _record = new OperationRecord();
|
||
if (PatientId == -1)
|
||
{
|
||
return _record;
|
||
}
|
||
BOperationRecord.SelectSingle(PatientId, RecoverId, ref _record);
|
||
|
||
if (_record.InRoomTime != null)
|
||
{
|
||
_record.OperationDate = _record.InRoomTime.Value.ToShortDateString();
|
||
_record.OpeDay = _record.InRoomTime.Value.ToString("yyyy-MM-dd");
|
||
}
|
||
|
||
string ASALevel = "";
|
||
DataTable OperationFrontdt = BOperationApply.GetOperationFrontDataTableByPatientId(PatientId);
|
||
if (OperationFrontdt.Rows.Count > 0)
|
||
{
|
||
_record.HISPatientId = OperationFrontdt.Rows[0]["HISPatientId"].ToString();
|
||
_record.VisitTimes = OperationFrontdt.Rows[0]["VisitTimes"].ToString();
|
||
_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.PatientDepName = OperationFrontdt.Rows[0]["PatientDepName"].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 = OperationFrontdt.Rows[0]["Age"].ToString();
|
||
_record.Identity = OperationFrontdt.Rows[0]["IdentityCard"].ToString();
|
||
_record.FareType = OperationFrontdt.Rows[0]["PatientKind"].ToString();
|
||
_record.BloodType = OperationFrontdt.Rows[0]["BloodType"].ToString();
|
||
_record.RHBloodType = OperationFrontdt.Rows[0]["RHBloodType"].ToString();
|
||
ASALevel = OperationFrontdt.Rows[0]["ASA"].ToString();
|
||
if (OperationFrontdt.Rows[0]["Height"].ToString() != "")
|
||
{
|
||
double Height = 0;
|
||
bool isNum = double.TryParse(OperationFrontdt.Rows[0]["Height"].ToString(), out Height);
|
||
if (isNum == true)
|
||
{
|
||
_record.Height = Height.ToString();
|
||
}
|
||
else
|
||
{
|
||
_record.Height = OperationFrontdt.Rows[0]["Height"].ToString();
|
||
}
|
||
}
|
||
if (OperationFrontdt.Rows[0]["Weight"].ToString() != "")
|
||
{
|
||
double Weight = 0;
|
||
bool isNum = double.TryParse(OperationFrontdt.Rows[0]["Weight"].ToString(), out Weight);
|
||
if (isNum == true)
|
||
{
|
||
_record.Weight = Weight.ToString();
|
||
}
|
||
else
|
||
{
|
||
_record.Weight = OperationFrontdt.Rows[0]["Weight"].ToString();
|
||
}
|
||
}
|
||
_record.Applydiagnose = OperationFrontdt.Rows[0]["ApplyDiagnoseInfoId"].ToString();
|
||
_record.Applyoperation = OperationFrontdt.Rows[0]["ApplyOperationInfoId"].ToString();
|
||
_record.OperationType = OperationFrontdt.Rows[0]["OperationType"].ToString();
|
||
_record.MedicalRecord = OperationFrontdt.Rows[0]["MedicalRecord"].ToString();
|
||
_record.PlanOperationTime = DateTime.Parse(OperationFrontdt.Rows[0]["PlanOperationTime"].ToString());
|
||
}
|
||
|
||
DataTable OperationDoingdt = BOperationRecord.GetOperationDoingDataTableByPatientId(PatientId, RecoverId);
|
||
if (OperationDoingdt.Rows.Count > 0)
|
||
{
|
||
_record.StateName = 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.OrtherDoctorId = OperationDoingdt.Rows[0]["OrtherDoctorId"].ToString().Trim();
|
||
if (_record.SpecialCase == null || _record.SpecialCase == "") _record.SpecialCase = "无";
|
||
_record.OperationRoom = OperationDoingdt.Rows[0]["OperationRoom"].ToString().Trim();
|
||
if (_record.Breath == null || _record.Breath == "")
|
||
_record.Breath = "10";
|
||
|
||
}
|
||
|
||
_record.OpeRecordInfo = BOperationRecordInfo.SelectSingle("OperationRecordId=" + _record.Id, null);
|
||
if (_record.OpeRecordInfo == null || _record.OpeRecordInfo.Id == null)
|
||
{
|
||
_record.OpeRecordInfo = new OperationRecordInfo();
|
||
_record.OpeRecordInfo.OperationRecordId = _record.Id;
|
||
_record.OpeRecordInfo.PatientId = PatientId;
|
||
_record.OpeRecordInfo.ApplyId = _record.OperationApplyId;
|
||
if (OperationFrontdt.Rows.Count > 0)
|
||
{
|
||
_record.OpeRecordInfo.OperationLevel = OperationFrontdt.Rows[0]["OperationLevelName"].ToString();
|
||
}
|
||
if (PublicMethod.HospitalName.Contains("漳浦"))
|
||
{
|
||
if (_record.OpeRecordInfo.InfoRemark == null || _record.OpeRecordInfo.InfoRemark == "")
|
||
_record.OpeRecordInfo.InfoRemark = "-";
|
||
if (_record.OpeRecordInfo.NeedleDirection == null || _record.OpeRecordInfo.NeedleDirection == "")
|
||
_record.OpeRecordInfo.NeedleDirection = "-";
|
||
if (_record.OpeRecordInfo.PunctureRemark2 == null || _record.OpeRecordInfo.PunctureRemark2 == "")
|
||
_record.OpeRecordInfo.PunctureRemark2 = "有";
|
||
}
|
||
_record.OpeRecordInfo.OperatorId = PublicMethod.OperatorName;
|
||
_record.OpeRecordInfo.OperatorTime = DateTime.Now;
|
||
_record.OpeRecordInfo.Id = BOperationRecordInfo.Insert(_record.OpeRecordInfo);
|
||
//是否启用默认项
|
||
if (PublicMethod.HospitalName.Contains("漳浦") && RecoverId==1)
|
||
{
|
||
if (_record.OpeSpecialCondition == null || _record.OpeSpecialCondition == "")
|
||
_record.OpeSpecialCondition = "无特殊情况";
|
||
if (_record.SpecialEvent == null || _record.SpecialEvent == "")
|
||
_record.SpecialEvent = "-";
|
||
if (_record.Remark1 == null || _record.Remark1 == "")
|
||
_record.Remark1 = "-";
|
||
if (_record.Remark2 == null || _record.Remark2 == "")
|
||
_record.Remark2 = "否";
|
||
if (_record.SpileWard == null || _record.SpileWard == "")
|
||
_record.SpileWard = "手术室";
|
||
if (_record.MuscleStrengthRecovery == null || _record.MuscleStrengthRecovery == "")
|
||
_record.MuscleStrengthRecovery = "好";
|
||
if (_record.CoughReflex == null || _record.CoughReflex == "")
|
||
_record.CoughReflex = "有";
|
||
if (_record.InOperaRoomState == null || _record.InOperaRoomState == "")
|
||
_record.InOperaRoomState = "清醒";
|
||
if (_record.ControlledAnalgesia == null || _record.ControlledAnalgesia == "")
|
||
_record.ControlledAnalgesia = "无";
|
||
if (_record.AnalgesiaRate == null || _record.AnalgesiaRate == "")
|
||
_record.AnalgesiaRate = "无";
|
||
if (_record.AnalgesiaModel == null || _record.AnalgesiaModel == "")
|
||
_record.AnalgesiaModel = "-";
|
||
if (_record.Pulse == null || _record.Pulse == "")
|
||
_record.Pulse = "病房";
|
||
if (_record.RouteMonitoring == null || _record.RouteMonitoring == "")
|
||
_record.RouteMonitoring = "自主呼吸氧气";
|
||
if (_record.Entourage == null || _record.Entourage == "")
|
||
_record.Entourage = "麻醉医师,护士";
|
||
BOperationRecord.Update(_record);
|
||
}
|
||
}
|
||
_record.AnalgesiaRecord = BOperationRecordAnalgesia.SelectSingle("OperationRecordId=" + _record.Id, null);
|
||
if (_record.AnalgesiaRecord == null || _record.AnalgesiaRecord.Id == null)
|
||
{
|
||
_record.AnalgesiaRecord = new OperationRecordAnalgesia();
|
||
_record.AnalgesiaRecord.OperationRecordId = _record.Id;
|
||
_record.AnalgesiaRecord.PatientId = PatientId;
|
||
_record.AnalgesiaRecord.ApplyId = _record.OperationApplyId;
|
||
_record.AnalgesiaRecord.IsValid = 1;
|
||
_record.AnalgesiaRecord.OperatorId = PublicMethod.OperatorId;
|
||
_record.AnalgesiaRecord.OperatorTime = DateTime.Now;
|
||
_record.AnalgesiaRecord.Id = BOperationRecordAnalgesia.Insert(_record.AnalgesiaRecord);
|
||
}
|
||
_record.FactBloodGasAnalysisList = BFactBloodGasAnalysis.Select("OperationRecordId=" + _record.Id, null);
|
||
foreach (var item in _record.FactBloodGasAnalysisList)
|
||
{
|
||
item.FactBloodGasAnalysisDataList = BFactBloodGasAnalysisData.Select("RecordId=" + item.Id, null);
|
||
}
|
||
|
||
FillEventsDataAll(PatientId, RecoverId, _record);
|
||
|
||
FillDrugDataAll(PatientId, RecoverId, _record);
|
||
|
||
DrawOutFluid(PatientId, RecoverId, _record);
|
||
|
||
GetAnaseDataQualityRecord(_record);
|
||
|
||
_record.SpareFive = "";
|
||
if (_record.OutRoomTime != null && _record.InRoomTime != null)
|
||
_record.SpareFive = Convert.ToInt32(((TimeSpan)(_record.OutRoomTime - _record.InRoomTime)).TotalMinutes).ToString() + "分钟";
|
||
_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 + " ";
|
||
}
|
||
|
||
if (RecoverId == 2)
|
||
{
|
||
_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.OpeRecoverOutInfo.Extend1 = " /";
|
||
_record.OpeRecoverOutInfo.Extend2 = " /";
|
||
}
|
||
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.DosageUnit.Trim() == "mL" || item.DosageUnit.Trim() == "ml" || item.DosageUnit.Trim() == "ML")
|
||
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();
|
||
|
||
}
|
||
|
||
|
||
List<OperationRecordInstrumentList> InstrumentLists = BOperationRecordInstrumentList.Select(" OperationRecordId=" + Convert.ToInt32(_record.Id), null);
|
||
if (InstrumentLists != null && InstrumentLists.Count > 0)
|
||
{
|
||
_record.InstrumentList = InstrumentLists[0];
|
||
//if (_record.InstrumentList != null)
|
||
//{
|
||
_record.InstrumentList.ApplianceRecordList = BApplianceRecord.GetApplianceRecordById(Convert.ToInt32(_record.Id), Convert.ToInt32(_record.InstrumentList.Id));
|
||
//}
|
||
//else
|
||
//{
|
||
// _record.InstrumentList = new OperationRecordInstrumentList();
|
||
// _record.InstrumentList.OperationRecordId = _record.Id;
|
||
// _record.InstrumentList.OperatorNo = PublicMethod.OperatorNo;
|
||
// _record.InstrumentList.OperatorName = PublicMethod.OperatorName;
|
||
// _record.InstrumentList.Id = BOperationRecordInstrumentList.Insert(_record.InstrumentList);
|
||
//}
|
||
}
|
||
if (InstrumentLists != null && InstrumentLists.Count > 1)
|
||
{
|
||
_record.InstrumentList2 = InstrumentLists[1];
|
||
//if (_record.InstrumentList2 != null)
|
||
//{
|
||
_record.InstrumentList2.ApplianceRecordList = BApplianceRecord.GetApplianceRecordById(Convert.ToInt32(_record.Id), Convert.ToInt32(_record.InstrumentList2.Id));
|
||
//}
|
||
|
||
}
|
||
|
||
|
||
if ((_record.ASALevel == null || _record.ASALevel == 0) && ASALevel != "")
|
||
BOperationReview.GetASALevel(PatientId, _record, ASALevel);
|
||
else if (_record.ASALevel == null || _record.ASALevel == 0)
|
||
BOperationReview.GetASALevel(PatientId, _record);
|
||
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++)
|
||
{
|
||
if (DrugAllData.Rows[i]["DrugsId"].ToString() == "" || DrugAllData.Rows[i]["DrugsId"].ToString() == "0") return;
|
||
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());
|
||
FactDrug.AnesType = DrugAllData.Rows[i]["AnesType"].ToString();
|
||
FactDrug.Comment = DrugAllData.Rows[i]["Comment"].ToString();
|
||
FactDrug.Access = DrugAllData.Rows[i]["Access"].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());
|
||
FactEventsObj.EventName = dt.Rows[i]["EventName"].ToString();
|
||
FactEventsObj.EventId = int.Parse(dt.Rows[i]["EventId"].ToString());
|
||
FactEventsObj.Remark = dt.Rows[i]["Remark"].ToString();
|
||
FactEventsObj.EventRemark = dt.Rows[i]["EventRemark"].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.SpileInTime = FactEventsObj.EventBeginTime;
|
||
}
|
||
if (FactEventsObj.EventName == "喉罩")
|
||
{
|
||
_record.InCGType = FactEventsObj.EventName;
|
||
_record.SpileInTime = FactEventsObj.EventBeginTime;
|
||
}
|
||
if (FactEventsObj.EventName == "拔管")
|
||
{
|
||
_record.InBGType = FactEventsObj.EventName;
|
||
_record.SpileOutTime = FactEventsObj.EventBeginTime;
|
||
}
|
||
if (FactEventsObj.EventName == "拔喉罩")
|
||
{
|
||
_record.InBGType = FactEventsObj.EventName;
|
||
_record.SpileOutTime = 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);
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 判断添加的事件 是否正确
|
||
/// </summary>
|
||
/// <param name="OpeState">true :术中 false:复苏</param>
|
||
/// <param name="_record">手术对象</param>
|
||
/// <param name="EventName">事件名称</param>
|
||
/// <param name="curTimeTemp">事件时间</param>
|
||
/// <param name="messing">返回提示消息</param>
|
||
/// <returns></returns>
|
||
public static bool IfTimeisTrue(bool OpeState, OperationRecord _record, string EventName, DateTime curTimeTemp, ref string messing)
|
||
{
|
||
//if (curTimeTemp > PublicMethod.ServerTime())
|
||
//{
|
||
// messing = EventName + "时间不可以大于当前时间 !";
|
||
// return false;
|
||
//}
|
||
if (EventName=="插管" || EventName=="拔管" ||EventName=="喉罩" ||EventName=="拔喉罩")
|
||
{
|
||
return true;
|
||
}
|
||
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)
|
||
{
|
||
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.AnesthesiaBeginTime == null && OpeState == true)
|
||
{
|
||
messing = "请先填写麻醉开始时间!";
|
||
return false;
|
||
}
|
||
if (EventName == "手术结束" && _record.OperationBeginTime == null && OpeState == true)
|
||
{
|
||
messing = "请先填写手术开始时间!";
|
||
return false;
|
||
}
|
||
//if (EventName == "拔管" && _record.SpileInTime == null && OpeState == true)
|
||
//{
|
||
// messing = "请先填写插管时间!";
|
||
// return false;
|
||
//}
|
||
if (EventName == "手术开始" && curTimeTemp > _record.OperationEndTime && OpeState == true)
|
||
{
|
||
messing = "手术开始时间必须晚于手术结束时间(" + _record.OperationEndTime + ") !";
|
||
return false;
|
||
}
|
||
|
||
if (EventName == "手术结束" && curTimeTemp < _record.OperationBeginTime && OpeState == true)
|
||
{
|
||
messing = "手术结束时间必须晚于手术开始时间(" + _record.OperationBeginTime + ") !";
|
||
return false;
|
||
}
|
||
|
||
if (EventName == "出室" && _record.OperationEndTime == null && OpeState == true)
|
||
{
|
||
messing = "请先填写手术结束时间!";
|
||
return false;
|
||
}
|
||
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 void SelectSingle(int PatientId, int RecoverId, ref OperationRecord operationRecord)
|
||
{
|
||
DOperationRecord.SelectSingleEntity("PatientId=" + PatientId + " and RecoverId=" + RecoverId, ref operationRecord);
|
||
}
|
||
public static void UpdateState(int PatientId, int TypeId, int State)
|
||
{
|
||
DOperationRecord.UpdateState(PatientId, TypeId, State);
|
||
}
|
||
public static void UpdateOpeState(int PatientId, int TypeId, int State, string Text)
|
||
{
|
||
DOperationRecord.UpdateOpeState(PatientId, TypeId, State, Text);
|
||
}
|
||
public static void DeleteOperationRecordData(int RecorId, int PatientId, int TypeId)
|
||
{
|
||
DOperationRecord.DeleteOperationRecordData(RecorId, PatientId, TypeId);
|
||
}
|
||
public static void DeleteOperationRecorvreData(int RecorId, int PatientId, int TypeId)
|
||
{
|
||
DOperationRecord.DeleteOperationRecorvreData(RecorId, 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;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 得到手术的最大时间点
|
||
/// </summary>
|
||
/// <param name="doOpeInfo"></param>
|
||
/// <returns></returns>
|
||
public static DateTime lastMaxOperationDate(int PatientId, int TypeId)
|
||
{
|
||
string sqlStr = "select top 1 * from (SELECT s.PatientId , s.EventEndTime etime FROM FactEvents s WHERE s.EventTypeId=" + TypeId + " and s.PatientId = " + PatientId + " union all SELECT s.PatientId , s.DrugEndTime FROM[dbo].[FactDrug] s WHERE s.DrugTypeId=" + TypeId + " and 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[2].ToString() == item[2].ToString())
|
||
{
|
||
item1[1] = "-1";
|
||
}
|
||
}
|
||
}
|
||
if (item[0].ToString() == "8")
|
||
{
|
||
foreach (DataRow item1 in dt.Rows)
|
||
{
|
||
if (item1[0].ToString() == "6" && item1[2].ToString() == item[2].ToString())
|
||
{
|
||
item1[1] = "-1";
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return dt;
|
||
}
|
||
|
||
public static int DeletePhysioDataByOpeID(int operationId)
|
||
{
|
||
string sqlStr = "DELETE FROM PhysioData where PatientId = " + operationId + " ";
|
||
return DBHelper.ExecNonQuery(sqlStr);
|
||
}
|
||
|
||
public static int DeletePhysioDataByID(int operationId, int PhysioParameterID)
|
||
{
|
||
string sqlStr = "delete FROM PhysioData where PatientId = " + operationId + " and PhysioDataConfigId=" + PhysioParameterID;
|
||
return DBHelper.ExecNonQuery(sqlStr);
|
||
}
|
||
|
||
public static void UpdatePhysioDataRespByTime(OperationRecord record)
|
||
{
|
||
if (record.SpileInTime == null && record.SpileOutTime != null) return;
|
||
int zzhx = 3;
|
||
int jxtq = 12;
|
||
//限制没有插管不让点击拔管
|
||
//插管拔管时间都有 更新插管前机械通气为自主呼吸 插管后机械通气为自主呼吸 插管开始到拔管是自主呼吸为机械通气
|
||
//有插管时间没拔管时间 更新插管前机械通气为自主呼吸 插管后自主呼吸为机械通气
|
||
//没有插管拔管时间更新所有机械通气为自主呼吸
|
||
if (record.SpileInTime != null && record.SpileOutTime != null)
|
||
{
|
||
string sqlStr = "Update PhysioData set PhysioDataConfigId=" + zzhx + " where PatientId = " + record.Id + " and PhysioDataConfigId=" + jxtq + " and RecordTime<'" + record.SpileInTime + "' ";
|
||
DBHelper.ExecNonQuery(sqlStr);
|
||
string sqlStr2 = "Update PhysioData set PhysioDataConfigId=" + jxtq + " where PatientId = " + record.Id + " and PhysioDataConfigId=" + zzhx + " and RecordTime>='" + record.SpileInTime
|
||
+ "' and RecordTime<='" + record.SpileOutTime + "' ";
|
||
DBHelper.ExecNonQuery(sqlStr2);
|
||
string sqlStr3 = "Update PhysioData set PhysioDataConfigId=" + zzhx + " where PatientId = " + record.Id + " and PhysioDataConfigId=" + jxtq + " and RecordTime>'" + record.SpileOutTime + "' ";
|
||
DBHelper.ExecNonQuery(sqlStr3);
|
||
}
|
||
else if (record.SpileInTime != null && record.SpileOutTime == null)
|
||
{
|
||
string sqlStr = "Update PhysioData set PhysioDataConfigId=" + zzhx + " where PatientId = " + record.Id + " and PhysioDataConfigId=" + jxtq + " and RecordTime<'" + record.SpileInTime + "' ";
|
||
DBHelper.ExecNonQuery(sqlStr);
|
||
string sqlStr2 = "Update PhysioData set PhysioDataConfigId=" + jxtq + " where PatientId = " + record.Id + " and PhysioDataConfigId=" + zzhx + " and RecordTime>='" + record.SpileInTime
|
||
+ "' ";
|
||
DBHelper.ExecNonQuery(sqlStr2);
|
||
}
|
||
else if (record.SpileInTime == null && record.SpileOutTime == null)
|
||
{
|
||
string sqlStr = "Update PhysioData set PhysioDataConfigId=" + zzhx + " where PatientId = " + record.Id + " and PhysioDataConfigId=" + jxtq;
|
||
DBHelper.ExecNonQuery(sqlStr);
|
||
}
|
||
}
|
||
|
||
public static DataTable getByOpeIDIsPhysioData(int operationId, string PhysioDataConfigId)
|
||
{
|
||
string sqlStr = "SELECT [PhysioDataConfig].Name , PhysioData.RecordTime, PhysioData.[Value] FROM [dbo].[PhysioDataConfig] INNER JOIN PhysioData ON [PhysioDataConfig].Id = PhysioData.PhysioDataConfigId where PatientId = " + operationId + " and PhysioDataConfigId in (" + PhysioDataConfigId + ") order by PhysioDataConfigId,PhysioData.RecordTime ASC";
|
||
return DBHelper.GetDataTable(sqlStr);
|
||
}
|
||
public static DataTable getByOpeIDIsPhysioData(int operationId)
|
||
{
|
||
string sqlStr = "SELECT [PhysioDataConfig].Name ,PhysioData.PhysioDataConfigId, PhysioData.RecordTime, PhysioData.[Value] FROM [dbo].[PhysioDataConfig] INNER JOIN PhysioData ON [PhysioDataConfig].Id = PhysioData.PhysioDataConfigId where PatientId = " + operationId + " order by PhysioDataConfigId,PhysioData.RecordTime ASC";
|
||
return DBHelper.GetDataTable(sqlStr);
|
||
}
|
||
|
||
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);
|
||
}
|
||
public static DataTable GetOpesByNo(string no)
|
||
{
|
||
try
|
||
{
|
||
StringBuilder strSql = new StringBuilder();
|
||
strSql.Append("select top 10 * from [V_OperationRecordInfo] where [StateId] in(6,8,9) and RecoverId=1 and (MdrecNo like '%" + no + "%' ) order by RecoredId desc");
|
||
return DBHelper.GetDataTable(strSql.ToString());
|
||
}
|
||
catch (Exception)
|
||
{
|
||
return new DataTable();
|
||
}
|
||
}
|
||
|
||
public static DataTable GetOpesByName(string name)
|
||
{
|
||
try
|
||
{
|
||
StringBuilder strSql = new StringBuilder();
|
||
strSql.Append("select top 10 * from [V_OperationRecordInfo] where [StateId] in(6,8,9) and RecoverId=1 and (MdrecNo like '%" + name + "%' or PatientName like '%" + name + "%') order by RecoredId desc");
|
||
return DBHelper.GetDataTable(strSql.ToString());
|
||
}
|
||
catch (Exception)
|
||
{
|
||
return new DataTable();
|
||
}
|
||
}
|
||
public static DataTable GetOpeIdByNoName(string no, string name)
|
||
{
|
||
try
|
||
{
|
||
StringBuilder strSql = new StringBuilder();
|
||
strSql.Append("select * from [V_OperationRecordInfo] where [StateId] in(6,8,9) and RecoverId=1 and (MdrecNo ='" + no + "' or PatientName='" + name + "') order by RecoredId desc");
|
||
return DBHelper.GetDataTable(strSql.ToString());
|
||
}
|
||
catch (Exception)
|
||
{
|
||
return null;
|
||
}
|
||
}
|
||
public static DataTable GetAllOperationRecordInfo(string condition)
|
||
{
|
||
StringBuilder sb = new StringBuilder("select * from V_OperationRecordInfo ");
|
||
if (condition.Length > 0)
|
||
{
|
||
sb.Append(" where " + condition);
|
||
}
|
||
try
|
||
{
|
||
return DBHelper.GetDataTable(sb.ToString());
|
||
}
|
||
catch (SqlException ex)
|
||
{
|
||
throw new Exception(ex.Message);
|
||
}
|
||
}
|
||
}
|
||
}
|