コード例 #1
0
ファイル: Vector.cs プロジェクト: wdebeau1/fhir-net-api
 public Vector MoveTo(Structure structure)
 {
     Vector clone = this.Clone();
     clone.Structure = structure;
     clone.Element = structure.Root;
     return clone;
 }
コード例 #2
0
ファイル: UriHelper.cs プロジェクト: wdebeau1/fhir-net-api
        /*
        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;
        }
コード例 #3
0
 private void _linkElements(Structure structure)
 {
     foreach (Element e in structure.Elements)
     {
         _tryLinkToParent(structure, e);
     }
 }
コード例 #4
0
 private void _linkElementRef(Structure structure, Element element)
 {
     if (element.ElementRef == null && element.ElementRefPath != null)
     {
         element.ElementRef = specification.GetElementByPath(structure, element.ElementRefPath);
     }
 }
コード例 #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();
 }
コード例 #6
0
 private bool _tryLinkToParent(Structure structure, Element element)
 {
     Element parent = specification.ParentOf(structure, element);
     if (parent != null)
     {
         parent.Children.Add(element);
         return true;
     }
     return false;
 }
コード例 #7
0
ファイル: Vector.cs プロジェクト: wdebeau1/fhir-net-api
 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;
 }
コード例 #8
0
ファイル: UriHelper.cs プロジェクト: wdebeau1/fhir-net-api
 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);
     }
     
 }
コード例 #9
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);
 }
コード例 #10
0
        public static Structure Primitive(string name, IPrimitiveValidator 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;
        }
コード例 #11
0
 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);
     }
 }
コード例 #12
0
 public static void SetTypeRefIdentification(Structure structure, TypeRef typeref)
 {
     typeref.Uri = Identify(structure, typeref);
 }
コード例 #13
0
 private void HarvestElements(Profile.ProfileStructureComponent source, Structure target)
 {
     foreach(var element in source.Element)
     {
         target.Elements.Add(HarvestElement(element));
     }
 }
コード例 #14
0
 public Element GetElementByPath(Structure structure, string path)
 {
     return structure.Elements.FirstOrDefault(element => element.Path.ToString() == path);
 }
コード例 #15
0
 public Element ParentOf(Structure structure, Element element)
 {
     Path path = element.Path.Parent();
     Element parent = structure.Elements.Find(e => e.Path.Equals(path));
     return parent;
 }
コード例 #16
0
 public Structure ReadStructure(XPathNavigator node)
 {
     Structure structure = new Structure();
     structure.Type = node.SelectSingleNode("f:type/@value", ns).Value;
     structure.NameSpacePrefix = FhirNamespaceManager.Fhir;
     PreReadSlices(structure, node.Select("f:element", ns));
     ReadStructureElements(structure, node.Select("f:element", ns));
     return structure;
 }
コード例 #17
0
 public void ReadStructureElements(Structure structure, XPathNodeIterator xElements)
 {
     foreach (XPathNavigator xElement in xElements)
     {
         Element element = ReadElement(structure, xElement);
         structure.Elements.Add(element);
     }
 }
コード例 #18
0
 public Element ReadElement(Structure structure, XPathNavigator node)
 {
     Element element = new Element();
     element.ID = id++;
     
     ReadElementDefinition(element, node);
     return element;
 }
コード例 #19
0
 public void PreReadSlices(Structure structure, XPathNodeIterator xNodes)
 {
     foreach (XPathNavigator node in xNodes)
     {
         if (IsSliceDefinitionNode(node))
         {
             Slicing s = readSlicing(node);
             Slicings.Add(s);
         }
     }
 }
コード例 #20
0
        public IEnumerable <Structure> GetStructures(Uri uri)
        {
            Structure structure = GetStructure(uri);

            return(Singleton(structure));
        }
コード例 #21
0
 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);
         }
     }
 }
コード例 #22
0
        public void ValidateStructure(Structure structure)
        {
            //if (structure.IsPrimitive)
             //   return; // there is no more detail.

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

            ValidateElementRefs(structure);
        }
コード例 #23
0
        public void TrackStructure(Structure structure)
        {
            Uri uri = structure.ProfileUri;

            tracker.MarkResolved(uri);
        }
コード例 #24
0
 internal void Add(Structure structure)
 {
     AssertNotSealed();
     _structures.Add(structure);
 }
コード例 #25
0
ファイル: UriHelper.cs プロジェクト: wdebeau1/fhir-net-api
 public static void SetStructureIdentification(Structure structure, Uri uri)
 {
     structure.ProfileUri = uri.RemoveAnchor();
     if (HasAnchor(uri))
     {
         structure.Uri = uri;
     }
     else
     {
         structure.Uri = Identify(structure);
     }
 }
コード例 #26
0
ファイル: UriHelper.cs プロジェクト: wdebeau1/fhir-net-api
 public static void SetTypeRefIdentification(Structure structure, TypeRef typeref)
 {
     typeref.Uri = Identify(structure, typeref);
 }
コード例 #27
0
 public Structure HarvestStructure(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;
 }
コード例 #28
0
 public void TrackStructure(Structure structure)
 {
     Uri uri = structure.ProfileUri;
     tracker.MarkResolved(uri);
 }
コード例 #29
0
 public Structure HarvestExtensionDefn(Profile.ProfileExtensionDefnComponent source)
 {
     Structure target = new Structure();
     target.Name = source.Code;
     Element element = new Element();
     element.Name = source.Code;
     HarvestElementDefinition(source.Definition, element);
     
     target.Elements.Add(element);
     return target;
 }