Beispiel #1
0
        public static void SerializeProvider(Provider value, IFhirWriter writer)
        {
            writer.WriteStartRootObject("Provider");
            writer.WriteStartComplexContent();

            // Serialize element's localId attribute
            if (value.InternalId != null && !String.IsNullOrEmpty(value.InternalId.Contents))
            {
                writer.WriteRefIdContents(value.InternalId.Contents);
            }

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

            // Serialize element language
            if (value.Language != null)
            {
                writer.WriteStartElement("language");
                CodeSerializer.SerializeCode(value.Language, writer);
                writer.WriteEndElement();
            }

            // Serialize element text
            if (value.Text != null)
            {
                writer.WriteStartElement("text");
                NarrativeSerializer.SerializeNarrative(value.Text, writer);
                writer.WriteEndElement();
            }

            // Serialize element contained
            if (value.Contained != null && value.Contained.Count > 0)
            {
                writer.WriteStartArrayElement("contained");
                foreach (var item in value.Contained)
                {
                    writer.WriteStartArrayMember("contained");
                    FhirSerializer.SerializeResource(item, writer);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }

            // Serialize element identifier
            if (value.Identifier != null && value.Identifier.Count > 0)
            {
                writer.WriteStartArrayElement("identifier");
                foreach (var item in value.Identifier)
                {
                    writer.WriteStartArrayMember("identifier");
                    IdentifierSerializer.SerializeIdentifier(item, writer);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }

            // Serialize element details
            if (value.Details != null)
            {
                writer.WriteStartElement("details");
                DemographicsSerializer.SerializeDemographics(value.Details, writer);
                writer.WriteEndElement();
            }

            // Serialize element organization
            if (value.Organization != null)
            {
                writer.WriteStartElement("organization");
                ResourceReferenceSerializer.SerializeResourceReference(value.Organization, writer);
                writer.WriteEndElement();
            }

            // Serialize element role
            if (value.Role != null && value.Role.Count > 0)
            {
                writer.WriteStartArrayElement("role");
                foreach (var item in value.Role)
                {
                    writer.WriteStartArrayMember("role");
                    CodeableConceptSerializer.SerializeCodeableConcept(item, writer);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }

            // Serialize element specialty
            if (value.Specialty != null && value.Specialty.Count > 0)
            {
                writer.WriteStartArrayElement("specialty");
                foreach (var item in value.Specialty)
                {
                    writer.WriteStartArrayMember("specialty");
                    CodeableConceptSerializer.SerializeCodeableConcept(item, writer);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }

            // Serialize element period
            if (value.Period != null)
            {
                writer.WriteStartElement("period");
                PeriodSerializer.SerializePeriod(value.Period, writer);
                writer.WriteEndElement();
            }


            writer.WriteEndComplexContent();
            writer.WriteEndRootObject();
        }
        public static void SerializeDemographics(Hl7.Fhir.Model.Demographics value, IFhirWriter writer)
        {
            writer.WriteStartComplexContent();

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

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

            // Serialize element identifier
            if (value.Identifier != null && value.Identifier.Count > 0)
            {
                writer.WriteStartArrayElement("identifier");
                foreach (var item in value.Identifier)
                {
                    writer.WriteStartArrayMember("identifier");
                    IdentifierSerializer.SerializeIdentifier(item, writer);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }

            // Serialize element name
            if (value.Name != null && value.Name.Count > 0)
            {
                writer.WriteStartArrayElement("name");
                foreach (var item in value.Name)
                {
                    writer.WriteStartArrayMember("name");
                    HumanNameSerializer.SerializeHumanName(item, writer);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }

            // 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);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }

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

            // Serialize element birthDate
            if (value.BirthDate != null)
            {
                writer.WriteStartElement("birthDate");
                FhirDateTimeSerializer.SerializeFhirDateTime(value.BirthDate, writer);
                writer.WriteEndElement();
            }

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

            // Serialize element address
            if (value.Address != null && value.Address.Count > 0)
            {
                writer.WriteStartArrayElement("address");
                foreach (var item in value.Address)
                {
                    writer.WriteStartArrayMember("address");
                    AddressSerializer.SerializeAddress(item, writer);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }

            // Serialize element photo
            if (value.Photo != null && value.Photo.Count > 0)
            {
                writer.WriteStartArrayElement("photo");
                foreach (var item in value.Photo)
                {
                    writer.WriteStartArrayMember("photo");
                    AttachmentSerializer.SerializeAttachment(item, writer);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }

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

            // Serialize element language
            if (value.Language != null && value.Language.Count > 0)
            {
                writer.WriteStartArrayElement("language");
                foreach (var item in value.Language)
                {
                    writer.WriteStartArrayMember("language");
                    DemographicsSerializer.SerializeDemographicsLanguageComponent(item, writer);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }


            writer.WriteEndComplexContent();
        }