Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
2d5e3ac
removed pragmas, WIP
Kasdejong Oct 16, 2024
02e6f5d
Changed target framework, added resolve signature, updated project fi…
Kasdejong Oct 16, 2024
2422e32
removed some attributes which are native to NetStandard2.1
Kasdejong Oct 17, 2024
78a6869
Merge branch 'develop' into spike/define-Iscopednode
Kasdejong Oct 17, 2024
1ce977a
started implementation of helper methods for ScopedNode
Kasdejong Oct 18, 2024
f17abda
Implemented resolve on IScopedNode
Kasdejong Oct 22, 2024
f233fb6
Added CodeableReference and Canonical to the reference detection
Kasdejong Oct 22, 2024
933b48d
Merge branch 'develop-6.0' into spike/define-Iscopednode
Kasdejong Oct 22, 2024
287be8f
wrote new CompatibilitySuppressions
Kasdejong Oct 22, 2024
8c269dc
added compatibility suppressions
Kasdejong Oct 22, 2024
8aa8d98
Merge branch 'develop-6.0' into spike/define-Iscopednode
Kasdejong Oct 22, 2024
157ae1d
fixed null reference exception when reading a non-existing uri from a…
Kasdejong Oct 23, 2024
82c247b
Merge branch 'develop-6.0' into spike/define-Iscopednode
Kasdejong Oct 23, 2024
d0ec44f
updated CompatibilitySuppressions.xml
Kasdejong Oct 23, 2024
adf60ee
Merge branch 'move-to-netstandard-2.1' into spike/define-Iscopednode
Kasdejong Oct 23, 2024
fd181b7
updated CompatibilitySuppressions.xml
Kasdejong Oct 23, 2024
c55b3df
Merge branch 'develop-6.0' into spike/define-Iscopednode
mmsmits Oct 23, 2024
520f9e0
This is unfortunate... I do not know if we want these compatibility s…
Kasdejong Oct 24, 2024
77a5f18
ignored unit tests (we will fix these when we rewrite FP engine)
Kasdejong Oct 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/Hl7.Fhir.Base/CompatibilitySuppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
<Right>lib/net8.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Hl7.Fhir.ElementModel.ScopedNodeExtensions</Target>
<Left>lib/net8.0/Hl7.Fhir.Base.dll</Left>
<Right>lib/net8.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Hl7.Fhir.ElementModel.Types.MetricConfiguration</Target>
Expand All @@ -22,6 +29,20 @@
<Right>lib/net8.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>F:Hl7.Fhir.ElementModel.ScopedNode.Parent</Target>
<Left>lib/net8.0/Hl7.Fhir.Base.dll</Left>
<Right>lib/net8.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Hl7.Fhir.ElementModel.ScopedNode.Children(System.String)</Target>
<Left>lib/net8.0/Hl7.Fhir.Base.dll</Left>
<Right>lib/net8.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Hl7.Fhir.ElementModel.TypedElementExtensions.IsExactlyEqualTo``1(``0,``0,System.Boolean)</Target>
Expand Down Expand Up @@ -85,6 +106,13 @@
<Right>lib/net8.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Hl7.Fhir.FhirPath.FhirEvaluationContext.get_ElementResolver</Target>
<Left>lib/net8.0/Hl7.Fhir.Base.dll</Left>
<Right>lib/net8.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Hl7.Fhir.FhirPath.FhirEvaluationContext.get_TerminologyService</Target>
Expand Down
36 changes: 31 additions & 5 deletions src/Hl7.Fhir.Base/ElementModel/ScopedNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@
* available at https://raw.githubusercontent.com/FirelyTeam/firely-net-sdk/master/LICENSE
*/

using Hl7.Fhir.Model;
using Hl7.Fhir.Specification;
using Hl7.Fhir.Support.Poco;
using Hl7.Fhir.Utility;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;

#nullable enable

namespace Hl7.Fhir.ElementModel
{
public class ScopedNode : ITypedElement, IAnnotated, IExceptionSource
public class ScopedNode : IScopedNode, IAnnotated, IExceptionSource
{
private class Cache
{
Expand Down Expand Up @@ -54,7 +56,6 @@ private ScopedNode(ScopedNode parentNode, ScopedNode? parentResource, ITypedElem

if (Current.Name == "entry")
_fullUrl = Current.Children("fullUrl").FirstOrDefault()?.Value as string ?? _fullUrl;

}

public ExceptionNotificationHandler? ExceptionHandler { get; set; }
Expand All @@ -72,7 +73,7 @@ private ScopedNode(ScopedNode parentNode, ScopedNode? parentResource, ITypedElem
/// <summary>
/// The resource or element which is the direct parent of this node.
/// </summary>
public readonly ScopedNode? Parent;
public IScopedNode? Parent { get; }

/// <summary>
/// Returns the location of the current element within its most direct parent resource or datatype.
Expand All @@ -87,6 +88,19 @@ private ScopedNode(ScopedNode parentNode, ScopedNode? parentResource, ITypedElem
/// <inheritdoc/>
public string Name => Current.Name;

/// <summary>
/// Will be replaced by a different implementation in the future.
/// </summary>
public NodeType Type => this switch
{
{ AtResource: true } when Current.Children("contained").Any() => NodeType.DomainResource | NodeType.Resource,
{ InstanceType: FhirTypeConstants.BUNDLE } => NodeType.Bundle | NodeType.Resource,
{ AtResource: true } => NodeType.Resource,
{ InstanceType: FhirTypeConstants.REFERENCE or FhirTypeConstants.CANONICAL or FhirTypeConstants.CODEABLEREFERENCE } => NodeType.Reference,
{ Value: not null } => NodeType.Primitive,
_ => 0
};

/// <inheritdoc/>
public string? InstanceType => Current.InstanceType;

Expand All @@ -96,6 +110,12 @@ private ScopedNode(ScopedNode parentNode, ScopedNode? parentResource, ITypedElem
/// <inheritdoc/>
public string Location => Current.Location;

public bool TryResolveBundleEntry(string fullUrl, [NotNullWhen(true)] out IScopedNode? result)
=> (result = ((ReferencedResourceCache)this.BundledResources()).ResolveReference(fullUrl)) is not null;

public bool TryResolveContainedEntry(string id, [NotNullWhen(true)] out IScopedNode? result)
=> (result = (this.ContainedResourcesWithId()).ResolveReference(id)) is not null;

/// <summary>
/// Whether this node is a root element of a Resource.
/// </summary>
Expand Down Expand Up @@ -264,7 +284,13 @@ private set
public IEnumerable<object> Annotations(Type type) => type == typeof(ScopedNode) ? (new[] { this }) : Current.Annotations(type);

/// <inheritdoc />
public IEnumerable<ITypedElement> Children(string? name = null) =>
IEnumerable<ITypedElement> ITypedElement.Children(string? name) =>
Current.Children(name).Select(c => new ScopedNode(this, ParentResource, c, _fullUrl));

/// <inheritdoc />
public IEnumerable<IScopedNode> Children(string? name = null) =>
Current.Children(name).Select(c => new ScopedNode(this, ParentResource, c, _fullUrl));

public string ShortPath => Current is ElementNode en ? en.ShortPath : Current.Location;
}
}
145 changes: 0 additions & 145 deletions src/Hl7.Fhir.Base/ElementModel/ScopedNodeExtensions.cs

This file was deleted.

6 changes: 3 additions & 3 deletions src/Hl7.Fhir.Base/FhirPath/ElementNavFhirExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public static void PrepareFhirSymbolTableFunctions()
public static SymbolTable AddFhirExtensions(this SymbolTable t)
{
t.Add("hasValue", (ITypedElement f) => f.HasValue(), doNullProp: false);
t.Add("resolve", (ITypedElement f, EvaluationContext ctx) => resolver(f, ctx), doNullProp: false);
t.Add("resolve", (IEnumerable<ITypedElement> f, EvaluationContext ctx) => f.Select(fi => resolver(fi, ctx)), doNullProp: false);
t.Add("resolve", (IScopedNode f, EvaluationContext ctx) => resolver(f, ctx), doNullProp: false);
t.Add("resolve", (IEnumerable<IScopedNode> f, EvaluationContext ctx) => f.Select(fi => resolver(fi, ctx)), doNullProp: false);

t.Add("memberOf", (ITypedElement input, string valueset, EvaluationContext ctx) => MemberOf(input, valueset, ctx), doNullProp: false);

Expand Down Expand Up @@ -69,7 +69,7 @@ public static SymbolTable AddFhirExtensions(this SymbolTable t)

return t;

static ITypedElement? resolver(ITypedElement f, EvaluationContext ctx)
static IScopedNode? resolver(IScopedNode f, EvaluationContext ctx)
{
return ctx is FhirEvaluationContext fctx ? f.Resolve(fctx.ElementResolver) : f.Resolve();
}
Expand Down
5 changes: 3 additions & 2 deletions src/Hl7.Fhir.Base/FhirPath/FhirEvaluationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

using Hl7.Fhir.ElementModel;
using Hl7.Fhir.Model;
using Hl7.Fhir.Specification.Terminology;
using Hl7.FhirPath;
using System;
Expand Down Expand Up @@ -78,9 +79,9 @@ private static ITypedElement toNearestResource(ScopedNode node)
return scan;
}

private Func<string, ITypedElement>? _elementResolver;
private Func<string, IScopedNode>? _elementResolver;

public Func<string, ITypedElement>? ElementResolver
public Func<string, IScopedNode>? ElementResolver
{
get { return _elementResolver; }
set { _elementResolver = value; }
Expand Down
1 change: 1 addition & 0 deletions src/Hl7.Fhir.Base/Hl7.Fhir.Base.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.1'">
<PackageReference Include="System.Buffers" Version="4.5.1" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
</ItemGroup>

Expand Down
Loading