/// <summary> /// Creates a new instance of the host with the given /// </summary> /// <param name="options">Settings for the microservice (location of rabbit, queue names etc)</param> /// <param name="auditor">Optional override for the value specified in <see cref="GlobalOptions.CohortExtractorOptions"/></param> /// <param name="fulfiller">Optional override for the value specified in <see cref="GlobalOptions.CohortExtractorOptions"/></param> public CohortExtractorHost(GlobalOptions options, IAuditExtractions auditor, IExtractionRequestFulfiller fulfiller) : base(options) { _consumerOptions = options.CohortExtractorOptions; _consumerOptions.Validate(); _auditor = auditor; _fulfiller = fulfiller; }
public ExtractionRequestQueueConsumer( CohortExtractorOptions options, IExtractionRequestFulfiller fulfiller, IAuditExtractions auditor, IProjectPathResolver pathResolver, IProducerModel fileMessageProducer, IProducerModel fileMessageInfoProducer) { _options = options; _fulfiller = fulfiller; _auditor = auditor; _resolver = pathResolver; _fileMessageProducer = fileMessageProducer; _fileMessageInfoProducer = fileMessageInfoProducer; }
/// <summary> /// Connects to RDMP platform databases to retrieve extractable catalogues and initializes the <see cref="IExtractionRequestFulfiller"/> (if none /// was specified in the constructor override). /// </summary> /// <param name="repositoryLocator"></param> private void InitializeExtractionSources(IRDMPPlatformRepositoryServiceLocator repositoryLocator) { // Get all extractable catalogues ICatalogue[] catalogues = repositoryLocator .DataExportRepository .GetAllObjects <ExtractableDataSet>() .Select(eds => eds.Catalogue) .ToArray(); if (_auditor == null) { _auditor = ObjectFactory.CreateInstance <IAuditExtractions>(_consumerOptions.AuditorType, typeof(IAuditExtractions).Assembly, repositoryLocator); } if (_auditor == null) { throw new Exception("No IAuditExtractions set"); } if (!_consumerOptions.AllCatalogues) { catalogues = catalogues.Where(c => _consumerOptions.OnlyCatalogues.Contains(c.ID)).ToArray(); } if (_fulfiller == null) { _fulfiller = ObjectFactory.CreateInstance <IExtractionRequestFulfiller>(_consumerOptions.RequestFulfillerType, typeof(IExtractionRequestFulfiller).Assembly, new object[] { catalogues }); } if (_fulfiller == null) { throw new Exception("No IExtractionRequestFulfiller set"); } if (!string.IsNullOrWhiteSpace(_consumerOptions.ModalityRoutingRegex)) { _fulfiller.ModalityRoutingRegex = new Regex(_consumerOptions.ModalityRoutingRegex); } if (!string.IsNullOrWhiteSpace(_consumerOptions.RejectorType)) { _fulfiller.Rejectors.Add(ObjectFactory.CreateInstance <IRejector>(_consumerOptions.RejectorType, typeof(IRejector).Assembly)); } if (_consumerOptions.RejectColumnInfos != null) { foreach (var id in _consumerOptions.RejectColumnInfos) { _fulfiller.Rejectors.Add(new ColumnInfoValuesRejector(repositoryLocator.CatalogueRepository.GetObjectByID <ColumnInfo>(id))); } } if (_consumerOptions.Blacklists != null) { foreach (int id in _consumerOptions.Blacklists) { var cata = repositoryLocator.CatalogueRepository.GetObjectByID <Catalogue>(id); var rejector = new BlacklistRejector(cata); _fulfiller.Rejectors.Add(rejector); } } if (!string.IsNullOrWhiteSpace(_consumerOptions.ProjectPathResolverType)) { _pathResolver = ObjectFactory.CreateInstance <IProjectPathResolver>(_consumerOptions.ProjectPathResolverType, typeof(IProjectPathResolver).Assembly, repositoryLocator); } else { _pathResolver = new DefaultProjectPathResolver(); } }
public IEnumerable <ExtractImageCollection> GetAllMatchingFiles(ExtractionRequestMessage message, IAuditExtractions auditor) { var queries = new List <QueryToExecute>(); foreach (var c in GetCataloguesFor(message)) { var query = GetQueryToExecute(c, message); if (query != null) { queries.Add(query); auditor.AuditCatalogueUse(message, c.Catalogue); } } Logger.Debug($"Found {queries.Count} Catalogues which support extracting based on '{message.KeyTag}'"); if (queries.Count == 0) { throw new Exception($"Couldn't find any compatible Catalogues to run extraction queries against for query {message}"); } List <IRejector> rejectorsToUse = message.IsNoFilterExtraction ? new List <IRejector>() : Rejectors; foreach (string valueToLookup in message.ExtractionIdentifiers) { var results = new ExtractImageCollection(valueToLookup); foreach (QueryToExecute query in queries) { foreach (QueryToExecuteResult result in query.Execute(valueToLookup, rejectorsToUse)) { if (!results.ContainsKey(result.SeriesTagValue)) { results.Add(result.SeriesTagValue, new HashSet <QueryToExecuteResult>()); } results[result.SeriesTagValue].Add(result); } } yield return(results); } }
public IEnumerable <ExtractImageCollection> GetAllMatchingFiles(ExtractionRequestMessage message, IAuditExtractions auditor) { Logger.Debug("Found " + message.KeyTag); foreach (string valueToLookup in message.ExtractionIdentifiers) { var results = new ExtractImageCollection(valueToLookup); string filePathValue = valueToLookup; // "img001.dcm"; string studyTagValue = "2"; string seriesTagValue = "3"; string instanceTagValue = "4"; bool rejection = false; string rejectionReason = ""; var result = new QueryToExecuteResult(filePathValue, studyTagValue, seriesTagValue, instanceTagValue, rejection, rejectionReason); if (!results.ContainsKey(result.SeriesTagValue)) { results.Add(result.SeriesTagValue, new HashSet <QueryToExecuteResult>()); } results[result.SeriesTagValue].Add(result); yield return(results); } }