382 lines
17 KiB
C#
382 lines
17 KiB
C#
using HelperDB;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.SqlClient;
|
|
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 string 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
|
|
{
|
|
bool isEqual = false;
|
|
if ((this.DosageUnit == ((FactDrug)drug1).DosageUnit) && (this.DrugChannel == ((FactDrug)drug1).DrugChannel) && (this.DrugName == ((FactDrug)drug1).DrugName) && (this.Access == ((FactDrug)drug1).Access))
|
|
{
|
|
isEqual = true;
|
|
}
|
|
if (isEqual == true && !this.DrugName.Contains("氧") && ((this.DensityUnit == ((FactDrug)drug1).DensityUnit) && (this.Density == ((FactDrug)drug1).Density)))
|
|
{
|
|
isEqual = true;
|
|
}
|
|
else
|
|
{
|
|
isEqual = false;
|
|
}
|
|
//if ((this.DrugChannel == ((FactDrug)drug1).DrugChannel) && (this.DrugName == ((FactDrug)drug1).DrugName) && (this.Access == ((FactDrug)drug1).Access))
|
|
//{
|
|
// return true;
|
|
//}
|
|
return isEqual;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
public bool isEqualRow(double y, DateTime time, double lineHeight)
|
|
{
|
|
bool reValue = false;
|
|
if (y > nowY && y < nowY + lineHeight)
|
|
{
|
|
reValue = true;
|
|
}
|
|
return reValue;
|
|
}
|
|
|
|
public bool isEqual(double y, DateTime time, double lineHeight)
|
|
{
|
|
bool reValue = false;
|
|
if ((y > nowY && y < nowY + lineHeight))
|
|
{
|
|
if (DrugBeginTime == DrugEndTime)
|
|
{
|
|
if ((DateTime.Compare(time, DateTime.Parse(DrugBeginTime.ToString())) > 0) && DateTime.Compare(time, DateTime.Parse(DrugBeginTime.ToString()).AddMinutes(10)) < 0)
|
|
{
|
|
reValue = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if ((DateTime.Compare(time, DateTime.Parse(DrugBeginTime.ToString())) > 0 && DateTime.Compare(time, DateTime.Parse(DrugEndTime.ToString())) < 0))
|
|
{
|
|
reValue = true;
|
|
}
|
|
}
|
|
}
|
|
return reValue;
|
|
}
|
|
|
|
|
|
/// <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);
|
|
}
|
|
public void drawText2(double x, double y)
|
|
{
|
|
if (zgcAnas == null) return;
|
|
clearAddObj(zgcAnas);
|
|
//画添加药品线,底部加加药次数和备注
|
|
this.nowY = y;
|
|
paintAdd(y);
|
|
}
|
|
|
|
public void ReDraw(ZedGraphControl zgc)
|
|
{
|
|
//擦掉加药的图例
|
|
clearAddObjPic(zgc);
|
|
//再重新画上去新的位置
|
|
paintAdd(nowY);
|
|
|
|
}
|
|
/// <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;
|
|
string s = "";
|
|
|
|
if (DensityStr != "" && this.DrugName.Contains("氧"))
|
|
{
|
|
if (this.DensityUnit != null && this.DensityUnit != "") DensityStr += this.DensityUnit;
|
|
s = (DensityStr).Trim();
|
|
}
|
|
if (VelocityStr != "")
|
|
{
|
|
if (VelocityStr != "") s = VelocityStr;
|
|
if (this.VelocityUnit != null && this.VelocityUnit != "") s += this.VelocityUnit;
|
|
}
|
|
if ((EqualDose == null || EqualDose == ""))
|
|
{
|
|
if (Dosage != 0)
|
|
EqualDose = ((double)Dosage).ToString();
|
|
//if (this.DosageUnit != null && this.DosageUnit != "") EqualDose += this.DosageUnit;
|
|
}
|
|
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.DrugName.Contains("氧"))
|
|
{
|
|
if (this.Density > 0 && this.DensityUnit != null && this.DensityUnit != "") DrName = ((double)this.Density).ToString() + this.DensityUnit + DrName;
|
|
}
|
|
if (this.DrugChannel != null && this.DrugChannel != "") DrName += "(" + this.DrugChannel + ")";
|
|
if (this.DosageUnit != null && this.DosageUnit != "") DrName += "(" + this.DosageUnit + ")";
|
|
if (this.BloodType != null && this.BloodType != "") DrName += "(" + this.BloodType + ")";
|
|
if (DrugKind.Contains("麻") || DrugKind.Contains("精神"))
|
|
ZUtil.DrawText(DrName, x1, y, zgcAnas, TextPrefix.DN + this.DrugName + this.Id.ToString(), Color.Red, 6f);
|
|
else
|
|
ZUtil.DrawText(DrName, x1, y, zgcAnas, TextPrefix.DN + this.DrugName + this.Id.ToString(), Color.Black, 6f);
|
|
}
|
|
}
|
|
|
|
public static int UpdateEntity(FactDrug factDrug)
|
|
{
|
|
using (SqlConnection conn = new SqlConnection(DBHelper._ConnectionString))
|
|
{
|
|
conn.Open();
|
|
using (SqlCommand cmd = conn.CreateCommand())
|
|
{
|
|
cmd.CommandText = "update FactDrug set PatientId=@PatientId,DrugTypeId=@DrugTypeId,DrugId=@DrugId,DrugBeginTime=@DrugBeginTime,DrugEndTime=@DrugEndTime,Dosage=@Dosage,DosageUnit=@DosageUnit,DrugChannel=@DrugChannel,GiveDrugType=@GiveDrugType,IsContinue=@IsContinue,Remark=@Remark,OperatorNo=@OperatorNo,OperatorName=@OperatorName,OperateDate=@OperateDate,Density=@Density,DensityUnit=@DensityUnit,Velocity=@Velocity,VelocityUnit=@VelocityUnit,BloodType=@BloodType,ParentId=@ParentId,DrugName=@DrugName,Access=@Access where Id=@Id";
|
|
//从实体中取出值放入Command的参数列表,BatchNo=@BatchNo,PaySelf=@PaySelf,TestFlag=@TestFlag,LimitFlag=@LimitFlag,Extend1=@Extend1,Extend2=@Extend2,Extend3=@Extend3,Extend4=@Extend4,Extend5=@Extend5
|
|
cmd.Parameters.Add(new SqlParameter("@PatientId", factDrug.PatientId));
|
|
cmd.Parameters.Add(new SqlParameter("@DrugTypeId", factDrug.DrugTypeId));
|
|
cmd.Parameters.Add(new SqlParameter("@DrugId", factDrug.DrugId));
|
|
cmd.Parameters.Add(new SqlParameter("@DrugBeginTime", factDrug.DrugBeginTime));
|
|
cmd.Parameters.Add(new SqlParameter("@DrugEndTime", factDrug.DrugEndTime));
|
|
cmd.Parameters.Add(new SqlParameter("@Dosage", factDrug.Dosage));
|
|
cmd.Parameters.Add(new SqlParameter("@DosageUnit", factDrug.DosageUnit));
|
|
cmd.Parameters.Add(new SqlParameter("@DrugChannel", factDrug.DrugChannel));
|
|
cmd.Parameters.Add(new SqlParameter("@GiveDrugType", factDrug.GiveDrugType));
|
|
cmd.Parameters.Add(new SqlParameter("@IsContinue", factDrug.IsContinue));
|
|
cmd.Parameters.Add(new SqlParameter("@Remark", factDrug.Remark));
|
|
cmd.Parameters.Add(new SqlParameter("@OperatorNo", factDrug.OperatorNo));
|
|
cmd.Parameters.Add(new SqlParameter("@OperatorName", factDrug.OperatorName));
|
|
cmd.Parameters.Add(new SqlParameter("@OperateDate", factDrug.OperateDate));
|
|
cmd.Parameters.Add(new SqlParameter("@Density", factDrug.Density));
|
|
cmd.Parameters.Add(new SqlParameter("@DensityUnit", factDrug.DensityUnit));
|
|
cmd.Parameters.Add(new SqlParameter("@Velocity", factDrug.Velocity));
|
|
cmd.Parameters.Add(new SqlParameter("@VelocityUnit", factDrug.VelocityUnit));
|
|
cmd.Parameters.Add(new SqlParameter("@BloodType", factDrug.BloodType));
|
|
cmd.Parameters.Add(new SqlParameter("@ParentId", factDrug.ParentId));
|
|
cmd.Parameters.Add(new SqlParameter("@DrugName", factDrug.DrugName));
|
|
cmd.Parameters.Add(new SqlParameter("@Access", factDrug.Access));
|
|
//cmd.Parameters.Add(new SqlParameter("@BatchNo", factDrug.BatchNo));
|
|
//cmd.Parameters.Add(new SqlParameter("@PaySelf", factDrug.PaySelf));
|
|
//cmd.Parameters.Add(new SqlParameter("@TestFlag", factDrug.TestFlag));
|
|
//cmd.Parameters.Add(new SqlParameter("@LimitFlag", factDrug.LimitFlag));
|
|
//cmd.Parameters.Add(new SqlParameter("@Extend1", factDrug.Extend1));
|
|
//cmd.Parameters.Add(new SqlParameter("@Extend2", factDrug.Extend2));
|
|
//cmd.Parameters.Add(new SqlParameter("@Extend3", factDrug.Extend3));
|
|
//cmd.Parameters.Add(new SqlParameter("@Extend4", factDrug.Extend4));
|
|
//cmd.Parameters.Add(new SqlParameter("@Extend5", factDrug.Extend5));
|
|
cmd.Parameters.Add(new SqlParameter("@Id", factDrug.Id));
|
|
return cmd.ExecuteNonQuery();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 加药排序类
|
|
/// </summary>
|
|
public class FactDrugComparer : IComparer<FactDrug>
|
|
{
|
|
public int Compare(FactDrug x, FactDrug y)
|
|
{
|
|
return (x.DrugBeginTime.CompareTo(y.DrugBeginTime));
|
|
}
|
|
}
|
|
}
|