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);
        }
Example #2
0
        public void should_Load()
        {
            Assert.True(_count > 0);
            Assert.False(_extractsContext.HtsClientsExtracts.Any());

            var count = _loader.Load(_extract.Id, _count).Result;

            Assert.True(count > 0);
            _extractsContext = TestInitializer.ServiceProvider.GetService <ExtractsContext>();
            Assert.AreEqual(count, _extractsContext.HtsClientsExtracts.Count());
            Log.Debug($"Temp {_count} Main {_extractsContext.HtsClientsExtracts.Count()}");
        }