public void should_UpdateSync()
        {
            var stages = _clientStageRepository.GetAll().ToList();

            _clientRepository.UpdateSyncStatus(stages);

            _clientRepository = new ClientRepository(_context);
            var syncedClients = _clientRepository.GetAll().ToList();

            Assert.True(syncedClients.First().SyncStatus == SyncStatus.Synced);
        }
示例#2
0
        public void should_ExtractAndStage()
        {
            var clients = _clientStageExtractor.ExtractAndStage().Result;

            Assert.True(clients == 1);
            var stagedClients = _clientStageRepository.GetAll().ToList();

            Assert.True(stagedClients.Count > 0);
            foreach (var clientStage in stagedClients)
            {
                Console.WriteLine(clientStage);
            }
        }
示例#3
0
        public Stats GetStats()
        {
            var all = _clientStageRepository.GetAll().Select(x => new { x.ClientId, x.SyncStatus }).ToList();

            var stats = new Stats(
                all.Count,
                all.Where(x => x.SyncStatus == SyncStatus.Staged).ToList().Count,
                all.Where(x => x.SyncStatus == SyncStatus.SentSuccess).ToList().Count,
                all.Where(x => x.SyncStatus == SyncStatus.SentFail).ToList().Count
                );

            return(stats);
        }
示例#4
0
        public async Task <IEnumerable <ClientPretestStage> > Extract(Guid?htsClientId = null)
        {
            _clientPretestStageRepository.Clear();

            var subscriber = await _subscriberSystemRepository.GetDefaultAsync();

            if (null == subscriber)
            {
                throw new Exception("Default EMR NOT SET");
            }
            var pretestStages = new List <ClientPretestStage>();

            var clientIds = _clientStageRepository.GetAll().Where(x => x.IsIndex).Select(x => x.ClientId).ToList();

            foreach (var clientId in clientIds)
            {
                HtsEncounterType encounterType = HtsEncounterType.Initial;

                //  Client

                var client = _clientRepository.GetClientStates(clientId);
                if (null != client)
                {
                    encounterType = client.IsInAnyState(LiveState.HtsRetestedInc, LiveState.HtsRetestedPos,
                                                        LiveState.HtsRetestedNeg)
                        ? HtsEncounterType.Repeat
                        : HtsEncounterType.Initial;
                }

                //  Pretests

                var pretests = _clientEncounterRepository.GetPretest(clientId).ToList();
                if (pretests.Any())
                {
                    foreach (var finalResult in pretests)
                    {
                        var stage = ClientPretestStage.Create(encounterType, finalResult, subscriber);
                        if (null != stage)
                        {
                            pretestStages.Add(stage);
                        }
                    }
                }
            }

            return(pretestStages);
        }
示例#5
0
        public void should_Sync_Users()
        {
            var count = _service.Sync().Result;

            Assert.True(count > 0);
            var clientStages = _clientStageRepository.GetAll();

            Assert.True(clientStages.Any(x => x.SyncStatus == SyncStatus.Staged));

            var clientRelStages = _clientStageRelationshipRepository.GetAll();

            Assert.True(clientRelStages.Any());

            var clients = _clientRepository.GetAll();

            Assert.True(clients.Any(x => x.SyncStatus == SyncStatus.Synced));

            var pretests = _clientPretestStageRepository.GetAll();

            Assert.True(pretests.Any());

            Console.WriteLine($"synced {count}");
        }