330 lines
		
	
	
		
			15 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			330 lines
		
	
	
		
			15 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using AIMSExtension;
 | |
| using DCSoft.Writer.Dom;
 | |
| using System;
 | |
| using System.Collections.Generic;
 | |
| using System.Linq;
 | |
| using System.Text;
 | |
| using System.Xml.Linq;
 | |
| 
 | |
| 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();
 | |
|                     if (field9.Text != "") Result += int.Parse(field9.Text);
 | |
|                     var field10 = Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
 | |
|                         && (x as XTextInputFieldElement).ID == "field10").FirstOrDefault();
 | |
|                     if (field10.Text != "") Result += int.Parse(field10.Text);
 | |
|                     var field11 = Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
 | |
|                         && (x as XTextInputFieldElement).ID == "field11").FirstOrDefault();
 | |
|                     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";
 | |
|                         }
 | |
| 
 | |
|                     }
 | |
| 
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| }
 | |
| //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;
 | |
| //    }
 | |
| //}
 | |
| 
 |