/// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="procedureStepClasses"></param>
 /// <param name="searchCriteria"></param>
 /// <param name="projection"></param>
 /// <param name="includeDegeneratePatientItems"></param>
 /// <param name="includeDegenerateProcedureItems"></param>
 public WorklistItemSearchArgs(
     Type[] procedureStepClasses,
     WorklistItemSearchCriteria[] searchCriteria,
     WorklistItemProjection projection,
     bool includeDegeneratePatientItems,
     bool includeDegenerateProcedureItems)
     : this(procedureStepClasses, searchCriteria, projection, includeDegeneratePatientItems, includeDegenerateProcedureItems, 0)
 {
 }
		/// <summary>
		/// Constructor.
		/// </summary>
		/// <param name="procedureStepClasses"></param>
		/// <param name="searchCriteria"></param>
		/// <param name="projection"></param>
		/// <param name="includeDegeneratePatientItems"></param>
		/// <param name="includeDegenerateProcedureItems"></param>
		public WorklistItemSearchArgs(
			Type[] procedureStepClasses,
			WorklistItemSearchCriteria[] searchCriteria,
			WorklistItemProjection projection,
			bool includeDegeneratePatientItems,
			bool includeDegenerateProcedureItems)
			: this(procedureStepClasses, searchCriteria, projection, includeDegeneratePatientItems, includeDegenerateProcedureItems, 0)
		{
		}
        /// <summary>
        /// Gets the tuple mapping for the specified projection.
        /// </summary>
        /// <param name="projection"></param>
        /// <returns></returns>
        public WorklistItemFieldSetterDelegate[] GetTupleMapping(WorklistItemProjection projection)
        {
            var result = new WorklistItemFieldSetterDelegate[projection.Fields.Count];

            for (var i = 0; i < projection.Fields.Count; i++)
            {
                result[i] = GetFieldSetter(projection.Fields[i]);
            }
            return(result);
        }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="procedureStepClasses"></param>
 /// <param name="searchCriteria"></param>
 /// <param name="projection"></param>
 /// <param name="includeDegeneratePatientItems"></param>
 /// <param name="includeDegenerateProcedureItems"></param>
 /// <param name="threshold"></param>
 public WorklistItemSearchArgs(
     Type[] procedureStepClasses,
     WorklistItemSearchCriteria[] searchCriteria,
     WorklistItemProjection projection,
     bool includeDegeneratePatientItems,
     bool includeDegenerateProcedureItems,
     int threshold)
 {
     ProcedureStepClasses            = procedureStepClasses;
     IncludeDegeneratePatientItems   = includeDegeneratePatientItems;
     IncludeDegenerateProcedureItems = includeDegenerateProcedureItems;
     Threshold      = threshold;
     SearchCriteria = searchCriteria;
     Projection     = projection;
 }
		/// <summary>
		/// Constructor.
		/// </summary>
		/// <param name="procedureStepClasses"></param>
		/// <param name="searchCriteria"></param>
		/// <param name="projection"></param>
		/// <param name="includeDegeneratePatientItems"></param>
		/// <param name="includeDegenerateProcedureItems"></param>
		/// <param name="threshold"></param>
		public WorklistItemSearchArgs(
			Type[] procedureStepClasses,
			WorklistItemSearchCriteria[] searchCriteria,
			WorklistItemProjection projection,
			bool includeDegeneratePatientItems,
			bool includeDegenerateProcedureItems,
			int threshold)
		{
			ProcedureStepClasses = procedureStepClasses;
			IncludeDegeneratePatientItems = includeDegeneratePatientItems;
			IncludeDegenerateProcedureItems = includeDegenerateProcedureItems;
			Threshold = threshold;
			SearchCriteria = searchCriteria;
			Projection = projection;
		}
		/// <summary>
		/// Class constructor.
		/// </summary>
		static WorklistItemProjection()
		{
			// define the base procedure step projection (without the time field)
			_procedureStepBase = new WorklistItemProjection(
				new [] {
					WorklistItemField.ProcedureStep,
					WorklistItemField.ProcedureStepName,
					WorklistItemField.ProcedureStepState,
                    WorklistItemField.Procedure,
                    WorklistItemField.Order,
                    WorklistItemField.Patient,
                    WorklistItemField.PatientProfile,
                    WorklistItemField.Mrn,
                    WorklistItemField.PatientName,
                    WorklistItemField.AccessionNumber,
                    WorklistItemField.Priority,
                    WorklistItemField.PatientClass,
                    WorklistItemField.DiagnosticServiceName,
                    WorklistItemField.ProcedureTypeName,
					WorklistItemField.ProcedurePortable,
					WorklistItemField.ProcedureLaterality,
				});

			// define the base reporting procedure step projection
			_reportingBase = _procedureStepBase.AddFields(
				new [] {
					WorklistItemField.Report,
					WorklistItemField.ReportPartIndex
				});

			// initialize the "search" projections for each type of worklist

			ModalityWorklistSearch = GetDefaultProjection(WorklistItemField.ProcedureScheduledStartTime);

			// need to display the correct time field
			// ProcedureScheduledStartTime seems like a reasonable choice for registration homepage search,
			// as it gives a general sense of when the procedure occurs in time
			RegistrationWorklistSearch = GetDefaultProjection(WorklistItemField.ProcedureScheduledStartTime);

			ReportingWorklistSearch = GetReportingProjection(WorklistItemField.ProcedureStartTime);

			// TODO: this timefield is the value from when this broker was part of ReportingWorklistBroker,
			// but what should it really be?  
			ProtocolWorklistSearch = GetDefaultProjection(WorklistItemField.ProcedureStartTime);

		}
        /// <summary>
        /// Class constructor.
        /// </summary>
        static WorklistItemProjection()
        {
            // define the base procedure step projection (without the time field)
            _procedureStepBase = new WorklistItemProjection(
                new [] {
                WorklistItemField.ProcedureStep,
                WorklistItemField.ProcedureStepName,
                WorklistItemField.ProcedureStepState,
                WorklistItemField.Procedure,
                WorklistItemField.Order,
                WorklistItemField.Patient,
                WorklistItemField.PatientProfile,
                WorklistItemField.Mrn,
                WorklistItemField.PatientName,
                WorklistItemField.AccessionNumber,
                WorklistItemField.Priority,
                WorklistItemField.PatientClass,
                WorklistItemField.DiagnosticServiceName,
                WorklistItemField.ProcedureTypeName,
                WorklistItemField.ProcedurePortable,
                WorklistItemField.ProcedureLaterality,
            });

            // define the base reporting procedure step projection
            _reportingBase = _procedureStepBase.AddFields(
                new [] {
                WorklistItemField.Report,
                WorklistItemField.ReportPartIndex
            });

            // initialize the "search" projections for each type of worklist

            ModalityWorklistSearch = GetDefaultProjection(WorklistItemField.ProcedureScheduledStartTime);

            // need to display the correct time field
            // ProcedureScheduledStartTime seems like a reasonable choice for registration homepage search,
            // as it gives a general sense of when the procedure occurs in time
            RegistrationWorklistSearch = GetDefaultProjection(WorklistItemField.ProcedureScheduledStartTime);

            ReportingWorklistSearch = GetReportingProjection(WorklistItemField.ProcedureStartTime);

            // TODO: this timefield is the value from when this broker was part of ReportingWorklistBroker,
            // but what should it really be?
            ProtocolWorklistSearch = GetDefaultProjection(WorklistItemField.ProcedureStartTime);
        }
 protected override WorklistItemProjection GetProjectionCore(WorklistItemField timeField)
 {
     return(WorklistItemProjection.GetDefaultProjection(timeField));
 }
		/// <summary>
		/// Gets the tuple mapping for the specified projection.
		/// </summary>
		/// <param name="projection"></param>
		/// <returns></returns>
		public WorklistItemFieldSetterDelegate[] GetTupleMapping(WorklistItemProjection projection)
		{
			var result = new WorklistItemFieldSetterDelegate[projection.Fields.Count];
			for (var i = 0; i < projection.Fields.Count; i++)
			{
				result[i] = GetFieldSetter(projection.Fields[i]);
			}
			return result;
		}