/// <summary> /// 获取呼吸时间列表 /// </summary> /// <param name="breathType"></param> /// <param name="anesEvent"></param> /// <param name="vitalSignGraph"></param> /// <returns></returns> private List <MedVitalSignBreathControlTime> BreathTimeList(string breathType, List <MED_ANESTHESIA_EVENT> anesEvent, MedVitalSignGraph vitalSignGraph, Dictionary <string, VitalSignCurveDetailModel> dict) { List <MED_ANESTHESIA_EVENT> rows = anesEvent.Where(x => x.EVENT_ITEM_NAME.Contains(breathType)).ToList(); DateTime controlStartTime = DateTime.MinValue; DateTime controlEndTime = DateTime.MaxValue; double dBreathValue = -1; //控制呼吸时间列表 List <MedVitalSignBreathControlTime> listControlTime = new List <MedVitalSignBreathControlTime>(); DateTime sysDatetTime = DateTime.Now; if (rows != null) { rows.ForEach(anesthesiaEventRow => { //初始化值 controlStartTime = DateTime.MinValue; controlEndTime = DateTime.MaxValue; if (anesthesiaEventRow.START_TIME.HasValue) { controlStartTime = anesthesiaEventRow.START_TIME.Value; } if (anesthesiaEventRow.END_TIME.HasValue) { controlEndTime = anesthesiaEventRow.END_TIME.Value; } if (anesthesiaEventRow.DOSAGE.HasValue) { dBreathValue = (double)anesthesiaEventRow.DOSAGE; } else { dBreathValue = 0; } //有开始时间 并且有体征数据 并且有呼吸值 if (controlStartTime != DateTime.MinValue && dBreathValue >= 0) { //没有结束时间 if (controlEndTime == DateTime.MaxValue) { controlEndTime = sysDatetTime; } DateTimeRange range = new DateTimeRange(controlStartTime, controlEndTime); //控制呼吸 MedVitalSignBreathControlTime breathControlTime = new MedVitalSignBreathControlTime(); breathControlTime.startTime = range.StartDateTime; breathControlTime.endTime = range.EndDateTime; breathControlTime.oStartTime = controlStartTime; breathControlTime.oEndTime = controlEndTime; breathControlTime.breathValue = dBreathValue; //显示频率 int timeSpan = 5; string breathName = "呼吸"; Color color = Color.Magenta; //设置初始值 foreach (VitalSignCurveDetailModel detail in dict.Values) { if (detail.CurveName.Equals("呼吸")) { color = detail.Color; break; } } foreach (VitalSignCurveDetailModel detail in dict.Values) { if (breathType == "自主呼吸") { breathName = "呼吸"; } else { breathName = breathType; } if (detail.CurveName.Equals(breathName)) { color = detail.Color; switch (detail.ShowTimeInterval) { case ShowTimeInterval.Five: timeSpan = 5; break; case ShowTimeInterval.Fifiteen: timeSpan = 15; break; case ShowTimeInterval.Ten: timeSpan = 10; break; case ShowTimeInterval.Twenty: timeSpan = 20; break; case ShowTimeInterval.HalfHour: timeSpan = 30; break; case ShowTimeInterval.Hour: timeSpan = 60; break; } } } //新增显示频率 20120927 breathControlTime.showTimeInterval = timeSpan; breathControlTime.curveColor = color; if (breathType.Contains("控制呼吸")) { breathControlTime.BreathType = BreathControlType.ControlBreath; if (!string.IsNullOrEmpty(vitalSignGraph.BreathPara1) && !string.IsNullOrEmpty(vitalSignGraph.BreathPara2) && !string.IsNullOrEmpty(vitalSignGraph.BreathPara3)) { List <MED_PAT_MONITOR_DATA_EXT> patMonitorDataExtDataTable = AnesInfoService.ClientInstance.GetPatMonitorExtList(ExtendAppContext.Current.PatientInformationExtend.PATIENT_ID, ExtendAppContext.Current.PatientInformationExtend.VISIT_ID, ExtendAppContext.Current.PatientInformationExtend.OPER_ID); if (patMonitorDataExtDataTable != null && patMonitorDataExtDataTable.Count > 0) { List <MED_PAT_MONITOR_DATA_EXT> rows1 = patMonitorDataExtDataTable.Where(x => x.ITEM_CODE == vitalSignGraph.BreathPara1 || x.ITEM_CODE == vitalSignGraph.BreathPara2 || x.ITEM_CODE == vitalSignGraph.BreathPara3).ToList(); if (rows1 != null && rows1.Count > 0) { rows1.ForEach(rr => { if (!vitalSignGraph.BreathParalList.ContainsKey(rr.TIME_POINT)) { vitalSignGraph.BreathParalList.Add(rr.TIME_POINT, new MedVitalSignGraph.BreathPara()); } if (!string.IsNullOrEmpty(rr.ITEM_VALUE)) { if (rr.ITEM_CODE.Equals(vitalSignGraph.BreathPara1)) { vitalSignGraph.BreathParalList[rr.TIME_POINT].Para1 = rr.ITEM_VALUE; } else if (rr.ITEM_CODE.Equals(vitalSignGraph.BreathPara2)) { vitalSignGraph.BreathParalList[rr.TIME_POINT].Para2 = rr.ITEM_VALUE; } else if (rr.ITEM_CODE.Equals(vitalSignGraph.BreathPara3)) { vitalSignGraph.BreathParalList[rr.TIME_POINT].Para3 = rr.ITEM_VALUE; } } }); } } } } else if (breathType.Contains("辅助呼吸")) { breathControlTime.BreathType = BreathControlType.HelpBreath; } else if (breathType.Contains("自主呼吸")) { breathControlTime.BreathType = BreathControlType.FreeBreath; } listControlTime.Add(breathControlTime); } }); } return(listControlTime); }
/// <summary> /// 呼吸控制 /// </summary> /// <param name="anesEvent"></param> /// <param name="vitalSignGraph"></param> protected void ControlBreath(List <MED_ANESTHESIA_EVENT> anesEvent, Dictionary <string, VitalSignCurveDetailModel> dict) { if (anesEvent != null) { List <MED_ANESTHESIA_EVENT> rows = anesEvent.Where(x => !string.IsNullOrEmpty(x.EVENT_ITEM_NAME) && x.EVENT_ITEM_NAME.Contains("呼吸")).ToList(); if (rows.Count == 0) { return; } //控制呼吸时间列表 List <MedVitalSignBreathControlTime> listControlTime = new List <MedVitalSignBreathControlTime>(); //最大体征时间 DateTime maxVitalSignTime = DateTime.MaxValue; VitalSignCurveDetailModel curveBreath = null; //获取体征当前时间以及呼吸曲线 for (int i = 0; i < _vitalSignCurves.Count; i++) { if (_vitalSignCurves[i].CurveName.Contains("呼吸")) { curveBreath = _vitalSignCurves[i]; continue; } for (int j = 0; j < _vitalSignCurves[i].Points.Count; j++) { if (maxVitalSignTime == DateTime.MaxValue) { maxVitalSignTime = _vitalSignCurves[i].Points[j].Time; } else if (maxVitalSignTime < _vitalSignCurves[i].Points[j].Time) { maxVitalSignTime = _vitalSignCurves[i].Points[j].Time; } } } if (curveBreath == null)//生成曲线 { if (dict.ContainsKey("92")) { curveBreath = dict["92"]; _vitalSignCurves.Add(curveBreath); } } if (curveBreath != null) { listControlTime.AddRange(BreathTimeList("自主呼吸", anesEvent, _vitalSignGraph, dict)); listControlTime.AddRange(BreathTimeList("控制呼吸", anesEvent, _vitalSignGraph, dict)); listControlTime.AddRange(BreathTimeList("辅助呼吸", anesEvent, _vitalSignGraph, dict)); } //排序 listControlTime listControlTime.Sort(new Comparison <MedVitalSignBreathControlTime>(delegate(MedVitalSignBreathControlTime controlTime1, MedVitalSignBreathControlTime controlTime2) { return(controlTime1.oStartTime.CompareTo(controlTime2.oStartTime)); })); //调整 listControlTime ,使得时间无重叠 if (listControlTime.Count > 1) { MedVitalSignBreathControlTime breathControlTime1 = null; MedVitalSignBreathControlTime breathControlTime2 = null; for (int i = 0; i < listControlTime.Count - 1; i++) { breathControlTime1 = listControlTime[i]; breathControlTime2 = listControlTime[i + 1]; if (breathControlTime1.endTime >= breathControlTime2.startTime) { breathControlTime1.endTime = breathControlTime2.startTime.AddMinutes(-5); } } } VitalSignPointModel point = null;//删除所有时间段内的点 for (int count = 0; count < listControlTime.Count; count++) { //删除控制呼吸以及辅助呼吸点 DateTimeRange range = new DateTimeRange(listControlTime[count].startTime, listControlTime[count].endTime); if (curveBreath.Points == null) { curveBreath.Points = new List <VitalSignPointModel>(); } for (int i = 0; i < curveBreath.Points.Count; i++) { point = curveBreath.Points[i]; if (point.Time >= range.StartDateTime && point.Time <= range.EndDateTime) { curveBreath.Points.Remove(point); i--; } } DateTime dt = range.StartDateTime; dt = new DateTime(dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, 0); //控制呼吸处理 if (listControlTime[count].BreathType == BreathControlType.ControlBreath) { SymbolModel symbol = new SymbolModel(SymbolType.Text); symbol.Text = "C"; bool isExist = false; for (int i = 0; i < curveBreath.LegendList.Count; i++) { if (curveBreath.LegendList[i].Symbol.SymbolType == symbol.SymbolType) { curveBreath.LegendList[i].Code = "控制呼吸"; curveBreath.LegendList[i].DisplayName = "控制呼吸"; isExist = true; } } if (!isExist) { LegendItem item = new LegendItem(); item.Code = "控制呼吸"; item.DisplayName = "控制呼吸"; item.Symbol = symbol; curveBreath.LegendList.Add(item); } while (dt <= range.EndDateTime) { point = new VitalSignPointModel(dt, listControlTime[count].breathValue, curveBreath, symbol, ""); curveBreath.Points.Add(point); //加入新点 dt = dt.AddMinutes(listControlTime[count].showTimeInterval); } } //辅助呼吸处理 else if (listControlTime[count].BreathType == BreathControlType.HelpBreath) { SymbolModel symbol = new SymbolModel(SymbolType.Text); symbol.Text = "A"; bool isExist = false; for (int i = 0; i < curveBreath.LegendList.Count; i++) { if (curveBreath.LegendList[i].Symbol.SymbolType == symbol.SymbolType) { curveBreath.LegendList[i].Code = "辅助呼吸"; curveBreath.LegendList[i].DisplayName = "辅助呼吸"; isExist = true; } } if (!isExist) { LegendItem item = new LegendItem(); item.Code = "辅助呼吸"; item.DisplayName = "辅助呼吸"; item.Symbol = symbol; curveBreath.LegendList.Add(item); } while (dt <= range.EndDateTime) { point = new VitalSignPointModel(dt, listControlTime[count].breathValue, curveBreath, symbol, ""); curveBreath.Points.Add(point); //加入新点 dt = dt.AddMinutes(listControlTime[count].showTimeInterval); } } else { while (dt <= range.EndDateTime) { point = new VitalSignPointModel(dt, listControlTime[count].breathValue, curveBreath, curveBreath.LegendList[0].Symbol, ""); curveBreath.Points.Add(point); //加入新点 dt = dt.AddMinutes(listControlTime[count].showTimeInterval); } } curveBreath.Points.Sort(new Comparison <VitalSignPointModel>(delegate(VitalSignPointModel point1, VitalSignPointModel point2) { return(point1.Time.CompareTo(point2.Time)); })); } } }