Ejemplo n.º 1
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;
        }
Ejemplo n.º 2
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);
     }
 }
Ejemplo n.º 3
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));
            }
        }
Ejemplo n.º 4
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;
            }
        }
Ejemplo n.º 5
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);
            }
        }
Ejemplo n.º 6
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;
                }
            }
        }
        public static void SerializeElementDefinitionComponent(Hl7.Fhir.Model.Profile.ElementDefinitionComponent value, IFhirWriter writer, bool summary)
        {
            writer.WriteStartComplexContent();

            // Serialize element _id
            if (value.LocalIdElement != null)
            {
                writer.WritePrimitiveContents("_id", value.LocalIdElement, XmlSerializationHint.Attribute);
            }

            // Serialize element extension
            if (value.Extension != null && !summary && value.Extension.Count > 0)
            {
                writer.WriteStartArrayElement("extension");
                foreach (var item in value.Extension)
                {
                    writer.WriteStartArrayMember("extension");
                    ExtensionSerializer.SerializeExtension(item, writer, summary);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }

            // Serialize element short
            if (value.ShortElement != null)
            {
                writer.WriteStartElement("short");
                FhirStringSerializer.SerializeFhirString(value.ShortElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element formal
            if (value.FormalElement != null)
            {
                writer.WriteStartElement("formal");
                FhirStringSerializer.SerializeFhirString(value.FormalElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element comments
            if (value.CommentsElement != null)
            {
                writer.WriteStartElement("comments");
                FhirStringSerializer.SerializeFhirString(value.CommentsElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element requirements
            if (value.RequirementsElement != null)
            {
                writer.WriteStartElement("requirements");
                FhirStringSerializer.SerializeFhirString(value.RequirementsElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element synonym
            if (value.SynonymElement != null && value.SynonymElement.Count > 0)
            {
                writer.WriteStartArrayElement("synonym");
                foreach (var item in value.SynonymElement)
                {
                    writer.WriteStartArrayMember("synonym");
                    FhirStringSerializer.SerializeFhirString(item, writer, summary);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }

            // Serialize element min
            if (value.MinElement != null)
            {
                writer.WriteStartElement("min");
                IntegerSerializer.SerializeInteger(value.MinElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element max
            if (value.MaxElement != null)
            {
                writer.WriteStartElement("max");
                FhirStringSerializer.SerializeFhirString(value.MaxElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element type
            if (value.Type != null && value.Type.Count > 0)
            {
                writer.WriteStartArrayElement("type");
                foreach (var item in value.Type)
                {
                    writer.WriteStartArrayMember("type");
                    ProfileSerializer.SerializeTypeRefComponent(item, writer, summary);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }

            // Serialize element nameReference
            if (value.NameReferenceElement != null)
            {
                writer.WriteStartElement("nameReference");
                FhirStringSerializer.SerializeFhirString(value.NameReferenceElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element value
            if (value.Value != null)
            {
                writer.WriteStartElement(SerializationUtil.BuildPolymorphicName("value", value.Value.GetType()));
                FhirSerializer.SerializeElement(value.Value, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element example
            if (value.Example != null)
            {
                writer.WriteStartElement(SerializationUtil.BuildPolymorphicName("example", value.Example.GetType()));
                FhirSerializer.SerializeElement(value.Example, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element maxLength
            if (value.MaxLengthElement != null)
            {
                writer.WriteStartElement("maxLength");
                IntegerSerializer.SerializeInteger(value.MaxLengthElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element condition
            if (value.ConditionElement != null && value.ConditionElement.Count > 0)
            {
                writer.WriteStartArrayElement("condition");
                foreach (var item in value.ConditionElement)
                {
                    writer.WriteStartArrayMember("condition");
                    IdSerializer.SerializeId(item, writer, summary);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }

            // Serialize element constraint
            if (value.Constraint != null && value.Constraint.Count > 0)
            {
                writer.WriteStartArrayElement("constraint");
                foreach (var item in value.Constraint)
                {
                    writer.WriteStartArrayMember("constraint");
                    ProfileSerializer.SerializeElementDefinitionConstraintComponent(item, writer, summary);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }

            // Serialize element mustSupport
            if (value.MustSupportElement != null)
            {
                writer.WriteStartElement("mustSupport");
                FhirBooleanSerializer.SerializeFhirBoolean(value.MustSupportElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element isModifier
            if (value.IsModifierElement != null)
            {
                writer.WriteStartElement("isModifier");
                FhirBooleanSerializer.SerializeFhirBoolean(value.IsModifierElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element binding
            if (value.BindingElement != null)
            {
                writer.WriteStartElement("binding");
                FhirUriSerializer.SerializeFhirUri(value.BindingElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element mapping
            if (value.Mapping != null && value.Mapping.Count > 0)
            {
                writer.WriteStartArrayElement("mapping");
                foreach (var item in value.Mapping)
                {
                    writer.WriteStartArrayMember("mapping");
                    ProfileSerializer.SerializeElementDefinitionMappingComponent(item, writer, summary);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }


            writer.WriteEndComplexContent();
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Parse ElementDefinitionComponent
        /// </summary>
        public static Hl7.Fhir.Model.Profile.ElementDefinitionComponent ParseElementDefinitionComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Profile.ElementDefinitionComponent existingInstance = null)
        {
            Hl7.Fhir.Model.Profile.ElementDefinitionComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Profile.ElementDefinitionComponent();
            string currentElementName = reader.CurrentElementName;

            reader.EnterElement();

            while (reader.HasMoreElements())
            {
                var atName = reader.CurrentElementName;
                // Parse element extension
                if (atName == "extension")
                {
                    result.Extension = new List <Hl7.Fhir.Model.Extension>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "extension"))
                    {
                        result.Extension.Add(ExtensionParser.ParseExtension(reader, errors));
                    }

                    reader.LeaveArray();
                }

                // Parse element _id
                else if (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

                // Parse element short
                else if (atName == "short")
                {
                    result.ShortElement = FhirStringParser.ParseFhirString(reader, errors);
                }

                // Parse element formal
                else if (atName == "formal")
                {
                    result.FormalElement = FhirStringParser.ParseFhirString(reader, errors);
                }

                // Parse element comments
                else if (atName == "comments")
                {
                    result.CommentsElement = FhirStringParser.ParseFhirString(reader, errors);
                }

                // Parse element requirements
                else if (atName == "requirements")
                {
                    result.RequirementsElement = FhirStringParser.ParseFhirString(reader, errors);
                }

                // Parse element synonym
                else if (atName == "synonym")
                {
                    result.SynonymElement = new List <Hl7.Fhir.Model.FhirString>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "synonym"))
                    {
                        result.SynonymElement.Add(FhirStringParser.ParseFhirString(reader, errors));
                    }

                    reader.LeaveArray();
                }

                // Parse element min
                else if (atName == "min")
                {
                    result.MinElement = IntegerParser.ParseInteger(reader, errors);
                }

                // Parse element max
                else if (atName == "max")
                {
                    result.MaxElement = FhirStringParser.ParseFhirString(reader, errors);
                }

                // Parse element type
                else if (atName == "type")
                {
                    result.Type = new List <Hl7.Fhir.Model.Profile.TypeRefComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "type"))
                    {
                        result.Type.Add(ProfileParser.ParseTypeRefComponent(reader, errors));
                    }

                    reader.LeaveArray();
                }

                // Parse element nameReference
                else if (atName == "nameReference")
                {
                    result.NameReferenceElement = FhirStringParser.ParseFhirString(reader, errors);
                }

                // Parse element value
                else if (atName.StartsWith("value"))
                {
                    result.Value = FhirParser.ParseElement(reader, errors);
                }

                // Parse element example
                else if (atName.StartsWith("example"))
                {
                    result.Example = FhirParser.ParseElement(reader, errors);
                }

                // Parse element maxLength
                else if (atName == "maxLength")
                {
                    result.MaxLengthElement = IntegerParser.ParseInteger(reader, errors);
                }

                // Parse element condition
                else if (atName == "condition")
                {
                    result.ConditionElement = new List <Hl7.Fhir.Model.Id>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "condition"))
                    {
                        result.ConditionElement.Add(IdParser.ParseId(reader, errors));
                    }

                    reader.LeaveArray();
                }

                // Parse element constraint
                else if (atName == "constraint")
                {
                    result.Constraint = new List <Hl7.Fhir.Model.Profile.ElementDefinitionConstraintComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "constraint"))
                    {
                        result.Constraint.Add(ProfileParser.ParseElementDefinitionConstraintComponent(reader, errors));
                    }

                    reader.LeaveArray();
                }

                // Parse element mustSupport
                else if (atName == "mustSupport")
                {
                    result.MustSupportElement = FhirBooleanParser.ParseFhirBoolean(reader, errors);
                }

                // Parse element isModifier
                else if (atName == "isModifier")
                {
                    result.IsModifierElement = FhirBooleanParser.ParseFhirBoolean(reader, errors);
                }

                // Parse element binding
                else if (atName == "binding")
                {
                    result.BindingElement = FhirUriParser.ParseFhirUri(reader, errors);
                }

                // Parse element mapping
                else if (atName == "mapping")
                {
                    result.Mapping = new List <Hl7.Fhir.Model.Profile.ElementDefinitionMappingComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "mapping"))
                    {
                        result.Mapping.Add(ProfileParser.ParseElementDefinitionMappingComponent(reader, errors));
                    }

                    reader.LeaveArray();
                }

                else
                {
                    errors.Add(String.Format("Encountered unknown element {0} while parsing {1}", reader.CurrentElementName, currentElementName), reader);
                    reader.SkipSubElementsFor(currentElementName);
                    result = null;
                }
            }

            reader.LeaveElement();
            return(result);
        }
Ejemplo n.º 9
0
 private void HarvestElementRef(Hl7.Fhir.Model.Profile.ElementDefinitionComponent source, Element target)
 {
     target.ElementRefPath = source.NameReference;
 }