public ResourceWrapperFactoryTests() { var serializer = new FhirJsonSerializer(); _rawResourceFactory = new RawResourceFactory(serializer); var dummyRequestContext = new FhirRequestContext( "POST", "https://localhost/Patient", "https://localhost/", Guid.NewGuid().ToString(), new Dictionary <string, StringValues>(), new Dictionary <string, StringValues>()); _fhirRequestContextAccessor = Substitute.For <RequestContextAccessor <IFhirRequestContext> >(); _fhirRequestContextAccessor.RequestContext.Returns(dummyRequestContext); _claimsExtractor = Substitute.For <IClaimsExtractor>(); _compartmentIndexer = Substitute.For <ICompartmentIndexer>(); _searchIndexer = Substitute.For <ISearchIndexer>(); _searchParameterDefinitionManager = Substitute.For <ISearchParameterDefinitionManager>(); _searchParameterDefinitionManager.GetSearchParameterHashForResourceType(Arg.Any <string>()).Returns("hash"); _resourceWrapperFactory = new ResourceWrapperFactory( _rawResourceFactory, _fhirRequestContextAccessor, _searchIndexer, _claimsExtractor, _compartmentIndexer, _searchParameterDefinitionManager, Deserializers.ResourceDeserializer); _nameSearchParameterInfo = new SearchParameterInfo("name", "name", ValueSets.SearchParamType.String, new Uri("https://localhost/searchParameter/name")) { SortStatus = SortParameterStatus.Enabled }; _addressSearchParameterInfo = new SearchParameterInfo("address-city", "address-city", ValueSets.SearchParamType.String, new Uri("https://localhost/searchParameter/address-city")) { SortStatus = SortParameterStatus.Enabled }; _ageSearchParameterInfo = new SearchParameterInfo("age", "age", ValueSets.SearchParamType.Number, new Uri("https://localhost/searchParameter/age")) { SortStatus = SortParameterStatus.Supported }; }
/// <inheritdoc /> public ResourceWrapper Create(ResourceElement resource, bool deleted, bool keepMeta) { RawResource rawResource = _rawResourceFactory.Create(resource, keepMeta); IReadOnlyCollection <SearchIndexEntry> searchIndices = _searchIndexer.Extract(resource); string searchParamHash = _searchParameterDefinitionManager.GetSearchParameterHashForResourceType(resource.InstanceType); IFhirRequestContext fhirRequestContext = _fhirRequestContextAccessor.FhirRequestContext; return(new ResourceWrapper( resource, rawResource, new ResourceRequest(fhirRequestContext.Method, fhirRequestContext.Uri), deleted, searchIndices, _compartmentIndexer.Extract(resource.InstanceType, searchIndices), _claimsExtractor.Extract(), searchParamHash)); }
private async System.Threading.Tasks.Task ProcessPostReindexSingleResourceRequest(ResourceWrapper originalResource, IReadOnlyCollection <SearchIndexEntry> searchIndices) { var hashValue = _searchParameterDefinitionManager.GetSearchParameterHashForResourceType(originalResource.ResourceTypeName); ResourceWrapper updatedResource = new ResourceWrapper( originalResource.ResourceId, originalResource.Version, originalResource.ResourceTypeName, originalResource.RawResource, originalResource.Request, originalResource.LastModified, deleted: false, searchIndices, originalResource.CompartmentIndices, originalResource.LastModifiedClaims, hashValue); await _fhirDataStore.UpdateSearchParameterIndicesAsync(updatedResource, WeakETag.FromVersionId(originalResource.Version), CancellationToken.None); }
public string GetSearchParameterHashForResourceType(string resourceType) { return(_inner.GetSearchParameterHashForResourceType(resourceType)); }