Пример #1
0
        //searches the ACV tree and triggers the ACVFound event when it reaches the size limit of the tree
        private void traverseACVTree(ACVTreeNode node, List<Visit> visits, List<Visit> currentACV, int index, int size, int maxSize, Visit isIncluded)
        {
            int count = 0;

            if(node.Visit != null)
                currentACV.Add(node.Visit);

            if (size == maxSize)
            {
                this.ACVFound(this, new ACVFoundArgs(new ACV(currentACV)));
                return;
            }

            for (int i = index; i < visits.Count; i++)
            {

                if (node.Visit == null && isIncluded != null && count < 1)
                {
                    if(isIncluded.equals(visits[i]))
                    {
                        node.addChild(new ACVTreeNode(visits[i], node));
                        count++;
                        break;
                    }
                }
                else
                {
                    node.addChild(new ACVTreeNode(visits[i], node));
                }
            }

            foreach (ACVTreeNode n in node.Children)
            {
                traverseACVTree(n, visits, new List<Visit>(currentACV), ++index, size + 1, maxSize, isIncluded);
            }
        }
Пример #2
0
 public void addChild(ACVTreeNode child)
 {
     this._children.Add(child);
 }
Пример #3
0
        //public hook to search the tree
        /*public void FindACVs(int maxSize)
        {
            if (this.Visits.Count > 0)
            {
                ACVTreeNode root = new ACVTreeNode(null, null);
                List<Visit> currentACV = new List<Visit>();

                this.traverseACVTree(root, this.Visits, currentACV, 0, 0, maxSize, null);
            }
        }*/
        //public hook to search the tree and register a callback
        public void FindACVs(int maxSize, ACVFoundEventHandler callback, Visit mustInclude)
        {
            this.Visits = DbMethods.getInstance().getPatientVisits(this.ID);
            this.ACVFound = callback;
            if (this.Visits.Count > 0)
            {
                ACVTreeNode root = new ACVTreeNode(null, null);
                List<Visit> currentACV = new List<Visit>();

                this.traverseACVTree(root, this.Visits, currentACV, 0, 0, maxSize, mustInclude);
            }
        }
Пример #4
0
 public ACVTreeNode(Visit visit, ACVTreeNode parent)
 {
     this._children = new List<ACVTreeNode>();
     this._parent = parent;
     this._visit = visit;
 }