public bool ElementFromBookmarks(XmlElement emrNote, Boolean newNote, EmrConstant.Button button) { if (!newNote) { for (int k = emrNote.ChildNodes.Count - 1; k >= 0; k--) { emrNote.RemoveChild(emrNote.ChildNodes[k]); } } string RegistryID = emrNote.OwnerDocument.ChildNodes[0].Attributes[EmrConstant.AttributeNames.RegistryID].Value; if (ThisAddIn.CanOption(ElementNames.EHRInterface) == true) { #region 定义健康档案接口变量 string PatientID = ""; string StateIn = ""; string DiagnosisIn = ""; string Treatment = ""; string StateOut = ""; string DiagnosisOut = ""; string OrderOut = ""; string ResidentPhysician = ""; string PhysicianInCharge = ""; string Department = ""; string Bah = ""; string zyh = ""; DateTime AdmitDateTime = new DateTime(); DateTime OutDateTime = new DateTime(); #endregion string Hospital = "东方地球物理公司第二职工医院"; using (gjtEmrPatients.emrPatients ep = new gjtEmrPatients.emrPatients()) try { DataSet dst = ep.GetPatientInf(RegistryID); PatientID = dst.Tables[0].Rows[0]["sfzh"].ToString(); //Department = dst.Tables[0].Rows[0]["ksbm"].ToString(); Bah = dst.Tables[0].Rows[0]["bah"].ToString(); zyh = dst.Tables[0].Rows[0]["zyh"].ToString(); AdmitDateTime = Convert.ToDateTime(dst.Tables[0].Rows[0]["zyrq"].ToString()); OutDateTime = Convert.ToDateTime(dst.Tables[0].Rows[0]["cyrq"].ToString()); if (PatientID == null || PatientID == "") { Globals.health = false; } } catch (Exception ex) { Globals.logAdapter.Record("EX741852968", ex.Message + ">>" + ex.ToString(), true); } if (PatientID == null || PatientID == "") { Globals.health = false; } if (Globals.health == true) { foreach (Word.XMLNode xn in ActiveDocumentManager.getDefaultAD().XMLNodes) { string content = xn.BaseName; switch (content) { case "科室": Department = xn.Range.Text.Trim(); break; case "入院情况": StateIn = xn.Range.Text.Trim(); break; case "入院诊断": DiagnosisIn = xn.Range.Text.Trim(); break; case "诊疗经过": Treatment = xn.Range.Text.Trim(); break; case "出院情况": StateOut = xn.Range.Text.Trim(); break; case "出院诊断": DiagnosisOut = xn.Range.Text.Trim(); break; case "出院医嘱": OrderOut = xn.Range.Text.Trim(); break; case "住院医师": if (xn.Range.Text != null) { ResidentPhysician = xn.Range.Text.Trim(); } break; case "医师": PhysicianInCharge = Globals.DoctorName; break; default: break; } } } if (Globals.health == true) { //WebReference.Hiss h = new WebReference.Hiss(); //{ // try // { // int result = h.Insert_InpatientInfo_EMR(PatientID, AdmitDateTime, OutDateTime, zyh, StateIn, DiagnosisIn, Treatment, StateOut, DiagnosisOut, OrderOut, // ResidentPhysician, PhysicianInCharge, Department, Hospital, Bah, ref err); // result++; // } // catch (Exception ex) // { // } //} Globals.health = false; } } Word.ContentControl title = null; Word.ContentControl titleNext = null; Word.Range range = ActiveDocumentManager.getDefaultAD().Paragraphs.First.Range; ArrayList lables = new ArrayList(); foreach (Word.ContentControl lable in ActiveDocumentManager.getDefaultAD().ContentControls) { if (lable.Title == StringGeneral.Label) { lables.Add(lable); } else if (lable.Title == StringGeneral.Control) { //lable.LockContentControl = false; //lable.LockContents = false; //lable.Delete(false); } } #region Check empty subtitle /* If the content of a subtitle is empty, you should delete it, otherwise, the insignificant * value of a xml element will be removed by sql 2005 for a xml column. */ if (button == EmrConstant.Button.CommitNote) { /* When commit note, required subtitle must not be empty. */ for (int i = lables.Count - 1; i > 0; i--) { title = (Word.ContentControl)lables[i - 1]; string required = title.Tag.ToString(); titleNext = (Word.ContentControl)lables[i]; range.Start = title.Range.End + 1; range.End = titleNext.Range.Start - 1; //20100128 if (required == StringGeneral.Yes) { if (range.Text != null) { //if (range.Text.Contains("选择一项")) //{ // MessageBox.Show(title.Range.Text + " -- 是必须要填写的!", ErrorMessage.Warning); // range.Select(); // return Return.Failed; //} } } if (!IsSignificant(range.Text)) { #region Empty subtitle if (required == StringGeneral.Yes) { /* Required subtitle must has content. */ //MessageBox.Show(title.Range.Text + " -- 是必须要填写的!", ErrorMessage.Warning); //range.Select(); //return Return.Failed; } else { /* Not required empty subtitle is removed. */ //range.Text = ""; //title.LockContentControl = false; //title.LockContents = false; //title.Delete(true); //lables.RemoveAt(i - 1); title.LockContents = false; ///guojt 2009/7/15 title.Range.Font.Color = Globals.labelFont.Color; title.LockContents = true; } #endregion } else { #region Not required empty subtitle needs change font color with that of the required if (required == EmrConstant.StringGeneral.No) { title.LockContents = false; title.Range.Font.Color = Globals.labelFont.Color; title.LockContents = true; } #endregion } } } #endregion #region Fill subtitel into emrNote for (int i = 0; i < lables.Count - 1; i++) { title = (Word.ContentControl)lables[i]; titleNext = (Word.ContentControl)lables[i + 1]; range.Start = title.Range.End + 1; range.End = titleNext.Range.Start - 1; XmlElement subTitle = emrNote.OwnerDocument.CreateElement(ElementNames.SubTitle); ElementFromBookmarkMe(subTitle, range); subTitle.SetAttribute(AttributeNames.TitleName, title.Range.Text); /* 2007-07-20 using doubale storage: word document and xml emrDocument. In emrDocuments, * only text is allowed. */ //ElementFromTables(doc, subTitle, range); //ElementFromImages(doc, subTitle, range); emrNote.AppendChild(subTitle); } #endregion //XmlElement revisions = doc.CreateElement(EmrConstant.ElementNames.Revisions); //range = ActiveDocumentManager.getDefaultAD().Content; //RevisionFromBookmark(doc, range, ref revisions); //emrNote.AppendChild(revisions); return(EmrConstant.Return.Successful); }