Exemplo n.º 1
0
        public void should_Save_Screening()
        {
            var son = _clients[0];

            _registryService.SaveOrUpdate(son, false);
            _registryService.UpdateRelationShips("Son", _indexId, son.Id);

            var encounter = _memberScreeningService.StartEncounter(_memberscreening.FormId,
                                                                   _memberscreening.EncounterTypeId, son.Id, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(),
                                                                   Guid.NewGuid(), _indexId);
            var screening = Builder <ObsMemberScreening> .CreateNew()
                            .With(x => x.EncounterId   = encounter.Id)
                            .With(x => x.Eligibility   = new Guid("b25eccd4-852f-11e7-bb31-be2e44b06b34"))
                            .With(x => x.IndexClientId = _indexId).Build();

            _memberScreeningService.SaveMemberScreening(screening, son.Id, _indexId);

            var saved = _memberScreeningService.OpenEncounter(encounter.Id);

            Assert.NotNull(saved);
            Assert.AreEqual(son.Id, saved.ClientId);
            Assert.AreEqual(_indexId, saved.IndexClientId);
            var memberscreening = saved.ObsMemberScreenings.FirstOrDefault();

            Assert.NotNull(memberscreening);
            Assert.AreEqual(encounter.Id, memberscreening.EncounterId);
            Assert.AreEqual(new Guid("b25eccd4-852f-11e7-bb31-be2e44b06b34"), memberscreening.Eligibility);
            Console.WriteLine(saved);
        }
        public void Init(string formId, string encounterTypeId, string mode, string clientId, string encounterId, string indexclient)
        {
            // Load Client

            Client = _dashboardService.LoadClient(new Guid(clientId));

            if (null != Client)
            {
                var clientJson = JsonConvert.SerializeObject(Client);
                _settings.AddOrUpdateValue("client", clientJson);
            }

            if (!string.IsNullOrWhiteSpace(indexclient))
            {
                IndexClient = new IndexClientDTO(new Guid(indexclient));
                _settings.AddOrUpdateValue("clientIndex", JsonConvert.SerializeObject(IndexClient));
            }

            // Load or Create Encounter

            if (!string.IsNullOrWhiteSpace(encounterTypeId))
            {
                _settings.AddOrUpdateValue("encounterTypeId", encounterTypeId);
            }

            EncounterTypeId = new Guid(encounterTypeId);


            var hivstatus = _lookupService.GetCategoryItems("HIVStatus", true, "[Select Mode]").ToList();

            HIVStatus = hivstatus;
            _settings.AddOrUpdateValue("lookup.hivstatus", JsonConvert.SerializeObject(hivstatus));
            var eligibility = _lookupService.GetCategoryItems("Eligibility", true, "[Select Outcome]").ToList();

            Eligibility = eligibility;
            _settings.AddOrUpdateValue("lookup.eligibility", JsonConvert.SerializeObject(eligibility));

            if (mode == "new")
            {
                //  New Encounter
                _settings.AddOrUpdateValue("client.ms.mode", "new");
                Encounter = _memberScreeningService.StartEncounter(new Guid(formId), EncounterTypeId, Client.Id, AppProviderId, AppUserId, AppPracticeId, AppDeviceId, IndexClient.Id);
            }
            else
            {
                //  Load Encounter
                _settings.AddOrUpdateValue("client.ms.mode", "open");
                Encounter = _memberScreeningService.OpenEncounter(new Guid(encounterId));
            }

            if (null == Encounter)
            {
                throw new ArgumentException("Encounter has not been Initialized");
            }
            //Store Encounter

            var encounterJson = JsonConvert.SerializeObject(Encounter);

            _settings.AddOrUpdateValue("client.encounter", encounterJson);
        }