/// <summary>
		/// Estimates the hit count for the specified search, unless the count exceeds a specified
		/// threshold, in which case the method returns false and no count is obtained.
		/// </summary>
		/// <param name="wisc"></param>
		/// <param name="count"></param>
		/// <returns></returns>
		public override bool EstimateSearchResultsCount(IWorklistItemSearchContext wisc, out int count)
		{
			count = 0;

			// if no degenerate items are included, we need to do exactly one query for worklist items,
			// no estimation is possible
			if (!wisc.IncludeDegeneratePatientItems && !wisc.IncludeDegenerateProcedureItems)
			{
				// search for worklist items, delegating the task of designing the query to the subclass
				count = wisc.CountWorklistItems(wisc.SearchCriteria);

				// return whether the count exceeded the threshold
				return count <= wisc.Threshold;
			}

			// if some degenerate items are to be included, then we can omit querying for "active worklist items", e.g. ProcedureSteps,
			// because the degenerate set is by definition a superset of the active items
			// Strategy:
			// Valid search fields are:
			// - Patient: Name, MRN, Healthcard
			// - Order/Procedure: Accession, Ordering Prac, Procedure Type, Date Range
			// The approach taken here is to perform a patient count query and a procedure count query.
			// The patient query will count all potential patient matches based on Patient-applicable search fields.
			// The procedure count query will count all potential procedure matches based on both Patient and Order/Procedure search fields.
			// If either count exceeds the threshold, we can bail immediately.
			// Otherwise, the counts must be combined.  Note that each count represents a potentially overlapping
			// set of items, so there is no possible way to determine an 'exact' count (hence the word Estimate).
			// However, we know that the true count is a) greater than or equal to the maximum of either independent count, and
			// b) less than or equal to the sum of both counts.  Therefore, choose the midpoint of this number as a
			// 'good enough' estimate.

			var numPatients = 0;
			if (wisc.IncludeDegeneratePatientItems)
			{
				// count number of patient matches
				numPatients = wisc.CountPatients(wisc.SearchCriteria);

				// if this number exceeds threshold, bail
				if (numPatients > wisc.Threshold)
					return false;
			}

			var numProcedures = 0;
			if (wisc.IncludeDegenerateProcedureItems)
			{
				// count number of procedure matches
				numProcedures = wisc.CountProcedures(wisc.SearchCriteria);

				// if this number exceeds threshold, bail
				if (numProcedures > wisc.Threshold)
					return false;
			}

			// combine the two numbers to produce a guess at the actual number of results
			count = (Math.Max(numPatients, numProcedures) + numPatients + numProcedures) / 2;

			// return whether the count exceeded the threshold
			return count <= wisc.Threshold;
		}
        /// <summary>
        /// Executes a search, returning a list of hits.
        /// </summary>
        /// <param name="wisc"></param>
        /// <returns></returns>
        public override IList <WorklistItem> GetSearchResults(IWorklistItemSearchContext wisc)
        {
            var results = new List <WorklistItem>();

            // the search criteria is broken up to gain performance. See #2416.
            var criteriaWithPatientConditions    = SelectCriteriaWithPatientConditions(wisc.SearchCriteria);
            var criteriaWithoutPatientConditions = ExcludeCriteriaWithPatientConditions(wisc.SearchCriteria);

            if (criteriaWithPatientConditions.Length > 0)
            {
                results = UnionMerge(results, wisc.FindWorklistItems(criteriaWithPatientConditions),
                                     item => item.ProcedureRef);
            }

            if (criteriaWithoutPatientConditions.Length > 0)
            {
                results = UnionMerge(results, wisc.FindWorklistItems(criteriaWithoutPatientConditions),
                                     item => item.ProcedureRef);
            }

            // include procedure degenerate items if requested
            if (wisc.IncludeDegenerateProcedureItems)
            {
                // search for procedures
                if (criteriaWithPatientConditions.Length > 0)
                {
                    results = UnionMerge(results, wisc.FindProcedures(criteriaWithPatientConditions),
                                         item => item.ProcedureRef);
                }

                if (criteriaWithoutPatientConditions.Length > 0)
                {
                    results = UnionMerge(results, wisc.FindProcedures(criteriaWithoutPatientConditions),
                                         item => item.ProcedureRef);
                }
            }

            // include patient degenerate items if requested
            if (wisc.IncludeDegeneratePatientItems)
            {
                // search for patients
                if (criteriaWithPatientConditions.Length > 0)
                {
                    // add any patients for which there is no result
                    results = UnionMerge(results, wisc.FindPatients(criteriaWithPatientConditions),
                                         item => item.PatientRef);
                }
            }

            return(results);
        }
		/// <summary>
		/// Executes a search, returning a list of hits.
		/// </summary>
		/// <param name="wisc"></param>
		/// <returns></returns>
		public override IList<WorklistItem> GetSearchResults(IWorklistItemSearchContext wisc)
		{
			var where = wisc.SearchCriteria;
			var results = new List<WorklistItem>();

			results = UnionMerge(results, wisc.FindWorklistItems(where), item => item.ProcedureRef);

			// include degenerate procedure items if requested
			if (wisc.IncludeDegenerateProcedureItems)
			{
				// search for procedures
				results = UnionMerge(results, wisc.FindProcedures(where), item => item.ProcedureRef);
			}

			// include degenerate patient items if requested
			if (wisc.IncludeDegeneratePatientItems)
			{
				// add any patients for which there is no result
				results = UnionMerge(results, wisc.FindPatients(where), item => item.PatientRef);
			}

			return results;
		}
        /// <summary>
        /// Executes a search, returning a list of hits.
        /// </summary>
        /// <param name="wisc"></param>
        /// <returns></returns>
        public override IList <WorklistItem> GetSearchResults(IWorklistItemSearchContext wisc)
        {
            var where = wisc.SearchCriteria;
            var results = new List <WorklistItem>();

            results = UnionMerge(results, wisc.FindWorklistItems(where), item => item.ProcedureRef);

            // include degenerate procedure items if requested
            if (wisc.IncludeDegenerateProcedureItems)
            {
                // search for procedures
                results = UnionMerge(results, wisc.FindProcedures(where), item => item.ProcedureRef);
            }

            // include degenerate patient items if requested
            if (wisc.IncludeDegeneratePatientItems)
            {
                // add any patients for which there is no result
                results = UnionMerge(results, wisc.FindPatients(where), item => item.PatientRef);
            }

            return(results);
        }
示例#5
0
 /// <summary>
 /// Estimates the hit count for the specified search, unless the count exceeds a specified
 /// threshold, in which case the method returns false and no count is obtained.
 /// </summary>
 /// <param name="wisc"></param>
 /// <param name="count"></param>
 /// <returns></returns>
 public abstract bool EstimateSearchResultsCount(IWorklistItemSearchContext wisc, out int count);
示例#6
0
 /// <summary>
 /// Executes a search, returning a list of hits.
 /// </summary>
 /// <param name="wisc"></param>
 /// <returns></returns>
 public abstract IList <WorklistItem> GetSearchResults(IWorklistItemSearchContext wisc);
        /// <summary>
        /// Estimates the hit count for the specified search, unless the count exceeds a specified
        /// threshold, in which case the method returns false and no count is obtained.
        /// </summary>
        /// <param name="wisc"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public override bool EstimateSearchResultsCount(IWorklistItemSearchContext wisc, out int count)
        {
            count = 0;

            // if no degenerate items are included, we need to do exactly one query for worklist items,
            // no estimation is possible
            if (!wisc.IncludeDegeneratePatientItems && !wisc.IncludeDegenerateProcedureItems)
            {
                // search for worklist items, delegating the task of designing the query to the subclass
                count = wisc.CountWorklistItems(wisc.SearchCriteria);

                // return whether the count exceeded the threshold
                return(count <= wisc.Threshold);
            }

            // if some degenerate items are to be included, then we can omit querying for "active worklist items", e.g. ProcedureSteps,
            // because the degenerate set is by definition a superset of the active items
            // Strategy:
            // Valid search fields are:
            // - Patient: Name, MRN, Healthcard
            // - Order/Procedure: Accession
            // The approach taken here is to perform a patient count query and a procedure count query.
            // The patient query will count all potential patient matches based on Patient-applicable search fields.
            // The procedure count query will count all potential procedure matches based on both Patient and Order/Procedure search fields.
            // If either count exceeds the threshold, we can bail immediately.
            // Otherwise, the counts must be combined.  Note that each count represents a potentially overlapping
            // set of items, so there is no possible way to determine an 'exact' count (hence the word Estimate).
            // However, we know that the true count is a) greater than or equal to the maximum of either independent count, and
            // b) less than or equal to the sum of both counts.  Therefore, choose the midpoint of this number as a
            // 'good enough' estimate.

            var numPatients = 0;

            if (wisc.IncludeDegeneratePatientItems)
            {
                // count number of patient matches
                numPatients = wisc.CountPatients(wisc.SearchCriteria);

                // if this number exceeds threshold, bail
                if (numPatients > wisc.Threshold)
                {
                    return(false);
                }
            }

            var numProcedures = 0;

            if (wisc.IncludeDegenerateProcedureItems)
            {
                // find procedures based on the patient search fields
                var criteriaWithPatientConditions = SelectCriteriaWithPatientConditions(wisc.SearchCriteria);
                if (criteriaWithPatientConditions.Length > 0)
                {
                    numProcedures += wisc.CountProcedures(criteriaWithPatientConditions);

                    // if this number exceeds threshold, bail
                    if (numProcedures > wisc.Threshold)
                    {
                        return(false);
                    }
                }

                // find procedures based on the order search fields
                var criteriaWithoutPatientConditions = ExcludeCriteriaWithPatientConditions(wisc.SearchCriteria);
                if (criteriaWithoutPatientConditions.Length > 0)
                {
                    numProcedures += wisc.CountProcedures(criteriaWithoutPatientConditions);

                    // if this number exceeds threshold, bail
                    if (numProcedures > wisc.Threshold)
                    {
                        return(false);
                    }
                }
            }

            // combine the two numbers to produce a guess at the actual number of results
            count = (Math.Max(numPatients, numProcedures) + numPatients + numProcedures) / 2;

            // return whether the count exceeded the threshold
            return(count <= wisc.Threshold);
        }
		/// <summary>
		/// Estimates the hit count for the specified search, unless the count exceeds a specified
		/// threshold, in which case the method returns false and no count is obtained.
		/// </summary>
		/// <param name="wisc"></param>
		/// <param name="count"></param>
		/// <returns></returns>
		public abstract bool EstimateSearchResultsCount(IWorklistItemSearchContext wisc, out int count);
		/// <summary>
		/// Executes a search, returning a list of hits.
		/// </summary>
		/// <param name="wisc"></param>
		/// <returns></returns>
		public abstract IList<WorklistItem> GetSearchResults(IWorklistItemSearchContext wisc);
		/// <summary>
		/// Executes a search, returning a list of hits.
		/// </summary>
		/// <param name="wisc"></param>
		/// <returns></returns>
		public override IList<WorklistItem> GetSearchResults(IWorklistItemSearchContext wisc)
		{
			var results = new List<WorklistItem>();

			// the search criteria is broken up to gain performance. See #2416.
			var criteriaWithPatientConditions = SelectCriteriaWithPatientConditions(wisc.SearchCriteria);
			var criteriaWithoutPatientConditions = ExcludeCriteriaWithPatientConditions(wisc.SearchCriteria);

			if (criteriaWithPatientConditions.Length > 0)
			{
				results = UnionMerge(results, wisc.FindWorklistItems(criteriaWithPatientConditions),
					item => item.ProcedureRef);
			}

			if (criteriaWithoutPatientConditions.Length > 0)
			{
				results = UnionMerge(results, wisc.FindWorklistItems(criteriaWithoutPatientConditions),
					item => item.ProcedureRef);
			}

			// include procedure degenerate items if requested
			if (wisc.IncludeDegenerateProcedureItems)
			{
				// search for procedures
				if (criteriaWithPatientConditions.Length > 0)
				{
					results = UnionMerge(results, wisc.FindProcedures(criteriaWithPatientConditions),
					                     item => item.ProcedureRef);
				}

				if (criteriaWithoutPatientConditions.Length > 0)
				{
					results = UnionMerge(results, wisc.FindProcedures(criteriaWithoutPatientConditions),
					                     item => item.ProcedureRef);
				}
			}

			// include patient degenerate items if requested
			if (wisc.IncludeDegeneratePatientItems)
			{
				// search for patients
				if (criteriaWithPatientConditions.Length > 0)
				{
					// add any patients for which there is no result
					results = UnionMerge(results, wisc.FindPatients(criteriaWithPatientConditions),
						item => item.PatientRef);
				}
			}

			return results;
		}