public async Task <IEnumerable <ClientStage> > Extract(Guid?htsClientId = null)
        {
            //_clientStageRepository.Clear();

            var subscriber = await _subscriberSystemRepository.GetDefaultAsync();

            if (null == subscriber)
            {
                throw new Exception("Default EMR NOT SET");
            }

            var practices = _practiceRepository.GetAllDefault().ToList();

            var clients = new List <ClientStage>();

            var persons = _personRepository.GetAllClients();

            foreach (var person in persons)
            {
                var client   = ClientStage.Create(person, subscriber);
                var practice = practices.FirstOrDefault(x => x.Id == client.PracticeId);

                if (null != practice)
                {
                    client.SiteCode = practice.Code;
                }

                clients.Add(client);
            }
            return(clients.Where(x => !x.ClientId.IsNullOrEmpty()));
        }
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);
        }
Ejemplo n.º 3
0
        public async Task <IEnumerable <ClientPartnerTracingStage> > Extract(Guid?htsClientId = null)
        {
            var subscriber = await _subscriberSystemRepository.GetDefaultAsync();

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

            var encounters = _clientEncounterRepository.GetPartnerTracing(htsClientId);

            foreach (var encounter in encounters)
            {
                clients.AddRange(ClientPartnerTracingStage.Create(encounter, subscriber));
            }

            return(clients.Where(x => !x.Id.IsNullOrEmpty()));
        }
        public async Task <IEnumerable <ClientStageRelationship> > Extract(Guid?htsClientId = null)
        {
            _clientStageRelationshipRepository.Clear();

            var subscriber = await _subscriberSystemRepository.GetDefaultAsync();

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

            var indexRelations = _clientRelationshipRepository.GetIndexRelations();

            foreach (var relationship in indexRelations)
            {
                clients.Add(ClientStageRelationship.Create(relationship, subscriber));
            }

            return(clients.Where(x => !x.Id.IsNullOrEmpty()));
        }