예제 #1
0
 /// <summary>
 /// 通过时间选中指定的节点,并使选中的节点显示在可视范围内 Add by wwj 2013-05-01
 /// </summary>
 /// <param name="captionDatetime"></param>
 public void SelectNodeByCaptionDatetime(string captionDatetime)
 {
     try
     {
         int index = -1;//索引
         foreach (CheckedListBoxItem item in checkedListBoxControlEmrNode.Items)
         {
             EmrNode emrNode = ((ListBoxItem)item).Value as EmrNode;
             if (emrNode != null)
             {
                 string captionDateTimeTemp = emrNode.DataRowItem["captiondatetime"].ToString();
                 if (captionDateTimeTemp == captionDatetime)
                 {
                     index = checkedListBoxControlEmrNode.Items.IndexOf(item);
                     checkedListBoxControlEmrNode.SelectedIndex = index;
                     checkedListBoxControlEmrNode.MakeItemVisible(index);
                     return;
                 }
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #2
0
 /// <summary>
 /// 对TreeList中的节点按照CaptionDateTime进行排序
 /// </summary>
 public bool SortTreeNodeInList()
 {
     try
     {
         List <CheckedListBoxItem> items        = checkedListBoxControlEmrNode.Items.Cast <CheckedListBoxItem>().ToList();
         List <CheckedListBoxItem> itemsOrdered = items.OrderBy(item =>
         {
             EmrNode node = item.Value as EmrNode;
             return(node.DataRowItem["captiondatetime"].ToString());
         }).ToList();
         bool isNeedReSort = false;
         for (int i = 0; i < items.Count; i++)
         {
             if (items[i] != itemsOrdered[i])
             {
                 isNeedReSort = true;
                 break;
             }
         }
         if (isNeedReSort)
         {
             checkedListBoxControlEmrNode.Items.Clear();
             foreach (CheckedListBoxItem item in itemsOrdered)
             {
                 checkedListBoxControlEmrNode.Items.Add(item);
             }
             return(true);
         }
         return(false);
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #3
0
 /// <summary>
 /// 删除一份病历后,删除在病程预览区中的该病程记录
 /// </summary>
 /// <param name="recorddetailID"></param>
 public void AfterDeleteEmr(string recorddetailID)
 {
     try
     {
         //获取recorddetail.ID == recorddetailID的病历
         var listBoxItem = checkedListBoxControlEmrNode.Items.Cast <CheckedListBoxItem>().Where(item =>
         {
             EmrNode emrNode = item.Value as EmrNode;
             if (emrNode != null && emrNode.ID == recorddetailID)
             {
                 return(true);
             }
             return(false);
         }).FirstOrDefault <CheckedListBoxItem>();
         if (listBoxItem != null)
         {
             //被选中则重新刷数据
             if (listBoxItem.CheckState == CheckState.Checked)
             {
                 listBoxItem.CheckState = CheckState.Unchecked;
                 RefreshEmrContent();
             }
             //移除删除的节点
             checkedListBoxControlEmrNode.Items.Remove(listBoxItem);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #4
0
 private void checkedListBoxControlEmrNode_MouseDown(object sender, MouseEventArgs e)
 {
     try
     {
         if (e.Button == System.Windows.Forms.MouseButtons.Left)
         {
             Point point     = checkedListBoxControlEmrNode.PointToClient(Cursor.Position);
             int   itemIndex = checkedListBoxControlEmrNode.IndexFromPoint(point);
             if (itemIndex >= 0)
             {
                 CheckedListBoxItem item = (CheckedListBoxItem)checkedListBoxControlEmrNode.GetItem(itemIndex);
                 if (point.X >= 4 && point.X <= 16)
                 {
                     if (m_FocusedCheckItem != item)
                     {
                         if (item.CheckState == CheckState.Checked)
                         {
                             item.CheckState = CheckState.Unchecked;
                         }
                         else
                         {
                             item.CheckState = CheckState.Checked;
                         }
                     }
                     m_FocusedCheckItem = item;
                     return;
                 }
                 if (item != null)
                 {
                     EmrNode emrNode = item.Value as EmrNode;
                     if (emrNode != null)
                     {
                         string captionDateTime = emrNode.DataRowItem["captiondatetime"].ToString();
                         this.CurrentEditorForm.SetCurrentElement(captionDateTime);
                     }
                 }
                 m_FocusedCheckItem = item;
             }
         }
     }
     catch (Exception ex)
     {
         MyMessageBox.Show(1, ex);
     }
 }
예제 #5
0
        /// <summary>
        /// 编辑器中的病历保存之后对病程预览区的影响
        /// 如果是新增:直接在预览区左侧的列表中增加此节点,但是不勾中,预览区中显示的病程内容不发生改变
        /// 如果是修改:在预览区左侧的列表中判断此病历有无勾中,如果勾中则重新捞取此病历的内容,并重新显示在预览区中
        /// </summary>
        public void AfterSaveEmr(string recorddetailID, string displayDateTime)
        {
            try
            {
                //获取recorddetail.ID == recorddetailID的病历
                var listBoxItem = checkedListBoxControlEmrNode.Items.Cast <CheckedListBoxItem>().Where(item =>
                {
                    EmrNode emrNode = item.Value as EmrNode;
                    if (emrNode != null && emrNode.ID == recorddetailID)
                    {
                        return(true);
                    }
                    return(false);
                }).FirstOrDefault <CheckedListBoxItem>();
                if (listBoxItem == null)
                {
                    #region 新增树节点
                    DataTable dtRecord = GetEmrRecordByID(recorddetailID);
                    if (dtRecord.Rows.Count > 0)
                    {
                        EmrNode emrNode     = new EmrNode(dtRecord.Rows[0]);
                        int     insertIndex = 0;
                        if (checkedListBoxControlEmrNode.Items.Count > 0)
                        {
                            //计算比上面获取病历的captiondatetime小的病历记录数目
                            int cnt = checkedListBoxControlEmrNode.Items.Cast <ListBoxItem>().Count(item =>
                            {
                                EmrNode node = item.Value as EmrNode;
                                if (emrNode != null &&
                                    (Convert.ToDateTime(emrNode.DataRowItem["captiondatetime"]) - Convert.ToDateTime(node.DataRowItem["captiondatetime"])).TotalSeconds > 0)
                                {
                                    return(true);
                                }
                                return(false);
                            });
                            insertIndex += cnt;
                        }
                        //在指定的位置插入树节点
                        CheckedListBoxItem checkedListBoxItem = new CheckedListBoxItem(emrNode, true);
                        checkedListBoxControlEmrNode.Items.Insert(insertIndex, checkedListBoxItem);
                        Point scrollPosition = CurrentEditorForm.CurrentEditorControl.AutoScrollPosition;
                        RefreshEmrContent();
                        CurrentEditorForm.CurrentEditorControl.SetAutoScrollPosition(new Point(scrollPosition.X, -scrollPosition.Y));
                    }
                    #endregion
                }
                else
                {
                    #region 修改树节点,并重新刷数据

                    DataTable dtRecord = GetEmrRecordByID(recorddetailID);
                    if (dtRecord.Rows.Count > 0)
                    {
                        EmrNode node = listBoxItem.Value as EmrNode;
                        node.DataRowItem.ItemArray = dtRecord.Rows[0].ItemArray;
                        node.Name = node.DataRowItem["name"].ToString();

                        bool isSorted = SortTreeNodeInList();//对节点进行排序
                        if (listBoxItem.CheckState == CheckState.Checked)
                        {
                            Point scrollPosition = CurrentEditorForm.CurrentEditorControl.AutoScrollPosition;
                            RefreshEmrContent();

                            if (!isSorted)
                            {//如果没有进行排序,则需要定位原先的Scroll的位置
                                CurrentEditorForm.CurrentEditorControl.SetAutoScrollPosition(new Point(scrollPosition.X, -scrollPosition.Y));
                            }
                            else
                            {
                                CurrentEditorForm.SetCurrentElement(displayDateTime);
                            }
                        }
                    }
                    #endregion
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #6
0
        /// <summary>
        /// 拼接选中病历的内容
        /// </summary>
        private XmlDocument ConcatCheckedEmrContent()
        {
            try
            {
                XmlDocument doc      = new XmlDocument();
                XmlNode     nodeBody = null;

                List <string> emrList = new List <string>();
                foreach (CheckedListBoxItem item in checkedListBoxControlEmrNode.Items)
                {
                    if (item.CheckState == CheckState.Checked)
                    {
                        EmrNode emrNode = ((ListBoxItem)item).Value as EmrNode;
                        if (emrNode.DataRowItem["content"].ToString() == "")
                        {
                            emrNode.DataRowItem["content"] = GetEmrContentByID(emrNode.ID);
                        }
                        string emrContent = emrNode.DataRowItem["content"].ToString();
                        if (!string.IsNullOrEmpty(emrContent))
                        {
                            emrList.Add(emrContent);
                        }
                    }
                }

                if (emrList.Count > 0)
                {
                    doc = new XmlDocument();
                    for (int i = 0; i < emrList.Count; i++)
                    {
                        try
                        {
                            if (doc.InnerText == "")
                            {
                                string emrContent = emrList[i];
                                doc.PreserveWhitespace = true;
                                doc.LoadXml(emrContent);
                                nodeBody = doc.SelectSingleNode("document/body");
                            }
                            else
                            {
                                XmlDocument xmlDoc = new XmlDocument();
                                xmlDoc.PreserveWhitespace = true;
                                xmlDoc.LoadXml(emrList[i]);
                                XmlNode bodyNode = xmlDoc.SelectSingleNode("document/body");
                                foreach (XmlNode node in bodyNode.ChildNodes)
                                {
                                    XmlNode deepCopyNode = doc.ImportNode(node, true);
                                    nodeBody.AppendChild(deepCopyNode);
                                }
                            }
                        }
                        catch
                        {
                            continue;
                        }
                    }
                }
                return(doc);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #7
0
        /// <summary>
        /// 默认选中复选框列表中的指定项目
        /// </summary>
        private void DefaultCheckItem()
        {
            try
            {
                if (checkedListBoxControlEmrNode.InvokeRequired)
                {
                    checkedListBoxControlEmrNode.Invoke(new Action(DefaultCheckItem));
                }
                else
                {
                    //if (checkedListBoxControlEmrNode.Items.Count <= m_NeedCheckItemCount)
                    //{
                    //    checkedListBoxControlEmrNode.CheckAll();
                    //}
                    //else
                    {
                        int index          = -1;                   //FirstCallRecordDetailID中在复选框列表中的索引
                        int needCheckCount = m_NeedCheckItemCount; //在复选框列表中需要选中的项目
                        foreach (CheckedListBoxItem item in checkedListBoxControlEmrNode.Items)
                        {
                            EmrNode emrNode = ((ListBoxItem)item).Value as EmrNode;
                            if (emrNode != null)
                            {
                                if (emrNode.ID == FirstCallRecordDetailID.ToString())
                                {
                                    FirstCallRecordDetailCaptionDateTime = emrNode.DataRowItem["captiondatetime"].ToString();
                                    index = checkedListBoxControlEmrNode.Items.IndexOf(item);
                                }
                            }
                        }

                        if (index != -1)
                        {
                            #region 勾中指定病历周围m_NeedCheckItemCount份病历
                            checkedListBoxControlEmrNode.Items[index].CheckState = CheckState.Checked;
                            for (int i = 1; i <= m_NeedCheckItemCount; i++)
                            {
                                if (index + i < checkedListBoxControlEmrNode.Items.Count)
                                {
                                    checkedListBoxControlEmrNode.Items[index + i].CheckState = CheckState.Checked;
                                }

                                if (checkedListBoxControlEmrNode.CheckedItems.Count == m_NeedCheckItemCount)
                                {
                                    break;
                                }

                                if (index - i >= 0)
                                {
                                    checkedListBoxControlEmrNode.Items[index - i].CheckState = CheckState.Checked;
                                }

                                if (checkedListBoxControlEmrNode.CheckedItems.Count == m_NeedCheckItemCount)
                                {
                                    break;
                                }
                            }
                            #endregion

                            checkedListBoxControlEmrNode.SelectedIndex = index;
                            checkedListBoxControlEmrNode.MakeItemVisible(index);
                        }
                        else
                        {
                            int itemCount = checkedListBoxControlEmrNode.Items.Count;
                            for (int i = 1; i <= m_NeedCheckItemCount; i++)
                            {
                                if (itemCount - i >= 0)
                                {
                                    checkedListBoxControlEmrNode.Items[itemCount - i].CheckState = CheckState.Checked;
                                }
                            }

                            int selectIndex = itemCount - m_NeedCheckItemCount;
                            checkedListBoxControlEmrNode.SelectedIndex = selectIndex;
                            checkedListBoxControlEmrNode.MakeItemVisible(selectIndex);
                        }

                        if (checkedListBoxControlEmrNode.CheckedItems.Count == checkedListBoxControlEmrNode.Items.Count)
                        {
                            checkEditAll.Checked = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }