private void _linkElementRef(Structure structure, Element element) { if (element.ElementRef == null && element.ElementRefPath != null) { element.ElementRef = specification.GetElementByPath(structure, element.ElementRefPath); } }
public Vector MoveTo(Element element, XPathNavigator node) { Vector clone = this.Clone(); clone.Element = element; clone.Node = node; return clone; }
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); } }
public void ValidateConstraints(Element element) { foreach(Constraint c in element.Constraints) { ValidateConstraint(element, c); } }
internal void InjectSlice(Element element) { Slicing slicing = GetSlicingForElement(element); if (slicing != null) { element.Discriminator = slicing.Discriminator; element.Slice = ++slicing.Count; } }
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; }
private bool _tryLinkToParent(Structure structure, Element element) { Element parent = specification.ParentOf(structure, element); if (parent != null) { parent.Children.Add(element); return true; } return false; }
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); }
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); } }
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); } }
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; }
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; } } }
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); }
public void ValidateElement(Element element) { ValidateAttribute(element); ValidateCardinality(element); ValidateConstraints(element); ValidateTypeRefs(element); }
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); } }
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); }
private Element HarvestElement(Hl7.Fhir.Model.Profile.ElementComponent source) { Element target = new Element(); HarvestElement(source, target); return target; }
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; }
internal Slicing GetSlicingForElement(Element element) { Slicing slicing = Slicings.FirstOrDefault(s => s.Path.Equals(element.Path)); return slicing; }
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; }
public Vector MoveTo(Element element) { Vector clone = this.Clone(); clone.Element = element; return clone; }
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; }
private void HarvestSlicing(Hl7.Fhir.Model.Profile.ElementComponent source, Element target) { InjectSlice(target); }
private void HarvestElementRef(Hl7.Fhir.Model.Profile.ElementDefinitionComponent source, Element target) { target.ElementRefPath = source.NameReference; }
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); } }
public void ValidateTypeRefs(Element element) { foreach (TypeRef t in element.TypeRefs) { ValidateTypeRef(element, t); } }
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)); } }