예제 #1
0
        public static void setPageNum(Word.Application wordApp)
        {
            Word.Document myDoc      = ActiveDocumentManager.getDefaultAD();
            int           iPageCount = getTotalPage(myDoc);
            int           iSections  = ActiveDocumentManager.getDefaultAD().Range().Sections.Count;

            for (int i = 1; i <= iSections; i++)
            {
                Range             rg = ActiveDocumentManager.getDefaultAD().Range().Sections[i].Range;
                Word.HeaderFooter hf = rg.Sections[1].Footers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary];
                hf.Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                hf.Range.Text = "第   页";

                hf.PageNumbers.NumberStyle = Word.WdPageNumberStyle.wdPageNumberStyleArabic;
                hf.PageNumbers.RestartNumberingAtSection = false;
                //hf.PageNumbers.StartingNumber = 1;
                //hf.LinkToPrevious = true;
                //hf.PageNumbers.
                object alignment  = Word.WdPageNumberAlignment.wdAlignPageNumberCenter;
                object oFirstPage = true;
                rg.Sections[1].Footers[WdHeaderFooterIndex.wdHeaderFooterPrimary].PageNumbers.Add(ref alignment, ref oFirstPage);
            }

            //throw new Exception();
        }
예제 #2
0
파일: EmrNote1.cs 프로젝트: zhanglg40/hmr
        private void ElementFromBookmarkMe(XmlElement subtitle, Word.Range range)
        {
            Word.Range rangeTmp = null;

            if (subtitle.ChildNodes.Count > 0)
            {
                subtitle.IsEmpty = true;
            }

            if (range.Tables.Count > 0)
            {
                #region Has tables
                ArrayList tableRangeStart = new ArrayList();
                ArrayList tableRangeEnd   = new ArrayList();
                foreach (Word.Table table in range.Tables)
                {
                    int start = table.Range.Start;
                    tableRangeStart.Add(start);
                    tableRangeEnd.Add(table.Range.End);
                }
                tableRangeStart.Sort();
                tableRangeEnd.Sort();
                /* Text of this range from start of range to end of first table range. */
                object textStart = range.Start;
                object textEnd   = tableRangeStart[0];
                rangeTmp = ActiveDocumentManager.getDefaultAD().Range(ref textStart, ref textEnd);
                if (rangeTmp.Text.Length > 0)
                {
                    subtitle.InnerText = TrimLineFeed(rangeTmp.Text);
                }
                /* If there are more table in the range. */
                for (int k = 1; k < tableRangeStart.Count; k++)
                {
                    /* Text of range between two tables.*/
                    rangeTmp.Start = (int)tableRangeEnd[k - 1];
                    rangeTmp.End   = (int)tableRangeStart[k];
                    if (rangeTmp.Text.Length > 0)
                    {
                        subtitle.InnerText += TrimLineFeed(rangeTmp.Text);
                    }
                }
                /* Text of from start of first table range to end of this range. */
                rangeTmp.Start = (int)tableRangeEnd[tableRangeStart.Count - 1];
                rangeTmp.End   = range.End;
                if (rangeTmp.Text != string.Empty)
                {
                    subtitle.InnerText += TrimLineFeed(rangeTmp.Text);
                }
                #endregion
            }
            else
            {
                if (range.Text != string.Empty)
                {
                    subtitle.InnerText = TrimLineFeed(range.Text);
                }
            }
        }
예제 #3
0
 private static void setGrammarCheck(Word.Application wordApp)
 {
     try
     {
         wordApp.ShowWindowsInTaskbar = false;
         ActiveDocumentManager.getDefaultAD().SpellingChecked = false;
         wordApp.Options.CheckGrammarWithSpelling = false;
         wordApp.CheckLanguage = false;
     }
     catch (Exception)
     {
     }
 }
예제 #4
0
 private void ResetFocus()
 {
     foreach (Word.ContentControl cc in ActiveDocumentManager.getDefaultAD().ContentControls)
     {
         if (cc.Title == StringGeneral.Label)
         {
             object     start = cc.Range.End + 1;
             object     end   = start;
             Word.Range rg    = ActiveDocumentManager.getDefaultAD().Range(ref start, ref end);
             rg.Select();
             break;
         }
     }
 }
예제 #5
0
 public static void setCopyConfig(Word.Application wordApp)
 {
     try
     {   //设置格式“匹配目标格式”
         wordApp.Options.PasteFormatBetweenDocuments       = Word.WdPasteOptions.wdMatchDestinationFormatting;
         wordApp.Options.PasteFormatBetweenStyledDocuments = Word.WdPasteOptions.wdMatchDestinationFormatting;
         wordApp.Options.PasteFormatFromExternalSource     = Word.WdPasteOptions.wdMatchDestinationFormatting;
         wordApp.Options.PasteFormatWithinDocument         = Word.WdPasteOptions.wdMatchDestinationFormatting;
         wordApp.Options.PasteAdjustParagraphSpacing       = true;
         ActiveDocumentManager.getDefaultAD().ActiveWindow.View.ShowFieldCodes = false; //显示域代码而非域值
         ActiveDocumentManager.getDefaultAD().ActiveWindow.DisplayRulers = true;        //标尺显示
         ActiveDocumentManager.getDefaultAD().ActiveWindow.DisplayVerticalRuler = true; //标尺显示
         setAutoSave(wordApp);
         setGrammarCheck(wordApp);
     }
     catch (Exception ex)
     {
     }
 }
예제 #6
0
        public static void split3(Word.Application wordApp)
        {
            bool bInsertSplit = false;
            int  iPageCount   = getTotalPage(ActiveDocumentManager.getDefaultAD());

            if (iPageCount > 1)
            {
                bInsertSplit = true;
            }
            else if (ActiveDocumentManager.getDefaultAD().Characters.Count > 1)
            {
                bInsertSplit = true;
            }
            if (bInsertSplit)
            {
                Range rg = ActiveDocumentManager.getDefaultAD().Range();
                rg.SetRange(rg.End, rg.End);
                rg.InsertBreak(WdSectionStart.wdSectionNewPage);
                int iSectionCount = ActiveDocumentManager.getDefaultAD().Sections.Count;
                ActiveDocumentManager.getDefaultAD().Sections[iSectionCount].Headers[WdHeaderFooterIndex.wdHeaderFooterPrimary].LinkToPrevious = false;
            }
        }
예제 #7
0
        public static void split2(Word.Application wordApp)
        {
            //return;
            Word.Document myDoc      = ActiveDocumentManager.getDefaultAD();
            int           iPageCount = getTotalPage(myDoc);

            //bool bInsertSplit = false;

            Range rg = myDoc.Range();

            rg.SetRange(rg.End, rg.End);

            int iSectionCount = myDoc.Sections.Count;

            //ActiveDocumentManager.getDefaultAD().Sections[iSectionCount].Headers[WdHeaderFooterIndex.wdHeaderFooterPrimary].LinkToPrevious = false;
            //ActiveDocumentManager.getDefaultAD().Sections[iSectionCount].Headers[WdHeaderFooterIndex.wdHeaderFooterFirstPage].LinkToPrevious = false;
            rg.InsertBreak(WdSectionStart.wdSectionNewPage);

            iSectionCount = myDoc.Sections.Count;
            //ActiveDocumentManager.getDefaultAD().Sections[iSectionCount].Headers[WdHeaderFooterIndex.wdHeaderFooterPrimary].LinkToPrevious = false;
            //ActiveDocumentManager.getDefaultAD().Sections[iSectionCount].Headers[WdHeaderFooterIndex.wdHeaderFooterFirstPage].LinkToPrevious = false;

            //setPageNum(wordApp);
        }
예제 #8
0
        /// <summary>
        /// //////////////////////////////////////////////////////////////////
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void GetNewReport(DataTable dt, string Score, string Knock, string strDep)
        {
            object oMissing = System.Reflection.Missing.Value;
            object unknow   = Type.Missing;

            object start = 0;
            object end   = 0;

            Microsoft.Office.Interop.Word.Range tableLocation = ActiveDocumentManager.getDefaultAD().Range(ref start, ref end);
            // 添加页眉
            emrtaskpane.wordApp.ActiveWindow.View.Type     = Word.WdViewType.wdOutlineView;
            emrtaskpane.wordApp.ActiveWindow.View.SeekView = Word.WdSeekView.wdSeekPrimaryHeader;
            emrtaskpane.wordApp.ActiveWindow.ActivePane.Selection.InsertAfter("");
            emrtaskpane.wordApp.Selection.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphRight; //设置右对齐
            emrtaskpane.wordApp.ActiveWindow.View.SeekView          = Word.WdSeekView.wdSeekMainDocument;              //跳出页眉设置

            emrtaskpane.wordApp.Selection.ParagraphFormat.LineSpacing = 15f;                                           //设置文档的行间距

            //移动焦点并换行
            object count  = 14;
            object WdLine = Microsoft.Office.Interop.Word.WdUnits.wdLine;              //换一行;

            emrtaskpane.wordApp.Selection.MoveDown(ref WdLine, ref count, ref unknow); //移动焦点
            emrtaskpane.wordApp.Selection.MoveDown(ref WdLine, ref count, ref unknow); //移动焦点

            emrtaskpane.wordApp.Selection.TypeParagraph();                             //插入段落

            Word.Range range = ActiveDocumentManager.getDefaultAD().Paragraphs.Last.Range;
            range.Start = ActiveDocumentManager.getDefaultAD().Paragraphs.Last.Range.End;

            range.Select();
            range.Text = "扣分情况明细表";
            range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
            range.Font.Name = "黑体";
            range.Font.Size = 14.5f;
            range.Start     = range.End;
            range.Select();

            /////////Microsoft.Office.Interop.Word.Table newTable = ActiveDocumentManager.getDefaultAD().Tables.Add(emrtaskpane.wordApp.Selection.Range, dt.Rows.Count+1, 9, ref unknow, ref unknow);
            Microsoft.Office.Interop.Word.Table newTable = ActiveDocumentManager.getDefaultAD().Tables.Add(emrtaskpane.wordApp.Selection.Range, dt.Rows.Count + 1, 4, ref unknow, ref unknow);



            //设置表格样式
            newTable.Borders.OutsideLineStyle = Word.WdLineStyle.wdLineStyleSingle;
            newTable.Borders.InsideLineStyle  = Word.WdLineStyle.wdLineStyleSingle;
            emrtaskpane.wordApp.Selection.ParagraphFormat.LineSpacing = 15f;//设置文档的行间距

            newTable.Cell(1, 1).Range.Text = "记录名称";
            newTable.Cell(1, 1).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
            newTable.Cell(1, 2).Range.Text = "扣分原因";
            newTable.Cell(1, 2).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
            newTable.Cell(1, 3).Range.Text = "扣分";
            newTable.Cell(1, 3).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
            newTable.Cell(1, 4).Range.Text = "记录得分";
            newTable.Cell(1, 4).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;


            newTable.Columns[1].Width = 80f;
            newTable.Columns[2].Width = 220f;
            newTable.Columns[3].Width = 35f;
            newTable.Columns[4].Width = 70f;


            decimal dLose    = 0;
            decimal GotScotr = 0;

            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    newTable.Cell(i + 2, 1).Range.Text = dt.Rows[i]["NoteName"].ToString();
                    newTable.Cell(i + 2, 1).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                    newTable.Cell(i + 2, 2).Range.Text = dt.Rows[i]["LoseReason"].ToString();
                    newTable.Cell(i + 2, 2).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                    newTable.Cell(i + 2, 3).Range.Text = dt.Rows[i]["LoseScore"].ToString();
                    if (dt.Rows[i]["LoseScore"].ToString().Trim() != "")
                    {
                        dLose = dLose + Convert.ToDecimal(dt.Rows[i]["LoseScore"].ToString());
                    }
                    newTable.Cell(i + 2, 3).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                    newTable.Cell(i + 2, 4).Range.Text = dt.Rows[i]["Score"].ToString();
                    if (dt.Rows[i]["Score"].ToString().Trim() != "")
                    {
                        GotScotr = GotScotr + Convert.ToDecimal(dt.Rows[i]["Score"].ToString());
                    }
                    newTable.Cell(i + 2, 4).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                }
            }

            // */



            object Line1 = Microsoft.Office.Interop.Word.WdUnits.wdLine;//换一行;

            //object WdLine = Microsoft.Office.Interop.Word.WdUnits.wdLine;//换一行;
            emrtaskpane.wordApp.Selection.MoveDown(ref Line1, ref count, ref unknow); //移动焦点
            emrtaskpane.wordApp.Selection.MoveDown(ref Line1, ref count, ref unknow); //移动焦点

            emrtaskpane.wordApp.Selection.TypeParagraph();                            //插入段落



            Word.Range range1 = ActiveDocumentManager.getDefaultAD().Paragraphs.Last.Range;
            range1.Start = ActiveDocumentManager.getDefaultAD().Paragraphs.Last.Range.End;

            range1.Select();
            //range1.Text = "姓名:" + this.valuateText + this.selfValuate + this.scorePercent + "44" + this.panel1 + this.panel2 + "33" + this.lbPatient + "55" + this.lbValuate + "11" + this.count + "66" + this.components + "22" + this.btnReport + "等级:" + "得分:" + this.regID;
            string temp1, temp2, temp3, temp4;

            temp1 = this.lbPatient.ToString();
            temp2 = temp1.Substring(34);
            temp3 = this.lbValuate.ToString();
            temp4 = temp3.Substring(34);



            range1.Text = "科室:" + strDep + "  " + "患者姓名:" + temp2 + "  " + "得分:" + GotScotr.ToString() + "  " + "扣分:" + dLose.ToString() + "  " + "等级:" + temp4;

            range1.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphRight;
            range1.Font.Name = "黑体";
            range1.Font.Size = 10f;
            range1.Start     = range.End;



            //Globals.ThisAddIn.HideEmrTaskPane();
            //Globals.ThisAddIn.ShowNoteMenu();
            //Globals.ThisAddIn.noteMenu.OperationEnableForStat(true);
        }
예제 #9
0
        //public bool AsTemplate(string doctorID, string departmentCode, int Flag)
        //{
        //    if (Globals.offline)
        //    {
        //        MessageBox.Show(ErrorMessage.NoNewTemplate, ErrorMessage.Warning);
        //        return Return.Failed;
        //    }
        //    string templateType = StringGeneral.PersonTemplate;
        //    string fullPath = null;

        //    #region Create a xml doc.
        //    XmlDocument doc = new XmlDocument();
        //    /* Load xml doc with local note template. */
        //    if (doctorID == EmrConstant.StringGeneral.NullCode)
        //    {
        //        /* As a department template */
        //        templateType = StringGeneral.DepartTemplate;
        //        fullPath = emrTaskPane.NoteTemplate.MakeDepartNoteTemplateCategory();
        //        if (File.Exists(fullPath)) doc.Load(fullPath);
        //        else doc.LoadXml("<NoteTemplates DepartmentCode=\"" + departmentCode + "\" />");
        //    }
        //    if (doctorID == EmrConstant.StringGeneral.AllCode)
        //    {
        //        /* As a hospital department template */
        //        templateType = StringGeneral.HospitalTemplate;
        //        fullPath = emrTaskPane.NoteTemplate.MakeHospitalNoteTemplateCategory();
        //        if (File.Exists(fullPath)) doc.Load(fullPath);
        //        else doc.LoadXml("<NoteTemplates HospitalCode=\"" + StringGeneral.AllCode + "\" />");
        //    }
        //    if (doctorID != EmrConstant.StringGeneral.NullCode && doctorID != EmrConstant.StringGeneral.AllCode)
        //    {
        //        /* As a person template */
        //        templateType = StringGeneral.PersonTemplate;
        //        fullPath = emrTaskPane.NoteTemplate.MakePersonNoteTemplateCategory(doctorID);
        //        if (File.Exists(fullPath)) doc.Load(fullPath);
        //        else doc.LoadXml("<NoteTemplates DoctorID=\"" + doctorID + "\" />");
        //    }
        //    #endregion

        //    #region Get tempmate name from the operator
        //    ArrayList names = new ArrayList();
        //    emrTaskPane.NoteTemplate.LoadTemplateNames(names, templateType);
        //    string NodeID1 = ThisAddIn.GetNoteIDFromWordWindow();
        //    string defaultName =
        //        Globals.emrPattern.GetNoteNameFromNoteID(NodeID1);

        //    SaveTemplate tempName = new SaveTemplate(names, defaultName, Flag);
        //    tempName.StartPosition = FormStartPosition.CenterScreen;
        //    if (tempName.ShowDialog() == DialogResult.Cancel) return false;

        //    string templateName = tempName.Get();
        //    string Creator = Globals.DoctorID;
        //    string CreateDate = DateTime.Now.ToString();
        //    string IllType = tempName.GetIllType();
        //    string IllName = tempName.GetIllName();
        //    string Type = tempName.GetTypes();
        //    string TypeName = tempName.GetTypeName();
        //    string Sex = tempName.GetSex();
        //    string NoteName = Globals.emrPattern.GetNoteNameFromNoteID(NodeID1);
        //    string TemplateName = tempName.GetTemplateName();

        //    if (noteInfo.GetEditMode() == NoteEditMode.Reading)
        //    {
        //        ThisAddIn.SetReadWrite();
        //        noteInfo.SetEditMode(NoteEditMode.Writing);
        //    }
        //    #endregion
        //    #region Create attributs for the new template
        //    XmlElement noteTemplate = doc.CreateElement(EmrConstant.ElementNames.NoteTemplate);
        //    noteTemplate.SetAttribute(AttributeNames.Name, templateName);
        //    noteTemplate.SetAttribute(AttributeNames.NoteID, NodeID1);
        //    noteTemplate.SetAttribute(AttributeNames.NoteName, NoteName);
        //    noteTemplate.SetAttribute(AttributeNames.Header, noteInfo.GetNoteHeaderType());
        //    noteTemplate.SetAttribute(AttributeNames.Unique, noteInfo.GetNoteUniqueFlag());
        //    if (author.finalCheckerLable != string.Empty)
        //        noteTemplate.SetAttribute(AttributeNames.Sign1, author.finalCheckerLable);
        //    if (author.checkerLable != string.Empty)
        //        noteTemplate.SetAttribute(AttributeNames.Sign2, author.checkerLable);
        //    noteTemplate.SetAttribute(AttributeNames.Sign3, author.writerLable);
        //    noteTemplate.SetAttribute(AttributeNames.Merge, merge);

        //    /// Special note treatment
        //    noteTemplate.SetAttribute(AttributeNames.StartTime, startTime);

        //    if (noteInfo.sexOption)
        //        noteTemplate.SetAttribute(AttributeNames.Sex, emrTaskPane.GetPatientSex());
        //    else
        //        noteTemplate.SetAttribute(AttributeNames.Sex, StringGeneral.Both);

        //    noteTemplate.SetAttribute(AttributeNames.IllName, IllName);
        //    noteTemplate.SetAttribute(AttributeNames.IllType, IllType);
        //    noteTemplate.SetAttribute(AttributeNames.Type, Type);
        //    noteTemplate.SetAttribute(AttributeNames.TypeName, TypeName);
        //    if (noteInfo.GetNoteHeaderType() == StringGeneral.None)
        //    {
        //        XmlNode notePattern = Globals.emrPattern.GetEmrNote(noteInfo.GetNoteID());
        //        if (notePattern != null)
        //        {
        //            XmlElement header = doc.CreateElement(ElementNames.Header);
        //            foreach (XmlNode subtitle in notePattern.SelectNodes(ElementNames.SubTitle))
        //            {
        //                if (subtitle.Attributes[AttributeNames.Value] == null) continue;

        //                XmlElement newSubtitle = doc.CreateElement(ElementNames.SubTitle);
        //                foreach (XmlAttribute att in subtitle.Attributes)
        //                {
        //                    newSubtitle.SetAttribute(att.Name, att.Value);
        //                }
        //                newSubtitle.InnerXml = subtitle.InnerXml;
        //                header.AppendChild(newSubtitle);
        //            }
        //            noteTemplate.AppendChild(header);
        //        }
        //    }
        //    #endregion
        //    #region Save the new template into dadabase and add new template to the template tree.
        //    if (emrTaskPane.NoteTemplate.AddNewTemplate(emrTaskPane, templateType, noteTemplate, IllType, IllName, Creator, CreateDate, Sex, Type, TypeName, NodeID1, NoteName, templateName) < 0) return Return.Failed;
        //    #endregion

        //    ActiveDocumentManager.getDefaultAD().Saved = true;
        //    emrTaskPane.TemplateOperationEnable(true);
        //    return Return.Successful;
        //}

        public bool AsTemplateOld(string doctorID, string departmentCode)
        {
            if (Globals.offline)
            {
                MessageBox.Show(ErrorMessage.NoNewTemplate, ErrorMessage.Warning);
                return(Return.Failed);
            }
            string templateType = StringGeneral.PersonTemplate;
            string fullPath     = null;

            #region Create a xml doc.
            XmlDocument doc = new XmlDocument();
            /* Load xml doc with local note template. */
            if (doctorID == EmrConstant.StringGeneral.NullCode)
            {
                /* As a department template */
                templateType = StringGeneral.DepartTemplate;
                fullPath     = emrTaskPane.NoteTemplate.MakeDepartNoteTemplateCategory();
                if (File.Exists(fullPath))
                {
                    doc.Load(fullPath);
                }
                else
                {
                    doc.LoadXml("<NoteTemplates DepartmentCode=\"" + departmentCode + "\" />");
                }
            }
            if (doctorID == EmrConstant.StringGeneral.AllCode)
            {
                /* As a hospital department template */
                templateType = StringGeneral.HospitalTemplate;
                fullPath     = emrTaskPane.NoteTemplate.MakeHospitalNoteTemplateCategory();
                if (File.Exists(fullPath))
                {
                    doc.Load(fullPath);
                }
                else
                {
                    doc.LoadXml("<NoteTemplates HospitalCode=\"" + StringGeneral.AllCode + "\" />");
                }
            }
            if (doctorID != EmrConstant.StringGeneral.NullCode && doctorID != EmrConstant.StringGeneral.AllCode)
            {
                /* As a person template */
                templateType = StringGeneral.PersonTemplate;
                fullPath     = emrTaskPane.NoteTemplate.MakePersonNoteTemplateCategory(doctorID);
                if (File.Exists(fullPath))
                {
                    doc.Load(fullPath);
                }
                else
                {
                    doc.LoadXml("<NoteTemplates DoctorID=\"" + doctorID + "\" />");
                }
            }
            #endregion

            #region Get tempmate name from the operator
            ArrayList names = new ArrayList();
            emrTaskPane.NoteTemplate.LoadTemplateNames(names, templateType);
            string childID = "";
            string NodeID1 = emrTaskPane.GetNoteIDFromWordWindow(ref childID);
            if (NodeID1 == childID || childID == "")
            {
                childID = "0";
            }
            string NoteName    = Globals.emrPattern.GetNoteNameFromNoteID(NodeID1);
            string defaultName = "";
            if (NodeID1 == "0")
            {
                defaultName = NoteName;
            }
            else
            {
                defaultName = Globals.childPattern.GetNoteNameFromNoteID(childID);
                if (defaultName == "" || defaultName == null)
                {
                    defaultName = NoteName;
                }
            }
            TemplateName tempName = new TemplateName(names, defaultName);
            tempName.StartPosition = FormStartPosition.CenterScreen;
            if (tempName.ShowDialog() == DialogResult.Cancel)
            {
                return(false);
            }

            string templateName = tempName.Get();
            //templateName += " *";
            if (noteInfo.GetEditMode() == NoteEditMode.Reading)
            {
                emrTaskPane.SetReadWrite();
                noteInfo.SetEditMode(NoteEditMode.Writing);
            }

            /* Remove revisions. */
            //  ActiveDocumentManager.getDefaultAD().AcceptAllRevisions();
            #endregion

            #region Create attributs for the new template
            XmlElement noteTemplate = doc.CreateElement(EmrConstant.ElementNames.NoteTemplate);
            noteTemplate.SetAttribute(AttributeNames.Name, templateName);
            noteTemplate.SetAttribute(AttributeNames.NoteID, NodeID1);
            noteTemplate.SetAttribute(AttributeNames.NoteName, NoteName);
            noteTemplate.SetAttribute(AttributeNames.Header, noteInfo.GetNoteHeaderType());
            noteTemplate.SetAttribute(AttributeNames.Unique, noteInfo.GetNoteUniqueFlag());
            noteTemplate.SetAttribute(AttributeNames.ChildID, childID);

            if (author.finalCheckerLable != string.Empty)
            {
                noteTemplate.SetAttribute(AttributeNames.Sign1, author.finalCheckerLable);
            }
            if (author.checkerLable != string.Empty)
            {
                noteTemplate.SetAttribute(AttributeNames.Sign2, author.checkerLable);
            }
            noteTemplate.SetAttribute(AttributeNames.Sign3, author.writerLable);
            noteTemplate.SetAttribute(AttributeNames.Merge, merge);

            /// Special note treatment
            noteTemplate.SetAttribute(AttributeNames.StartTime, startTime);

            if (noteInfo.sexOption)
            {
                noteTemplate.SetAttribute(AttributeNames.Sex, emrTaskPane.GetPatientSex());
            }
            else
            {
                noteTemplate.SetAttribute(AttributeNames.Sex, StringGeneral.Both);
            }

            if (noteInfo.GetNoteHeaderType() == StringGeneral.None)
            {
                XmlNode notePattern = Globals.emrPattern.GetEmrNote(noteInfo.GetNoteID());
                if (notePattern != null)
                {
                    XmlElement header = doc.CreateElement(ElementNames.Header);
                    foreach (XmlNode subtitle in notePattern.SelectNodes(ElementNames.SubTitle))
                    {
                        if (subtitle.Attributes[AttributeNames.Value] == null)
                        {
                            continue;
                        }

                        XmlElement newSubtitle = doc.CreateElement(ElementNames.SubTitle);
                        foreach (XmlAttribute att in subtitle.Attributes)
                        {
                            newSubtitle.SetAttribute(att.Name, att.Value);
                        }
                        newSubtitle.InnerXml = subtitle.InnerXml;
                        header.AppendChild(newSubtitle);
                    }
                    noteTemplate.AppendChild(header);
                }
            }
            #endregion
            #region Save the new template into dadabase and add new template to the template tree.
            if (emrTaskPane.NoteTemplate.AddNewTemplateOld(emrTaskPane, templateType, noteTemplate) < 0)
            {
                return(Return.Failed);
            }
            #endregion

            ActiveDocumentManager.getDefaultAD().Saved = true;
            //emrTaskPane.TemplateOperationEnable(true);
            return(Return.Successful);
        }
예제 #10
0
파일: ucAuthor.cs 프로젝트: zhanglg40/hmr
        //public void BecomeNormalNoteOld()
        //{
        //    AuthorInfo authorInfo;
        //    authorInfo.Writer = Globals.DoctorName;
        //    authorInfo.WrittenDate = ThisAddIn.Today().ToString(StringGeneral.DateFormat);
        //    authorInfo.Checker = "";
        //    authorInfo.ChildID = string.Empty;
        //    authorInfo.CheckedDate = "";
        //    authorInfo.FinalChecker = "";
        //    authorInfo.FinalCheckedDate = "";
        //    authorInfo.TemplateType = StringGeneral.NoneTemplate;
        //    authorInfo.TemplateName = "";
        //    authorInfo.NoteID = "";
        //    authorInfo.NoteName = "";
        //    authorInfo.WriterLable = emrTaskPane.currentNote.author.writerLable;
        //    authorInfo.CheckerLable = emrTaskPane.currentNote.author.checkerLable;
        //    authorInfo.FinalCheckerLable = emrTaskPane.currentNote.author.finalCheckerLable;

        //    DrawAuthor(authorInfo);

        //}

        public void DrawAuthor1(AuthorInfo authorInfo)
        {
            Word.WdColor fontColor = Globals.headerFontColor;
            float        fontSize  = Globals.headerFontSize;

            Word.Range range  = ActiveDocumentManager.getDefaultAD().Paragraphs.Last.Range;
            string     writer = writerLable + authorInfo.Writer;

            if (writerLable == "ЛМепЃК")
            {
                writer = " ";
            }
            range.Start    = ActiveDocumentManager.getDefaultAD().Paragraphs.Last.Range.End;
            ccWriter       = emrTaskPane.AddContentControlText(range, writer, null, true, fontSize, fontColor);
            ccWriter.Title = StringGeneral.Label;      // as end of emrNote content
            ccWriter.Tag   = StringGeneral.RemoveFlag; // as a note template, it will be removed

            if (writer.Length > 1)
            {
                range.Start   = ccWriter.Range.End + 1;
                ccWrittenDate = emrTaskPane.AddContentControlText(range, " " + authorInfo.WrittenDate, null,
                                                                  true, fontSize, fontColor);
                ccWrittenDate.Tag   = StringGeneral.RemoveFlag;
                ccWrittenDate.Title = AttributeNames.WrittenDate;
            }

            string checker = checkerLable + authorInfo.Checker;

            if (checker.Length > 0)
            {
                range.Start = ccWrittenDate.Range.End + 1;
                ccChecker   = emrTaskPane.AddContentControlText(range, Globals.space6 + checker, null,
                                                                true, fontSize, fontColor);
                ccChecker.Tag   = StringGeneral.RemoveFlag;    // as a note template, it will be removed
                ccChecker.Title = AttributeNames.Checker;
                range.Start     = ccChecker.Range.End + 1;
                ccCheckedDate   = emrTaskPane.AddContentControlText(range, " " + authorInfo.CheckedDate, null,
                                                                    true, fontSize, fontColor);
                ccCheckedDate.Tag   = StringGeneral.RemoveFlag;    // as a note template, it will be removed
                ccCheckedDate.Title = AttributeNames.CheckedDate;
            }
            string finalChecker = finalCheckerLable + authorInfo.FinalChecker;

            if (finalChecker.Length > 0)
            {
                if (ccChecker == null)
                {
                    range.Start = ccWriter.Range.End + 1;
                }
                else
                {
                    range.Start = ccChecker.Range.End + 1;
                }

                ccFinalChecker = emrTaskPane.AddContentControlText(range, Globals.space6 +
                                                                   finalChecker, null, true, fontSize, fontColor);
                ccFinalChecker.Tag   = StringGeneral.RemoveFlag;    // as a note template, it will be removed
                ccFinalChecker.Title = AttributeNames.FinalChecker;
                range.Start          = ccFinalChecker.Range.End + 1;
                ccFinalCheckedDate   = emrTaskPane.AddContentControlText(range, " " + authorInfo.FinalCheckedDate,
                                                                         null, true, fontSize, fontColor);
                ccFinalCheckedDate.Tag   = StringGeneral.RemoveFlag;    // as a note template, it will be removed
                ccFinalCheckedDate.Title = AttributeNames.FinalCheckedDate;
            }
        }
예제 #11
0
파일: ucAuthor.cs 프로젝트: zhanglg40/hmr
        public void DrawAuthor2(AuthorInfo authorInfo)
        {
            Word.WdColor fontColor = Globals.headerFontColor;
            float        fontSize  = Globals.headerFontSize;
            int          len       = 0;

            #region Writter
            Word.Range range  = ActiveDocumentManager.getDefaultAD().Paragraphs.Last.Range;
            string     writer = writerLable + authorInfo.Writer;
            if (writerLable == string.Empty)
            {
                writer = writerLable;
            }

            range.Start = ActiveDocumentManager.getDefaultAD().Paragraphs.Last.Range.End;
            Word.ContentControl ccNull = emrTaskPane.AddSubTitle(range, " ", Word.WdColor.wdColorWhite);
            ccNull.Title        = StringGeneral.Label; // as end of emrNote content
            ccNull.Tag          = StringGeneral.RemoveFlag;
            ccNull.LockContents = false;

            if (writer.Length > 1)
            {
                if (ThisAddIn.CanOption(ElementNames.ManualSign))
                {
                    writer = writer + StringGeneral.SignSpace;
                }

                if (!ThisAddIn.CanOption(ElementNames.ShowWriter))
                {
                    writer = " ";
                }

                if (!ThisAddIn.CanOption(ElementNames.AutoSign))
                {
                    writer = writerLable + StringGeneral.SignSpace;
                }

                range.Start = ccNull.Range.End + 1;
                ccWriter    = emrTaskPane.AddContentControlTextRight(range, Globals.space6 + writer,
                                                                     null, false, fontSize, fontColor);
                ccWriter.Tag        = StringGeneral.RemoveFlag; // as a note template, it will be removed
                ccWriter.Title      = AttributeNames.Writer;
                ccWriter.Range.Font = Globals.contentFont;


                range.Start = ccWriter.Range.End + 1;
                //if (Globals.EncryptSign == true)
                //{
                //    ccWriter.Range.Text = ccWriter.Range.Text.Trim();
                //    emrTaskPane.ThisAddIn.CanOption(ElementNames.ShowWriter)Sign(range, fontSize, fontColor, "WSign");
                //}
                ccWriter.LockContentControl = true;
                ccWriter.LockContents       = true;

                string writtenDate = " ";
                if (ThisAddIn.CanOption(ElementNames.ShowWritenDate))
                {
                    writtenDate += authorInfo.WrittenDate;
                }
                ccWrittenDate = emrTaskPane.AddContentControlTextRight(range, writtenDate, null,
                                                                       false, fontSize, fontColor);
                ccWrittenDate.Tag                = StringGeneral.RemoveFlag;
                ccWrittenDate.Title              = AttributeNames.WrittenDate;
                ccWrittenDate.Range.Font         = Globals.contentFont;
                ccWrittenDate.LockContentControl = true;
                ccWrittenDate.LockContents       = true;

                len += ccWriter.Range.Text.Length + ccWrittenDate.Range.Text.Length;
            }
            #endregion
            #region Checker
            string checker = checkerLable + authorInfo.Checker;
            if (checkerLable == string.Empty)
            {
                checker = checkerLable;
            }
            if (checker.Length > 0)
            {
                if (ThisAddIn.CanOption(ElementNames.ManualSign))
                {
                    checker = checker + StringGeneral.SignSpace;
                }
                if (!ThisAddIn.CanOption(ElementNames.ShowWriter))
                {
                    checker = " ";
                }
                if (!ThisAddIn.CanOption(ElementNames.AutoSign))
                {
                    checker = checkerLable + StringGeneral.SignSpace;
                }

                range.Start = ccWriter.Range.Start - 1;
                range.End   = range.Start;
                ccChecker   = emrTaskPane.AddContentControlTextRight(range, Globals.space6 + checker, null,
                                                                     false, fontSize, fontColor);
                ccChecker.Tag                = StringGeneral.RemoveFlag; // as a note template, it will be removed
                ccChecker.Title              = AttributeNames.Checker;
                ccChecker.Range.Font         = Globals.contentFont;
                ccChecker.LockContentControl = true;
                ccChecker.LockContents       = true;

                range.Start = ccChecker.Range.End + 1;
                string checkedDate = " ";
                if (ThisAddIn.CanOption(ElementNames.ShowWritenDate))
                {
                    checkedDate += authorInfo.CheckedDate;
                }
                ccCheckedDate = emrTaskPane.AddContentControlTextRight(range, checkedDate, null,
                                                                       false, fontSize, fontColor);
                ccCheckedDate.Tag                = StringGeneral.RemoveFlag; // as a note template, it will be removed
                ccCheckedDate.Title              = AttributeNames.CheckedDate;
                ccCheckedDate.Range.Font         = Globals.contentFont;
                ccCheckedDate.LockContentControl = true;
                ccCheckedDate.LockContents       = true;

                len += ccChecker.Range.Text.Length + ccCheckedDate.Range.Text.Length;
            }

            #endregion
            #region FinalChecker
            string finalChecker = finalCheckerLable + authorInfo.FinalChecker;
            if (finalCheckerLable == string.Empty)
            {
                finalChecker = finalCheckerLable;
            }
            if (finalChecker.Length > 0)
            {
                if (ThisAddIn.CanOption(ElementNames.ManualSign))
                {
                    finalChecker = finalChecker + StringGeneral.SignSpace;
                }

                if (!ThisAddIn.CanOption(ElementNames.ShowWriter))
                {
                    finalChecker = " ";
                }

                if (!ThisAddIn.CanOption(ElementNames.AutoSign))
                {
                    finalChecker = finalCheckerLable + StringGeneral.SignSpace;
                }


                if (ccChecker == null)
                {
                    range.Start = ccWriter.Range.Start - 1;
                }
                else
                {
                    range.Start = ccChecker.Range.Start - 1;
                }
                range.End      = range.Start;
                ccFinalChecker = emrTaskPane.AddContentControlTextRight(range, finalChecker,
                                                                        null, false, fontSize, fontColor);
                ccFinalChecker.Tag                = StringGeneral.RemoveFlag; // as a note template, it will be removed
                ccFinalChecker.Title              = AttributeNames.FinalChecker;
                ccFinalChecker.Range.Font         = Globals.contentFont;
                ccFinalChecker.LockContentControl = true;
                ccFinalChecker.LockContents       = true;

                range.Start = ccFinalChecker.Range.End + 1;
                string finalCheckedDate = " ";
                if (ThisAddIn.CanOption(ElementNames.ShowWritenDate))
                {
                    finalCheckedDate += authorInfo.FinalCheckedDate;
                }
                ccFinalCheckedDate = emrTaskPane.AddContentControlTextRight(range, finalCheckedDate,
                                                                            null, false, fontSize, fontColor);
                ccFinalCheckedDate.Tag                = StringGeneral.RemoveFlag; // as a note template, it will be removed
                ccFinalCheckedDate.Title              = AttributeNames.FinalCheckedDate;
                ccFinalCheckedDate.Range.Font         = Globals.contentFont;
                ccFinalCheckedDate.LockContentControl = true;
                ccFinalCheckedDate.LockContents       = true;

                len += ccFinalChecker.Range.Text.Length + ccFinalCheckedDate.Range.Text.Length;
            }

            #endregion
            /////guojt test sourcesafe
            //int padSpace = Globals.countPerLine - len;
            //if (Globals.auditSystem == AuditSystem.A1)
            //{

            //    for (int i = 0; i < padSpace; i++) ccNull.Range.Text += "  ";
            //}
        }
예제 #12
0
파일: EmrNote1.cs 프로젝트: zhanglg40/hmr
        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);
        }
예제 #13
0
        public void GetNewReport(DataTable dt)
        {
            object oMissing = System.Reflection.Missing.Value;
            object unknow   = Type.Missing;
            object start    = 0;
            object end      = 0;

            Microsoft.Office.Interop.Word.Range tableLocation = ActiveDocumentManager.getDefaultAD().Range(ref start, ref end);
            // 添加页眉
            emrTaskPane.wordApp.ActiveWindow.View.Type     = Word.WdViewType.wdOutlineView;
            emrTaskPane.wordApp.ActiveWindow.View.SeekView = Word.WdSeekView.wdSeekPrimaryHeader;
            emrTaskPane.wordApp.ActiveWindow.ActivePane.Selection.InsertAfter("");
            emrTaskPane.wordApp.Selection.ParagraphFormat.Alignment   = Word.WdParagraphAlignment.wdAlignParagraphRight; //设置右对齐
            emrTaskPane.wordApp.ActiveWindow.View.SeekView            = Word.WdSeekView.wdSeekMainDocument;              //跳出页眉设置
            emrTaskPane.wordApp.Selection.ParagraphFormat.LineSpacing = 15f;                                             //设置文档的行间距

            //2012-07-29 LiuQi 删除页眉
            int c = ActiveDocumentManager.getDefaultAD().Paragraphs[1].Borders.Count;

            emrTaskPane.wordApp.ActiveWindow.View.SeekView = Microsoft.Office.Interop.Word.WdSeekView.wdSeekCurrentPageHeader;
            Microsoft.Office.Interop.Word.Application WordApp;
            Microsoft.Office.Interop.Word.Document    WordDoc;
            WordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
            if (c != 0)
            {
                Word.HeaderFooter hf = ActiveDocumentManager.getDefaultAD().Sections[1].Headers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary];
                Word.Range        r  = hf.Range;
                //r.Start = r.End;
                r.Select();
                Word.Border border = r.Borders[Word.WdBorderType.wdBorderBottom];
                border.Visible = false;
            }
            //移动焦点并换行
            object count  = 14;
            object WdLine = Microsoft.Office.Interop.Word.WdUnits.wdLine;              //换一行;

            emrTaskPane.wordApp.Selection.MoveDown(ref WdLine, ref count, ref unknow); //移动焦点
            emrTaskPane.wordApp.Selection.MoveDown(ref WdLine, ref count, ref unknow); //移动焦点
            emrTaskPane.wordApp.Selection.TypeParagraph();                             //插入段落
            Word.Range range = ActiveDocumentManager.getDefaultAD().Paragraphs.Last.Range;
            range.Start = ActiveDocumentManager.getDefaultAD().Paragraphs.Last.Range.End;

            range.Select();
            //// range.Text = "病历质量月度评分表" + "(" + comboBox2.Text + "年" + comboBox1.Text + "月)";
            if (hz)
            {
                range.Text = "各科室现岗病历质检情况一览表";
            }
            else
            {
                range.Text = "现岗病历质量评分科室汇总表";
            }
            range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
            range.Font.Name = "黑体";
            range.Font.Size = 15.5f;
            range.Start     = range.End;
            range.Select();


            range.Text = dateTimePickerStart.Value.ToString() + "至" + dateTimePickerEnd.Value.ToString();
            range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
            range.Font.Name = "黑体";
            range.Font.Size = 10f;
            range.Start     = range.End;
            range.Select();

            ActiveDocumentManager.getDefaultAD().PageSetup.Orientation = Word.WdOrientation.wdOrientPortrait;
            ActiveDocumentManager.getDefaultAD().PageSetup.PageWidth = emrTaskPane.wordApp.CentimetersToPoints(29.7F);
            ActiveDocumentManager.getDefaultAD().PageSetup.PageHeight = emrTaskPane.wordApp.CentimetersToPoints(21F);
            int rows = 0;

            if (ks || qy)
            {
                rows = 9;
            }
            else
            {
                rows = 8;
            }
            Microsoft.Office.Interop.Word.Table newTable = ActiveDocumentManager.getDefaultAD().Tables.Add(emrTaskPane.wordApp.Selection.Range, dt.Rows.Count + 1, rows, ref unknow, ref unknow);
            //设置表格样式
            newTable.Range.Font.Size          = 11.0f;
            newTable.Borders.OutsideLineStyle = Word.WdLineStyle.wdLineStyleSingle;
            newTable.Borders.InsideLineStyle  = Word.WdLineStyle.wdLineStyleSingle;
            emrTaskPane.wordApp.Selection.ParagraphFormat.LineSpacing = 15f;//设置文档的行间距
            if (ks || qy)
            {
                newTable.Cell(1, 1).Range.Text = "科室";
                newTable.Cell(1, 1).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                newTable.Cell(1, 2).Range.Text = "主治医师";
                newTable.Cell(1, 2).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;

                newTable.Cell(1, 3).Range.Text = "病案号";
                newTable.Cell(1, 3).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                newTable.Cell(1, 4).Range.Text = "住院日期";
                newTable.Cell(1, 4).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;

                newTable.Cell(1, 5).Range.Text = "住院号";
                newTable.Cell(1, 5).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                newTable.Cell(1, 6).Range.Text = "扣分项目";
                newTable.Cell(1, 6).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                newTable.Cell(1, 7).Range.Text = "扣分原因";
                newTable.Cell(1, 7).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                newTable.Cell(1, 8).Range.Text = "总得分";
                newTable.Cell(1, 8).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                newTable.Cell(1, 9).Range.Text = "等级";
                newTable.Cell(1, 9).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;

                newTable.Columns[1].Width = 60f;
                newTable.Columns[2].Width = 60f;
                newTable.Columns[3].Width = 70f;//能显示三个字
                newTable.Columns[4].Width = 65f;
                newTable.Columns[5].Width = 60f;
                newTable.Columns[6].Width = 70f;
                newTable.Columns[7].Width = 220f;
                newTable.Columns[8].Width = 50f;
                newTable.Columns[9].Width = 40f;

                //if (dt.Rows.Count > 0)
                //{

                //    try
                //    {
                //        for (int i = 0; i < dt.Rows.Count; i++)
                //        {

                //            newTable.Cell(i + 2, 4).Range.Text = dt.Rows[i]["zyrq"].ToString();
                //            newTable.Cell(i + 2, 4).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                //            newTable.Cell(i + 2, 1).Range.Text = dt.Rows[i]["ksmc"].ToString();
                //            newTable.Cell(i + 2, 1).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                //            newTable.Cell(i + 2, 2).Range.Text = dt.Rows[i]["ysm"].ToString();
                //            newTable.Cell(i + 2, 2).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                //            newTable.Cell(i + 2, 3).Range.Text = dt.Rows[i]["bah"].ToString();
                //            newTable.Cell(i + 2, 3).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                //            newTable.Cell(i + 2, 5).Range.Text = dt.Rows[i]["zyh"].ToString();
                //            newTable.Cell(i + 2, 5).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;


                //            newTable.Cell(i + 2, 6).Range.Text = dt.Rows[i]["kfxm"].ToString();
                //            newTable.Cell(i + 2, 6).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
                //            newTable.Cell(i + 2, 7).Range.Text = dt.Rows[i]["kfyy"].ToString();
                //            newTable.Cell(i + 2, 7).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                //            newTable.Cell(i + 2, 8).Range.Text = dt.Rows[i]["sdf"].ToString();
                //            newTable.Cell(i + 2, 8).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                //            newTable.Cell(i + 2, 9).Range.Text = dt.Rows[i]["pj"].ToString();
                //            newTable.Cell(i + 2, 9).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;

                //        }

                //        verticalCellMerge(newTable, 2, 1);
                //        verticalCellMerge(newTable, 2, 2);
                //        verticalCellMerge(newTable, 2, 3);
                //        verticalCellMerge(newTable, 2, 4);
                //        verticalCellMerge(newTable, 2, 8);
                //        verticalCellMerge(newTable, 2, 9);
                //        verticalCellMerge(newTable, 2, 5);
                //        // verticalCellMerge(newTable,2,5);
                //    }
                //    catch (Exception ex)
                //    {

                //        MessageBox.Show(ex.ToString());
                //    }
                //}
                if (dt.Rows.Count > 0)
                {
                    try
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            newTable.Cell(i + 2, 4).Range.Text = dt.Rows[i]["住院日期"].ToString();
                            newTable.Cell(i + 2, 4).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                            newTable.Cell(i + 2, 1).Range.Text = dt.Rows[i]["科室"].ToString();
                            newTable.Cell(i + 2, 1).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                            newTable.Cell(i + 2, 2).Range.Text = dt.Rows[i]["质检医师"].ToString();
                            newTable.Cell(i + 2, 2).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                            newTable.Cell(i + 2, 3).Range.Text = dt.Rows[i]["病案号"].ToString();
                            newTable.Cell(i + 2, 3).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                            newTable.Cell(i + 2, 5).Range.Text = dt.Rows[i]["住院号"].ToString();
                            newTable.Cell(i + 2, 5).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;


                            newTable.Cell(i + 2, 6).Range.Text = dt.Rows[i]["扣分项目"].ToString();
                            newTable.Cell(i + 2, 6).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
                            newTable.Cell(i + 2, 7).Range.Text = dt.Rows[i]["扣分原因"].ToString();
                            newTable.Cell(i + 2, 7).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                            newTable.Cell(i + 2, 8).Range.Text = dt.Rows[i]["总得分"].ToString();
                            newTable.Cell(i + 2, 8).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                            newTable.Cell(i + 2, 9).Range.Text = dt.Rows[i]["评审结果"].ToString();
                            newTable.Cell(i + 2, 9).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                        }

                        verticalCellMerge(newTable, 2, 1);
                        verticalCellMerge(newTable, 2, 2);
                        verticalCellMerge(newTable, 2, 3);
                        verticalCellMerge(newTable, 2, 4);
                        verticalCellMerge(newTable, 2, 8);
                        verticalCellMerge(newTable, 2, 9);
                        verticalCellMerge(newTable, 2, 5);
                        // verticalCellMerge(newTable,2,5);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                }
            }
            else
            {
                newTable.Cell(1, 1).Range.Text = "科室";
                newTable.Cell(1, 1).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                newTable.Cell(1, 2).Range.Text = "病历质检数";
                newTable.Cell(1, 2).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                newTable.Cell(1, 3).Range.Text = "甲级";
                newTable.Cell(1, 3).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                newTable.Cell(1, 4).Range.Text = "甲级病历率";
                newTable.Cell(1, 4).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                newTable.Cell(1, 5).Range.Text = "乙级";
                newTable.Cell(1, 5).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                newTable.Cell(1, 6).Range.Text = "乙级病历率";
                newTable.Cell(1, 6).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                newTable.Cell(1, 7).Range.Text = "丙级";
                newTable.Cell(1, 7).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                newTable.Cell(1, 8).Range.Text = "丙级病历率";
                newTable.Cell(1, 8).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;

                newTable.Columns[1].Width = 70f;
                newTable.Columns[2].Width = 70f;
                newTable.Columns[3].Width = 70f;//能显示三个字
                newTable.Columns[4].Width = 70f;
                newTable.Columns[5].Width = 70f;
                newTable.Columns[6].Width = 70f;

                if (dt.Rows.Count > 0)
                {
                    int k = 2;
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        decimal bl    = Convert.ToDecimal(dt.Rows[i]["病历率"].ToString());
                        string  strbl = (Convert.ToDecimal(bl.ToString("0.00")) * 100).ToString() + "%";

                        if (i > 0)
                        {
                            if (dt.Rows[i]["科室"].ToString() == dt.Rows[i - 1]["科室"].ToString())
                            {
                                newTable.Cell(k, 1).Range.Text = dt.Rows[i]["科室"].ToString();
                                newTable.Cell(k, 1).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                                newTable.Cell(k, 2).Range.Text = dt.Rows[i]["科室质检数"].ToString();
                                newTable.Cell(k, 2).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;

                                if (dt.Rows[i]["评级"].ToString() == "甲")
                                {
                                    newTable.Cell(k, 3).Range.Text = dt.Rows[i]["病历数"].ToString();
                                    newTable.Cell(k, 3).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                                    newTable.Cell(k, 4).Range.Text = strbl;
                                    newTable.Cell(k, 4).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                                }
                                else if (dt.Rows[i]["评级"].ToString() == "乙")
                                {
                                    newTable.Cell(k, 5).Range.Text = dt.Rows[i]["病历数"].ToString();
                                    newTable.Cell(k, 5).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                                    newTable.Cell(k, 6).Range.Text = strbl;
                                    newTable.Cell(k, 6).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                                }
                                else if (dt.Rows[i]["评级"].ToString() == "丙")
                                {
                                    newTable.Cell(k, 7).Range.Text = dt.Rows[i]["病历数"].ToString();
                                    newTable.Cell(k, 7).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                                    newTable.Cell(k, 8).Range.Text = strbl;
                                    newTable.Cell(k, 8).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                                }
                            }
                            else
                            {
                                k++;
                                newTable.Cell(k, 1).Range.Text = dt.Rows[i]["科室"].ToString();
                                newTable.Cell(k, 1).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                                newTable.Cell(k, 2).Range.Text = dt.Rows[i]["科室质检数"].ToString();;
                                newTable.Cell(k, 2).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;

                                if (dt.Rows[i]["评级"].ToString() == "甲")
                                {
                                    newTable.Cell(k, 3).Range.Text = dt.Rows[i]["病历数"].ToString();
                                    newTable.Cell(k, 3).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                                    newTable.Cell(k, 4).Range.Text = strbl;
                                    newTable.Cell(k, 4).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                                }
                                else if (dt.Rows[i]["评级"].ToString() == "乙")
                                {
                                    newTable.Cell(k, 5).Range.Text = dt.Rows[i]["病历数"].ToString();
                                    newTable.Cell(k, 5).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                                    newTable.Cell(k, 6).Range.Text = strbl;
                                    newTable.Cell(k, 6).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                                }
                                else if (dt.Rows[i]["评级"].ToString() == "丙")
                                {
                                    newTable.Cell(k, 7).Range.Text = dt.Rows[i]["病历数"].ToString();
                                    newTable.Cell(k, 7).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                                    newTable.Cell(k, 8).Range.Text = strbl;
                                    newTable.Cell(k, 8).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                                }
                            }
                        }
                        else
                        {
                            newTable.Cell(i + 2, 1).Range.Text = dt.Rows[i]["科室"].ToString();
                            newTable.Cell(i + 2, 1).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                            newTable.Cell(i + 2, 2).Range.Text = dt.Rows[i]["科室质检数"].ToString();
                            newTable.Cell(i + 2, 2).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;

                            if (dt.Rows[i]["评级"].ToString() == "甲")
                            {
                                newTable.Cell(i + 2, 3).Range.Text = dt.Rows[i]["病历数"].ToString();
                                newTable.Cell(i + 2, 3).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                                newTable.Cell(i + 2, 4).Range.Text = strbl;
                                newTable.Cell(i + 2, 4).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                            }
                            else if (dt.Rows[i]["评级"].ToString() == "乙")
                            {
                                newTable.Cell(i + 2, 5).Range.Text = dt.Rows[i]["病历数"].ToString();
                                newTable.Cell(i + 2, 5).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                                newTable.Cell(i + 2, 6).Range.Text = strbl;
                                newTable.Cell(i + 2, 6).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                            }
                            else if (dt.Rows[i]["评级"].ToString() == "丙")
                            {
                                newTable.Cell(i + 2, 7).Range.Text = dt.Rows[i]["病历数"].ToString();
                                newTable.Cell(i + 2, 7).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                                newTable.Cell(i + 2, 8).Range.Text = strbl;
                                newTable.Cell(i + 2, 8).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                            }
                        }
                    }
                    //删除多余的行
                    for (int i = 2; i <= newTable.Rows.Count; i++)
                    {
                        if (newTable.Cell(i, 1).Range.Text == "\r\a")
                        {
                            newTable.Rows[i].Delete();
                            i = i - 2;
                        }
                    }
                }
            }
            object Line1 = Microsoft.Office.Interop.Word.WdUnits.wdLine;//换一行;

            //object WdLine = Microsoft.Office.Interop.Word.WdUnits.wdLine;//换一行;
            emrTaskPane.wordApp.Selection.MoveDown(ref Line1, ref count, ref unknow); //移动焦点
            emrTaskPane.wordApp.Selection.MoveDown(ref Line1, ref count, ref unknow); //移动焦点

            emrTaskPane.wordApp.Selection.TypeParagraph();                            //插入段落
            Word.Range range1 = ActiveDocumentManager.getDefaultAD().Paragraphs.Last.Range;
            range1.Start = ActiveDocumentManager.getDefaultAD().Paragraphs.Last.Range.End;
            int count2 = newTable.Rows.Count - 1;

            range1.Select();
            range1.Text = "记录数共计" + count2 + "条";

            range1.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphRight;
            range1.Font.Name = "黑体";
            range1.Font.Size = 10f;
            range1.Start     = range.End;
            //Globals.ThisAddIn.ShowNoteMenu();
            //OperationEnableForStat(true);
            Cursor.Current = Cursors.Default;
        }
예제 #14
0
        public void GetNewReport(DataTable dt)
        {
            object oMissing = System.Reflection.Missing.Value;
            object unknow   = Type.Missing;
            object start    = 0;
            object end      = 0;

            Microsoft.Office.Interop.Word.Range tableLocation = ActiveDocumentManager.getDefaultAD().Range(ref start, ref end);
            // 添加页眉
            emrTaskPane.wordApp.ActiveWindow.View.Type     = Word.WdViewType.wdOutlineView;
            emrTaskPane.wordApp.ActiveWindow.View.SeekView = Word.WdSeekView.wdSeekPrimaryHeader;
            emrTaskPane.wordApp.ActiveWindow.ActivePane.Selection.InsertAfter("");
            emrTaskPane.wordApp.Selection.ParagraphFormat.Alignment   = Word.WdParagraphAlignment.wdAlignParagraphRight; //设置右对齐
            emrTaskPane.wordApp.ActiveWindow.View.SeekView            = Word.WdSeekView.wdSeekMainDocument;              //跳出页眉设置
            emrTaskPane.wordApp.Selection.ParagraphFormat.LineSpacing = 15f;                                             //设置文档的行间距
            //移动焦点并换行
            object count  = 14;
            object WdLine = Microsoft.Office.Interop.Word.WdUnits.wdLine;              //换一行;

            emrTaskPane.wordApp.Selection.MoveDown(ref WdLine, ref count, ref unknow); //移动焦点
            emrTaskPane.wordApp.Selection.MoveDown(ref WdLine, ref count, ref unknow); //移动焦点
            emrTaskPane.wordApp.Selection.TypeParagraph();                             //插入段落

            Word.Range range = ActiveDocumentManager.getDefaultAD().Paragraphs.Last.Range;
            range.Start = ActiveDocumentManager.getDefaultAD().Paragraphs.Last.Range.End;
            range.Select();
            ///range.Text = "终末病历质量评分汇总表" + "(" + comboBox2.Text + "年" + comboBox1.Text + "月)";
            range.Text = "终末病历质量评分汇总表";
            range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
            range.Font.Name = "黑体";
            range.Font.Size = 14.5f;
            range.Start     = range.End;
            range.Select();
            Microsoft.Office.Interop.Word.Table newTable = ActiveDocumentManager.getDefaultAD().Tables.Add(emrTaskPane.wordApp.Selection.Range, dt.Rows.Count + 1, 8, ref unknow, ref unknow);

            //设置表格样式
            newTable.Borders.OutsideLineStyle = Word.WdLineStyle.wdLineStyleSingle;
            newTable.Borders.InsideLineStyle  = Word.WdLineStyle.wdLineStyleSingle;
            emrTaskPane.wordApp.Selection.ParagraphFormat.LineSpacing = 15f;//设置文档的行间距
            newTable.Cell(1, 1).Range.Text = "出院日期";
            newTable.Cell(1, 1).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
            newTable.Cell(1, 2).Range.Text = "科室";
            newTable.Cell(1, 2).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
            newTable.Cell(1, 3).Range.Text = "主管医师";
            newTable.Cell(1, 3).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
            newTable.Cell(1, 4).Range.Text = "病案号";
            newTable.Cell(1, 4).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
            newTable.Cell(1, 5).Range.Text = "扣分原因";
            newTable.Cell(1, 5).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
            newTable.Cell(1, 6).Range.Text = "扣分";
            newTable.Cell(1, 6).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
            newTable.Cell(1, 7).Range.Text = "得分";
            newTable.Cell(1, 7).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
            newTable.Cell(1, 8).Range.Text = "病历级别";
            newTable.Cell(1, 8).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
            newTable.Columns[1].Width = 40f;
            newTable.Columns[2].Width = 36f;
            newTable.Columns[3].Width = 45f;//能显示三个字
            newTable.Columns[4].Width = 43f;
            newTable.Columns[5].Width = 150f;
            newTable.Columns[6].Width = 40f;
            newTable.Columns[7].Width = 40f;
            newTable.Columns[8].Width = 36f;
            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    newTable.Cell(i + 2, 1).Range.Text = dt.Rows[i]["出院日期"].ToString();
                    newTable.Cell(i + 2, 1).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                    newTable.Cell(i + 2, 2).Range.Text = dt.Rows[i]["科室"].ToString();
                    newTable.Cell(i + 2, 2).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                    newTable.Cell(i + 2, 3).Range.Text = dt.Rows[i]["主管医师"].ToString();
                    newTable.Cell(i + 2, 3).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                    newTable.Cell(i + 2, 4).Range.Text = dt.Rows[i]["病案号"].ToString();
                    newTable.Cell(i + 2, 4).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                    newTable.Cell(i + 2, 5).Range.Text = dt.Rows[i]["扣分原因"].ToString();
                    newTable.Cell(i + 2, 5).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
                    newTable.Cell(i + 2, 6).Range.Text = dt.Rows[i]["扣分"].ToString();
                    newTable.Cell(i + 2, 6).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                    newTable.Cell(i + 2, 7).Range.Text = dt.Rows[i]["得分"].ToString();
                    newTable.Cell(i + 2, 7).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                    newTable.Cell(i + 2, 8).Range.Text = dt.Rows[i]["病历级别"].ToString();
                    newTable.Cell(i + 2, 8).Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
                }
            }
            object Line1 = Microsoft.Office.Interop.Word.WdUnits.wdLine;//换一行;

            //object WdLine = Microsoft.Office.Interop.Word.WdUnits.wdLine;//换一行;
            emrTaskPane.wordApp.Selection.MoveDown(ref Line1, ref count, ref unknow); //移动焦点
            emrTaskPane.wordApp.Selection.MoveDown(ref Line1, ref count, ref unknow); //移动焦点
            emrTaskPane.wordApp.Selection.TypeParagraph();                            //插入段落
            Word.Range range1 = ActiveDocumentManager.getDefaultAD().Paragraphs.Last.Range;
            range1.Start = ActiveDocumentManager.getDefaultAD().Paragraphs.Last.Range.End;
            range1.Select();
            range1.Text = "记录数共计" + dt.Rows.Count.ToString() + "条";
            range1.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphRight;
            range1.Font.Name = "黑体";
            range1.Font.Size = 10f;
            range1.Start     = range.End;
            //Globals.ThisAddIn.ShowNoteMenu();
            //Globals.ThisAddIn.noteMenu.OperationEnableForStat(true);
        }