diff --git a/src/FhirStore.CommonVersioned/Storage/ResourceStore.cs b/src/FhirStore.CommonVersioned/Storage/ResourceStore.cs index 0bcd56f..b956e23 100644 --- a/src/FhirStore.CommonVersioned/Storage/ResourceStore.cs +++ b/src/FhirStore.CommonVersioned/Storage/ResourceStore.cs @@ -85,10 +85,10 @@ public class ResourceStore : IVersionedResourceStore private Dictionary _executableSubscriptions = new(); /// The supported includes. - private string[] _supportedIncludes = Array.Empty(); + private string[] _supportedIncludes = []; /// The supported reverse includes. - private string[] _supportedRevIncludes = Array.Empty(); + private string[] _supportedRevIncludes = []; /// Gets the keys. /// Type of the string. @@ -525,7 +525,7 @@ public bool TryResolveIdentifier(string system, string value, out Hl7.Fhir.Model ParsedSubscriptionTopic? parsedSubscriptionTopic = null; ParsedSubscription? parsedSubscription = null; - + // perform any mandatory validation switch (source.TypeName) { @@ -585,7 +585,7 @@ public bool TryResolveIdentifier(string system, string value, out Hl7.Fhir.Model source.Meta.Tag = new List(); } - if (!source.Meta.Tag.Any(c => + if (!source.Meta.Tag.Any(c => c.System.Equals("http://hl7.org/fhir/us/core/CodeSystem/us-core-tags", StringComparison.Ordinal) && c.Code.Equals("patient-supplied"))) { @@ -701,8 +701,8 @@ public bool TryResolveIdentifier(string system, string value, out Hl7.Fhir.Model /// [out] The outcome. /// The updated resource, or null if it could not be performed. public Resource? InstanceUpdate( - Resource source, - bool allowCreate, + Resource source, + bool allowCreate, string ifMatch, string ifNoneMatch, HashSet protectedResources, @@ -1409,7 +1409,7 @@ private void PerformSubscriptionTest( { additionalContext.AddRange(reverses); } - } + } SubscriptionEvent subEvent = new() { @@ -1648,7 +1648,7 @@ public void RemoveExecutableSearchParameter(string name) if (_searchParameters.TryGetValue(name, out ModelInfo.SearchParamDefinition? spd)) { - if ((!string.IsNullOrEmpty(spd.Url)) && + if ((!string.IsNullOrEmpty(spd.Url)) && _searchParamUrlsToNames.ContainsKey(spd.Url)) { _ = _searchParamUrlsToNames.Remove(spd.Url); @@ -1757,7 +1757,11 @@ public bool TryGetSearchParamDefinition(string name, [NotNullWhen(true)] out Mod /// An enumerator that allows foreach to be used to process the search includes in this /// collection. /// - public IEnumerable GetSearchIncludes() => _supportedIncludes; + public IEnumerable GetSearchIncludes() => _searchParameters.Values + .Where(sp => sp.Type == SearchParamType.Reference) + .Where(sp => sp.Name != null) + .Select(sp => this._resourceName + ":" + sp.Name!) + .Order(); /// Gets the search reverse includes supported by this store. /// diff --git a/src/FhirStore.CommonVersioned/Storage/VersionedFhirStore.cs b/src/FhirStore.CommonVersioned/Storage/VersionedFhirStore.cs index a96511b..2a85eb2 100644 --- a/src/FhirStore.CommonVersioned/Storage/VersionedFhirStore.cs +++ b/src/FhirStore.CommonVersioned/Storage/VersionedFhirStore.cs @@ -383,7 +383,7 @@ public void Init(TenantConfiguration config) DiscoverInteractionHooks(); // generate our initial capability statement - _ = GenerateCapabilities(new FhirRequestContext(this, "GET", _config.BaseUrl + "/metadata")); + _ = generateCapabilities(new FhirRequestContext(this, "GET", _config.BaseUrl + "/metadata")); // create a timer to check max resource count if we are monitoring that _maxResourceCount = config.MaxResourceCount; @@ -5572,7 +5572,7 @@ private CapabilityStatement GetCapabilities(FhirRequestContext? ctx) { if (_capabilitiesAreStale || (ctx?.Forwarded != null)) { - return GenerateCapabilities(ctx); + return generateCapabilities(ctx); } // bypass read to avoid instance read hooks (firing meta hooks) @@ -5581,9 +5581,8 @@ private CapabilityStatement GetCapabilities(FhirRequestContext? ctx) /// Updates the current capabilities of this store. /// The request context. - /// (Optional) The store. /// The capability statement. - private CapabilityStatement GenerateCapabilities(FhirRequestContext? ctx) + private CapabilityStatement generateCapabilities(FhirRequestContext? ctx) { string root = getBaseUrl(ctx); string smartRoot = fhirUrlToSmart(root); @@ -5624,7 +5623,7 @@ private CapabilityStatement GenerateCapabilities(FhirRequestContext? ctx) new() { Code = Hl7.Fhir.Model.CapabilityStatement.SystemRestfulInteraction.SearchSystem }, new() { Code = Hl7.Fhir.Model.CapabilityStatement.SystemRestfulInteraction.Transaction }, }, - //SearchParam = new(), // currently, search parameters are expanded out to all-resource + //SearchParam = new(), // search parameters are expanded out to each resource Operation = _operations.Values .Where(o => o.AllowSystemLevel) .Select(o => new CapabilityStatement.OperationComponent() @@ -5688,19 +5687,19 @@ private CapabilityStatement GenerateCapabilities(FhirRequestContext? ctx) Versioning = CapabilityStatement.ResourceVersionPolicy.NoVersion, //ReadHistory = true, UpdateCreate = true, - //ConditionalCreate = true, - ConditionalRead = CapabilityStatement.ConditionalReadStatus.NotSupported, - //ConditionalUpdate = true, + ConditionalCreate = true, + ConditionalRead = CapabilityStatement.ConditionalReadStatus.FullSupport, + ConditionalUpdate = true, //ConditionalPatch = true, ConditionalDelete = CapabilityStatement.ConditionalDeleteStatus.NotSupported, - ReferencePolicy = new CapabilityStatement.ReferenceHandlingPolicy?[] - { + ReferencePolicy = + [ CapabilityStatement.ReferenceHandlingPolicy.Literal, - //CapabilityStatement.ReferenceHandlingPolicy.Logical, + CapabilityStatement.ReferenceHandlingPolicy.Logical, //CapabilityStatement.ReferenceHandlingPolicy.Resolves, //CapabilityStatement.ReferenceHandlingPolicy.Enforced, CapabilityStatement.ReferenceHandlingPolicy.Local, - }, + ], SearchInclude = resourceStore.GetSearchIncludes(), SearchRevInclude = resourceStore.GetSearchRevIncludes(), SearchParam = resourceStore.GetSearchParamDefinitions().Select(sp => new CapabilityStatement.SearchParamComponent()