예제 #1
0
        private Element HarvestElement(Hl7.Fhir.Model.Profile.ElementComponent source)
        {
            Element target = new Element();

            HarvestElement(source, target);
            return(target);
        }
        public static void SerializeElementComponent(Hl7.Fhir.Model.Profile.ElementComponent 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 path
            if (value.PathElement != null)
            {
                writer.WriteStartElement("path");
                FhirStringSerializer.SerializeFhirString(value.PathElement, writer, summary);
                writer.WriteEndElement();
            }

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

            // Serialize element slicing
            if (value.Slicing != null)
            {
                writer.WriteStartElement("slicing");
                ProfileSerializer.SerializeElementSlicingComponent(value.Slicing, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element definition
            if (value.Definition != null)
            {
                writer.WriteStartElement("definition");
                ProfileSerializer.SerializeElementDefinitionComponent(value.Definition, writer, summary);
                writer.WriteEndElement();
            }


            writer.WriteEndComplexContent();
        }
예제 #3
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);
        }
예제 #4
0
        private Representation TransformRepresentation(Hl7.Fhir.Model.Profile.ElementComponent source)
        {
            if (source.Representation == null)
            {
                return(Representation.Element);
            }

            return((source.Representation.Contains(Hl7.Fhir.Model.Profile.PropertyRepresentation.XmlAttr))
                ? Representation.Attribute
                : Representation.Element);
        }
예제 #5
0
        private Slicing PrepareSlice(Hl7.Fhir.Model.Profile.ElementComponent source)
        {
            Slicing slicing = new Slicing();

            slicing.Path = new Path(source.Path);

            //TODO: Support multiple discriminators
            if (source.Slicing.Discriminator.Count() > 1)
            {
                throw Error.NotImplemented("Multiple discriminators not yet implemented");
            }

            //TODO: Support discriminator-less matching!
            slicing.Discriminator = new Path(source.Slicing.Discriminator.First());
            return(slicing);
        }
예제 #6
0
        /// <summary>
        /// Parse ElementComponent
        /// </summary>
        public static Hl7.Fhir.Model.Profile.ElementComponent ParseElementComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Profile.ElementComponent existingInstance = null)
        {
            Hl7.Fhir.Model.Profile.ElementComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Profile.ElementComponent();
            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 path
                else if (atName == "path")
                {
                    result.PathElement = FhirStringParser.ParseFhirString(reader, errors);
                }

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

                // Parse element slicing
                else if (atName == "slicing")
                {
                    result.Slicing = ProfileParser.ParseElementSlicingComponent(reader, errors);
                }

                // Parse element definition
                else if (atName == "definition")
                {
                    result.Definition = ProfileParser.ParseElementDefinitionComponent(reader, errors);
                }

                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);
        }
예제 #7
0
 private void HarvestSlicing(Hl7.Fhir.Model.Profile.ElementComponent source, Element target)
 {
     InjectSlice(target);
 }