Esempio n. 1
0
        /// <summary>
        /// Adds criteria to the query (the 'where' clause).
        /// </summary>
        /// <param name="query"></param>
        /// <param name="args"></param>
        public virtual void AddCriteria(HqlProjectionQuery query, QueryBuilderArgs args)
        {
            QueryBuilderHelpers.AddCriteriaToQuery(HqlConstants.WorklistItemQualifier, args.Criteria, query, RemapHqlExpression);

            // modify the query to workaround some NHibernate bugs
            QueryBuilderHelpers.NHibernateBugWorkaround(query.Froms[0], query.Conditions, a => a);
        }
        public override void AddRootQuery(HqlProjectionQuery query, QueryBuilderArgs args)
        {
            base.AddRootQuery(query, args);

            var from = query.Froms[0];             // added by base.AddRootQuery

            // join report/report part object, because may have criteria or projections on this object
            from.Joins.Add(HqlConstants.JoinReportPart);
            from.Joins.Add(HqlConstants.JoinReport);

            // check if we need to apply the "most recent step" condition
            // this is essentially a workaround to avoid showing duplicates in some worklist results
            // we can only apply this workaround when there is exactly one ps class specified
            // fortunately, there are no use cases yet where more than one ps class is specified
            // that require the workaround
            if (args.ProcedureStepClasses.Length == 1)
            {
                var psClass = CollectionUtils.FirstElement(args.ProcedureStepClasses);
                if (psClass == typeof(PublicationStep))
                {
                    query.Conditions.Add(ConditionMostRecentPublicationStep);
                }
                if (psClass == typeof(TranscriptionStep))
                {
                    query.Conditions.Add(ConditionMostRecentTranscriptionStep);
                }
            }
        }
Esempio n. 3
0
        public override void AddRootQuery(HqlProjectionQuery query, QueryBuilderArgs args)
        {
            base.AddRootQuery(query, args);

            var from = query.Froms[0];                  // this would be added by the base.AddWorklistRootQuery call

            // join protocol object, because may have criteria on this object
            from.Joins.Add(HqlConstants.JoinProtocol);

            // check if we need to apply the "most recent step" condition
            // this is essentially a workaround to avoid showing duplicates in some worklist results
            // we can only apply this workaround when there is exactly one ps class specified
            // fortunately, there are no use cases yet where more than one ps class is specified
            // that require the workaround
            if (args.ProcedureStepClasses.Length == 1)
            {
                var psClass = CollectionUtils.FirstElement(args.ProcedureStepClasses);
                // the proc step class may be set to the more general "ProtocolProcedureStep" so
                // we need to check for both
                if (psClass == typeof(ProtocolAssignmentStep) || psClass == typeof(ProtocolProcedureStep))
                {
                    // when querying for Rejected protocols, only show the most recent ProtocolAssignmentStep
                    // There may be many ProtocolAssignmentStep if a protocol is rejected, resubmitted and rejected again.
                    // For rejected protocols, the condition "pr.Status not in ('RJ')" is always false.  So the max(EndTime) condition is used
                    // For non-rejected protocols, the first condition is always true, and the max(EndTime) condition is never used.
                    query.Conditions.Add(ConditionMostRecentProtocolAssignmentStepIfRejected);
                }
            }
        }
		public override void AddRootQuery(HqlProjectionQuery query, QueryBuilderArgs args)
		{
			base.AddRootQuery(query, args);

			var from = query.Froms[0];	// this would be added by the base.AddWorklistRootQuery call

			// join protocol object, because may have criteria on this object
			from.Joins.Add(HqlConstants.JoinProtocol);

			// check if we need to apply the "most recent step" condition
			// this is essentially a workaround to avoid showing duplicates in some worklist results
			// we can only apply this workaround when there is exactly one ps class specified
			// fortunately, there are no use cases yet where more than one ps class is specified
			// that require the workaround
			if (args.ProcedureStepClasses.Length == 1)
			{
				var psClass = CollectionUtils.FirstElement(args.ProcedureStepClasses);
				// the proc step class may be set to the more general "ProtocolProcedureStep" so
				// we need to check for both
				if (psClass == typeof(ProtocolAssignmentStep) || psClass == typeof(ProtocolProcedureStep))
				{
					// when querying for Rejected protocols, only show the most recent ProtocolAssignmentStep
					// There may be many ProtocolAssignmentStep if a protocol is rejected, resubmitted and rejected again.
					// For rejected protocols, the condition "pr.Status not in ('RJ')" is always false.  So the max(EndTime) condition is used
					// For non-rejected protocols, the first condition is always true, and the max(EndTime) condition is never used.
					query.Conditions.Add(ConditionMostRecentProtocolAssignmentStepIfRejected);
				}
			}
		}
Esempio n. 5
0
		/// <summary>
		/// Adds criteria to the query (the 'where' clause).
		/// </summary>
		/// <param name="query"></param>
		/// <param name="args"></param>
		public virtual void AddCriteria(HqlProjectionQuery query, QueryBuilderArgs args)
		{
			QueryBuilderHelpers.AddCriteriaToQuery(HqlConstants.WorklistItemQualifier, args.Criteria, query, RemapHqlExpression);

			// modify the query to workaround some NHibernate bugs
			QueryBuilderHelpers.NHibernateBugWorkaround(query.Froms[0], query.Conditions, a => a);
		}
Esempio n. 6
0
        /// <summary>
        /// Query result tuples are passed through this method in order to perform
        /// any pre-processing.
        /// </summary>
        /// <param name="tuple"></param>
        /// <param name="args"></param>
        /// <returns></returns>
        public object[] PreProcessResult(object[] tuple, QueryBuilderArgs args)
        {
            // assume we will return a tuple of the same dimension as the input
            // therefore, we just map field for field, calling to PreProcessResultField on each field
            var projection = args.Projection;

            for (var i = 0; i < projection.Fields.Count; i++)
            {
                tuple[i] = PreProcessResultField(tuple[i], projection.Fields[i]);
            }
            return(tuple);
        }
Esempio n. 7
0
        /// <summary>
        /// Establishes the root query (the 'from' clause and any 'join' clauses).
        /// </summary>
        /// <param name="query"></param>
        /// <param name="args"></param>
        public override void AddRootQuery(HqlProjectionQuery query, QueryBuilderArgs args)
        {
            var procedureStepClasses = args.ProcedureStepClasses;

            // if we have 1 procedure step class, we can say "from x"
            // otherwise we need to say "from ProcedureStep where ps.class = ..."
            if (procedureStepClasses.Length == 1)
            {
                var procStepClass = CollectionUtils.FirstElement(procedureStepClasses);
                query.Froms.Add(new HqlFrom(procStepClass.Name, "ps", WorklistJoins));
            }
            else
            {
                // either 0 or > 1 classes were specified
                query.Froms.Add(new HqlFrom(typeof(ProcedureStep).Name, "ps", WorklistJoins));
                if (procedureStepClasses.Length > 1)
                {
                    query.Conditions.Add(HqlCondition.IsOfClass("ps", procedureStepClasses));
                }
            }
        }
		/// <summary>
		/// Establishes the root query (the 'from' clause and any 'join' clauses).
		/// </summary>
		/// <param name="query"></param>
		/// <param name="args"></param>
		public override void AddRootQuery(HqlProjectionQuery query, QueryBuilderArgs args)
		{
			var procedureStepClasses = args.ProcedureStepClasses;

			// if we have 1 procedure step class, we can say "from x"
			// otherwise we need to say "from ProcedureStep where ps.class = ..."
			if (procedureStepClasses.Length == 1)
			{
				var procStepClass = CollectionUtils.FirstElement(procedureStepClasses);
				query.Froms.Add(new HqlFrom(procStepClass.Name, "ps", WorklistJoins));
			}
			else
			{
				// either 0 or > 1 classes were specified
				query.Froms.Add(new HqlFrom(typeof(ProcedureStep).Name, "ps", WorklistJoins));
				if(procedureStepClasses.Length > 1)
				{
					query.Conditions.Add(HqlCondition.IsOfClass("ps", procedureStepClasses));
				}
			}
		}
		public override void AddRootQuery(HqlProjectionQuery query, QueryBuilderArgs args)
		{
			base.AddRootQuery(query, args);

			var from = query.Froms[0]; // added by base.AddRootQuery

			// join report/report part object, because may have criteria or projections on this object
			from.Joins.Add(HqlConstants.JoinReportPart);
			from.Joins.Add(HqlConstants.JoinReport);

			// check if we need to apply the "most recent step" condition
			// this is essentially a workaround to avoid showing duplicates in some worklist results
			// we can only apply this workaround when there is exactly one ps class specified
			// fortunately, there are no use cases yet where more than one ps class is specified
			// that require the workaround
			if (args.ProcedureStepClasses.Length == 1)
			{
				var psClass = CollectionUtils.FirstElement(args.ProcedureStepClasses);
				if (psClass == typeof(PublicationStep))
					query.Conditions.Add(ConditionMostRecentPublicationStep);
				if (psClass == typeof(TranscriptionStep))
					query.Conditions.Add(ConditionMostRecentTranscriptionStep);
			}
		}
Esempio n. 10
0
		/// <summary>
		/// Adds a paging restriction to the query (the 'top' or 'limit' clause).
		/// </summary>
		/// <param name="query"></param>
		/// <param name="args"></param>
		public virtual void AddPagingRestriction(HqlProjectionQuery query, QueryBuilderArgs args)
		{
			query.Page = args.Page;
		}
Esempio n. 11
0
		/// <summary>
		/// Adds an item projection to the query (the 'select' clause).
		/// </summary>
		/// <param name="query"></param>
		/// <param name="args"></param>
		public virtual void AddItemProjection(HqlProjectionQuery query, QueryBuilderArgs args)
		{
			query.Selects.AddRange(GetWorklistItemSelects(args.Projection));
		}
Esempio n. 12
0
		/// <summary>
		/// Adds a count projection to the query (e.g. 'select count(*)').
		/// </summary>
		/// <param name="query"></param>
		/// <param name="args"></param>
		public virtual void AddCountProjection(HqlProjectionQuery query, QueryBuilderArgs args)
		{
			query.Selects.AddRange(HqlConstants.DefaultCountProjection);
		}
Esempio n. 13
0
		/// <summary>
		/// Adds ordering to the query (the 'rder by' clause).
		/// </summary>
		/// <param name="query"></param>
		/// <param name="args"></param>
		public virtual void AddOrdering(HqlProjectionQuery query, QueryBuilderArgs args)
		{
			QueryBuilderHelpers.AddOrderingToQuery(HqlConstants.WorklistItemQualifier, query, args.Criteria, RemapHqlExpression);
		}
 /// <summary>
 /// Establishes the root query (the 'from' clause and any 'join' clauses).
 /// </summary>
 /// <param name="query"></param>
 /// <param name="args"></param>
 public override void AddRootQuery(HqlProjectionQuery query, QueryBuilderArgs args)
 {
     query.Froms.Add(DefaultFrom);
 }
Esempio n. 15
0
 /// <summary>
 /// Adds the "active procedure step" constraint (affects the 'from' clause).
 /// </summary>
 /// <param name="query"></param>
 /// <param name="args"></param>
 public void AddActiveProcedureStepConstraint(HqlProjectionQuery query, QueryBuilderArgs args)
 {
     query.Conditions.Add(HqlConstants.ConditionActiveProcedureStep);
 }
Esempio n. 16
0
 /// <summary>
 /// Adds a count projection to the query (e.g. 'select count(*)').
 /// </summary>
 /// <param name="query"></param>
 /// <param name="args"></param>
 public virtual void AddCountProjection(HqlProjectionQuery query, QueryBuilderArgs args)
 {
     query.Selects.AddRange(HqlConstants.DefaultCountProjection);
 }
Esempio n. 17
0
 /// <summary>
 /// Constrains the patient profile to match the performing facility.
 /// </summary>
 /// <param name="query"></param>
 /// <param name="args"></param>
 public override void AddConstrainPatientProfile(HqlProjectionQuery query, QueryBuilderArgs args)
 {
     // constrain patient profile to performing facility
     query.Conditions.Add(HqlConstants.ConditionConstrainPatientProfile);
 }
Esempio n. 18
0
 /// <summary>
 /// Constrains the patient profile to match the performing facility.
 /// </summary>
 /// <param name="query"></param>
 /// <param name="args"></param>
 public override void AddConstrainPatientProfile(HqlProjectionQuery query, QueryBuilderArgs args)
 {
     // calling this method on this class would not make any sense
     throw new InvalidOperationException();
 }
Esempio n. 19
0
        /// <summary>
        /// Establishes the root query (the 'from' clause and any 'join' clauses).
        /// </summary>
        /// <param name="query"></param>
        /// <param name="args"></param>
        public override void AddRootQuery(HqlProjectionQuery query, QueryBuilderArgs args)
        {
            query.Froms.Add(DefaultFrom);

            // do not constrain patient profile
        }
Esempio n. 20
0
		/// <summary>
		/// Constrains the patient profile to match the performing facility.
		/// </summary>
		/// <param name="query"></param>
		/// <param name="args"></param>
		public override void AddConstrainPatientProfile(HqlProjectionQuery query, QueryBuilderArgs args)
		{
			// calling this method on this class would not make any sense
			throw new InvalidOperationException();
		}
Esempio n. 21
0
		/// <summary>
		/// Establishes the root query (the 'from' clause and any 'join' clauses).
		/// </summary>
		/// <param name="query"></param>
		/// <param name="args"></param>
		public override void AddRootQuery(HqlProjectionQuery query, QueryBuilderArgs args)
		{
			query.Froms.Add(DefaultFrom);

			// do not constrain patient profile
		}
Esempio n. 22
0
 /// <summary>
 /// Constrains the patient profile to match the performing facility.
 /// </summary>
 /// <param name="query"></param>
 /// <param name="args"></param>
 public abstract void AddConstrainPatientProfile(HqlProjectionQuery query, QueryBuilderArgs args);
Esempio n. 23
0
 /// <summary>
 /// Establishes the root query (the 'from' clause and any 'join' clauses).
 /// </summary>
 /// <param name="query"></param>
 /// <param name="args"></param>
 public abstract void AddRootQuery(HqlProjectionQuery query, QueryBuilderArgs args);
Esempio n. 24
0
 /// <summary>
 /// Adds ordering to the query (the 'rder by' clause).
 /// </summary>
 /// <param name="query"></param>
 /// <param name="args"></param>
 public virtual void AddOrdering(HqlProjectionQuery query, QueryBuilderArgs args)
 {
     QueryBuilderHelpers.AddOrderingToQuery(HqlConstants.WorklistItemQualifier, query, args.Criteria, RemapHqlExpression);
 }
Esempio n. 25
0
		/// <summary>
		/// Query result tuples are passed through this method in order to perform
		/// any pre-processing.
		/// </summary>
		/// <param name="tuple"></param>
		/// <param name="args"></param>
		/// <returns></returns>
		public object[] PreProcessResult(object[] tuple, QueryBuilderArgs args)
		{
			// assume we will return a tuple of the same dimension as the input
			// therefore, we just map field for field, calling to PreProcessResultField on each field
			var projection = args.Projection;
			for (var i = 0; i < projection.Fields.Count; i++)
			{
				tuple[i] = PreProcessResultField(tuple[i], projection.Fields[i]);
			}
			return tuple;
		}
Esempio n. 26
0
 /// <summary>
 /// Adds an item projection to the query (the 'select' clause).
 /// </summary>
 /// <param name="query"></param>
 /// <param name="args"></param>
 public virtual void AddItemProjection(HqlProjectionQuery query, QueryBuilderArgs args)
 {
     query.Selects.AddRange(GetWorklistItemSelects(args.Projection));
 }
Esempio n. 27
0
		/// <summary>
		/// Establishes the root query (the 'from' clause and any 'join' clauses).
		/// </summary>
		/// <param name="query"></param>
		/// <param name="args"></param>
		public override void AddRootQuery(HqlProjectionQuery query, QueryBuilderArgs args)
		{
			query.Froms.Add(DefaultFrom);
		}
Esempio n. 28
0
		/// <summary>
		/// Establishes the root query (the 'from' clause and any 'join' clauses).
		/// </summary>
		/// <param name="query"></param>
		/// <param name="args"></param>
		public abstract void AddRootQuery(HqlProjectionQuery query, QueryBuilderArgs args);
		/// <summary>
		/// Adds the "active procedure step" constraint (affects the 'from' clause).
		/// </summary>
		/// <param name="query"></param>
		/// <param name="args"></param>
		public void AddActiveProcedureStepConstraint(HqlProjectionQuery query, QueryBuilderArgs args)
		{
			query.Conditions.Add(HqlConstants.ConditionActiveProcedureStep);
		}
Esempio n. 30
0
		/// <summary>
		/// Constrains the patient profile to match the performing facility.
		/// </summary>
		/// <param name="query"></param>
		/// <param name="args"></param>
		public abstract void AddConstrainPatientProfile(HqlProjectionQuery query, QueryBuilderArgs args);
		/// <summary>
		/// Constrains the patient profile to match the performing facility.
		/// </summary>
		/// <param name="query"></param>
		/// <param name="args"></param>
		public override void AddConstrainPatientProfile(HqlProjectionQuery query, QueryBuilderArgs args)
		{
			// constrain patient profile to performing facility
			query.Conditions.Add(HqlConstants.ConditionConstrainPatientProfile);
		}
Esempio n. 32
0
 /// <summary>
 /// Adds a paging restriction to the query (the 'top' or 'limit' clause).
 /// </summary>
 /// <param name="query"></param>
 /// <param name="args"></param>
 public virtual void AddPagingRestriction(HqlProjectionQuery query, QueryBuilderArgs args)
 {
     query.Page = args.Page;
 }