public void should_Sync_Multiple_New_Facility() { var practices = Builder <Practice> .CreateListOfSize(3).All() .With(x => x.Code = DateTime.Now.Ticks.ToString()) .With(x => x.CountyId = 47) .With(x => x.PracticeTypeId = string.Empty) .With(x => x.IsDefault == false) .Build(); practices[2].IsDefault = true; Console.WriteLine($"{practices[2]} <{practices[2].IsDefault}>"); _practiceRepository.Sync(practices); _practiceRepository = new PracticeRepository(_context); foreach (var practice in practices) { var facility = _practiceRepository.Get(practice.Id); Assert.IsNotNull(facility); Assert.AreEqual("Facility", facility.PracticeTypeId); Console.WriteLine($"{facility} [{facility.IsDefault}]"); } var facilities = _practiceRepository.GetAll().ToList(); Assert.True(facilities.Where(x => x.IsDefault).ToList().Count == 1); }
public void Sync(Guid practiceId, ClientInfo client) { var practice = _practiceRepository.Get(practiceId); if (null == practice) { throw new ArgumentException("Facility is not Registered!"); } //person var personInfo = client.Person; var exisitngPerson = _personRepository.Get(personInfo.Id); if (null == exisitngPerson) { var person = Person.CreateClient(personInfo); _personRepository.Insert(person); _personRepository.Save(); //client var cient = Client.Create(client, practiceId, person.Id); _clientRepository.Insert(cient); _clientRepository.Save(); } else { exisitngPerson.UpdateClient(personInfo); _personRepository.Update(exisitngPerson); _personRepository.Save(); var existingClient = exisitngPerson.Clients.FirstOrDefault(x => x.Id == client.Id); if (null != existingClient) { existingClient.Update(client); _clientRepository.Update(existingClient); } else { var cient = Client.Create(client, practiceId, exisitngPerson.Id); _clientRepository.Insert(cient); } _clientRepository.Save(); } }
public void EnrollDevicePractice(List <Practice> practices) { foreach (var practice in practices) { var existingPractice = _practiceRepository.Get(practice.Id); if (null == existingPractice) { Log.Debug($"Enrolling new practice {practice}"); practice.MakeFacility(); _practiceRepository.InsertOrUpdate(practice); _practiceRepository.Save(); } } }
public void should_Sync_New_Facility() { var practice = Builder <Practice> .CreateNew() .With(x => x.Code = DateTime.Now.Ticks.ToString()) .With(x => x.CountyId = 47) .With(x => x.PracticeTypeId = string.Empty) .Build(); _practiceRepository.Sync(practice); _practiceRepository.Save(); var facility = _practiceRepository.Get(practice.Id); Assert.IsNotNull(facility); Assert.AreEqual("Facility", facility.PracticeTypeId); Console.WriteLine(facility); }
public void Sync(EncounterInfo encounterInfo) { //Check pracitce var practice = _practiceRepository.Get(encounterInfo.PracticeId); if (null == practice) { throw new ArgumentException("Facility is not registered"); } //Check client var client = _clientRepository.Get(encounterInfo.ClientId); if (null == client) { throw new ArgumentException("Client is not registered"); } var encounter = _encounterRepository.Get(encounterInfo.Id); if (null == encounter) { encounter = Encounter.Create(encounterInfo); _encounterRepository.Insert(encounter); _encounterRepository.Save(); var obs = Obs.Create(encounterInfo); _obsRepository.Insert(obs); _obsRepository.Save(); } else { encounter.Update(encounterInfo); _encounterRepository.Update(encounter); _encounterRepository.Save(); var obs = Obs.Create(encounterInfo); _obsRepository.ReplaceAll(encounter.Id, obs); _obsRepository.Save(); } }
private async Task <string> GetPractice() { var practice = await _practiceRepository.Get(); return(JsonConvert.SerializeObject(practice)); }