AIMS/DrawGraph/AreaManage/FactDrug.cs
2022-11-29 22:07:55 +08:00

263 lines
10 KiB
C#

using System;
using System.Collections.Generic;
using System.Diagnostics.Eventing.Reader;
using System.Drawing;
using System.Linq;
using System.Text;
namespace DrawGraph
{
public class FactDrug : EventObj
{
public int Id;
public int PatientId;
public int DrugTypeId;
public int DrugId;
public string DrugName;
public decimal Dosage;
public string DosageUnit;
public int IsContinue;
public DateTime DrugBeginTime;
public DateTime DrugEndTime;
public string DrugChannel;
public string GiveDrugType;
public string Remark;
public string DrugKind;
public string AnesType;
public string Comment;
public string OperatorNo { get; set; }
public string OperatorName { get; set; }
public DateTime OperateDate { get; set; }
public decimal Density;
public string DensityUnit;
public decimal Velocity;
public string VelocityUnit;
public string BloodType;
public int ParentId;
public string Access { get; set; }
public string BatchNo { get; set; }
public string PaySelf { get; set; }
public string TestFlag { get; set; }
public string LimitFlag { get; set; }
public string Extend1 { get; set; }
public string Extend2 { get; set; }
public string Extend3 { get; set; }
public string Extend4 { get; set; }
public string Extend5 { get; set; }
public List<FactDrug> ChildFactDrugList;
public double nowY { get; set; }
public string EqualDose { get; set; }
/// <summary>
/// 清空所有与某条加药相关的控件。
/// </summary>
/// <param name="DrugsRecord"></param>
public override void clearAddObj(ZedGraphControl zgc)
{
//if (zgcAnas == null || zgcAnas != zgc)
zgcAnas = zgc;
clearAddObjPic(zgc);
clearDNDTDD(zgc);
//clearIm(zgc);
delAddObj(this.DrugName + this.DrugId);
delLineObj("zhuyDrugs" + this.Id);
delLineObj("zhuyDrugstop" + this.Id);
delLineObj("zhuyDrugsend" + this.Id);
delAddObj("BeforeDrugs0");
delAddObj("BeforeDrugs1");
delAddObj("BeforeDrugs2");
}
private void clearAddObjPic(ZedGraphControl zgc)
{
//if (zgcAnas == null || zgcAnas != zgc)
zgcAnas = zgc;
delAddObj(TextPrefix.DT + this.DrugName + this.Id.ToString());
delAddObj(TextPrefix.DD + this.DrugName + this.Id.ToString());
delAddObj(TextPrefix.DD + this.DrugName + this.Id.ToString() + "spicle");
delAddObj(TextPrefix.DU + this.DrugName + this.Id.ToString());
delAddArrows(TextPrefix.AR + this.DrugName + this.Id.ToString());
delLineObj("A" + TextPrefix.AR + this.DrugName + this.Id.ToString());
delLineObj("B" + TextPrefix.AR + this.DrugName + this.Id.ToString());
}
public override void clearDNAndDT(ZedGraphControl zgc)
{
//if (zgcAnas == null)
zgcAnas = zgc;
delAddObj(TextPrefix.DN + this.DrugName + this.Id.ToString());
delAddObj(TextPrefix.DT + this.DrugName + this.Id.ToString());
delAddObj(TextPrefix.DU + this.DrugName + this.Id.ToString());
//delAddObj(TextPrefix.DD + this.DrugName + this.Id.ToString());
delAddObj(this.DrugName + this.DrugId);
}
public void clearDNDTDD(ZedGraphControl zgc)
{
//if (zgcAnas == null || zgcAnas != zgc)
zgcAnas = zgc;
delAddObj(TextPrefix.DN + this.DrugName + this.Id.ToString());
delAddObj(TextPrefix.DT + this.DrugName + this.Id.ToString());
delAddObj(TextPrefix.DU + this.DrugName + this.Id.ToString());
delAddObj(TextPrefix.DD + this.DrugName + this.Id.ToString());
delAddObj(this.DrugName + this.DrugId);
}
public void clearIm(ZedGraphControl zgc)
{
if (zgcAnas == null || zgcAnas != zgc) zgcAnas = zgc;
delAddObj(TextPrefix.IM + this.DrugName + this.Id.ToString());
}
public bool Equal(object drug1)
{
try
{
if ((this.DosageUnit == ((FactDrug)drug1).DosageUnit) && (this.DrugChannel == ((FactDrug)drug1).DrugChannel) && (this.DrugName == ((FactDrug)drug1).DrugName) && (this.Access == ((FactDrug)drug1).Access))// && (this.DrugEffect == ((DrugsRecord)drug1).DrugEffect)&& (this.Remark == ((DrugsRecord)drug1).Remark)
{
return true;
}
return false;
}
catch (Exception)
{
return false;
}
}
/// <summary>
/// 画一条加药记录
/// </summary>
/// <param name="index">高度</param>
/// <param name="faRecord">总量</param>
public override void drawText(double x, double y)
{
if (zgcAnas == null) return;
clearAddObj(zgcAnas);
//画添加药品线,底部加加药次数和备注
this.nowY = y;
paintAdd(y);
//写加药的左边与右信息
drawAddText(x, y);
}
/// <summary>
/// 画添加药品线,底部加加药次数和备注信息
/// </summary>
/// <param name="DrugsRecord"></param>
/// <param name="index"></param>
public void paintAdd(double y)
{
string tagName = this.DrugName + this.Id.ToString();
string DoseStr = "";
if (Dosage != 0)
DoseStr = (((double)this.Dosage).ToString());
string RemarkStr = this.Remark;//
string DensityStr = Density == 0 ? "" : ((double)this.Density).ToString();
string VelocityStr = Velocity == 0 ? "" : ((double)this.Velocity).ToString();
string s = "";
if (DensityStr != "" || VelocityStr != "")
{
if (this.DensityUnit != null && this.DensityUnit != "") DensityStr += this.DensityUnit;
s = (DensityStr + " " + VelocityStr).Trim();
if (DensityStr != "" && VelocityStr != "") s = DensityStr + "/" + VelocityStr;
if (this.VelocityUnit != null && this.VelocityUnit != "") s += this.VelocityUnit;
}
if ((EqualDose == null || EqualDose == ""))
{
if (Dosage != 0)
EqualDose = ((double)Dosage).ToString();
}
DateTime dt = DrugEndTime;
DateTime drugDt = this.DrugBeginTime;
bool isContinued = false;
if (IsContinue == 1 && DrugBeginTime == DrugEndTime)
{
dt = End;
isContinued = true;
}
if (DrugEndTime != null && DrugBeginTime != null && DrugBeginTime != DrugEndTime)
{
TimeSpan tsp = DrugEndTime - DrugBeginTime;
if (tsp.TotalMinutes >= 10)
{
drugDt = DrugBeginTime.AddMinutes(tsp.TotalMinutes / 2 - 3);
}
}
if (((TimeSpan)(pageEnd - this.DrugBeginTime)).TotalMinutes <= 2)
{
if (EqualDose == null)
{
if (s.Trim() != "")
drawDoseObj(y, tagName, this.DrugBeginTime, dt, drugDt, s + " " + RemarkStr, 5f, isContinued);
else
drawDoseObj(y, tagName, this.DrugBeginTime, dt, drugDt, DoseStr + " " + RemarkStr, 5f, isContinued);
}
else
{
if (s.Trim() != "")
drawDoseObj(y, tagName, this.DrugBeginTime, dt, drugDt, s + "(" + EqualDose + ")" + RemarkStr, 5f, isContinued);
else
drawDoseObj(y, tagName, this.DrugBeginTime, dt, drugDt, EqualDose + " " + RemarkStr, 5f, isContinued);
}
}
else
{
if (EqualDose == null)
{
if (s.Trim() != "")
drawDoseObj(y, tagName, this.DrugBeginTime, dt, drugDt, s + " " + RemarkStr, 6f, isContinued);
else
drawDoseObj(y, tagName, this.DrugBeginTime, dt, drugDt, DoseStr + " " + RemarkStr, 6f, isContinued);
}
else
{
if (s.Trim() != "")
drawDoseObj(y, tagName, this.DrugBeginTime, dt, drugDt, s + "(" + EqualDose + ")" + RemarkStr, 5.5f, isContinued);
else
drawDoseObj(y, tagName, this.DrugBeginTime, dt, drugDt, EqualDose + " " + RemarkStr, 5.5f, isContinued);
}
}
}
/// <summary>
/// 写加药的左边与右信息
/// </summary>
/// <param name="y">高度</param>
/// <param name="totalDose">总量</param>
public void drawAddText(double x, double y)
{
//左边写药名
TextObj text = (TextObj)zgcAnas.MasterPane.GraphObjList[TextPrefix.DN + this.DrugName + this.Id.ToString()];
if (text == null)
{
double x1 = x;// 0.05f;
string DrName = this.DrugName.Trim();
//if (this.Remark != null && this.Remark != "") DrName += "(" + this.Remark + ")";
if (this.DrugChannel != null && this.DrugChannel != "") DrName += "(" + this.DrugChannel + ")";
if (this.DosageUnit != null && this.DosageUnit != "") DrName += "(" + this.DosageUnit + ")";
if (DrugKind.Contains("麻醉") || DrugKind.Contains("精神"))
ZUtil.DrawText(DrName, x1, y, zgcAnas, TextPrefix.DN + this.DrugName + this.Id.ToString(), Color.Red, 5.75f);
else
ZUtil.DrawText(DrName, x1, y, zgcAnas, TextPrefix.DN + this.DrugName + this.Id.ToString(), Color.Black, 5.75f);
}
}
}
/// <summary>
/// 加药排序类
/// </summary>
public class FactDrugComparer : IComparer<FactDrug>
{
public int Compare(FactDrug x, FactDrug y)
{
return (x.DrugBeginTime.CompareTo(y.DrugBeginTime));
}
}
}