/// <summary>
 /// Initializes a new instance of the <see cref="CacheResult"/> class based on the provided resources and searchProgress.
 /// </summary>
 /// <param name="searchProgress">the search progress.</param>
 /// <param name="cacheSize">the cached data size.</param>
 /// <param name="resources">the resources.</param>
 public CacheResult(
     SearchProgress searchProgress = null,
     int cacheSize = 0,
     Dictionary <string, List <JObject> > resources = null)
 {
     SearchProgress = searchProgress ?? new SearchProgress();
     CacheSize      = cacheSize;
     Resources      = resources ?? new Dictionary <string, List <JObject> >();
 }
        // TODO: Refine this together with TaskExecutor class. Maybe this is more like a task class.
        public TaskContext(
            string id,
            int taskIndex,
            string jobId,
            FilterScope filterScope,
            DataPeriod dataPeriod,
            DateTimeOffset since,
            IList <TypeFilter> typeFilters,
            IList <PatientWrapper> patients             = null,
            SearchProgress searchProgress               = null,
            Dictionary <string, int> outputFileIndexMap = null,
            Dictionary <string, int> searchCount        = null,
            Dictionary <string, int> processedCount     = null,
            Dictionary <string, int> skippedCount       = null,
            bool isCompleted = false)
        {
            // immutable fields
            Id          = id;
            TaskIndex   = taskIndex;
            JobId       = jobId;
            FilterScope = filterScope;
            DataPeriod  = dataPeriod;
            Since       = since;
            TypeFilters = typeFilters;
            Patients    = patients;

            // fields to record progress
            SearchProgress     = searchProgress ?? new SearchProgress();
            OutputFileIndexMap = outputFileIndexMap ?? new Dictionary <string, int>();
            IsCompleted        = isCompleted;

            // statistical fields
            SearchCount    = searchCount ?? new Dictionary <string, int>();
            ProcessedCount = processedCount ?? new Dictionary <string, int>();
            SkippedCount   = skippedCount ?? new Dictionary <string, int>();
        }