Exemplo n.º 1
0
        private void FillModelMacro()
        {
            PadForm padForm = m_CurrentPadForm;

            if (padForm != null)
            {
                string deptName = textBoxDept.Text.Trim();
                string wardName = textBoxWard.Text.Trim();

                bool isModified = padForm.zyEditorControl1.EMRDoc.Modified;

                //根据病历的不同状态,调用程序在此处初始化宏的值。
                //替换标题中的宏
                XmlDocument headerdoc = new XmlDocument();
                headerdoc.LoadXml(padForm.zyEditorControl1.EMRDoc.HeadString);
                XmlNodeList nodes = headerdoc.SelectNodes("header/p/macro");
                foreach (XmlNode node in nodes)
                {
                    if (node.Attributes["name"].Value.Trim() == "科室" && !string.IsNullOrEmpty(deptName))
                    {
                        node.InnerText = deptName;
                    }
                    else if (node.Attributes["name"].Value.Trim() == "病区" && !string.IsNullOrEmpty(wardName))
                    {
                        node.InnerText = wardName;
                    }
                }
                padForm.zyEditorControl1.EMRDoc.HeadString = headerdoc.OuterXml;

                //替换文档中的宏
                //获得所有宏元素列表
                ArrayList      al  = new ArrayList();
                ZYTextDocument doc = padForm.zyEditorControl1.EMRDoc;
                doc.GetAllSpecElement(al, doc.RootDocumentElement, ElementType.Macro, null);

                //循环每个宏元素,根据宏元素的Name属性,查询并赋值线Text属性
                foreach (ZYMacro m in al)
                {
                    if (m.Name == "科室" && !string.IsNullOrEmpty(deptName))
                    {
                        m.Text = deptName;
                    }
                    else if (m.Name == "病区" && !string.IsNullOrEmpty(wardName))
                    {
                        m.Text = wardName;
                    }
                }

                doc.RefreshSize();
                doc.ContentChanged();
                doc.OwnerControl.Refresh();
                doc.UpdateCaret();

                padForm.zyEditorControl1.EMRDoc.Modified = isModified;
            }
        }
Exemplo n.º 2
0
        private void FillModelMacro(PadForm padForm)
        {
            try
            {
                if (padForm != null)
                {
                    bool isModified = padForm.zyEditorControl1.EMRDoc.Modified;

                    //根据病历的不同状态,调用程序在此处初始化宏的值。
                    //替换标题中的宏
                    XmlDocument headerdoc = new XmlDocument();
                    headerdoc.LoadXml(padForm.zyEditorControl1.EMRDoc.HeadString);
                    XmlNodeList nodes = headerdoc.SelectNodes("header/p/macro");
                    foreach (XmlNode node in nodes) //为默认值的时候进行替换
                    {
                        if (node.Attributes["name"].Value.Trim() == "科室" && node.InnerText.Trim() != "科室")
                        {
                            continue;
                        }
                        if (node.Attributes["name"].Value.Trim() == "病区" && node.InnerText.Trim() != "病区")
                        {
                            continue;
                        }

                        //Add by wwj 2012-07-17
                        if (node.Attributes["name"].Value.Trim() == "医师签名" && node.InnerText.Trim() != "医师签名")
                        {
                            continue;
                        }

                        if (node.Attributes["name"].Value.Trim() == "当前日期" && node.InnerText.Trim() != "当前日期")
                        {
                            continue;
                        }
                        if (node.Attributes["name"].Value.Trim() == "当前时间" && node.InnerText.Trim() != "当前时间")
                        {
                            continue;
                        }

                        node.InnerText = GetDataByNameForMacro(node.Attributes["name"].Value);
                    }
                    padForm.zyEditorControl1.EMRDoc.HeadString = headerdoc.OuterXml;

                    //替换文档中的宏
                    //获得所有宏元素列表
                    ArrayList      al  = new ArrayList();
                    ZYTextDocument doc = padForm.zyEditorControl1.EMRDoc;
                    doc.GetAllSpecElement(al, doc.RootDocumentElement, ElementType.Macro, null);

                    //循环每个宏元素,根据宏元素的Name属性,查询并赋值线Text属性
                    foreach (ZYMacro m in al)
                    {
                        if (m.Name == "科室" && m.Text.Trim() != "科室")
                        {
                            continue;
                        }
                        if (m.Name == "病区" && m.Text.Trim() != "病区")
                        {
                            continue;
                        }

                        //Add by wwj 2012-07-17
                        if (m.Name == "医师签名" && m.text.Trim() != "医师签名")
                        {
                            continue;
                        }

                        if (m.Name == "当前日期" && m.text.Trim() != "当前日期")
                        {
                            continue;
                        }
                        if (m.Name == "当前时间" && m.text.Trim() != "当前时间")
                        {
                            continue;
                        }

                        m.Text = GetDataByNameForMacro(m.Name);
                    }

                    doc.RefreshSize();
                    doc.ContentChanged();
                    doc.OwnerControl.Refresh();
                    doc.UpdateCaret();

                    padForm.zyEditorControl1.EMRDoc.Modified = isModified;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 3
0
        private void ReplaceModelMacro(EmrModel model)
        {
            try
            {
                //循环每个可替换元素,根据可替换元素的Name属性,查询并赋值Text属性
                //获得病历中所有可替换元素列表
                ArrayList      al  = new ArrayList();
                ZYTextDocument doc = CurrentForm.zyEditorControl1.EMRDoc;
                doc.GetAllSpecElement(al, doc.RootDocumentElement, ElementType.Replace, null);

                //无可替换元素则退出
                if (al.Count < 0)
                {
                    return;
                }

                Dictionary <string, PadForm> padFormDictionary = new Dictionary <string, PadForm>();

                //获得当前病历需要替换的项目需要从哪些病历中提取
                DataTable dtReplaceItem = m_RecordDal.GetReplaceItem(model.ModelName);

                //源病历的列表
                List <string> sourceEmrList = m_RecordDal.GetSourceEMRByDestEmrName(model.ModelName, dtReplaceItem);

                foreach (string sourceEmr in sourceEmrList)
                {
                    PadForm padForm = GetSourcePadFormForReplaceItem(sourceEmr);
                    padFormDictionary.Add(sourceEmr, padForm);
                }

                if (padFormDictionary.Count == 0)
                {
                    return;
                }

                int startIndex;
                int endIndex;
                GetEditAreaIndex(doc, out startIndex, out endIndex);

                DocumentModel docModel = CurrentForm.zyEditorControl1.EMRDoc.Info.DocumentModel;

                //替换当前病历中的项目
                foreach (ZYReplace m in al)
                {
                    //排除编辑范围之外的可替换元素
                    if (c_IsOpenEditAreaCanReplaceFlag && docModel == DocumentModel.Read && startIndex != -1 && endIndex != -1)
                    {
                        int zyReplaceIndex = CurrentForm.zyEditorControl1.EMRDoc.Content.IndexOf(m.FirstElement);
                        if (zyReplaceIndex < startIndex || zyReplaceIndex > endIndex)
                        {
                            continue;
                        }
                    }

                    List <string> destList = m_RecordDal.GetSourceEMRByDestItemAndDestEmrName(model.ModelName, m.Name, dtReplaceItem);
                    if (destList.Count == 0)
                    {
                        continue;
                    }
                    if (destList.Count == 2)
                    {
                        string  source_emrname  = destList[0];
                        string  source_itemname = destList[1];
                        PadForm padForm         = padFormDictionary[source_emrname];
                        if (padForm != null)
                        {
                            m.Text = padForm.zyEditorControl1.EMRDoc.GetReplaceText(source_itemname);
                        }
                    }
                }
                doc.RefreshSize();
                doc.ContentChanged();
                doc.OwnerControl.Refresh();
                doc.UpdateCaret();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }