Ejemplo n.º 1
0
        public void should_Get_Pretest_By_Client()
        {
            var encounters = _clientRepository.GetPretest(_clientId).ToList();

            Assert.True(encounters.Any());
            var details = encounters.SelectMany(x => x.Obses).ToList();

            Assert.True(details.Any());
        }
Ejemplo n.º 2
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);
        }