public async Task GivenAnUpdatedResource_WhenUpdatingSearchParameterIndexAsync_ThenResourceMetadataIsUnchanged() { ResourceElement patientResource = CreatePatientResourceElement("Patient", Guid.NewGuid().ToString()); SaveOutcome upsertResult = await Mediator.UpsertResourceAsync(patientResource); SearchParameter searchParam = null; const string searchParamName = "newSearchParam"; try { searchParam = await CreatePatientSearchParam(searchParamName, SearchParamType.String, "Patient.name"); ISearchValue searchValue = new StringSearchValue(searchParamName); (ResourceWrapper original, ResourceWrapper updated) = await CreateUpdatedWrapperFromExistingPatient(upsertResult, searchParam, searchValue); await _dataStore.UpdateSearchIndexForResourceAsync(updated, WeakETag.FromVersionId(original.Version), CancellationToken.None); // Get the reindexed resource from the database var resourceKey1 = new ResourceKey(upsertResult.RawResourceElement.InstanceType, upsertResult.RawResourceElement.Id, upsertResult.RawResourceElement.VersionId); ResourceWrapper reindexed = await _dataStore.GetAsync(resourceKey1, CancellationToken.None); VerifyReindexedResource(original, reindexed); } finally { if (searchParam != null) { _searchParameterDefinitionManager.DeleteSearchParameter(searchParam.ToTypedElement()); await _fixture.TestHelper.DeleteSearchParameterStatusAsync(searchParam.Url, CancellationToken.None); } } }
public async Task GivenAnUpdatedResource_WhenUpdateSearchIndexForResourceAsync_ThenResourceGetsUpdated() { ResourceElement patientResource = Samples.GetJsonSample("Patient"); SaveOutcome upsertResult = await Mediator.UpsertResourceAsync(patientResource); (FhirCosmosResourceWrapper original, ResourceWrapper updated) = await CreateUpdatedWrapperFromExistingResource(upsertResult); ResourceWrapper replaceResult = await _dataStore.UpdateSearchIndexForResourceAsync(updated, original.ETag, CancellationToken.None); Assert.Equal(original.ResourceId, replaceResult.ResourceId); Assert.Equal(original.Version, replaceResult.Version); Assert.Equal(original.ResourceTypeName, replaceResult.ResourceTypeName); Assert.Equal(original.LastModified, replaceResult.LastModified); }
private async System.Threading.Tasks.Task ProcessPostReindexSingleResourceRequest(ResourceWrapper originalResource, IReadOnlyCollection <SearchIndexEntry> searchIndices) { ResourceWrapper updatedResource = new ResourceWrapper( originalResource.ResourceId, originalResource.Version, originalResource.ResourceTypeName, originalResource.RawResource, originalResource.Request, originalResource.LastModified, deleted: false, searchIndices, originalResource.CompartmentIndices, originalResource.LastModifiedClaims); await _fhirDataStore.UpdateSearchIndexForResourceAsync(updatedResource, WeakETag.FromVersionId(originalResource.Version), CancellationToken.None); }