public static void SerializeImagingStudy(Hl7.Fhir.Model.ImagingStudy value, IFhirWriter writer, bool summary)
        {
            writer.WriteStartRootObject("ImagingStudy");
            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 language
            if (value.LanguageElement != null && !summary)
            {
                writer.WriteStartElement("language");
                CodeSerializer.SerializeCode(value.LanguageElement, writer, summary);
                writer.WriteEndElement();
            }

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

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

            // Serialize element dateTime
            if (value.DateTimeElement != null && !summary)
            {
                writer.WriteStartElement("dateTime");
                FhirDateTimeSerializer.SerializeFhirDateTime(value.DateTimeElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element subject
            if (value.Subject != null && !summary)
            {
                writer.WriteStartElement("subject");
                ResourceReferenceSerializer.SerializeResourceReference(value.Subject, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element uid
            if (value.UidElement != null && !summary)
            {
                writer.WriteStartElement("uid");
                OidSerializer.SerializeOid(value.UidElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element accessionNo
            if (value.AccessionNo != null && !summary)
            {
                writer.WriteStartElement("accessionNo");
                IdentifierSerializer.SerializeIdentifier(value.AccessionNo, writer, summary);
                writer.WriteEndElement();
            }

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

            // Serialize element modality
            if (value.Modality_Element != null && !summary && value.Modality_Element.Count > 0)
            {
                writer.WriteStartArrayElement("modality");
                foreach (var item in value.Modality_Element)
                {
                    writer.WriteStartArrayMember("modality");
                    CodeSerializer.SerializeCode <Hl7.Fhir.Model.ImagingStudy.ImagingModality>(item, writer, summary);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }

            // Serialize element referrer
            if (value.Referrer != null && !summary)
            {
                writer.WriteStartElement("referrer");
                ResourceReferenceSerializer.SerializeResourceReference(value.Referrer, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element availability
            if (value.AvailabilityElement != null && !summary)
            {
                writer.WriteStartElement("availability");
                CodeSerializer.SerializeCode <Hl7.Fhir.Model.ImagingStudy.InstanceAvailability>(value.AvailabilityElement, writer, summary);
                writer.WriteEndElement();
            }

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

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

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

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

            // Serialize element procedure
            if (value.Procedure != null && !summary && value.Procedure.Count > 0)
            {
                writer.WriteStartArrayElement("procedure");
                foreach (var item in value.Procedure)
                {
                    writer.WriteStartArrayMember("procedure");
                    CodingSerializer.SerializeCoding(item, writer, summary);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }

            // Serialize element interpreter
            if (value.Interpreter != null && !summary)
            {
                writer.WriteStartElement("interpreter");
                ResourceReferenceSerializer.SerializeResourceReference(value.Interpreter, writer, summary);
                writer.WriteEndElement();
            }

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

            // Serialize element series
            if (value.Series != null && !summary && value.Series.Count > 0)
            {
                writer.WriteStartArrayElement("series");
                foreach (var item in value.Series)
                {
                    writer.WriteStartArrayMember("series");
                    ImagingStudySerializer.SerializeImagingStudySeriesComponent(item, writer, summary);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }


            writer.WriteEndComplexContent();
            writer.WriteEndRootObject();
        }
        public static void SerializeImagingStudySeriesComponent(Hl7.Fhir.Model.ImagingStudy.ImagingStudySeriesComponent 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 number
            if (value.NumberElement != null)
            {
                writer.WriteStartElement("number");
                IntegerSerializer.SerializeInteger(value.NumberElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element modality
            if (value.ModalityElement != null)
            {
                writer.WriteStartElement("modality");
                CodeSerializer.SerializeCode <Hl7.Fhir.Model.ImagingStudy.Modality>(value.ModalityElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element uid
            if (value.UidElement != null)
            {
                writer.WriteStartElement("uid");
                OidSerializer.SerializeOid(value.UidElement, writer, summary);
                writer.WriteEndElement();
            }

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

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

            // Serialize element availability
            if (value.AvailabilityElement != null)
            {
                writer.WriteStartElement("availability");
                CodeSerializer.SerializeCode <Hl7.Fhir.Model.ImagingStudy.InstanceAvailability>(value.AvailabilityElement, writer, summary);
                writer.WriteEndElement();
            }

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

            // Serialize element bodySite
            if (value.BodySite != null)
            {
                writer.WriteStartElement("bodySite");
                CodingSerializer.SerializeCoding(value.BodySite, writer, summary);
                writer.WriteEndElement();
            }

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

            // Serialize element instance
            if (value.Instance != null && value.Instance.Count > 0)
            {
                writer.WriteStartArrayElement("instance");
                foreach (var item in value.Instance)
                {
                    writer.WriteStartArrayMember("instance");
                    ImagingStudySerializer.SerializeImagingStudySeriesInstanceComponent(item, writer, summary);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }


            writer.WriteEndComplexContent();
        }
        public static void SerializeImagingStudySeriesInstanceComponent(Hl7.Fhir.Model.ImagingStudy.ImagingStudySeriesInstanceComponent 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 number
            if (value.NumberElement != null)
            {
                writer.WriteStartElement("number");
                IntegerSerializer.SerializeInteger(value.NumberElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element uid
            if (value.UidElement != null)
            {
                writer.WriteStartElement("uid");
                OidSerializer.SerializeOid(value.UidElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element sopclass
            if (value.SopclassElement != null)
            {
                writer.WriteStartElement("sopclass");
                OidSerializer.SerializeOid(value.SopclassElement, writer, summary);
                writer.WriteEndElement();
            }

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

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

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

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


            writer.WriteEndComplexContent();
        }
 internal static void SerializeElement(Element value, IFhirWriter writer, bool summary)
 {
     if (value.GetType() == typeof(Hl7.Fhir.Model.Address))
     {
         AddressSerializer.SerializeAddress((Hl7.Fhir.Model.Address)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Attachment))
     {
         AttachmentSerializer.SerializeAttachment((Hl7.Fhir.Model.Attachment)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Choice))
     {
         ChoiceSerializer.SerializeChoice((Hl7.Fhir.Model.Choice)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.CodeableConcept))
     {
         CodeableConceptSerializer.SerializeCodeableConcept((Hl7.Fhir.Model.CodeableConcept)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Coding))
     {
         CodingSerializer.SerializeCoding((Hl7.Fhir.Model.Coding)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Contact))
     {
         ContactSerializer.SerializeContact((Hl7.Fhir.Model.Contact)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Extension))
     {
         ExtensionSerializer.SerializeExtension((Hl7.Fhir.Model.Extension)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.HumanName))
     {
         HumanNameSerializer.SerializeHumanName((Hl7.Fhir.Model.HumanName)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Identifier))
     {
         IdentifierSerializer.SerializeIdentifier((Hl7.Fhir.Model.Identifier)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Narrative))
     {
         NarrativeSerializer.SerializeNarrative((Hl7.Fhir.Model.Narrative)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Period))
     {
         PeriodSerializer.SerializePeriod((Hl7.Fhir.Model.Period)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Quantity))
     {
         QuantitySerializer.SerializeQuantity((Hl7.Fhir.Model.Quantity)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Range))
     {
         RangeSerializer.SerializeRange((Hl7.Fhir.Model.Range)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Ratio))
     {
         RatioSerializer.SerializeRatio((Hl7.Fhir.Model.Ratio)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.ResourceReference))
     {
         ResourceReferenceSerializer.SerializeResourceReference((Hl7.Fhir.Model.ResourceReference)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.SampledData))
     {
         SampledDataSerializer.SerializeSampledData((Hl7.Fhir.Model.SampledData)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Schedule))
     {
         ScheduleSerializer.SerializeSchedule((Hl7.Fhir.Model.Schedule)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Base64Binary))
     {
         Base64BinarySerializer.SerializeBase64Binary((Hl7.Fhir.Model.Base64Binary)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.FhirBoolean))
     {
         FhirBooleanSerializer.SerializeFhirBoolean((Hl7.Fhir.Model.FhirBoolean)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Code))
     {
         CodeSerializer.SerializeCode((Hl7.Fhir.Model.Code)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Date))
     {
         DateSerializer.SerializeDate((Hl7.Fhir.Model.Date)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.FhirDateTime))
     {
         FhirDateTimeSerializer.SerializeFhirDateTime((Hl7.Fhir.Model.FhirDateTime)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.FhirDecimal))
     {
         FhirDecimalSerializer.SerializeFhirDecimal((Hl7.Fhir.Model.FhirDecimal)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Id))
     {
         IdSerializer.SerializeId((Hl7.Fhir.Model.Id)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.IdRef))
     {
         IdRefSerializer.SerializeIdRef((Hl7.Fhir.Model.IdRef)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Instant))
     {
         InstantSerializer.SerializeInstant((Hl7.Fhir.Model.Instant)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Integer))
     {
         IntegerSerializer.SerializeInteger((Hl7.Fhir.Model.Integer)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Oid))
     {
         OidSerializer.SerializeOid((Hl7.Fhir.Model.Oid)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.FhirString))
     {
         FhirStringSerializer.SerializeFhirString((Hl7.Fhir.Model.FhirString)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.FhirUri))
     {
         FhirUriSerializer.SerializeFhirUri((Hl7.Fhir.Model.FhirUri)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Uuid))
     {
         UuidSerializer.SerializeUuid((Hl7.Fhir.Model.Uuid)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.XHtml))
     {
         XHtmlSerializer.SerializeXHtml((Hl7.Fhir.Model.XHtml)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Age))
     {
         QuantitySerializer.SerializeQuantity((Hl7.Fhir.Model.Age)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Count))
     {
         QuantitySerializer.SerializeQuantity((Hl7.Fhir.Model.Count)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Distance))
     {
         QuantitySerializer.SerializeQuantity((Hl7.Fhir.Model.Distance)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Duration))
     {
         QuantitySerializer.SerializeQuantity((Hl7.Fhir.Model.Duration)value, writer, summary);
     }
     else if (value.GetType() == typeof(Hl7.Fhir.Model.Money))
     {
         QuantitySerializer.SerializeQuantity((Hl7.Fhir.Model.Money)value, writer, summary);
     }
     else
     {
         throw new Exception("Encountered unknown type " + value.GetType().Name);
     }
 }