private void _linkElementRef(Structure structure, Element element)
 {
     if (element.ElementRef == null && element.ElementRefPath != null)
     {
         element.ElementRef = specification.GetElementByPath(structure, element.ElementRefPath);
     }
 }
 private void _linkElements(Structure structure)
 {
     foreach (Element e in structure.Elements)
     {
         _tryLinkToParent(structure, e);
     }
 }
Example #3
0
        /*
        public static Uri ResolvingUri(TypeRef typeref)
        {
            if (typeref.ProfileUri == null)
            {
                return BaseProfileUriFor(typeref.Code);
            }
            else
            {
                return new Uri(typeref.ProfileUri);
            }
        }
        */

        public static Uri Identify(Structure structure, TypeRef typeref)
        {
            string name = typeref.Code;
            Uri uri;

            if ((name == "ResourceReference"))
            {
                uri = BaseProfileUriFor(name);
            }
            else if (typeref.ProfileUri != null)
            {
                
                if (typeref.ProfileUri.StartsWith("#"))
                {
                    uri = new Uri(structure.ProfileUri + typeref.ProfileUri);
                }
                else if (typeref.ProfileUri != null)
                {
                    uri = new Uri(typeref.ProfileUri);
                }
                else 
                {
                    uri = BaseProfileUriFor(name);
                }
            }
            else // typeref.profileuri == null
            {
                uri = BaseProfileUriFor(name);
            }

            return uri;
        }
Example #4
0
 public Vector MoveTo(Structure structure)
 {
     Vector clone = this.Clone();
     clone.Structure = structure;
     clone.Element = structure.Root;
     return clone;
 }
Example #5
0
 static string StructureUri(string profileuri, string type, string name)
 {
     Structure structure = new Structure();
     structure.Type = type;
     structure.Name = name;
     Uri uri = new Uri(profileuri);
     UriHelper.SetStructureIdentification(structure, uri);
     return structure.Uri.ToString();
 }
Example #6
0
 public static Vector Create(Structure structure, XPathNavigator node, XmlNamespaceManager nsm)
 {
     Vector vector = new Vector();
     vector.Structure = structure;
     vector.Element = (structure != null) ? structure.Root : null;
     vector.Node = node;
     vector.NSM = nsm;
     vector.Origin = vector; 
     return vector;
 }
 private bool _tryLinkToParent(Structure structure, Element element)
 {
     Element parent = specification.ParentOf(structure, element);
     if (parent != null)
     {
         parent.Children.Add(element);
         return true;
     }
     return false;
 }
Example #8
0
 public static void AddExtensionElement(Structure structure, Element parent = null)
 {
     parent = parent  ?? structure.Root;
     string path = string.Format("{0}.extension", parent.Path); 
     Element element = new Element();
     element.Path = new Path(path);
     element.Name = "extension";
     element.Cardinality = new Cardinality { Min = "0", Max = "*" };
     TypeRef typeref = new TypeRef("Extension");
     UriHelper.SetTypeRefIdentification(structure, typeref);
     element.TypeRefs.Add(typeref);
     structure.Elements.Add(element);
 }
Example #9
0
 public static Uri Identify(Structure structure)
 {
     string name = structure.Name ?? structure.Type;
     if (IsBaseProfile(structure.ProfileUri))
     {
         return BaseProfileUriFor(name);
     }
     else
     {
         return AddAnchor(structure.ProfileUri, name);
     }
     
 }
Example #10
0
        public static Structure Primitive(string name, Func<string,bool> validator, string nsprefix = FhirNamespaceManager.Fhir)
        {
            Structure structure = new Structure();
            structure.Type = name;
            UriHelper.SetStructureIdentification(structure, UriHelper.BASEPROFILE);

            Element element = new Element();
            element.Path = new Path(name);
            element.Name = name;
            element.IsPrimitive = true;
            element.PrimitiveValidator = validator;
            element.Cardinality = new Cardinality { Min = "1", Max = "1" };
            element.NameSpacePrefix = nsprefix;
            structure.Elements.Add(element);

            AddExtensionElement(structure, element);
            
            return structure;
        }
        public static Structure XhtmlStructure()
        {
            Structure structure = Primitive(Fhir.Model.FHIRDefinedType.Xhtml, null, FhirNamespaceManager.XHtml);

            return(structure);
        }
Example #12
0
 public static void SetTypeRefIdentification(Structure structure, TypeRef typeref)
 {
     typeref.Uri = Identify(structure, typeref);
 }
 public void TrackStructure(Structure structure)
 {
     Uri uri = structure.ProfileUri;
     tracker.MarkResolved(uri);
 }
 private void fixUris(Structure structure, Uri uri)
 {
     UriHelper.SetStructureIdentification(structure, uri);
     List<TypeRef> typerefs = structure.Elements.SelectMany(e => e.TypeRefs).ToList();
     foreach (TypeRef t in typerefs)
     {
         UriHelper.SetTypeRefIdentification(structure, t);
     }
 }
Example #15
0
 public static void SetTypeRefIdentification(Structure structure, TypeRef typeref)
 {
     typeref.Uri = Identify(structure, typeref);
 }
 public Element GetElementByPath(Structure structure, string path)
 {
     return(structure.Elements.FirstOrDefault(element => element.Path.ToString() == path));
 }
 public void ValidateElementRefs(Structure structure)
 {
     foreach(Element element in structure.Elements)
     {
         if (element.ElementRefPath != null && element.ElementRef == null)
         {
             Log(Group.Reference, Status.Failed, 
                 "Element [{0}] Name reference to different element [{1}] is unresolved", 
                 element.Path, element.ElementRefPath);
         }
     }
 }
        public Element ParentOf(Element element)
        {
            Structure structure = StructureOf(element);

            return(ParentOf(structure, element));
        }
        public Structure HarvestExtensionDefn(Hl7.Fhir.Model.Profile.ProfileExtensionDefnComponent source)
        {
            Structure target = new Structure();
            target.Name = source.Name;
            Element element = new Element();
            element.Name = source.Name;

            //TODO: Add support for complex extensions
            if (source.Element.Count > 0)
                throw new NotImplementedException("Complex extensions are not supported by the harvester");

            HarvestElementDefinition(source.Element[0].Definition, element);
            
            target.Elements.Add(element);
            return target;
        }
 public Structure HarvestStructure(Hl7.Fhir.Model.Profile.ProfileStructureComponent source, Uri uri)
 {
     Structure target = new Structure();
     target.Name = source.Name;
     target.Type = source.Type;
     target.NameSpacePrefix = FhirNamespaceManager.Fhir;
     PrepareSlices(source);
     HarvestElements(source, target);
     fixUris(target, uri);
     return target;
 }
 public Element GetElementByPath(Structure structure, string path)
 {
     return structure.Elements.FirstOrDefault(element => element.Path.ToString() == path);
 }
        public void ValidateStructure(Structure structure)
        {
            //if (structure.IsPrimitive)
             //   return; // there is no more detail.

            foreach (Element element in structure.Elements)
            {
                ValidateElement(element);
            }

            ValidateElementRefs(structure);
        }
 private void HarvestElements(Hl7.Fhir.Model.Profile.ProfileStructureComponent source, Structure target)
 {
     if (source.Snapshot == null) throw Error.Argument("source", "Structure must have a differential representation");
     
     foreach(Hl7.Fhir.Model.Profile.ElementComponent component in source.Snapshot.Element)
     {
         if (component.Slicing == null)
         {
             var element = HarvestElement(component);
             target.Elements.Add(element);
         }
         /*if (!target.Root.HasElements)
             target.Root.IsPrimitive == true; */
         // of moet structure zelf een IsPrimitive krijgen?
     }
 }
 internal void Add(Structure structure)
 {
     AssertNotSealed();
     _structures.Add(structure);
 }
 public Element ParentOf(Structure structure, Element element)
 {
     Path path = element.Path.Parent();
     Element parent = structure.Elements.Find(e => e.Path.Equals(path));
     return parent;
 }
 internal void Add(Structure structure)
 {
     AssertNotSealed();
     _structures.Add(structure);
 }
Example #27
0
 public static void SetStructureIdentification(Structure structure, Uri uri)
 {
     structure.ProfileUri = uri.RemoveAnchor();
     if (HasAnchor(uri))
     {
         structure.Uri = uri;
     }
     else
     {
         structure.Uri = Identify(structure);
     }
 }