public async Task <bool> Handle(ExtractHtsClientTracing request, CancellationToken cancellationToken)
        {
            //Extract
            int found = await _patientSourceExtractor.Extract(request.Extract, request.DatabaseProtocol);


            //Validate
            await _extractValidator.Validate(request.Extract.Id, found, "HtsClientTracingExtracts", "TempHtsClientTracingExtracts");

            //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(HtsClientTracing),
                                                       nameof(ExtractStatus.Loaded),
                                                       found, loaded, rejected, loaded, 0)));

            return(true);
        }
示例#2
0
        public async Task <bool> Handle(ExtractAllergiesChronicIllness request, CancellationToken cancellationToken)
        {
            //Extract
            int found = await _AllergiesChronicIllnessSourceExtractor.Extract(request.Extract, request.DatabaseProtocol);

            //Validate
            await _extractValidator.Validate(request.Extract.Id, found, nameof(AllergiesChronicIllnessExtract), $"{nameof(TempAllergiesChronicIllnessExtract)}s");

            //Load
            int loaded = await _AllergiesChronicIllnessLoader.Load(request.Extract.Id, found, request.DatabaseProtocol.SupportsDifferential);

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


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

            //notify loaded
            DomainEvents.Dispatch(
                new ExtractActivityNotification(request.Extract.Id, new DwhProgress(
                                                    nameof(AllergiesChronicIllnessExtract),
                                                    nameof(ExtractStatus.Loaded),
                                                    found, loaded, rejected, loaded, 0)));

            return(true);
        }
示例#3
0
        public async Task <bool> Handle(ExtractMetricMigration request, CancellationToken cancellationToken)
        {
            //Extract
            int found = await _metricMigrationSourceExtractor.Extract(request.Extract, request.DatabaseProtocol);


            //Validate
            await _extractValidator.Validate(request.Extract.Id, found, "Migration", "TempMetricMigrationExtracts");

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

            int rejected =
                // TODO: CHECK MGS Rejection
                _extractHistoryRepository.ProcessRejected(request.Extract.Id, found - loaded, request.Extract, false);


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

            //notify loaded
            DomainEvents.Dispatch(
                new MgsExtractActivityNotification(request.Extract.Id, new ExtractProgress(
                                                       nameof(MetricMigrationExtract),
                                                       nameof(ExtractStatus.Loaded),
                                                       found, loaded, rejected, loaded, 0)));

            return(true);
        }
        public async Task <bool> Handle(ExtractPatient request, CancellationToken cancellationToken)
        {
            //Extract
            int found = await _patientSourceExtractor.Extract(request.Extract, request.DatabaseProtocol);

            //Check for duplicate patients
            var patientKeys = _tempPatientExtractRepository.GetAll().Select(k => k.PatientPK);
            var distinct    = new HashSet <int?>();
            var duplicates  = new HashSet <int?>();

            foreach (var key in patientKeys)
            {
                if (!distinct.Add(key))
                {
                    duplicates.Add(key);
                }
            }

            if (duplicates.Any())
            {
                var readDuplicates = string.Join(", ", duplicates.ToArray());
                throw new DuplicatePatientException($"Duplicate patient(s) with PatientPK(s) {readDuplicates} found");
            }

            //Validate
            await _extractValidator.Validate(request.Extract.Id, found, nameof(PatientExtract), $"{nameof(TempPatientExtract)}s");

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

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


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

            //notify loaded
            DomainEvents.Dispatch(
                new ExtractActivityNotification(request.Extract.Id, new DwhProgress(
                                                    nameof(PatientExtract),
                                                    nameof(ExtractStatus.Loaded),
                                                    found, loaded, rejected, loaded, 0)));

            return(true);
        }