public async Task DeleteAsync(Guid id) { Organization organization = await GetOrganizationFromFHIRAsync(id.ToString()).ConfigureAwait(false); if (organization != null) { await _client.DeleteAsync(organization).ConfigureAwait(false); } }
public async Task UpdateDelete_UsingResourceIdentity_ResultReturned() { var client = new FhirClient(_endpoint) { PreferredFormat = ResourceFormat.Json, ReturnFullResource = true }; var pat = new Patient() { Name = new List <HumanName>() { new HumanName() { Given = new List <string>() { "test_given" }, Family = new List <string>() { "test_family" }, } }, Id = "async-test-patient" }; // Create the patient Console.WriteLine("Creating patient..."); Patient p = await client.UpdateAsync <Patient>(pat); Assert.IsNotNull(p); // Refresh the patient Console.WriteLine("Refreshing patient..."); await client.RefreshAsync(p); // Delete the patient Console.WriteLine("Deleting patient..."); await client.DeleteAsync(p); Console.WriteLine("Reading patient..."); Func <Task> act = async() => { await client.ReadAsync <Patient>(new ResourceIdentity("/Patient/async-test-patient")); }; // VERIFY // Assert.ThrowsException <FhirOperationException>(act, "the patient is no longer on the server"); Console.WriteLine("Test Completed"); }
/// <summary> /// Delete Patient by identifier /// </summary> /// <param name="identifier"></param> /// <returns>Success/Fail</returns> public async Task <bool> DeletePatientByIdentifierAsync(string identifier) { var patient = await SearchByIdentifierAsync(identifier).ConfigureAwait(false); if (patient == null) { return(false); } await _fhirClient.DeleteAsync(patient).ConfigureAwait(false); return(true); }
public void PatientCreationUpdateDeletion() { Patient patient = null !; "When creating a patient resource".x( async() => patient = await _client.CreateAsync( new Patient { Active = true, Name = { new HumanName { Family = "Tester", Given = new[]{ "Anne" }, Use = HumanName.NameUse.Usual } } }).ConfigureAwait(false)); "Then patient has id".x(() => Assert.NotNull(patient.Id)); "And patient can be updated".x( async() => { patient.BirthDateElement = new Date(1970, 1, 1); patient = await _client.UpdateAsync(patient).ConfigureAwait(false); Assert.NotNull(patient.BirthDate); }); "and can be found when searched".x( async() => { var p = await _client.SearchByIdAsync <Patient>(patient.Id).ConfigureAwait(false); Assert.NotEmpty(p.GetResources()); }); "When patient can be deleted".x( async() => { await _client.DeleteAsync(patient).ConfigureAwait(false); }); "Then cannot be found".x( async() => { var p = await _client.SearchByIdAsync <Patient>(patient.Id).ConfigureAwait(false); Assert.Empty(p.GetResources()); }); }
public void CreateEditDeleteAsync() { var furore = new Organization { Name = "Furore", Identifier = new List<Identifier> { new Identifier("http://hl7.org/test/1", "3141") }, Telecom = new List<Contact> { new Contact { System = Contact.ContactSystem.Phone, Value = "+31-20-3467171" } } }; FhirClient client = new FhirClient(testEndpoint); var tags = new List<Tag> { new Tag("http://nu.nl/testname", Tag.FHIRTAGSCHEME_GENERAL, "TestCreateEditDelete") }; var fe = client.CreateAsync<Organization>(furore, tags: tags, refresh: true).Result; Assert.IsNotNull(furore); Assert.IsNotNull(fe); Assert.IsNotNull(fe.Id); Assert.IsNotNull(fe.SelfLink); Assert.AreNotEqual(fe.Id, fe.SelfLink); Assert.IsNotNull(fe.Tags); Assert.AreEqual(1, fe.Tags.Count(), "Tag count on new organization record don't match"); Assert.AreEqual(fe.Tags.First(), tags[0]); createdTestOrganizationUrl = fe.Id; fe.Resource.Identifier.Add(new Identifier("http://hl7.org/test/2", "3141592")); var fe2 = client.UpdateAsync(fe, refresh: true).Result; Assert.IsNotNull(fe2); Assert.AreEqual(fe.Id, fe2.Id); Assert.AreNotEqual(fe.SelfLink, fe2.SelfLink); Assert.AreEqual(2, fe2.Resource.Identifier.Count); Assert.IsNotNull(fe2.Tags); Assert.AreEqual(1, fe2.Tags.Count(), "Tag count on updated organization record don't match"); Assert.AreEqual(fe2.Tags.First(), tags[0]); fe.Resource.Identifier.Add(new Identifier("http://hl7.org/test/3", "3141592")); var fe3 = client.UpdateAsync(fe2.Id, fe.Resource, refresh: true).Result; Assert.IsNotNull(fe3); Assert.AreEqual(3, fe3.Resource.Identifier.Count); client.DeleteAsync(fe3).Wait(); try { // Get most recent version fe = client.ReadAsync<Organization>(new ResourceIdentity(fe.Id)).Result; Assert.Fail(); } catch { Assert.IsTrue(client.LastResponseDetails.Result == HttpStatusCode.Gone); } }
public void CreateEditDeleteAsync() { var furore = new Organization { Name = "Furore", Identifier = new List <Identifier> { new Identifier("http://hl7.org/test/1", "3141") }, Telecom = new List <Contact> { new Contact { System = Contact.ContactSystem.Phone, Value = "+31-20-3467171" } } }; FhirClient client = new FhirClient(testEndpoint); var tags = new List <Tag> { new Tag("http://nu.nl/testname", Tag.FHIRTAGSCHEME_GENERAL, "TestCreateEditDelete") }; var fe = client.CreateAsync <Organization>(furore, tags: tags, refresh: true).Result; Assert.IsNotNull(furore); Assert.IsNotNull(fe); Assert.IsNotNull(fe.Id); Assert.IsNotNull(fe.SelfLink); Assert.AreNotEqual(fe.Id, fe.SelfLink); Assert.IsNotNull(fe.Tags); Assert.AreEqual(1, fe.Tags.Count(), "Tag count on new organization record don't match"); Assert.AreEqual(fe.Tags.First(), tags[0]); createdTestOrganizationUrl = fe.Id; fe.Resource.Identifier.Add(new Identifier("http://hl7.org/test/2", "3141592")); var fe2 = client.UpdateAsync(fe, refresh: true).Result; Assert.IsNotNull(fe2); Assert.AreEqual(fe.Id, fe2.Id); Assert.AreNotEqual(fe.SelfLink, fe2.SelfLink); Assert.AreEqual(2, fe2.Resource.Identifier.Count); Assert.IsNotNull(fe2.Tags); Assert.AreEqual(1, fe2.Tags.Count(), "Tag count on updated organization record don't match"); Assert.AreEqual(fe2.Tags.First(), tags[0]); fe.Resource.Identifier.Add(new Identifier("http://hl7.org/test/3", "3141592")); var fe3 = client.UpdateAsync(fe2.Id, fe.Resource, refresh: true).Result; Assert.IsNotNull(fe3); Assert.AreEqual(3, fe3.Resource.Identifier.Count); client.DeleteAsync(fe3).Wait(); try { // Get most recent version fe = client.ReadAsync <Organization>(new ResourceIdentity(fe.Id)).Result; Assert.Fail(); } catch { Assert.IsTrue(client.LastResponseDetails.Result == HttpStatusCode.Gone); } }