Example #1
0
 public void SetUp()
 {
     _loader    = TestInitializer.ServiceProvider.GetService <IHtsClientsLoader>();
     _extractor = TestInitializer.ServiceProvider.GetService <IHtsClientsSourceExtractor>();
     _extract   = _extracts.First(x => x.Name.IsSameAs("HtsClient"));
     _count     = _extractor.Extract(_extract, _protocol).Result;
 }
        public async Task <bool> Handle(ExtractHtsClients request, CancellationToken cancellationToken)
        {
            //Extract
            int found = await _patientSourceExtractor.Extract(request.Extract, request.DatabaseProtocol);


            //Validate
            await _extractValidator.Validate(request.Extract.Id, found, "HtsClientsExtracts", "TempHtsClientsExtracts");

            //Load
            int loaded = await _patientLoader.Load(request.Extract.Id, found);

            int rejected =
                _extractHistoryRepository.ProcessRejected(request.Extract.Id, found - loaded, request.Extract);


            _extractHistoryRepository.ProcessExcluded(request.Extract.Id, rejected, request.Extract);

            //notify loaded
            DomainEvents.Dispatch(
                new HtsExtractActivityNotification(request.Extract.Id, new ExtractProgress(
                                                       nameof(HtsClients) + "Extracts",
                                                       nameof(ExtractStatus.Loaded),
                                                       found, loaded, rejected, loaded, 0)));

            return(true);
        }
        public void should_Extract(string name)
        {
            Assert.False(_extractsContext.TempHtsClientsExtracts.Any());
            var extract = _extracts.First(x => x.Name.IsSameAs(name));
            var count   = _extractor.Extract(extract, _protocol).Result;

            _extractsContext = TestInitializer.ServiceProvider.GetService <ExtractsContext>();
            Assert.AreEqual(count, _extractsContext.TempHtsClientsExtracts.Count());
            Log.Debug($"extracted {_extractsContext.TempHtsClientsExtracts.Count()}");
        }