Ejemplo n.º 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);
            }
        }
Ejemplo n.º 2
0
        public bool IsSafe(List<Patient> patients, int acvSize, Visit mustInclude)
        {
            bool safe = true;
            this._safetyPatientsBuffer = new List<Patient>();
            Stopwatch sw = new Stopwatch();

            this.FindACVs(acvSize,
                (Patient sender, ACVFoundArgs args) =>
                {
                    sw.Start();
                    ACV acv = args.ACV;
                    int matchCount = 0;

                    if(safe){
                        foreach (Patient p in patients)
                        {
                            if (p.MatchesACV(acv) && p.ID != this.ID)
                            {
                                matchCount++;
                                this._safetyPatientsBuffer.Add(p);

                                if (matchCount >= this._safeNessThreshold)
                                {
                                    break;
                                }
                            }
                        }
                    }

                    if(matchCount < this._safeNessThreshold)
                    {
                        safe = false;
                    }

                    sw.Stop();
                },
                mustInclude
            );

            if (safe)
            {
                this._safe = true;
            }
            else
            {
                this._safe = false;
            }

            return safe;
        }
Ejemplo n.º 3
0
        public bool IsStillSafe(List<Patient> patients, int acvSize, Visit newVisit)
        {
            if (!this._safetyAssessed)
                return this.IsSafe(patients, acvSize, null);
            if(this._safe == true)
                return this.IsSafe(patients, acvSize, newVisit);

            return false;
        }
Ejemplo n.º 4
0
        //check if the patient currently has a visit
        public bool HasVisit(Visit visit)
        {
            foreach (Visit v in this._visits)
            {
                if (v.ID == visit.ID)
                {
                    return true;
                }
            }

            return false;
        }
Ejemplo n.º 5
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);
            }
        }
Ejemplo n.º 6
0
        //adds a visit to the patient
        public void AddVisit(Visit visit)
        {
            if (this.HasVisit(visit))
            {
                throw new Exception("This patient already has this visit");
            }

            this._visits.Add(visit);
            visit.Patient = this;
        }
Ejemplo n.º 7
0
        //checkes if this visit is equal to a specified visit
        public bool equals(Visit v)
        {
            if (!(v.Date.Date == this._date.Date))
            {
                return false;
            }

            if (!(v.RationalID == this._rationalID))
            {
                return false;
            }

            return true;
        }
Ejemplo n.º 8
0
 public ACVTreeNode(Visit visit, ACVTreeNode parent)
 {
     this._children = new List<ACVTreeNode>();
     this._parent = parent;
     this._visit = visit;
 }