AIMS/DrawGraph/AreaManage/OutputManage.cs
leomon 59207230db 术前诊断修改术后跟随改变
保存手术或者诊断去除换行符
配药显示在下面
默认尿量出血量 -
删除药品后标签定位
2023-05-05 12:42:39 +08:00

296 lines
11 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Newtonsoft.Json;
using AIMSExtension;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace DrawGraph
{
[Serializable, JsonObject(MemberSerialization.OptOut)]
public class OutputManage : AreaManageBase
{
/// <summary>
/// 药品区域
/// </summary>
public RectangleFramePackObj sapPpack;
public LinesPackObj lines;
public LinePackObj H3pack;
public LinePackObj H5pack;
public int RowsCount;
/// <summary>
/// 当前手术对象
/// </summary>
private OperationRecord myOpeRecord = null;
public List<string> DrugsListstr = new List<string>();
#region
public OutputManage()
{
init();
}
public OutputManage(object _operationRecor, DrawGraph.ZedGraphControl _zedControl, TemplateManage _template, string _name) : base(_operationRecor, _zedControl, _template, _name)
{
init();
}
public void init()
{
//自己要用的手术对象
myOpeRecord = OpeRecord as OperationRecord;
}
/// <summary>
/// 初始画的后置方法
/// </summary>
public override void FollowUpMethod()
{
H3pack = template.GetPackObjectOTag<LinePackObj>("OutputManage_LinePackObj_11");
H5pack = template.GetPackObjectOTag<LinePackObj>("OutputManage_LinePackObj_5");
sapPpack = template.GetPackObjectOTag<RectangleFramePackObj>("OutputManage_RectangleFramePackObj_10");
lines = template.GetPackObjectOTag<LinesPackObj>("OutputManage_LinesPackObj_15");
RowsCount = Convert.ToInt32(lines.XPageSpan / lines.XMajorGridStep);
}
#endregion
#region
/// <summary>
/// 鼠标点击画板
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public override void MouseDown(ZedGraphControl sender, MouseEventArgs e)
{
//if (e.Button == System.Windows.Forms.MouseButtons.Left)
//{
// MessageBox.Show(this.GetType().Name + "is Click Left Button");
//}
}
public override void MouseMove(ZedGraphControl sender, MouseEventArgs e)
{
}
public override void MouseUp(ZedGraphControl sender, MouseEventArgs e)
{
}
public override void MouseDoubleClick(ZedGraphControl sender, MouseEventArgs e)
{
}
public override void KeyUp(ZedGraphControl sender, KeyEventArgs e)
{
}
#endregion
#region
public override void Bind()
{
init();
DrawOutput();
}
/// <summary>
/// 画加药
/// </summary>
private void DrawOutput()
{
try
{
foreach (FactOutputLiquids temp in myOpeRecord.FactOutputLiquidsList)
{
temp.clearAddObj(ZedControl);
}
reDrawDrug();
}
catch (Exception exp)
{
PublicMethod.WriteLog(exp);
}
}
/// <summary>
/// 重新画加药文本
/// </summary>
private void reDrawDrug()
{
try
{
//画在第几行
int rowDrugsIndex = 0;
//y的高度//主要高度
double drugsy = 0;
//加药最后位置
double maxDrugsy = sapPpack.RealEndY;
//持续加药当前时间
DateTime curTimeTemp = OperationRecord.getOpeMaxTime(myOpeRecord);
DateTime serverTime = DateTime.Now;
if (curTimeTemp > serverTime) curTimeTemp = serverTime;
//超出的药画备注 镇痛药备注
List<string> DrugListstr = new List<string>();
DrugListstr.Add("【出量】");
myOpeRecord.BeforeDrugs = "";
myOpeRecord.AnalgesiaDrug = "";
//当前时间段加药集合
myOpeRecord.FactOutputLiquidsList.ForEach(drug =>
{
if (drug.IsContinue == 1 && drug.BeginTime == drug.EndTime) drug.End = curTimeTemp;
else if (drug.EndTime != null) drug.End = drug.EndTime;
});
List<FactOutputLiquids> _FactOutputLiquidsList = myOpeRecord.FactOutputLiquidsList.Where(s => IfInTimeExist(s.BeginTime, s.End) == true).ToList();
//加药按加药时间排序
//_FactOutputLiquidsList.Sort(new FactOutputLiquidsComparer());
for (int i = 0; i < _FactOutputLiquidsList.Count; i++)
{
FactOutputLiquids temp = _FactOutputLiquidsList[i];
bool isEqual = false;
bool isChildEqual = false;
//以行号返回具休的位置
drugsy = sapPpack.RealY + getYPositionByListIndex(rowDrugsIndex, sapPpack.RealY, sapPpack.RealEndY, RowsCount);
SetDrug(temp, curTimeTemp, drugsy);
//判断是否重复的 主药或组药
for (int j = 0; j < i; j++)
{
FactOutputLiquids addDrug1 = _FactOutputLiquidsList[j];
//如果加药品ID相同并且加加药ID不同则认为加了同一种加药
if (addDrug1.Equal(temp))
{
addDrug1.clearDNAndDT(ZedControl);
//因为相同则取得相同对象的Y,为当前的对象的高度
drugsy = addDrug1.nowY;
isEqual = true;
continue;
}
}
if (isChildEqual == true) continue;
if (drugsy <= maxDrugsy)
{
temp.drawText(H3pack.RealX + 0.006f, drugsy);
if (isEqual == false)
rowDrugsIndex++;
}
else
ListAddDrugs(DrugListstr, i, temp);
}
myOpeRecord.OutsListstr = DrugListstr;
DrawOutDose();
}
catch (Exception ex)
{
throw ex;
}
}
private void DrawOutDose()
{
try
{
double allOutDose = 0;
double nlDose = 0;
double sxDose = 0;
myOpeRecord.FactOutputLiquidsList.ForEach(item =>
{
if (item.DosageUnit.Trim() == "mL" || item.DosageUnit.Trim() == "ml" || item.DosageUnit.Trim() == "ML")
{
Double val = Convert.ToDouble(item.Dosage);
allOutDose += val;
if (item.OutputLiquidsName == "尿量")
nlDose += val;
else if (item.OutputLiquidsName == "出血量")
sxDose += val;
}
});
template.SetObjValue(myOpeRecord, "OperationRecord.OutAmount", allOutDose.ToString(), allOutDose.ToString(), allOutDose.ToString() != myOpeRecord.OutAmount ? true : false);
string outStr = "";
if (nlDose > 0)
outStr += "尿量 " + nlDose + " ml\n";
else
outStr += "尿量 -\n";
if (sxDose > 0)
outStr += "出血量 " + sxDose + " ml\n";
else
outStr += "出血量 -\n";
if (outStr != "")
template.SetObjValue(myOpeRecord, "OperationRecord.Crystal", outStr, outStr, false);
}
catch (Exception ex)
{
PublicMethod.WriteLog(ex);
}
}
private void SetDrug(FactOutputLiquids temp, DateTime curTimeTemp, double y)
{
if (temp.IsContinue == 1 && temp.BeginTime == temp.EndTime) temp.End = curTimeTemp;
temp.EqualDose = null;
temp.setAnasArr(ZedControl, H5pack.RealX, sapPpack.RealEndX, myOpeRecord.PageBegin, myOpeRecord.PageBegin.AddMinutes(EVERY_PAGE_TIME_SPAN));
temp.nowY = y;
}
private static void ListAddDrugs(List<string> DrugListstr, int i, FactOutputLiquids temp)
{
string dose = "";
if (dose.Trim() != "") dose += " ";
dose += ((double)temp.Dosage).ToString();
if (temp.DosageUnit != null)
{
dose += temp.DosageUnit;
}
DrugListstr.Add(string.Format("({0}){1} {2} {3}{4}{5}", i + 1, (temp.BeginTime == temp.EndTime) ? temp.BeginTime.ToShortTimeString() : temp.BeginTime.ToShortTimeString() + "->" + temp.EndTime.ToShortTimeString(), temp.OutputLiquidsName.Trim(), dose, "", ""));
//DrugListstr.Append(" ");
}
#endregion
#region
private bool IfInTimeExist(DateTime Begin, DateTime End)
{
DateTime lastime = myOpeRecord.lastPageBegin.AddSeconds(59);
bool b = false;
if (End == null)
{
if (Begin > myOpeRecord.PageBegin && Begin < lastime)
{
b = true;
}
}
else
{
if (Begin >= myOpeRecord.PageBegin && Begin <= lastime)
{
b = true;
}
else if (End >= myOpeRecord.PageBegin && End <= lastime)
{
b = true;
}
else if (Begin < myOpeRecord.PageBegin && End > lastime)
{
b = true;
}
}
return b;
}
/// <summary>
/// 根据顶部加药序号确定数值生命体征的纵向位置以1为单位
/// </summary>
/// <param name="index"></param>
/// <returns></returns>
public double getYPositionByListIndex(double index, double yTop, double yBottom, int rowCount)
{
double heightT = ZedControl.Height * (yBottom - yTop);
double setpTemp = heightT / rowCount;
//求一格在实际高度中的百分比
double bfb = (setpTemp / heightT);
//两线之间度*百分比得到一格的百分比高度
double ygBFB = (yBottom - yTop) * bfb;
double y = ygBFB * index;
return y;
}
#endregion
}
}