/// <summary> /// 移动体征 /// </summary> public void MovingPoints(VitalSignPointModel point) { MED_VITAL_SIGN row = _vitalSignList.Where(x => x.ITEM_CODE == point.Curve.CurveCode && x.TIME_POINT == point.Time).FirstOrDefault(); if (row != null) { if (row.ITEM_VALUE != point.Value.ToString()) { row.ITEM_VALUE = point.Value.ToString(); } try { SavePoints(row); } catch (Exception ex) { Logger.Error("移动体征保存数据异常", ex); } } else { row = new MED_VITAL_SIGN(); row.ITEM_CODE = point.Curve.CurveCode; row.ITEM_NAME = point.Curve.CurveName; row.TIME_POINT = point.Time; row.ITEM_VALUE = point.Value.ToString(); row.Flag = "2"; try { SavePoints(row); } catch (Exception ex) { Logger.Error("移动体征保存数据异常", ex); } } }
/// <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)); })); } } }
/// <summary> ///添加坐标点 /// </summary> /// <param name="time"></param> /// <param name="value"></param> public void AddDataPoint(DateTime time, double value, object Tag, MouseEventHandler MouseEnterHandler, MouseEventHandler MouseLeaveHandler, ref DataPoint point, SymbolType symbolType = SymbolType.Point) { VitalSignPointModel model = null; if (null != Tag && Tag is VitalSignPointModel) { model = Tag as VitalSignPointModel; } bool isOverMin, isOverMax; var x = _XAxis.LocalTransform(time, out isOverMin, out isOverMax); if (isOverMin || isOverMax) //超过x轴范围返回 { return; } double drawValue = value; if (drawValue > _YAxis.Max) { drawValue = _YAxis.Max; } else if (drawValue < _YAxis.Min) { drawValue = _YAxis.Min; } var y = _drawHeight - _YAxis.LocalTransform(drawValue); var currentFigures = _pathGeometry.Figures[_index]; LineSegment lineSegment = null; PathFigure figure = null; //添加基本坐标点 if (currentFigures.StartPoint.X == 0D && currentFigures.StartPoint.Y == 0D && currentFigures.Segments.Count == 0) { figure = _pathGeometry.Figures[_index]; figure.StartPoint = new Point(x, y); } else { //坐标点 lineSegment = new LineSegment(); lineSegment.Point = new Point(x, y); currentFigures.Segments.Add(lineSegment); } //添加点 string pathText = model == null ? "" : model.Symbol.Text; Path path = Symbol.MakePath(symbolType, new Point(x, y), new Size(_pointWidth, _pointHeight), LineColor, Colors.White, false, pathText); path.Tag = Tag; path.StrokeThickness = 1.5; //path.RenderTransform = new TranslateTransform(1, 1); path.MouseEnter += MouseEnterHandler; path.MouseMove += MouseEnterHandler; path.MouseLeave += MouseLeaveHandler; Path path2 = Symbol.MakePath(SymbolType.CustomRectangle, new Point(x, y), new Size(_pointWidth, _pointHeight), LineColor, Colors.White); path2.Tag = Tag; path2.StrokeThickness = 1.5; //path.RenderTransform = new TranslateTransform(1, 1); path2.MouseEnter += MouseEnterHandler; path2.MouseMove += MouseEnterHandler; path2.MouseLeave += MouseLeaveHandler; point = new DataPoint(time, value, x, y, new List <FrameworkElement>() { path, path2 }, figure, lineSegment); _points.Add(point); _points = _points.OrderBy(p => p.Time).ToList(); //_points[time] = new DataPoint //{ // Time = time, // Value = value, // X = x, // Y = y //}; }