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 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 >= 80 || Age <= 1)) { item.Checked = true; if (AgeText != null) AgeText.Text = "1"; } else if (item.ID == "年龄_2" && Age < 50) { item.Checked = true; if (AgeText != null) AgeText.Text = "2"; } else if (item.ID == "年龄_3" && (Age >= 50 && Age <= 64)) { item.Checked = true; if (AgeText != null) AgeText.Text = "3"; } else if (item.ID == "年龄_4" && (Age >= 65 && Age <= 79)) { item.Checked = true; if (AgeText != null) AgeText.Text = "4"; } } } } } } } //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; // } //} //var p = element.GetType().GetProperty("Name").GetValue(element, null); //if (p == null) // return; //string pName = p.ToString(); //switch (pName) //{ // case "麻醉方式与手术体位": // SetValueById("field6", "Text", element.Text); // break; // case "体型(BMI)": // SetValueById("field7", "Text", element.Text); // break; // case "年龄": // SetValueById("field8", "Text", element.Text); // break; // case "皮肤": // SetValueById("field9", "Text", element.Text); // break; // case "预计手术时间": // SetValueById("field10", "Text", element.Text); // break; // case "手术施压": // SetValueById("field11", "Text", element.Text); // break; // default: // break; //}