コード例 #1
0
        /// <summary>
        /// Parse OrganizationContactComponent
        /// </summary>
        public static Hl7.Fhir.Model.Organization.OrganizationContactComponent ParseOrganizationContactComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Organization.OrganizationContactComponent existingInstance = null)
        {
            Hl7.Fhir.Model.Organization.OrganizationContactComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Organization.OrganizationContactComponent();
            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 purpose
                else if (atName == "purpose")
                {
                    result.Purpose = CodeableConceptParser.ParseCodeableConcept(reader, errors);
                }

                // Parse element name
                else if (atName == "name")
                {
                    result.Name = HumanNameParser.ParseHumanName(reader, errors);
                }

                // Parse element telecom
                else if (atName == "telecom")
                {
                    result.Telecom = new List <Hl7.Fhir.Model.Contact>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "telecom"))
                    {
                        result.Telecom.Add(ContactParser.ParseContact(reader, errors));
                    }

                    reader.LeaveArray();
                }

                // Parse element address
                else if (atName == "address")
                {
                    result.Address = AddressParser.ParseAddress(reader, errors);
                }

                // Parse element gender
                else if (atName == "gender")
                {
                    result.Gender = CodeableConceptParser.ParseCodeableConcept(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);
        }
コード例 #2
0
        public static void SerializeOrganizationContactComponent(Hl7.Fhir.Model.Organization.OrganizationContactComponent 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 purpose
            if (value.Purpose != null)
            {
                writer.WriteStartElement("purpose");
                CodeableConceptSerializer.SerializeCodeableConcept(value.Purpose, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element name
            if (value.Name != null)
            {
                writer.WriteStartElement("name");
                HumanNameSerializer.SerializeHumanName(value.Name, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element telecom
            if (value.Telecom != null && value.Telecom.Count > 0)
            {
                writer.WriteStartArrayElement("telecom");
                foreach (var item in value.Telecom)
                {
                    writer.WriteStartArrayMember("telecom");
                    ContactSerializer.SerializeContact(item, writer, summary);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }

            // Serialize element address
            if (value.Address != null)
            {
                writer.WriteStartElement("address");
                AddressSerializer.SerializeAddress(value.Address, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element gender
            if (value.Gender != null)
            {
                writer.WriteStartElement("gender");
                CodeableConceptSerializer.SerializeCodeableConcept(value.Gender, writer, summary);
                writer.WriteEndElement();
            }


            writer.WriteEndComplexContent();
        }