Пример #1
0
 private void _linkElementRef(Structure structure, Element element)
 {
     if (element.ElementRef == null && element.ElementRefPath != null)
     {
         element.ElementRef = specification.GetElementByPath(structure, element.ElementRefPath);
     }
 }
Пример #2
0
 public Vector MoveTo(Element element, XPathNavigator node)
 {
     Vector clone = this.Clone();
     clone.Element = element;
     clone.Node = node;
     return clone;
 }
Пример #3
0
        public void ValidateTypeRef(Element element, TypeRef typeref)
        {

            // Test if the Surrect was able to link to the target structure.
            if (typeref.Structure != null)
            {
                Log(Group.Reference, Status.Valid, "Type reference to structure [{0}] is valid", typeref.Code);
                
                // Genest structuren valideren hoeft niet. Want alle structures worden al op hoofdniveau gevalideerd
                //ValidateStructure(typeref.Structure);

            }

            // Test if there is a reference at all
            else if (typeref.Code == null)
            {
                Log(Group.Reference, Status.Failed, "Missing a reference to a structure in element [{0}]", element.Name);
            }

            // Test if code is itself valid? If so, the reference valid but the target is missing.
            else if (Regex.IsMatch(typeref.Code, "[A-Za-z][A-Za-z0-9]*"))
            {
                // Collect first to avoid duplicates
                missingStructureNames.Add(typeref.Code);
            }

            // The code contains invalid characters
            else
            {
                Log(Group.Reference, Status.Failed, "Invalid structure reference '{0}' in {1}", typeref.Code, element.Path);
            }
        }
Пример #4
0
 public void ValidateConstraints(Element element)
 {
     foreach(Constraint c in element.Constraints)
     {
         ValidateConstraint(element, c);
     }
 }
Пример #5
0
 internal void InjectSlice(Element element)
 {
     Slicing slicing = GetSlicingForElement(element);
     if (slicing != null)
     {
         element.Discriminator = slicing.Discriminator;
         element.Slice = ++slicing.Count;
     }
 }
Пример #6
0
        private void HarvestFixedValue(Hl7.Fhir.Model.Profile.ElementDefinitionComponent source, Element target)
        {
            target.FixedValue = null;

            if (source.Fixed != null)
                target.FixedValue = source.Fixed;

            if (source.Pattern != null)
                target.PatternValue = source.Pattern;
        }
Пример #7
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;
 }
Пример #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);
 }
Пример #9
0
 public void ValidateConstraint(Element element, Constraint constraint)
 {
     if (constraint.IsValid)
     {
         
         Log(Group.Constraint, Status.Valid, "Constraint is valid");
     }
     else 
     {
          Log(Group.Constraint, Status.Failed, 
              "Constraint [{0}] ({1}) has an invalid XPath: {2}", 
              constraint.Name, constraint.HumanReadable, constraint.CompilerError.Message);
     }
 }
Пример #10
0
        private void HarvestConstraints(Hl7.Fhir.Model.Profile.ElementDefinitionComponent source, Element target)
        {
            if (source.Constraint == null)
                return;

            foreach (Hl7.Fhir.Model.Profile.ElementDefinitionConstraintComponent c in source.Constraint)
            {
                Constraint constraint = new Constraint();
                constraint.Name = c.Name ?? c.Key;
                constraint.XPath = c.Xpath;
                constraint.HumanReadable = c.Human;
                target.Constraints.Add(constraint);
            }
        }
Пример #11
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;
        }
Пример #12
0
        private void HarvestBinding(Hl7.Fhir.Model.Profile.ElementDefinitionComponent source, Element target)
        {

            if (source.Binding != null)
            {
                var reference = source.Binding.Reference;

                if (reference is Hl7.Fhir.Model.ResourceReference)
                {
                    // todo: dit deel is nog niet getest.
                    target.BindingUri = (reference as Hl7.Fhir.Model.ResourceReference).Url.ToString();
                }
                else if (reference is Hl7.Fhir.Model.FhirUri)
                {
                    target.BindingUri = (reference as Hl7.Fhir.Model.FhirUri).Value;
                }
            }

        }
Пример #13
0
        public void ValidateCardinality(Element element)
        {
            if (element.Cardinality.Min == null || element.Cardinality.Max == null)
            Log(Group.Element, Status.Incomplete, "Element [{0}] does not define it's cardinality", element.Path);

        }
Пример #14
0
 public void ValidateElement(Element element)
 {
     ValidateAttribute(element);
     ValidateCardinality(element);
     ValidateConstraints(element);
     ValidateTypeRefs(element);
 }
Пример #15
0
 public void ValidateAttribute(Element element)
 {
     if (element.Representation == Representation.Attribute)
     {
         if (element.Children != null)
             Log(Group.Attribute, Status.Failed, "Element [{0}] is has an attribute representation and can not have children", element);
     }
 }
Пример #16
0
        private void HarvestElement(Hl7.Fhir.Model.Profile.ElementComponent source, Element target)
        {
            target.Path = new Path(source.Path);
            target.Name = target.Path.ElementName; //source.Name; 
            target.Representation = TransformRepresentation(source);

            HarvestElementDefinition(source.Definition, target);
            HarvestSlicing(source, target); 
        }
Пример #17
0
 private Element HarvestElement(Hl7.Fhir.Model.Profile.ElementComponent source)
 {
     Element target = new Element();
     HarvestElement(source, target);
     return target;
 }
Пример #18
0
        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;
        }
Пример #19
0
 internal Slicing GetSlicingForElement(Element element)
 {
     Slicing slicing = Slicings.FirstOrDefault(s => s.Path.Equals(element.Path));
     return slicing;
 }
Пример #20
0
 private void HarvestCardinality(Hl7.Fhir.Model.Profile.ElementDefinitionComponent source, Element target)
 {
     Cardinality cardinality = new Cardinality();
     cardinality.Min = source.Min.ToString();
     cardinality.Max = source.Max;
     target.Cardinality = cardinality;
 }
Пример #21
0
 public Vector MoveTo(Element element)
 {
     Vector clone = this.Clone();
     clone.Element = element;
     return clone;
 }
Пример #22
0
        private void _addNameSpace(Element element)
        {
            if (element.HasTypeRef)
            {
                TypeRef typeref = element.TypeRefs.FirstOrDefault(t => t.Structure != null);
                if (typeref != null)
                {
                    element.NameSpacePrefix = typeref.Structure.NameSpacePrefix;
                }
            }

            if (element.NameSpacePrefix == null)
                element.NameSpacePrefix = FhirNamespaceManager.Fhir;
        }
Пример #23
0
 private void HarvestSlicing(Hl7.Fhir.Model.Profile.ElementComponent source, Element target)
 {
     InjectSlice(target);
 }
Пример #24
0
 private void HarvestElementRef(Hl7.Fhir.Model.Profile.ElementDefinitionComponent source, Element target)
 {
     target.ElementRefPath = source.NameReference;
 }
Пример #25
0
 private void HarvestElementDefinition(Hl7.Fhir.Model.Profile.ElementDefinitionComponent source, Element target)
 {
     if (source != null)
     {
         HarvestBinding(source, target);
         HarvestTypeRefs(source, target);
         HarvestElementRef(source, target);
         HarvestCardinality(source, target);
         HarvestConstraints(source, target);
         HarvestFixedValue(source, target);
     }
 }
Пример #26
0
 public void ValidateTypeRefs(Element element)
 {
     foreach (TypeRef t in element.TypeRefs)
     {
         ValidateTypeRef(element, t);
     }
 }
Пример #27
0
        private void HarvestTypeRefs(Hl7.Fhir.Model.Profile.ElementDefinitionComponent source, Element target)
        {
            if (source.Type == null)
                return;

            foreach (var type in source.Type)
            {
                target.TypeRefs.Add(HarvestTypeRef(type));
            }
        }