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"; } } } } } public static void SaveCocumentValue(string XmlFileName, XTextDocument Document, 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); } if (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); } 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); } } } catch (Exception ex) { PublicMethod.WriteLog(ex); } } 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 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; } } 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; // } //}