Exemple #1
0
        /// <summary>
        /// Turn a relative reference into an absolute url, based on the fullUrl of the parent resource
        /// </summary>
        /// <param name="node"></param>
        /// <param name="identity"></param>
        /// <returns></returns>
        /// <remarks>See https://www.hl7.org/fhir/bundle.html#references for more information</remarks>
        public static ResourceIdentity MakeAbsolute(this ScopedNode node, ResourceIdentity identity)
        {
            if (identity.IsRelativeRestUrl)
            {
                // Relocate the relative url on the base given in the fullUrl of the entry (if applicable)
                var fullUrl = node.FullUrl();

                if (fullUrl != null)
                {
                    var parentIdentity = new ResourceIdentity(fullUrl);

                    if (parentIdentity.IsAbsoluteRestUrl)
                    {
                        identity = identity.WithBase(parentIdentity.BaseUri);
                    }
                    else if (parentIdentity.IsUrn)
                    {
                        identity = new ResourceIdentity($"{parentIdentity}/{identity.Id}");
                    }
                }

                // Return the identity - will remain relative if we did not find a fullUrl
            }

            return(identity);
        }
Exemple #2
0
 private ScopedNode(ScopedNode parent, ScopedNode parentResource, ITypedElement wrapped)
 {
     Current          = wrapped;
     ExceptionHandler = parent.ExceptionHandler;
     ParentResource   = parent.AtResource ? parent : parentResource;
 }
Exemple #3
0
 public static string MakeAbsolute(this ScopedNode node, string reference) =>
 node.MakeAbsolute(new ResourceIdentity(reference)).ToString();