public void should_Extract()
        {
            var clients = _stageExtractor.Extract().Result.ToList();

            Assert.True(clients.Count > 0);
            foreach (var clientStage in clients)
            {
                Console.WriteLine(clientStage);
            }
        }
        private async Task <IndexClientMessage> CreateNonPretestEncounters(MESSAGE_HEADER header, PATIENT_IDENTIFICATION pid, ClientStage stagedClient, ClientPretestStage lastPretest, params LoadAction[] actions)
        {
            ENCOUNTERS encounter = null;

            //  PLACER_DETAIL

            var lastplacerDetail = PLACER_DETAIL.Create(lastPretest.UserId, lastPretest.Id);

            //  NewReferral
            NewReferral newReferral = null;

            if (actions.Contains(LoadAction.All) || actions.Contains(LoadAction.Referral))
            {
                var allReferrals = await _clientReferralStageExtractor.Extract(stagedClient.ClientId);

                if (allReferrals.Any())
                {
                    var referrall = allReferrals.LastOrDefault();
                    newReferral = NewReferral.Create(referrall);
                }
            }

            //  NewTracing
            var newTracings = new List <NewTracing>();

            if (actions.Contains(LoadAction.All) || actions.Contains(LoadAction.Tracing))
            {
                var allTracing = await _clientTracingStageExtractor.Extract(stagedClient.ClientId);

                if (allTracing.Any())
                {
                    newTracings = NewTracing.Create(allTracing.ToList());
                }
            }

            // NewLinkage
            NewLinkage newLinkage = null;

            if (actions.Contains(LoadAction.All) || actions.Contains(LoadAction.Linkage))
            {
                var allLinkages = await _clientLinkageStageExtractor.Extract(stagedClient.ClientId);

                if (allLinkages.Any())
                {
                    var linkage = allLinkages.LastOrDefault();
                    newLinkage = linkage.HasData ? NewLinkage.Create(linkage) : null;
                }
            }

            if (null == newReferral && !newTracings.Any() && null == newLinkage)
            {
                return(null);
            }

            encounter = ENCOUNTERS.Create(lastplacerDetail, null, null, newReferral, newTracings, newLinkage);

            return(new IndexClientMessage(header,
                                          new List <NEWCLIENT> {
                NEWCLIENT.Create(pid, encounter)
            }, stagedClient.ClientId));
        }