diff --git a/src/Hl7.Fhir.Base/CompatibilitySuppressions.xml b/src/Hl7.Fhir.Base/CompatibilitySuppressions.xml
index 62440fee9f..f79ce1c7ea 100644
--- a/src/Hl7.Fhir.Base/CompatibilitySuppressions.xml
+++ b/src/Hl7.Fhir.Base/CompatibilitySuppressions.xml
@@ -8,6 +8,13 @@
lib/net8.0/Hl7.Fhir.Base.dll
true
+
+ CP0001
+ T:Hl7.Fhir.ElementModel.ScopedNodeExtensions
+ lib/net8.0/Hl7.Fhir.Base.dll
+ lib/net8.0/Hl7.Fhir.Base.dll
+ true
+
CP0001
T:Hl7.Fhir.ElementModel.Types.MetricConfiguration
@@ -22,6 +29,20 @@
lib/net8.0/Hl7.Fhir.Base.dll
true
+
+ CP0002
+ F:Hl7.Fhir.ElementModel.ScopedNode.Parent
+ lib/net8.0/Hl7.Fhir.Base.dll
+ lib/net8.0/Hl7.Fhir.Base.dll
+ true
+
+
+ CP0002
+ M:Hl7.Fhir.ElementModel.ScopedNode.Children(System.String)
+ lib/net8.0/Hl7.Fhir.Base.dll
+ lib/net8.0/Hl7.Fhir.Base.dll
+ true
+
CP0002
M:Hl7.Fhir.ElementModel.TypedElementExtensions.IsExactlyEqualTo``1(``0,``0,System.Boolean)
@@ -85,6 +106,13 @@
lib/net8.0/Hl7.Fhir.Base.dll
true
+
+ CP0002
+ M:Hl7.Fhir.FhirPath.FhirEvaluationContext.get_ElementResolver
+ lib/net8.0/Hl7.Fhir.Base.dll
+ lib/net8.0/Hl7.Fhir.Base.dll
+ true
+
CP0002
M:Hl7.Fhir.FhirPath.FhirEvaluationContext.get_TerminologyService
diff --git a/src/Hl7.Fhir.Base/ElementModel/ScopedNode.cs b/src/Hl7.Fhir.Base/ElementModel/ScopedNode.cs
index 6622cd49da..380f61da11 100644
--- a/src/Hl7.Fhir.Base/ElementModel/ScopedNode.cs
+++ b/src/Hl7.Fhir.Base/ElementModel/ScopedNode.cs
@@ -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
{
@@ -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; }
@@ -72,7 +73,7 @@ private ScopedNode(ScopedNode parentNode, ScopedNode? parentResource, ITypedElem
///
/// The resource or element which is the direct parent of this node.
///
- public readonly ScopedNode? Parent;
+ public IScopedNode? Parent { get; }
///
/// Returns the location of the current element within its most direct parent resource or datatype.
@@ -87,6 +88,19 @@ private ScopedNode(ScopedNode parentNode, ScopedNode? parentResource, ITypedElem
///
public string Name => Current.Name;
+ ///
+ /// Will be replaced by a different implementation in the future.
+ ///
+ 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
+ };
+
///
public string? InstanceType => Current.InstanceType;
@@ -96,6 +110,12 @@ private ScopedNode(ScopedNode parentNode, ScopedNode? parentResource, ITypedElem
///
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;
+
///
/// Whether this node is a root element of a Resource.
///
@@ -264,7 +284,13 @@ private set
public IEnumerable