Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 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
14 changes: 14 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,13 @@
<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.TypedElementExtensions.IsExactlyEqualTo``1(``0,``0,System.Boolean)</Target>
Expand Down
34 changes: 30 additions & 4 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,
Comment thread
Kasdejong marked this conversation as resolved.
{ 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 @@ -266,5 +286,11 @@ private set
/// <inheritdoc />
public IEnumerable<ITypedElement> Children(string? name = null) =>
Current.Children(name).Select(c => new ScopedNode(this, ParentResource, c, _fullUrl));

/// <inheritdoc />
IEnumerable<IScopedNode> IScopedNode.Children(string? name) =>
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.

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