Esempio n. 1
0
        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> CreatePretestEncounters(MESSAGE_HEADER header,
                                                                        PATIENT_IDENTIFICATION pid, ClientStage stagedClient, ClientPretestStage pretest,
                                                                        params LoadAction[] actions)
        {
            ENCOUNTERS encounter = null;

            //  PLACER_DETAIL
            var placerDetail = PLACER_DETAIL.Create(pretest.UserId, pretest.Id);

            //  PRE_TEST
            PRE_TEST preTest = null;

            if (actions.Contains(LoadAction.All) || actions.Contains(LoadAction.Pretest))
            {
                preTest = PRE_TEST.Create(pretest);
            }

            //  HIV_TESTS
            HIV_TESTS hivTests = null;

            if (actions.Contains(LoadAction.All) || actions.Contains(LoadAction.Testing))
            {
                var allfinalTests = await _clientFinalTestStageExtractor.Extract(stagedClient.ClientId);

                var alltests = await _clientTestingStageExtractor.Extract();

                var finalTest = allfinalTests.Where(x => x.PretestEncounterId == pretest.Id).ToList()
                                .LastOrDefault();

                var tests = alltests.Where(x => x.PretestEncounterId == pretest.Id).ToList();

                if (null != finalTest && tests.Any())
                {
                    hivTests = HIV_TESTS.Create(tests, finalTest);
                }
            }

            // GET THE LAST ONE


            encounter = ENCOUNTERS.Create(placerDetail, preTest, hivTests, null, new List <NewTracing>(), null);

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