AIMS/DocumentManagement/DocumentEntity/DocumentExtension.cs
2023-08-03 12:55:03 +08:00

960 lines
48 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 AIMSExtension;
using DCSoft.Writer.Dom;
using HelperDB;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
namespace DocumentManagement
{
public static class DocumentExtension
{
public static void GetDocumentValue(string DocName, XTextDocument Document, PatientRecord Patient)
{
if (DocName == "不计费耗材使用清单")
{
int j = 131;
int K = 211;
for (int i = 51; i < 113; i++)
{
SetTextValue(Document, "field" + K.ToString(), "field" + i.ToString(), "field" + j.ToString());
j++;
K++;
}
int c1 = 113;
int c2 = 193;
for (int i = 35; i < 50; i++)
{
SetTextValue(Document, "field" + i.ToString(), "field" + c1.ToString(), "field" + c2.ToString());
c1++;
c2++;
}
var AllPriceText = Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
&& (x as XTextInputFieldElement).ID == "field50").FirstOrDefault();
double Result = GetTextAllValue(Document, 131, 208);
if (Result != 0)
{
AllPriceText.Text = Result.ToString();
}
}
if (DocName == "压疮风险评估表")
{
int Result = 0;
try
{
var AnaesthesiaText = Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
&& (x as XTextInputFieldElement).ID == "field6").FirstOrDefault();
if (AnaesthesiaText.Text != "") Result += int.Parse(AnaesthesiaText.Text);
var BMItext = Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
&& (x as XTextInputFieldElement).ID == "field7").FirstOrDefault();
if (BMItext.Text != "") Result += int.Parse(BMItext.Text);
var AgeText = Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
&& (x as XTextInputFieldElement).ID == "field8").FirstOrDefault();
if (AgeText.Text != "") Result += int.Parse(AgeText.Text);
var field9 = Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
&& (x as XTextInputFieldElement).ID == "field9").FirstOrDefault();
var field10 = Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
&& (x as XTextInputFieldElement).ID == "field10").FirstOrDefault();
var field11 = Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
&& (x as XTextInputFieldElement).ID == "field11").FirstOrDefault();
var asa = Document.RadioBoxes.ToArray().Where(x => x is XTextRadioBoxElement
&& (x as XTextRadioBoxElement).GroupName == "皮肤" && (x as XTextRadioBoxElement).Checked == true).FirstOrDefault();
if (asa != null)
field9.Text = asa.FormulaValue;
var asa2 = Document.RadioBoxes.ToArray().Where(x => x is XTextRadioBoxElement
&& (x as XTextRadioBoxElement).GroupName == "预计手术时间" && (x as XTextRadioBoxElement).Checked == true).FirstOrDefault();
if (asa2 != null)
field10.Text = asa2.FormulaValue;
var asa3 = Document.RadioBoxes.ToArray().Where(x => x is XTextRadioBoxElement
&& (x as XTextRadioBoxElement).GroupName == "手术施压" && (x as XTextRadioBoxElement).Checked == true).FirstOrDefault();
if (asa3 != null)
field11.Text = asa3.FormulaValue;
if (field9.Text != "") Result += int.Parse(field9.Text);
if (field10.Text != "") Result += int.Parse(field10.Text);
if (field11.Text != "") Result += int.Parse(field11.Text);
}
catch (Exception)
{
}
var field12 = Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
&& (x as XTextInputFieldElement).ID == "field12").FirstOrDefault();
if (Result != 0) field12.Text = Result.ToString();
}
}
public static void SetTextValue(XTextDocument Document, string one, string count, string price)
{
var onepriceText = Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
&& (x as XTextInputFieldElement).ID == one).FirstOrDefault();
var CountText = Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
&& (x as XTextInputFieldElement).ID == count).FirstOrDefault();
var PriceText = Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
&& (x as XTextInputFieldElement).ID == price).FirstOrDefault();
if (onepriceText != null && CountText != null && PriceText != null)
if (onepriceText.Text != "" && CountText.Text != "")
{
try
{
double num = double.Parse(CountText.Text.Trim());
double oneprice = double.Parse(onepriceText.Text);
PriceText.Text = (num * oneprice).ToString();
}
catch (Exception)
{
}
}
}
public static double GetTextAllValue(XTextDocument Document, int minNum, int maxNum)
{
double Result = 0;
for (int i = minNum; i < maxNum; i++)
{
var PriceText = Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
&& (x as XTextInputFieldElement).ID == "field" + i).FirstOrDefault();
if (PriceText.Text != "")
{
try
{
double price = double.Parse(PriceText.Text);
Result += price;
}
catch (Exception)
{
}
}
}
return Result;
}
public static void SetDocumentDefaultValue(string DocName, XTextDocument Document, PatientRecord Patient)
{
if (DocName == "压疮风险评估表")
{
string AnaesthesiaMethodName = Patient.ApplyAnaesthesiaMethodName;
if (Patient.AnaesthesiaMethodName != "") AnaesthesiaMethodName = Patient.AnaesthesiaMethodName;
double BMI = -1;
if (Patient.BMI != null && Patient.BMI != "") BMI = double.Parse(Patient.BMI);
int Age = 0;
if (Patient.BirthDay != null && Patient.BirthDay != "") Age = PublicMethod.GetAgeNum(DateTime.Parse(Patient.BirthDay));
var AnaesthesiaText = Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
&& (x as XTextInputFieldElement).ID == "field6").FirstOrDefault();
var BMItext = Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
&& (x as XTextInputFieldElement).ID == "field7").FirstOrDefault();
var AgeText = Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
&& (x as XTextInputFieldElement).ID == "field8").FirstOrDefault();
foreach (XTextRadioBoxElement item in Document.RadioBoxes)
{
if (AnaesthesiaMethodName != "")
{
if (item.ID == "麻醉方式与手术体位_4" && AnaesthesiaMethodName.Contains("全身")) //|| Patient.OperationBodyPositionName.Contains("截石位")
{
item.Checked = true;
if (AnaesthesiaText != null)
AnaesthesiaText.Text = "4";
}
else if (item.ID == "麻醉方式与手术体位_1" && AnaesthesiaMethodName.Contains("局部")) //|| Patient.OperationBodyPositionName.Contains("仰卧位")
{
item.Checked = true;
if (AnaesthesiaText != null)
AnaesthesiaText.Text = "1";
}
else if (item.ID == "麻醉方式与手术体位_2" && AnaesthesiaMethodName.Contains("阻滞")) //|| Patient.OperationBodyPositionName.Contains("侧卧位")
{
item.Checked = true;
if (AnaesthesiaText != null)
AnaesthesiaText.Text = "2";
}
else if (item.ID == "麻醉方式与手术体位_3" && AnaesthesiaMethodName.Contains("椎管")) //|| Patient.OperationBodyPositionName.Contains("俯卧位")
{
item.Checked = true;
if (AnaesthesiaText != null)
AnaesthesiaText.Text = "3";
}
}
if (BMI != -1)
{
if (item.ID == "体型(BMI)_1" && (BMI >= 18.5 && BMI <= 23.9))
{
item.Checked = true;
if (BMItext != null)
BMItext.Text = "1";
}
else if (item.ID == "体型(BMI)_2" && ((BMI >= 17.5 && BMI < 18.5) || (BMI >= 24 && BMI <= 27.9)))
{
item.Checked = true;
if (BMItext != null)
BMItext.Text = "2";
}
else if (item.ID == "体型(BMI)_3" && ((BMI >= 16 && BMI < 17.5) || (BMI >= 28 && BMI <= 40)))
{
item.Checked = true;
if (BMItext != null)
BMItext.Text = "3";
}
else if (item.ID == "体型(BMI)_4" && (BMI < 16 || BMI > 40))
{
item.Checked = true;
if (BMItext != null)
BMItext.Text = "4";
}
}
if (Age > 0)
{
if (item.ID == "年龄_1" && Age < 50)
{
item.Checked = true;
if (AgeText != null)
AgeText.Text = "1";
}
else if (item.ID == "年龄_2" && Age >= 50 && Age <= 64)
{
item.Checked = true;
if (AgeText != null)
AgeText.Text = "2";
}
else if (item.ID == "年龄_3" && Age >= 65 && Age <= 79)
{
item.Checked = true;
if (AgeText != null)
AgeText.Text = "3";
}
else if (item.ID == "年龄_4" && (Age >= 80 || Age <= 1))
{
item.Checked = true;
if (AgeText != null)
AgeText.Text = "4";
}
}
}
}
}
public static void SaveCocumentValue(string XmlFileName, XTextDocument Document, ref PatientRecord Patient)
{
try
{
//更新ASA分级与心功能分级
if (XmlFileName == "麻醉术前访视单")
{
var asa = Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
&& (x as XTextInputFieldElement).ToolTip == "ASA分级").FirstOrDefault();
string strASA = asa == null ? "" : asa.Text;
var hf = Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
&& (x as XTextInputFieldElement).ToolTip == "心功能分级").FirstOrDefault();
string strH = hf == null ? "" : hf.Text;
UpdateASA(Patient.ApplyId, strASA, strH);
}
else if (XmlFileName == "麻醉术前访视评估记录单" || XmlFileName == "麻醉术前访视评估单")
{
string asaname = "";
string niyme = "";
var asa = Document.RadioBoxes.ToArray().Where(x => x is XTextRadioBoxElement
&& (x as XTextRadioBoxElement).Name == "asa");
foreach (var item in asa)
{
if ((item as XTextRadioBoxElement).Checked == true)
{
asaname = item.Text;
}
}
var niy = Document.RadioBoxes.ToArray().Where(x => x is XTextRadioBoxElement
&& (x as XTextRadioBoxElement).Name == "xgnfj");
foreach (var item in niy)
{
if ((item as XTextRadioBoxElement).Checked == true)
{
niyme = item.Text;
}
}
UpdateASA(Patient.ApplyId, asaname, niyme);
if (XmlFileName == "麻醉术前访视评估单")
{
var operation = Document.Fields.ToArray().Where(x => x.ID == "KB20180604142340471").FirstOrDefault();
if (operation != null && operation.Text != "" && operation.Text != Patient.ApplyOperationInfoName)
{
AddApplyOperation(Patient, GetOperationId(operation.Text));
Patient.ApplyOperationInfoName = operation.Text;
}
var diagnose = Document.Fields.ToArray().Where(x => x.ID == "field69").FirstOrDefault();
if (diagnose != null && diagnose.Text != "" && diagnose.Text != Patient.ApplyDiagnoseInfoName)
{
AddApplyDiagnose(Patient, GetDiagnoseId(diagnose.Text));
Patient.ApplyDiagnoseInfoName = diagnose.Text;
}
}
}
else if (XmlFileName == "麻醉知情同意书")
{
var asa = Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
&& (x as XTextInputFieldElement).Name == "拟定麻醉").FirstOrDefault();
if (asa != null)
{
AddAnaesthesiaMethod(Patient, asa.FormulaValue);
}
var diagnose = Document.Fields.ToArray().Where(x => x.ID == "KB20180604142254986").FirstOrDefault();
if (diagnose != null && diagnose.Text != "" && diagnose.Text != Patient.ApplyDiagnoseInfoName)
{
AddApplyDiagnose(Patient, GetDiagnoseId(diagnose.Text));
Patient.ApplyDiagnoseInfoName = diagnose.Text;
}
}
}
catch (Exception ex)
{
PublicMethod.WriteLog(ex);
}
}
public static void SetCocumentValue(string XmlFileName, XTextDocument Document)
{
try
{
if (XmlFileName == "手术患者压疮风险评估记录表")
{
int num = 0;
var asa = Document.RadioBoxes.ToArray().Where(x => x is XTextRadioBoxElement
&& (x as XTextRadioBoxElement).GroupName == "麻醉方式与手术体位" && (x as XTextRadioBoxElement).Checked == true).FirstOrDefault();
if (asa != null)
num += int.Parse(asa.FormulaValue);
string strASA = asa == null ? "" : asa.FormulaValue;
var hf = Document.RadioBoxes.ToArray().Where(x => x is XTextRadioBoxElement
&& (x as XTextRadioBoxElement).GroupName == "体型(BMI)" && (x as XTextRadioBoxElement).Checked == true).FirstOrDefault();
if (hf != null)
num += int.Parse(hf.FormulaValue);
var pf = Document.RadioBoxes.ToArray().Where(x => x is XTextRadioBoxElement
&& (x as XTextRadioBoxElement).GroupName == "皮肤" && (x as XTextRadioBoxElement).Checked == true).FirstOrDefault();
if (pf != null)
num += int.Parse(pf.FormulaValue);
var zthd = Document.RadioBoxes.ToArray().Where(x => x is XTextRadioBoxElement
&& (x as XTextRadioBoxElement).GroupName == "肢体活动" && (x as XTextRadioBoxElement).Checked == true).FirstOrDefault();
if (zthd != null)
num += int.Parse(zthd.FormulaValue);
var sssj = Document.RadioBoxes.ToArray().Where(x => x is XTextRadioBoxElement
&& (x as XTextRadioBoxElement).GroupName == "预计手术时间" && (x as XTextRadioBoxElement).Checked == true).FirstOrDefault();
if (sssj != null)
num += int.Parse(sssj.FormulaValue);
var gwjb = Document.RadioBoxes.ToArray().Where(x => x is XTextRadioBoxElement
&& (x as XTextRadioBoxElement).GroupName == "高危疾病" && (x as XTextRadioBoxElement).Checked == true).FirstOrDefault();
if (gwjb != null)
num += int.Parse(gwjb.FormulaValue);
var patientId = Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
&& (x as XTextInputFieldElement).ID == "field12").FirstOrDefault();
patientId.Text = (num > 0 ? num.ToString() : "");
}
else if (XmlFileName == "手术患者压疮风险评估记录表")
{
int num = 0;
var asa = Document.RadioBoxes.ToArray().Where(x => x is XTextRadioBoxElement
&& (x as XTextRadioBoxElement).GroupName == "体温丢失因素" && (x as XTextRadioBoxElement).Checked == true).FirstOrDefault();
if (asa != null)
num += int.Parse(asa.FormulaValue);
string strASA = asa == null ? "" : asa.FormulaValue;
var hf = Document.RadioBoxes.ToArray().Where(x => x is XTextRadioBoxElement
&& (x as XTextRadioBoxElement).GroupName == "手术出血量" && (x as XTextRadioBoxElement).Checked == true).FirstOrDefault();
if (hf != null)
num += int.Parse(hf.FormulaValue);
var pf = Document.RadioBoxes.ToArray().Where(x => x is XTextRadioBoxElement
&& (x as XTextRadioBoxElement).GroupName == "压力剪切力改变" && (x as XTextRadioBoxElement).Checked == true).FirstOrDefault();
if (pf != null)
num += int.Parse(pf.FormulaValue);
var zthd = Document.RadioBoxes.ToArray().Where(x => x is XTextRadioBoxElement
&& (x as XTextRadioBoxElement).GroupName == "实际手术时间" && (x as XTextRadioBoxElement).Checked == true).FirstOrDefault();
if (zthd != null)
num += int.Parse(zthd.FormulaValue);
var patientId = Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
&& (x as XTextInputFieldElement).ID == "field14").FirstOrDefault();
patientId.Text = (num > 0 ? num.ToString() : "");
}
else if (XmlFileName == "压疮风险评估表")
{
int num = 0;
var asa = Document.RadioBoxes.ToArray().Where(x => x is XTextRadioBoxElement
&& (x as XTextRadioBoxElement).GroupName == "麻醉方式与手术体位" && (x as XTextRadioBoxElement).Checked == true).FirstOrDefault();
if (asa != null)
{
num += int.Parse(asa.FormulaValue);
var field6 = Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
&& (x as XTextInputFieldElement).ID == "field6").FirstOrDefault();
field6.Text = asa.FormulaValue;
}
var hf = Document.RadioBoxes.ToArray().Where(x => x is XTextRadioBoxElement
&& (x as XTextRadioBoxElement).GroupName == "体型(BMI)" && (x as XTextRadioBoxElement).Checked == true).FirstOrDefault();
if (hf != null)
{
num += int.Parse(hf.FormulaValue);
var field7 = Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
&& (x as XTextInputFieldElement).ID == "field7").FirstOrDefault();
field7.Text = hf.FormulaValue;
}
var age = Document.RadioBoxes.ToArray().Where(x => x is XTextRadioBoxElement
&& (x as XTextRadioBoxElement).GroupName == "年龄" && (x as XTextRadioBoxElement).Checked == true).FirstOrDefault();
if (age != null)
{
num += int.Parse(age.FormulaValue);
var field8 = Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
&& (x as XTextInputFieldElement).ID == "field8").FirstOrDefault();
field8.Text = age.FormulaValue;
}
var pf = Document.RadioBoxes.ToArray().Where(x => x is XTextRadioBoxElement
&& (x as XTextRadioBoxElement).GroupName == "皮肤" && (x as XTextRadioBoxElement).Checked == true).FirstOrDefault();
if (pf != null)
{
num += int.Parse(pf.FormulaValue);
var field8 = Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
&& (x as XTextInputFieldElement).ID == "field9").FirstOrDefault();
field8.Text = pf.FormulaValue;
}
var sssj = Document.RadioBoxes.ToArray().Where(x => x is XTextRadioBoxElement
&& (x as XTextRadioBoxElement).GroupName == "预计手术时间" && (x as XTextRadioBoxElement).Checked == true).FirstOrDefault();
if (sssj != null)
{
num += int.Parse(sssj.FormulaValue);
var field = Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
&& (x as XTextInputFieldElement).ID == "field10").FirstOrDefault();
field.Text = sssj.FormulaValue;
}
var gwjb = Document.RadioBoxes.ToArray().Where(x => x is XTextRadioBoxElement
&& (x as XTextRadioBoxElement).GroupName == "手术施压" && (x as XTextRadioBoxElement).Checked == true).FirstOrDefault();
if (gwjb != null)
{
num += int.Parse(gwjb.FormulaValue);
var field = Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
&& (x as XTextInputFieldElement).ID == "field11").FirstOrDefault();
field.Text = gwjb.FormulaValue;
}
var patientId = Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
&& (x as XTextInputFieldElement).ID == "field12").FirstOrDefault();
patientId.Text = (num > 0 ? num.ToString() : "");
}
}
catch (Exception ex)
{
PublicMethod.WriteLog(ex);
}
}
public static void SetCocumentValueText(string XmlFileName, XTextDocument Document, XTextInputFieldElement element)
{
try
{
if (XmlFileName == "分娩镇痛麻醉记录单")
{
if (element != null && element.Name == "镇痛开始时间" && element.Text != "")
{
DateTime dt = DateTime.Parse(element.Text);
var texts = element.WriterControl.Document.Fields.ToArray().Where(x => x is XTextInputFieldElement).ToList();
foreach (var item in texts)
{
switch (item.ID)
{
case "field24":
item.Text = dt.AddMinutes(5).ToString("MM-dd HH:mm");
break;
case "field25":
item.Text = dt.AddMinutes(10).ToString("MM-dd HH:mm");
break;
case "field26":
item.Text = dt.AddMinutes(30).ToString("MM-dd HH:mm");
break;
case "field27":
item.Text = dt.AddHours(1).ToString("MM-dd HH:mm");
break;
case "field28":
item.Text = dt.AddHours(2).ToString("MM-dd HH:mm");
break;
case "field29":
item.Text = dt.AddHours(3).ToString("MM-dd HH:mm");
break;
case "field30":
item.Text = dt.AddHours(4).ToString("MM-dd HH:mm");
break;
case "field31":
item.Text = dt.AddHours(5).ToString("MM-dd HH:mm");
break;
case "field32":
item.Text = dt.AddHours(6).ToString("MM-dd HH:mm");
break;
case "field33":
item.Text = dt.AddHours(7).ToString("MM-dd HH:mm");
break;
case "field34":
item.Text = dt.AddHours(8).ToString("MM-dd HH:mm");
break;
}
}
}
else if (element != null && element.Name == "BP" && element.Text != "")
{
int bp = 0;
if (int.TryParse(element.Text, out bp))
{
if (bp > 60)
{
element.Text = bp.ToString() + "/";
}
}
}
}
}
catch (Exception ex)
{
PublicMethod.WriteLog(ex);
}
}
public static void SetCocumentValueText2(string XmlFileName, XTextDocument Document, XTextInputFieldElement element)
{
try
{
if (XmlFileName == "分娩镇痛麻醉记录单")
{
if (element != null && element.Name == "BP" && element.Text != "")
{
if (element.Text.Contains("/"))
{
List<string> list = element.Text.Split('/').ToList();
if (list.Count == 2)
{
int bp = 0;
int bp2 = 0;
if (int.TryParse(list[0], out bp) && int.TryParse(list[1], out bp2))
{
var texts = element.WriterControl.Document.Fields.ToArray().Where(x => x is XTextInputFieldElement && (x as XTextInputFieldElement).Name == "BP").ToList();
foreach (var item in texts)
{
if (item.ID == element.ID) continue;
int randomNumber = GenerateRandomNumberWithPercentageRange(bp, 10);
int randomNumber2 = GenerateRandomNumberWithPercentageRange(bp2, 10);
item.Text = randomNumber.ToString() + "/" + randomNumber2.ToString();
}
}
}
}
}
else if (element != null && element.Name == "HR" && element.Text != "")
{
int bp = 0;
if (int.TryParse(element.Text, out bp))
{
if (bp > 0)
{
var texts = element.WriterControl.Document.Fields.ToArray().Where(x => x is XTextInputFieldElement && (x as XTextInputFieldElement).Name == "HR").ToList();
foreach (var item in texts)
{
if (item.ID == element.ID) continue;
int randomNumber = GenerateRandomNumberWithPercentageRange(bp, 10);
item.Text = randomNumber.ToString();
}
}
}
}
else if (element != null && element.Name == "RR" && element.Text != "")
{
int bp = 0;
if (int.TryParse(element.Text, out bp))
{
if (bp > 0)
{
var texts = element.WriterControl.Document.Fields.ToArray().Where(x => x is XTextInputFieldElement && (x as XTextInputFieldElement).Name == "RR").ToList();
foreach (var item in texts)
{
if (item.ID == element.ID) continue;
int randomNumber = GenerateRandomNumberWithPercentageRange(bp, 5);
item.Text = randomNumber.ToString();
}
}
}
}
else if (element != null && element.Name == "SPO2" && element.Text != "")
{
int bp = 0;
if (int.TryParse(element.Text, out bp))
{
if (bp > 0)
{
var texts = element.WriterControl.Document.Fields.ToArray().Where(x => x is XTextInputFieldElement && (x as XTextInputFieldElement).Name == "SPO2").ToList();
foreach (var item in texts)
{
if (item.ID == element.ID) continue;
item.Text = bp.ToString();
}
}
}
}
else if (element != null && element.Name == "VAS" && element.Text != "")
{
int bp = 0;
if (int.TryParse(element.Text, out bp))
{
if (bp > 0)
{
var texts = element.WriterControl.Document.Fields.ToArray().Where(x => x is XTextInputFieldElement && (x as XTextInputFieldElement).Name == "VAS").ToList();
foreach (var item in texts)
{
if (item.ID == element.ID) continue;
item.Text = bp.ToString();
}
}
}
}
}
}
catch (Exception ex)
{
PublicMethod.WriteLog(ex);
}
}
static int GenerateRandomNumberWithPercentageRange(int number, int percentage)
{
Random random = new Random();
int min = number - percentage;
int max = number + percentage;
return random.Next(min, max);
}
public static int AddApplyOperation(PatientRecord _operationRecord, string Operation)
{
int i = 0;
if (Operation.Trim() == "" || Operation == ",")
{
DeleteApplyOperation(_operationRecord.ApplyId);
i++;
}
else
{
DeleteApplyOperation(_operationRecord.ApplyId);
i++;
string[] Operationstr = Operation.Split(',');
foreach (string OperationId in Operationstr)
{
string Name = "";
string sql = string.Format("select Name from Operation where Id = '{0}'", OperationId);
object dt = DBHelper.ExecuteScalar(sql);
if (dt != null) { Name = dt.ToString(); }
StringBuilder strSql = new StringBuilder();
strSql.Append("insert into [ApplyOperationInfo](");
strSql.Append("OperationApplyId,OperationId,OperatorNo,OperatorName,OperateDate,OperationName,LeftRemark,RightRemark");
strSql.Append(")");
strSql.Append(" values (");
strSql.Append("" + _operationRecord.ApplyId + ",");
strSql.Append("" + OperationId + ",");
strSql.Append("'" + AIMSExtension.PublicMethod.OperatorNo + "',");
strSql.Append("'" + AIMSExtension.PublicMethod.OperatorName + "',");
strSql.Append("'" + DateTime.Now + "',");
strSql.Append("'" + Name + "',");//" + FactOperationInfoObj.OperationName + "
strSql.Append("'',");//" + FactOperationInfoObj.LeftRemark + "
strSql.Append("''");//" + FactOperationInfoObj.RightRemark + "
strSql.Append(")");
i += HelperDB.DbHelperSQL.ExecNonQuery(strSql.ToString());
}
}
return i;
}
public static int AddApplyDiagnose(PatientRecord _operationRecord, string Diagnose)
{
int i = 0;
if (Diagnose.Trim() == "" || Diagnose == ",")
{
DeleteApplyDiagnose(_operationRecord.ApplyId);
i++;
}
else
{
DeleteApplyDiagnose(_operationRecord.ApplyId);
i++;
string[] Diagnosestr = Diagnose.Split(',');
foreach (string DiagnoseId in Diagnosestr)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("insert into [ApplyDiagnoseInfo](");
strSql.Append("OperationApplyId,DiagnoseId,OperatorNo,OperatorName,OperateDate");
strSql.Append(")");
strSql.Append(" values (");
strSql.Append("" + _operationRecord.ApplyId + ",");
strSql.Append("" + DiagnoseId + ",");
strSql.Append("'" + AIMSExtension.PublicMethod.OperatorNo + "',");
strSql.Append("'" + AIMSExtension.PublicMethod.OperatorName + "',");
strSql.Append("'" + DateTime.Now + "'");
strSql.Append(")");
i += HelperDB.DbHelperSQL.ExecNonQuery(strSql.ToString());
}
}
return i;
}
public static void AddAnaesthesiaMethod(PatientRecord _operationRecord, string AnaesthesiaMethod)
{
if (AnaesthesiaMethod.Trim() == "" || AnaesthesiaMethod == "+")
{
DeleteAnaesthesiaMethod(_operationRecord.ApplyId);
}
else
{
DeleteAnaesthesiaMethod(_operationRecord.ApplyId);
string[] Operationstr = AnaesthesiaMethod.Split('+');
foreach (string AnaesthesiaMethodId in Operationstr)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("insert into [ApplyAnaesthesiaMethod](");
strSql.Append("[OperationApplyId], [AnaesthesiaMethodId], [OperatorNo], [OperatorName], [OperateDate]");
strSql.Append(")");
strSql.Append(" values (");
strSql.Append("" + _operationRecord.ApplyId + ",");
strSql.Append("" + GetAnaesthesiaMethodId(AnaesthesiaMethodId) + ",");
strSql.Append("'" + AIMSExtension.PublicMethod.OperatorNo + "',");
strSql.Append("'" + AIMSExtension.PublicMethod.OperatorName + "',");
strSql.Append("'" + DateTime.Now + "'");
strSql.Append(")");
HelperDB.DbHelperSQL.ExecNonQuery(strSql.ToString());
}
}
}
public static void DeleteAnaesthesiaMethod(int PatientId)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("delete ApplyAnaesthesiaMethod ");
strSql.Append(" where OperationApplyId=" + PatientId + " ");
HelperDB.DbHelperSQL.ExecNonQuery(strSql.ToString());
}
public static void DeleteApplyOperation(int OperationApplyId)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("delete ApplyOperationInfo ");
strSql.Append(" where OperationApplyId=" + OperationApplyId + " ");
HelperDB.DbHelperSQL.ExecNonQuery(strSql.ToString());
}
public static void DeleteApplyDiagnose(int OperationApplyId)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("delete ApplyDiagnoseInfo ");
strSql.Append(" where OperationApplyId=" + OperationApplyId + " ");
HelperDB.DbHelperSQL.ExecNonQuery(strSql.ToString());
}
public static int GetAnaesthesiaMethodId(string Name)
{
try
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select * from AnaesthesiaMethod ");
strSql.Append(" where name='" + Name.Trim() + "' ");
return int.Parse(HelperDB.DBHelper.ExecuteScalar(strSql.ToString()).ToString());
}
catch (Exception)
{
return 1;
}
}
private static string GetOperationId(string Name)
{
string namestr = Name.Replace("\n", "").Replace("\t", "");
List<string> result = new List<string>();
List<string> names = new List<string>();
if (namestr.Contains(","))
{
names = namestr.Split(',').ToList();
}
else if (namestr.Contains(""))
{
names = namestr.Split('').ToList();
}
else if (namestr.Contains("+"))
{
names = namestr.Split('+').ToList();
}
else
{
names.Add(namestr);
}
foreach (var name in names)
{
DataTable dt = DBHelper.GetDataTable("select * from Operation where Name ='" + name + "'");
if (dt.Rows.Count == 0)
{
DBHelper.ExecNonQuery(string.Concat(new Object[]{
"insert into Operation(ICDCode,Name,HelpCode,IsValid,UseRate,OperatorNo,[OperatorName],OperateDate) values('','"+name+"','"+PublicMethod.GetFirstLetter(name)+"',1,1,'admin','系统管理员','"+DateTime.Now+"')"}));
}
dt = DBHelper.GetDataTable("select * from Operation where Name ='" + name + "'");
if (dt.Rows.Count > 0)
{
for (int j = 0; j < dt.Rows.Count; j++)
{
result.Add(dt.Rows[0]["Id"].ToString());
}
}
}
return string.Join(",", result.ToArray());
}
private static string GetDiagnoseId(string Name)
{
string namestr = Name.Replace("\n", "").Replace("\t", "");
List<string> result = new List<string>();
List<string> names = new List<string>();
if (namestr.Contains(","))
{
names = namestr.Split(',').ToList();
}
else if (namestr.Contains(""))
{
names = namestr.Split('').ToList();
}
else if (namestr.Contains("+"))
{
names = namestr.Split('+').ToList();
}
else
{
names.Add(namestr);
}
foreach (var name in names)
{
DataTable dt = DBHelper.GetDataTable("select * from Disease where Name ='" + name + "'");
if (dt.Rows.Count == 0)
{
DBHelper.ExecNonQuery(string.Concat(new Object[]{
"insert into Disease(ICDCode,Name,HelpCode,IsValid,UseRate,OperatorNo,[OperatorName],OperateDate) values('','"+name+"','"+PublicMethod.GetFirstLetter(name)+"',1,1,'admin','系统管理员','"+DateTime.Now+"')"}));
}
dt = DBHelper.GetDataTable("select * from Disease where Name ='" + name + "'");
if (dt.Rows.Count > 0)
{
for (int j = 0; j < dt.Rows.Count; j++)
{
result.Add(dt.Rows[0]["Id"].ToString());
}
}
}
return string.Join(",", result.ToArray());
}
public static void UpdateASA(int ApplyId, string ASA, string HeartFunctionLevel)
{
StringBuilder sb = new StringBuilder();
sb.Append(" UPDATE OperationApply SET");
sb.Append(" ASA ='" + ASA + "'");
sb.Append(" ,HeartFunctionLevel='" + HeartFunctionLevel + "'");
sb.Append(" WHERE id='" + ApplyId + "'");
HelperDB.DbHelperSQL.ExecNonQuery(sb.ToString());
}
}
}
//100038004389
//https://wqs.jd.com/order/m.confirm.shtml?sceneval=2&bid=&wdref=https%3A%2F%2Fitem.m.jd.com%2Fproduct%2F100038004389.html%3Fsceneval%3D2%26jxsid%3D16698592780168569097&scene=jd&isCanEdit=1&EncryptInfo=&Token=&commlist=100038004389%2C%2C1%2C100038004389%2C1%2C0%2C0&locationid=1-72-2819&type=0&lg=0&supm=0&favorablerate=97&jxsid=16698592780168569097&login=1&r=0.9297322414368827#/index
//var p = element.GetType().GetProperty("ID").GetValue(element, null);
//string pID = p.ToString();
//if (pID != null)
//{
// switch (element.ID)
// {
// case "D2018071115522659588135":
// if (element.Text.Length > 0)
// {
// SetValueByName("手术麻醉史", "Checked", false);
// }
// else
// {
// SetValueByName("手术麻醉史", "Checked", true);
// }
// break;
// case "D2018071115522661909621":
// if (element.Text.Length > 0)
// {
// SetValueByName("心血管系统正常", "Checked", false);
// }
// else if (element.Text.Length == 0
// && !GetCheckedValueByName("高血压")
// && !GetCheckedValueByName("冠心病")
// && !GetCheckedValueByName("瓣膜病")
// && !GetCheckedValueByName("心律失常"))
// {
// SetValueByName("心血管系统正常", "Checked", true);
// }
// break;
// case "D2018071115522620315681":
// if (element.Text.Length > 0)
// {
// SetValueByName("呼吸系统正常", "Checked", false);
// }
// else if (element.Text.Length == 0
// && !GetCheckedValueByName("COPD")
// && !GetCheckedValueByName("哮喘"))
// {
// SetValueByName("呼吸系统正常", "Checked", true);
// }
// break;
// case "D2018071115522648623408":
// if (element.Text.Length > 0)
// {
// SetValueByName("内分泌系统正常", "Checked", false);
// }
// else if (element.Text.Length == 0
// && !GetCheckedValueByName("内分泌系统糖尿病")
// && !GetCheckedValueByName("库兴综合症")
// && !GetCheckedValueByName("内分泌系统甲亢"))
// {
// SetValueByName("内分泌系统正常", "Checked", true);
// }
// break;
// case "D2018071115522634957489":
// if (element.Text.Length > 0)
// {
// SetValueByName("消化系统正常", "Checked", false);
// }
// else if (element.Text.Length == 0
// && !GetCheckedValueByName("肝炎")
// && !GetCheckedValueByName("肝硬化")
// && !GetCheckedValueByName("胃食管返流"))
// {
// SetValueByName("消化系统正常", "Checked", true);
// }
// break;
// case "D2018071115522646181951":
// if (element.Text.Length > 0)
// {
// SetValueByName("泌尿系统正常", "Checked", false);
// }
// else if (element.Text.Length == 0
// && !GetCheckedValueByName("肾病")
// && !GetCheckedValueByName("尿毒症")
// && !GetCheckedValueByName("肾衰"))
// {
// SetValueByName("泌尿系统正常", "Checked", true);
// }
// break;
// case "D2018071115522612984378":
// if (element.Text.Length > 0)
// {
// SetValueByName("神经系统正常", "Checked", false);
// }
// else if (element.Text.Length == 0
// && !GetCheckedValueByName("昏迷")
// && !GetCheckedValueByName("脑梗")
// && !GetCheckedValueByName("老年痴呆")
// && !GetCheckedValueByName("帕金森综合症"))
// {
// SetValueByName("神经系统正常", "Checked", true);
// }
// break;
// default:
// break;
// }
//}