/// <summary>
        /// Turn a relative reference into an absolute url, based on the fullUrl of the parent resource
        /// </summary>
        /// <param name="nav"></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 ScopedNavigator nav, ResourceIdentity identity)
        {
            if (identity.IsRelativeRestUrl)
            {
                // Relocate the relative url on the base given in the fullUrl of the entry (if applicable)
                var fullUrl = nav.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);
        }